gdb: Fix reading of partial symtabs in dbxread.c
authorThiago Jung Bauermann <thiago.bauermann@linaro.org>
Mon, 3 Apr 2023 22:39:46 +0000 (22:39 +0000)
committerThiago Jung Bauermann <thiago.bauermann@linaro.org>
Wed, 5 Apr 2023 19:56:09 +0000 (19:56 +0000)
After commit 9675da25357c ("Use unrelocated_addr in minimal symbols"),
aarch64-linux started failing gdb.asm/asm-source.exp:

Running /home/thiago.bauermann/src/binutils-gdb/gdb/testsuite/gdb.asm/asm-source.exp ...
PASS: gdb.asm/asm-source.exp: f at main
PASS: gdb.asm/asm-source.exp: n at main
PASS: gdb.asm/asm-source.exp: next over macro
FAIL: gdb.asm/asm-source.exp: step into foo2
PASS: gdb.asm/asm-source.exp: info target
PASS: gdb.asm/asm-source.exp: info symbol
PASS: gdb.asm/asm-source.exp: list
PASS: gdb.asm/asm-source.exp: search
FAIL: gdb.asm/asm-source.exp: f in foo2
FAIL: gdb.asm/asm-source.exp: n in foo2 (the program exited)
FAIL: gdb.asm/asm-source.exp: bt ALL in foo2
FAIL: gdb.asm/asm-source.exp: bt 2 in foo2
PASS: gdb.asm/asm-source.exp: s 2
PASS: gdb.asm/asm-source.exp: n 2
FAIL: gdb.asm/asm-source.exp: bt 3 in foo3
PASS: gdb.asm/asm-source.exp: info source asmsrc1.s
FAIL: gdb.asm/asm-source.exp: finish from foo3 (the program is no longer running)
FAIL: gdb.asm/asm-source.exp: info source asmsrc2.s
PASS: gdb.asm/asm-source.exp: info sources
FAIL: gdb.asm/asm-source.exp: info line
FAIL: gdb.asm/asm-source.exp: next over foo3 (the program is no longer running)
FAIL: gdb.asm/asm-source.exp: return from foo2
PASS: gdb.asm/asm-source.exp: look at global variable
PASS: gdb.asm/asm-source.exp: x/i &globalvar
PASS: gdb.asm/asm-source.exp: disassem &globalvar, (int *) &globalvar+1
PASS: gdb.asm/asm-source.exp: look at static variable
PASS: gdb.asm/asm-source.exp: x/i &staticvar
PASS: gdb.asm/asm-source.exp: disassem &staticvar, (int *) &staticvar+1
PASS: gdb.asm/asm-source.exp: look at static function

The problem is simple: a pair of parentheses was removed from the
expression calculating text_end and thus text_size was only added if
lowest_text_address wasn't equal to -1.

This patch restores the previous behaviour and fixes the testcase.
Tested on native aarch64-linux.

Reviewed-By: Tom Tromey <tom@tromey.com>
gdb/dbxread.c

index f7c44c14ae2eb4e363565e3a086af25d1be815c5..73371edd841284ea93f990a285a0c90ceb24f3db 100644 (file)
@@ -1950,9 +1950,9 @@ read_dbx_symtab (minimal_symbol_reader &reader,
         is.  */
       unrelocated_addr text_end
        = (unrelocated_addr
-          (lowest_text_address == (unrelocated_addr) -1
-           ? text_addr
-           : CORE_ADDR (lowest_text_address)
+          ((lowest_text_address == (unrelocated_addr) -1
+            ? text_addr
+            : CORE_ADDR (lowest_text_address))
            + text_size));
 
       dbx_end_psymtab (objfile, partial_symtabs,