aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2022-05-20Test "set multiple-symbols on" creating multiple breakpointsPedro Alves1-25/+75
To look for code paths that lead to create_breakpoints_sal creating multiple breakpoints, I ran the whole testsuite with this hack: --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8377,8 +8377,7 @@ create_breakpoints_sal (struct gdbarch *gdbarch, int from_tty, int enabled, int internal, unsigned flags) { - if (canonical->pre_expanded) - gdb_assert (canonical->lsals.size () == 1); + gdb_assert (canonical->lsals.size () == 1); surprisingly, the assert never failed... The way to get to create_breakpoints_sal with multiple lsals is to use "set multiple-symbols ask" and then select multiple options from the menu, like so: (gdb) set multiple-symbols ask (gdb) b overload1arg [0] cancel [1] all [2] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg() [3] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(char) [4] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(double) [5] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(float) [6] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(int) [7] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(long) [8] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(short) [9] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(signed char) [10] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(unsigned char) [11] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(unsigned int) [12] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(unsigned long) [13] /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc:foo::overload1arg(unsigned short) > 2-3 Breakpoint 2 at 0x1532: file /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc, line 107. Breakpoint 3 at 0x154b: file /home/pedro/gdb/binutils-gdb/src/gdb/testsuite/gdb.cp/ovldbreak.cc, line 110. warning: Multiple breakpoints were set. Use the "delete" command to delete unwanted breakpoints. ... which would trigger the assert. This commit makes gdb.cp/ovldbreak.exp test this scenario. It does that by making set_bp_overloaded take a list of expected created breakpoints rather than just one breakpoint. It converts the procedure to use gdb_test_multiple instead of send_gdb/gdb_expect along the way. Change-Id: Id87d1e08feb6670440d926f5344e5081f5e37c8e
2022-05-20Make sure momentary breakpoints are always thread-specificPedro Alves1-37/+46
This adds a new ctor to momentary_breakpoints with a few parameters that are always necessary for momentary breakpoints. In particular, I noticed that set_std_terminate_breakpoint doesn't make the breakpoint be thread specific, which looks like a bug to me. The point of that breakpoint is to intercept std::terminate calls that happen as result of the called thread throwing an exception that won't be caught by the dummy frame. If some other thread calls std::terminate, IMO, it's no different from some other thread calling exit/_exit, for example. Change-Id: Ifc5ff4a6d6e58b8c4854d00b86725382d38a1a02
2022-05-20Momentary breakpoints should have no breakpoint numberPedro Alves1-1/+0
Momentary breakpoints have no breakpoint number, their breakpoint number should be always 0, to avoid constantly incrementing (or decrementing) the internal breakpoint count. Indeed, set_momentary_breakpoint installs the created breakpoint without a number. However, momentary_breakpoint_from_master incorrectly gives an internal breakpoint number to the new breakpoint. This commit fixes that. Change-Id: Iedcae5432cdf232db9e9a6e1a646d358abd34f95
2022-05-20Add/tweak intro comments of struct breakpoint and several subclassesPedro Alves2-8/+17
This tweaks the intro comments of the following classes: internal_breakpoint momentary_breakpoint breakpoint base_breakpoint watchpoint catchpoint Change-Id: If6b31f51ebbb81705fbe5b8435f60ab2c88a98c8
2022-05-20Move add_location(sal) to base_breakpointPedro Alves5-37/+31
After the previous patches, only base_breakpoint subclasses use add_location(sal), so we can move it to base_breakpoint (a.k.a. base class for code breakpoints). This requires a few casts here and there, but always at spots where you can see from context what the breakpoint's type actually is. I inlined new_single_step_breakpoint into its only caller exactly for this reason. I did try to propagate more use of base_breakpoint to avoid casts, but that turned out unwieldy for this patch. Change-Id: I49d959322b0fdce5a88a216bb44730fc5dd7c6f8
2022-05-20Move common bits of catchpoint/exception_catchpoint to breakpoint's ctorPedro Alves3-19/+21
Move common bits of catchpoint and exception_catchpoint to breakpoint's ctor, to avoid duplicating code. Change-Id: I3a115180f4d496426522f1d89a3875026aea3cf2
2022-05-20Make catchpoint inherit breakpoint, eliminate init_raw_breakpointPedro Alves3-37/+7
struct catchpoint's ctor currently calls init_raw_breakpoint, which is a bit weird, as that ctor-like function takes a sal argument, but catchpoints don't have code locations. Instead, make struct catchpoint's ctor add the catchpoint's dummy location using add_dummy_location. init_raw_breakpoint uses add_location under the hood, and with a dummy sal it would ultimately use the breakpoint's gdbarch for the location's gdbarch, so replace the references to loc->gdbarch (which is now NULL) in syscall_catchpoint to references to the catchpoint's gdbarch. struct catchpoint's ctor was the last user of init_raw_breakpoint, so this commit eliminates the latter. Since catchpoint locations aren't code locations, make struct catchpoint inherit struct breakpoint instead of base_breakpoint. This let's us delete the tracepoint::re_set override too. Change-Id: Ib428bf71efb09fdaf399c56e4372b0f41d9c5869
2022-05-20Make breakpoint_address_bits look at the location kindPedro Alves2-37/+23
Software watchpoints allocate a special dummy location using software_watchpoint_add_no_memory_location, and then breakpoint_address_bits checks whether the location is that special location to decide whether the location has a meaninful address to print. Introduce a new bp_loc_software_watchpoint location kind, and make breakpoint_address_bits use bl_address_is_meaningful instead, which returns false for bp_loc_other, which is in accordance with we document for bp_location::address: /* (... snip ...) Valid for all types except bp_loc_other. */ CORE_ADDR address = 0; Rename software_watchpoint_add_no_memory_location to add_dummy_location, and simplify it. This will be used by catchpoints too in a following patch. Note that neither "info breakpoints" nor "maint info breakpoints" actually prints the addresses of watchpoints, but I think it would be useful to do so in "maint info breakpoints". This approach let's us implement that in the future. Change-Id: I50e398f66ef618c31ffa662da755eaba6295aed7
2022-05-20Make exception_catchpoint inherit base_breakpoint instead of catchpointPedro Alves1-6/+12
exception_catchpoint is really a code breakpoint, with locations set by sals, re-set like other code breakpoints, etc., so make it inherit base_breakpoint. This adds a bit of duplicated code to exception_catchpoint's ctor (copied from struct catchpoint's ctor), but it will be eliminated in a following patch. Change-Id: I9fbb2927491120e9744a4f5e5cb5e6870ca07009
2022-05-20Refactor momentary breakpoints, eliminate set_raw_breakpoint{,_without_location}Pedro Alves1-73/+24
This commit makes set_momentary_breakpoint allocate the breakpoint type without relying on set_raw_breakpoint, and similarly, momentary_breakpoint_from_master not rely on set_raw_breakpoint_without_location. This will let us convert init_raw_breakpoint to a ctor in a following patch. The comment about set_raw_breakpoint being used in gdbtk sources is stale. gdbtk no longer uses it. Change-Id: Ibbf77731e4b22e18ccebc1b5799bbec0aff28c8a
2022-05-20Refactor set_internal_breakpoint / internal_breakpoint ctorPedro Alves1-19/+18
This moves initialization of internal_breakpoint's breakpoint fields to internal_breakpoint's ctor, and stops using new_breakpoint_from_type for internal_breakpoint breakpoints. Change-Id: I898ed0565f47cb00e4429f1c6446e6f9a385a78d
2022-05-20Convert init_ada_exception_catchpoint to a ctorPedro Alves3-59/+49
Currently, init_ada_exception_catchpoint is defined in breakpoint.c, I presume so it can call the static describe_other_breakpoints function. I think this is a dependency inversion. init_ada_exception_catchpoint, being code specific to Ada catchpoints, should be in ada-lang.c, and describe_other_breakpoints, a core function, should be exported. And then, we can convert init_ada_exception_catchpoint to an ada_catchpoint ctor. Change-Id: I07695572dabc5a75d3d3740fd9b95db1529406a1
2022-05-20Make ada_catchpoint_location's owner ctor parameter be ada_catchpointPedro Alves1-16/+16
This commit changes ada_catchpoint_location's ctor from: ada_catchpoint_location (breakpoint *owner) to: ada_catchpoint_location (ada_catchpoint *owner) just to make the code better document intention. To do this, we need to move the ada_catchpoint_location type's definition to after ada_catchpoint is defined, otherwise the compiler doesn't know that ada_catchpoint is convertible to struct breakpoint. Change-Id: Id908b2e38bde30b262381e00c5637adb9bf0129d
2022-05-20init_breakpoint_sal -> base_breakpoint::base_breakpointPedro Alves2-122/+129
This converts init_breakpoint_sal to a base_breakpoint constructor. It removes a use of init_raw_breakpoint. To avoid manually adding a bunch of parameters to new_breakpoint_from_type, and manually passing them down to the constructors of a number of different base_breakpoint subclasses, make new_breakpoint_from_type a variable template function. Change-Id: I4cc24133ac4c292f547289ec782fc78e5bbe2510
2022-05-20Remove "internal" parameter from a couple functionsPedro Alves1-3/+3
None of init_breakpoint_sal, create_breakpoint_sal, and strace_marker_create_breakpoints_sal make use of their "internal" parameter, so remove it. Change-Id: I943f3bb44717ade7a7b7547edf8f3ff3c37da435
2022-05-20More breakpoint_ops parameter eliminationPedro Alves2-11/+8
Remove breakpoint_ops parameters from a few functions that don't need it. Change-Id: Ifcf5e1cc688184acbf5e19b8ea60138ebe63cf28
2022-05-20Make a few functions work with base_breakpoint instead of breakpointPedro Alves2-31/+8
This makes tracepoints inherit from base_breakpoint, since their locations are code locations. If we do that, then we can eliminate tracepoint::re_set and tracepoint::decode_location, as they are doing the same as the base_breakpoint implementations. With this, all breakpoint types created by new_breakpoint_from_type are code breakpoints, i.e., base_breakpoint subclasses, and thus we can make it return a base_breakpoint pointer. Finally, init_breakpoint_sal can take a base_breakpoint pointer as "self" pointer too. This will let us convert this function to a base_breakpoint ctor in a following patch. Change-Id: I3a4073ff1a4c865f525588095c18dc42b744cb54
2022-05-20ranged_breakpoint: move initialization to ctorPedro Alves1-8/+19
Move initialization of ranged_breakpoint's fields to its ctor. Change-Id: If7b842861f3cc6a429ea329d45598b5852283ba3
2022-05-20ranged_breakpoint: use install_breakpointPedro Alves1-12/+5
This commit replaces a chunk of code in break_range_command by an equivalent call to install_breakpoint. Change-Id: I31c06cabd36f5be91740aab029265f678aa78e35
2022-05-20ranged_breakpoint: don't use init_raw_breakpointPedro Alves1-1/+1
ranged_breakpoint's ctor already sets the breakpoint's type to bp_hardware_breakpoint. Since this is a "regular" breakpoint, b->pspace should remain NULL. Thus, the only thing init_raw_breakpoint is needed for, is to add the breakpoint's location. Do that directly. Change-Id: I1505de94c3919881c2b300437e2c0da9b05f76bd
2022-05-20Make structs breakpoint/base_breakpoint/catchpoint be abstractPedro Alves2-1/+20
You should never instanciate these types directly. Change-Id: I8086c74c415eadbd44924bb0ef20f34b5b97ee6f
2022-05-20add_location_to_breakpoint -> breakpoint::add_locationPedro Alves2-37/+36
Make add_location_to_breakpoint be a method of struct breakpoint. A patch later in the series will move this to base_breakpoint, but for now, it needs to be here. Change-Id: I5bdc2ec1a7c2d66f26f51bf6f6adc8384a90b129
2022-05-20PowerPC: Make test gdb.arch/powerpc-power10.exp Endian independent.Carl Love1-368/+746
The .quad statement stores the 64-bit hex value in Endian order. When used to store a 64-bit prefix instructions on Big Endian (BE) systems, the .quad statement stores the 32-bit suffix followed by the 32-bit prefix rather than the expected order of prefix word followed by the suffix word. GDB fetches 32-bits at a time when disassembling instructions. The disassembly on BE gets messed up since GDB fetches the suffix first and interprets it as a word instruction not a prefixed instruction. When gdb fetches the prefix part of the instruction, following the initial suffix word, gdb associates the prefix word incorrectly with the following 32-bits as the suffix for the instruction when in fact it is the following instruction. For example on BE we have two prefixed instructions stored using the .quad statement as follows: addr word GDB action --------------------------------------------- 1 suffix inst A <- GDB interprets as a word instruction 2 prefix inst A <- GDB uses this prefix with 3 suffix inst B <- this suffix rather than the suffix at addr 1. 4 prefix inst B This patch changes the .quad statement into two .longs to explicitly store the prefix followed by the suffix of the instruction. The patch rearranges the instructions to put all of the word instructions together followed by the prefix instructions for clarity. The patch has been tested on Power 10 and Power 7 BE and LE to verify the change works as expected.
2022-05-20Remove obsolete text from documentationTom Tromey1-3/+0
The documentation says that -enable-pretty-printing is experimental in 7.0 and may change -- that's long enough ago that I think we can say that this text is no longer correct or useful.
2022-05-20Fix non-pointer type compilation error in aix-thread.cAditya Vidyadhar Kamath1-2/+2
In aix-thread.c we use ms->value_address () to get the symbol address. This triggers the following compiler error... base operand of '->' has non-pointer type 'bound_minimal_symbol' ... because ms is not a pointer. This commit fixes this error by using ms.value_address () instead.
2022-05-19gdb/doc: use @value{GDBP} in 'info pretty-printer' exampleAndrew Burgess1-8/+8
Update the 'info pretty-printer' example in the manual to make use of @value{GDBP} instead of hard-coding '(gdb)'.
2022-05-19gdb/doc: make use of group/end group in 'info pretty-printers' exampleAndrew Burgess1-0/+10
The 'info pretty-printers' example is pretty long and consists of many commands and their output. Currently, when the pdf manual is generated this example spans a page-break, with the page-break falling part way through some example output from GDB. This commit breaks up the example using @group .... @end group, within each group is a single GDB command and all its output. Now, when the pdf manual is created, the page-break is placed after the output of one GDB command, and before the subsequent command, this looks much nicer.
2022-05-19gdb/doc: fix inconsistent info pretty-printer exampleNikolaos Chatzikonstantinou1-3/+1
The example for 'info pretty-printer' in the manual passes an object-regexp in some cases, but presents output as though no object-regexp was passed. This commit fixes the two mistakes, in one case, fixing the output to filter based on object-regexp, and in the other, to remove the object-regexp from the command and leave all the output.
2022-05-19gdb: testsuite: Support displaced stepping on LoongArchTiezhu Yang1-1/+1
When execute the following command on LoongArch: make check-gdb TESTS="gdb.base/async-shell.exp" we can see the following message in gdb/testsuite/gdb.sum: UNSUPPORTED: gdb.base/async-shell.exp: displaced stepping modify support_displaced_stepping to support displaced stepping on LoongArch. With this patch: PASS: gdb.base/async-shell.exp: run & PASS: gdb.base/async-shell.exp: shell echo foo PASS: gdb.base/async-shell.exp: interrupt PASS: gdb.base/async-shell.exp: process stopped I did the following tests that use support_displaced_stepping with this patch on LoongArch, there is no failed testcases. loongson@linux:~/gdb.git$ grep -r support_displaced_stepping gdb/testsuite/gdb.* gdb/testsuite/gdb.arch/disp-step-insn-reloc.exp:if { ![support_displaced_stepping] } { gdb/testsuite/gdb.base/step-over-no-symbols.exp: if { $displaced != "off" && ![support_displaced_stepping] } { gdb/testsuite/gdb.base/moribund-step.exp:if { ![support_displaced_stepping] } { gdb/testsuite/gdb.base/async-shell.exp:if { ![support_displaced_stepping] } { gdb/testsuite/gdb.base/inferior-died.exp:if { ![support_displaced_stepping] } { gdb/testsuite/gdb.base/step-over-syscall.exp: if {$displaced == "on" && ![support_displaced_stepping]} { gdb/testsuite/gdb.mi/mi-watch-nonstop.exp:if { ![support_displaced_stepping] } { gdb/testsuite/gdb.mi/mi-ns-stale-regcache.exp:if { ![support_displaced_stepping] } { gdb/testsuite/gdb.mi/mi-nonstop.exp:if { ![support_displaced_stepping] } { gdb/testsuite/gdb.mi/mi-nsmoribund.exp:if { ![support_displaced_stepping] } { gdb/testsuite/gdb.mi/mi-nsintrall.exp:if { ![support_displaced_stepping] } { gdb/testsuite/gdb.mi/mi-nsthrexec.exp:if { ![support_displaced_stepping] } { gdb/testsuite/gdb.mi/mi-nonstop-exit.exp:if { ![support_displaced_stepping] } { gdb/testsuite/gdb.multi/watchpoint-multi.exp:if [support_displaced_stepping] { gdb/testsuite/gdb.python/py-evthreads.exp:if { ![support_displaced_stepping] } { gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp: if { $displaced != "off" && ![support_displaced_stepping] } { gdb/testsuite/gdb.threads/interrupt-while-step-over.exp: if { ${displaced-stepping} != "off" && ![support_displaced_stepping] } { gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp: if { $displaced != "off" && ![support_displaced_stepping] } { Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
2022-05-18Use aarch64_features to describe register features in target descriptions.John Baldwin8-38/+70
Replace the sve bool member of aarch64_features with a vq member that holds the vector quotient. It is zero if SVE is not present. Add std::hash<> specialization and operator== so that aarch64_features can be used as a key with std::unordered_map<>. Change the various functions that create or lookup aarch64 target descriptions to accept a const aarch64_features object rather than a growing number of arguments. Replace the multi-dimension tdesc_aarch64_list arrays used to cache target descriptions with unordered_maps indexed by aarch64_feature.
2022-05-18PowerPC: bp-permanent.exp, kill-after-signal fixCarl Love2-12/+18
Fix changes that didn't make it into commit: dd9cd55e990bcc9f8448cac38d242d53974b3604. Fix missing -wrap on gdb_test_multiple in gdb.base/kill-after-signal.exp that is causing regression test on x86_64-linux with taskset -c 0.
2022-05-18[AArch64] Return the regnum for PC (32) on aarch64Yichao Yu4-0/+122
This will allow the unwind info to explicitly specify a different value for the return address from the link register. Such usage, although uncommon, is valid and useful for signal frames. It is also supported by aadwarf64 from ARM (Note 9 in [1]). Ref https://sourceware.org/pipermail/gdb/2022-May/050091.html [1] https://github.com/ARM-software/abi-aa/blob/2022Q1/aadwarf64/aadwarf64.rst#dwarf-register-names Signed-off-by: Luis Machado <luis.machado@arm.com>
2022-05-18Support -prompt and -lbl in gdb_testPedro Alves3-35/+42
This teaches gdb_test to forward the -prompt and -lbl options to gdb_test_multiple. The option parsing is done with parse_args. As a cleanup, instead of using llength and lindex to get at the positional arguments, use lassign, and check whether the corresponding variable is empty. Convert gdb.base/ui-redirect.exp and gdb.xml/tdesc-reload.exp to use gdb_test -prompt/-lbl instead of gdb_test_multiple as examples. Change-Id: I243e1296d32c05a421ccef30b63d43a89eaeb4a0
2022-05-18Remove unused DWARF PAUTH registersLuis Machado2-5/+0
The AARCH64_DWARF_PAUTH_DMASK and AARCH64_DWARF_PAUTH_CMASK DWARF registers never made their way into the aadwarf64. The following patch removes these constants and their use. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26295
2022-05-18Rename PAUTH_RA_STATE to RA_SIGN_STATELuis Machado2-18/+18
The aadwarf64 [1] names this register RA_SIGN_STATE, so update the code to use the same name. [1] https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst
2022-05-18[gdb/testsuite] Simplify unknown lang testing in gdb.base/parse_number.expTom de Vries1-3/+8
Move testing of language unknown out of the $supported_archs loop in gdb.base/parse_number.exp. This reduces total amount of tests from 18466 to 17744. Tested on x86_64-linux.
2022-05-18[gdb/testsuite] Use hex_for_lang in gdb.base/parse_number.expTom de Vries1-1/+14
In gdb.base/parse_number.exp, add a new proc hex_for_lang that formats a hex number appropriately for a given language. Tested on x86_64-linux.
2022-05-18[gdb/tdep] Add gdb/syscalls/update-linux-from-src.shTom de Vries23-38/+1230
Add a new script gdb/syscalls/update-linux-from-src.sh, that can be used to generate *-linux.xml.in files from linux kernel sources, like so: ... $ ./update-linux-from-src.sh ~/upstream/linux-stable.git Skipping aarch64-linux.xml.in, no syscall.tbl Generating amd64-linux.xml.in Skipping arm-linux.xml.in, use arm-linux.py instead Skipping bfin-linux.xml.in, no longer supported Generating i386-linux.xml.in Generating mips-n32-linux.xml.in Generating mips-n64-linux.xml.in Generating mips-o32-linux.xml.in Generating ppc64-linux.xml.in Generating ppc-linux.xml.in Generating s390-linux.xml.in Generating s390x-linux.xml.in Generating sparc64-linux.xml.in Generating sparc-linux.xml.in ... Update *-linux.xml.in and *-linux.xml using linux kernel tag v5.18-rc6.
2022-05-17Fix typo in info pageNikolaos Chatzikonstantinou1-1/+1
2022-05-17Fix gdb.python/py-connection.exp with remote targetsPedro Alves1-2/+2
After the patch to make gdb_test's question non-optional when specified, gdb.python/py-connection.exp started failing like so: $ make check TESTS="gdb.python/py-connection.exp" RUNTESTFLAGS="--target_board=native-gdbserver" (gdb) PASS: gdb.python/py-connection.exp: info connections while the connection is still around disconnect^M Ending remote debugging.^M (gdb) FAIL: gdb.python/py-connection.exp: kill the inferior The problem is that "disconnect" when debugging with the native target asks the user whether to kill the program, while with remote targets, it doesn't. Fix it by explicitly killing before disconnecting. Tested with --target_board unix, native-gdbserver, and native-extended-gdbserver. Change-Id: Icd85015c76deb84b71894715d43853c1087eba0b
2022-05-17gdb, btrace: Throw an error for empty recordings when replaying starts.Felix Willgerodt1-1/+1
This makes record_btrace_start_replaying() more consistent, as it already errors out e.g. on a recording with only gaps.
2022-05-17Make gdb_test's question non-optional if specifiedPedro Alves1-4/+21
gdb_test supports handling scenarios where GDB asks a question before finishing handling some command. The full prototype of gdb_test is: # gdb_test COMMAND PATTERN MESSAGE QUESTION RESPONSE However, QUESTION is a question that GDB _may_ ask, not one that GDB _must_ ask: # QUESTION is a question GDB may ask in response to COMMAND, like # "are you sure?" # RESPONSE is the response to send if QUESTION appears. If GDB doesn't raise the question, the test still passes. I think that this is a misfeature. If GDB regresses and stops asking a question, the testsuite won't notice. So I think that if a QUESTION is specified, gdb_test should ensure it comes out of GDB. Running the testsuite exposed a number of tests that pass QUESTION/RESPONSE to GDB, but no question comes out. The previous commits fixed them all, so this commit changes gdb_test's behavior. A related issue is that gdb_test doesn't enforce that if you specify QUESTION, that you also specify RESPONSE. I.e., you should pass 1, 2, 3, or 5 arguments to gdb_test, but never 4, or more than 5. Making gdb_test detect bogus arguments actually regressed some testcases, also all fixed in previous commits. Change-Id: I47c39c9034e6a6841129312037a5ca4c5811f0db
2022-05-17gdb.base/skip.exp: Don't abuse gdb_test's question supportPedro Alves1-24/+31
gdb.base/skip.exp abuses gdb_test's support for answering a GDB question to do this: # With gcc 9.2.0 we jump once back to main before entering foo here. # If that happens try to step a second time. gdb_test "step" "foo \\(\\) at.*" "step 3" \ "main \\(\\) at .*\r\n$gdb_prompt " "step" After a patch later in this series, gdb_test will FAIL if GDB does NOT issue the question, so this test would start failing on older GCCs. Switch to using gdb_test_multiple instead. There are three spots in the file that have the same pattern, and they're actually in a sequence of commands that is repeated those 3 times. Factor all that out to a procedure. I don't have gcc 9.2 handy, but I do have gcc 6.5, and that one is affected as well, so update the comment. Change-Id: If0a7e3cdf5191b4eec95ce0c8845c3a4d801c39e
2022-05-17Avoid having to unload file in gdb.server/connect-with-no-symbol-file.expPedro Alves1-10/+7
gdb.server/connect-with-no-symbol-file.exp's connect_no_symbol_file does: gdb_test "file" ".*" "discard symbol table" \ {Discard symbol table from `.*'\? \(y or n\) } "y" A following patch will make gdb_test expect the question out of GDB if one is passed down as argument to gdb_test. With that, this test starts failing. This is because connect_no_symbol_file is called in a loop, and the first time around, there's a loaded file, so "file" asks the "Discard symbol table ... ?" question, while in the following iterations there's no file, so there's no question. Fix this by not loading a file into GDB in the first place. Change-Id: I810c036b57842c4c5b47faf340466b0d446d1abc
2022-05-17Fix bogus gdb_test invocationsPedro Alves3-2/+3
A following patch will make gdb_test error out if bogus arguments are passed, which exposed bugs in a few testcases: - gdb.python/py-parameter.exp, passing a spurious "1" as extra parameter, resulting in: ERROR: Unexpected arguments: {set test-file-param bar.txt} {The name of the file has been changed to bar.txt} {set new file parameter} 1 - gdb.python/py-xmethods.exp, a missing test message, resulting in the next gdb_test being interpreted as message, question and response! With the enforcing patch, this was caught with: ERROR: Unexpected arguments: {p g.mul<char>('a')} {From Python G<>::mul.*} gdb_test {p g_ptr->mul<char>('a')} {From Python G<>::mul.*} {after: g_ptr->mul<char>('a')} - gdb.base/pointers.exp, missing a quote. Change-Id: I66f2db4412025a64121db7347dfb0b48240d46d4
2022-05-17gdb.base/scope.exp: Remove bogus gdb_test questionsPedro Alves1-30/+30
This test is abusing the QUESTION/RESPONSE feature to send an alternative command to GDB if the first command fails. Like so: gdb_test "print 'scope0.c'::filelocal" \ "\\\$$decimal = 1" "print 'scope0.c'::filelocal at main" \ "No symbol \"scope0.c\" in current context.*" \ "print '$srcdir/$subdir/scope0.c'::filelocal" So if 'scope0.c' doesn't work, we try again with '$srcdir/$subdir/scope0.c'. I strongly suspect this is really an obsolete test. I think that if '$srcdir/$subdir/scope0.c' works, then 'scope0.c' should have worked too, thus I'd think that if we pass due to the question path, then it's a bug. So just remove the question part passed to gdb_test. Change-Id: I2acc99285f1d519284051b49693b5441fbdfe3cd
2022-05-17Remove gdb_test questions that GDB doesn't askPedro Alves6-11/+6
Change-Id: Ib2616dc883e9dc9ee100f6c86d83a921a0113c16
2022-05-16gdb: Fix typo in last change in gdb.texinfoEli Zaretskii1-1/+1
2022-05-16gdb: Document the 'metadata' styling in GDB displays.Eli Zaretskii1-0/+10
The 'metadata' styling was never documented in the GDB manual. This fills that gap.
2022-05-16Fix Ada exception regression on WindowsTom Tromey1-1/+1
The breakpoint c++-ification series introduced another bug in Ada -- it caused "catch exception" and related commands to fail on Windows. The problem is that the re_set method calls the wrong superclass method, so the breakpoint doesn't get correctly re-set when the runtime offsets change. This patch fixes the problem.