Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 04/13] Use gdb_bfd_sections in get_stap_base_address
Date: Fri, 28 Aug 2020 13:06:41 -0400	[thread overview]
Message-ID: <5f794d12-c1a7-4cb5-68a8-1bb76fff3d1c@simark.ca> (raw)
In-Reply-To: <20200828162349.987-5-tom@tromey.com>

On 2020-08-28 12:23 p.m., Tom Tromey wrote:
> This changes get_stap_base_address to avoid bfd_map_over_sections, in
> favor of iteration.
> 
> gdb/ChangeLog
> 2020-08-28  Tom Tromey  <tom@tromey.com>
> 
> 	* stap-probe.c (get_stap_base_address_1): Remove.
> 	(get_stap_base_address): Use foreach.
> ---
>  gdb/ChangeLog    |  5 +++++
>  gdb/stap-probe.c | 20 ++++++--------------
>  2 files changed, 11 insertions(+), 14 deletions(-)
> 
> diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
> index 73596446cce..fb6010d14ff 100644
> --- a/gdb/stap-probe.c
> +++ b/gdb/stap-probe.c
> @@ -1578,19 +1578,6 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
>    probesp->emplace_back (ret);
>  }
>  
> -/* Helper function which tries to find the base address of the SystemTap
> -   base section named STAP_BASE_SECTION_NAME.  */
> -
> -static void
> -get_stap_base_address_1 (bfd *abfd, asection *sect, void *obj)
> -{
> -  asection **ret = (asection **) obj;
> -
> -  if ((sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS))
> -      && sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME))
> -    *ret = sect;
> -}
> -
>  /* Helper function which iterates over every section in the BFD file,
>     trying to find the base address of the SystemTap base section.
>     Returns 1 if found (setting BASE to the proper value), zero otherwise.  */
> @@ -1600,7 +1587,12 @@ get_stap_base_address (bfd *obfd, bfd_vma *base)
>  {
>    asection *ret = NULL;
>  
> -  bfd_map_over_sections (obfd, get_stap_base_address_1, (void *) &ret);
> +  for (asection *sect : gdb_bfd_sections (obfd))
> +    {
> +      if ((sect->flags & (SEC_DATA | SEC_ALLOC | SEC_HAS_CONTENTS))
> +	  && sect->name && !strcmp (sect->name, STAP_BASE_SECTION_NAME))
> +	ret = sect;
> +    }

This is where I meant to say:

FYI: I've been taught by Pedro [1] that we don't actually need curly braces in this case,
and I've been misleading people about this for a while .  For future code I write like
this, I won't use the curly braces.

[1] https://sourceware.org/pipermail/gdb-patches/2020-August/171532.html

Simon



  reply	other threads:[~2020-08-28 17:06 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-28 16:23 [PATCH 00/13] Use gdb_bfd_sections in more places Tom Tromey
2020-08-28 16:23 ` [PATCH 01/13] Add a new overload of gdb_bfd_sections Tom Tromey
2020-08-28 16:34   ` Simon Marchi
2020-08-28 19:25     ` Tom Tromey
2020-08-28 16:23 ` [PATCH 02/13] Use gdb_bfd_sections in core_target_open Tom Tromey
2020-08-28 16:23 ` [PATCH 03/13] Use gdb_bfd_sections in gdb_bfd_close_or_warn Tom Tromey
2020-08-28 16:23 ` [PATCH 04/13] Use gdb_bfd_sections in get_stap_base_address Tom Tromey
2020-08-28 17:06   ` Simon Marchi [this message]
2020-08-28 16:23 ` [PATCH 05/13] Use gdb_bfd_sections in build_objfile_section_table Tom Tromey
2020-08-28 16:23 ` [PATCH 06/13] Use gdb_bfd_sections in symfile.c Tom Tromey
2020-08-28 17:00   ` Simon Marchi
2020-08-28 17:06     ` Simon Marchi
2020-08-28 16:23 ` [PATCH 07/13] Use gdb_bfd_sections in dwarf2/read.c Tom Tromey
2020-08-28 16:23 ` [PATCH 08/13] Use gdb_bfd_sections in ELF osabi tag sniffing Tom Tromey
2020-08-28 16:23 ` [PATCH 09/13] Use gdb_bfd_sections in gcore_memory_sections Tom Tromey
2020-08-28 16:23 ` [PATCH 10/13] Use gdb_bfd_sections in restore_command Tom Tromey
2020-08-28 17:12   ` Simon Marchi
2020-08-29 15:47     ` Tom Tromey
2020-08-29 15:49       ` Simon Marchi
2020-08-28 16:23 ` [PATCH 11/13] Use gdb_bfd_sections in elf_symfile_read Tom Tromey
2020-08-28 16:23 ` [PATCH 12/13] Use gdb_bfd_sections in build_section_table Tom Tromey
2020-08-28 16:23 ` [PATCH 13/13] Use gdb_bfd_sections in generic_load Tom Tromey
2020-08-28 17:14 ` [PATCH 00/13] Use gdb_bfd_sections in more places Simon Marchi
2020-08-31 18:19 ` John Baldwin
2020-09-19 18:07 ` Tom Tromey

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=5f794d12-c1a7-4cb5-68a8-1bb76fff3d1c@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.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