Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH][gdb/testsuite] Generate .debug_aranges entry for dummy CU
@ 2021-08-26 11:58 Tom de Vries via Gdb-patches
  2021-08-27 13:42 ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Tom de Vries via Gdb-patches @ 2021-08-26 11:58 UTC (permalink / raw)
  To: gdb-patches

Hi,

A best practise for DWARF [1] is to generate .debug_aranges entries for CUs
even if they have no address range.

Generate .debug_arange entries for the dummy CUs added by the DWARF assembler.

Tested on x86_64-linux.

[1] http://wiki.dwarfstd.org/index.php?title=Best_Practices

Any comments?

Thanks,
- Tom

[gdb/testsuite] Generate .debug_aranges entry for dummy CU

---
 gdb/testsuite/lib/dwarf.exp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 32b110b3f3e..02cb4db729c 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -2436,8 +2436,14 @@ namespace eval Dwarf {
 
     # Emit a dummy CU.
     proc dummy_cu {} {
+	declare_labels dummy_cu
+
 	# Generate a CU with default options and empty body.
-	cu {} {
+	cu {label dummy_cu} {
+	}
+
+	# Generate an .debug_aranges entry for the dummy CU.
+	aranges {} dummy_cu {
 	}
     }
 

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

* Re: [PATCH][gdb/testsuite] Generate .debug_aranges entry for dummy CU
  2021-08-26 11:58 [PATCH][gdb/testsuite] Generate .debug_aranges entry for dummy CU Tom de Vries via Gdb-patches
@ 2021-08-27 13:42 ` Tom Tromey
  2021-08-27 14:52   ` Tom de Vries via Gdb-patches
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2021-08-27 13:42 UTC (permalink / raw)
  To: Tom de Vries via Gdb-patches

>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> A best practise for DWARF [1] is to generate .debug_aranges entries for CUs
Tom> even if they have no address range.

Tom> Generate .debug_arange entries for the dummy CUs added by the DWARF assembler.

Tom> Tested on x86_64-linux.

Tom> [1] http://wiki.dwarfstd.org/index.php?title=Best_Practices

Tom> Any comments?

Tom> +	declare_labels dummy_cu

If there are two dummy CUs, won't the labels clash?

Tom

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

* Re: [PATCH][gdb/testsuite] Generate .debug_aranges entry for dummy CU
  2021-08-27 13:42 ` Tom Tromey
@ 2021-08-27 14:52   ` Tom de Vries via Gdb-patches
  2021-08-27 16:40     ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Tom de Vries via Gdb-patches @ 2021-08-27 14:52 UTC (permalink / raw)
  To: Tom Tromey, Tom de Vries via Gdb-patches

On 8/27/21 3:42 PM, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Tom> A best practise for DWARF [1] is to generate .debug_aranges entries for CUs
> Tom> even if they have no address range.
> 
> Tom> Generate .debug_arange entries for the dummy CUs added by the DWARF assembler.
> 
> Tom> Tested on x86_64-linux.
> 
> Tom> [1] http://wiki.dwarfstd.org/index.php?title=Best_Practices
> 
> Tom> Any comments?
> 
> Tom> +	declare_labels dummy_cu
> 

[ FWIW, with the committed "[gdb/testsuite] Add label option to proc cu"
there's also no longer a need for declare_labels. ]

> If there are two dummy CUs, won't the labels clash?

No, due to the way cu labels are defined in "[gdb/testsuite] Add label
option to proc cu".

So, for say test-case gdb.dwarf2/dw2-ranges-base.exp we have these
references:
...
$ grep "Offset" outputs/gdb.dwarf2/dw2-ranges-base/dw2-ranges-base-dw.S
        .4byte        .Lcu0_begin       /* Offset into .debug_info */
        .4byte        .Lcu1_begin       /* Offset into .debug_info */
        .4byte        .Lcu2_begin       /* Offset into .debug_info */
...
where .Lcu0_begin is a dummy CU, .Lcu1_begin is the one specified by the
.exp file and .Lcu2_begin is another dummy CU.

Thanks,
- Tom

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

* Re: [PATCH][gdb/testsuite] Generate .debug_aranges entry for dummy CU
  2021-08-27 14:52   ` Tom de Vries via Gdb-patches
@ 2021-08-27 16:40     ` Tom Tromey
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2021-08-27 16:40 UTC (permalink / raw)
  To: Tom de Vries; +Cc: Tom Tromey, Tom de Vries via Gdb-patches

Tom> No, due to the way cu labels are defined in "[gdb/testsuite] Add label
Tom> option to proc cu".

Oh yeah, I forgot how define_label worked.
Sorry about that!  The patch looked good to me.

Tom

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

end of thread, other threads:[~2021-08-27 16:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26 11:58 [PATCH][gdb/testsuite] Generate .debug_aranges entry for dummy CU Tom de Vries via Gdb-patches
2021-08-27 13:42 ` Tom Tromey
2021-08-27 14:52   ` Tom de Vries via Gdb-patches
2021-08-27 16:40     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox