From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 2/6] Make call_site_target members private
Date: Wed, 1 Dec 2021 15:04:28 -0700 [thread overview]
Message-ID: <20211201220432.4105152-3-tromey@adacore.com> (raw)
In-Reply-To: <20211201220432.4105152-1-tromey@adacore.com>
This makes the data members of call_site_target 'private'. This lets
us remove most of its public API. call_site_to_target_addr is changed
to be a method of this type. This is a preparatory refactoring for
the fix at the end of this series.
---
gdb/dwarf2/loc.c | 26 ++++++++++++--------------
gdb/gdbtypes.h | 44 +++++++++++++++++++++-----------------------
2 files changed, 33 insertions(+), 37 deletions(-)
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 1d49e7960f1..7a3fda5eac1 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -632,16 +632,14 @@ show_entry_values_debug (struct ui_file *file, int from_tty,
value);
}
-/* Find DW_TAG_call_site's DW_AT_call_target address.
- CALLER_FRAME (for registers) can be NULL if it is not known. This function
- always returns valid address or it throws NO_ENTRY_VALUE_ERROR. */
+/* See gdbtypes.h. */
-static CORE_ADDR
-call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
- struct call_site *call_site,
- struct frame_info *caller_frame)
+CORE_ADDR
+call_site_target::address (struct gdbarch *call_site_gdbarch,
+ const struct call_site *call_site,
+ struct frame_info *caller_frame) const
{
- switch (call_site->target.loc_kind ())
+ switch (m_loc_kind)
{
case call_site_target::DWARF_BLOCK:
{
@@ -650,7 +648,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
struct type *caller_core_addr_type;
struct gdbarch *caller_arch;
- dwarf_block = call_site->target.loc_dwarf_block ();
+ dwarf_block = m_loc.dwarf_block;
if (dwarf_block == NULL)
{
struct bound_minimal_symbol msym;
@@ -695,7 +693,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
const char *physname;
struct bound_minimal_symbol msym;
- physname = call_site->target.loc_physname ();
+ physname = m_loc.physname;
/* Handle both the mangled and demangled PHYSNAME. */
msym = lookup_minimal_symbol (physname, NULL, NULL);
@@ -720,7 +718,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
int sect_idx = COMPUNIT_BLOCK_LINE_SECTION (cust);
CORE_ADDR delta = per_objfile->objfile->section_offsets[sect_idx];
- return call_site->target.loc_physaddr () + delta;
+ return m_loc.physaddr + delta;
}
default:
@@ -790,7 +788,7 @@ func_verify_no_selftailcall (struct gdbarch *gdbarch, CORE_ADDR verify_addr)
/* CALLER_FRAME with registers is not available for tail-call jumped
frames. */
- target_addr = call_site_to_target_addr (gdbarch, call_site, NULL);
+ target_addr = call_site->address (gdbarch, nullptr);
if (target_addr == verify_addr)
{
@@ -968,7 +966,7 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
/* CALLER_FRAME with registers is not available for tail-call jumped
frames. */
- target_func_addr = call_site_to_target_addr (gdbarch, call_site, NULL);
+ target_func_addr = call_site->address (gdbarch, nullptr);
if (target_func_addr == callee_pc)
{
@@ -1159,7 +1157,7 @@ dwarf_expr_reg_to_entry_parameter (struct frame_info *frame,
caller_pc = get_frame_pc (caller_frame);
call_site = call_site_for_pc (gdbarch, caller_pc);
- target_addr = call_site_to_target_addr (gdbarch, call_site, caller_frame);
+ target_addr = call_site->address (gdbarch, caller_frame);
if (target_addr != func_addr)
{
struct minimal_symbol *target_msym, *func_msym;
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 48d1658613f..d2b5483c893 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1821,47 +1821,35 @@ struct call_site_target
DWARF_BLOCK,
};
- kind loc_kind () const
- {
- return m_loc_kind;
- }
-
- CORE_ADDR loc_physaddr () const
- {
- gdb_assert (m_loc_kind == PHYSADDR);
- return m_loc.physaddr;
- }
-
void set_loc_physaddr (CORE_ADDR physaddr)
{
m_loc_kind = PHYSADDR;
m_loc.physaddr = physaddr;
}
- const char *loc_physname () const
- {
- gdb_assert (m_loc_kind == PHYSNAME);
- return m_loc.physname;
- }
-
void set_loc_physname (const char *physname)
{
m_loc_kind = PHYSNAME;
m_loc.physname = physname;
}
- dwarf2_locexpr_baton *loc_dwarf_block () const
- {
- gdb_assert (m_loc_kind == DWARF_BLOCK);
- return m_loc.dwarf_block;
- }
-
void set_loc_dwarf_block (dwarf2_locexpr_baton *dwarf_block)
{
m_loc_kind = DWARF_BLOCK;
m_loc.dwarf_block = dwarf_block;
}
+ /* Find DW_TAG_call_site's DW_AT_call_target address. CALLER_FRAME
+ (for registers) can be NULL if it is not known. This function
+ always returns valid address or it throws
+ NO_ENTRY_VALUE_ERROR. */
+
+ CORE_ADDR address (struct gdbarch *call_site_gdbarch,
+ const struct call_site *call_site,
+ struct frame_info *caller_frame) const;
+
+private:
+
union
{
/* Address. */
@@ -1953,6 +1941,16 @@ struct call_site
CORE_ADDR pc () const;
+ /* Find the target address. CALLER_FRAME (for registers) can be
+ NULL if it is not known. This function always returns valid
+ address or it throws NO_ENTRY_VALUE_ERROR. */
+
+ CORE_ADDR address (struct gdbarch *call_site_gdbarch,
+ struct frame_info *caller_frame) const
+ {
+ return target.address (call_site_gdbarch, this, caller_frame);
+ }
+
/* * List successor with head in FUNC_TYPE.TAIL_CALL_LIST. */
struct call_site *tail_call_next = nullptr;
--
2.31.1
next prev parent reply other threads:[~2021-12-01 22:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 22:04 [PATCH 0/6] Handle split functions in call site chains Tom Tromey
2021-12-01 22:04 ` [PATCH 1/6] Change call_site_target to use custom type and enum Tom Tromey
2021-12-01 22:04 ` Tom Tromey [this message]
2021-12-01 22:04 ` [PATCH 3/6] Constify chain_candidate Tom Tromey
2021-12-01 22:04 ` [PATCH 4/6] Change call_site_find_chain_1 to work recursively Tom Tromey
2021-12-01 22:04 ` [PATCH 5/6] Change call_site_target to iterate over addresses Tom Tromey
2021-12-01 22:04 ` [PATCH 6/6] Handle multiple addresses in call_site_target Tom Tromey
2022-02-28 18:34 ` [PATCH 0/6] Handle split functions in call site chains Tom Tromey
2022-03-28 19:54 ` 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=20211201220432.4105152-3-tromey@adacore.com \
--to=tromey@adacore.com \
--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).