You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was testing this extension's "Attach to a local process" functionality on Windows and noticed that this didn't work as expected, and in fact it appeared the debug adapter was crashing. With further investigation, I tracked this down to a difference in the gdb behavior between the Windows version and the Linux version I was also using. I've included GDB/MI dumps from running a typical attach from the command line, on both Windows and Linux, to show typical output from the debugger.
Windows GDB/MI Attach to Local Process
Click to expand...
C:\> gdb --interpreter=mi2 -p 7740
=thread-group-added,id="i1"
~"GNU gdb (GDB for MinGW-W64 x86_64, built by Brecht Sanders) 10.2\n"
~"Copyright (C) 2021 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
~"\nType \"show copying\" and \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-w64-mingw32\".\n"
~"Type \"show configuration\" for configuration details.\n"
~"For bug reporting instructions, please see:\n"
~"<https://www.gnu.org/software/gdb/bugs/>.\n"
~"Find the GDB manual and other documentation resources online at:\n <http://www.gnu.org/software/gdb/documentation/>."
~"\n\n"
~"For help, type \"help\".\n"
~"Type \"apropos word\" to search for commands related to \"word\".\n"
~"Attaching to process 7740\n"
=thread-group-started,id="i1",pid="7740"
=thread-created,id="1",group-id="i1"
=thread-created,id="2",group-id="i1"
~"[New Thread 7740.0x15ac]\n"
~"Reading symbols from c:\\git\\hello_world_exe\\hello_world-gcc.exe...\n"
=library-loaded,id="C:\\Windows\\SYSTEM32\\ntdll.dll",target-name="C:\\Windows\\SYSTEM32\\ntdll.dll",host-name="C:\\Windows\\SYSTEM32\\ntdll.dll",symbols-loaded="0",thread-group="i1",ranges=[{from="0x00007fff8ef71000",to="0x00007fff8f164544"}]
=library-loaded,id="C:\\Windows\\System32\\kernel32.dll",target-name="C:\\Windows\\System32\\kernel32.dll",host-name="C:\\Windows\\System32\\kernel32.dll",symbols-loaded="0",thread-group="i1",ranges=[{from="0x00007fff8ed81000",to="0x00007fff8ee3d30c"}]
=library-loaded,id="C:\\Windows\\System32\\KernelBase.dll",target-name="C:\\Windows\\System32\\KernelBase.dll",host-name="C:\\Windows\\System32\\KernelBase.dll",symbols-loaded="0",thread-group="i1",ranges=[{from="0x00007fff8cd01000",to="0x00007fff8cfc7abc"}]
=library-loaded,id="C:\\Windows\\System32\\msvcrt.dll",target-name="C:\\Windows\\System32\\msvcrt.dll",host-name="C:\\Windows\\System32\\msvcrt.dll",symbols-loaded="0",thread-group="i1",ranges=[{from="0x00007fff8d8a1000",to="0x00007fff8d93d4a8"}]
*stopped
(gdb)
Linux GDB/MI Attach to Local Process
Click to expand...
~/> gdb --interpreter=mi2 -p 5083
=thread-group-added,id="i1"
~"GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2\n"
~"Copyright (C) 2020 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law."
~"\nType \"show copying\" and \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-linux-gnu\".\n"
~"Type \"show configuration\" for configuration details.\n"
~"For bug reporting instructions, please see:\n"
~"<http://www.gnu.org/software/gdb/bugs/>.\n"
~"Find the GDB manual and other documentation resources online at:\n <http://www.gnu.org/software/gdb/documentation/>."
~"\n\n"
~"For help, type \"help\".\n"
~"Type \"apropos word\" to search for commands related to \"word\".\n"
~"Attaching to process 5083\n"
=thread-group-started,id="i1",pid="5083"
=thread-created,id="1",group-id="i1"
~"Reading symbols from /home/troy/git/hello_world_exe/hello_world-gcc...\n"
=library-loaded,id="/lib/x86_64-linux-gnu/libc.so.6",target-name="/lib/x86_64-linux-gnu/libc.so.6",host-name="/lib/x86_64-linux-gnu/libc.so.6",symbols-loaded="0",thread-group="i1",ranges=[{from="0x00007fa908c5f630",to="0x00007fa908dd418d"}]
=library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1",ranges=[{from="0x00007fa908e3b100",to="0x00007fa908e5d674"}]
~"Reading symbols from /lib/x86_64-linux-gnu/libc.so.6...\n"
~"Reading symbols from /usr/lib/debug//lib/x86_64-linux-gnu/libc-2.31.so...\n"
~"Reading symbols from /lib64/ld-linux-x86-64.so.2...\n"
~"(No debugging symbols found in /lib64/ld-linux-x86-64.so.2)\n"
~"main () at hello_world.c:6\n"
&"6\thello_world.c: No such file or directory.\n"
*stopped,frame={addr="0x000056429f0ff15d",func="main",args=[],file="hello_world.c",fullname="C:\\usr\\src/hello_world.c",line="6",arch="i386:x86-64"},thread-id="1",stopped-threads="all",core="2"
(gdb)
Investigation
The difference is that on Windows, the exec-async-output does not contain any optional results in this particular instance:
*stopped
The same attach on Linux does contain optional results and doesn't exibit the same problem.
Further investigation into the extension's implementation indicates that there is a bug in the parsing such that it will not successfully handle an async-record which does not contain any optional results, and in fact will crash the adapter. The crash is due to attempting to use regex match results that don't exist (because the match didn't actually succeed). The reason the match fails is because the current regex, when attempting to match the async-class, expects to also match the comma separator between the async-class and the optional result. The regex should be updated so that it is not necessary to match this comma separator.
The text was updated successfully, but these errors were encountered:
I was testing this extension's "Attach to a local process" functionality on Windows and noticed that this didn't work as expected, and in fact it appeared the debug adapter was crashing. With further investigation, I tracked this down to a difference in the
gdb
behavior between the Windows version and the Linux version I was also using. I've included GDB/MI dumps from running a typical attach from the command line, on both Windows and Linux, to show typical output from the debugger.Windows GDB/MI Attach to Local Process
Click to expand...
Linux GDB/MI Attach to Local Process
Click to expand...
Investigation
The difference is that on Windows, the
exec-async-output
does not contain any optional results in this particular instance:*stopped
The same attach on Linux does contain optional results and doesn't exibit the same problem.
Further investigation into the extension's implementation indicates that there is a bug in the parsing such that it will not successfully handle an
async-record
which does not contain any optional results, and in fact will crash the adapter. The crash is due to attempting to use regex match results that don't exist (because the match didn't actually succeed). The reason the match fails is because the current regex, when attempting to match theasync-class
, expects to also match the comma separator between theasync-class
and the optionalresult
. The regex should be updated so that it is not necessary to match this comma separator.The text was updated successfully, but these errors were encountered: