aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ada
AgeCommit message (Collapse)AuthorFilesLines
2022-09-07[gdb/testsuite] Fix gdb.ada/access_tagged_param.exp for aarch64Tom de Vries3-3/+3
On aarch64-linux, I run into: ... Breakpoint 2, pck.inspect (obj=0x430eb0 \ <system.pool_global.global_pool_object>, <objL>=0) at pck.adb:17^M 17 procedure Inspect (Obj: access Top_T'Class) is^M (gdb) FAIL: gdb.ada/access_tagged_param.exp: continue ... while on x86_64-linux, I see: ... Breakpoint 2, pck.inspect (obj=0x62b2a0, <objL>=2) at pck.adb:19^M 19 null;^M (gdb) PASS: gdb.ada/access_tagged_param.exp: continue ... Note the different line numbers, 17 vs 19. The difference comes from the gdbarch_skip_prologue implementation. The amd64_skip_prologue implementation doesn't use gcc line numbers, and falls back to the architecture-specific prologue analyzer, which correctly skips past the prologue, to address 0x4022f7: ... 00000000004022ec <pck__inspect>: 4022ec: 55 push %rbp 4022ed: 48 89 e5 mov %rsp,%rbp 4022f0: 48 89 7d f8 mov %rdi,-0x8(%rbp) 4022f4: 89 75 f4 mov %esi,-0xc(%rbp) 4022f7: 90 nop 4022f8: 90 nop 4022f9: 5d pop %rbp 4022fa: c3 ret ... The aarch64_skip_prologue implementation does use gcc line numbers, which are: ... File name Line number Starting address View Stmt pck.adb 17 0x402580 x pck.adb 17 0x402580 1 x pck.adb 19 0x40258c x pck.adb 20 0x402590 x ... and which are represented like this internally in gdb: ... INDEX LINE ADDRESS IS-STMT PROLOGUE-END 0 17 0x0000000000402580 Y 1 17 0x0000000000402580 Y 2 19 0x000000000040258c Y 3 20 0x0000000000402590 Y 4 END 0x00000000004025a0 Y ... The second entry is interpreted as end-of-prologue, so 0x402580 is used, while the actual end of the prologue is at 0x40258c: ... 0000000000402580 <pck__inspect>: 402580: d10043ff sub sp, sp, #0x10 402584: f90007e0 str x0, [sp, #8] 402588: b90007e1 str w1, [sp, #4] 40258c: d503201f nop 402590: d503201f nop 402594: 910043ff add sp, sp, #0x10 402598: d65f03c0 ret 40259c: d503201f nop ... Note that the architecture-specific prologue analyzer would have gotten this right: ... (gdb) p /x aarch64_analyze_prologue (gdbarch, pc, pc + 128, 0) $2 = 0x40258c ... Fix the FAIL by making the test-case more robust against problems in prologue skipping, by setting the breakpoint on line 19 instead. Likewise in a few similar test-cases. Tested on x86_64-linux and aarch64-linux.
2022-07-30[gdb/testsuite] Fix gdb.ada/literals.exp with aarch64Tom de Vries1-1/+1
On aarch64-linux, I run into: ... (gdb) print 16#ffffffffffffffff#^M $7 = 18446744073709551615^M (gdb) FAIL: gdb.ada/literals.exp: print 16#ffffffffffffffff# ... while on x86_64-linux instead, I get: ... (gdb) print 16#ffffffffffffffff#^M $7 = -1^M (gdb) PASS: gdb.ada/literals.exp: print 16#ffffffffffffffff# ... We can easily reproduce this on x86_64-linux using: ... $ gdb -q -batch -ex "set lang ada" -ex "set arch i386" \ -ex "print 16#ffffffffffffffff#" $1 = -1 $ gdb -q -batch -ex "set lang ada" -ex "set arch aarch64" \ -ex "print 16#ffffffffffffffff#" $1 = 18446744073709551615 ... With i386, we have: ... (gdb) p int_bits $3 = 32 (gdb) p long_bits $4 = 32 (gdb) p long_long_bits $5 = 64 ... and so in processInt we hit the fits-in-unsigned-long-long case where we use as type long long: ... /* Note: Interprets ULLONG_MAX as -1. */ yylval.typed_val.type = type_long_long (par_state); ... With aarch64, we have instead: ... (gdb) p int_bits $1 = 32 (gdb) p long_bits $2 = 64 (gdb) p long_long_bits $3 = 64 ... and so in processInt we hit the fits-in-unsigned-long case where we use as type unsigned long: ... yylval.typed_val.type = builtin_type (par_state->gdbarch ())->builtin_unsigned_long; ... It's not clear why for ada we're using long long for the fits-in-unsigned-long-long case. Fix this by using unsigned long long for the fits-in-unsigned-long-long case, meaning the new reference output is 18446744073709551615 instead of -1. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29416
2022-07-29[gdb/testsuite] Fix gdb.ada/convvar_comp.exp with broken debug infoTom de Vries1-1/+9
On aarch64-linux I run into this failure with gcc 7.5.0: ... (gdb) print $item.started^M $1 = (-5312, 65535, 4202476)^M (gdb) FAIL: gdb.ada/convvar_comp.exp: print $item.started ... The test-case expects (0, 0, 0), but we're getting another value due to incorrect location information. Work around this by: - first printing the value, and then - verifying that the convenience variable matches the printed value. I've verified that the test-case still checks what it should by disabling the fix from commit cc0e770c0d0 ("memory error printing component of record from convenience variable") and observing the test-case fail. Tested on x86_64-linux and aarch64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29420
2022-07-22gdb/testsuite: give binaries distinct names in Ada testsSimon Marchi34-71/+71
Some Ada tests repeat their test sequence with different gnat-encodings, typically "all" and "minimal". However, they give the same name to both binaries, meaning the second run overwrites the binary of the first run. This makes it difficult and confusing when trying to reproduce problems manually with the test artifacts. Change those tests to use unique names for each pass. Change-Id: Iaa3c9f041241249a7d67392e785c31aa189dcc88
2022-07-18Remove array typedef assumption for AdaTom Tromey3-0/+128
Currently the Ada code assumes that it can distinguish between a multi-dimensional array and an array of arrays by looking for an intervening typedef -- that is, for an array of arrays, there will be a typedef wrapping the innermost array type. A recent compiler change removes this typedef, which causes a gdb failure in the internal AdaCore test suite. This patch handles this case by checking whether the array type in question has a name.
2022-06-24gdb/testsuite: remove unneeded calls to get_compiler_infoAndrew Burgess4-13/+0
It is not necessary to call get_compiler_info before calling test_compiler_info, and, after recent commits that removed setting up the gcc_compiled, true, and false globals from get_compiler_info, there is now no longer any need for any test script to call get_compiler_info directly. As a result every call to get_compiler_info outside of lib/gdb.exp is redundant, and this commit removes them all. There should be no change in what is tested after this commit.
2022-06-14[gdb/testsuite] Fix regexp in gdb.ada/mi_var_access.expTom de Vries1-1/+3
With gcc-12 and target board unix/-m32, we run into: ... (gdb) ^M Expecting: ^(-var-create A_String_Access \* A_String_Access[^M ]+)?(\^done,name="A_String_Access",numchild="1",.*[^M ]+[(]gdb[)] ^M [ ]*) -var-create A_String_Access * A_String_Access^M ^error,msg="Value out of range."^M (gdb) ^M FAIL: gdb.ada/mi_var_access.exp: Create varobj (unexpected output) ... What happens is easier to understand if we take things out of the mi context: ... $ gdb -q -batch \ outputs/gdb.ada/mi_var_access/mi_access \ -ex "b mi_access.adb:19" \ -ex run \ -ex "p A_String_Access" ... Breakpoint 1, mi_access () at mi_access.adb:19 19 A_String : String (3 .. 5) := "345"; -- STOP $1 = (pck.string_access) <error reading variable: Value out of range.> ... while with target board unix we have instead: ... $1 = (pck.string_access) 0x431b40 <ada_main.sec_default_sized_stacks> ... The var-create command samples the value of the variable at a location where the variable is not yet initialized, and with target board unix we accidentally hit a valid address, but with target board unix/-m32 that's not the case. Fix the FAIL by accepting the error message. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28464
2022-06-10[gdb/testsuite] Fix timeout in gdb.ada/ghost.expTom de Vries1-3/+3
On openSUSE Tumbleweed with gcc-12, I run into a timeout: ... (gdb) print value^M Multiple matches for value^M [0] cancel^M [1] ada.strings.maps.value (<ref> ada.strings.maps.character_mapping; \ character) return character at a-strmap.adb:599^M [2] pck.value at src/gdb/testsuite/gdb.ada/ghost/pck.ads:17^M [3] system.object_reader.value (<ref> system.object_reader.object_symbol) \ return system.object_reader.uint64 at s-objrea.adb:2279^M [4] system.traceback.symbolic.value (system.address) return string at \ s-trasym.adb:200^M > FAIL: gdb.ada/ghost.exp: print value (timeout) print ghost_value^M Argument must be choice number^M (gdb) FAIL: gdb.ada/ghost.exp: print ghost_value ... Fix this by prefixing value (as well as the other printed values) with the package name: ... (gdb) print pck.value^M ... Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29055
2022-05-25gdb: Fix DUPLICATE and PATH regressions throughoutPedro Alves4-11/+17
The previous patch to add -prompt/-lbl to gdb_test introduced a regression: Before, you could specify an explicit empty message to indicate you didn't want to PASS, like so: gdb_test COMMAND PATTERN "" After said patch, gdb_test no longer distinguishes no-message-specified vs empty-message, so tests that previously would be silent on PASS, now started emitting PASS messages based on COMMAND. This in turn introduced a number of PATH/DUPLICATE violations in the testsuite. This commit fixes all the regressions I could see. This patch uses the new -nopass feature introduced in the previous commit, but tries to avoid it if possible. Most of the patch fixes DUPLICATE issues the usual way, of using with_test_prefix or explicit unique messages. See previous commit's log for more info. In addition to looking for DUPLICATEs, I also looked for cases where we would now end up with an empty message in gdb.sum, due to a gdb_test being passed both no message and empty command. E.g., this in gdb.ada/bp_reset.exp: gdb_run_cmd gdb_test "" "Breakpoint $decimal, foo\\.nested_sub \\(\\).*" was resulting in this in gdb.sum: PASS: gdb.ada/bp_reset.exp: I fixed such cases by passing an explicit message. We may want to make such cases error out. Tested on x86_64 GNU/Linux, native and native-extended-gdbserver. I see zero PATH cases now. I get zero DUPLICATEs with native testing now. I still see some DUPLICATEs with native-extended-gdbserver, but those were preexisting, unrelated to the gdb_test change. Change-Id: I5375f23f073493e0672190a0ec2e847938a580b2
2022-05-16gdb/testsuite: fix "continue outside of loop" TCL errorsBruno Larsen3-3/+3
Many test cases had a few lines in the beginning that look like: if { condition } { continue } Where conditions varied, but were mostly in the form of ![runto_main] or [skip_*_tests], making it quite clear that this code block was supposed to finish the test if it entered the code block. This generates TCL errors, as most of these tests are not inside loops. All cases on which this was an obvious mistake are changed in this patch.
2022-05-12Make gdb.ada/float-bits.exp more genericLuis Machado1-19/+68
There are assumptions in the test about the long double format being used. While the results are OK for i387 128-bit long doubles, it is not correct for IEEE quad 128-bit long doubles. Also, depending on the target (64-bit/32-bit), long doubles may not be available at all. And it may be the case that the compiler for a 64-bit target doesn't support 128-bit long doubles, but GDB might still support it internally. Lastly, not every long double format has invalid values. Some formats consider all values as valid floating point numbers. These divergences cause the following FAIL's on aarch64/arm: FAIL: gdb.ada/float-bits.exp: print val_long_double FAIL: gdb.ada/float-bits.exp: print val_long_double after assignment With the above in mind, extend the test a little so it behaves well on different architectures and so it works with different long double formats. Main changes: - Use long double values appropriate for the long double format. - Test long double assignment to compiler-generated long double variables. - Test long double assignment to GDB internal variables. Tested on x86_64 (16 PASS), i686 (16 PASS), aarch64 (12 PASS) and arm (9 PASS).
2022-05-08[gdb/testsuite] Fix gdb.ada/catch_ex_std.exp with remote-gdbserver-on-localhostTom de Vries1-0/+4
When running test-case gdb.ada/catch_ex_std.exp on target board remote-gdbserver-on-localhost, I run into: ... (gdb) continue^M Continuing.^M [Inferior 1 (process 15656) exited with code 0177]^M (gdb) FAIL: gdb.ada/catch_ex_std.exp: runto: run to main Remote debugging from host ::1, port 49780^M /home/vries/foo: error while loading shared libraries: libsome_package.so: \ cannot open shared object file: No such file or directory^M ... Fix this by adding the usual shared-library + remote-target helper "gdb_load_shlib $sofile". Tested on x86_64-linux with native and target board remote-gdbserver-on-localhost.
2022-04-18gdb/testsuite: make gdb.ada/mi_prot.exp stop at expected locationSimon Marchi1-1/+1
This test attempts to run until the line marked "STOP", which is at prot.adb:34. It first runs until the "main" symbol, then tries to place a breakpoint by line at line 34, without specifying the source file. When looking at the logs: -break-insert -t 34^M ^done,bkpt={number="2",type="breakpoint",disp="del",enabled="y",addr="0x0000555555558a6c",func="adafinal",file="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_pro t/b~prot.adb",fullname="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_prot/b~prot.adb",line="44",thread-groups=["i1"],times="0",original-location="/home/simark/b uild/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_prot/b~prot.adb:34"}^M ... continues ... *stopped,reason="breakpoint-hit",disp="del",bkptno="2",frame={addr="0x0000555555558a6c",func="adafinal",args=[],file="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/ mi_prot/b~prot.adb",fullname="/home/simark/build/binutils-gdb-one-target/gdb/testsuite/outputs/gdb.ada/mi_prot/b~prot.adb",line="44",arch="i386:x86-64"},thread-id="1",stopped-threads="all",co re="8"^M ... we see that the breakpoint is placed in some generated file, not in the test source file as we expect. The problem is that "b main" in Ada does not place a breakpoint on the "Ada main", but on some symbol in a generated source file. So when stopped at the "main" symbol, we are not stopped in the file that contains the STOP marker at line 34. The test passes anyway today, so it doesn't seem to matter that we are stopped at an unexpected location. But it starts failing with this patch [1], because b~prot.adb:34 happens to be between two functions, so the breakpoint doesn't resolve. Fix this by placing the breakpoint at "$srcfile:$line", which works regardless of what is the current source file. However, this ends up introducing a path in the test name. Modify mi_tbreak and mi_continue_to_line to avoid that. [1] https://sourceware.org/pipermail/gdb-patches/2022-April/187686.html Change-Id: I742e2a9993046dcb5e30c64fe2ad920a363baf75
2022-04-15[gdb/testsuite] Fix gdb.ada/float-bits.exp with -m32Tom de Vries1-5/+22
With test-case gdb.ada/float-bits.exp and native we get: ... (gdb) print 16llf#7FFFF7FF4054A56FA5B99019A5C8#^M $9 = 5.0e+25^M (gdb) PASS: gdb.ada/float-bits.exp: print 16llf#7FFFF7FF4054A56FA5B99019A5C8# ... but with target board unix/-m32 we have instead: ... (gdb) print 16llf#7FFFF7FF4054A56FA5B99019A5C8#^M Cannot export value 2596145952482202326224873165792712 as 96-bits \ unsigned integer (must be between 0 and 79228162514264337593543950335)^M (gdb) FAIL: gdb.ada/float-bits.exp: print 16llf#7FFFF7FF4054A56FA5B99019A5C8# ... Fix this by testing whether 16llf is supported by doing ptype long_long_float which gets us either: ... type = <16-byte float>^M ... or: ... type = <12-byte float>^M ... Tested on x86_64-linux with native and unix/-m32. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29041
2022-04-12Fix bug in Ada number lexingTom Tromey1-0/+3
On irc, Pedro pointed out that Ada couldn't properly handle 0xffffffffffffffff. This used to work, but is a regression due to some patches I wrote in the Ada lexer. This patch fixes the bug.
2022-04-12Require GNAT debug info for some Ada testsTom Tromey5-0/+25
A few Ada tests require some debug info in the GNAT runtime. When run without this info, these tests can't pass. This patch changes these tests to detect this situation and stop with "untested".
2022-04-04Add context-sensitive field name completion to Ada parserTom Tromey1-0/+31
This updates the Ada expression parser to implement context-sensitive field name completion. This is PR ada/28727. This is somewhat complicated due to some choices in the Ada lexer -- it chooses to represent a sequence of "."-separated identifiers as a single token, so the parser must partially recreate the completer's logic to find the completion word boundaries. Despite the minor warts in this patch, though, it is a decent improvement. It's possible that the DWARF reader rewrite will help fix the package completion problem pointed out in this patch as well. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28727
2022-04-04Implement completion for Ada attributesTom Tromey1-0/+5
This adds a completer for Ada attributes. Some work in the lexer is required in order to match end-of-input correctly, as flex does not have a general-purpose way of doing this. (The approach taken here is recommended in the flex manual.)
2022-04-04Fix bug in Ada attributes lexingTom Tromey1-7/+9
The Ada lexer allows whitespace between the apostrophe and the attribute text, but processAttribute does not handle this. This patch fixes the problem and introduces a regression test.
2022-04-04Handle ghost entities in symbol lookupTom Tromey4-0/+96
Normally, SPARK ghost entities are removed from the executable. However, with -gnata, they will be preserved. In this situation, it's handy to be able to inspect them. This patch allows this by removing the "___ghost_" prefix in the appropriate places.
2022-04-04[gdb/testsuite] Fix KPASS in gdb.ada/arrayptr.expTom de Vries1-16/+45
On openSUSE Leap 15.3 I run into: ... KPASS: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all \ (PRMS minimal encodings) KPASS: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr(3) \ (PRMS minimal encodings) KPASS: gdb.ada/arrayptr.exp: scenario=minimal: print pa_ptr.all(3) \ (PRMS minimal encodings) ... The test-case KFAILs some tests. However, the analysis in the corresponding PR talks of a compiler problem, so it should use XFAILs instead. The KFAILs are setup for pre-gcc-12, but apparantly the fix has been backported to system compiler 7.5.0, hence the KPASS. Fix this by: - using an XFAIL instead of a KFAIL - matching the specific gdb output that corresponds to the XFAILs (reproduced on Fedora 34). Tested on x86_64-linux, specifically openSUSE Leap 15.3 and Fedora 34.
2022-03-30Decode "dynamic" interface types in AdaTom Tromey4-0/+127
In Ada, if a class implements an interface and has a dynamic superclass, then the "offset to top" -- the offset that says how to turn a pointer to the interface into a pointer to the whole object -- is stored in the object itself. This patch changes GDB to understand this. Because this only touches Ada code, and because Joel already reviewed it internally, I am checking it in.
2022-03-17Add another test for Ada Wide_Wide_StringTom Tromey4-1/+17
In an earlier patch, I had written that I wanted to add this test: ptype Wide_Wide_String'("literal") ... but that it failed with the distro GNAT. Further investigation showed that it could be made to work by adding a function using Wide_Wide_String to the program -- this caused the type to end up in the debug info. This patch adds the test. I'm checking this in.
2022-03-16Reimplement array concatenation for Ada and DTom Tromey1-0/+12
This started as a patch to implement string concatenation for Ada. However, while working on this, I looked at how this code could possibly be called. It turns out there are only two users of concat_operation: Ada and D. So, in addition to implementing this for Ada, this patch rewrites value_concat, removing the odd "concatenate or repeat" semantics, which were completely unused. As Ada and D both seem to represent strings using TYPE_CODE_ARRAY, this removes the TYPE_CODE_STRING code from there as well.
2022-03-16Ada support for wide stringsTom Tromey2-0/+6
This adds some basic support for Wide_String and Wide_Wide_String to the Ada expression evaluator. In particular, a string literal may be converted to a wide or wide-wide string depending on context. The patch updates an existing test case. Note that another test, namely something like: ptype Wide_Wide_String'("literal") ... would be nice to add, but when tested against a distro GNAT, this did not work (probably due to lack of debuginfo); so, I haven't included it here.
2022-03-07Fix bug in ada_print_floatingTom Tromey1-0/+3
ada_print_floating rewrites a floating-point string representation to conform to Ada syntax. However, if you managed to get a floating point error, you might see: (gdb) print whatever $2 = <invalid float valu.0e> What's happening here is that ada_print_floating doesn't recognize this error case, and proceeds to modify the error text. This patch fixes this problem.
2022-03-07Implement real literal extension for AdaTom Tromey2-0/+72
Sometimes it is convenient to be able to specify the exact bits of a floating-point literal. For example, you may want to set a floating-point register to a denormalized value, or to a particular NaN. In C, you can do this by combining the "{}" cast with an array literal, like: (gdb) p {double}{0x576488BDD2AE9FFE} $1 = 9.8765449999999996e+112 This patch adds a somewhat similar idea to Ada. It extends the lexer to allow "l" and "f" suffixes in a based literal. The "f" indicates a floating-point literal, and the "l"s control the size of the floating-point type. Note that this differs from Ada's based real literals. I believe those can also be used to control the bits of a floating-point value, but they are a bit more cumbersome to use (simplest is binary but that's also very lengthy). Also, these aren't implemented in GDB. I chose not to allow this extension to work with based integer literals with exponents. That didn't seem very useful.
2022-03-07Fix Ada integer literals with exponentsTom Tromey1-0/+36
While working on another patch, I noticed that Ada integer literals with exponents did not work. For example, with one form you get an error: (gdb) print 8e2 Invalid digit `e' in based literal And with another form you get an incorrect value: (gdb) print 16#8#e2 $2 = 8 This patch fixes the bugs and adds tests.
2022-03-07Fix gdb.ada/arrayptr.exp resultsTom Tromey1-24/+13
PR ada/28115 points out that gdb.ada/arrayptr.exp works with GNAT 12, but fails with minimal encodings in earlier versions. This patch updates the test to try to report the results correctly. I tried this with the Fedora 34 system gcc (GCC 11) and with a GCC 12 built from git trunk sometime relatively recently. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28115
2022-03-07Handle non-ASCII identifiers in AdaTom Tromey12-0/+405
Ada allows non-ASCII identifiers, and GNAT supports several such encodings. This patch adds the corresponding support to gdb. GNAT encodes non-ASCII characters using special symbol names. For character sets like Latin-1, where all characters are a single byte, it uses a "U" followed by the hex for the character. So, for example, thorn would be encoded as "Ufe" (0xFE being lower case thorn). For wider characters, despite what the manual says (it claims Shift-JIS and EUC can be used), in practice recent versions only support Unicode. Here, characters in the base plane are represented using "Wxxxx" and characters outside the base plane using "WWxxxxxxxx". GNAT has some further quirks here. Ada is case-insensitive, and GNAT emits symbols that have been case-folded. For characters in ASCII, and for all characters in non-Unicode character sets, lower case is used. For Unicode, however, characters that fit in a single byte are converted to lower case, but all others are converted to upper case. Furthermore, there is a bug in GNAT where two symbols that differ only in the case of "Y WITH DIAERESIS" (and potentially others, I did not check exhaustively) can be used in one program. I chose to omit handling this case from gdb, on the theory that it is hard to figure out the logic, and anyway if the bug is ever fixed, we'll regret having a heuristic. This patch introduces a new "ada source-charset" setting. It defaults to Latin-1, as that is GNAT's default. This setting controls how "U" characters are decoded -- W/WW are always handled as UTF-32. The ada_tag_name_from_tsd change is needed because this function will read memory from the inferior and interpret it -- and this caused an encoding failure on PPC when running a test that tries to read uninitialized memory. This patch implements its own UTF-32-based case folder. This avoids host platform quirks, and is relatively simple. A short Python program to generate the case-folding table is included. It simply relies on whatever version of Unicode is used by the host Python, which seems basically acceptable. Test cases for UTF-8, Latin-1, and Latin-3 are included. This exercises most of the new code paths, aside from Y WITH DIAERESIS as noted above.
2022-02-28Handle multi-byte bracket sequences in Ada lexerTom Tromey2-2/+11
As noted in an earlier patch, the Ada lexer does not handle multi-byte bracket sequences. This patch adds support for these for character literals. gdb does not generally seem to handle the Ada wide string types, so for the time being these continue to be excluded -- but an explicit error is added to make this more clear.
2022-02-28Handle 'QWW' encoding case in Ada enumsTom Tromey4-0/+114
In Ada, an enum can contain character literals. GNAT encodes these values in a special way. For example, the Unicode character U+0178 would be represented as 'QW0178' in the DWARF: <3><112f>: Abbrev Number: 2 (DW_TAG_enumerator) <1130> DW_AT_name : (indirect string, offset: 0x19ff): QW0178 <1134> DW_AT_const_value : 2 gdb handles this reasonably well, but failed to handle the 'QWW' encoding, which is used for characters outside the base plane. Also, while working on this, I noticed that gdb will print the decimal value for an enum character constant: (gdb) print Char_X $2 = 1 'x' This is a nice feature, IMO, because in this situation the 'x' enum constant does not have its usual decimal value -- it has the value that's assigned based on the enumeration type. However, gdb did not do this when it decided to print the constant using the bracket notation: (gdb) print Char_Thorn $3 = ["de"] This patch changes gdb to print the decimal value here as well, and to put the bracket notation in single quotes -- otherwise gdb will be printing something that it can't then read. Now it looks like: (gdb) print Char_Thorn $3 = 4 '["de"]' Note that gdb can't read longer bracket notations, like the other ones printed in this test case: (gdb) print Char_King $4 = 3 '["01fa00"]' While I think this is a bug, I plan to fix it separately. Finally, in the new test case, the copyright dates are chosen this way because this all started as a copy of an existing test.
2022-02-04Improve Ada unchecked union type printingTom Tromey2-2/+10
Currently, "ptype" of an Ada unchecked union may show a compiler-generated wrapper structure in its output. It's more Ada-like to elide this structure, which is what this patch implements. It turned out to be simplest to reuse a part of print_variant_clauses for this. As this is Ada-specific, and Joel already reviewed it internally, I am going to check it in.
2022-01-20Avoid bad breakpoints with --gc-sectionsTom Tromey4-0/+102
We found a case where --gc-sections can cause gdb to set an invalid breakpoint. In the included test case, gdb will set a breakpoint with two locations, one of which is 0x0. The code in lnp_state_machine::check_line_address is intended to filter out this sort of problem, but in this case, the entire CU is empty, causing unrelocated_lowpc==0x0 -- which circumvents the check. It seems to me that if a CU is empty like this, then it is ok to simply ignore the line table, as there won't be any locations anyway.
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker679-679/+679
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2021-12-07[gdb/symtab] Support -readnow during rereadTom de Vries1-8/+0
When running test-case gdb.base/cached-source-file.exp with target board readnow, we run into: ... FAIL: gdb.base/cached-source-file.exp: rerun program (the program exited) ... The problem is that when rereading, the readnow is ignored. Fix this by copying the readnow handling code from symbol_file_add_with_addrs to reread_symbols. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=26800
2021-12-02(Ada/AArch64) fix fixed point argument passing in inferior funcallXavier Roirand4-0/+111
Consider the following code: type FP1_Type is delta 0.1 range -1.0 .. +1.0; -- Ordinary function Call_FP1 (F : FP1_Type) return FP1_Type is begin return F; end Call_FP1; When the default in GCC is to generate proper DWARF info for fixed point types, then in gdb, printing the result of a call to call_fp1 with a decimal parameter leads to: (gdb) p call_fp1(0.5) $1 = 0 The displayed value is wrong, and we actually expected: (gdb) p call_fp1(0.5) $1 = 0.5 What happened is that our fixed point type parameter got promoted to a 32bit integer because we detected that the length of that object was less than 4 bytes. The compiler does not perform this promotion and therefore GDB should not either. This patch fixes the behavior described above.
2021-12-02Implement 'task apply'Tom Tromey1-0/+5
This adds a 'task apply' command, which is the Ada tasking analogue of 'thread apply'. Unlike 'thread apply', it doesn't offer the 'ascending' flag; but otherwise it's essentially the same.
2021-12-02Add "task" keyword to the "watch" commandTom Tromey2-0/+156
Breakpoints in gdb can be made specific to an Ada task using the "task" qualifier. This patch applies this same idea to watchpoints.
2021-11-25[gdb/cli] Add "set logging enabled", deprecate "set logging on/off"Tom de Vries1-2/+2
Before commit 3b6acaee895 "Update more calls to add_prefix_cmd" we had the following output for "show logging file": ... $ gdb -q -batch -ex "set trace-commands on" \ -ex "set logging off" \ -ex "show logging file" \ -ex "set logging on" \ -ex "show logging file" +set logging off +show logging file Future logs will be written to gdb.txt. +set logging on +show logging file Currently logging to "gdb.txt". ... After that commit we have instead: ... +set logging off +show logging file The current logfile is "gdb.txt". +set logging on +show logging file The current logfile is "gdb.txt". ... Before the commit, whether logging is enabled or not can be deduced from the output of the command. After the commit, the message is unified and it's no longer clear whether logging is enabled or not. Fix this by: - adding a new command "show logging enabled" - adding a corresponding new command "set logging enabled on/off" - making the commands "set logging on/off" deprecated aliases of the "set logging enabled on/off" command. Update the docs and testsuite to use "set logging enabled". Mention the new and deprecated commands in NEWS. Tested on x86_64-linux.
2021-10-21Fix latent Ada bug when accessing field offsetsTom Tromey2-36/+51
The "add accessors for field (and call site) location" patch caused a gdb crash when running the internal AdaCore testsuite. This turned out to be a latent bug in ada-lang.c. The immediate cause of the bug is that find_struct_field unconditionally uses TYPE_FIELD_BITPOS. This causes an assert for a dynamic type. This patch fixes the problem by doing two things. First, it changes find_struct_field to use a dummy value for the field offset in the situation where the offset is not actually needed by the caller. This works because the offset isn't used in any other way -- only as a result. Second, this patch assures that calls to find_struct_field use a resolved type when the offset is needed. For value_tag_from_contents_and_address, this is done by resolving the type explicitly. In ada_value_struct_elt, this is done by passing nullptr for the out parameters when they are not needed (the second call in this function already uses a resolved type). Note that, while we believe the parent field probably can't occur at a variable offset, the patch still updates this code path, just in case. I've updated an existing test case to reproduce the crash. I'm checking this in.
2021-10-19Fix bug in dynamic type resolutionTom Tromey2-0/+31
A customer-reported problem led us to a bug in dynamic type resolution. resolve_dynamic_struct will recursively call resolve_dynamic_type_internal, passing it the sub-object for the particular field being resolved. While it offsets the address here, it does not also offset the "valaddr" -- the array of bytes describing the memory. This patch fixes the bug, by offsetting both. A test case is included that can be used to reproduce the bug.
2021-10-05Remove 'varsize-limit'Tom Tromey2-3/+18
This makes the Ada-specific "varsize-limit" a synonym for "max-value-size", and removes the Ada-specific checks of the limit. I am not certain of the history here, but it seems to me that this code is fully obsolete now. And, removing this makes it possible to index large Ada arrays without triggering an error. A new test case is included to demonstrate this.
2021-09-30gdb/testsuite: make runto_main not pass no-message to runtoSimon Marchi23-31/+0
As follow-up to this discussion: https://sourceware.org/pipermail/gdb-patches/2020-August/171385.html ... make runto_main not pass no-message to runto. This means that if we fail to run to main, for some reason, we'll emit a FAIL. This is the behavior we want the majority of (if not all) the time. Without this, we rely on tests logging a failure if runto_main fails, otherwise. They do so in a very inconsisteny mannet, sometimes using "fail", "unsupported" or "untested". The messages also vary widly. This patch removes all these messages as well. Also, remove a few "fail" where we call runto (and not runto_main). by default (without an explicit no-message argument), runto prints a failure already. In two places, gdb.multi/multi-re-run.exp and gdb.python/py-pp-registration.exp, remove "message" passed to runto. This removes a few PASSes that we don't care about (but FAILs will still be printed if we fail to run to where we want to). This aligns their behavior with the rest of the testsuite. Change-Id: Ib763c98c5f4fb6898886b635210d7c34bd4b9023
2021-09-24Fix handling of DW_AT_data_bit_offsetTom Tromey2-0/+82
A newer version of GCC will now emit member locations using just DW_AT_data_bit_offset, like: <3><14fe>: Abbrev Number: 1 (DW_TAG_member) <14ff> DW_AT_name : (indirect string, offset: 0x215e): nb_bytes <1503> DW_AT_decl_file : 1 <1503> DW_AT_decl_line : 10 <1504> DW_AT_decl_column : 7 <1505> DW_AT_type : <0x150b> <1509> DW_AT_bit_size : 31 <150a> DW_AT_data_bit_offset: 64 whereas earlier versions would emit something like: <3><164f>: Abbrev Number: 7 (DW_TAG_member) <1650> DW_AT_name : (indirect string, offset: 0x218d): nb_bytes <1654> DW_AT_decl_file : 1 <1655> DW_AT_decl_line : 10 <1656> DW_AT_decl_column : 7 <1657> DW_AT_type : <0x165f> <165b> DW_AT_byte_size : 4 <165c> DW_AT_bit_size : 31 <165d> DW_AT_bit_offset : 1 <165e> DW_AT_data_member_location: 8 That is, DW_AT_data_member_location is not emitted any more. This is a change due to the switch to DWARF 5 by default. This change pointed out an existing bug in gdb, namely that the attr_to_dynamic_prop depends on the presence of DW_AT_data_member_location. This patch moves the handling of DW_AT_data_bit_offset into handle_data_member_location, and updates attr_to_dynamic_prop to handle this new case. A new test case is included. This test fails with GCC 11, but passes with an earlier version of GCC.
2021-09-21[gdb/testsuite] Fix gdb.ada/interface.exp with gcc-9Tom de Vries1-5/+5
When running test-case gdb.ada/interface.exp with gcc-9, we run into: ... (gdb) info locals^M s = (x => 1, y => 2, w => 3, h => 4)^M r = (x => 1, y => 2, w => 3, h => 4)^M (gdb) FAIL: gdb.ada/interface.exp: info locals ... The failure is caused by the regexp expecting variable r followed by variable s. Fix this by allowing variable s followed by variable r as well. Tested on x86_64-linux.
2021-09-21[gdb/testsuite] Fix gdb.ada/mi_prot.expTom de Vries1-1/+1
When running test-case gdb.ada/mi_prot.exp with gcc 8.5.0, we run into: ... (gdb) ^M Expecting: ^(-stack-list-arguments --no-frame-filters 1[^M ]+)?(\^done,stack=.*[^M ]+[(]gdb[)] ^M [ ]*) -stack-list-arguments --no-frame-filters 1^M ^done,stack-args=[frame={level="0",args=[{name="<_object>",value="(ceiling_priority =\ > 97, local => 0)"},{name="v",value="5"},{name="<_objectO>",value="true"}]},frame={le\ vel="1",args=[{name="v",value="5"},{name="<_objectO>",value="true"}]},frame={level="2\ ",args=[]}]^M (gdb) ^M FAIL: gdb.ada/mi_prot.exp: -stack-list-arguments --no-frame-filters 1 (unexpected out\ put) ... Fix this by updating the regexp to expect "^done,stack-args=" instead of "^done,stack=". Tested on x86_64-linux.
2021-09-20[gdb/testsuite] Fix gdb.ada/big_packed_array.exp xfail for -m32Tom de Vries1-0/+10
With test-case gdb.ada/big_packed_array.exp and target board unix/-m32 I run into: ... (gdb) print bad^M $2 = (0 => 0 <repeats 24 times>, 160)^M (gdb) FAIL: gdb.ada/big_packed_array.exp: scenario=minimal: print bad ... The problem is that while the variable is an array of 196 bits (== 24.5 bytes), the debug information describes it as 25 unsigned char. This is PR gcc/101643, and the test-case contains an xfail for this, which catches only: ... (gdb) print bad^M $2 = (0 => 0 <repeats 25 times>)^M ... Fix this by updating the xfail pattern. Tested on x86_64-linux.
2021-09-18[gdb/ada] Handle artificial local symbolsTom de Vries1-0/+7
With current master and gcc 7.5.0/8.5.0, we have this timeout: ... (gdb) print s^M Multiple matches for s^M [0] cancel^M [1] s at src/gdb/testsuite/gdb.ada/interface/foo.adb:20^M [2] s at src/gdb/testsuite/gdb.ada/interface/foo.adb:?^M > FAIL: gdb.ada/interface.exp: print s (timeout) ... [ The FAIL doesn't reproduce with gcc 9.3.1. This difference in behaviour bisects to gcc commit d70ba0c10de. The FAIL with earlier gcc bisects to gdb commit ba8694b650b. ] The FAIL is caused by gcc generating this debug info describing a named artificial variable: ... <2><1204>: Abbrev Number: 31 (DW_TAG_variable) <1205> DW_AT_name : s.14 <1209> DW_AT_type : <0x1213> <120d> DW_AT_artificial : 1 <120d> DW_AT_location : 5 byte block: 91 e0 7d 23 18 \ (DW_OP_fbreg: -288; DW_OP_plus_uconst: 24) ... An easy way to fix this would be to simply not put named artificial variables into the symbol table. However, that causes regressions for Ada. It relies on being able to get the value from such variables, using a named reference. Fix this instead by marking the symbol as artificial, and: - ignoring such symbols in ada_resolve_variable, which fixes the FAIL - ignoring such ada symbols in do_print_variable_and_value, which prevents them from showing up in "info locals" Note that a fix for the latter was submitted here ( https://sourceware.org/pipermail/gdb-patches/2008-January/054994.html ), and this patch borrows from it. Tested on x86_64-linux. Co-Authored-By: Joel Brobecker <brobecker@adacore.com> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28180
2021-08-02Handle compiler-generated suffixes in Ada namesTom Tromey1-1/+1
The compiler may add a suffix to a mangled name. A typical example would be splitting a function and creating a ".cold" variant. This patch changes Ada decoding (aka demangling) to handle these suffixes. It also changes the encoding process to handle them as well. A symbol like "function.cold" will now be displayed to the user as "function[cold]". The "." is not simply preserved because that is already used in Ada.