aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.dap
AgeCommit message (Collapse)AuthorFilesLines
2023-09-20gdb/dap: check for breakpoint source before unpackingGregory Anders1-0/+7
Not all breakpoints have a source location. For example, a breakpoint set on a raw address will have only the "address" field populated, but "source" will be None, which leads to a RuntimeError when attempting to unpack the filename and line number. Before attempting to unpack the filename and line number from the breakpoint, ensure that the source information is not None. Also populate the source and line information separately from the "instructionReference" field, so that breakpoints that include only an address are still included. Approved-By: Tom Tromey <tom@tromey.com>
2023-09-19Handle pointers and references correctly in DAPTom Tromey2-0/+137
A user pointed out that the current DAP variable code does not let the client deference a pointer. Oops! Fixing this oversight is simple enough -- adding a new no-op pretty-printer for pointers and references is quite simple. However, doing this naive caused a regession in scopes.exp, which expected there to be no children of a 'const char *' variable. This problem was fixed by the preceding patches in the series, which ensure that a C type of this kind is recognized as a string. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30821
2023-09-12Avoid spurious breakpoint-setting failure in DAPTom Tromey1-2/+7
A user pointed out that if a DAP setBreakpoints request has a 'source' field in a SourceBreakpoint object, then the gdb DAP implementation will throw an exception. While SourceBreakpoint does not allow 'source' in the spec, it seems better to me to accept it. I don't think we should fully go down the "Postel's Law" path -- after all, we have the type-checker -- but at the same time, if we do send errors, they should be intentional and not artifacts of the implementation. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30820
2023-09-05Handle array- and string-like values in no-op pretty printersTom Tromey7-0/+389
This changes the no-op pretty printers -- used by DAP -- to handle array- and string-like objects known by the gdb core. Two new tests are added, one for Ada and one for Rust.
2023-08-16Implement DAP module-removed eventTom Tromey2-2/+16
DAP specifies an event that should be sent when a module is removed. This patch implements this. Tested-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
2023-08-03Use frame.name() in FrameDecoratorTom Tromey1-1/+8
A co-worker pointed out that gdb's DAP implementation might return an integer for the name of a stack frame, like: {"id": 1, "name": 93824992310799, ...} This can be seen currently in the logs of the bt-nodebug.exp test case. What is happening is that FrameDecorator falls back on returning the PC when the frame's function symbol cannot be found, relying on the gdb core to look up the minsym and print its name. This can actually yield the wrong answer sometimes, because it falls into the get_frame_pc / get_frame_address_in_block problem -- if the frame is at a call to a noreturn function, the PC in this case might appear to be in the next function in memory. For more on this, see: https://sourceware.org/bugzilla/show_bug.cgi?id=8416 and related bugs. However, there's a different approach we can take: the code here can simply use Frame.name. This handles the PC problem correctly, and gets us the information we need.
2023-08-01Implement DAP "source" requestTom Tromey3-3/+74
This implements the DAP "source" request. I renamed the "loadedSources" function from "sources" to "loaded_sources" to avoid any confusion. I also moved the loadedSources test to the new sources.exp. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30691
2023-08-01Implement ValueFormat for DAPTom Tromey1-0/+10
This patch implements ValueFormat for DAP. Currently this only means supporting "hex". Note that StackFrameFormat is defined to have many more options, but none are currently recognized. It isn't entirely clear how these should be handled. I'll file a new gdb bug for this, and perhaps an upstream DAP bug as well. New in v2: - I realized that the "hover" context was broken, and furthermore that we only had tests for "hover" failing, not for it succeeding. This version fixes the oversight and adds a test. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30469
2023-08-01Respect supportsMemoryReferences in DAPTom Tromey2-0/+4
I noticed that the support for memoryReference in the "variables" output is gated on the client "supportsMemoryReferences" capability. This patch implements this and makes some other changes to the DAP memory reference code: * Remove the memoryReference special case from _SetResult. Upstream DAP fixed this oversight in response to https://github.com/microsoft/debug-adapter-protocol/issues/414 * Don't use the address of a variable as its memoryReference -- only emit this for pointer types. There's no spec support for the previous approach. * Use strip_typedefs to handle typedefs of pointers.
2023-08-01Add DAP support for C++ exceptionsTom Tromey2-0/+102
This adds DAP support for the various C++ exception-catching operations. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30682
2023-08-01Implement DAP 'terminated' eventTom Tromey1-0/+39
This implements the DAP 'terminated' event. Vladimir Makaev noticed that VSCode will not report the debug session as over unless this is sent. It's not completely clear when exactly this event ought to be sent. Here I've done it when the inferior exits. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30681
2023-08-01Do not send "new breakpoint" event when breakpoint is setTom Tromey1-5/+6
When the DAP client sets a breakpoint, gdb currently sends a "new breakpoint" event. However, Vladimir Makaev discovered that this causes VSCode to think there are two breakpoints. This patch changes gdb to suppress the event in this case. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30678
2023-08-01Add "cwd" parameter to DAP launch requestTom Tromey1-0/+40
This adds the "cwd" parameter to the DAP launch request. This came up here: https://github.com/eclipse-cdt-cloud/cdt-gdb-adapter/issues/90 ... and seemed like a good idea. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-08-01Refactor dap_launchTom Tromey2-2/+2
This patch refactors dap_launch to make it more extensible and also easier to use.
2023-07-21Implement DAP modules requestTom Tromey3-0/+142
This implements the DAP "modules" request, and also arranges to add the module ID to stack frames.
2023-07-21Add instruction bytes to DAP disassembly responseTom Tromey1-0/+9
The DAP disassemble command lets the client return the underlying bytes of the instruction in an implementation-defined format. This patch updates gdb to return this, and simply uses a hex string of the bytes as the format. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-07-10Add Ada scope test for DAPTom Tromey4-0/+154
This adds a DAP test for fetching scopes and variables with an Ada program. This test is the reason that the FrameVars code does not check is_constant on the symbols it returns. Note that this test also shows that string-printing is incorrect in Ada. This is a known bug but I'm still considering how to fix it.
2023-07-10Handle typedefs in no-op pretty printersTom Tromey1-3/+3
The no-ops pretty-printers that were introduced for DAP have a classic gdb bug: they neglect to call check_typedef. This will cause some strange behavior; for example not showing the children of a variable whose type is a typedef of a structure type. This patch fixes the oversight.
2023-07-10Reimplement DAP stack traces using frame filtersTom Tromey1-1/+2
This reimplements DAP stack traces using frame filters. This slightly simplifies the code, because frame filters and DAP were already doing some similar work. This also renames RegisterReference and ScopeReference to make it clear that these are private (and so changes don't have to worry about other files). Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30468
2023-07-07Fix result of DAP setExpressionTom Tromey1-1/+1
A co-worker, Andry, noticed that the DAP setExpression implementation returned the wrong fields -- it used "result" rather than "value", and included "memoryReference", which isn't in the spec (an odd oversight, IMO). This patch fixes the problems.
2023-06-22Implement DAP "hover" contextTom Tromey2-0/+100
A DAP client can request that an expression be evaluated in "hover" context, meaning that it should not cause side effects. In gdb, this can be implemented by temporarily setting a few "may-" parameters to "off". In order to make this work, I had to also change "may-write-registers" so that it can be changed while the program is running. I don't think there was any reason for this prohibition in the first place. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30476
2023-06-22Implement DAP logging breakpointsTom Tromey2-0/+82
DAP allows a source breakpoint to specify a log message. When this is done, the breakpoint acts more like gdb's dprintf: it logs a message but does not cause a stop. I looked into implement this using dprintf with the new %V printf format. However, my initial attempt at this did not work, because when the inferior is continued, the dprintf output is captured by the gdb.execute call. Maybe this could be fixed by having all inferior-continuation commands use the "&" form; the main benefit of this would be that expressions are only parsed a single time.
2023-06-22Handle supportsVariablePaging in DAPTom Tromey1-7/+17
A bug report about the supportsVariablePaging capability in DAP resulted in a clarification: when this capability is not present, DAP implementations should ignore the paging parameters to the "variables" request. This patch implements this clarification.
2023-06-22Handle exceptions when creating DAP breakpointsTom Tromey2-7/+36
When creating a DAP breakpoint, a failure should be returned by setting "verified" to False. gdb didn't properly implement this, and there was a FIXME comment to this effect. This patch fixes the problem.
2023-06-22Fix type of DAP hitConditionTom Tromey1-1/+1
DAP specifies a breakpoint's hitCondition as a string, meaning it is an expression to be evaluated. However, gdb implemented this as if it were an integer instead. This patch fixes this oversight.
2023-06-13[gdb/testsuite] Fix gdb.dap/type_check.exp with older pythonTom de Vries2-1/+10
On openSUSE Leap 15.4 with system python 3.6, I run into: ... (gdb) python check_everything()^M (gdb) FAIL: gdb.dap/type_check.exp: type checker ... In check_everything, the hasattr test fails silently: ... def check_everything(): # Older versions of Python can't really implement this. if hasattr(typing, "get_origin"): ... and that makes the gdb_test in the test-case fail. Fix this by emitting UNSUPPORTED instead in check_everything, and detecting this in the test-case. Tested on x86_64-linux.
2023-06-12Implement DAP conditional breakpointsTom Tromey2-0/+91
I realized that I had only implemented DAP breakpoint conditions for exception breakpoints, and not other kinds of breakpoints. This patch corrects the oversight.
2023-06-12Implement DAP breakpointLocations requestTom Tromey2-1/+16
This implements the DAP breakpointLocations request.
2023-06-12Add "stop at main" extension to DAP launch requestTom Tromey1-0/+37
Co-workers who work on a program that uses DAP asked for the ability to have gdb stop at the main subprogram when launching. This patch implements this extension. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-06-12Add "target" parameter to DAP attach requestTom Tromey1-0/+49
This adds a new "target" to the DAP attach request. This is passed to "target remote". I thought "attach" made the most sense for this, because in some sense gdb is attaching to a running process. It's worth noting that all DAP "attach" parameters are defined by the implementation. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-06-12Handle DAP supportsVariableType capabilityTom Tromey1-1/+2
A DAP client can report the supportsVariableType capability in the initialize request. In this case, gdb can include the type of a variable or expression in various results.
2023-06-12Implement DAP setExpression requestTom Tromey1-0/+5
This implements the DAP setExpression request.
2023-06-12Add type-checking to DAP requestsTom Tromey2-0/+125
It occurred to me recently that gdb's DAP implementation should probably check the types of objects coming from the client. This patch implements this idea by reusing Python's existing type annotations, and supplying a decorator that verifies these at runtime. Python doesn't make it very easy to do runtime type-checking, so the core of the checker is written by hand. I haven't tried to make a fully generic runtime type checker. Instead, this only checks the subset that is needed by DAP. For example, only keyword-only functions are handled. Furthermore, in a few spots, it wasn't convenient to spell out the type that is accepted. I've added a couple of comments to this effect in breakpoint.py. I've tried to make this code compatible with older versions of Python, but I've only been able to try it with 3.9 and 3.10.
2023-06-12Add test for DAP pause requestTom Tromey1-0/+41
I neglected to write a test for the DAP "pause" request. This patch adds one.
2023-06-12Add singleThread support to some DAP requestsTom Tromey2-4/+8
A few DAP requests support a "singleThread" parameter, which is somewhat similar to scheduler-locking. This patch implements support for this.
2023-06-12Implement DAP stepOut requestTom Tromey2-1/+14
This implements the DAP "stepOut" request.
2023-06-12Implement DAP attach requestTom Tromey2-0/+61
This implements the DAP "attach" request. Note that the copyright dates on the new test source file are not incorrect -- this was copied verbatim from another directory. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-06-12Implement DAP setExceptionBreakpoints requestTom Tromey3-0/+127
This implements the DAP setExceptionBreakpoints request for Ada. This is a somewhat minimal implementation, in that "exceptionOptions" are not implemented (or advertised) -- I wasn't completely sure how this feature is supposed to work. I haven't added C++ exception handling here, but it's easy to do if needed. This patch relies on the new MI command execution support to do its work.
2023-05-24Add "args" and "env" parameters to DAP launch requestTom Tromey2-0/+118
This patch augments the DAP launch request with some optional new parameters that let the client control the command-line arguments and the environment of the inferior. Reviewed-By: Andrew Burgess <aburgess@redhat.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-05-23Handle DAP evaluate request without a frame IDTom Tromey2-0/+86
DAP specifies that if an evaluate request does not have a frameID parameter, then the expression is evaluated in the global scope.
2023-05-23Implement DAP loadedSources requestTom Tromey1-0/+3
This implements the DAP loadedSources request, using gdb.execute_mi to avoid having to write another custom Python API.
2023-05-12Implement DAP register scopeTom Tromey1-2/+16
I noticed that gdb's DAP code did not provide a way to see register values. DAP defines a "register" scope, which this patch implements. This patch also adds the missing (and optional) "presentationHint" to scopes.
2023-05-05Filter out types from DAP scopes requestTom Tromey1-6/+6
The DAP scopes request examines the symbols in a block tree, but neglects to omit types. This patch fixes the problem.
2023-04-24[gdb/testsuite] Skip dap tests for tcl 8.5Tom de Vries1-0/+2
When running the dap tests on a system with tcl 8.5, we run into: ... ERROR: tcl error sourcing gdb/testsuite/gdb.dap/memory.exp. ERROR: bad class "entier": must be alnum, alpha, ascii, control, boolean, \ digit, double, false, graph, integer, list, lower, print, punct, space, \ true, upper, wideinteger, wordchar, or xdigit while executing "string is entier $num" (procedure "num" line 16) invoked from within ... Fix this by: - requiring tcl 8.6 in allow_dap_tests, and - adding the missing require allow_dap_tests in gdb.dap/memory.exp. Tested on x86_64-linux.
2023-04-03Add readMemory and writeMemory requests to DAPTom Tromey2-0/+110
This adds the DAP readMemory and writeMemory requests. A small change to the evaluation code is needed in order to test this -- this is one of the few ways for a client to actually acquire a memory reference.
2023-03-26[gdb/testsuite] Introduce allow_dap_testsTom de Vries3-2/+4
Simon pointed out that with gdb.dap/*.exp and target board native-gdbserver, we run into problems. I see for each test-case: ... +++ run Traceback (most recent call last): File "startup.py", line 146, in exec_and_log output = gdb.execute(cmd, from_tty=True, to_string=True) gdb.error: Don't know how to run. Try "help target". ... Likewise with target board native-extended-gdbserver. Fix this by: - adding a new proc allow_dap_tests, - using it in all the gdb.dap tests, and - bailing out if GDBFLAGS/INTERNAL_GDBFLAGS contains "set auto-connect-native-target off". Tested on x86_64-linux. Reported-By: Simon Marchi <simon.marchi@efficios.com> Approved-By: Tom Tromey <tom@tromey.com>
2023-03-24Implement repl evaluation for DAPTom Tromey1-0/+5
The evaluate command supports a "context" parameter which tells the adapter the context in which an evaluation occurs. One of the supported values is "repl", which we took to mean evaluation of a gdb command. That is what this patch implements. Note that some gdb commands probably will not work correctly with the rest of the protocol. For example if the user types "continue", confusion may result. This patch requires the earlier patch to fix up scopes in DAP.
2023-03-14Implement DAP variables, scopes, and evaluate requestsTom Tromey2-0/+136
The DAP code already claimed to implement "scopes" and "evaluate", but this wasn't done completely correctly. This patch implements these and also implements the "variables" request. After this patch, variables and scopes correctly report their sub-structure. This also interfaces with the gdb pretty-printer API, so the output of pretty-printers is available.
2023-03-06Fix DAP stackTrace through frames without debuginfoTom Tromey3-0/+100
The DAP stackTrace implementation did not fully account for frames without debuginfo. Attemping this would yield a result like: {"request_seq": 5, "type": "response", "command": "stackTrace", "success": false, "message": "'NoneType' object has no attribute 'filename'", "seq": 11} This patch fixes the problem by adding another check for None.
2023-03-01gdb: update some copyright years (2022 -> 2023)Simon Marchi2-2/+2
The copyright years in the ROCm files (e.g. solib-rocm.c) are wrong, they end in 2022 instead of 2023. I suppose because I posted (or at least prepared) the patches in 2022 but merged them in 2023, and forgot to update the year. I found a bunch of other files that are in the same situation. Fix them all up. Change-Id: Ia55f5b563606c2ba6a89046f22bc0bf1c0ff2e10 Reviewed-By: Tom Tromey <tom@tromey.com>