public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/symtab] Fix htab_find_slot call in read_call_site_scope
@ 2021-10-01 15:15 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2021-10-01 15:15 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b4c919f75256a8f2263950ce2f970ba40d279b57

commit b4c919f75256a8f2263950ce2f970ba40d279b57
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Fri Oct 1 17:15:20 2021 +0200

    [gdb/symtab] Fix htab_find_slot call in read_call_site_scope
    
    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>

Diff:
---
 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 f4967a03f9a..b9b62b40a22 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 5ec7a5f97a8..6d09576208d 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1793,9 +1793,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.  */
+    /* Address of the first instruction after this call.  */
 
     CORE_ADDR pc;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-01 15:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-01 15:15 [binutils-gdb] [gdb/symtab] Fix htab_find_slot call in read_call_site_scope Tom de Vries

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).