Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH][gdb/testsuite] Add share_abbrev option to cu in dwarf assembler
@ 2020-11-05 16:39 Tom de Vries
  2020-11-10 18:47 ` Simon Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Tom de Vries @ 2020-11-05 16:39 UTC (permalink / raw)
  To: gdb-patches

Hi,

This adds a share_abbrev option in the dwarf assembler, such that
different CUs can share a single abbrev table, like so:
...
cu { share_abbrev first } { ... }
cu { share_abbrev 1 } { ... }
cu { share_abbrev 1 } { ... }
cu { share_abbrev last } { ... }
...

Tested by adding share_abbrev first/last to the two CUs in
gdb.dwarf2/imported-unit.exp.

Any comments?

Thanks,
- Tom

[gdb/testsuite] Add share_abbrev option to cu in dwarf assembler

gdb/testsuite/ChangeLog:

2020-11-05  Tom de Vries  <tdevries@suse.de>

	* lib/dwarf.exp (Dwarf::_abbrev_label): New var.
	(cu): Add share_abbrev option.

---
 gdb/testsuite/lib/dwarf.exp | 42 ++++++++++++++++++++++++++++++++++--------
 1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index c585621ac4..40d0648826 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -310,6 +310,10 @@ namespace eval Dwarf {
     # table.
     variable _abbrev_num
 
+    # The label used for the current CU's abbrev table.  This may be shared
+    # between CUs.
+    variable _abbrev_label
+
     # The string table for this assembly.  The key is the string; the
     # value is the label for that string.
     variable _strings
@@ -1039,6 +1043,11 @@ namespace eval Dwarf {
     #                default = default
     # fission 0|1  - boolean indicating if generating Fission debug info
     #                default = 0
+    # share_abbrev 0|first|1|last
+    #              - non-zero indicating that a series of CUs shares the same
+    #                abbrev table.  The first and last in the series are marked
+    #                using first and last.
+    #                default = 0
     # BODY is Tcl code that emits the DIEs which make up the body of
     # the CU.  It is evaluated in the caller's context.
     proc cu {options body} {
@@ -1049,12 +1058,14 @@ namespace eval Dwarf {
 	variable _cu_version
 	variable _cu_addr_size
 	variable _cu_offset_size
+	variable _abbrev_label
 
 	# Establish the defaults.
 	set is_64 0
 	set _cu_version 4
 	set _cu_addr_size default
 	set fission 0
+	set share_abbrev 0
 	set section ".debug_info"
 	set _abbrev_section ".debug_abbrev"
 
@@ -1065,6 +1076,7 @@ namespace eval Dwarf {
 		version { set _cu_version $value }
 		addr_size { set _cu_addr_size $value }
 		fission { set fission $value }
+		share_abbrev { set share_abbrev $value }
 		default { error "unknown option $name" }
 	    }
 	}
@@ -1084,8 +1096,18 @@ namespace eval Dwarf {
 	_section $section
 
 	set cu_num [incr _cu_count]
-	set my_abbrevs [_compute_label "abbrev${cu_num}_begin"]
-	set _abbrev_num 1
+
+	set init_abbrev \
+	    [expr [string equal $share_abbrev 0] \
+		 || [string equal $share_abbrev first]]
+	set finish_abbrev \
+	    [expr [string equal $share_abbrev 0] \
+		 || [string equal $share_abbrev last]]
+
+	if { $init_abbrev } {
+	    set _abbrev_label [_compute_label "abbrev${cu_num}_begin"]
+	    set _abbrev_num 1
+	}
 
 	set _cu_label [_compute_label "cu${cu_num}_begin"]
 	set start_label [_compute_label "cu${cu_num}_start"]
@@ -1100,18 +1122,22 @@ namespace eval Dwarf {
 	}
 	define_label $start_label
 	_op .2byte $_cu_version Version
-	_op .${_cu_offset_size}byte $my_abbrevs Abbrevs
+	_op .${_cu_offset_size}byte $_abbrev_label Abbrevs
 	_op .byte $_cu_addr_size "Pointer size"
 
-	_defer_output $_abbrev_section {
-	    define_label $my_abbrevs
+	if { $init_abbrev } {
+	    _defer_output $_abbrev_section {
+		define_label $_abbrev_label
+	    }
 	}
 
 	uplevel $body
 
-	_defer_output $_abbrev_section {
-	    # Emit the terminator.
-	    _op .byte 0x0 "Abbrev end - Terminator"
+	if { $finish_abbrev } {
+	    _defer_output $_abbrev_section {
+		# Emit the terminator.
+		_op .byte 0x0 "Abbrev end - Terminator"
+	    }
 	}
 
 	define_label $end_label

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

* Re: [PATCH][gdb/testsuite] Add share_abbrev option to cu in dwarf assembler
  2020-11-05 16:39 [PATCH][gdb/testsuite] Add share_abbrev option to cu in dwarf assembler Tom de Vries
@ 2020-11-10 18:47 ` Simon Marchi
  2020-11-10 18:59   ` Simon Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Marchi @ 2020-11-10 18:47 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches


On 2020-11-05 11:39 a.m., Tom de Vries wrote:
> Hi,
>
> This adds a share_abbrev option in the dwarf assembler, such that
> different CUs can share a single abbrev table, like so:
> ...
> cu { share_abbrev first } { ... }
> cu { share_abbrev 1 } { ... }
> cu { share_abbrev 1 } { ... }
> cu { share_abbrev last } { ... }
> ...
>
> Tested by adding share_abbrev first/last to the two CUs in
> gdb.dwarf2/imported-unit.exp.
>
> Any comments?

No comments, other than I'm curious what's the end goal of this.  You
have a bug to reproduce that requires it?

Simon

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

* Re: [PATCH][gdb/testsuite] Add share_abbrev option to cu in dwarf assembler
  2020-11-10 18:47 ` Simon Marchi
