I'm trying to get started with microsoft's azure sphere development.
When I try to debug any of the starter projects within vs code, it tells me that I have a breakpoint set on the first line of the app.
However, vs code doesn't show any breakpoints in the "Breakpoints" tab.
I am running the latest VS code version (1.44) with the Azure Sphere Extension 20.1 on windows 10. The same problem appears on Linux.
To reproduce the bug:
Download the starter projects from github
Install the Azure sphere extension for visual studio code.
open HelloWorld_HighLevelApp folder in azure-sphere-samples\Samples\HelloWorld\HelloWorld_HighLevelApp in visual studio code.
Go to the Debug tab and hit the green play button on top left corner. Next to the button it should say Launch for Azure Sphere High-Level Applications (gdb)
For me it doesn't an error but the output console shows:
Deploying image...
Starting debugger....
Process /mnt/apps/1689d8b2-c835-2e27-27ad-e894d6d15fa9/bin/app created; pid = 2233
Listening on port 2345
Remote debugging from host 192.168.35.1, port 54911
Starting CMake Hello World application...
The Debug Console shows:
...
Breakpoint 1, main () at ../../main.c:45
45 {
Loaded 'target:/usr/lib/libapplibs.so.0'. Symbols loaded.
Loaded 'target:/lib/libgcc_s.so.1'. Symbols loaded.
Loaded 'target:/usr/lib/libc++runtime.so.1'. Symbols loaded.
Is there a work around / a plan to fix the issue?
Addition 1:
To provide extra clarification here is a screenshot, showing the miss match of console output (breakpoint set) and ui (no breakpoint set)
Azure Sphere uses gdbserver to provide a debug channel to the device. A default behavior of gdb is to break on entering main. This can be confusing to people on Windows who expect a run to breakpoint behavior as is common in Visual Studio. For our interface with GDB we intentionally silently skip the breakpoint on entering main in Visual Studio to be consistent. You can actually see that breakpoint skipped in the debug log output window.
For VS Code we also skip the breakpoint on main when you are on Windows. It looks like you are on Linux from the output above. I haven't used it on Linux for a few weeks so can't recall if the behavior is intentionally different there or not. It would make sense to me to break on entering to main when on Linux as that is the common expectation when using GDB which is more common there than on Windows. I'll check if this is by design or not and reply back, but I suspect it is.
Solution:
Finally I found the root cause of the issue. Visual studio code acts just slightly different when debugging the sphere device compared to just plain c code.
When you start the debugging mode and you haven't set a breakpoint initially, it won't start running your program till you have set a breakpoint. In plain c debugging the program just runs through and printed values are shown in the debug console.
Related
I'm using Visual Studio 2017 to develop a C++ app on a remote Linux machine. First, I run my code on the remote machine and then attach to the remote process using SSH. I attach to Native (GDB) code and hit my breakpoint. The problem is that I can't view the contents of a string received in the debugger.
std::string msg_str(static_cast<char*>(incoming.data()), incoming.size());
The string above is retrieved via ZeroMQ message. If I do a QuickWatch on msg_str, none of the values are in a human readable form.
What I expect to see is:
{"message":"mark","color":"#FFAABB","session_id":"XVg32B","x":34,"y":563}
What do I need to do in order to view this in the VS2017 debugger?
edit
No I'm not compiling with VS. I'm developing a game using the Urho3D engine. On the Linux box I use cmake to create the makefile and then compile/link using make from a SSH bash shell. In VS I get all kinds of build errors.
I've been searching high and low for more information on how to set this project up, to no avail. My biggest problem is that I'm a C# developer trying to come up to speed with C++. The learning curve is pretty steep...
I think the problem is that you've attached to the remote process and VS doesn't know that it's supposed to be looking at a std::string. Are you able to run your test by building then executing from within VS? Does VS know that the source it can see is what's running in the debugger?
It looks like at least some of the string is visible in QuickWatch as _M_p. The result you expect doesn't appear to be a simple string, could this have a bearing?
I just tried inspecting std::string ss ("12345", 5) in QuickWatch in VS2017 (15.7.3) and the string is displayed exactly as you would expect. But I did compile and run (F5) from VS.
========= 18 June
You can create a makefile project in VCLinux very easily. Add a new project to your solution and choose Visual C++ - Cross Platform - Linux - Makefile Project. Then copy your sources and makefile into the newly created project directory and add them to the VS project. In the project settings, set the Remote Build commands, e.g. cd $(RemoteProjectDir);make debug and under Debugging set the remote command you want executed.
Depending on how complex your project is, it might be worth creating a very simple, stand-alone test to try out remote building and debugging to verify that you can set a breakpoint and correctly visualise a string.
Not the perfect solution, but I do msg_str.c_str() in the immediate window. Probably wouldn't work well for anything beyond the 7bit ascii subset of utf.
I have a C++ application (it's built using Qt 5.8 library and works with PostgreSQL 9.5 database in case it's relevant). The application is build by MSVC 2012 compiler, is 64-bit application and both debug and release versions run normally on their own and under cdb debugger.
When I try to profile the running application by Visual Studio instrument (Analyze -> Profiler -> Attach), it seemingly hangs as soon as it tries to do something meaningful: simply resizing a window or clicking on checkboxes works, but any attempt to compute new values and write them to database never succeeds, as if control flow didn't return from some call.
When I stop the profiling, Studio marks as a "hot path" sequence of calls RtlWalkFrameChain->RtlpWalkFrameChain->RtlpLookupFunctionEntryForStackWalks->RtlLookupFunctionTable->RtlAcquireSRWLockShared.
RtlpWalkFrameChain has the biggest "exclusive samples" count.
Trying to filter data to exclude initial several seconds of run (until the apparent freeze) results in "No Call Tree Data Is Available" message.
I didn't manage to find any article or post with a similar problem.
The project is build in Qt Creator (I don't have a project file Studio would understand, so I can't run "normal" performance analysis).
OS is Windows 7, exact version of Visual Studio is 11.0.61219.00 Update 5.
Any idea on the subject would be welcome.
Upd: When I try to profile the application with Luke Stackwalker profiler, it aborts with the message ERROR: StackWalk64-Endless-Callstack!. The only relevant comment about the message I found is this Stackoverflow question. When I run application under cdb debugger and then try to profile it with Luke Stackwalker, the error message is the same, but subsequent pause in the debugger shows the proper (or at least believable) stack for all threads. For the working thread debugger points to a line of code inside system library and doesn't advance no matter what I do (once again, without profiling attempts the application runs normally, debugger or not).
I am working on this node.js application using Visual Studio Code IDE. Everytime I run this application, it is attaching a debugger (which takes around 2-5 seconds) and then executing the application.
So, my issue is everytime if I modify some code (or a simple variable name) and execute the program, it takes this much time to see the output even though I haven't set any breakpoints.
Need help in disabling the debugger in Visual Studio Code IDE for node applications development. I can't find anything helpful on net :( .
There is workbench.action.debug.run which is bound to cmd+f5 / ctrl+f5 by default.
You can find it in the command palette under the name "Debug: Start without Debugging"
Inside the VsCode terminal, I've switched the terminal to zsh instead of the JS Debug Console and it fixed it:
Screenshot of the terminal's dropdown
You can just switch from "Javascript Debug Terminal" to "powershell" (command terminal). it doesn't attach the debugger again
consider passing the option below on settings.json
"debug.javascript.autoAttachFilter": "onlyWithFlag"
with this option, you will always need to pass ---inspect option to start debugging mode. otherwise, it will always start normal running mode.
The cluster debugging option is removed from Visual studio 2012.
So is there any way to debug MPI apps in VS2012 ?
Visual studio 2012 and later versions do not support MPI debugging. However there is a workaround:
Start debugging by specifying mpiexec.exe as your command and related parameters and the name of your executable as command arguments:
Command-> mpiexec.exe
CommandArguments-> -n 2 myapp.exe
When the execution starts, use Debug->Attach to process... to attach the debugger to one your processes. Sometimes I add a simple press any key to continue logic to my app, just to pause the program until I finish this attaching process.
In order to ease tings you can use an extension called Reattach that lets you attach to the last processed you attached with one button click.
One problem with this workaround is that you cannot select which MPI process you attach :(
I have an .exe that crashes in release mode. I want to debug where the crash occurs.
How can I use VC++ to debug a crash in a release-mode .exe?
You can run Visual Studio and attach it to a process to debug.
Also check through the Windows Event Viewer (an often overlooked source of information) for any exceptions that Windows may have caught.
Firstly if you have access to the code you can open the workspace in visual studion and debug it by pressing F5 button.
Secondly go through the steps that leads to the crash. At that point of time check the location pointed to by the call stack.
This will give you indication on the funciton or line where crash is occuring.
We are assuming this application was written in VC++. How often are you able to reproduce this issue. Is it like everytime you can reproduce it or how is it.