Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [PATCH][gdb/testsuite] Add label option to proc cu
Date: Thu, 26 Aug 2021 13:56:07 +0200	[thread overview]
Message-ID: <20210826115605.GA22680@delia> (raw)

Hi,

We can use current dwarf assembly infrastructure to declare a label that marks
the start of the CU header:
...
  declare_labels header_start_cu_a
  _section ".debug_info"
  header_start_cu_a : cu {} {
  }
  _section ".debug_info"
  header_start_cu_b : cu {} {
  }
...
on the condition that we switch to the .debug_info section before, which makes
this style of use fragile.

Another way to achieve the same is to use the label as generated by the cu
proc itself:
...
  variable _cu_label
  cu {} {
  }
  set header_start_cu_a $_cu_label
  cu {} {
  }
  set header_start_cu_b $_cu_label
...
but again that seems fragile given that adding a new CU inbetween will
silently result in the wrong value for the label.

Add a label option to proc cu such that we can simply do:
...
  declare_labels header_start_cu_a
  cu { label header_start_cu_a } {
  }
  cu { label header_start_cu_b } {
  }
...

Tested on x86_64-linux.

Any comments?

Thanks,
- Tom

[gdb/testsuite] Add label option to proc cu

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

diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index ce7b5983ab9..8dda798ddf8 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -1258,6 +1258,10 @@ namespace eval Dwarf {
     #                default = default
     # fission 0|1  - boolean indicating if generating Fission debug info
     #                default = 0
+    # label <label>
+    #              - string indicating label to be defined at the start
+    #                of the CU header.
+    #                default = ""
     # 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} {
@@ -1278,6 +1282,7 @@ namespace eval Dwarf {
 	set _cu_is_fission 0
 	set section ".debug_info"
 	set _abbrev_section ".debug_abbrev"
+	set label ""
 
 	foreach { name value } $options {
 	    set value [uplevel 1 "subst \"$value\""]
@@ -1286,6 +1291,7 @@ namespace eval Dwarf {
 		version { set _cu_version $value }
 		addr_size { set _cu_addr_size $value }
 		fission { set _cu_is_fission $value }
+		label { set label $value }
 		default { error "unknown option $name" }
 	    }
 	}
@@ -1309,6 +1315,9 @@ namespace eval Dwarf {
 	}
 
 	_section $section
+	if { $label != "" } {
+	    $label:
+	}
 
 	set cu_num [incr _cu_count]
 	set my_abbrevs [_compute_label "abbrev${cu_num}_begin"]

             reply	other threads:[~2021-08-26 11:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 11:56 Tom de Vries via Gdb-patches [this message]
2021-08-26 13:38 ` Simon Marchi via Gdb-patches
2021-08-26 15:16   ` Tom de Vries via Gdb-patches
2021-08-27 13:24     ` Tom Tromey
2021-08-27 14:13       ` Tom de Vries via Gdb-patches

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=20210826115605.GA22680@delia \
    --to=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    /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