Inconsistent treatment of template parameters in DWARF reader

Message ID 20250305005206.896622-1-tom@tromey.com
State New
Headers
Series Inconsistent treatment of template parameters in DWARF reader |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed

Commit Message

Tom Tromey March 5, 2025, 12:52 a.m. UTC
  I noticed that if you hack some clean_restart calls into
paramless.exp, the test will fail.  That is, the test currently relies
on the desired CUs already being expanded when trying to set a
breakpoint -- which is clearly a bug, the CU expansion state should
not affect "break".

I tracked this down to incorrect construction of a lookup_name_info in
cooked_index_functions::expand_symtabs_matching.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32510
---
 gdb/dwarf2/read.c                  |  4 ++--
 gdb/testsuite/gdb.cp/paramless.exp | 15 +++++----------
 2 files changed, 7 insertions(+), 12 deletions(-)
  

Comments

Simon Marchi March 5, 2025, 3:23 p.m. UTC | #1
On 3/4/25 7:52 PM, Tom Tromey wrote:
> I noticed that if you hack some clean_restart calls into
> paramless.exp, the test will fail.  That is, the test currently relies
> on the desired CUs already being expanded when trying to set a
> breakpoint -- which is clearly a bug, the CU expansion state should
> not affect "break".
> 
> I tracked this down to incorrect construction of a lookup_name_info in
> cooked_index_functions::expand_symtabs_matching.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32510
> ---
>  gdb/dwarf2/read.c                  |  4 ++--
>  gdb/testsuite/gdb.cp/paramless.exp | 15 +++++----------
>  2 files changed, 7 insertions(+), 12 deletions(-)
> 
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 6080dca6ea6..bf17efaad21 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -16004,8 +16004,8 @@ cooked_index_functions::expand_symtabs_matching
>        segment_lookup_names.reserve (name_vec.size ());
>        for (auto &segment_name : name_str_vec)
>  	{
> -	  segment_lookup_names.emplace_back (segment_name,
> -	    symbol_name_match_type::FULL, completing, true);
> +	  segment_lookup_names.emplace_back (segment_name, match_type,
> +					     completing, true);
>  	}

I'm not super familiar with this code, but it makes sense to use the
match_type that ultimately was passed by the caller.

Could you remove the unnecessary curly braces while at it?

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon
  
Tom Tromey March 5, 2025, 5:10 p.m. UTC | #2
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

Simon> Could you remove the unnecessary curly braces while at it?

I did it.

Simon> Approved-By: Simon Marchi <simon.marchi@efficios.com>

Thanks.

Also I forgot I'd sent this patch earlier, which explains the duplicate.

Tom
  

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 6080dca6ea6..bf17efaad21 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16004,8 +16004,8 @@  cooked_index_functions::expand_symtabs_matching
       segment_lookup_names.reserve (name_vec.size ());
       for (auto &segment_name : name_str_vec)
 	{
-	  segment_lookup_names.emplace_back (segment_name,
-	    symbol_name_match_type::FULL, completing, true);
+	  segment_lookup_names.emplace_back (segment_name, match_type,
+					     completing, true);
 	}
 
       for (const cooked_index_entry *entry : table->find (name_str_vec.back (),
diff --git a/gdb/testsuite/gdb.cp/paramless.exp b/gdb/testsuite/gdb.cp/paramless.exp
index fe7c0b38748..68f66441f80 100644
--- a/gdb/testsuite/gdb.cp/paramless.exp
+++ b/gdb/testsuite/gdb.cp/paramless.exp
@@ -30,17 +30,12 @@  if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
     return -1
 }
 
-gdb_breakpoint "outer<int>::fn" message
-delete_breakpoints
-
-gdb_breakpoint "outer<char>::fn<short>" message
-delete_breakpoints
+foreach ordinary {"outer<int>::fn" "outer<char>::fn<short>" "toplev<char>"} {
+    gdb_breakpoint $ordinary message
+    clean_restart $testfile
+}
 
 gdb_test "break outer::fn" "Breakpoint $decimal at .*2 locations."
-delete_breakpoints
 
+clean_restart $testfile
 gdb_test "break toplev" "Breakpoint $decimal at .*2 locations."
-delete_breakpoints
-
-gdb_breakpoint "toplev<char>" message
-delete_breakpoints