public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] [gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp with clang
@ 2022-09-01 14:09 Tom de Vries
  2022-09-01 14:09 ` [PATCH 2/2] [gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp for ppc64le Tom de Vries
  0 siblings, 1 reply; 4+ messages in thread
From: Tom de Vries @ 2022-09-01 14:09 UTC (permalink / raw)
  To: gdb-patches

When running test-case gdb.dwarf2/dw2-dir-file-name.exp with clang, we run
into:
...
(gdb) break *compdir_missing__ldir_missing__file_basename^M
Breakpoint 2 at 0x400580^M
(gdb) continue^M
Continuing.^M
^M
Breakpoint 2, 0x0000000000400580 in \
  compdir_missing.ldir_missing.file_basename ()^M
(gdb) FAIL: gdb.dwarf2/dw2-dir-file-name.exp: \
  compdir_missing__ldir_missing__file_basename: continue to breakpoint: \
  compdir_missing__ldir_missing__file_basename
...

The problem is that the test-case uses labels outside functions, which is know
to cause problem with clang, as documented in the comment for proc
function_range.

Fix this by using get_func_info instead.

Tested on x86_64-linux, with both gcc 7.5.0 and clang 13.0.0.
---
 gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.c  | 19 +-----
 .../gdb.dwarf2/dw2-dir-file-name.exp          | 66 +++++++++++++++++--
 2 files changed, 62 insertions(+), 23 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.c b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.c
index a2a0db27155..8041053b4d8 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.c
+++ b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.c
@@ -63,28 +63,13 @@ FUNC (compdir_absolute_ldir_absolute_file_relative_different)	\
 FUNC (compdir_absolute_ldir_absolute_file_absolute_same)	\
 FUNC (compdir_absolute_ldir_absolute_file_absolute_different)
 
-#ifdef __mips__
-#define START_INSNS asm (".insn\n");
-#else
-#define START_INSNS
-#endif
-
-/* Notes: (1) The '*_start' label below is needed because 'name' may
-   point to a function descriptor instead of to the actual code.  (2)
-   The '.balign' should specify the highest possible function
-   alignment across all supported architectures, such that the label
-   never points into the alignment gap.  */
-
 #define FUNC(name)					\
-  asm (".balign 8");					\
-  asm (#name "_start: .globl " #name "_start\n");	\
-  START_INSNS						\
   static void						\
   name (void)						\
   {							\
+    asm (#name "_label: .globl " #name "_label\n");	\
     v++;						\
-  }							\
-  asm (#name "_end: .globl " #name "_end\n");
+  }
 FUNCBLOCK
 #undef FUNC
 
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
index 4c4c1ff07af..08b5c645fa2 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
@@ -34,6 +34,50 @@ if {[is_64_target]} {
 }
 
 standard_testfile
+
+set func_info_names {
+    compdir_missing__ldir_missing__file_basename
+    compdir_missing__ldir_missing__file_relative
+    compdir_missing__ldir_missing__file_absolute
+    compdir_missing__ldir_relative_file_basename
+    compdir_missing__ldir_relative_file_relative
+    compdir_missing__ldir_relative_file_absolute
+    compdir_missing__ldir_absolute_file_basename
+    compdir_missing__ldir_absolute_file_relative
+    compdir_missing__ldir_absolute_file_absolute_same
+    compdir_missing__ldir_absolute_file_absolute_different
+    compdir_relative_ldir_missing__file_basename
+    compdir_relative_ldir_missing__file_relative
+    compdir_relative_ldir_missing__file_absolute
+    compdir_relative_ldir_relative_file_basename
+    compdir_relative_ldir_relative_file_relative
+    compdir_relative_ldir_relative_file_absolute
+    compdir_relative_ldir_absolute_file_basename
+    compdir_relative_ldir_absolute_file_relative
+    compdir_relative_ldir_absolute_file_absolute_same
+    compdir_relative_ldir_absolute_file_absolute_different
+    compdir_absolute_ldir_missing__file_basename
+    compdir_absolute_ldir_missing__file_relative
+    compdir_absolute_ldir_missing__file_absolute_same
+    compdir_absolute_ldir_missing__file_absolute_different
+    compdir_absolute_ldir_relative_file_basename
+    compdir_absolute_ldir_relative_file_relative
+    compdir_absolute_ldir_relative_file_absolute_same
+    compdir_absolute_ldir_relative_file_absolute_different
+    compdir_absolute_ldir_absolute_file_basename_same
+    compdir_absolute_ldir_absolute_file_basename_different
+    compdir_absolute_ldir_absolute_file_relative_same
+    compdir_absolute_ldir_absolute_file_relative_different
+    compdir_absolute_ldir_absolute_file_absolute_same
+    compdir_absolute_ldir_absolute_file_absolute_different
+}
+
+with_shared_gdb {
+    foreach func_info_name $func_info_names {
+	get_func_info $func_info_name
+    }
+}
+
 set asmsrcfile [standard_output_file ${testfile}asm.S]
 set asmobjfile [standard_output_file ${testfile}asm.o]
 set srcabsdir [standard_output_file ${testfile}.d]
@@ -52,6 +96,11 @@ proc out_cu { name cu_dir cu_name line_dir line_name } {
     global f
     global addr_len
 
+    global ${name}_start
+    global ${name}_end
+    set name_start [set ${name}_start]
+    set name_end [set ${name}_end]
+
     puts -nonewline $f "\
 .L${name}_begin:
 	.4byte	.L${name}_end - .L${name}_start	/* Length of Compilation Unit */
@@ -69,8 +118,8 @@ proc out_cu { name cu_dir cu_name line_dir line_name } {
 	.ascii	\"GNU C\\0\"			/* DW_AT_producer */
 	.byte	2				/* DW_AT_language (DW_LANG_C) */
 	.4byte	.Lline_${name}_begin		/* DW_AT_stmt_list */
-	.${addr_len}byte ${name}_start		/* DW_AT_low_pc */
-	.${addr_len}byte ${name}_end		/* DW_AT_high_pc */
+	.${addr_len}byte $name_start		/* DW_AT_low_pc */
+	.${addr_len}byte $name_end		/* DW_AT_high_pc */
 "
     if { $cu_dir != "" } {
 	puts $f "  .ascii $cu_dir /* DW_AT_comp_dir */"
@@ -80,8 +129,8 @@ proc out_cu { name cu_dir cu_name line_dir line_name } {
 
 	.uleb128	3			/* Abbrev: DW_TAG_subprogram */
 	.asciz		\"${name}\"		/* DW_AT_name */
-	.${addr_len}byte ${name}_start		/* DW_AT_low_pc */
-	.${addr_len}byte ${name}_end		/* DW_AT_high_pc */
+	.${addr_len}byte $name_start		/* DW_AT_low_pc */
+	.${addr_len}byte $name_end		/* DW_AT_high_pc */
 
 	.byte		0			/* End of children of CU */
 .L${name}_end:
@@ -92,6 +141,11 @@ proc out_line { name cu_dir cu_name line_dir line_name } {
     global f
     global addr_len
 
+    global ${name}_start
+    global ${name}_end
+    set name_start [set ${name}_start]
+    set name_end [set ${name}_end]
+
     puts -nonewline $f "\
 .Lline_${name}_begin:
 	.4byte		.Lline_${name}_end - .Lline_${name}_start	/* Initial length */
@@ -138,14 +192,14 @@ proc out_line { name cu_dir cu_name line_dir line_name } {
 	.byte		0	/* DW_LNE_set_address */
 	.uleb128	${addr_len}+1
 	.byte		2
-	.${addr_len}byte ${name}_start
+	.${addr_len}byte $name_start
 	.byte		1	/* DW_LNS_copy */
 	.byte		3	/* DW_LNS_advance_line */
 	.sleb128	1	/* ... to 1000 */
 	.byte		0	/* DW_LNE_set_address */
 	.uleb128	${addr_len}+1
 	.byte		2
-	.${addr_len}byte ${name}_end
+	.${addr_len}byte $name_end
 	.byte		1	/* DW_LNS_copy */
 	.byte		0	/* DW_LNE_end_of_sequence */
 	.uleb128	1

base-commit: 7b0d7ede79f548915641ac5916fbeb77fc9c44ff
-- 
2.35.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] [gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp for ppc64le
  2022-09-01 14:09 [PATCH 1/2] [gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp with clang Tom de Vries
@ 2022-09-01 14:09 ` Tom de Vries
  2022-09-12 10:20   ` Luis Machado
  0 siblings, 1 reply; 4+ messages in thread
From: Tom de Vries @ 2022-09-01 14:09 UTC (permalink / raw)
  To: gdb-patches

In commit cd919f5533c ("[gdb/testsuite] Fix
gdb.dwarf2/dw2-dir-file-name.exp"), I made gdb.dwarf2/dw2-dir-file-name.exp
independent of prologue analyzers, using this change:
...
-       gdb_breakpoint $func
+       gdb_breakpoint *$func
...

That however caused a regression on ppc64le.  For PowerPC, as described in the
ELFv2 ABI, a function can have a global and local entry point.

Setting a breakpoint on *$func effectively creates a breakpoint for the global
entry point, so if the function is entered through the local entry point, the
breakpoint doesn't trigger.

Fix this by reverting commit cd919f5533c, and setting the breakpoint on
${func}_label instead.

Tested on x86_64-linux and ppc64le-linux.
---
 gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp | 8 ++++----
 gdb/testsuite/lib/gdb.exp                      | 7 +------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
index 08b5c645fa2..053f7229537 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
@@ -450,20 +450,20 @@ proc test { func compdir filename } {
 	    error "not absolute"
 	}
 
-	gdb_breakpoint *$func
+	gdb_breakpoint ${func}_label
 	gdb_continue_to_breakpoint $func "$func \\(\\) at .*"
 
 	gdb_test_no_output "set filename-display absolute"
 	verbose -log "expect: ${absolute}"
-	gdb_test "frame" "#0  $func \\(\\) at [string_to_regexp ${absolute}]:999" "absolute"
+	gdb_test "frame" " in $func \\(\\) at [string_to_regexp ${absolute}]:999" "absolute"
 
 	gdb_test_no_output "set filename-display basename"
 	verbose -log "expect: [file tail $filename]"
-	gdb_test "frame" "#0  $func \\(\\) at [string_to_regexp [file tail $filename]]:999" "basename"
+	gdb_test "frame" " in $func \\(\\) at [string_to_regexp [file tail $filename]]:999" "basename"
 
 	gdb_test_no_output "set filename-display relative"
 	verbose -log "expect: $filename"
-	gdb_test "frame" "#0  $func \\(\\) at [string_to_regexp $filename]:999" "relative"
+	gdb_test "frame" " in $func \\(\\) at [string_to_regexp $filename]:999" "relative"
     }
 }
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 17523f82996..2f1147159ad 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -787,14 +787,9 @@ proc gdb_continue_to_breakpoint {name {location_pattern .*}} {
     global gdb_prompt
     set full_name "continue to breakpoint: $name"
 
-    set re_at_in " (at|in) "
-    if { [regexp $re_at_in $location_pattern] } {
-	set re_at_in " "
-    }
-
     set kfail_pattern "Process record does not support instruction 0xfae64 at.*"
     gdb_test_multiple "continue" $full_name {
-	-re "(?:Breakpoint|Temporary breakpoint) .*$re_at_in$location_pattern\r\n$gdb_prompt $" {
+	-re "(?:Breakpoint|Temporary breakpoint) .* (at|in) $location_pattern\r\n$gdb_prompt $" {
 	    pass $full_name
 	}
 	-re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" {
-- 
2.35.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] [gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp for ppc64le
  2022-09-01 14:09 ` [PATCH 2/2] [gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp for ppc64le Tom de Vries
@ 2022-09-12 10:20   ` Luis Machado
  2022-09-13 14:55     ` Tom de Vries
  0 siblings, 1 reply; 4+ messages in thread
From: Luis Machado @ 2022-09-12 10:20 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

On 9/1/22 15:09, Tom de Vries via Gdb-patches wrote:
> In commit cd919f5533c ("[gdb/testsuite] Fix
> gdb.dwarf2/dw2-dir-file-name.exp"), I made gdb.dwarf2/dw2-dir-file-name.exp
> independent of prologue analyzers, using this change:
> ...
> -       gdb_breakpoint $func
> +       gdb_breakpoint *$func
> ...
> 
> That however caused a regression on ppc64le.  For PowerPC, as described in the
> ELFv2 ABI, a function can have a global and local entry point.
> 
> Setting a breakpoint on *$func effectively creates a breakpoint for the global
> entry point, so if the function is entered through the local entry point, the
> breakpoint doesn't trigger.
> 
> Fix this by reverting commit cd919f5533c, and setting the breakpoint on
> ${func}_label instead.
> 
> Tested on x86_64-linux and ppc64le-linux.
> ---
>   gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp | 8 ++++----
>   gdb/testsuite/lib/gdb.exp                      | 7 +------
>   2 files changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
> index 08b5c645fa2..053f7229537 100644
> --- a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
> +++ b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
> @@ -450,20 +450,20 @@ proc test { func compdir filename } {
>   	    error "not absolute"
>   	}
>   
> -	gdb_breakpoint *$func
> +	gdb_breakpoint ${func}_label
>   	gdb_continue_to_breakpoint $func "$func \\(\\) at .*"
>   
>   	gdb_test_no_output "set filename-display absolute"
>   	verbose -log "expect: ${absolute}"
> -	gdb_test "frame" "#0  $func \\(\\) at [string_to_regexp ${absolute}]:999" "absolute"
> +	gdb_test "frame" " in $func \\(\\) at [string_to_regexp ${absolute}]:999" "absolute"
>   
>   	gdb_test_no_output "set filename-display basename"
>   	verbose -log "expect: [file tail $filename]"
> -	gdb_test "frame" "#0  $func \\(\\) at [string_to_regexp [file tail $filename]]:999" "basename"
> +	gdb_test "frame" " in $func \\(\\) at [string_to_regexp [file tail $filename]]:999" "basename"
>   
>   	gdb_test_no_output "set filename-display relative"
>   	verbose -log "expect: $filename"
> -	gdb_test "frame" "#0  $func \\(\\) at [string_to_regexp $filename]:999" "relative"
> +	gdb_test "frame" " in $func \\(\\) at [string_to_regexp $filename]:999" "relative"
>       }
>   }
>   
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 17523f82996..2f1147159ad 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -787,14 +787,9 @@ proc gdb_continue_to_breakpoint {name {location_pattern .*}} {
>       global gdb_prompt
>       set full_name "continue to breakpoint: $name"
>   
> -    set re_at_in " (at|in) "
> -    if { [regexp $re_at_in $location_pattern] } {
> -	set re_at_in " "
> -    }
> -
>       set kfail_pattern "Process record does not support instruction 0xfae64 at.*"
>       gdb_test_multiple "continue" $full_name {
> -	-re "(?:Breakpoint|Temporary breakpoint) .*$re_at_in$location_pattern\r\n$gdb_prompt $" {
> +	-re "(?:Breakpoint|Temporary breakpoint) .* (at|in) $location_pattern\r\n$gdb_prompt $" {
>   	    pass $full_name
>   	}
>   	-re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" {

Looks like this makes the testsuite go from PASS to FAIL for aarch64. Are we still stopping in the first instruction and ignoring prologues?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] [gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp for ppc64le
  2022-09-12 10:20   ` Luis Machado
@ 2022-09-13 14:55     ` Tom de Vries
  0 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2022-09-13 14:55 UTC (permalink / raw)
  To: Luis Machado, gdb-patches

On 9/12/22 12:20, Luis Machado wrote:
> On 9/1/22 15:09, Tom de Vries via Gdb-patches wrote:
>> In commit cd919f5533c ("[gdb/testsuite] Fix
>> gdb.dwarf2/dw2-dir-file-name.exp"), I made 
>> gdb.dwarf2/dw2-dir-file-name.exp
>> independent of prologue analyzers, using this change:
>> ...
>> -       gdb_breakpoint $func
>> +       gdb_breakpoint *$func
>> ...
>>
>> That however caused a regression on ppc64le.  For PowerPC, as 
>> described in the
>> ELFv2 ABI, a function can have a global and local entry point.
>>
>> Setting a breakpoint on *$func effectively creates a breakpoint for 
>> the global
>> entry point, so if the function is entered through the local entry 
>> point, the
>> breakpoint doesn't trigger.
>>
>> Fix this by reverting commit cd919f5533c, and setting the breakpoint on
>> ${func}_label instead.
>>
>> Tested on x86_64-linux and ppc64le-linux.
>> ---
>>   gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp | 8 ++++----
>>   gdb/testsuite/lib/gdb.exp                      | 7 +------
>>   2 files changed, 5 insertions(+), 10 deletions(-)
>>
>> diff --git a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp 
>> b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
>> index 08b5c645fa2..053f7229537 100644
>> --- a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
>> +++ b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
>> @@ -450,20 +450,20 @@ proc test { func compdir filename } {
>>           error "not absolute"
>>       }
>> -    gdb_breakpoint *$func
>> +    gdb_breakpoint ${func}_label
>>       gdb_continue_to_breakpoint $func "$func \\(\\) at .*"
>>       gdb_test_no_output "set filename-display absolute"
>>       verbose -log "expect: ${absolute}"
>> -    gdb_test "frame" "#0  $func \\(\\) at [string_to_regexp 
>> ${absolute}]:999" "absolute"
>> +    gdb_test "frame" " in $func \\(\\) at [string_to_regexp 
>> ${absolute}]:999" "absolute"
>>       gdb_test_no_output "set filename-display basename"
>>       verbose -log "expect: [file tail $filename]"
>> -    gdb_test "frame" "#0  $func \\(\\) at [string_to_regexp [file 
>> tail $filename]]:999" "basename"
>> +    gdb_test "frame" " in $func \\(\\) at [string_to_regexp [file 
>> tail $filename]]:999" "basename"
>>       gdb_test_no_output "set filename-display relative"
>>       verbose -log "expect: $filename"
>> -    gdb_test "frame" "#0  $func \\(\\) at [string_to_regexp 
>> $filename]:999" "relative"
>> +    gdb_test "frame" " in $func \\(\\) at [string_to_regexp 
>> $filename]:999" "relative"
>>       }
>>   }
>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>> index 17523f82996..2f1147159ad 100644
>> --- a/gdb/testsuite/lib/gdb.exp
>> +++ b/gdb/testsuite/lib/gdb.exp
>> @@ -787,14 +787,9 @@ proc gdb_continue_to_breakpoint {name 
>> {location_pattern .*}} {
>>       global gdb_prompt
>>       set full_name "continue to breakpoint: $name"
>> -    set re_at_in " (at|in) "
>> -    if { [regexp $re_at_in $location_pattern] } {
>> -    set re_at_in " "
>> -    }
>> -
>>       set kfail_pattern "Process record does not support instruction 
>> 0xfae64 at.*"
>>       gdb_test_multiple "continue" $full_name {
>> -    -re "(?:Breakpoint|Temporary breakpoint) 
>> .*$re_at_in$location_pattern\r\n$gdb_prompt $" {
>> +    -re "(?:Breakpoint|Temporary breakpoint) .* (at|in) 
>> $location_pattern\r\n$gdb_prompt $" {
>>           pass $full_name
>>       }
>>       -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" {
> 
> Looks like this makes the testsuite go from PASS to FAIL for aarch64. 
> Are we still stopping in the first instruction and ignoring prologues?

No, we're stopping at the correct instruction, but whether the 
breakpoint is printed with or without instruction address is dependent 
on whether there is a prologue or not, which is an artefact of having a 
rudimentary line table.

I've proposed a fix here ( 
https://sourceware.org/pipermail/gdb-patches/2022-September/191829.html 
), which adds an extra entry in the line table, such that we'll always 
print without instruction address.

Thanks,
- Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-13 14:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-01 14:09 [PATCH 1/2] [gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp with clang Tom de Vries
2022-09-01 14:09 ` [PATCH 2/2] [gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp for ppc64le Tom de Vries
2022-09-12 10:20   ` Luis Machado
2022-09-13 14:55     ` 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).