Xamarin: How do you set a breakpoint in a simple C++ project? - c++

I am new to Xamarin Studio. I am trying to set a breakpoint in a C++ project's automatically created main.cpp file, which contains a hello world line only. I am on Xamarin Studio Community 5.10.3 (build 51) on Mac. The solution is created from a template in Other->Miscellaneous->C/C++->Console Project->CPP. While debugging I am setting a breakpoint but execution won't stop at the breakpoint. How to make the debugger to stop there?

There should be two options to run the program, "Start Without Debugging" and "Start With Debugging" under the "Run" toolbar at the top. You must use the second option to have the program stop at the breakpoint. Are you running the program with the little "run" arrow icon? If so, that starts the program without the debugger. You must select the "Start With Debugging" option under the "Run" toolbar.

Related

How to let the c++ output in the vc code terminal

When I run a C++ program in vs code, it alway pops up a new window. Are there any ways to let the program output to the inner terminal (or output window) of vs code, instead of the annoying pop up window?
In VS-Code you configure the build/run in the tasks.json, and the debug in the launch.json (all configuration files go under ${workspaceFolder}/.vscode/).
You can set a keyboard shortcut for each task or for debug. For example my default build task is run with Ctrl+Shift+Band debug starts with F5. More info on how to set build/run/debug in VS-Code:
https://code.visualstudio.com/docs/languages/cpp
And as shingo mentioned depending on the externalConsole flag you can control if a new terminal window pops up or not.

how to set VSCode when i execute a c++ program the screen doesn't disappear immediately

I know i can use "system pause" or "getchar" to make the screen doesn't disappear immeadiately when i use VSCode to execute my c/c++ program,but it's really troublesome.I want to know if i could let the program pause automaticly just like
VS and other IDE.
VSCode have the Intergrated terminal (Ctrl + `), you can run and see console output there.
Even in Visual Studio C++, if you do not set break point, the console app will terminate and disappear when reach return 0 in main.

How to enable instruction stepping in eclipse-cdt (Eclipse for C++) by default?

I repeatedly debug a program in Eclipse CDT in instruction stepping mode, i.e. a "step over" causes the next assembler/machine code instruction to be executed rather than the next line of C/C++ code.
Because I do it over and over again, it nags me to have to press the "instruction stepping" button again for every execution. Is there a way to enable it by default? I tried to find it in the debug configuration settings of the program that I debug, but I didn't find it there.
By default local launch is using new debugging framework called DSF which
does not remember this settings (at least in mars), however old one did remember it.
You can switch to old one using the following steps:
Open launch configuration
Click on link at the bottom to switch Launcher (on any page)
Select "Legacy Create Process Launcher"
If you use this one now if you press instruction stepping mode it will remember it for the next session

Stop eclipse CDT from debugging from main()?

If I debug my C++ code using eclipse CDT, it appears that it always starts the debugging process from the main() function, even though there is no breakpoint at the beginning of the main().
Is there a way to have eclipse CDT start to debug from the first breakpoint rather than main()?
On the menu Run -> Debug Configurations, right click the C/C++ Applications item on the left, and create New configuration. Go to the Debugger tab and uncheck the Stop on startup at checkbox.
Open "Debug Configurations" GUI
Choose your application
Select "Debugger" tab
Uncheck "Stop on startup at main"

Run .exe outside IDE but use break points inside IDE

Using VS .NET 2003. Would like to run the .exe from outside the IDE (i.e. command prompt or double clicking .exe icon in windows) However, still want break points to hit in the IDE.
How do I set this up?
(Running from outside IDE but IDE seeing it as run from "Debug" -> "Start")
Thanks.
On the Debug menu, choose the "Attach to process" option to attach a debugger to your externally-running application.
Visual Studio enables Just In Time Debugging by default. If you haven't turned it off you can call DebugBreak() and you will get a popup allowing you to attach a debugger. If you don't attach a debugger then the program will exit, so you could try wrapping the DebugBreak call in a MessageBox or some other conditional code based on an environment variable or config item.
Since it is C the call to DebugBreak() is correct - this will give you a nasty error dialog (different look depending on the OS), which should have a 'Debug' option. If you click this you should get a dialog to select one of the installed debuggers (VS.NET shoud be among them). Selecting it should bring you to the DebugBreak() line. However this can fail if the debugger can not find the pdb files for your app - in that case you will just get the disassembly view and no source code view.
You can also use WinDBG and the 'Open executable option' - again it will need the pdb files to yield anything useful.