@ 2020-11-10 18:59   ` Simon Marchi
  2020-11-10 19:01     ` Tom de Vries
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Marchi @ 2020-11-10 18:59 UTC (permalink / raw)
  To: Tom de Vries, gdb-patches

On 2020-11-10 1:47 p.m., Simon Marchi wrote:
> No comments, other than I'm curious what's the end goal of this.  You
> have a bug to reproduce that requires it?
> 
> Simon

Ok, I see the other patches you sent shortly after:

[PATCH][gdb/testsuite] Make fission use shared_abbrev in dwarf assembler
[PATCH][gdb/testsuite] Handle multiple sources in build_executable_from_fission_assembler
[PATCH][gdb/testsuite] Add gdb.dwarf2/fission-multi-cu-clang.exp

Are they intended to be a series?

Simon

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

* Re: [PATCH][gdb/testsuite] Add share_abbrev option to cu in dwarf assembler
  2020-11-10 18:59   ` Simon Marchi
@ 2020-11-10 19:01     ` Tom de Vries
  0 siblings, 0 replies; 4+ messages in thread
From: Tom de Vries @ 2020-11-10 19:01 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 11/10/20 7:59 PM, Simon Marchi wrote:
> On 2020-11-10 1:47 p.m., Simon Marchi wrote:
>> No comments, other than I'm curious what's the end goal of this.  You
>> have a bug to reproduce that requires it?
>>
>> Simon
> 
> Ok, I see the other patches you sent shortly after:
> 
> [PATCH][gdb/testsuite] Make fission use shared_abbrev in dwarf assembler
> [PATCH][gdb/testsuite] Handle multiple sources in build_executable_from_fission_assembler
> [PATCH][gdb/testsuite] Add gdb.dwarf2/fission-multi-cu-clang.exp
> 
> Are they intended to be a series?

Yes, they are.

Thanks,
- Tom

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

end of thread, other threads:[~2020-11-10 19:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05 16:39 [PATCH][gdb/testsuite] Add share_abbrev option to cu in dwarf assembler Tom de Vries
2020-11-10 18:47 ` Simon Marchi
2020-11-10 18:59   ` Simon Marchi
2020-11-10 19:01     ` 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