* [PATCH 0/6] More symbol methods
@ 2022-04-20 14:50 Tom Tromey
2022-04-20 14:50 ` [PATCH 1/6] Add accessors for symbol's artificial field Tom Tromey
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Tom Tromey @ 2022-04-20 14:50 UTC (permalink / raw)
To: gdb-patches
I've been experimenting a little with lazy symbol reading, and for
that it is convenient to have accessors for members.
This patch series implements this idea. It seemed like a reasonable
cleanup on its own, so I figured I'd send it.
Regression tested on x86-64 Fedora 34.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/6] Add accessors for symbol's artificial field
2022-04-20 14:50 [PATCH 0/6] More symbol methods Tom Tromey
@ 2022-04-20 14:50 ` Tom Tromey
2022-04-20 15:15 ` Simon Marchi
2022-04-20 14:50 ` [PATCH 2/6] Use array_view for symbol_impls Tom Tromey
` (4 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2022-04-20 14:50 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
For a series I'm experimenting with, it was handy to hide a symbol's
"artificial" field behind accessors. This patch is the result.
---
gdb/ada-lang.c | 6 +++---
gdb/dwarf2/read.c | 2 +-
gdb/symtab.h | 16 ++++++++++++++--
3 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7623d0eb48d..6ba313d3fe3 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3854,7 +3854,7 @@ ada_resolve_variable (struct symbol *sym, const struct block *block,
candidates.end (),
[] (block_symbol &bsym)
{
- return bsym.symbol->artificial;
+ return bsym.symbol->artificial ();
}),
candidates.end ());
@@ -13456,9 +13456,9 @@ class ada_language : public language_defn
}
/* See language.h. */
- virtual bool symbol_printing_suppressed (struct symbol *symbol) const override
+ bool symbol_printing_suppressed (struct symbol *symbol) const override
{
- return symbol->artificial;
+ return symbol->artificial ();
}
/* See language.h. */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 6dcd446e5f4..a4987d4996e 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -20688,7 +20688,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
/* Handle DW_AT_artificial. */
attr = dwarf2_attr (die, DW_AT_artificial, cu);
if (attr != nullptr)
- sym->artificial = attr->as_boolean ();
+ sym->set_artificial (attr->as_boolean ());
/* Default assumptions.
Use the passed type or decode it from the die. */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 4a33c7a119f..ce09bc19bfe 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1203,7 +1203,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
m_is_inlined (0),
maybe_copied (0),
subclass (SYMBOL_NONE),
- artificial (false)
+ m_artificial (false)
{
/* We can't use an initializer list for members of a base class, and
general_symbol_info needs to stay a POD type. */
@@ -1369,6 +1369,18 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
m_value.chain = sym;
}
+ /* Return true if this symbol was marked as artificial. */
+ bool artificial () const
+ {
+ return m_artificial;
+ }
+
+ /* Set the 'artificial' flag on this symbol. */
+ void set_artificial (bool artificial)
+ {
+ m_artificial = artificial;
+ }
+
/* Data type of value */
struct type *m_type = nullptr;
@@ -1423,7 +1435,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
/* Whether this symbol is artificial. */
- bool artificial : 1;
+ bool m_artificial : 1;
/* Line number of this symbol's definition, except for inlined
functions. For an inlined function (class LOC_BLOCK and
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/6] Use array_view for symbol_impls
2022-04-20 14:50 [PATCH 0/6] More symbol methods Tom Tromey
2022-04-20 14:50 ` [PATCH 1/6] Add accessors for symbol's artificial field Tom Tromey
@ 2022-04-20 14:50 ` Tom Tromey
2022-04-20 14:50 ` [PATCH 3/6] Remove symbol::aclass_index Tom Tromey
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2022-04-20 14:50 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
It seemed to me that using array_view for symbol_impls would give a
bit more error checking, at least when gdb is built in libstdc++ debug
mode.
---
gdb/symtab.c | 2 +-
gdb/symtab.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index a75492603b8..43a64edab34 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -6502,7 +6502,7 @@ static struct symbol_impl symbol_impl[MAX_SYMBOL_IMPLS];
/* The globally visible pointer. This is separate from 'symbol_impl'
so that it can be const. */
-const struct symbol_impl *symbol_impls = &symbol_impl[0];
+gdb::array_view<const struct symbol_impl> symbol_impls (symbol_impl);
/* Make sure we saved enough room in struct symbol. */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index ce09bc19bfe..9b677ffe451 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1188,7 +1188,7 @@ enum symbol_subclass_kind
SYMBOL_RUST_VTABLE
};
-extern const struct symbol_impl *symbol_impls;
+extern gdb::array_view<const struct symbol_impl> symbol_impls;
/* This structure is space critical. See space comments at the top. */
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/6] Remove symbol::aclass_index
2022-04-20 14:50 [PATCH 0/6] More symbol methods Tom Tromey
2022-04-20 14:50 ` [PATCH 1/6] Add accessors for symbol's artificial field Tom Tromey
2022-04-20 14:50 ` [PATCH 2/6] Use array_view for symbol_impls Tom Tromey
@ 2022-04-20 14:50 ` Tom Tromey
2022-04-20 14:50 ` [PATCH 4/6] Replace symbol_objfile with symbol::objfile Tom Tromey
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2022-04-20 14:50 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
Symbols have an aclass_index method, but this isn't needed, because
the aclass index isn't useful outside of the symbol implementation.
---
gdb/symtab.h | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 9b677ffe451..3f9052d76f3 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1221,11 +1221,6 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
symbol (const symbol &) = default;
symbol &operator= (const symbol &) = default;
- unsigned int aclass_index () const
- {
- return m_aclass_index;
- }
-
void set_aclass_index (unsigned int aclass_index)
{
m_aclass_index = aclass_index;
@@ -1233,7 +1228,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
const symbol_impl &impl () const
{
- return symbol_impls[this->aclass_index ()];
+ return symbol_impls[this->m_aclass_index];
}
address_class aclass () const
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 4/6] Replace symbol_objfile with symbol::objfile
2022-04-20 14:50 [PATCH 0/6] More symbol methods Tom Tromey
` (2 preceding siblings ...)
2022-04-20 14:50 ` [PATCH 3/6] Remove symbol::aclass_index Tom Tromey
@ 2022-04-20 14:50 ` Tom Tromey
2022-04-20 14:50 ` [PATCH 5/6] Replace symbol_arch with symbol::arch Tom Tromey
2022-04-20 14:50 ` [PATCH 6/6] Replace symbol_symtab with symbol::symtab Tom Tromey
5 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2022-04-20 14:50 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This turns symbol_objfile into a method on symbol.
---
gdb/block.c | 2 +-
gdb/expop.h | 2 +-
gdb/findvar.c | 10 +++++-----
gdb/guile/scm-frame.c | 2 +-
gdb/guile/scm-symbol.c | 2 +-
gdb/infcmd.c | 2 +-
gdb/printcmd.c | 2 +-
gdb/python/py-frame.c | 2 +-
gdb/python/py-symbol.c | 4 ++--
gdb/symmisc.c | 2 +-
gdb/symtab.c | 14 +++++++-------
gdb/symtab.h | 12 ++++++------
gdb/valops.c | 2 +-
13 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/gdb/block.c b/gdb/block.c
index 3fe096db583..530d2339cc6 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -48,7 +48,7 @@ block_objfile (const struct block *block)
const struct global_block *global_block;
if (BLOCK_FUNCTION (block) != NULL)
- return symbol_objfile (BLOCK_FUNCTION (block));
+ return BLOCK_FUNCTION (block)->objfile ();
global_block = (struct global_block *) block_global_block (block);
return global_block->compunit_symtab->objfile ();
diff --git a/gdb/expop.h b/gdb/expop.h
index a17311f74e5..cfe96cbe589 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -225,7 +225,7 @@ check_objfile (struct type *type, struct objfile *objfile)
static inline bool
check_objfile (struct symbol *sym, struct objfile *objfile)
{
- return check_objfile (symbol_objfile (sym), objfile);
+ return check_objfile (sym->objfile (), objfile);
}
static inline bool
diff --git a/gdb/findvar.c b/gdb/findvar.c
index ec21c82532b..4f109f560b9 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -636,7 +636,7 @@ language_defn::read_var_value (struct symbol *var,
v = allocate_value (type);
if (overlay_debugging)
{
- struct objfile *var_objfile = symbol_objfile (var);
+ struct objfile *var_objfile = var->objfile ();
addr = symbol_overlayed_address (var->value_address (),
var->obj_section (var_objfile));
store_typed_address (value_contents_raw (v).data (), type, addr);
@@ -663,7 +663,7 @@ language_defn::read_var_value (struct symbol *var,
if (overlay_debugging)
addr
= symbol_overlayed_address (var->value_address (),
- var->obj_section (symbol_objfile (var)));
+ var->obj_section (var->objfile ()));
else
addr = var->value_address ();
break;
@@ -705,7 +705,7 @@ language_defn::read_var_value (struct symbol *var,
if (overlay_debugging)
addr = symbol_overlayed_address
(BLOCK_ENTRY_PC (var->value_block ()),
- var->obj_section (symbol_objfile (var)));
+ var->obj_section (var->objfile ()));
else
addr = BLOCK_ENTRY_PC (var->value_block ());
break;
@@ -755,7 +755,7 @@ language_defn::read_var_value (struct symbol *var,
gdbarch_iterate_over_objfiles_in_search_order
(symbol_arch (var),
minsym_lookup_iterator_cb, &lookup_data,
- symbol_objfile (var));
+ var->objfile ());
msym = lookup_data.result.minsym;
/* If we can't find the minsym there's a problem in the symbol info.
@@ -764,7 +764,7 @@ language_defn::read_var_value (struct symbol *var,
if (msym == NULL)
{
const char *flavour_name
- = objfile_flavour_name (symbol_objfile (var));
+ = objfile_flavour_name (var->objfile ());
/* We can't get here unless we've opened the file, so flavour_name
can't be NULL. */
diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c
index 68fa35cf94c..e53c8602322 100644
--- a/gdb/guile/scm-frame.c
+++ b/gdb/guile/scm-frame.c
@@ -624,7 +624,7 @@ gdbscm_frame_block (SCM self)
if (block != NULL)
{
return bkscm_scm_from_block
- (block, symbol_objfile (BLOCK_FUNCTION (fn_block)));
+ (block, BLOCK_FUNCTION (fn_block)->objfile ());
}
return SCM_BOOL_F;
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index dbe19865d4e..48ea28fb243 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -103,7 +103,7 @@ syscm_get_symbol_map (struct symbol *symbol)
if (symbol->is_objfile_owned ())
{
- struct objfile *objfile = symbol_objfile (symbol);
+ struct objfile *objfile = symbol->objfile ();
htab = (htab_t) objfile_data (objfile, syscm_objfile_data_key);
if (htab == NULL)
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 84eb6e5d79b..c7f339a7a94 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1086,7 +1086,7 @@ jump_command (const char *arg, int from_tty)
struct obj_section *section;
fixup_symbol_section (sfn, 0);
- section = sfn->obj_section (symbol_objfile (sfn));
+ section = sfn->obj_section (sfn->objfile ());
if (section_is_overlay (section)
&& !section_is_mapped (section))
{
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index f4f64b669bc..0e139e09c41 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1681,7 +1681,7 @@ info_address_command (const char *exp, int from_tty)
gdb_printf ("\" is ");
val = sym->value_longest ();
if (sym->is_objfile_owned ())
- section = sym->obj_section (symbol_objfile (sym));
+ section = sym->obj_section (sym->objfile ());
else
section = NULL;
gdbarch = symbol_arch (sym);
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index bf9eba89c5f..d07158a5ec6 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -306,7 +306,7 @@ frapy_block (PyObject *self, PyObject *args)
if (block)
{
return block_to_block_object
- (block, symbol_objfile (BLOCK_FUNCTION (fn_block)));
+ (block, BLOCK_FUNCTION (fn_block)->objfile ());
}
Py_RETURN_NONE;
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 12c97bf63bb..5d475504fe6 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -305,7 +305,7 @@ set_symbol (symbol_object *obj, struct symbol *symbol)
if (symbol->is_objfile_owned ()
&& symbol_symtab (symbol) != NULL)
{
- struct objfile *objfile = symbol_objfile (symbol);
+ struct objfile *objfile = symbol->objfile ();
obj->next = ((symbol_object *)
objfile_data (objfile, sympy_objfile_data_key));
@@ -351,7 +351,7 @@ sympy_dealloc (PyObject *obj)
&& sym_obj->symbol->is_objfile_owned ()
&& symbol_symtab (sym_obj->symbol) != NULL)
{
- set_objfile_data (symbol_objfile (sym_obj->symbol),
+ set_objfile_data (sym_obj->symbol->objfile (),
sympy_objfile_data_key, sym_obj->next);
}
if (sym_obj->next)
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 18741e4cab5..dee11fdf57d 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -503,7 +503,7 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
struct obj_section *section;
if (symbol->is_objfile_owned ())
- section = symbol->obj_section (symbol_objfile (symbol));
+ section = symbol->obj_section (symbol->objfile ());
else
section = NULL;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 43a64edab34..7188169f660 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1806,7 +1806,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
gdb_assert (objfile || symbol_symtab (sym));
if (objfile == NULL)
- objfile = symbol_objfile (sym);
+ objfile = sym->objfile ();
if (sym->obj_section (objfile) != nullptr)
return sym;
@@ -3780,7 +3780,7 @@ find_function_start_sal (symbol *sym, bool funfirstline)
fixup_symbol_section (sym, NULL);
symtab_and_line sal
= find_function_start_sal_1 (BLOCK_ENTRY_PC (sym->value_block ()),
- sym->obj_section (symbol_objfile (sym)),
+ sym->obj_section (sym->objfile ()),
funfirstline);
sal.symbol = sym;
return sal;
@@ -3907,7 +3907,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
{
fixup_symbol_section (sym, NULL);
- objfile = symbol_objfile (sym);
+ objfile = sym->objfile ();
pc = BLOCK_ENTRY_PC (sym->value_block ());
section = sym->obj_section (objfile);
name = sym->linkage_name ();
@@ -5789,7 +5789,7 @@ find_gnu_ifunc (const symbol *sym)
lookup_name_info lookup_name (sym->search_name (),
symbol_name_match_type::SEARCH_NAME);
- struct objfile *objfile = symbol_objfile (sym);
+ struct objfile *objfile = sym->objfile ();
CORE_ADDR address = BLOCK_ENTRY_PC (sym->value_block ());
minimal_symbol *ifunc = NULL;
@@ -6593,10 +6593,10 @@ initialize_ordinary_address_classes (void)
/* See symtab.h. */
struct objfile *
-symbol_objfile (const struct symbol *symbol)
+symbol::objfile () const
{
- gdb_assert (symbol->is_objfile_owned ());
- return symbol->owner.symtab->compunit ()->objfile ();
+ gdb_assert (is_objfile_owned ());
+ return owner.symtab->compunit ()->objfile ();
}
/* See symtab.h. */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 3f9052d76f3..79967f7c38b 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1376,6 +1376,12 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
m_artificial = artificial;
}
+ /* Return the OBJFILE of this symbol. It is an error to call this
+ if is_objfile_owned is false, which only happens for
+ architecture-provided types. */
+
+ struct objfile *objfile () const;
+
/* Data type of value */
struct type *m_type = nullptr;
@@ -1492,12 +1498,6 @@ extern int register_symbol_block_impl (enum address_class aclass,
extern int register_symbol_register_impl (enum address_class,
const struct symbol_register_ops *);
-/* Return the OBJFILE of SYMBOL.
- It is an error to call this if symbol.is_objfile_owned is false, which
- only happens for architecture-provided types. */
-
-extern struct objfile *symbol_objfile (const struct symbol *symbol);
-
/* Return the ARCH of SYMBOL. */
extern struct gdbarch *symbol_arch (const struct symbol *symbol);
diff --git a/gdb/valops.c b/gdb/valops.c
index e84cabf8f14..27e84d9f6b3 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -127,7 +127,7 @@ find_function_in_inferior (const char *name, struct objfile **objf_p)
}
if (objf_p)
- *objf_p = symbol_objfile (sym.symbol);
+ *objf_p = sym.symbol->objfile ();
return value_of_variable (sym.symbol, sym.block);
}
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 5/6] Replace symbol_arch with symbol::arch
2022-04-20 14:50 [PATCH 0/6] More symbol methods Tom Tromey
` (3 preceding siblings ...)
2022-04-20 14:50 ` [PATCH 4/6] Replace symbol_objfile with symbol::objfile Tom Tromey
@ 2022-04-20 14:50 ` Tom Tromey
2022-04-20 14:50 ` [PATCH 6/6] Replace symbol_symtab with symbol::symtab Tom Tromey
5 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2022-04-20 14:50 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This turns symbol_arch into a method on symbol.
---
gdb/block.c | 2 +-
gdb/findvar.c | 2 +-
gdb/guile/scm-symbol.c | 2 +-
gdb/printcmd.c | 2 +-
gdb/symtab.c | 8 ++++----
gdb/symtab.h | 8 ++++----
gdb/tracepoint.c | 2 +-
7 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/gdb/block.c b/gdb/block.c
index 530d2339cc6..bab6868bbbb 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -60,7 +60,7 @@ struct gdbarch *
block_gdbarch (const struct block *block)
{
if (BLOCK_FUNCTION (block) != NULL)
- return symbol_arch (BLOCK_FUNCTION (block));
+ return BLOCK_FUNCTION (block)->arch ();
return block_objfile (block)->arch ();
}
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 4f109f560b9..067fb3f6757 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -753,7 +753,7 @@ language_defn::read_var_value (struct symbol *var,
lookup_data.name = var->linkage_name ();
gdbarch_iterate_over_objfiles_in_search_order
- (symbol_arch (var),
+ (var->arch (),
minsym_lookup_iterator_cb, &lookup_data,
var->objfile ());
msym = lookup_data.result.minsym;
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 48ea28fb243..9e89b0458af 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -115,7 +115,7 @@ syscm_get_symbol_map (struct symbol *symbol)
}
else
{
- struct gdbarch *gdbarch = symbol_arch (symbol);
+ struct gdbarch *gdbarch = symbol->arch ();
struct syscm_gdbarch_data *data
= (struct syscm_gdbarch_data *) gdbarch_data (gdbarch,
syscm_gdbarch_data_key);
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 0e139e09c41..102058a8579 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1684,7 +1684,7 @@ info_address_command (const char *exp, int from_tty)
section = sym->obj_section (sym->objfile ());
else
section = NULL;
- gdbarch = symbol_arch (sym);
+ gdbarch = sym->arch ();
if (SYMBOL_COMPUTED_OPS (sym) != NULL)
{
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 7188169f660..d5d3877d90e 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -6602,11 +6602,11 @@ symbol::objfile () const
/* See symtab.h. */
struct gdbarch *
-symbol_arch (const struct symbol *symbol)
+symbol::arch () const
{
- if (!symbol->is_objfile_owned ())
- return symbol->owner.arch;
- return symbol->owner.symtab->compunit ()->objfile ()->arch ();
+ if (!is_objfile_owned ())
+ return owner.arch;
+ return owner.symtab->compunit ()->objfile ()->arch ();
}
/* See symtab.h. */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 79967f7c38b..09335ef9a91 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1382,6 +1382,10 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
struct objfile *objfile () const;
+ /* Return the ARCH of this symbol. */
+
+ struct gdbarch *arch () const;
+
/* Data type of value */
struct type *m_type = nullptr;
@@ -1498,10 +1502,6 @@ extern int register_symbol_block_impl (enum address_class aclass,
extern int register_symbol_register_impl (enum address_class,
const struct symbol_register_ops *);
-/* Return the ARCH of SYMBOL. */
-
-extern struct gdbarch *symbol_arch (const struct symbol *symbol);
-
/* Return the SYMTAB of SYMBOL.
It is an error to call this if symbol.is_objfile_owned is false, which
only happens for architecture-provided types. */
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 5a4048f9078..18c3803ac19 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2506,7 +2506,7 @@ info_scope_command (const char *args_in, int from_tty)
if (symname == NULL || *symname == '\0')
continue; /* Probably botched, certainly useless. */
- gdbarch = symbol_arch (sym);
+ gdbarch = sym->arch ();
gdb_printf ("Symbol %s is ", symname);
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 6/6] Replace symbol_symtab with symbol::symtab
2022-04-20 14:50 [PATCH 0/6] More symbol methods Tom Tromey
` (4 preceding siblings ...)
2022-04-20 14:50 ` [PATCH 5/6] Replace symbol_arch with symbol::arch Tom Tromey
@ 2022-04-20 14:50 ` Tom Tromey
2022-04-20 15:20 ` Simon Marchi
5 siblings, 1 reply; 11+ messages in thread
From: Tom Tromey @ 2022-04-20 14:50 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This turns symbol_symtab into a method on symbol. It also replaces
symbol_set_symtab with a method.
---
gdb/ada-lang.c | 6 ++---
gdb/btrace.c | 6 ++---
gdb/buildsym.c | 12 +++++-----
gdb/compile/compile-c-symbols.c | 2 +-
gdb/compile/compile-cplus-symbols.c | 2 +-
gdb/compile/compile-cplus-types.c | 4 ++--
gdb/compile/compile-object-load.c | 2 +-
gdb/dwarf2/read.c | 12 +++++-----
gdb/frame.c | 2 +-
gdb/guile/scm-symbol.c | 2 +-
gdb/jit.c | 2 +-
gdb/linespec.c | 18 +++++++--------
gdb/mdebugread.c | 2 +-
gdb/mi/mi-symbol-cmds.c | 8 +++----
gdb/python/py-symbol.c | 6 ++---
gdb/python/python.c | 2 +-
gdb/record-btrace.c | 4 ++--
gdb/source.c | 2 +-
gdb/symtab.c | 34 ++++++++++++++---------------
gdb/symtab.h | 24 ++++++++++----------
20 files changed, 76 insertions(+), 76 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 6ba313d3fe3..8c64fea0f33 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3681,7 +3681,7 @@ See set/show multiple-symbol."));
struct symtab *symtab = NULL;
if (syms[i].symbol->is_objfile_owned ())
- symtab = symbol_symtab (syms[i].symbol);
+ symtab = syms[i].symbol->symtab ();
if (syms[i].symbol->line () != 0 && symtab != NULL)
{
@@ -4712,9 +4712,9 @@ cache_symbol (const char *name, domain_enum domain, struct symbol *sym,
the symbol is local or not, we check the block where we found it
against the global and static blocks of its associated symtab. */
if (sym
- && BLOCKVECTOR_BLOCK (symbol_symtab (sym)->compunit ()->blockvector (),
+ && BLOCKVECTOR_BLOCK (sym->symtab ()->compunit ()->blockvector (),
GLOBAL_BLOCK) != block
- && BLOCKVECTOR_BLOCK (symbol_symtab (sym)->compunit ()->blockvector (),
+ && BLOCKVECTOR_BLOCK (sym->symtab ()->compunit ()->blockvector (),
STATIC_BLOCK) != block)
return;
diff --git a/gdb/btrace.c b/gdb/btrace.c
index b195b59a7c3..c4f0d4911ab 100644
--- a/gdb/btrace.c
+++ b/gdb/btrace.c
@@ -102,7 +102,7 @@ ftrace_print_filename (const struct btrace_function *bfun)
sym = bfun->sym;
if (sym != NULL)
- filename = symtab_to_filename_for_display (symbol_symtab (sym));
+ filename = symtab_to_filename_for_display (sym->symtab ());
else
filename = "<unknown>";
@@ -210,8 +210,8 @@ ftrace_function_switched (const struct btrace_function *bfun,
return 1;
/* Check the location of those functions, as well. */
- bfname = symtab_to_fullname (symbol_symtab (sym));
- fname = symtab_to_fullname (symbol_symtab (fun));
+ bfname = symtab_to_fullname (sym->symtab ());
+ fname = symtab_to_fullname (fun->symtab ());
if (filename_cmp (fname, bfname) != 0)
return 1;
}
diff --git a/gdb/buildsym.c b/gdb/buildsym.c
index 628903d674f..927074b7669 100644
--- a/gdb/buildsym.c
+++ b/gdb/buildsym.c
@@ -1006,15 +1006,15 @@ buildsym_compunit::end_compunit_symtab_with_blockvector
/* Inlined functions may have symbols not in the global or
static symbol lists. */
if (BLOCK_FUNCTION (block) != NULL)
- if (symbol_symtab (BLOCK_FUNCTION (block)) == NULL)
- symbol_set_symtab (BLOCK_FUNCTION (block), symtab);
+ if (BLOCK_FUNCTION (block)->symtab () == NULL)
+ BLOCK_FUNCTION (block)->set_symtab (symtab);
/* Note that we only want to fix up symbols from the local
blocks, not blocks coming from included symtabs. That is why
we use ALL_DICT_SYMBOLS here and not ALL_BLOCK_SYMBOLS. */
ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (block), miter, sym)
- if (symbol_symtab (sym) == NULL)
- symbol_set_symtab (sym, symtab);
+ if (sym->symtab () == NULL)
+ sym->set_symtab (symtab);
}
}
@@ -1114,8 +1114,8 @@ set_missing_symtab (struct pending *pending_list,
{
for (i = 0; i < pending->nsyms; ++i)
{
- if (symbol_symtab (pending->symbol[i]) == NULL)
- symbol_set_symtab (pending->symbol[i], cu->primary_filetab ());
+ if (pending->symbol[i]->symtab () == NULL)
+ pending->symbol[i]->set_symtab (cu->primary_filetab ());
}
}
}
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 642c0be5db3..d49ecdab92f 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -57,7 +57,7 @@ convert_one_symbol (compile_c_instance *context,
int is_local)
{
gcc_type sym_type;
- const char *filename = symbol_symtab (sym.symbol)->filename;
+ const char *filename = sym.symbol->symtab ()->filename;
unsigned short line = sym.symbol->line ();
context->error_symbol_once (sym.symbol);
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index 7ad9ea91132..95d43507c30 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -48,7 +48,7 @@ convert_one_symbol (compile_cplus_instance *instance,
{
/* Squash compiler warning. */
gcc_type sym_type = 0;
- const char *filename = symbol_symtab (sym.symbol)->filename;
+ const char *filename = sym.symbol->symtab ()->filename;
unsigned short line = sym.symbol->line ();
instance->error_symbol_once (sym.symbol);
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index cea30304aa2..ab65e47f49d 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -625,7 +625,7 @@ compile_cplus_convert_struct_or_union_members
we can do but ignore this member. */
continue;
}
- const char *filename = symbol_symtab (sym.symbol)->filename;
+ const char *filename = sym.symbol->symtab ()->filename;
unsigned int line = sym.symbol->line ();
physaddr = sym.symbol->value_address ();
@@ -764,7 +764,7 @@ compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance,
continue;
}
- const char *filename = symbol_symtab (sym.symbol)->filename;
+ const char *filename = sym.symbol->symtab ()->filename;
unsigned int line = sym.symbol->line ();
CORE_ADDR address = BLOCK_START (sym.symbol->value_block ());
const char *kind;
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 7da02c07f9b..2303381b49a 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -421,7 +421,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
lookup_name_info func_matcher (GCC_FE_WRAPPER_FUNCTION,
symbol_name_match_type::SEARCH_NAME);
- bv = symbol_symtab (func_sym)->compunit ()->blockvector ();
+ bv = func_sym->symtab ()->compunit ()->blockvector ();
nblocks = BLOCKVECTOR_NBLOCKS (bv);
gdb_ptr_type_sym = NULL;
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index a4987d4996e..faf1a9ef543 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -7878,9 +7878,9 @@ fixup_go_packaging (struct dwarf2_cu *cu)
struct objfile *objfile = cu->per_objfile->objfile;
if (strcmp (package_name.get (), this_package_name.get ()) != 0)
complaint (_("Symtab %s has objects from two different Go packages: %s and %s"),
- (symbol_symtab (sym) != NULL
+ (sym->symtab () != NULL
? symtab_to_filename_for_display
- (symbol_symtab (sym))
+ (sym->symtab ())
: objfile_name (objfile)),
this_package_name.get (), package_name.get ());
}
@@ -12149,7 +12149,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
of gdb assume that symbols do, and this is reasonably
true. */
for (symbol *sym : template_args)
- symbol_set_symtab (sym, symbol_symtab (templ_func));
+ sym->set_symtab (templ_func->symtab ());
}
/* In C++, we can have functions nested inside functions (e.g., when
@@ -15045,7 +15045,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
{
struct symtab *symtab;
if (sym != nullptr)
- symtab = symbol_symtab (sym);
+ symtab = sym->symtab ();
else if (cu->line_header != nullptr)
{
/* Any related symtab will do. */
@@ -15069,7 +15069,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
other parts of gdb assume that symbols do, and this is
reasonably true. */
for (int i = 0; i < TYPE_N_TEMPLATE_ARGUMENTS (type); ++i)
- symbol_set_symtab (TYPE_TEMPLATE_ARGUMENT (type, i), symtab);
+ TYPE_TEMPLATE_ARGUMENT (type, i)->set_symtab (symtab);
}
}
}
@@ -20721,7 +20721,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
if (fe == NULL)
complaint (_("file index out of range"));
else
- symbol_set_symtab (sym, fe->symtab);
+ sym->set_symtab (fe->symtab);
}
switch (die->tag)
diff --git a/gdb/frame.c b/gdb/frame.c
index 2e574a2f009..5e3c02e2029 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2701,7 +2701,7 @@ find_frame_sal (frame_info *frame)
symtab_and_line sal;
if (sym->line () != 0)
{
- sal.symtab = symbol_symtab (sym);
+ sal.symtab = sym->symtab ();
sal.line = sym->line ();
}
else
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 9e89b0458af..55eac3cfff6 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -364,7 +364,7 @@ gdbscm_symbol_symtab (SCM self)
if (!symbol->is_objfile_owned ())
return SCM_BOOL_F;
- return stscm_scm_from_symtab (symbol_symtab (symbol));
+ return stscm_scm_from_symtab (symbol->symtab ());
}
/* (symbol-name <gdb:symbol>) -> string */
diff --git a/gdb/jit.c b/gdb/jit.c
index ae679a1f043..f7e25e494d4 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -589,7 +589,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
/* The name. */
block_name->set_domain (VAR_DOMAIN);
block_name->set_aclass_index (LOC_BLOCK);
- symbol_set_symtab (block_name, filetab);
+ block_name->set_symtab (filetab);
block_name->set_type (lookup_function_type (block_type));
block_name->set_value_block (new_block);
diff --git a/gdb/linespec.c b/gdb/linespec.c
index ba89bd09b56..61ad69dd882 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -2188,7 +2188,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
for (const auto &sym : ls->labels.label_symbols)
{
struct program_space *pspace
- = symbol_symtab (sym.symbol)->compunit ()->objfile ()->pspace;
+ = sym.symbol->symtab ()->compunit ()->objfile ()->pspace;
if (symbol_to_sal (&sal, state->funfirstline, sym.symbol)
&& maybe_add_address (state->addr_set, pspace, sal.pc))
@@ -2210,7 +2210,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls)
for (const auto &sym : ls->function_symbols)
{
program_space *pspace
- = symbol_symtab (sym.symbol)->compunit ()->objfile ()->pspace;
+ = sym.symbol->symtab ()->compunit ()->objfile ()->pspace;
set_current_program_space (pspace);
/* Don't skip to the first line of the function if we
@@ -3483,8 +3483,8 @@ compare_symbols (const block_symbol &a, const block_symbol &b)
{
uintptr_t uia, uib;
- uia = (uintptr_t) symbol_symtab (a.symbol)->compunit ()->objfile ()->pspace;
- uib = (uintptr_t) symbol_symtab (b.symbol)->compunit ()->objfile ()->pspace;
+ uia = (uintptr_t) a.symbol->symtab ()->compunit ()->objfile ()->pspace;
+ uib = (uintptr_t) b.symbol->symtab ()->compunit ()->objfile ()->pspace;
if (uia < uib)
return true;
@@ -3608,7 +3608,7 @@ find_method (struct linespec_state *self,
/* Program spaces that are executing startup should have
been filtered out earlier. */
- pspace = symbol_symtab (sym)->compunit ()->objfile ()->pspace;
+ pspace = sym->symtab ()->compunit ()->objfile ()->pspace;
gdb_assert (!pspace->executing_startup);
set_current_program_space (pspace);
t = check_typedef (sym->type ());
@@ -3619,7 +3619,7 @@ find_method (struct linespec_state *self,
sure not to miss the last batch. */
if (ix == sym_classes->size () - 1
|| (pspace
- != (symbol_symtab (sym_classes->at (ix + 1).symbol)
+ != (sym_classes->at (ix + 1).symbol->symtab ()
->compunit ()->objfile ()->pspace)))
{
/* If we did not find a direct implementation anywhere in
@@ -3985,7 +3985,7 @@ find_label_symbols (struct linespec_state *self,
{
fn_sym = elt.symbol;
set_current_program_space
- (symbol_symtab (fn_sym)->compunit ()->objfile ()->pspace);
+ (fn_sym->symtab ()->compunit ()->objfile ()->pspace);
block = fn_sym->value_block ();
find_label_symbols_in_block (block, name, fn_sym, completion_mode,
@@ -4380,7 +4380,7 @@ symbol_to_sal (struct symtab_and_line *result,
if (sym->aclass () == LOC_LABEL && sym->value_address () != 0)
{
*result = {};
- result->symtab = symbol_symtab (sym);
+ result->symtab = sym->symtab ();
result->symbol = sym;
result->line = sym->line ();
result->pc = sym->value_address ();
@@ -4396,7 +4396,7 @@ symbol_to_sal (struct symtab_and_line *result,
{
/* We know its line number. */
*result = {};
- result->symtab = symbol_symtab (sym);
+ result->symtab = sym->symtab ();
result->symbol = sym;
result->line = sym->line ();
result->pc = sym->value_address ();
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 6dcac13d2c5..7083beb01ed 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -4486,7 +4486,7 @@ mylookup_symbol (const char *name, const struct block *block,
static void
add_symbol (struct symbol *s, struct symtab *symtab, struct block *b)
{
- symbol_set_symtab (s, symtab);
+ s->set_symtab (symtab);
mdict_add_symbol (BLOCK_MULTIDICT (b), s);
}
diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c
index 60321f76796..56e9c3f3ce0 100644
--- a/gdb/mi/mi-symbol-cmds.c
+++ b/gdb/mi/mi-symbol-cmds.c
@@ -132,7 +132,7 @@ mi_symbol_info (enum search_domain kind, const char *name_regexp,
/* As long as we have debug symbols... */
while (i < symbols.size () && symbols[i].msymbol.minsym == nullptr)
{
- symtab *symtab = symbol_symtab (symbols[i].symbol);
+ symtab *symtab = symbols[i].symbol->symtab ();
ui_out_emit_tuple symtab_tuple_emitter (uiout, nullptr);
uiout->field_string ("filename",
@@ -144,7 +144,7 @@ mi_symbol_info (enum search_domain kind, const char *name_regexp,
/* As long as we have debug symbols from this symtab... */
for (; (i < symbols.size ()
&& symbols[i].msymbol.minsym == nullptr
- && symbol_symtab (symbols[i].symbol) == symtab);
+ && symbols[i].symbol->symtab () == symtab);
++i)
{
symbol_search &s = symbols[i];
@@ -256,7 +256,7 @@ output_module_symbols_in_single_module_and_file
/* The symbol for the first result, and the symtab in which it resides. */
const symbol *first_result_symbol = iter->second.symbol;
- symtab *first_symbtab = symbol_symtab (first_result_symbol);
+ symtab *first_symbtab = first_result_symbol->symtab ();
/* Formatted output. */
ui_out_emit_tuple current_file (uiout, nullptr);
@@ -269,7 +269,7 @@ output_module_symbols_in_single_module_and_file
we change module, or we change symtab. */
for (; (iter != end
&& first_module_symbol == iter->first.symbol
- && first_symbtab == symbol_symtab (iter->second.symbol));
+ && first_symbtab == iter->second.symbol->symtab ());
++iter)
output_debug_symbol (uiout, kind, iter->second.symbol,
iter->second.block);
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 5d475504fe6..414a310da64 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -91,7 +91,7 @@ sympy_get_symtab (PyObject *self, void *closure)
if (!symbol->is_objfile_owned ())
Py_RETURN_NONE;
- return symtab_to_symtab_object (symbol_symtab (symbol));
+ return symtab_to_symtab_object (symbol->symtab ());
}
static PyObject *
@@ -303,7 +303,7 @@ set_symbol (symbol_object *obj, struct symbol *symbol)
obj->symbol = symbol;
obj->prev = NULL;
if (symbol->is_objfile_owned ()
- && symbol_symtab (symbol) != NULL)
+ && symbol->symtab () != NULL)
{
struct objfile *objfile = symbol->objfile ();
@@ -349,7 +349,7 @@ sympy_dealloc (PyObject *obj)
sym_obj->prev->next = sym_obj->next;
else if (sym_obj->symbol != NULL
&& sym_obj->symbol->is_objfile_owned ()
- && symbol_symtab (sym_obj->symbol) != NULL)
+ && sym_obj->symbol->symtab () != NULL)
{
set_objfile_data (sym_obj->symbol->objfile (),
sympy_objfile_data_key, sym_obj->next);
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 7a9c8c1b66e..11aaa7ae778 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -831,7 +831,7 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw)
if (p.msymbol.minsym == NULL)
{
- struct symtab *symtab = symbol_symtab (p.symbol);
+ struct symtab *symtab = p.symbol->symtab ();
const char *fullname = symtab_to_fullname (symtab);
symbol_name = fullname;
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 1d5f839385c..373d82b8b99 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1067,7 +1067,7 @@ btrace_compute_src_line_range (const struct btrace_function *bfun,
if (sym == NULL)
goto out;
- symtab = symbol_symtab (sym);
+ symtab = sym->symtab ();
for (const btrace_insn &insn : bfun->insn)
{
@@ -1100,7 +1100,7 @@ btrace_call_history_src_line (struct ui_out *uiout,
return;
uiout->field_string ("file",
- symtab_to_filename_for_display (symbol_symtab (sym)),
+ symtab_to_filename_for_display (sym->symtab ()),
file_name_style.style ());
btrace_compute_src_line_range (bfun, &begin, &end);
diff --git a/gdb/source.c b/gdb/source.c
index 9d9ff4bbc3e..8691113c729 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -329,7 +329,7 @@ select_source_symtab (struct symtab *s)
if (sal.symtab == NULL)
/* We couldn't find the location of `main', possibly due to missing
line number info, fall back to line 1 in the corresponding file. */
- loc->set (symbol_symtab (bsym.symbol), 1);
+ loc->set (bsym.symbol->symtab (), 1);
else
loc->set (sal.symtab, std::max (sal.line - (lines_to_list - 1), 1));
return;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index d5d3877d90e..6926d1559b2 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1803,7 +1803,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
/* We either have an OBJFILE, or we can get at it from the sym's
symtab. Anything else is a bug. */
- gdb_assert (objfile || symbol_symtab (sym));
+ gdb_assert (objfile || sym->symtab ());
if (objfile == NULL)
objfile = sym->objfile ();
@@ -3940,7 +3940,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
have proven the CU (Compilation Unit) supports it. sal->SYMTAB does not
have to be set by the caller so we use SYM instead. */
if (sym != NULL
- && symbol_symtab (sym)->compunit ()->locations_valid ())
+ && sym->symtab ()->compunit ()->locations_valid ())
force_skip = 0;
saved_pc = pc;
@@ -4020,7 +4020,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
is aligned. */
if (!force_skip && sym && start_sal.symtab == NULL)
{
- pc = skip_prologue_using_lineinfo (pc, symbol_symtab (sym));
+ pc = skip_prologue_using_lineinfo (pc, sym->symtab ());
/* Recalculate the line number. */
start_sal = find_pc_sect_line (pc, section, 0);
}
@@ -4052,7 +4052,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
&& BLOCK_FUNCTION (function_block)->line () != 0)
{
sal->line = BLOCK_FUNCTION (function_block)->line ();
- sal->symtab = symbol_symtab (BLOCK_FUNCTION (function_block));
+ sal->symtab = BLOCK_FUNCTION (function_block)->symtab ();
}
}
@@ -4692,8 +4692,8 @@ symbol_search::compare_search_syms (const symbol_search &sym_a,
{
int c;
- c = FILENAME_CMP (symbol_symtab (sym_a.symbol)->filename,
- symbol_symtab (sym_b.symbol)->filename);
+ c = FILENAME_CMP (sym_a.symbol->symtab ()->filename,
+ sym_b.symbol->symtab ()->filename);
if (c != 0)
return c;
@@ -4873,7 +4873,7 @@ global_symbol_searcher::add_matching_symbols
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
- struct symtab *real_symtab = symbol_symtab (sym);
+ struct symtab *real_symtab = sym->symtab ();
QUIT;
@@ -5146,7 +5146,7 @@ print_symbol_info (enum search_domain kind,
int block, const char *last)
{
scoped_switch_to_sym_language_if_auto l (sym);
- struct symtab *s = symbol_symtab (sym);
+ struct symtab *s = sym->symtab ();
if (last != NULL)
{
@@ -5266,7 +5266,7 @@ symtab_symbol_info (bool quiet, bool exclude_minsyms,
p.block,
last_filename);
last_filename
- = symtab_to_filename_for_display (symbol_symtab (p.symbol));
+ = symtab_to_filename_for_display (p.symbol->symtab ());
}
}
}
@@ -5486,7 +5486,7 @@ rbreak_command (const char *regexp, int from_tty)
{
if (p.msymbol.minsym == NULL)
{
- struct symtab *symtab = symbol_symtab (p.symbol);
+ struct symtab *symtab = p.symbol->symtab ();
const char *fullname = symtab_to_fullname (symtab);
string = string_printf ("%s:'%s'", fullname,
@@ -6612,19 +6612,19 @@ symbol::arch () const
/* See symtab.h. */
struct symtab *
-symbol_symtab (const struct symbol *symbol)
+symbol::symtab () const
{
- gdb_assert (symbol->is_objfile_owned ());
- return symbol->owner.symtab;
+ gdb_assert (is_objfile_owned ());
+ return owner.symtab;
}
/* See symtab.h. */
void
-symbol_set_symtab (struct symbol *symbol, struct symtab *symtab)
+symbol::set_symtab (struct symtab *symtab)
{
- gdb_assert (symbol->is_objfile_owned ());
- symbol->owner.symtab = symtab;
+ gdb_assert (is_objfile_owned ());
+ owner.symtab = symtab;
}
/* See symtab.h. */
@@ -6870,7 +6870,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
print_symbol_info (FUNCTIONS_DOMAIN, q.symbol, q.block,
last_filename);
last_filename
- = symtab_to_filename_for_display (symbol_symtab (q.symbol));
+ = symtab_to_filename_for_display (q.symbol->symtab ());
}
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 09335ef9a91..645348fc6b2 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1386,6 +1386,18 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
struct gdbarch *arch () const;
+ /* Return the SYMTAB of this SYMBOL. It is an error to call this if
+ is_objfile_owned is false, which only happens for
+ architecture-provided types. */
+
+ struct symtab *symtab () const;
+
+ /* Set the symtab of this symbol to SYMTAB. It is an error to call
+ this if is_objfile_owned is false, which only happens for
+ architecture-provided types. */
+
+ void set_symtab (struct symtab *symtab);
+
/* Data type of value */
struct type *m_type = nullptr;
@@ -1502,18 +1514,6 @@ extern int register_symbol_block_impl (enum address_class aclass,
extern int register_symbol_register_impl (enum address_class,
const struct symbol_register_ops *);
-/* Return the SYMTAB of SYMBOL.
- It is an error to call this if symbol.is_objfile_owned is false, which
- only happens for architecture-provided types. */
-
-extern struct symtab *symbol_symtab (const struct symbol *symbol);
-
-/* Set the symtab of SYMBOL to SYMTAB.
- It is an error to call this if symbol.is_objfile_owned is false, which
- only happens for architecture-provided types. */
-
-extern void symbol_set_symtab (struct symbol *symbol, struct symtab *symtab);
-
/* An instance of this type is used to represent a C++ template
function. A symbol is really of this type iff
symbol::is_cplus_template_function is true. */
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/6] Add accessors for symbol's artificial field
2022-04-20 14:50 ` [PATCH 1/6] Add accessors for symbol's artificial field Tom Tromey
@ 2022-04-20 15:15 ` Simon Marchi
2022-04-20 15:20 ` Tom Tromey
0 siblings, 1 reply; 11+ messages in thread
From: Simon Marchi @ 2022-04-20 15:15 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
> @@ -1369,6 +1369,18 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
> m_value.chain = sym;
> }
>
> + /* Return true if this symbol was marked as artificial. */
> + bool artificial () const
> + {
> + return m_artificial;
> + }
> +
> + /* Set the 'artificial' flag on this symbol. */
> + void set_artificial (bool artificial)
> + {
> + m_artificial = artificial;
> + }
Since this is a boolean / flag, I would name those "is_artificial" and
"set_is_artificial". To follow GDB's conventions it should probably be
"artificial_p", but I always found this scheme awkward to read (vs
is_foo, which just reads like plain english).
LGTM in any case.
Simon
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 6/6] Replace symbol_symtab with symbol::symtab
2022-04-20 14:50 ` [PATCH 6/6] Replace symbol_symtab with symbol::symtab Tom Tromey
@ 2022-04-20 15:20 ` Simon Marchi
2022-04-20 15:29 ` Tom Tromey
0 siblings, 1 reply; 11+ messages in thread
From: Simon Marchi @ 2022-04-20 15:20 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
> diff --git a/gdb/symtab.h b/gdb/symtab.h
> index 09335ef9a91..645348fc6b2 100644
> --- a/gdb/symtab.h
> +++ b/gdb/symtab.h
> @@ -1386,6 +1386,18 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
>
> struct gdbarch *arch () const;
>
> + /* Return the SYMTAB of this SYMBOL. It is an error to call this if
I think "symtab" should not be capitalized here.
Otherwise, this all LGTM (including previous patches).
Simon
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/6] Add accessors for symbol's artificial field
2022-04-20 15:15 ` Simon Marchi
@ 2022-04-20 15:20 ` Tom Tromey
0 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2022-04-20 15:20 UTC (permalink / raw)
To: Simon Marchi; +Cc: Tom Tromey, gdb-patches
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
Simon> Since this is a boolean / flag, I would name those "is_artificial" and
Simon> "set_is_artificial". To follow GDB's conventions it should probably be
Simon> "artificial_p", but I always found this scheme awkward to read (vs
Simon> is_foo, which just reads like plain english).
I'll make the change.
I like the _p form for nostalgic reasons -- it's derived from Lisp, the
actually fun language -- but I tend to agree now that we should keep
things more accessible.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 6/6] Replace symbol_symtab with symbol::symtab
2022-04-20 15:20 ` Simon Marchi
@ 2022-04-20 15:29 ` Tom Tromey
0 siblings, 0 replies; 11+ messages in thread
From: Tom Tromey @ 2022-04-20 15:29 UTC (permalink / raw)
To: Simon Marchi; +Cc: Tom Tromey, gdb-patches
>> + /* Return the SYMTAB of this SYMBOL. It is an error to call this if
Simon> I think "symtab" should not be capitalized here.
Yeah, neither word there ought to be. I fixed this.
Simon> Otherwise, this all LGTM (including previous patches).
Thanks. I'm rebuilding to make sure I did the is_artificial renaming
correctly, then I'm going to check it in.
Tom
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2022-04-20 15:29 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-20 14:50 [PATCH 0/6] More symbol methods Tom Tromey
2022-04-20 14:50 ` [PATCH 1/6] Add accessors for symbol's artificial field Tom Tromey
2022-04-20 15:15 ` Simon Marchi
2022-04-20 15:20 ` Tom Tromey
2022-04-20 14:50 ` [PATCH 2/6] Use array_view for symbol_impls Tom Tromey
2022-04-20 14:50 ` [PATCH 3/6] Remove symbol::aclass_index Tom Tromey
2022-04-20 14:50 ` [PATCH 4/6] Replace symbol_objfile with symbol::objfile Tom Tromey
2022-04-20 14:50 ` [PATCH 5/6] Replace symbol_arch with symbol::arch Tom Tromey
2022-04-20 14:50 ` [PATCH 6/6] Replace symbol_symtab with symbol::symtab Tom Tromey
2022-04-20 15:20 ` Simon Marchi
2022-04-20 15:29 ` Tom Tromey
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).