aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2023-01-30Clean up lnp_state_machine constructorTom Tromey1-20/+13
This changes the lnp_state_machine constructor to initialize members directly; and changes lnp_state_machine itself to initialize members inline when possible. Reviewed-By: Lancelot Six <lancelot.six@amd.com>
2023-01-30Make addrmap const-correct in cooked indexTom Tromey3-9/+11
After the cooked index is created, the addrmaps should be const. Change-Id: I8234520ab346ced40a8dd6e478ba21fc438c2ba2
2023-01-30gdb: provide const-correct versions of addrmap::find and addrmap::foreachSimon Marchi5-21/+40
Users of addrmap::find and addrmap::foreach that have a const addrmap should ideally receive const pointers to objects, to indicate they should not be modified. However, users that have a non-const addrmap should still receive a non-const pointer. To achieve this, without adding more virtual methods, make the existing find and foreach virtual methods private and prefix them with "do_". Add small non-const and const wrappers for find and foreach. Obviously, the const can be cast away, but if using static_cast instead of C-style casts, then the compiler won't let you cast the const away. I changed all the callers of addrmap::find and addrmap::foreach I could find to make them use static_cast. Change-Id: Ia8e69d022564f80d961413658fe6068edc71a094
2023-01-30Use xfail in ptype_tagged_param.expTom Tromey1-1/+1
Pedro pointed out that ptype_tagged_param.exp used a kfail, but an xfail would be more appropriate as the problem appears to be in gcc, not gdb.
2023-01-30gdb: Remove workaround for the vCont packetChristina Schimpe1-19/+4
The workaround for the vCont packet is no longer required due to the former commit "gdb: Make global feature array a per-remote target array". The vCont packet is now checked once when the connection is started and the supported vCont actions are set to the target's remote state attribute.
2023-01-30gdb: Add per-remote target variables for memory read and write configChristina Schimpe4-65/+169
This patch adds per-remote target variables for the configuration of memory read- and write packet size. It is a further change to commit "gdb: Make global feature array a per-remote target array" to apply the fixme notes described in commit 5b6d1e4 "Multi-target support". The former global variables for that configuration are still available to allow the command line configuration for all future remote connections. Similar to the command line configuration of the per- remote target feature array, the commands - set remotewritesize (deprecated) - set remote memory-read-packet-size - set remote memory-write-packet-size will configure the current target (if available). If no target is available, the default configuration for future remote connections is adapted. The show command will display the current remote target's packet size configuration. If no remote target is selected, the default configuration for future connections will be shown. It is required to adapt the test gdb.base/remote.exp which is failing for --target_board=native-extended-gdbserver. With that board GDB connects to gdbserver at gdb start time. Due to this patch two loggings "The target may not be able to.." are shown if the command 'set remote memory-write-packet-size fixed' is executed while a target is connected for the current inferior. To fix this, the clean_restart command is moved to a later time point of the test. It is sufficient to be connected to the server when "runto_main" is executed. Now the connection time is similar to a testrun with --target_board=native-gdbserver. To allow the user to distinguish between the packet-size configuration for future remote connections and for the currently selected target, the commands' loggings are adapted.
2023-01-30gdb: Make global feature array a per-remote target arrayChristina Schimpe21-725/+868
This patch applies the appropriate FIXME notes described in commit 5b6d1e4 "Multi-target support". "You'll notice that remote.c includes some FIXME notes. These refer to the fact that the global arrays that hold data for the remote packets supported are still globals. For example, if we connect to two different servers/stubs, then each might support different remote protocol features. They might even be different architectures, like e.g., one ARM baremetal stub, and a x86 gdbserver, to debug a host/controller scenario as a single program. That isn't going to work correctly today, because of said globals. I'm leaving fixing that for another pass, since it does not appear to be trivial, and I'd rather land the base work first. It's already useful to be able to debug multiple instances of the same server (e.g., a distributed cluster, where you have full control over the servers installed), so I think as is it's already reasonable incremental progress." Using this patch it is possible to configure per-remote targets' feature packets. Given the following setup for two gdbservers: ~~~~ gdbserver --multi :1234 gdbserver --disable-packet=vCont --multi :2345 ~~~~ Before this patch configuring of range-stepping was not possible for one of two connected remote targets with different support for the vCont packet. As one of the targets supports vCont, it should be possible to configure "set range-stepping". However, the output of GDB looks like: (gdb) target extended-remote :1234 Remote debugging using :1234 (gdb) add-inferior -no-connection [New inferior 2] Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) target extended-remote :2345 Remote debugging using :2345 (gdb) set range-stepping on warning: Range stepping is not supported by the current target (gdb) inferior 1 [Switching to inferior 1 [<null>] (<noexec>)] (gdb) set range-stepping on warning: Range stepping is not supported by the current target ~~~~ Two warnings are shown. The warning for inferior 1 should not appear as it is connected to a target supporting the vCont package. ~~~~ (gdb) target extended-remote :1234 Remote debugging using :1234 (gdb) add-inferior -no-connection [New inferior 2] Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) target extended-remote :2345 Remote debugging using :2345 (gdb) set range-stepping on warning: Range stepping is not supported by the current target (gdb) inferior 1 [Switching to inferior 1 [<null>] (<noexec>)] (gdb) set range-stepping on (gdb) ~~~~ Now only one warning is shown for inferior 2, which is connected to a target not supporting vCont. The per-remote target feature array is realized by a new class remote_features, which stores the per-remote target array and provides functions to determine supported features of the target. A remote_target object now has a new member of that class. Each time a new remote_target object is initialized, a new per-remote target array is constructed based on the global remote_protocol_packets array. The global array is initialized in the function _initialize_remote and can be configured using the command line. Before this patch the command line configuration affected current targets and future remote targets (due to the global feature array used by all remote targets). This behavior is different and the configuration applies as follows: - If a target is connected, the command line configuration affects the current connection. All other existing remote targets are not affected. - If not connected, the command line configuration affects future connections. The show command displays the current remote target's configuration. If no remote target is selected the default configuration for future connections is shown. If we have for instance the following setup with inferior 2 being selected: ~~~~ (gdb) info inferiors Num Description Connection Executable 1 <null> 1 (extended-remote :1234) * 2 <null> 2 (extended-remote :2345) ~~~~ Before this patch, if we run 'set remote multiprocess-feature-packet', the following configuration was set: The feature array of all remote targets (in this setup the two connected targets) and all future remote connections are affected. After this patch, it will be configured as follows: The feature array of target with port :2345 which is currently selected will be configured. All other existing remote targets are not affected. The show command 'show remote multiprocess-feature-packet' will display the configuration of target with port :2345. Due to this configuration change, it is required to adapt the test "gdb/testsuite/gdb.multi/multi-target-info-inferiors.exp" to configure the multiprocess-feature-packet before the connections are created. To inform the gdb user about the new behaviour of the 'show remote PACKET-NAME' commands and the new configuration impact for remote targets using the 'set remote PACKET-NAME' commands the commands' outputs are adapted. Due to this change it is required to adapt each test using the set/show remote 'PACKET-NAME' commands.
2023-01-27More const-correctness in cooked indexerTom Tromey2-12/+13
I noticed that iterating over the index yields non-const cooked_index_entry objects. However, after finalization, they should not be modified. This patch enforces this by adding const where needed. v2 makes the find, all_entries, and wait methods const as well.
2023-01-27[gdb/testsuite] Simplify gdb.base/unwind-on-each-insn.exp.tclTom de Vries4-34/+14
Recent commit 1d98e564c97 ("[gdb/testsuite] Add gdb.base/unwind-on-each-insn-{amd64,i386}.exp") broke commit eb015bf86b6 ("[gdb/testsuite] Avoid using .eh_frame in gdb.base/unwind-on-each-insn.exp"), in the sense that gdb.base/unwind-on-each-insn.exp no longer uses -fno-asynchronous-unwind-tables, due to trying to concatenate two lists using: ... lappend srcfile2_flags $nodebug_flags ... which should instead be: ... lappend srcfile2_flags {*}$nodebug_flags ... Fix this by simplifying gdb.base/unwind-on-each-insn.exp.tcl, completely leaving the responsibility to set srcfile_flags and srcfile2_flags to each includer. Tested on x86_64-linux.
2023-01-27Invert test in gdb.ada/ptype_tagged_param.expTom Tromey1-1/+1
Simon pointed out that the kfail check in gdb.ada/ptype_tagged_param.exp is inverted. See: https://sourceware.org/pipermail/gdb-patches/2023-January/196296.html This patch fixes the problem.
2023-01-27gdb/tui: more debug outputAndrew Burgess2-0/+24
Add some additional debug output that I've found really useful while working on the previous set of patches. Unless tui debug is turned on, then there should be no user visible changes with this commit.
2023-01-27gdb/tui: avoid extra refresh_window on vertical scrollAndrew Burgess2-7/+14
While working on the previous couple of patches I noticed that when I scroll the src and asm windows vertically, I get two refresh_window calls. The two calls can be traced back to tui_source_window_base::update_source_window_as_is, in here we call show_source_content, which calls refresh_window, and then update_exec_info, which also calls refresh_window. In this commit I propose making the refresh_window call in update_exec_info optional. In update_source_window_as_is I'll then call update_exec_info before calling show_source_content, and pass a flag to update_exec_info to defer the refresh. There are places where update_exec_info is used without any subsequent refresh_window call (e.g. when a breakpoint is updated), so update_exec_info does not to call refresh_window in some cases, which is why I'm using a flag to control the refresh. With this changes I'm now only seeing a single refresh_window call for each vertical scroll. There should be no user visible changes after this commit.
2023-01-27gdb/tui: avoid extra refresh_window on horizontal scrollAndrew Burgess1-3/+5
While working on the previous patches I noticed that in some cases I was seeing two calls to tui_source_window_base::refresh_window when scrolling the window horizontally. The two calls would trigger in for the tui-disasm-long-lines.exp test when the pad needed to be refilled. The two called both come from tui_source_window_base::show_source_content. The first call is nested within check_and_display_highlight_if_needed, while the second call is done directly at the end of show_source_content. The check_and_display_highlight_if_needed is being used to draw the window box to the window, this is needed here because show_source_content is what gets called when the window needs updating, e.g. after a resize. We could potentially do the boxing in refresh_window, but then we'd be doing it each time we scroll, even though the box doesn't need changing in this case. However, we can move the check_and_display_highlight_if_needed to be the last thing done in show_source_content, this means that we can rely on the refresh_window call within it to be our single refresh call. There should be no user visible changes after this commit.
2023-01-27gdb/tui: rewrite of tui_source_window_base to handle very long linesAndrew Burgess3-22/+215
This commit addresses an issue that is exposed by the test script gdb.tui/tui-disasm-long-lines.exp, that is, tui_source_window_base does not handle very long lines. The problem can be traced back to the newpad call in tui_source_window_base::show_source_content, this is where we allocate a backing pad to hold the window content. Unfortunately, there appears to be a limit to the size of pad that can be allocated, and the gdb.tui/tui-disasm-long-lines.exp test goes beyond this limit. As a consequence the newpad call fails and returns nullptr. It just so happens that the reset of the tui_source_window_base code can handle the pad being nullptr (this happens anyway when the window is first created, so we already depend on nullptr handling), so all that happens is the source window displays no content. ... well, sort of ... something weird does happen in the command window, we seem to see a whole bunch of blank lines. I've not bothered to track down exactly what's happening there, but it's some consequence of GDB attempting to write content to a WINDOW* that is nullptr. Before explaining my solution, I'll outline how things currently work: Consider we have the following window content to display: aaaaaaaaaa bbbbbbbbbbbbbbbbbbbb ccccccccccccccc the longest line here is 20 characters. If our display window is 10 characters wide, then we will create a pad that is 20 characters wide, and then copy the lines of content into the pad: .--------------------. |aaaaaaaaaa | |bbbbbbbbbbbbbbbbbbbb| |ccccccccccccccc | .--------------------. Now we will copy a 10 character wide view into this pad to the display, our display will then see: .----------. |aaaaaaaaaa| |bbbbbbbbbb| |cccccccccc| .----------. As the user scrolls left and right we adjust m_horizontal_offset and use this to select which part of the pad is copied onto the display. The benefit of this is that we only need to copy the content to the pad once, which includes processing the ansi escape sequences, and then the user can scroll left and right as much as they want relatively cheaply. The problem then, is that if the longest content line is very long, then we try to allocate a very large pad, which can fail. What I propose is that we allow both the pad and the display view to scroll. Once we allow this, then it becomes possible to allocate a pad that is smaller than the longest display line. We then copy part of the content into the pad. As the user scrolls the view left and right GDB will continue to copy content from the pad just as it does right now. But, when the user scrolls to the edge of the pad, GDB will copy a new block of content into the pad, and then update the view as normal. This all works fine so long as the maximum pad size is larger than the current window size - which seems a reasonable restriction, if ncurses can't support a pad of a given size it seems likely it will not support a display window of that size either. If we return to our example above, but this time we assume that the maximum pad size is 15 characters, then initially the pad would be loaded like this: .---------------. |aaaaaaaaaa | |bbbbbbbbbbbbbbb| |ccccccccccccccc| .---------------. Notice that the last 5 characters from the 'b' line are no longer included in the pad. There is still enough content though to fill the 10 character wide display, just as we did before. The pad contents remain unchanged until the user scrolls the display right to this point: .----------. |aaaaa | |bbbbbbbbbb| |cccccccccc| .----------. Now, when the user scrolls right once more GDB spots that the user has reached the end of the pad, and the pad contents are reloaded, like this: .---------------. |aaaaa | |bbbbbbbbbbbbbbb| |cccccccccc | .---------------. The display can now be updated from the pad again just like normal. With this change in place the gdb.tui/tui-disasm-long-lines.exp test now correctly loads the assembler code, and we can scroll around as expected. Most of the changes are pretty mundane, just updating to match the above. One interesting change though is the new member function tui_source_window_base::puts_to_pad_with_skip. This replaces direct calls to tui_puts when copying content to the pad. The content strings contain ansi escape sequences. When these strings are written to the pad these escape sequences are translated into ncurses attribute setting calls. Now however, we sometimes only write a partial string to the pad, skipping some of the leading content. Imagine then that we have a content line like this: "\033[31mABCDEFGHIJKLM\033[0m" Now the escape sequences in this content mean that the actual content (the 'ABCDEFGHIJKLM') will have a red foreground color. If we want to copy this to the pad, but skip the first 3 characters, then what we expect is to have the pad contain 'DEFGHIJKLM', but this text should still have a red foreground color. It is this problem that puts_to_pad_with_skip solves. This function skips some number of printable characters, but processes all the escape sequences. This means that when we do start printing the actual content the content will have the expected attributes. /
2023-01-27gdb/tui: make m_horizontal_offset privateAndrew Burgess1-2/+4
I noticed that tui_source_window_base::m_horizontal_offset was protected, but could be made private, so lets do that. This makes more sense in the context of a later commit where I plan to add another member variable that is similar to m_horizontal_offset. The new member variable could also be private. So I had to choose, place the new member variable next to m_horizontal_offset making it protected, but grouping similar variables together, or make m_horizontal_offset private, and then add the new variable as private too. I chose to make m_horizontal_offset private, which is this commit. There should be no user visible changes after this commit.
2023-01-27gdb/tui: disable tui mode when an assert triggersAndrew Burgess2-1/+14
When an assert triggers in tui mode the output is not great, the internal backtrace that is generated is printed directly to the file descriptor for gdb_stderr, and, as a result, does not currently format itself correctly - the output uses only '\n' at the end of each line, and so, when the terminal is in raw mode, the cursor does not return to the start of each line after the '\n'. This is mostly fixable, we could update bt-utils.c to use '\r\n' instead of just '\n', and this would fix most of the problems. The one we can't easily fix is if/when GDB is built to use execinfo instead of libbacktrace, in this case we use backtrace_symbols_fd to print the symbols, and this function only uses '\n' as the line terminator. Fixing this would require switching to backtrace_symbols, but that API uses malloc, which is something we're trying to avoid (this code is called when GDB hits an error, so ideally we don't want to rely on malloc). However, the execinfo code is only used when libbacktrace is not available (or the user specifically disables libbacktrace) so maybe we can ignore that problem... ... but there is another problem. When the backtrace is printed in raw mode, it is possible that the backtrace fills the screen. With the terminal in raw mode we don't have the ability to scroll back, which means we loose some of the backtrace, which isn't ideal. In this commit I propose that we should disable tui mode whenever we handle a fatal signal, or when we hit the internal error code path (e.g. when an assert triggers). With this done then we don't need to update the bt-utils.c code, and the execinfo version of the code (using backtrace_symbols_fd) works just fine. We also get the ability to scroll back to view the error message and all of the backtrace, assuming the users terminal supports scrolling back. The only downside I see with this change is if the tui_disable call itself causes an error for some reason, or, if we handle a single at a time when it is not safe to call tui_disable, in these cases the extra tui_disable call might cause GDB to loose the original error. However, I think (just from personal experience) that the above two issues are pretty rare and the benefits from this change far out weighs the possible drawbacks.
2023-01-27gdb/tui: improve errors from tui focus commandAndrew Burgess4-10/+179
This commit improves (I think) the errors from the tui focus command. There are a number of errors that can be triggered by the focus command, they include: (1) Window name "NAME" is ambiguous (2) Unrecognized window name "NAME" (3) Window "NAME" cannot be focused Error (1) is triggered when the user gives a partial window name, and the name matches multiple windows in the current layout. It is worth noting that the ambiguity must be within the current layout; if the partial name matches one window in the current layout, and one or more windows not in the current layout, then this is not ambiguous, and focus will shift to the matching window in the current layout. This error was not previous being tested, but in this commit I make use of the Python API to trigger and test this error. Error (3) is simple enough, and was already being tested. This is triggered by something like 'focus status'. The named window needs to be present in the current layout, and non-focusable in order to trigger the error. Error (2) is what I'd like to improve in this commit. This error triggers if the name the user gives doesn't match any window in the current layout. Even if GDB does know about the window, but the window isn't in the current layout, then GDB will say it doesn't recognize the window name. In this commit I propose to to split this error into three different errors. These will be: (a) Unrecognized window name "NAME" (b) No windows matching "NAME" in the current layout (c) Window "NAME" is not in the current layout Error (a) is the same as before, but will now only trigger if GDB doesn't know about window NAME at all. If the window is known, but not in the current layout then one of the other errors will trigger. Error (b) will trigger if NAME is ambiguous for multiple windows that are not in the current layout. If NAME identifies a single window in the current layout then that window will continue to be selected, just as it currently is. Only in the case where NAME doesn't identify a window in the current layout do we then check all the other known windows, if NAME matches multiple of these, then (b) is triggered. Finally, error (c) is used when NAME uniquely identifies a single window that is not in the current layout. The hope with these new errors is that the user will have a better understanding of what went wrong. Instead of GDB claiming to not know about a window, the mention of the current layout will hint to the user that they should first switch layouts. There are tests included for all the new errors.
2023-01-27gdb/testsuite: fix line feed scrolling in tuiterm.expAndrew Burgess1-2/+16
In a following commit I managed to trigger the line feed scrolling case in tuiterm.exp. This case is currently unhandled, and this commit fills in this missing functionality. The implementation is pretty simple, just scroll all the content up one line at a time until the cursor is back on the screen (a single line of scroll is all that should be needed). This change is untested in this commit, but is required by the next commit.
2023-01-26Use clean_restart in gdb.baseTom Tromey36-172/+44
Change gdb.base to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.pythonTom Tromey9-49/+11
Change gdb.python to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.cpTom Tromey2-8/+2
Change gdb.cp to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.disasmTom Tromey6-30/+6
Change gdb.disasm to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.perfTom Tromey1-4/+1
Change gdb.perf to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.goTom Tromey1-5/+1
Change gdb.go to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.stabsTom Tromey1-4/+1
Change gdb.stabs to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.fortranTom Tromey2-11/+2
Change gdb.fortran to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.adaTom Tromey3-9/+3
Change gdb.ada to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.dwarf2Tom Tromey7-22/+7
Change gdb.dwarf2 to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.reverseTom Tromey4-24/+4
Change gdb.reverse to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.archTom Tromey27-116/+27
Change gdb.arch to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.guileTom Tromey9-53/+11
Change gdb.guile to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.threadsTom Tromey4-23/+4
Change gdb.threads to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.objcTom Tromey4-39/+4
Change gdb.objc to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.traceTom Tromey20-140/+33
Change gdb.trace to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.openclTom Tromey1-6/+1
Change gdb.opencl to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.linespecTom Tromey1-3/+1
Change gdb.linespec to use clean_restart more consistently.
2023-01-26Use clean_restart in gdb.pascalTom Tromey2-10/+2
Change gdb.pascal to use clean_restart more consistently.
2023-01-26Use mi_clean_restart moreTom Tromey60-401/+147
This changes a number of MI tests to use mi_clean_restart rather than separate calls. This reduces the number of lines, which is nice, and also provides a nicer model to copy for future tests.
2023-01-26Start gdb after building executable in mi-basics.expTom Tromey1-5/+5
A lot of the MI tests start gdb and only then build the executable. This just seemed weird to me, so I've fixed this up. In this patch, no other cleanups are done, the startup is just moved to a more logical (to me) spot.
2023-01-26Remove unnecessary call to standard_testfileTom Tromey1-2/+0
This test does not build a program and does not need to call standard_testfile.
2023-01-26Minor "require" fixupsTom Tromey2-6/+2
I found a couple of spots that could use "require", and one spot where hoisting the "require" closer to the top of the file made it more clear.
2023-01-26Remove some dead code in gdb.fortran/info-types.expTom Tromey1-17/+0
An early "return" in this test case prevents a test from running. This seems to have been intentional and has been in place since: commit d57cbee932f86df06251498daa93154046dc77c0 Author: Andrew Burgess <andrew.burgess@embecosm.com> Date: Tue Dec 3 13:18:43 2019 +0000 gdb/testsuite/fortran: Fix info-modules/info-types for gfortran 8+ This patch removes the dead code.
2023-01-26Eliminate spurious returns from the test suiteTom Tromey113-173/+1
A number of tests end with "return". However, this is unnecessary. This patch removes all of these.
2023-01-26Use clean_restart in gdb.dlangTom Tromey4-16/+4
Change gdb.dlang to use clean_restart more consistently.
2023-01-26Use ordinary calling convention for clean_restartTom Tromey2-16/+6
clean_restart accepts a single optional argument. Rather than using {args} and handling the argument by hand, change it to use Tcl's own argument-checking.
2023-01-26gdb/testsuite: initialize "correct" variable in gdb.cp/cpexprs.exp.tclSimon Marchi1-0/+2
Due to a GDB bug (visible when building with -D_GLIBCXX_DEBUG), GDB crashes somewhere in the middle of gdb.cp/cpexprs.exp, and thus fails to read the string, at gdb.cp/cpexprs.exp.tcl:725. The "correct" variable doesn't get set, and I then see this TCL error: ERROR: can't read "correct": no such variable Avoid the TCL error by initializing the "correct" variable to a dummy value. Change-Id: I828968d9b2d105ef47f8da2ef598aa16a518c059
2023-01-26gdb/testsuite/dap: fix gdb.dap/basic-dap.exp disassembly test for PIESimon Marchi1-3/+30
Prior to this patch, I get: >>> {"seq": 17, "type": "request", "command": "disassemble", "arguments": {"memoryReference": "0x115d", "instructionCount": 1}} Content-Length: 147 {"request_seq": 17, "type": "response", "command": "disassemble", "success": false, "message": "Cannot access memory at address 0x115d", "seq": 41}FAIL: gdb.dap/basic-dap.exp: disassemble one instruction success FAIL: gdb.dap/basic-dap.exp: instructions in disassemble output The problem is that the PC to disassemble is taken from the breakpoint insertion response, which happens before running. With a PIE executable, that PC is unrelocated, but the disassembly request happens after relocation. I chose to fix this by watching for a breakpoint changed event giving the new breakpoint address, and recording the address from there. I think this is an interesting way to fix it, because it adds a bit of test coverage, I don't think these events are checked right now. Other ways to fix it would be: - Get the address by doing a breakpoint insertion after the program is started, or some other way. - Do the disassembly by symbol instead of by address. - Do the disassembly before running the program. Change-Id: I3c396f796ac4c8b22e7dfd2fa1c5467f7a47e84e
2023-01-26gdb/testsuite/dap: make dap_wait_for_event_and_check return preceding messagesSimon Marchi1-6/+22
In the following patch, I change gdb.dap/basic-dap.exp such that after waiting for some event, it checks if it received another event meanwhile. To help with this, make dap_wait_for_event_and_check and _dap_dap_wait_for_event return a list with everything received before the event of interest. This is similar to what dap_check_request_and_response returns. Change-Id: I85c8980203a2dec833937e7552c2196bc137935d
2023-01-26gdb/testsuite/dap: rename dap_read_event to dap_wait_for_event_and_checkSimon Marchi2-8/+8
I think that name describes a bit better what the proc does, it is similar to "wait_for" in tuiterm.exp. Change-Id: Ie55aa011e6595dd1b5a874db13881ba572ace419
2023-01-26gdb/testsuite/dap: pass around dicts instead of TON objectsSimon Marchi2-33/+30
The DAP helper functions generally return TON objects. However, callers almost all immediately use ton::2dict to convert them to dicts, to access their contents. This commits makes things a bit simpler for them by having function return dicts directly instead. The downside is that the TON objects contain type information. For instance, a "2" in a TCL dict could have been the integer 2 or the string "2" in JSON. By converting to TCL dicts, we lose that information. If some tests specifically want to check the types of some fields, I think we can add intermediary functions that return TON objects, without having to complicate other callers who don't care. Change-Id: I2ca47bea355bf459090bae8680c6a917350b5c3f