public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Zoran Zaric <Zoran.Zaric@amd.com>,
	Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 09/13] gdb/testsuite: DWARF assembler: add context parameters to _location
Date: Wed, 20 Jan 2021 00:39:21 -0500	[thread overview]
Message-ID: <20210120053925.142862-10-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20210120053925.142862-1-simon.marchi@polymtl.ca>

From: Simon Marchi <simon.marchi@efficios.com>

The _location proc is used to assemble a location description.  It needs
to know some contextual information:

- size of an address
- size of an offset (into another DWARF section)
- DWARF version

It currently get all this directly from global variables holding the
compilation unit information.  This is fine because as of now, all
location descriptions are generated in the context of creating a
compilation unit.  However, a subsequent patch will generate location
descriptions while generating a .debug_loclists section.  _location
should therefore no longer rely on the current compilation unit's
properties.

Change it to accept these values as parameters instead of accessing the
values for the CU.

No functional changes intended.

gdb/testsuite/ChangeLog:

	* lib/dwarf.exp (_location): Add parameters.
	(_handle_DW_FORM): Adjust.

Change-Id: Ib94981979c83ffbebac838081d645ad71c221637
---
 gdb/testsuite/lib/dwarf.exp | 40 +++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 13 deletions(-)

diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index aba4afba2249..f4f1cab05e68 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -515,11 +515,15 @@ namespace eval Dwarf {
 	    }
 
 	    SPECIAL_expr {
+		variable _cu_version
+		variable _cu_addr_size
+		variable _cu_offset_size
+
 		set l1 [new_label "expr_start"]
 		set l2 [new_label "expr_end"]
 		_op .uleb128 "$l2 - $l1" "expression"
 		define_label $l1
-		_location $value
+		_location $value $_cu_version $_cu_addr_size $_cu_offset_size
 		define_label $l2
 	    }
 
@@ -889,18 +893,28 @@ namespace eval Dwarf {
     # This is a miniature assembler for location expressions.  It is
     # suitable for use in the attributes to a DIE.  Its output is
     # prefixed with "=" to make it automatically use DW_FORM_block.
+    #
     # BODY is split by lines, and each line is taken to be a list.
+    #
+    # DWARF_VERSION is the DWARF version for the section where the location
+    # description is found.
+    #
+    # ADDR_SIZE is the length in bytes (4 or 8) of an address on the target
+    # machine (typically found in the header of the section where the location
+    # description is found).
+    #
+    # OFFSET_SIZE is the length in bytes (4 or 8) of an offset into a DWARF
+    # section.  This typically depends on whether 32-bit or 64-bit DWARF is
+    # used, as indicated in the header of the section where the location
+    # description is found.
+    #
     # (FIXME should use 'info complete' here.)
     # Each list's first element is the opcode, either short or long
     # forms are accepted.
     # FIXME argument handling
     # FIXME move docs
-    proc _location {body} {
+    proc _location { body dwarf_version addr_size offset_size } {
 	variable _constants
-	variable _cu_label
-	variable _cu_version
-	variable _cu_addr_size
-	variable _cu_offset_size
 
 	foreach line [split $body \n] {
 	    # Ignore blank lines, and allow embedded comments.
@@ -912,7 +926,7 @@ namespace eval Dwarf {
 
 	    switch -exact -- $opcode {
 		DW_OP_addr {
-		    _op .${_cu_addr_size}byte [lindex $line 1]
+		    _op .${addr_size}byte [lindex $line 1]
 		}
 
 		DW_OP_regx {
@@ -992,10 +1006,10 @@ namespace eval Dwarf {
 
 		    # Here label is a section offset.
 		    set label [lindex $line 1]
-		    if { $_cu_version == 2 } {
-			_op .${_cu_addr_size}byte $label
+		    if { $dwarf_version == 2 } {
+			_op .${addr_size}byte $label
 		    } else {
-			_op .${_cu_offset_size}byte $label
+			_op .${offset_size}byte $label
 		    }
 		    _op .sleb128 [lindex $line 2]
 		}
@@ -1007,10 +1021,10 @@ namespace eval Dwarf {
 
 		    # Here label is a section offset.
 		    set label [lindex $line 1]
-		    if { $_cu_version == 2 } {
-			_op .${_cu_addr_size}byte $label
+		    if { $dwarf_version == 2 } {
+			_op .${addr_size}byte $label
 		    } else {
-			_op .${_cu_offset_size}byte $label
+			_op .${offset_size}byte $label
 		    }
 		}
 
-- 
2.30.0


  parent reply	other threads:[~2021-01-20  5:41 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20  5:39 [PATCH 00/13] DWARF 5 rnglists & loclists fixes (PR 26813) Simon Marchi
2021-01-20  5:39 ` [PATCH 01/13] gdb/dwarf: change read_loclist_index complaints into errors Simon Marchi
2021-01-28 15:17   ` Zoran Zaric
2021-01-28 15:42     ` Simon Marchi
2021-02-25 19:20       ` Tom Tromey
2021-01-20  5:39 ` [PATCH 02/13] gdb/dwarf: fix bound check in read_rnglist_index Simon Marchi
2021-01-28 15:22   ` Zoran Zaric
2021-01-20  5:39 ` [PATCH 03/13] gdb/dwarf: add missing bound check to read_loclist_index Simon Marchi
2021-01-20  5:39 ` [PATCH 04/13] gdb/dwarf: remove unnecessary check in read_{rng, loc}list_index Simon Marchi
2021-01-20  5:39 ` [PATCH 05/13] gdb/dwarf: few fixes for handling DW_FORM_{rng, loc}listx Simon Marchi
2021-01-28 15:30   ` [PATCH 05/13] gdb/dwarf: few fixes for handling DW_FORM_{rng,loc}listx Zoran Zaric
2021-01-20  5:39 ` [PATCH 06/13] gdb/dwarf: read correct rnglist/loclist header in read_{rng, loc}list_index Simon Marchi
2021-01-28 15:39   ` [PATCH 06/13] gdb/dwarf: read correct rnglist/loclist header in read_{rng,loc}list_index Zoran Zaric
2021-01-28 15:49     ` Simon Marchi
2021-01-28 15:54       ` Zoran Zaric
2021-01-20  5:39 ` [PATCH 07/13] gdb/dwarf: read DW_AT_ranges value as unsigned in partial_die_info::read Simon Marchi
2021-01-28 15:41   ` Zoran Zaric
2021-01-28 15:51     ` Simon Marchi
2021-01-20  5:39 ` [PATCH 08/13] gdb/testsuite: add .debug_rnglists tests Simon Marchi
2021-01-28 16:24   ` Zoran Zaric
2021-01-20  5:39 ` Simon Marchi [this message]
2021-01-28 16:30   ` [PATCH 09/13] gdb/testsuite: DWARF assembler: add context parameters to _location Zoran Zaric
2021-01-20  5:39 ` [PATCH 10/13] gdb/testsuite: add .debug_loclists tests Simon Marchi
2021-01-28 16:52   ` Zoran Zaric
2021-01-28 17:47     ` Simon Marchi
2021-01-29 10:13       ` Zoran Zaric
2021-01-29 15:57         ` Simon Marchi
2021-01-29 16:58           ` Zoran Zaric
2021-01-29 17:37             ` Simon Marchi
2021-01-20  5:39 ` [PATCH 11/13] gdb/dwarf: split dwarf2_cu::ranges_base in two Simon Marchi
2021-01-20  5:39 ` [PATCH 12/13] gdb/dwarf: make read_{loc, rng}list_index return sect_offset Simon Marchi
2021-02-25 19:26   ` Tom Tromey
2021-01-20  5:39 ` [PATCH 13/13] gdb/testsuite: add test for .debug_{rng, loc}lists section without offset array Simon Marchi
2021-02-02 15:43 ` [PATCH 00/13] DWARF 5 rnglists & loclists fixes (PR 26813) Simon Marchi

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=20210120053925.142862-10-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=Zoran.Zaric@amd.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).