public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Tom de Vries <tdevries@suse.de>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/4] [gdb/symtab] Fix htab_find_slot call in read_call_site_scope
Date: Fri, 1 Oct 2021 09:09:59 -0400	[thread overview]
Message-ID: <113a7cab-f06b-32ad-caa1-b0c87e67335b@polymtl.ca> (raw)
In-Reply-To: <20211001123328.22314-1-tdevries@suse.de>



On 2021-10-01 08:33, Tom de Vries via Gdb-patches wrote:
> From: Simon Marchi <simon.marchi@polymtl.ca>
> 
> In read_call_site_scope we have:
> ...
>   call_site_local.pc = pc;
>   slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT);
> ...
> 
> The call passes a call_site pointer as element.  OTOH, the hashtab is created
> using hash_f == core_addr_hash and eq_f == core_addr_eq, so the element
> will be accessed through a CORE_ADDR pointer.
> 
> This is not wrong (at least in C), given that pc is the first field in
> call_site.
> 
> Nevertheless, as in call_site_for_pc, make the htab_find_slot call match the
> used hash_f and eq_f by using &pc instead:
> ...
>   slot = htab_find_slot (cu->call_site_htab, &pc, INSERT);
> ...
> 
> Tested on x86_64-linux.
> 
> Co-Authored-By: Tom de Vries <tdevries@suse.de>
> ---
>  gdb/dwarf2/read.c | 5 ++---
>  gdb/gdbtypes.h    | 4 +---
>  2 files changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
> index 00aa64dd0ab..23870c04e74 100644
> --- a/gdb/dwarf2/read.c
> +++ b/gdb/dwarf2/read.c
> @@ -13341,7 +13341,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
>    struct gdbarch *gdbarch = objfile->arch ();
>    CORE_ADDR pc, baseaddr;
>    struct attribute *attr;
> -  struct call_site *call_site, call_site_local;
> +  struct call_site *call_site;
>    void **slot;
>    int nparams;
>    struct die_info *child_die;
> @@ -13369,8 +13369,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
>      cu->call_site_htab = htab_create_alloc_ex (16, core_addr_hash, core_addr_eq,
>  					       NULL, &objfile->objfile_obstack,
>  					       hashtab_obstack_allocate, NULL);
> -  call_site_local.pc = pc;
> -  slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT);
> +  slot = htab_find_slot (cu->call_site_htab, &pc, INSERT);
>    if (*slot != NULL)
>      {
>        complaint (_("Duplicate PC %s for DW_TAG_call_site "
> diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
> index 2a641122aec..84b751e82e3 100644
> --- a/gdb/gdbtypes.h
> +++ b/gdb/gdbtypes.h
> @@ -1783,9 +1783,7 @@ struct call_site_parameter
>  
>  struct call_site
>    {
> -    /* * Address of the first instruction after this call.  It must be
> -       the first field as we overload core_addr_hash and core_addr_eq
> -       for it.  */

Ah, I had not seen this comment.  So it was on purpose.  Still, I think
that it makes it more confusing than anything.  The patch LGTM.

Simon

  parent reply	other threads:[~2021-10-01 13:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 12:33 Tom de Vries
2021-10-01 12:33 ` [PATCH 2/4] [gdb/symtab] Remove COMPUNIT_CALL_SITE_HTAB Tom de Vries
2021-10-01 13:13   ` Simon Marchi
2021-10-01 12:33 ` [PATCH 3/4] [gdb/symtab] Add call_site::pc () Tom de Vries
2021-10-01 18:10   ` Simon Marchi
2021-10-04 16:45     ` Tom de Vries
2021-10-01 12:33 ` [PATCH 4/4] [gdb/symtab] Use unrelocated addresses in call_site Tom de Vries
2021-10-01 20:56   ` Simon Marchi
2021-10-04 16:47     ` Tom de Vries
2021-10-01 13:09 ` Simon Marchi [this message]
2021-10-03 19:34   ` [PATCH 1/4] [gdb/symtab] Fix htab_find_slot call in read_call_site_scope Tom de Vries
2021-10-04 12:05     ` Simon Marchi
2021-10-04 12:46       ` Tom de Vries
2021-10-04 15:41         ` Simon Marchi
2021-10-04 16:14           ` Tom de Vries
2021-10-04 16:34             ` 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=113a7cab-f06b-32ad-caa1-b0c87e67335b@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).