From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/testsuite] Add .debug_loc support in dwarf assembler
Date: Thu, 14 Oct 2021 09:32:12 -0400 [thread overview]
Message-ID: <0316a868-cb5e-37e3-0040-d64d1acaf521@polymtl.ca> (raw)
In-Reply-To: <20211014123315.GA22867@delia.home>
> diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
> index 66f9844fe2e..a15eacfb46c 100644
> --- a/gdb/testsuite/lib/dwarf.exp
> +++ b/gdb/testsuite/lib/dwarf.exp
> @@ -2369,6 +2369,102 @@ namespace eval Dwarf {
> aranges_end:
> }
>
> + # Emit a .debug_loc entry.
> +
> + proc loc_entry { start end location_description } {
> + # Determine how to emit addresses.
> + variable _addr_size
> + if { $_addr_size == 8 } {
> + set addr_op .8byte
> + } elseif { $_addr_size == 4 } {
> + set addr_op .4byte
> + }
> +
> + # Emit start and end address.
> + _op $addr_op $start "Start address"
> + _op $addr_op $end "End address"
> +
> + declare_labels location_description_start
> + declare_labels location_description_end
> +
> + # Emit length of location description.
> + set len "$location_description_end - $location_description_start"
> + _op .2byte $len "Location description length"
> +
> + # Tag start of location description.
> + define_label $location_description_start
> +
> + # Emit location description.
> + variable _cu_version
> + variable _cu_offset_size
> + _location $location_description $_cu_version $_addr_size \
> + $_cu_offset_size
> +
> + # Tag end of location description.
> + define_label $location_description_end
> + }
> +
> + # Emit a DWARF .debug_loc contribution.
> + #
> + # OPTIONS is a list with an even number of elements containing
> + # option-name and option-value pairs.
> + # Current options are:
> + # cu_is_64 0|1 - boolean indicating if references from location
> + # descriptions refer to a 64-bit DWARF CU.
> + # default = 0 (32-bit)
> + # cu_version n - section version of DWARF CU referenced from location
> + # descriptions.
> + # default = 4
> + #
> + # BODY is Tcl code that emits the parts which make up the body of
> + # the debug_loc contribution. It is evaluated in the caller's context.
> + # The following command is available for the BODY section:
> + #
> + # loc_entry <start> <end> <location description>
> + # -- emit a .debug_loc entry
> +
> + proc loc { options body } {
I would suggest using the same trick as used for rnglists: rename
loc_entry to _loc_entry (or something like that, to show it's
internal). And use:
with_override Dwarf::entry Dwarf::_loc_entry {
uplevel $body
}
Users would then look like:
loc { ... } {
entry 0x123 0x456 {
...
}
}
I think that looks good: because you are in the "loc" context, it is
obvious enough that entry is a location list entry. I think that makes
it easy to write.
I would have suggested renaming "loc" to "loclist", because this is
actually generating a "location list", according to the standard. But
that might become confusing with the DWARF5 "loclists"...
But other than that, the patch LGTM.
Simon
next prev parent reply other threads:[~2021-10-14 13:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-14 12:33 Tom de Vries via Gdb-patches
2021-10-14 13:32 ` Simon Marchi via Gdb-patches [this message]
2021-10-14 15:02 ` 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=0316a868-cb5e-37e3-0040-d64d1acaf521@polymtl.ca \
--to=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
--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