From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH][gdb/testsuite] Add share_abbrev option to cu in dwarf assembler
Date: Thu, 5 Nov 2020 17:39:39 +0100 [thread overview]
Message-ID: <20201105163938.GA26291@delia> (raw)
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
next reply other threads:[~2020-11-05 16:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 16:39 Tom de Vries [this message]
2020-11-10 18:47 ` Simon Marchi
2020-11-10 18:59 ` Simon Marchi
2020-11-10 19:01 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201105163938.GA26291@delia \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox