public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/5] Introduce symbol_block_ops::get_block_value
Date: Tue, 14 Mar 2023 14:04:48 -0600	[thread overview]
Message-ID: <20230314-submit-pragma-import-export-v1-4-a235709f7e96@adacore.com> (raw)
In-Reply-To: <20230314-submit-pragma-import-export-v1-0-a235709f7e96@adacore.com>

This adds a new callback to symbol_block_ops.  This callback lets a
LOC_BLOCK symbol implement its own function to find the underlying
block.
---
 gdb/symtab.c | 3 ++-
 gdb/symtab.h | 9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 57ba61c2c05..237b3ff794f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -6391,7 +6391,8 @@ register_symbol_block_impl (enum address_class aclass,
 
   /* Sanity check OPS.  */
   gdb_assert (ops != NULL);
-  gdb_assert (ops->find_frame_base_location != NULL);
+  gdb_assert (ops->find_frame_base_location != nullptr
+	      || ops->get_block_value != nullptr);
 
   return result;
 }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 0a42fd2380c..ea3cf395f26 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1149,6 +1149,12 @@ struct symbol_block_ops
      the corresponding DW_AT_frame_base attribute.  */
   CORE_ADDR (*get_frame_base) (struct symbol *framefunc,
 			       frame_info_ptr frame);
+
+  /* Return the block for this function.  So far, this is used to
+     implement function aliases.  So, if this is set, then it's not
+     necessary to set the other functions in this structure; and vice
+     versa.  */
+  const block *(*get_block_value) (const struct symbol *sym);
 };
 
 /* Functions used with LOC_REGISTER and LOC_REGPARM_ADDR.  */
@@ -1507,6 +1513,9 @@ struct block_symbol
 inline const block *
 symbol::value_block () const
 {
+  if (SYMBOL_BLOCK_OPS (this) != nullptr
+      && SYMBOL_BLOCK_OPS (this)->get_block_value != nullptr)
+    return SYMBOL_BLOCK_OPS (this)->get_block_value (this);
   return m_value.block;
 }
 

-- 
2.39.1


  parent reply	other threads:[~2023-03-14 20:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14 20:04 [PATCH 0/5] Implement Ada Pragma Import and Pragma Export Tom Tromey
2023-03-14 20:04 ` [PATCH 1/5] Introduce lookup_minimal_symbol_linkage Tom Tromey
2023-03-14 20:04 ` [PATCH 2/5] Bump MAX_SYMBOL_IMPLS Tom Tromey
2023-03-14 20:04 ` [PATCH 3/5] Define symbol::value_block separately Tom Tromey
2023-03-14 20:04 ` Tom Tromey [this message]
2023-03-14 20:04 ` [PATCH 5/5] Handle Ada Pragma Import and Pragma Export Tom Tromey
2023-03-29 16:10 ` [PATCH 0/5] Implement " 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=20230314-submit-pragma-import-export-v1-4-a235709f7e96@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).