[1/2] gdb: Fix reading of partial symtabs in dbxread.c

Message ID 20230404175915.288558-2-thiago.bauermann@linaro.org
State New
Headers
Series Fix regression in stabs debug info |

Commit Message

Thiago Jung Bauermann April 4, 2023, 5:59 p.m. UTC
  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.
---
 gdb/dbxread.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Patch

diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index f7c44c14ae2e..73371edd8412 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -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,