aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib/dwarf.exp
AgeCommit message (Collapse)AuthorFilesLines
2023-01-01Update copyright year range in header of all files managed by GDBJoel Brobecker1-1/+1
This commit is the result of running the gdb/copyright.py script, which automated the update of the copyright year range for all source files managed by the GDB project to be updated to include year 2023.
2022-11-28gdb/testsuite: remove use of then keyword from library filesAndrew Burgess1-5/+5
The canonical form of 'if' in modern TCL is 'if {} {}'. But there's still a bunch of places in the testsuite where we make use of the 'then' keyword, and sometimes these get copies into new tests, which just spreads poor practice. This commit removes all use of the 'then' keyword from the testsuite library files (in boards/, config/, and lib/). Previous commits have removed all uses of the 'then' keyword from the test script files, this commit just cleans up the library files. There should be no changes in what is tested after this commit.
2022-11-10gdb/testsuite: allowed for function_range to deal with mangled functionsBruno Larsen1-1/+1
When calling get_func_info inside a test case, it would cause failures if the function was printed using a C++ style mangled name. The current patch fixes this by allowing for mangled names along with the current rules. Approved-By: Tom Tromey <tom@tromey.com>
2022-10-25[gdb/testsuite] Handle missing .note.GNU-stackTom de Vries1-0/+2
On openSUSE Tumbleweed I run into this for the dwarf assembly test-cases, and some hardcoded assembly test-cases: ... Running gdb.dwarf2/fission-absolute-dwo.exp ... gdb compile failed, ld: warning: fission-absolute-dwo.o: \ missing .note.GNU-stack section implies executable stack ld: NOTE: This behaviour is deprecated and will be removed in a future \ version of the linker === gdb Summary === # of untested testcases 1 ... Fix the dwarf assembly test-cases by adding the missing .note.GNU-stack in proc Dwarf::assemble. Fix the hard-coded test-cases using this command: ... $ for f in $(find gdb/testsuite/gdb.* -name *.S); do if ! grep -q note.GNU-stack $f; then echo -e "\t.section\t.note.GNU-stack,\"\",@progbits" >> $f; fi; done ... Likewise for .s files, and gdb/testsuite/lib/my-syscalls.S. The idiom for arm seems to be to use %progbits instead, see commit 9a5911c08be ("gdb/testsuite/gdb.dwarf2: Replace @ with % for ARM compatability"), so hand-edit gdb/testsuite/gdb.arch/arm-disp-step.S to use %progbits instead. Note that dwarf assembly testcases use %progbits as decided by proc _section. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29674
2022-10-13[gdb/testsuite] Fix gdb.dwarf2/macro-source-path.exp with -m32Tom de Vries1-5/+2
With test-case gdb.dwarf2/macro-source-path.exp and target board unix/-m32, I run into: ... as: macro-source-path-gcc11-ld238-dw5-filename-641.o: \ unsupported relocation type: 0x1^M ... The problem is that we have 64-bit dwarf so the debug_line offset in the .debug_macro section is an 8-byte entity, emitted using ".8byte": ... .section .debug_macro .Lcu_macros4: .2byte 5 /* version */ .byte 3 /* flags */ .8byte .LLlines3 /* debug_line offset */ ... but the linker doesn't support 8-byte relocation types on a 32-bit architecture. This is similar to what was fixed in commit a5ac8e7fa3b ("[gdb/testsuite] Fix 64-bit dwarf test-cases with -m32") for for instance .debug_abbrev. Fix this in the same way, by using _op_offset to emit the debug_line offset. Tested on x86_64-linux with native and target board unix/-m32.
2022-09-30[gdb/testsuite] Add aranges to gdb.dwarf2/dw2-dir-file-name.expTom de Vries1-2/+13
Since commit 52b920c5d20 ("[gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp for ppc64le"), the test-case fails with target board cc-with-debug-names, due to missing .debug_aranges info. Add the missing .debug_aranges info. Also add a file_id option to Dwarf::assemble, to make it possible to contribute to an already open file. Tested on x86_64-linux.
2022-09-06[gdb/symtab] Support .debug_names section with TUs in .debug_infoTom de Vries1-4/+17
When running test-case gdb.cp/cpexprs-debug-types.exp on target board cc-with-debug-names/gdb:debug_flags=-gdwarf-5, we get an executable with a .debug_names section, but no .debug_types section. For dwarf-5, the TUs are no longer put in a separate unit, but instead they're put in the .debug_info section. When loading the executable, the .debug_names section is silently ignored because of this check in dwarf2_read_debug_names: ... if (map->tu_count != 0) { /* We can only handle a single .debug_types when we have an index. */ if (per_bfd->types.size () != 1) return false; ... which triggers because per_bfd->types.size () == 0. The intention of the check is to make sure we don't have more that one .debug_types section, as can happen in a object file (see PR12984): ... $ grep "\.debug_types" 11.s .section .debug_types,"G",@progbits,wt.75c042c23a9a07ee,comdat .section .debug_types,"G",@progbits,wt.c59c413bf50a4607,comdat ... Fix this by: - changing the check condition to "per_bfd->types.size () > 1", and - handling per_bfd->types.size () == 0. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29385
2022-09-06[gdb/testsuite] Add gdb.dwarf2/debug-names-bad-cu-index.expTom de Vries1-8/+24
Add test-case gdb.dwarf2/debug-names-bad-cu-index.exp, a regression test for commit 2fe9a3c41fa ("[gdb/symtab] Fix bad compile unit index complaint"). Tested on x86_64-linux.
2022-09-06[gdb/testsuite] Add gdb.dwarf2/debug-names-tu.expTom de Vries1-12/+44
Add a test-case gdb.dwarf2/debug-names-tu.exp, that uses the dwarf assembler to specify a .debug_names index with the TU list referring to a TU from the .debug_types section. This is intended to produce something similar to: ... $ gcc -g -fdebug-types-section ~/hello.c -gdwarf-4 $ gdb-add-index -dwarf-5 a.out ... Tested on x86_64-linux.
2022-08-31gdb, testsuite: adapt function_range expected nameNils-Christian Kempke1-4/+8
When writing a dwarf testcase for some C++ code I wanted to use the MACRO_AT_range which in turn uses the function_range proc in dwarf.exp to extract the bounds of 'main'. However, the macro failed as GDB prints the C++ 'main' with its arguments as 'main(int, char**)' or 'main()'. The reason for this is that in read.c::dwarf2_compute_name we call c_type_print_args on C++ functions and append their arguments to the function name. This happens to all C++ functions, but is only visible when the function doesn't have a linkage name. An example might make this more clear. Given the following code >> cat c.cpp int foo (int a, float b) { return 0; } int main (int argc, char **argv) { return 0; } which is legal in both languages, C and C++, and compiling it with e.g. clang or gcc will make the disassemble command look like: >> clang --version clang version 10.0.0-4ubuntu1 ... >> clang -O0 -g ./c.cpp >> gdb -q ./a.out -ex "start" ... (gdb) disassemble main Dump of assembler code for function main(int, char**): 0x0000000000401120 <+0>: push %rbp 0x0000000000401121 <+1>: mov %rsp,%rbp ... 0x0000000000401135 <+21>: ret End of assembler dump. (gdb) disassemble foo Dump of assembler code for function _Z3fooif: 0x0000000000401110 <+0>: push %rbp 0x0000000000401111 <+1>: mov %rsp,%rbp ... 0x000000000040111f <+15>: ret End of assembler dump. Note, that main is emitted with its arguments while for foo the linkage name is being printed, as also visible in its DWARF: >> objdump ./a.out --dwarf=info | grep "foo" -A3 -B3 <2b> DW_AT_low_pc : 0x401110 <33> DW_AT_high_pc : 0x10 <37> DW_AT_frame_base : 1 byte block: 56 (DW_OP_reg6 (rbp)) <39> DW_AT_linkage_name: (indirect string, offset: 0x39): _Z3fooif <3d> DW_AT_name : (indirect string, offset: 0x42): foo <41> DW_AT_decl_file : 1 <42> DW_AT_decl_line : 1 <43> DW_AT_type : <0x9a> Now, let's rename the C++ file and compile it as C: >> mv c.cpp c.c >> clang -O0 -g ./c.c >> gdb -q ./a.out -ex "start' ... (gdb) disassemble main Dump of assembler code for function main: 0x0000000000401120 <+0>: push %rbp 0x0000000000401121 <+1>: mov %rsp,%rbp ... 0x0000000000401135 <+21>: ret End of assembler dump. (gdb) disassemble foo Dump of assembler code for function foo: 0x0000000000401110 <+0>: push %rbp 0x0000000000401111 <+1>: mov %rsp,%rbp ... 0x000000000040111f <+15>: ret End of assembler dump. Note, for foo we did not get a linkage name emitted in DWARF, so it is printed by its name: >> objdump --dwarf=info ./a.out | grep foo -A3 -B3 <2b> DW_AT_low_pc : 0x401110 <33> DW_AT_high_pc : 0x10 <37> DW_AT_frame_base : 1 byte block: 56 (DW_OP_reg6 (rbp)) <39> DW_AT_name : (indirect string, offset: 0x37): foo <3d> DW_AT_decl_file : 1 <3e> DW_AT_decl_line : 1 <3f> DW_AT_prototyped : 1 To make the macro and proc work with C++ as well, an optional argument list was added to the regex matching the function name in the disassemble command in function_range. This does not change any used behavior as currently, there exists no C++ test using the proc function_range. Signed-off-by: Nils-Christian Kempke <nils-christian.kempke@intel.com>
2022-08-07[gdb/testsuite] Add support for .debug_names in dwarf assemblerTom de Vries1-5/+224
Add: - support for a per-module .debug_names section in the dwarf assembler, and - a test-case excercising this new functionality. A per-module .debug_names section needs to have an entry in the CU list for each CU in the module, which is made more difficult by two things: - linking in other objects, which may contain additional CUs (typically the case on openSUSE), and - adding dummy CUs in the dwarf assembler. We handle this by: - compiling with -nostartfiles (so the test-case contains _start rather than main), and - disabling the dummy CU generation for the test-case. I've kept things simple by having the test-case specify the hash value, rather than adding that functionality in the dwarf assembler. Also I've kept the bucket count to 1, which makes it trivial to satisfy the requirement that "the symbol is entered into a bucket whose index is the hash value modulo bucket_count". The readelf dump of the .debug_names section from the test-case looks like: ... Version 5 Augmentation string: 47 44 42 00 ("GDB") CU table: [ 0] 0x0 TU table: Foreign TU table: Used 1 of 1 bucket. Out of 2 items there are 1 bucket clashes (longest of 1 entries). Symbol table: [ 0] #eddb6232 _start: <1> DW_TAG_subprogram DW_IDX_compile_unit=0 [ 1] #0b888030 int: <2> DW_TAG_base_type DW_IDX_compile_unit=0 ... Tested on x86_64-linux.
2022-07-29gdb/testsuite: add macros test for source files compiled in various waysSimon Marchi1-0/+92
Using different ways of passing source file paths to compilers results n different file and directory paths in the line header. For example: - gcc foo.c - gcc ./foo.c - gcc ../cwd/foo.c - gcc $PWD/foo.c Because of this, GDB sometimes failed to look up macros. The previous patch fixed that as much as possible. This patch adds the corresponding tests. Add both a DWARF assembler-based test and a regular test. The DWARF assembled-based one tests some hard-coded debug info based on what I have observed some specific versions of gcc and clang generate. We want to make sure that GDB keeps handling all these cases correctly, even if it's not always clear whether they are really valid DWARF. Also, they will be tested no matter what the current target compiler is for a given test run. The regular test is compiled using the target compiler, so it may help find bugs when testing against some other toolchains than what was used to generate the DWARF assembler-based test. For the DWARF assembler-based test, add to testsuite/lib/dwarf.exp the necessary code to generate a DWARF5 .debug_macro section. The design of the new procs is based on what was done for rnglists and loclists. To test against a specific compiler one can use this command, for example: $ make check TESTS="gdb.base/macro-source-path.exp" RUNTESTFLAGS="CC_FOR_TARGET=clang --target_board unix/gdb:debug_flags=-gdwarf-5" Change-Id: Iab8da498e57d10cc2a3d09ea136685d9278cfcf6
2022-06-09gdb/testsuite: remove get_compiler_info calls from gdb.exp and dwarf.expAndrew Burgess1-8/+0
We don't need to call get_compiler_info before calling test_compiler_info; test_compiler_info includes a call to get_compiler_info. This commit cleans up lib/gdb.exp and lib/dwarf.exp a little by removing some unneeded calls to get_compiler_info. We could do the same cleanup throughout the testsuite, but I'm leaving that for another day. There should be no change in the test results after this commit.
2022-05-06[gdb/testsuite] Fix gdb.dwarf2/locexpr-data-member-location.exp with nopieTom de Vries1-3/+13
When running test-case gdb.dwarf2/locexpr-data-member-location.exp with target board unix/-fno-PIE/-no-pie/-m32 I run into: ... (gdb) step^M 26 return 0;^M (gdb) FAIL: gdb.dwarf2/locexpr-data-member-location.exp: step into foo ... The problem is that the test-case tries to mimic some gdb_compile_shlib behaviour using: ... set flags {additional_flags=-fpic debug} get_func_info foo $flags ... but this doesn't work with the target board setting, because we end up doing: ... gcc locexpr-data-member-location-lib.c -fpic -g -lm -fno-PIE -no-pie -m32 \ -o func_addr23029.x ... while gdb_compile_shlib properly filters out the -fno-PIE -no-pie. Consequently, the address for foo determined by get_func_info doesn't match the actual address of foo. Fix this by printing the address of foo using the result of gdb_compile_shlib.
2022-04-18gdb/testsuite/dwarf: don't automatically add directory and file entry for ↵Simon Marchi1-15/+18
DWARF 5 To support DWARF 5 in the DWARF assembler line tables, we currently copy the first user-provided directory and the first user-provided files and make them elements at indices 0 in the directory and file name tables. That was a sufficient behavior at the time (see commit 44fda089397a ("[gdb/testsuite] Support .debug_line v5 in dwarf assembler")), but in the following patches, I would need to have finer grained control on what is generated exactly. For example, I'd like to generate a DWARF 5 line table with just a single file and a single directory. Get rid of this behavior, and implement what is suggested in 44fda089397a: make include_dir return the directory index that can be used to refer to that directory entry (based on the DWARF version), and use it afterwards. Adjust dw2-lines.exp and dw2-prologue-end.exp accordingly. Their produced DWARF5 binaries will change a bit, in that they will now have a single directory and file, where they had two before. But it doesn't change the expected GDB behavior. Change-Id: I5459b16ac9b7f28c34c9693c35c9afd2ebb3aa3b
2022-04-07gdb/testsuite/dwarf: simplify line number program syntaxSimon Marchi1-4/+2
By calling `uplevel $body` in the program proc (a pattern we use at many places), we can get rid of curly braces around each line number program directive. That seems like a nice small improvement to me. Change-Id: Ib327edcbffbd4c23a08614adee56c12ea25ebc0b
2022-04-07gdb/testsuite/dwarf: remove two unused variablesSimon Marchi1-19/+0
These variables seem to be unused, remove them. Change-Id: I7d613d9d35735930ee78b2c348943c73a702afbb
2022-04-04gdb: Add support for DW_LNS_set_prologue_end in line-tableLancelot SIX1-6/+10
Add support for DW_LNS_set_prologue_end when building line-tables. This attribute can be set by the compiler to indicate that an instruction is an adequate place to set a breakpoint just after the prologue of a function. The compiler might set multiple prologue_end, but considering how current skip_prologue_using_sal works, this commit modifies it to accept the first instruction with this marker (if any) to be the place where a breakpoint should be placed to be at the end of the prologue. The need for this support came from a problematic usecase generated by hipcc (i.e. clang). The problem is as follows: There's a function (lets call it foo) which covers PC from 0xa800 to 0xa950. The body of foo begins with a call to an inlined function, covering from 0xa800 to 0xa94c. The issue is that when placing a breakpoint at 'foo', GDB inserts the breakpoint at 0xa818. The 0x18 offset is what GDB thinks is foo's first address past the prologue. Later, when hitting the breakpoint, GDB reports the stop within the inlined function because the PC falls in its range while the user expects to stop in FOO. Looking at the line-table for this location, we have: INDEX LINE ADDRESS IS-STMT [...] 14 293 0x000000000000a66c Y 15 END 0x000000000000a6e0 Y 16 287 0x000000000000a800 Y 17 END 0x000000000000a818 Y 18 287 0x000000000000a824 Y [...] For comparison, let's look at llvm-dwarfdump's output for this CU: Address Line Column File ISA Discriminator Flags ------------------ ------ ------ ------ --- ------------- ------------- [...] 0x000000000000a66c 293 12 2 0 0 is_stmt 0x000000000000a6e0 96 43 82 0 0 is_stmt 0x000000000000a6f8 102 18 82 0 0 is_stmt 0x000000000000a70c 102 24 82 0 0 0x000000000000a710 102 18 82 0 0 0x000000000000a72c 101 16 82 0 0 is_stmt 0x000000000000a73c 2915 50 83 0 0 is_stmt 0x000000000000a74c 110 1 1 0 0 is_stmt 0x000000000000a750 110 1 1 0 0 is_stmt end_sequence 0x000000000000a800 107 0 1 0 0 is_stmt 0x000000000000a800 287 12 2 0 0 is_stmt prologue_end 0x000000000000a818 114 59 81 0 0 is_stmt 0x000000000000a824 287 12 2 0 0 is_stmt 0x000000000000a828 100 58 82 0 0 is_stmt [...] The main difference we are interested in here is that llvm-dwarfdump's output tells us that 0xa800 is an adequate place to place a breakpoint past a function prologue. Since we know that foo covers from 0xa800 to 0xa94c, 0xa800 is the address at which the breakpoint should be placed if the user wants to break in foo. This commit proposes to add support for the prologue_end flag in the line-program processing. The processing of this prologue_end flag is made in skip_prologue_sal, before it calls gdbarch_skip_prologue_noexcept. The intent is that if the compiler gave information on where the prologue ends, we should use this information and not try to rely on architecture dependent logic to guess it. The testsuite have been executed using this patch on GNU/Linux x86_64. Testcases have been compiled with both gcc/g++ (verison 9.4.0) and clang/clang++ (version 10.0.0) since at the time of writing GCC does not set the prologue_end marker. Tests done with GCC 11.2.0 (not over the entire testsuite) show that it does not emit this flag either. No regression have been observed with GCC or Clang. Note that when using Clang, this patch fixes a failure in gdb.opt/inline-small-func.exp. Change-Id: I720449a8a9b2e1fb45b54c6095d3b1e9da9152f8
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker1-1/+1
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-11-29[gdb/testsuite] Fix typo in proc linesTom de Vries1-1/+1
Proc lines contains a typo: ... string_form { set $_line_string_form $value } ... Remove the incorrect '$' in '$_line_string_form'. Tested on x86_64-linux.
2021-11-29[gdb/testsuite] Fix gdb.dwarf2/dw2-lines.exp with -m32Tom de Vries1-10/+2
When running test-case gdb.dwarf2/dw2-lines.exp with target board -unix/-m32, we run into another instance of PR28383, where the dwarf assembler generates 64-bit relocations which are not supported by the 32-bit assembler: ... dw2-lines-dw.S: Assembler messages:^M outputs/gdb.dwarf2/dw2-lines/dw2-lines-dw.S:76: Error: \ cannot represent relocation type BFD_RELOC_64^M ... Fix this by using _op_offset in _line_finalize_header. Tested on x86_64-linux.
2021-11-22[gdb/symtab] Support .debug_line with DW_FORM_line_strpTom de Vries1-10/+65
I noticed a new gcc option -gdwarf64 and tried it out (using gcc 11.2.1). With a test-case hello.c: ... int main (void) { printf ("hello\n"); return 0; } ... compiled like this: ... $ gcc -g -gdwarf64 ~/hello.c ... I ran into: ... $ gdb -q -batch a.out DW_FORM_line_strp pointing outside of .debug_line_str section \ [in module a.out] ... Debugging gdb revealed that the string offset is: ... (gdb) up objfile=0x182ab70, str_offset=1378684502312, form_name=0xeae9b5 "DW_FORM_line_strp") at src/gdb/dwarf2/section.c:208 208 error (_("%s pointing outside of %s section [in module %s]"), (gdb) p /x str_offset $1 = 0x14100000128 (gdb) ... which is read when parsing a .debug_line entry at 0x1e0. Looking with readelf at the 0x1e0 entry, we have: ... The Directory Table (offset 0x202, lines 2, columns 1): Entry Name 0 (indirect line string, offset: 0x128): /data/gdb_versions/devel 1 (indirect line string, offset: 0x141): /home/vries ... which in a hexdump looks like: ... 0x00000200 1f022801 00004101 00000201 1f020f02 ... What happens is the following: - readelf interprets the DW_FORM_line_strp reference to .debug_line_str as a 4 byte value, and sees entries 0x00000128 and 0x00000141. - gdb instead interprets it as an 8 byte value, and sees as first entry 0x0000014100000128, which is too big so it bails out. AFAIU, gdb is wrong. It assumes DW_FORM_line_strp is 8 bytes on the basis that the corresponding CU is 64-bit DWARF. However, the .debug_line contribution has it's own initial_length field, and encodes there that it's 32-bit DWARF. Fix this by using the correct offset size for DW_FORM_line_strp references in .debug_line. Note: the described test-case does trigger this complaint (both with and without this patch): ... $ gdb -q -batch -iex "set complaints 10" a.out During symbol reading: intermixed 32-bit and 64-bit DWARF sections ... The reason that the CU has 64-bit dwarf is because -gdwarf64 was passed to gcc. The reason that the .debug_line entry has 32-bit dwarf is because that's what gas generates. Perhaps this is complaint-worthy, but I don't think it is wrong. Tested on x86_64-linux, using native and target board dwarf64.exp.
2021-11-22[gdb/testsuite] Support .debug_line v5 in dwarf assemblerTom de Vries1-5/+64
The v5 section version for .debug_line has: - two new fields address_size and segment_selector_size - a different way to encode the directory and filename tables. Add support for this in the dwarf assembler. For now, make the v5 directory and filename tables work with the v4 type of specification in the test-cases by adding duplicate entries at position 0. This will need to be properly fixed with an intrusive fix that changes how directory and filename entries are specified in the test-cases, f.i: ... set diridx [include_dir "${srcdir}/${subdir}"] set fileidx [file_name "$srcfile" $diridx] ... Tested on x86_64-linux.
2021-11-22[gdb/testsuite] Factor out _line_finalize_headerTom de Vries1-26/+49
Rather than generate dwarf immediately in procs include_dir and file_name, postpone generation and store the data in variables. Then handle the generation in a new proc _line_finalize_header. Tested on x86-64-linux.
2021-11-22[gdb/testsuite] Support .debug_line v4 in dwarf assemblerTom de Vries1-0/+4
The .debug_line header got a new field in v4: maximum_operations_per_instruction. Generate this field in the dwarf assembler, for now hardcoding the value to 1, meaning non-VLIW. Tested on x86_64-linux.
2021-11-22[gdb/testsuite] Add test-case gdb.dwarf2/dw2-lines.expTom de Vries1-0/+6
Add a new test-case gdb.dwarf2/dw2-lines.exp that tests various .debug_line sections. Tested on x86_64-linux.
2021-11-22[gdb/testsuite] Speed up MACRO_AT_* callsTom de Vries1-12/+148
Currently, for each MACRO_AT_range or MACRO_AT_func in dwarf assembly the following is done: - $srcdir/$subdir/$srcfile is compiled to an executable using flags "debug" - a new gdb instance is started - the new executable is loaded. This is inefficient, because the executable is identical within the same Dwarf::assemble call. Share the gdb instance in the same Dwarf::assemble invocation, which speeds up a make check with RUNTESTFLAGS like this to catch all dwarf assembly test-cases: ... rtf=$(echo $(cd src/gdb/testsuite; find gdb.* -type f -name "*.exp" \ | xargs grep -l Dwarf::assemble)) ... from: ... real 1m39.916s user 1m25.668s sys 0m21.377s ... to: ... real 1m29.512s user 1m17.316s sys 0m19.100s ... Tested on x86_64-linux.
2021-11-19[gdb/testsuite] Fix 64-bit dwarf test-cases with -m32Tom de Vries1-9/+35
When running test-case gdb.dwarf2/loc-sec-offset.exp with target board -m32, I run into: ... builtin_spawn -ignore SIGHUP gcc -fno-stack-protector -m32 \ -fdiagnostics-color=never -c -o loc-sec-offset-dw641.o \ loc-sec-offset-dw64.S^M as: loc-sec-offset-dw641.o: unsupported relocation type: 0x1^M loc-sec-offset-dw64.S: Assembler messages:^M loc-sec-offset-dw64.S:29: Error: cannot represent relocation type \ BFD_RELOC_64^M ... Looking at line 29, we have: ... .8byte .Labbrev1_begin /* Abbrevs */ ... It would be nice if the assembler could handle this somehow. But I guess it's not unreasonable that an assembler for a 32-bit architecture will object to handling 64-bit labels. Instead, work around this in the dwarf assembler by emitting: ... .4byte .Labbrev1_begin /* Abbrevs (lsw) */ .4byte 0 /* Abbrevs (msw) */ ... Tested on x86_64-linux with target board unix/-m32. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28383
2021-11-09Correctly handle DW_LLE_start_endTom Tromey1-1/+11
When the code to handle DW_LLE_start_end was added (as part of some DWARF 5 work), it was written to add the base address. However, this seems incorrect -- the DWARF standard describes this as an address, not an offset from the base address. This patch changes a couple of spots in dwarf2/loc.c to fix this problem. It then changes decode_debug_loc_addresses to return DEBUG_LOC_OFFSET_PAIR instead, which preserves the previous semantics. This only showed up on the RISC-V target internally, due to the combination of DWARF 5 and a newer version of GCC. I've updated a couple of existing loclists test cases to demonstrate the bug.
2021-10-14[gdb/testsuite] Add .debug_loc support in dwarf assemblerTom de Vries1-0/+99
Add .debug_loc support in the dwarf assembler, and use it in new test-case gdb.dwarf2/loc-sec-offset.exp (which is based on gdb.dwarf2/loclists-sec-offset.exp). Tested on x86_64-linux.
2021-09-30gdb/testsuite/dwarf: use options for rnglists/loclists procsSimon Marchi1-56/+27
Change how rnglists and loclists procs to align them with how procs for aranges (and other things in the DWARF assembler) work. Instead of using "args" (variable number of parameters in TCL) and command-line style option arguments, use one leading "option" parameters, used as a kind of key/value dictionary of options parsed using `parse_options`. Change-Id: I63e60d17ae16a020ce4d6de44baf3d152ea42a1a
2021-09-30gdb/testsuite/dwarf: don't define nested procs for rnglists/loclistsSimon Marchi1-254/+287
When I wrote support for rnglists and loclists in the testsuite's DWARF assembler, I made it with nested procs, for example proc "table" inside proc "rnglists". The intention was that this proc "table" could only be used by the user while inside proc "rnglists"'s body. I had chosen very simple names, thinking there was no chance of name clashes. I recently learned that this is not how TCL works. This ends up defining a proc "table" in the current namespace ("Dwarf" in this case). Things still work if you generate rnglists and loclists in the same file, as each redefines its own procedures when executing. But if a user of the assembler happened to define a convenience "table" or "start_end" procedure, for example, it would get overriden. I'd like to change how this works to reduce the chances of a name clash. - Move the procs out of each other, so they are not defined in a nested fashion. - Prefix them with "_rnglists_" or "_loclists_". - While calling $body in the various procs, temporarily make the procs available under their "short" name. For example, while in rngllists' body, make _rnglists_table available as just "table". This allows existing code to keep working and keeps it not too verbose. - Modify with_override to allow the overriden proc to not exist. In that case, the temporary proc is deleted on exit. Note the non-conforming indentation when calling with_override in _loclists_list. This is on purpose: as we implement more loclists (and rnglists) entry types, the indentation would otherwise get larger and larger without much value for readability. So I think it's reasonable here to put them on the same level. Change-Id: I7bb48d26fcb0dba1ae4dada05c0c837212424328
2021-09-24[gdb/testsuite] Don't leave gdb instance running after function_rangeTom de Vries1-0/+1
A typical dwarf assembly test-case start like this: ... standard_testfile .c -debug.S set asm_file [standard_output_file $srcfile2] Dwarf::assemble $asm_file { ... } if { [prepare_for_testing "failed to prepare" ${testfile} \ [list $srcfile $asm_file] {nodebug}] } { return -1 } ... When accidentally using build_for_executable instead of prepare_for_testing (or intentionally using it but forgetting to add clean_restart $binfile or some such) the mistake may not be caught, because another gdb instance is still running, and we may silently end up testing compiler-generated DWARF. This can be caused by something relatively obvious, like an earlier prepare_for_testing or clean_restart, but also by something more obscure like function_range, which may even be triggered by dwarf assembly like this: ... {MACRO_AT_func {main}} ... Fix this by calling gdb_exit at the end of function_range. Also fix the fallout of that in test-case gdb.dwarf2/dw2-bad-elf.exp, where a get_sizeof call used the gdb instance left lingering by function_range. [ A better and more complete fix would add a new proc get_exec_info, that would be called at the start of the dwarf assembly body: ... Dwarf::assemble $asm_file { get_exec_info {main foo} {int void*} ... that would: - do a prepare_for_testing with $srcfile (roughtly equivalent to what MACRO_AT_func does, - call function_range for all functions main and foo, without starting a new gdb instance - set corresponding variables at the call-site: main_start, main_len, main_end, foo_start, foo_len, foo_end. - get size for types int and void* - set corresponding variables at the call-site: int_size, void_ptr_size. - do a gdb_exit. ] Tested on x86_64-linux.
2021-09-24gdb/testsuite: Make it possible to use TCL variables in DWARF assembler loclistsPedro Alves1-0/+4
It is currently not possible to use variables in locations lists. For example, with: diff --git a/gdb/testsuite/gdb.dwarf2/loclists-multiple-cus.exp b/gdb/testsuite/gdb.dwarf2/loclists-multiple-cus.exp index 6b4f5c8cbb8..cdbf948619f 100644 --- a/gdb/testsuite/gdb.dwarf2/loclists-multiple-cus.exp +++ b/gdb/testsuite/gdb.dwarf2/loclists-multiple-cus.exp @@ -30,6 +30,8 @@ if {![dwarf2_support]} { return 0 } +set myconst 0x123456 + # Test with 32-bit and 64-bit DWARF. foreach_with_prefix is_64 {false true} { if { $is_64 } { @@ -49,6 +51,7 @@ foreach_with_prefix is_64 {false true} { global func1_addr func1_len global func2_addr func2_len global is_64 + global myconst # The CU uses the DW_FORM_loclistx form to refer to the .debug_loclists # section. @@ -107,7 +110,7 @@ foreach_with_prefix is_64 {false true} { list_ { # When in func1. start_length $func1_addr $func1_len { - DW_OP_constu 0x123456 + DW_OP_constu $myconst DW_OP_stack_value } we get: $ make check TESTS="*/loclists-multiple-cus.exp" ... gdb compile failed, build/gdb/testsuite/outputs/gdb.dwarf2/loclists-multiple-cus/loclists-multiple-cus-dw32.S: Assembler messages: build/gdb/testsuite/outputs/gdb.dwarf2/loclists-multiple-cus/loclists-multiple-cus-dw32.S:78: Error: leb128 operand is an undefined symbol: $myconst ... That means $myconst was copied literally to the generated assembly file. This patch fixes it, by running subst on the location list body, in the context of the caller. The fix is applied to both Dwarf::loclists::table::list_::start_length and Dwarf::loclists::table::list_::start_end. Reported-by: Zoran Zaric <Zoran.Zaric@amd.com> Change-Id: I615a64431857242d9f477d5699e3732df1b31322
2021-08-30[gdb/testsuite] Improve argument syntax of proc arangeTom de Vries1-17/+14
The current syntax of proc arange is: ... proc arange { arange_start arange_length {comment ""} {seg_sel ""} } { ... and a typical call looks like: ... arange $start $len ... This style is somewhat annoying because if you want to specify the last parameter, you need to give the default values of all the other optional ones before as well: ... arange $start $len "" $seg_sel ... Update the syntax to: ... proc arange { options arange_start arange_length } { parse_options { { comment "" } { seg_sel "" } } ... such that a typical call looks like: ... arange {} $start $len ... and a call using seg_sel looks like: ... arange { seg_sel $seg_sel } $start $len ... Also update proc aranges, which already has an options argument, to use the new proc parse_options. Tested on x86_64-linux. Co-Authored-By: Simon Marchi <simon.marchi@polymtl.ca>
2021-08-27[gdb/testsuite] Generate .debug_aranges entry for dummy CUTom de Vries1-1/+5
A best practise for DWARF [1] is to generate .debug_aranges entries for CUs even if they have no address range. Generate .debug_arange entries for the dummy CUs added by the DWARF assembler. Tested on x86_64-linux. [1] http://wiki.dwarfstd.org/index.php?title=Best_Practices
2021-08-27[gdb/testsuite] Support .debug_aranges in dwarf assemblyTom de Vries1-0/+153
Add a proc aranges such that we can generate .debug_aranges sections in dwarf assembly using: ... cu { label cu_label } { ... } aranges {} cu_label { arange $addr $len [<comment>] [$segment_selector] } ... Tested on x86_64-linux.
2021-08-27[gdb/testsuite] Add label option to proc cuTom de Vries1-0/+11
We can use current dwarf assembly infrastructure to declare a label that marks the start of the CU header: ... declare_labels header_start_cu_a _section ".debug_info" header_start_cu_a : cu {} { } _section ".debug_info" header_start_cu_b : cu {} { } ... on the condition that we switch to the .debug_info section before, which makes this style of use fragile. Another way to achieve the same is to use the label as generated by the cu proc itself: ... variable _cu_label cu {} { } set header_start_cu_a $_cu_label cu {} { } set header_start_cu_b $_cu_label ... but again that seems fragile given that adding a new CU inbetween will silently result in the wrong value for the label. Add a label option to proc cu such that we can simply do: ... cu { label header_start_cu_a } { } cu { label header_start_cu_b } { } ... Tested on x86_64-linux.
2021-08-23[gdb/testsuite] Add dummy start and end CUs in dwarf assemblyTom de Vries1-1/+16
Say one compiles a hello.c: ... $ gcc -g hello.c ... On openSUSE Leap 15.2 and Tumbleweed, the CU for hello.c is typically not the first in .debug_info, nor the last, due to presence of debug information in objects for sources like: - ../sysdeps/x86_64/start.S - init.c - ../sysdeps/x86_64/crti.S - elf-init.c - ../sysdeps/x86_64/crtn.S. On other systems, say ubuntu 18.04.5, the CU for hello.c is typically the first and the last in .debug_info. This difference has caused me to find some errors in the dwarf assembly using openSUSE, that didn't show up on other platforms. Force the same situation on other platforms by adding a dummy start and end CU. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2021-08-22 Tom de Vries <tdevries@suse.de> PR testsuite/28235 * lib/dwarf.exp (Dwarf::dummy_cu): New proc. (Dwarf::assemble): Add dummy start and end CU.
2021-08-05Replace the symbol needs evaluator with a parserZoran Zaric1-0/+4
This patch addresses a design problem with the symbol_needs_eval_context class. It exposes the problem by introducing two new testsuite test cases. To explain the issue, I first need to explain the dwarf_expr_context class that the symbol_needs_eval_context class derives from. The intention behind the dwarf_expr_context class is to commonize the DWARF expression evaluation mechanism for different evaluation contexts. Currently in gdb, the evaluation context can contain some or all of the following information: architecture, object file, frame and compilation unit. Depending on the information needed to evaluate a given expression, there are currently three distinct DWARF expression evaluators:  - Frame: designed to evaluate an expression in the context of a call    frame information (dwarf_expr_executor class). This evaluator doesn't    need a compilation unit information.  - Location description: designed to evaluate an expression in the    context of a source level information (dwarf_evaluate_loc_desc    class). This evaluator expects all information needed for the    evaluation of the given expression to be present.  - Symbol needs: designed to answer a question about the parts of the    context information required to evaluate a DWARF expression behind a    given symbol (symbol_needs_eval_context class). This evaluator    doesn't need a frame information. The functional difference between the symbol needs evaluator and the others is that this evaluator is not meant to interact with the actual target. Instead, it is supposed to check which parts of the context information are needed for the given DWARF expression to be evaluated by the location description evaluator. The idea is to take advantage of the existing dwarf_expr_context evaluation mechanism and to fake all required interactions with the actual target, by returning back dummy values. The evaluation result is returned as one of three possible values, based on operations found in a given expression: - SYMBOL_NEEDS_NONE, - SYMBOL_NEEDS_REGISTERS and - SYMBOL_NEEDS_FRAME. The problem here is that faking results of target interactions can yield an incorrect evaluation result. For example, if we have a conditional DWARF expression, where the condition depends on a value read from an actual target, and the true branch of the condition requires a frame information to be evaluated, while the false branch doesn't, fake target reads could conclude that a frame information is not needed, where in fact it is. This wrong information would then cause the expression to be actually evaluated (by the location description evaluator) with a missing frame information. This would then crash the debugger. The gdb.dwarf2/symbol_needs_eval_fail.exp test introduces this scenario, with the following DWARF expression:                    DW_OP_addr $some_variable                    DW_OP_deref                    # conditional jump to DW_OP_bregx                    DW_OP_bra 4                    DW_OP_lit0                    # jump to DW_OP_stack_value                    DW_OP_skip 3                    DW_OP_bregx $dwarf_regnum 0                    DW_OP_stack_value This expression describes a case where some variable dictates the location of another variable. Depending on a value of some_variable, the variable whose location is described by this expression is either read from a register or it is defined as a constant value 0. In both cases, the value will be returned as an implicit location description on the DWARF stack. Currently, when the symbol needs evaluator fakes a memory read from the address behind the some_variable variable, the constant value 0 is used as the value of the variable A, and the check returns the SYMBOL_NEEDS_NONE result. This is clearly a wrong result and it causes the debugger to crash. The scenario might sound strange to some people, but it comes from a SIMD/SIMT architecture where $some_variable is an execution mask.  In any case, it is a valid DWARF expression, and GDB shouldn't crash while evaluating it. Also, a similar example could be made based on a condition of the frame base value, where if that value is concluded to be 0, the variable location could be defaulted to a TLS based memory address. The gdb.dwarf2/symbol_needs_eval_timeout.exp test introduces a second scenario. This scenario is a bit more abstract due to the DWARF assembler lacking the CFI support, but it exposes a different manifestation of the same problem. Like in the previous scenario, the DWARF expression used in the test is valid:                        DW_OP_lit1                        DW_OP_addr $some_variable                        DW_OP_deref                        # jump to DW_OP_fbreg                        DW_OP_skip 4                        DW_OP_drop                        DW_OP_fbreg 0                        DW_OP_dup                        DW_OP_lit0                        DW_OP_eq                        # conditional jump to DW_OP_drop                        DW_OP_bra -9                        DW_OP_stack_value Similarly to the previous scenario, the location of a variable A is an implicit location description with a constant value that depends on a value held by a global variable. The difference from the previous case is that DWARF expression contains a loop instead of just one branch. The end condition of that loop depends on the expectation that a frame base value is never zero. Currently, the act of faking the target reads will cause the symbol needs evaluator to get stuck in an infinite loop. Somebody could argue that we could change the fake reads to return something else, but that would only hide the real problem. The general impression seems to be that the desired design is to have one class that deals with parsing of the DWARF expression, while there are virtual methods that deal with specifics of some operations. Using an evaluator mechanism here doesn't seem to be correct, because the act of evaluation relies on accessing the data from the actual target with the possibility of skipping the evaluation of some parts of the expression. To better explain the proposed solution for the issue, I first need to explain a couple more details behind the current design: There are multiple places in gdb that handle DWARF expression parsing for different purposes. Some are in charge of converting the expression to some other internal representation (decode_location_expression, disassemble_dwarf_expression and dwarf2_compile_expr_to_ax), some are analysing the expression for specific information (compute_stack_depth_worker) and some are in charge of evaluating the expression in a given context (dwarf_expr_context::execute_stack_op and decode_locdesc). The problem is that all those functions have a similar (large) switch statement that handles each DWARF expression operation. The result of this is a code duplication and harder maintenance. As a step into the right direction to solve this problem (at least for the purpose of a DWARF expression evaluation) the expression parsing was commonized inside of an evaluator base class (dwarf_expr_context). This makes sense for all derived classes, except for the symbol needs evaluator (symbol_needs_eval_context) class. As described previously the problem with this evaluator is that if the evaluator is not allowed to access the actual target, it is not really evaluating. Instead, the desired function of a symbol needs evaluator seems to fall more into expression analysis category. This means that a more natural fit for this evaluator is to be a symbol needs analysis, similar to the existing compute_stack_depth_worker analysis. Another problem is that using a heavyweight mechanism of an evaluator to do an expression analysis seems to be an unneeded overhead. It also requires a more complicated design of the parent class to support fake target reads. The reality is that the whole symbol_needs_eval_context class can be replaced with a lightweight recursive analysis function, that will give more correct result without compromising the design of the dwarf_expr_context class. The analysis treats the expression byte stream as a DWARF operation graph, where each graph node can be visited only once and each operation can decide if the frame context is needed for their evaluation. The downside of this approach is adding of one more similar switch statement, but at least this way the new symbol needs analysis will be a lightweight mechnism and it will provide a correct result for any given DWARF expression. A more desired long term design would be to have one class that deals with parsing of the DWARF expression, while there would be a virtual methods that deal with specifics of some DWARF operations. Then that class would be used as a base for all DWARF expression parsing mentioned at the beginning. This however, requires a far bigger changes that are out of the scope of this patch series. The new analysis requires the DWARF location description for the argc argument of the main function to change in the assembly file gdb.python/amd64-py-framefilter-invalidarg.S. Originally, expression ended with a 0 value byte, which was never reached by the symbol needs evaluator, because it was detecting a stack underflow when evaluating the operation before. The new approach does not simulate a DWARF stack anymore, so the 0 value byte needs to be removed because it makes the DWARF expression invalid. gdb/ChangeLog: * dwarf2/loc.c (class symbol_needs_eval_context): Remove. (dwarf2_get_symbol_read_needs): New function. (dwarf2_loc_desc_get_symbol_read_needs): Remove. (locexpr_get_symbol_read_needs): Use dwarf2_get_symbol_read_needs. gdb/testsuite/ChangeLog: * gdb.python/amd64-py-framefilter-invalidarg.S : Update argc DWARF location expression. * lib/dwarf.exp (_location): Handle DW_OP_fbreg. * gdb.dwarf2/symbol_needs_eval.c: New file. * gdb.dwarf2/symbol_needs_eval_fail.exp: New file. * gdb.dwarf2/symbol_needs_eval_timeout.exp: New file.
2021-06-22gdb: Support DW_LLE_start_endAndreas Schwab1-0/+29
Without that it is impossible to debug on riscv64. gdb/ PR symtab/27999 * dwarf2/loc.c (decode_debug_loclists_addresses): Support DW_LLE_start_end. gdb/testsuite/ PR symtab/27999 * lib/dwarf.exp (start_end): New proc inside loclists. * gdb.dwarf2/loclists-start-end.exp: New file. * gdb.dwarf2/loclists-start-end.c: New file.
2021-04-14testsuite, gdb: recognize DW_OP_fbreg in lib/dwarf.expTankut Baris Aktemur1-0/+5
gdb/testsuite/ChangeLog: 2021-04-14 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * lib/dwarf.exp (_location): Recognize DW_OP_fbreg as an op.
2021-04-07gdb/testsuite: fix fission support in the Dwarf assemblerAndrew Burgess1-44/+217
This commit fixes fission support in the Dwarf assembler. I added the new test gdb.dwarf2/fission-absolute-dwo.exp which is a simple example of using the fission support. I also rewrote the existing test gdb.dwarf2/fission-multi-cu.exp to use the new functionality (instead of using an x86-64 only assembler file). To better support compiling the assembler files produced by the Dwarf assembler I have added the new proc build_executable_and_dwo_files in lib/dwarf.exp, this replaces build_executable_from_fission_assembler, all the tests that used the old proc have been updated. Where the old proc assumed a single .S source file which contained the entire test, the new proc allows for multiple source files. The Dwarf assembler already had some fission support, however, this was not actually used in any tests, and when I tried using it there were a few issues. The biggest change is that we now generate DW_FORM_GNU_addr_index instead of DW_FORM_addr for the low and high pc in _handle_macro_at_range, support for the DW_FORM_GNU_addr_index is new in this commit. gdb/testsuite/ChangeLog: * gdb.dwarf2/fission-absolute-dwo.c: New file. * gdb.dwarf2/fission-absolute-dwo.exp: New file. * gdb.dwarf2/fission-base.exp: Use build_executable_and_dwo_files instead of build_executable_from_fission_assembler. * gdb.dwarf2/fission-loclists-pie.exp: Likewise. * gdb.dwarf2/fission-loclists.exp: Likewise.
2021-03-31Add some error checking to DWARF assemblerTom Tromey1-33/+52
I had written a DWARF location expression like DW_OP_const1u DW_OP_stack_value ... and was surprised to see that the DW_OP_stack_value didn't appear in the "readelf" output. The problem here is that DW_OP_const1u requires an operand, but neither the DWARF assembler nor gas diagnosed this problem. This patch adds some checking to Dwarf::_location to try to avoid this in the future. The checking is done via a helper proc that also dissects the argument list and sets an array in the caller's frame. gdb/testsuite/ChangeLog 2021-03-31 Tom Tromey <tromey@adacore.com> * lib/dwarf.exp (Dwarf::_get_args): New proc. (Dwarf::_location): Use it.
2021-03-22gdb/testsuite: use the correct .debug_str section name for DW_FORM_strpAndrew Burgess1-1/+1
When handling DWARF attributes of the form DW_FORM_strp the strings should be placed in the .debug_str section, not .debug_string as they currently are by the DWARF assembler (in lib/dwarf.exp). I've added a test. This is as much to test the DWARF generator as it is to test GDB as GCC makes frequent use of DW_FORM_strp so we can be pretty sure this part of GDB is already well tested. gdb/testsuite/ChangeLog: * gdb.dwarf2/dw2-using-debug-str.c: New file. * gdb.dwarf2/dw2-using-debug-str.exp: New file. * lib/dwarf.exp (Dwarf::DW_FORM_strp): Create .debug_str section, not .debug_string.
2021-03-06Avoid crash on missing dwz fileTom Tromey1-2/+2
If DWARF contains a reference to a "dwz" file, but there is no .gnu_debugaltlink section, then gdb will crash. This happens because dwarf2_get_dwz_file will return NULL, but some callers do not expect this. This patch changes dwarf2_get_dwz_file so that callers can require a dwz file. Then, it updates the callers that are attempting to process references to the dwz file to require one. This includes a new testcase. The dwarf.exp changes don't handle the new forms exactly correctly -- they are only handled well enough to let this test case complete. gdb/ChangeLog 2021-03-06 Tom Tromey <tom@tromey.com> * dwarf2/read.h (dwarf2_get_dwz_file): Add 'require' parameter. * dwarf2/read.c (dwarf2_get_dwz_file): Add 'require' parameter. (get_abbrev_section_for_cu, read_attribute_value) (get_debug_line_section): Update. * dwarf2/macro.c (dwarf_decode_macro_bytes): Update. gdb/testsuite/ChangeLog 2021-03-06 Tom Tromey <tom@tromey.com> * lib/dwarf.exp (_handle_DW_FORM): Treat DW_FORM_GNU_ref_alt and DW_FORM_GNU_strp_alt like DW_FORM_sec_offset. * gdb.dwarf2/dwznolink.exp: New file.
2021-02-11gdb: Remove arm-symbianelf supportAlan Modra1-1/+0
Since it has gone from bfd/. * arm-symbian-tdep.c: Delete. * NEWS: Mention arm-symbian removal. * Makefile.in: Remove arm-symbian-tdep entries. * configure.tgt: Remove arm*-*-symbianelf*. * doc/gdb.texinfo: Remove mention of SymbianOS. * osabi.c (gdb_osabi_names): Remove "Symbian". * osabi.h (enum gdb_osabi): Remove GDB_OSABI_SYMBIAN. * testsuite/gdb.base/ending-run.exp: Remove E32Main handling. * testsuite/gdb.ada/catch_ex_std.exp: Remove arm*-*-symbianelf* handling. * testsuite/gdb.base/dup-sect.exp: Likewise. * testsuite/gdb.base/long_long.exp: Likewise. * testsuite/gdb.base/solib-weak.exp: Likewise. * testsuite/gdb.guile/scm-section-script.exp: Likewise. * testsuite/gdb.python/py-section-script.exp: Likewise. * testsuite/lib/dwarf.exp: Likewise. * testsuite/lib/gdb.exp: Likewise.
2021-02-02gdb/testsuite: add test for .debug_{rng,loc}lists section without offset arraySimon Marchi1-10/+38
It is possible for the tables in the .debug_{rng,loc}lists sections to not have an array of offsets. In that case, the offset_entry_count field of the header is 0. The forms DW_FORM_{rng,loc}listx (reference by index) can't be used with that table. Instead, the DW_FORM_sec_offset form, which references a {rng,loc}list by direct offset in the section, must be used. From what I saw, this is what GCC currently produces. Add tests for this case. I didn't see any bug related to this, I just think that it would be nice to have coverage for this. A new `-with-offset-array` option is added to the `table` procs, used when generating {rng,loc}lists, to decide whether to generate the offset array. gdb/testsuite/ChangeLog: * lib/dwarf.exp (rnglists): Add -no-offset-array option to table proc. * gdb.dwarf2/rnglists-sec-offset.exp: Add test for .debug_rnglists table without offset array. * gdb.dwarf2/loclists-sec-offset.exp: Add test for .debug_loclists table without offset array. Change-Id: I8e34a7bf68c9682215ffbbf66600da5b7db91ef7
2021-02-02gdb/testsuite: add .debug_loclists testsSimon Marchi1-0/+196
Add tests for the various issues fixed in the previous patches. Add a new "loclists" procedure to the DWARF assembler, to allow generating .debug_loclists sections. gdb/testsuite/ChangeLog: PR gdb/26813 * lib/dwarf.exp (_handle_DW_FORM): Handle DW_FORM_loclistx. (loclists): New proc. * gdb.dwarf2/loclists-multiple-cus.c: New. * gdb.dwarf2/loclists-multiple-cus.exp: New. * gdb.dwarf2/loclists-sec-offset.c: New. * gdb.dwarf2/loclists-sec-offset.exp: New. Change-Id: I209bcb2a9482762ae943e518998d1f7761f76928
2021-02-02gdb/testsuite: DWARF assembler: add context parameters to _locationSimon Marchi1-13/+27
The _location proc is used to assemble a location description. It needs to know some contextual information: - size of an address - size of an offset (into another DWARF section) - DWARF version It currently get all this directly from global variables holding the compilation unit information. This is fine because as of now, all location descriptions are generated in the context of creating a compilation unit. However, a subsequent patch will generate location descriptions while generating a .debug_loclists section. _location should therefore no longer rely on the current compilation unit's properties. Change it to accept these values as parameters instead of accessing the values for the CU. No functional changes intended. gdb/testsuite/ChangeLog: * lib/dwarf.exp (_location): Add parameters. (_handle_DW_FORM): Adjust. Change-Id: Ib94981979c83ffbebac838081d645ad71c221637