Debugging a solution and the test output is visible for less than a second - c++

I'm having a problem with visual studio. I'm trying to run a unit test using the Google test framework and the output keeps flickering on for a sec and disappearing. How do I keep the output the executable shows on the screen so that I can see the results of the test?
It worked previously but I changed some of the settings (can't remember what) and now it just flickers on and off.

Run it with Debug > Start Without Debugging (Ctrl+F5) rather than Start Debugging (F5). When you do that, the IDE keeps the console open and waits for a key press after the program exits.

Related

Visual studio 2017 debug console saying "ops"

First off, i haven't been coding or using Visual studio for super long so please explain in details so i can follow. Thanks!
Every time i try to run any code i get the message "ops" in the debug window. I disabled my antivirus(windows defender) and reinstalled a bunch of times. I get the same issue using Visual studio 2019. Anyone have ideas ?
I tried a bunch of different codes and even the default hello world that the Windows Console Application gives you isn't running.
Please check for the existence of one of the following registry keys.
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun
If they exist and are not expected, please remove. They may be created by malware, so you may need to use an antivirus product to remove the unwanted software.
Step 1: Add a breakpoint at the top of your program.
Step 2: Enlarge the tiny console window to a normal size.
Step 3: Click "Continue" on the debugger.
Step 4: "ops" turns into "To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops."

How to ignore breakpoints in DLLs in Visual Studio

I'm using a 3rd party dll with no source code available. It runs perfectly fine, but every time I run my program, an annoying pop-up says "MyProgram.exe has triggered a breakpoint".
If I press continue, my program runs 100% correctly.
If I press break, I can see that the breakpoint is occurring in the 3rd party file alp41basic.dll
I have no clue why they put breakpoints in their dll. How can I disable them?
My question is identical to one that went unanswered:
https://stackoverflow.com/questions/17514072/is-there-a-way-to-make-visual-studio-continue-when-an-exception-occurs-on-a-line
I eventually checked in with the company that distributed the dll, and indeed there are breakpoints in there for reasons that I won't get into. However, if I run the program outside the debugger (even simply open the binary from windows), these popup windows do not occur.
Thank you all for your help!

How can I stop the Visual Studio Test Runner when a test hangs

When a test hangs in a loop, the small green progress bar in the test runner does not proceed, but there is no way to stop the test run. Or is there?
VS 2013
Edit: This occured when using the XUnit TestRunner. The Cancel button simply did not show up. After testing various test runners in a new solution, it turned out, that it works with all of them. Finally it also worked with my original solution. So there was some anomaly in the state of my VS environment that caused cancel to disapper.
You can click "Cancel" in Test Explorer:
Show Test Explorer by going to TEST > Windows > Test Explorer.
This is in Visual Studio 2013.
Instructions for other versions of VS can be found here
Sorry for waking up an old thread:)
just wanted to share my solution here, I had the same issue on VS 2015.
There is some text below the search input just where the cancel should appear (take a look at #Codeman print screen), the text is actually some description on how you can setup a build for your tests, the text is several lines and at the end you have "do not show this any more" just press it and then the cancel button appears:)
Very strange bug, sorry I do not have some print screens of this
hope it helps someone
VS2015. If the hanging tests are executables instead of DLLs you need to kill those tests in the task manager. You need to close the Test Explorer Window to prevent automatic running. While the tests are running/hanging you will not be able to compile the according project.
For me the solution was to go to Task Manager, locate chromedriver and end the task.
Visual Studio 2022 Professional version 17.2.3.
I have found the solution to this issue. To stop the run after cancel is pressed, just set the 'Terminate process on cancel' option to True.

Dubugging a program not run within the debugger and without a crash

I left a program running last night, it worked fine for about 5 hours and then one of its built-in self-diagnostic tests detected a problem and brought up a dialog box telling me the issue. The program was built with debug information (/Zi). Is it possible to somehow get the debugger started so I can examine the value of some variables within the program? Or is it too late?
You can attach the debugger to the running process:
Debug > Attach to Process...
Just open up the program's solution first.
Assuming you've still got the error dialog on the screen you can break into the program and work back up the call stack examining variables etc.
For the future crashes ... if you have windbg or Visual Studio Professional, you can debug crash dumps, even when program isn't running. It is quite useful sometimes. See "MiniDumpWriteDump" on MSDN for more info.
Other than that it is "Attach to process".
Professional edition of Visual Studio have Just-in-Time debugger, that will kick in as soon as anything crashes, even if MSVC wasn't running. It will also locate source code (if debug info and source code are available) and open/create solution for you.
There is an option in the Debug menu to attach the debugger to a running process, IIRC.

Eclipse C++ - output to window DOS

I am using Eclipse with C++. When I run the program, I get the following message in my Console window:
**** Build of configuration Debug for project Disks Repulsion ****
**** Internal Builder is used for build ****
Nothing to build for Disks Repulsion
I makes changes to the program and run it again, and this time I get following message:
**** Build of configuration Debug for project Disks Repulsion ****
**** Internal Builder is used for build ****
g++ -oDisksRepulsion.exe DisksRepulsion.o -lopengl32 -lglu32 -lglut32
C:\MinGW\bin..\lib\gcc\mingw32\3.4.5........\mingw32\bin\ld.exe: cannot open output file DisksRepulsion.exe: Permission denied
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 103 ms.
When I first ran the program, it started my program (I can see it running in my Window Task Manager), but there is no output being sent to the console.
After making changes to my program, the program is still running in the background, so I get the "Permission denied" error, when I try to run the program. I can make the error go away by ending the instances via task manager. However, when I run the program, I still don't see any output being sent to the console.
Yesterday, I was able to see the output in my console, but don't know why I cannot see it today. Also, when I saw my output, the cursor's focus did not change from the code to the console. I dislike having to do it manually.
I also don't like that when I make changes to my program, and run it again, that the program is not automatically terminated on its own.
I have used VC++ and I prefer the window Dos for output. So, I wanted to know if there is anyway in Eclipse to send the output to Windows Command Prompt, since I know that the instance of the .exe is really gone when I close the program. It automatically gets cursor's focus. I will also be able to get some output.
I installed MinGW with MaSYS or something, to compile the program.
It sounds like your application isn't terminating on its own and you didn't build in any sort of interface that would allow you to kill the program. This sounds like a bug in your code and not an Eclipse issue. If issuing a Ctrl+C in the console won't kill your program, then look into coding something that will let you kill your app with keystroke or input sequence.
If you want to run your app in a command console, then open a normal command console, browse to the folder containing your project, and run the compiled executable from the console instead of doing it through the Eclipse interface.
A simple solution, which I've been using for ages now, is opening a command prompt yourself and running the executable manually. An advantage of this method is that you can set your "DOS" window's size to anything you want. (Right now I'm using a 120x50 window with 8192 lines of scrollback buffer.) Another one is that you will never lose your console output; in fact, you'll be able to see outputs from past runs. (8192 lines is A LOT unless you're printf-debugging a tight loop.)
An alternative to terminating your program from the taskbar is using the red icons on the top right corner of the Eclipse "Console" window.
Is your program's entrypoint main() or WinMain()? There may also be a setting/link option for the "subsystem," console or Windows I think they're called in Visual Studio.
Anyway, if your program is starting up via WinMain, the expectation is that you'll have a Windows form of some sort through which the user can control the program. If you use main(), then your program should automatically trigger the opening of a console window.
Look up AllocConsole() on MSDN (or google it) if you are using WinMain() intentionally and want a console window to also open up. There's some trickery also available via google search that can hook stdout to this console, but at this time I don't remember what it is. (You basically redirect the stdout handle to your new console.)
Good luck.