public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/4] [gdb/symtab] Remove COMPUNIT_CALL_SITE_HTAB
Date: Fri,  1 Oct 2021 14:33:26 +0200	[thread overview]
Message-ID: <20211001123328.22314-2-tdevries@suse.de> (raw)
In-Reply-To: <20211001123328.22314-1-tdevries@suse.de>

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove macro COMPUNIT_CALL_SITE_HTAB, and provide access to the htab using
member functions:
- compunit_symtab::find_call_site
- compunit_symtab::set_call_site_htab

Tested on x86_64-linux.

Co-Authored-By: Tom de Vries <tdevries@suse.de>
---
 gdb/block.c       | 10 +++++-----
 gdb/dwarf2/read.c |  2 +-
 gdb/symtab.c      | 24 ++++++++++++++++++++++++
 gdb/symtab.h      |  9 +++++++--
 4 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/gdb/block.c b/gdb/block.c
index 4cb95731396..90c0c5b3250 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -225,15 +225,15 @@ struct call_site *
 call_site_for_pc (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   struct compunit_symtab *cust;
-  void **slot = NULL;
+  call_site *cs = nullptr;
 
   /* -1 as tail call PC can be already after the compilation unit range.  */
   cust = find_pc_compunit_symtab (pc - 1);
 
-  if (cust != NULL && COMPUNIT_CALL_SITE_HTAB (cust) != NULL)
-    slot = htab_find_slot (COMPUNIT_CALL_SITE_HTAB (cust), &pc, NO_INSERT);
+  if (cust != nullptr)
+    cs = cust->find_call_site (pc);
 
-  if (slot == NULL)
+  if (cs == nullptr)
     {
       struct bound_minimal_symbol msym = lookup_minimal_symbol_by_pc (pc);
 
@@ -247,7 +247,7 @@ call_site_for_pc (struct gdbarch *gdbarch, CORE_ADDR pc)
 		    : msym.minsym->print_name ()));
     }
 
-  return (struct call_site *) *slot;
+  return cs;
 }
 
 /* Return the blockvector immediately containing the innermost lexical block
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 23870c04e74..ac8460df9a4 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9510,7 +9510,7 @@ process_full_comp_unit (dwarf2_cu *cu, enum language pretend_language)
       if (gcc_4_minor >= 5)
 	cust->epilogue_unwind_valid = 1;
 
-      cust->call_site_htab = cu->call_site_htab;
+      cust->set_call_site_htab (cu->call_site_htab);
     }
 
   per_objfile->set_symtab (cu->per_cu, cust);
diff --git a/gdb/symtab.c b/gdb/symtab.c
index a30d900cf8d..b7a00709d00 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -331,6 +331,30 @@ search_domain_name (enum search_domain e)
 
 /* See symtab.h.  */
 
+call_site *
+compunit_symtab::find_call_site (CORE_ADDR pc) const
+{
+  if (m_call_site_htab == nullptr)
+    return nullptr;
+
+  void **slot = htab_find_slot (m_call_site_htab, &pc, NO_INSERT);
+  if (slot == nullptr)
+    return nullptr;
+
+  return (call_site *) *slot;
+}
+
+/* See symtab.h.  */
+
+void
+compunit_symtab::set_call_site_htab (htab_t call_site_htab)
+{
+  gdb_assert (m_call_site_htab == nullptr);
+  m_call_site_htab = call_site_htab;
+}
+
+/* See symtab.h.  */
+
 struct symtab *
 compunit_primary_filetab (const struct compunit_symtab *cust)
 {
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 5182f51672e..6a6cf8201bc 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1449,6 +1449,12 @@ struct symtab
 
 struct compunit_symtab
 {
+  /* Set m_call_site_htab.  */
+  void set_call_site_htab (htab_t call_site_htab);
+
+  /* Find call_site info for PC.  */
+  call_site *find_call_site (CORE_ADDR pc) const;
+
   /* Unordered chain of all compunit symtabs of this objfile.  */
   struct compunit_symtab *next;
 
@@ -1503,7 +1509,7 @@ struct compunit_symtab
   unsigned int epilogue_unwind_valid : 1;
 
   /* struct call_site entries for this compilation unit or NULL.  */
-  htab_t call_site_htab;
+  htab_t m_call_site_htab;
 
   /* The macro table for this symtab.  Like the blockvector, this
      is shared between different symtabs in a given compilation unit.
@@ -1538,7 +1544,6 @@ using compunit_symtab_range = next_range<compunit_symtab>;
 #define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section)
 #define COMPUNIT_LOCATIONS_VALID(cust) ((cust)->locations_valid)
 #define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid)
-#define COMPUNIT_CALL_SITE_HTAB(cust) ((cust)->call_site_htab)
 #define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table)
 
 /* A range adapter to allowing iterating over all the file tables
-- 
2.26.2


  reply	other threads:[~2021-10-01 12:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 12:33 [PATCH 1/4] [gdb/symtab] Fix htab_find_slot call in read_call_site_scope Tom de Vries
2021-10-01 12:33 ` Tom de Vries [this message]
2021-10-01 13:13   ` [PATCH 2/4] [gdb/symtab] Remove COMPUNIT_CALL_SITE_HTAB 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 ` [PATCH 1/4] [gdb/symtab] Fix htab_find_slot call in read_call_site_scope Simon Marchi
2021-10-03 19:34   ` 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=20211001123328.22314-2-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /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).