Closed GitMensch closed 1 year ago
IIUC the error message appeared in the CLI output and all the MI side was only informed that the inferior had terminated? If so, that is a question for GDB folk I guess? (But I know you do a lot of stuff on GDB, so perhaps I am misunderstanding the issue?)
IIUC the error message appeared in the CLI output and all the MI side was only informed that the inferior had terminated?
Yes.
If so, that is a question for GDB folk I guess?
Possibly both "GDB folk" and "debug adapter".
The issue from the debug adapter site is that cli output is not handled if "openGdbConsole": false
is set, but should.
Other extensions will then show the output in the debug console (detailed when verbose, otherwise only the actual stdout and stderr/undefined messages - the later is currently missing in the extension and not shown in the log at all).
But yes: there should be a MI message and rechecking shows - there isn't one. I guess I'll need to build GDB 13 (or at least the last release 12) and recheck there, and report it otherwise.
Thanks for the clarification. Let me see what I can do about the "openGdbConsole": false
case.
Can you send the DAP + MI trace when "openGdbConsole": false
? Alternatively how to make such a broken executable that you described in OP?
If I do the simple case of passing in an invalid program
I get an expected pop-up:
The screenshot above has a testcase to verify it:
I will have a read through the code to see why other error messages might be muted.
how to make such a broken executable that you described in OP?
The "common" real-world example is a library that was linked with version 123 but used with version 120.
The screenshot above has a testcase to verify it
That works because there is an async result record for the "file-exec-and-symbols" request (output from another client, but identical here):
{"token":2,"outOfBandRecord":[],"resultRecords":{"resultClass":"error","results":[["msg","/tmp/not/there: No such file or directory."]]}}
(note: that's a local gdb, not gdbserver with "No such file or directory.", so the comments in the referenced code are at least misleading)
if a linked shared library has a mismatch you get:
{"token":2,"outOfBandRecord":[],"resultRecords":{"resultClass":"done","results":[]}}
And also a positive result for exec-run
and only after both an stderr message (not a failure), likely from the dynamic link loader.
The only "direct" result GDB sends is a console output with the "Inferior ... exited", followed by notify events thread-exited + thread-group-exited, followed by "stopped" return.
The code you've linked is likely "finished" there already.
See #241 for what I created as you outlined in https://github.com/eclipse-cdt-cloud/cdt-gdb-adapter/issues/239#issuecomment-1411173434
The test case I added in #241 sends the error to the inferior's stderr, so it is completely lost by cdt-gdb-adapter, but would be improved by having #161 fixed properly.
For now with no proper inferior, the stderr of the inferior disappear to nothing as the spawned process's stderr is never read:
In the immediate term I am going to start capturing stderr and returning that to the client.
In the immediate term I am going to start capturing stderr and returning that to the client.
With the stderr captured and sent as OutputEvent this issue is now resolved, however somewhat unsatisfactorily as buffering, and intermixing of outputs with gdb itself, means that it is brittle.
Well done. As there's no way to update the built-in extension (which isn't rebuild and ci-published as vsix either) I can't test this now. To make this complete: would you mind sharing the output when starting this with the "wrong" libsome in the debugger, both with and without verbose mode enabled?
verbose off full contents of debug console
GNU gdb (Ubuntu 10.2-0ubuntu1~20.04~1) 10.2
Copyright (C) 2021 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-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://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".
GDB unhandled notify: cmd-param-changed: {"param":"auto-load safe-path","value":"/"}
[Inferior 1 (process 538748) exited with code 0177]
/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/BrokenSO: error while loading shared libraries: libsomea.so: cannot open shared object file: No such file or directory
verbose on full contents of debug console
From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"gdb","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-gb","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true,"supportsArgsCanBeInterpretedByShell":true,"supportsMemoryEvent":true})
To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsConfigurationDoneRequest":true,"supportsSetVariable":true,"supportsConditionalBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsFunctionBreakpoints":true,"supportsDisassembleRequest":true,"supportsReadMemoryRequest":true,"supportsWriteMemoryRequest":true}}
From client: launch({"type":"gdb","request":"launch","name":"cdt version","program":"/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/BrokenSO","verbose":true,"openGdbConsole":false,"__configurationTarget":6,"__sessionId":"6088ea4e-e273-4b35-86be-10c4b59d670e"})
GDB notify async: thread-group-added,id="i1"
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"GNU gdb (Ubuntu 10.2-0ubuntu1~20.04~1) 10.2\n"}}
GNU gdb (Ubuntu 10.2-0ubuntu1~20.04~1) 10.2
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Copyright (C) 2021 Free Software Foundation, Inc.\n"}}
Copyright (C) 2021 Free Software Foundation, Inc.
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"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."}}
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.To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"\nType \"show copying\" and \"show warranty\" for details.\n"}}
Type "show copying" and "show warranty" for details.
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"This GDB was configured as \"x86_64-linux-gnu\".\n"}}
This GDB was configured as "x86_64-linux-gnu".
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Type \"show configuration\" for configuration details.\n"}}
Type "show configuration" for configuration details.
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"For bug reporting instructions, please see:\n"}}
For bug reporting instructions, please see:
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"<https://www.gnu.org/software/gdb/bugs/>.\n"}}
<https://www.gnu.org/software/gdb/bugs/>.
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Find the GDB manual and other documentation resources online at:\n <http://www.gnu.org/software/gdb/documentation/>."}}
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"\n\n"}}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"For help, type \"help\".\n"}}
For help, type "help".
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"Type \"apropos word\" to search for commands related to \"word\".\n"}}
Type "apropos word" to search for commands related to "word".
GDB notify async: cmd-param-changed,param="auto-load safe-path",value="/"
GDB unhandled notify: cmd-param-changed: {"param":"auto-load safe-path","value":"/"}
GDB command: 0 -gdb-set non-stop off
GDB result: 0 done
GDB command: 1 -gdb-set mi-async on
GDB result: 1 done
GDB command: 2 -file-exec-and-symbols "/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/BrokenSO"
GDB result: 2 done
GDB command: 3 -enable-pretty-printing
GDB result: 3 done
To client: {"seq":0,"type":"event","event":"initialized"}
To client: {"seq":0,"type":"response","request_seq":2,"command":"launch","success":true}
From client: setBreakpoints({"source":{"name":"empty.c","path":"/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/empty.c"},"lines":[9],"breakpoints":[{"line":9}],"sourceModified":false})
GDB command: 4 -break-list
From client: setBreakpoints({"source":{"name":"MultiThread.cc","path":"/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/MultiThread.cc"},"lines":[36],"breakpoints":[{"line":36}],"sourceModified":false})
GDB command: 5 -break-list
From client: setFunctionBreakpoints({"breakpoints":[]})
GDB command: 6 -break-list
GDB result: 4 done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
GDB result: 5 done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
GDB result: 6 done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
To client: {"seq":0,"type":"response","request_seq":5,"command":"setFunctionBreakpoints","success":true,"body":{"breakpoints":[]}}
GDB command: 7 -break-insert --source "/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/empty.c" --line 9
GDB command: 8 -break-insert --source "/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/MultiThread.cc" --line 36
GDB result: 7 error,msg="No source file named /scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/empty.c."
To client: {"seq":0,"type":"response","request_seq":3,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"verified":false,"message":"No source file named /scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/empty.c."}]}}
GDB result: 8 error,msg="No source file named /scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/MultiThread.cc."
To client: {"seq":0,"type":"response","request_seq":4,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"verified":false,"message":"No source file named /scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/MultiThread.cc."}]}}
From client: configurationDone(undefined)
GDB command: 9 -exec-run
GDB notify async: thread-group-started,id="i1",pid="540863"
GDB notify async: thread-created,id="1",group-id="i1"
GDB notify async: 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="0x00007ffff7fd0100",to="0x00007ffff7ff2684"}]
GDB result: 9 running
GDB exec async: running,thread-id="all"
To client: {"seq":0,"type":"response","request_seq":6,"command":"configurationDone","success":true}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"[Inferior 1 (process 540863) exited with code 0177]\n"}}
[Inferior 1 (process 540863) exited with code 0177]
GDB notify async: thread-exited,id="1",group-id="i1"
GDB notify async: thread-group-exited,id="i1",exit-code="0177"
GDB exec async: stopped,reason="exited",exit-code="0177"
To client: {"seq":0,"type":"event","event":"terminated"}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stderr","output":"/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/BrokenSO: error while loading shared libraries: libsomea.so: cannot open shared object file: No such file or directory\n"}}
/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/BrokenSO: error while loading shared libraries: libsomea.so: cannot open shared object file: No such file or directory
From client: threads(undefined)
GDB command: 10 -thread-info
GDB result: 10 done,threads=[]
To client: {"seq":0,"type":"response","request_seq":7,"command":"threads","success":true,"body":{"threads":[]}}
From client: disconnect({"restart":false})
GDB command: 11 -gdb-exit
GDB result: 11 exit
To client: {"seq":0,"type":"response","request_seq":8,"command":"disconnect","success":true}
openGdbConsole full contents of debug console
From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"gdb","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-gb","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true,"supportsArgsCanBeInterpretedByShell":true,"supportsMemoryEvent":true})
To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsConfigurationDoneRequest":true,"supportsSetVariable":true,"supportsConditionalBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsFunctionBreakpoints":true,"supportsDisassembleRequest":true,"supportsReadMemoryRequest":true,"supportsWriteMemoryRequest":true}}
From client: launch({"type":"gdb","request":"launch","name":"cdt version","program":"/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/BrokenSO","verbose":true,"openGdbConsole":true,"__configurationTarget":6,"__sessionId":"92becc83-96e3-4403-aa2a-32c43a9669c7"})
cdt-gdb-adapter: spawning gdb console in client terminal
To client: "runInTerminal"({"kind":"integrated","cwd":"/tmp/a/eclipse/plugins/org.eclipse.cdt.debug.application_11.1.0.202212091724/scripts","env":{[...]
GDB notify async: thread-group-added,id="i1"
GDB command: 0 -gdb-set non-stop off
GDB result: 0 done
GDB command: 1 -gdb-set mi-async on
GDB result: 1 done
GDB command: 2 -file-exec-and-symbols "/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/BrokenSO"
GDB result: 2 done
GDB command: 3 -enable-pretty-printing
GDB result: 3 done
To client: {"seq":0,"type":"event","event":"initialized"}
To client: {"seq":0,"type":"response","request_seq":2,"command":"launch","success":true}
From client: setBreakpoints({"source":{"name":"empty.c","path":"/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/empty.c"},"lines":[9],"breakpoints":[{"line":9}],"sourceModified":false})
GDB command: 4 -break-list
From client: setBreakpoints({"source":{"name":"MultiThread.cc","path":"/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/MultiThread.cc"},"lines":[36],"breakpoints":[{"line":36}],"sourceModified":false})
GDB command: 5 -break-list
From client: setFunctionBreakpoints({"breakpoints":[]})
GDB command: 6 -break-list
GDB result: 4 done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
GDB command: 7 -break-insert --source "/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/empty.c" --line 9
GDB result: 5 done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
GDB command: 8 -break-insert --source "/scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/MultiThread.cc" --line 36
GDB result: 6 done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
To client: {"seq":0,"type":"response","request_seq":6,"command":"setFunctionBreakpoints","success":true,"body":{"breakpoints":[]}}
GDB result: 7 error,msg="No source file named /scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/empty.c."
To client: {"seq":0,"type":"response","request_seq":4,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"verified":false,"message":"No source file named /scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/empty.c."}]}}
GDB result: 8 error,msg="No source file named /scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/MultiThread.cc."
To client: {"seq":0,"type":"response","request_seq":5,"command":"setBreakpoints","success":true,"body":{"breakpoints":[{"verified":false,"message":"No source file named /scratch/debug/git/cdt-gdb-adapter/src/integration-tests/test-programs/MultiThread.cc."}]}}
From client: configurationDone(undefined)
GDB command: 9 -exec-run
GDB notify async: thread-group-started,id="i1",pid="541685"
GDB notify async: thread-created,id="1",group-id="i1"
GDB notify async: 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="0x00007ffff7fd0100",to="0x00007ffff7ff2684"}]
GDB result: 9 running
GDB exec async: running,thread-id="all"
To client: {"seq":0,"type":"response","request_seq":7,"command":"configurationDone","success":true}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"stdout","output":"[Inferior 1 (process 541685) exited with code 0177]\n"}}
[Inferior 1 (process 541685) exited with code 0177]
GDB notify async: thread-exited,id="1",group-id="i1"
GDB notify async: thread-group-exited,id="i1",exit-code="0177"
GDB exec async: stopped,reason="exited",exit-code="0177"
To client: {"seq":0,"type":"event","event":"terminated"}
From client: threads(undefined)
GDB command: 10 -thread-info
GDB result: 10 done,threads=[]
To client: {"seq":0,"type":"response","request_seq":8,"command":"threads","success":true,"body":{"threads":[]}}
From client: disconnect({"restart":false})
GDB command: 11 -gdb-exit
GDB result: 11 exit
To client: {"seq":0,"type":"response","request_seq":9,"command":"disconnect","success":true}
I've wondered why a launch configuration did not work, and only after
"openGdbConsole": true,
was enabled I've seen it there: "symbol lookup error: undefined symbol" (there was a bad .so in LD_LIBRARY_PATH).Any idea why this was not reported by the debug adapter to the ui?`