webfreak001 / code-debug Goto Github PK
View Code? Open in Web Editor NEWNative debugging for VSCode
License: The Unlicense
Native debugging for VSCode
License: The Unlicense
My source code is reasonably colorized, but there is no error detection, no "Show definition," etc., that I can see. What does it take to make that work for C/C++ programs?
This is awesome! Please consider hooking up WinDBG too?
MSVC, Clang, DMD, and LDC all produce MS compatible COFF/PDB output in Windows, and LLDB can't really debug that yet.
By doing this you will also solve the debug situation for Windows C++ developers; by far the largest native developer community, and they have no debug solution yet.
Hello, I try to use the debug extension to debug a helloworld C program, but I can not find any output of the program being debugged, although breaks and watches of gdb works. The vscode Output window only have git and tasks results which is the output of the make program, and the Debug Console window only have gdb debug info output. Please help!
The command version gdb 7.11 works all right at Mac OSX10.10.5 machine, and output "hello, world! the value = 100" in the end:
jasmine:vscodetes$ gdb helloworld
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin14.5.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from hello world...Reading symbols from /Users/z01/work/vscodetest/helloworld.dSYM/Contents/Resources/DWARF/helloworld...done.
done.
(gdb) run
Starting program: /Users/z01/work/vscodetest/helloworld
warning: `/BinaryCache/coreTLS/coreTLS-35.40.1~1/Objects/coretls.build/coretls.build/Objects-normal/x86_64/system_coretls_vers.o': can't open to read symbols: No such file or directory.
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.40.1~1/Symbols/BuiltProducts/libcoretls_ciphersuites.a"
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.40.1~1/Symbols/BuiltProducts/libcoretls_handshake.a"
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.40.1~1/Symbols/BuiltProducts/libcoretls_record.a"
warning: Could not open OSO archive file "/BinaryCache/coreTLS/coreTLS-35.40.1~1/Symbols/BuiltProducts/libcoretls_stream_parser.a"
hello, world! the value = 100[Inferior 1 (process 639) exited normally]
If submitting a bug please make sure
gdb --version
>= 7.7.1gdb
cwd
and target
are properly setScreenshots are helpful but not required
Don't know this is by design, but it appears that the autorun commands go off twice.
1-gdb-set target-async on
2-environment-directory "c:\\dev\\abc/out/obj"
3-target-select remote localhost:4444
undefined=thread-group-added,id="i1"
Reading symbols from c:\dev\abc/out/use/A_Myriad_A_5_9.elf...
done.
Not implemented stop reason (assuming exception): undefined
target remote localhost:4444
monitor interface=0
monitor port=0
monitor speed=500000
monitor type=0
monitor unit=2
monitor connect
4-stack-list-frames 0 20
target remote localhost:4444
A program is being debugged already. Kill it? (y or n) [answered Y; input not from terminal]
Remote debugging using localhost:4444
0x0000a408 in CanOpen_GetSetS16 (WriteBOOL=0 '\000', DataU8Ptr=0xa401 "") at CanOpenDef.h:132
132 else { ((U16Type*)CanOpenDataU8Ptr)->DataU16 = (U16)*VarS16Ptr; }
Not implemented stop reason (assuming exception): undefined
monitor interface=0
monitor port=0
monitor speed=500000
5-stack-list-frames 0 20
monitor type=0
monitor unit=2
monitor connect
Failed to run command `stack-list-frames 0 20`: Cannot access memory at address 0x4
An error occured: Cannot access memory at address 0x4
Failed to run command `stack-list-frames 0 20`: Cannot access memory at address 0x4
An error occured: Cannot access memory at address 0x4
In order for this to work, it appears that the extension needs to support
/** The debug adapter supports a (side effect free) evaluate request for data hovers. */
supportsEvaluateForHovers?: boolean;
microsoft/vscode#2745 (comment)
https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/debug/common/debugProtocol.d.ts#L489
See #3
Not on the clear on what I should change "target" to. I assume the final executable?
I'm actually looking for remote GDB debugging. Perhaps this is the wrong plugin for me?
When using ARM GDB the call stack rarely displays any information on breakpoints/pause. have not been able to pinpoint when it does work
Reopening as the issue is not resolved.
Please do not close as I will as soon as it's resolved
I have no IntelliSense extensions loaded yet. While stopped at a breakpoint in my C program, if I move the mouse over various words in the program, I get warning messages in the debug console. Notice for example that the word "negative" was from a /* comment */, so it shouldn't try to get its value!
Hovering over a variable name that has a value does seem to work - it (Code or code-debug) shows the value in a hover message.
This might be considered a user error, because what I did was install code-debug a second time, rather that uninstalling and reinstalling, or updating. I didn't read far enough in the installation instructions. :-)
However, I would suggest that code-debug (or perhaps VS Code itself) should check if the user is trying to reinstall, and give some more user-friendly error handling.
Attached is the output I got on my xterm, when I started Code, then tried to reinstall code-debug. Note that the first few lines, down to and including "bash: no job control in this shell" happen every time I start Code. That's probably a separate issue, but if someone knows how to fix that, please let me know.
Il looks like README.md
images URLs from your website are broken.
Relying on external sources makes the content your Git commits dependent of those sources. This implies a lot of considerations such as high-availability and concurrent version management.
As an example, it is impossible for contributors to update screen captures without access on i.webfreak.org.
IMO, you should directly add them into your repository and use relative URLs to display their content in the README.md
file.
It does not breaks the page displayed on the marketplace.
For a real-world example, see:
lldb-mi
(tried frame variables
)cwd
and target
are properly setScreenshots are helpful but not required
I am trying to use VSCode 1.0 with your extension on OS X El Capitan, VS Code does not show local variables when VS Code hit breakpoint.
When I pause process from VSCode - I see local variables, but only simple values, not structures, all structures show <unknown>
and Could not expand variable
.
If submitting a bug please make sure
lldb --version
is apple versionlldb-mi
Xcode command tools won't provide lldb-mi
, but this command is shipped with Xcode.app
just one command can make OS X user use this extension.
ln -s/Applications/Xcode.app/Contents/Developer/usr/bin/lldb-mi /usr/local/bin/lldb-mi
And how to configure launch.json
to make it support breakpoint?
I would love a way to examine memory locations with GDB (ARM GDB) via the "x adr" command. by manually entering in locations and lengths, or even better by expanding pointers.
"executable": "./Sw/A_XMC/out/use/A_Myriad_A_5_6.elf"
successfully parses all symbols and I am able, through the Debug Console, to read variables using p SymbolName
which means they're all there.
Shouldn't they appear in the variables list on the left? I can manually add Watch expressions and reference variables just fine.
For some reasons, I need to execute an extra command (loading an appropriate execution environment on the target machine) before executing GDB over SSH.
Could it be possible to add an extraCommands
options in the config which would contains the commands to execute on the remote machine (within the same SSH session than GDB) before calling GDB?
I added "preLaunchTask": "make"
to launch.json and
{
"version": "0.1.0",
"command": "make",
"isShellCommand": false,
// Show the output window only if unrecognized errors occur.
"showOutput": "always", //"silent",
// use the standard tsc problem matcher to find compile problems
// in the output.
"problemMatcher": "$tsc"
}
in tasks.json and now make runs each time I click start, which is pretty good. But,
undefined=thread-group-added,id="i1"
). I'd like the output window to remain visible if there are make errors.I would suggest you provide a more extensive launch.json and a tasks.json file tailored to C/C++ development and with some comments, similar to the default tasks.json file. That would enable new users to get started more quickly.
Please include a license with the source code. Preferably the same license that Visual Studio Code uses
Breakpoints can be set or cleared using the Code UI, but the change has no effect until the next time the Start button is clicked in Code.
For example, I can set some breakpoints through the Code UI, click Start, and Code will stop when a breakpoint is hit. But if I clear the breakpoint via Code UI and then continue, the program will continue to stop at that breakpoint location. Or if I set a new breakpoint during the pause and then continue, Code won't stop at the new breakpoint.
It seems as if Code updates gdb's breakpoints only at Start time, not during pauses.
Or maybe it's another case of improper argument passing to gdb. If I type enable or disable on the input line of the debug console while paused, breakpoints are enabled or disabled as expected. But if type disable th.c:1403
, I get a message in the debug console: Bad breakpoint number 'th'
and the breakpoint isn't disabled.
Hi,
I tried to look around the configurations but I couldn't find a straightforward way to use gdb from a different toolchain (arm-none-eabi
in my case), is it possible? If not, could it be made possible to configure which gdb executable to use? This would be useful when performing remote debugging on different architectures.
Hi,
Could you provide a quick How-to on how to debug your debugging adapter. I've been trying to debug it on OSX after adding rust support but I can't manage to have the gdb debugger recognized once launched in debug mode.
Thanks
-----code
#include <stdio.h>
#include <unistd.h>
int func ( void )
{
return 0 ;
}
int main ( int argc ,char *argv[] )
{
int a = 0 ;
printf ( "hello world\n" ) ;
return 0 ;
}
----- log
Running gdb over ssh...
undefined=thread-group-added,id="i1"
Running executable
Failed to run command `break-insert /root/duxin/project/gdbtest/main.cpp:6`: Cannot access memory at address 0x4005a4
An error occured: Cannot access memory at address 0x4005a4
hello world
----- launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "gdb",
"request": "launch",
"target": "./main",
"cwd": "${workspaceRoot}",
"ssh": {
"forwardX11": false,
"host": "192.168.4.32",
"cwd": "/root/duxin/project/gdbtest",
"password": "oracle",
"user": "root"
}
}
]
}
See #26
I want use terminal.app
instead of VSCode console output.
for example:
#include <iostream>
#include <string>
struct A
{
std::string infoa;
};
struct B
{
std::string infob;
A* a;
};
struct C
{
std::string infoc;
B* b;
void Test()
{
std::cout << infoc << ", " << b->infob << ", " << b->a->infoa << std::endl;
}
};
int main()
{
A* a = new A{"aaa"};
B* b = new B{"bbb", a};
C c = C{"ccc", b};
c.Test();
return 0;
}
same commands passed directly to gdb
7-data-evaluate-expression "_this"
7^done,value="{infoc = "ccc", b = 0x614c50}"
(gdb)
8-data-evaluate-expression "_b"
8^done,value="{infob = "bbb", a = 0x614c20}"
(gdb)
9-data-evaluate-expression "*a"
9^error,msg="Attempt to take contents of a non-pointer value."
(gdb)
When CWD is not present, a general warning says that Warning: c:devMyPath: No such file or directory.
As you can see, no slashes are present.
Setting "cwd": "C:/dev/My/Path"
or "cwd": "C:\\dev\\My\\Path"
produces the same message. However, setting it to "cwd": "C:/dev/My/Path/"
(note trailing slash) ends up as
Failed to run command `environment-directory "C:\dev\My\Path\"`: Problem parsing arguments: environment-directory "C:\dev\My\Path\"
An error occured: Problem parsing arguments: environment-directory "C:\dev\My\Path\"
Not fluent enough in TypeScript to fix it I'm afraid.
See #26
Hi,
Some people I know would like to use some of the changes you merged yesterday.
Could you please vsce publish
a new version?
data-evaluate-expression
is used to inspect the value of variables during debugging (as your documentation clearly says).
For some reason gdb still uses my pretty printers but lldb-mi ignores them.
This is not a bug report since I get the same behavior in the command line: data-evaluate-expression
ignores my type summary variable formatters but if I use frame variable
or even print
they come out nice. Why is data-evaluate-expression
being used across the board? Is this intentional? Am I missing something?
The procedure for installing or updating code-debug is unclear. Starting with this page:
https://marketplace.visualstudio.com/items?itemName=webfreak.debug
There is a green "Get Started" button at the top of the page which takes you to some good instructions (https://code.visualstudio.com/docs/editor/extension-gallery?pub=webfreak&ext=debug) on how to install code-debug. The first time I installed code-debug, I clicked on that button and installed without too much trouble. However, later I wanted to try to reinstall, and I clicked on the "Get Started" link on the right side of the webfreak.debug page under "Resources." That took me to https://github.com/WebFreak001/code-debug , and I wasn't sure how to proceed. I clicked "Download ZIP" but then couldn't figure out what to do with the zip file.
I would suggest several things to avoid confusion:
Please provide clear basic documentation about how to set up launch.json. A link to documentation in the Microsoft/vscode project would be fine, if there is such documentation.
Note that I don't know Node.js and would rather not spend a day learning it, just to be able to use Code for developing my C code app. The Code getting started guide suggests developing a Node.js app in order to get familiar with how Code works. Unfortunately, it's not clear which version of Node.js should be installed, how to install it (I get various errors), how to install the example files, etc. The learning curve is way too steep. A quick reference guide for setting up launch.json tailored to C/C++ code development would be great.
Some questions:
Regarding "cwd": "${workspaceRoot}", if I have my source and object files all in one directory and I start Code in that directory, can I leave that line as is? When might I want to change cwd to some different value?
Is ${workspaceRoot} a Node.js variable? How can I view its value?
Is "target": "./myapp" or "target": "myapp" OK if the myapp executable is in the cwd directory? I'm guessing the file path (for example ".") is relative to cwd, is that right?
How does Code know where to find the source files?
How can I set the default command line args for my application?
I'm having a hard time getting Code to stop at breakpoints. Can I start my app and have Code/gdb break immediately so I can set breakpoints and have gdb break when a breakpoint is reached? This is for local debugging.
Can I have my app's stdin, stdout and stderr go to a separate window from the gdb dialog?
How can I run a make from within Code, i.e. how can I set up the launch.json or similar file to enable this?
Please provide an example and some documentation.
Thanks!
Greetings. I recently tried to create a debug configuration, one with GDB, and another with LLDB, neither worked...
No errors printed out in Debug Console, and no error popups shown.
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "gdb",
"request": "launch",
"preLaunchTask": "exifextract_all",
"cwd": "${workspaceRoot}",
"target": "./Build/Final/exifextract",
"arguments": "./Test/IMG_0985.JPG ./Test/IMG_1351.JPG ./Test/IMG_1353.JPG ./Test/IMG_1355.JPG ./Test/IMG_1357.JPG"
}
]
}
No errors in Debug Console. One error popup shown...:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "lldb-mi",
"request": "launch",
"preLaunchTask": "exifextract_all",
"cwd": "${workspaceRoot}",
"target": "./Build/Final/exifextract",
"arguments": "./Test/IMG_0985.JPG ./Test/IMG_1351.JPG ./Test/IMG_1353.JPG ./Test/IMG_1355.JPG ./Test/IMG_1357.JPG"
}
]
}
It's worth noting that, when using the GDB configuration, my executable doesn't appear to ever be launched.
However, when using the LLDB configuration, my executable is launched, but terminated almost immediately.
It's also worth noting that my executable runs just fine from the command-line.
I've reviewed issues #37 and #59 (as well as #60, it's duplicate), but neither were of any help to me.
Both GDB and LLDB work fine from the console, and the versions of both, meet the requirements (7.7.1 for GDB, 3.7.1 for LLDB).
Edit: As pointed out in a later comment, when I removed the arguments
property from my launch configuration(s), they work fine.
Latest release. Using GDB v7.7
1-gdb-set target-async on
2-environment-directory "c:\\dev\\trunk/Sw/A_XMC/out/obj"
3-target-select remote localhost:4444
Reading symbols from c:\dev\trunk\Sw\A_XMC\out\use\A_Myriad_A_5_9.elf...
done.
../../gdb-7.7.50.20140303/gdb/thread.c:85: internal-error: inferior_thread: Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session?
(y or n) [answered Y; input not from terminal]
undefined
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
../../gdb-7.7.50.20140303/gdb/thread.c:85: internal-error: inferior_thread: Assertion `tp' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB?
(y or n) [answered Y; input not from terminal]
Not on the clear what this could be...
Could it be possible to implement support for calling GDB over SSH ?
From what I've understood, it seems quite easy to implement within code-debug. You would simply need to replace the system executable calls and stdio redirections by an appropriate SSH implementation. simple-ssh seems to do the job but there might be better alternatives.
You can take a look at the Visual Studio (!= vscode) GDB Debugger Extension for an example implementation of this use-case. Source code of Microsoft/MIEngine might also help 😉
Here are my personal requirements for this feature:
target
field must point to the target executable not the ssh serverlaunch.json
proposal:
"request": "launch",
"target": "./bin/executable",
"cwd": "/home/target/build",
"ssh": {
"host": "127.0.0.1",
"port": "2222",
"user": "jdoe",
"password": "pw4jdoe"
}
It seems debug console show more old logs when i stop debug and try to debug again.
#include <stdio.h>
int main(int argc, char* argv[])
{
int a = 10;
a *= 10;
while (1) {
printf("hello, world! the value = %d\n", a);
a += 10;
fflush(stdout);
}
return 0;
}
when start with no break points. Debug console window show more logs util it can't show any thing, then an empty debug console shows. Then i click stop debug button. when i start debug again. There is till no logs show (maybe for there have more old logs not showed before).
Two problem here:
If submitting a bug please make sure
gdb --version
>= 7.7.1gdb
cwd
and target
are properly setScreenshots are helpful but not required
using lldb-mi
It supports way more languages
Just tried out your latest release and was able to successfully connect to my GDB bridge and send a bunch of monitor commands!
Is there a way to set variable address offset?
I'm currently using an ELF file as executable, so I get a bunch of errors when I try to set a breakpoint. Not really interested in breakpoints right now, but more to read variables on the fly.
So it successfully reads the ELF file. But then it complains about some weird path with no slashes.
After that I try to set a breakpoint since my variable list is all empty. That's when the "Failed to run command" pops up. Any ideas there?
Also, I'm able to read data with x/uw 0x20000BD0
which is my 1ms timer and it successfully returns!
I am not sure how to set PATH in Ubuntu after install debug? Thanks
f5 ->
Failed to run command break-insert /home/aaa/src/d/DCD/src/client/client.d:39
: No source file named /home/aaa/src/d/DCD/src/client/client.d(this file exist actually).
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "gdb",
"request": "launch",
"target": "./dcd-client",
"cwd": "${workspaceRoot}"
}
]
}
When starting debug (green play button) the following error is outputted:
undefined(lldb) 1-gdb-set target-async on
(lldb) 2-file-exec-and-symbols "/Users/nikharris/source/navitas-hub-emulator/hub-emulator"
undefinederror: '1-gdb-set' is not a valid command.
error: '2-file-exec-and-symbols' is not a valid command.
platform: OSX 10.11.3
Visual Studio Code version: 0.10.11
lldb-mi version: 7.4
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "lldb-mi",
"request": "launch",
"target": "./hub-emulator",
"cwd": "${workspaceRoot}"
}
]
}
Prior to debugging, I have to run source gdb.script
in the Debug Console to set up my GDB bridge properly. I have a bunch of monitor commands in there, but also (as mentioned in #6 (comment)) I choose to run e.g. add-symbol-file C:/dev/My/Path/MyElfFile.elf 0x8020000
to manually set my address offset.
Would be super sweet to having a script called automatically! What do you think?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.