public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/6] gdb: add getter/setter for compunit_symtab::objfile
@ 2021-12-01 15:47 Simon Marchi
  2021-12-01 15:47 ` [PATCH 2/6] gdb: remove COMPUNIT_OBJFILE macro Simon Marchi
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Simon Marchi @ 2021-12-01 15:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

From: Simon Marchi <simon.marchi@efficios.com>

Rename the field to m_objfile, and add a getter and a setter.  Update
all users.

Change-Id: If7e2f763ee3e70570140d9af9261b1b056253317
---
 gdb/symfile.c |  8 ++++----
 gdb/symmisc.c |  2 +-
 gdb/symtab.c  |  2 +-
 gdb/symtab.h  | 14 ++++++++++++--
 4 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/gdb/symfile.c b/gdb/symfile.c
index 9e5c2d488812..e15df3fed739 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2757,7 +2757,7 @@ deduce_language_from_filename (const char *filename)
 struct symtab *
 allocate_symtab (struct compunit_symtab *cust, const char *filename)
 {
-  struct objfile *objfile = cust->objfile;
+  struct objfile *objfile = cust->objfile ();
   struct symtab *symtab
     = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symtab);
 
@@ -2815,7 +2815,7 @@ allocate_compunit_symtab (struct objfile *objfile, const char *name)
 					       struct compunit_symtab);
   const char *saved_name;
 
-  cu->objfile = objfile;
+  cu->set_objfile (objfile);
 
   /* The name we record here is only for display/debugging purposes.
      Just save the basename to avoid path issues (too long for display,
@@ -2841,8 +2841,8 @@ allocate_compunit_symtab (struct objfile *objfile, const char *name)
 void
 add_compunit_symtab_to_objfile (struct compunit_symtab *cu)
 {
-  cu->next = cu->objfile->compunit_symtabs;
-  cu->objfile->compunit_symtabs = cu;
+  cu->next = cu->objfile ()->compunit_symtabs;
+  cu->objfile ()->compunit_symtabs = cu;
 }
 \f
 
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index e38ceb6bda12..68ab1fab78a2 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -965,7 +965,7 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
   struct linetable *linetable;
   struct objfile *objfile;
 
-  objfile = symtab->compunit_symtab->objfile;
+  objfile = symtab->compunit_symtab->objfile ();
   printf_filtered (_("objfile: %s ((struct objfile *) %s)\n"),
 		   objfile_name (objfile),
 		   host_address_to_string (objfile));
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 3f2eb64a7c42..7e1030512b56 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -338,7 +338,7 @@ compunit_symtab::find_call_site (CORE_ADDR pc) const
     return nullptr;
 
   CORE_ADDR delta
-    = this->objfile->section_offsets[COMPUNIT_BLOCK_LINE_SECTION (this)];
+    = this->objfile ()->section_offsets[COMPUNIT_BLOCK_LINE_SECTION (this)];
   CORE_ADDR unrelocated_pc = pc - delta;
 
   struct call_site call_site_local (unrelocated_pc, nullptr, nullptr);
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 61f20b25a7bd..d56671e0a9e8 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1449,6 +1449,16 @@ struct symtab
 
 struct compunit_symtab
 {
+  struct objfile *objfile () const
+  {
+    return m_objfile;
+  }
+
+  void set_objfile (struct objfile *objfile)
+  {
+    m_objfile = objfile;
+  }
+
   /* Set m_call_site_htab.  */
   void set_call_site_htab (htab_t call_site_htab);
 
@@ -1459,7 +1469,7 @@ struct compunit_symtab
   struct compunit_symtab *next;
 
   /* Object file from which this symtab information was read.  */
-  struct objfile *objfile;
+  struct objfile *m_objfile;
 
   /* Name of the symtab.
      This is *not* intended to be a usable filename, and is
@@ -1535,7 +1545,7 @@ struct compunit_symtab
 
 using compunit_symtab_range = next_range<compunit_symtab>;
 
-#define COMPUNIT_OBJFILE(cust) ((cust)->objfile)
+#define COMPUNIT_OBJFILE(cust) ((cust)->objfile ())
 #define COMPUNIT_FILETABS(cust) ((cust)->filetabs)
 #define COMPUNIT_DEBUGFORMAT(cust) ((cust)->debugformat)
 #define COMPUNIT_PRODUCER(cust) ((cust)->producer)
-- 
2.33.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-12-01 15:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-01 15:47 [PATCH 1/6] gdb: add getter/setter for compunit_symtab::objfile Simon Marchi
2021-12-01 15:47 ` [PATCH 2/6] gdb: remove COMPUNIT_OBJFILE macro Simon Marchi
2021-12-01 15:47 ` [PATCH 3/6] gdb: rename compunit_primary_filetab to compunit_symtab::primary_filetab Simon Marchi
2021-12-01 15:47 ` [PATCH 4/6] gdb: add compunit_symtab::add_filetab method Simon Marchi
2021-12-01 15:47 ` [PATCH 5/6] gdb: add compunit_symtab::set_primary_filetab method Simon Marchi
2021-12-01 15:47 ` [PATCH 6/6] gdb: move compunit_filetabs to compunit_symtab::filetabs Simon Marchi

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