public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/symtab] Fix line number of static const class member
@ 2023-03-24 14:46 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2023-03-24 14:46 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9ed6d7410c800c331d1f24051c85e4e52d7dfced

commit 9ed6d7410c800c331d1f24051c85e4e52d7dfced
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Mar 24 15:45:56 2023 +0100

    [gdb/symtab] Fix line number of static const class member
    
    Since commit 6d263fe46e0 ("Avoid bad breakpoints with --gc-sections"), there
    was a silent regression on openSUSE Leap 15.4 for test-case
    gdb.cp/m-static.exp, from:
    ...
    (gdb) info variable everywhere^M
    All variables matching regular expression "everywhere":^M
    ^M
    File /home/vries/tmp.local-remote-host-native/m-static.h:^M
    8:      const int gnu_obj_4::everywhere;^M
    (gdb)
    ...
    to:
    ...
    (gdb) info variable everywhere^M
    All variables matching regular expression "everywhere":^M
    ^M
    File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static.h:^M
    8:      const int gnu_obj_4::everywhere;^M
    ^M
    File /data/vries/gdb/src/gdb/testsuite/gdb.cp/m-static1.cc:^M
    8:      const int gnu_obj_4::everywhere;^M
    (gdb)
    ...
    
    Another regression was found due to that commit, and it was fixed in commit
    99d679e7b30 ("[gdb/symtab] Fix "file index out of range" complaint") by
    limiting the scope of the fix in the original commit.
    
    Fix this regression by yet further limiting the scope of that fix, making sure
    that this bit in dwarf_decode_lines is executed again for m-static1.cc:
    ...
      /* Make sure a symtab is created for every file, even files
         which contain only variables (i.e. no code with associated
         line numbers).  */
    ...
    
    Tested on x86_64-linux.
    
    PR symtab/30265
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30265

Diff:
---
 gdb/dwarf2/read.c                 | 3 +--
 gdb/testsuite/gdb.cp/m-static.exp | 4 +++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index c9208a097bf..c910be875a3 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -7610,8 +7610,7 @@ handle_DW_AT_stmt_list (struct die_info *die, struct dwarf2_cu *cu,
      then there won't be any interesting code in the CU, but a check later on
      (in lnp_state_machine::check_line_address) will fail to properly exclude
      an entry that was removed via --gc-sections.  */
-  if (have_code)
-    dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping);
+  dwarf_decode_lines (cu->line_header, cu, lowpc, decode_mapping && have_code);
 }
 
 /* Process DW_TAG_compile_unit or DW_TAG_partial_unit.  */
diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
index 37d3289a751..a78baa9e895 100644
--- a/gdb/testsuite/gdb.cp/m-static.exp
+++ b/gdb/testsuite/gdb.cp/m-static.exp
@@ -185,8 +185,10 @@ gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const flo
 if { $non_dwarf } { setup_xfail *-*-* }
 gdb_test "info variable everywhere" \
     [multi_line \
+	 {All variables matching regular expression "everywhere":} \
+	 "" \
 	 "File (.*/)?m-static\[.\]h:" \
-	 "$decimal:\tconst int gnu_obj_4::everywhere;.*"]
+	 "$decimal:\tconst int gnu_obj_4::everywhere;"]
 
 # Perhaps at some point test4 should also include a test for a static
 # const int that was initialized in the header file.  But I'm not sure

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-24 14:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-24 14:46 [binutils-gdb] [gdb/symtab] Fix line number of static const class member Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).