[PATCH 33/33] gdb: remove SYMBOL_LINE macro
Simon Marchi
simon.marchi@polymtl.ca
Fri Jan 28 12:45:31 GMT 2022
From: Simon Marchi <simon.marchi@efficios.com>
Add a getter and a setter for a symbol's line. Remove the corresponding macro
and adjust all callers.
Change-Id: I229f2b8fcf938c07975f641361313a8761fad9a5
---
gdb/ada-lang.c | 4 ++--
gdb/compile/compile-c-symbols.c | 2 +-
gdb/compile/compile-cplus-symbols.c | 2 +-
gdb/compile/compile-cplus-types.c | 4 ++--
gdb/dwarf2/read.c | 2 +-
gdb/frame.c | 4 ++--
gdb/guile/scm-symbol.c | 2 +-
gdb/linespec.c | 6 +++---
gdb/mi/mi-symbol-cmds.c | 4 ++--
gdb/python/py-symbol.c | 2 +-
gdb/stabsread.c | 4 ++--
gdb/symtab.c | 10 +++++-----
gdb/symtab.h | 13 +++++++++++--
13 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index fbeb176d5668..0dd83cda8e5a 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3355,14 +3355,14 @@ See set/show multiple-symbol."));
if (syms[i].symbol->is_objfile_owned ())
symtab = symbol_symtab (syms[i].symbol);
- if (SYMBOL_LINE (syms[i].symbol) != 0 && symtab != NULL)
+ if (syms[i].symbol->line () != 0 && symtab != NULL)
{
printf_filtered ("[%d] ", i + first_choice);
ada_print_symbol_signature (gdb_stdout, syms[i].symbol,
&type_print_raw_options);
printf_filtered (_(" at %s:%d\n"),
symtab_to_filename_for_display (symtab),
- SYMBOL_LINE (syms[i].symbol));
+ syms[i].symbol->line ());
}
else if (is_enumeral
&& syms[i].symbol->type ()->name () != NULL)
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 4f7a5b22da51..bb156024ffa1 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -58,7 +58,7 @@ convert_one_symbol (compile_c_instance *context,
{
gcc_type sym_type;
const char *filename = symbol_symtab (sym.symbol)->filename;
- unsigned short line = SYMBOL_LINE (sym.symbol);
+ 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 7cf5703dc71d..33febaccdfd8 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -49,7 +49,7 @@ convert_one_symbol (compile_cplus_instance *instance,
/* Squash compiler warning. */
gcc_type sym_type = 0;
const char *filename = symbol_symtab (sym.symbol)->filename;
- unsigned short line = SYMBOL_LINE (sym.symbol);
+ 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 198799669865..f0ac05f4f2aa 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -626,7 +626,7 @@ compile_cplus_convert_struct_or_union_members
continue;
}
const char *filename = symbol_symtab (sym.symbol)->filename;
- unsigned int line = SYMBOL_LINE (sym.symbol);
+ unsigned int line = sym.symbol->line ();
physaddr = SYMBOL_VALUE_ADDRESS (sym.symbol);
instance->plugin ().build_decl
@@ -765,7 +765,7 @@ compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance,
}
const char *filename = symbol_symtab (sym.symbol)->filename;
- unsigned int line = SYMBOL_LINE (sym.symbol);
+ unsigned int line = sym.symbol->line ();
CORE_ADDR address = BLOCK_START (SYMBOL_BLOCK_VALUE (sym.symbol));
const char *kind;
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 3a22bcdd43d8..c063e7baa2b5 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -21727,7 +21727,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
inlined_func ? DW_AT_call_line : DW_AT_decl_line,
cu);
if (attr != nullptr)
- SYMBOL_LINE (sym) = attr->constant_value (0);
+ sym->set_line (attr->constant_value (0));
attr = dwarf2_attr (die,
inlined_func ? DW_AT_call_file : DW_AT_decl_file,
diff --git a/gdb/frame.c b/gdb/frame.c
index 6e2f6b245a25..ce95cf8343bc 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2699,10 +2699,10 @@ find_frame_sal (frame_info *frame)
gdb_assert (sym);
symtab_and_line sal;
- if (SYMBOL_LINE (sym) != 0)
+ if (sym->line () != 0)
{
sal.symtab = symbol_symtab (sym);
- sal.line = SYMBOL_LINE (sym);
+ sal.line = sym->line ();
}
else
/* If the symbol does not have a location, we don't know where
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 4c28603fa636..dbe19865d4e2 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -510,7 +510,7 @@ gdbscm_symbol_line (SCM self)
= syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct symbol *symbol = s_smob->symbol;
- return scm_from_int (SYMBOL_LINE (symbol));
+ return scm_from_int (symbol->line ());
}
/* (symbol-value <gdb:symbol> [#:frame <gdb:frame>]) -> <gdb:value>
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 1775c7c48f3e..b7b24f7d97a3 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -4451,7 +4451,7 @@ symbol_to_sal (struct symtab_and_line *result,
*result = {};
result->symtab = symbol_symtab (sym);
result->symbol = sym;
- result->line = SYMBOL_LINE (sym);
+ result->line = sym->line ();
result->pc = SYMBOL_VALUE_ADDRESS (sym);
result->pspace = result->symtab->pspace ();
result->explicit_pc = 1;
@@ -4461,13 +4461,13 @@ symbol_to_sal (struct symtab_and_line *result,
{
/* Nothing. */
}
- else if (SYMBOL_LINE (sym) != 0)
+ else if (sym->line () != 0)
{
/* We know its line number. */
*result = {};
result->symtab = symbol_symtab (sym);
result->symbol = sym;
- result->line = SYMBOL_LINE (sym);
+ result->line = sym->line ();
result->pc = SYMBOL_VALUE_ADDRESS (sym);
result->pspace = result->symtab->pspace ();
return 1;
diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c
index 6ed26d69269d..1b08854296c0 100644
--- a/gdb/mi/mi-symbol-cmds.c
+++ b/gdb/mi/mi-symbol-cmds.c
@@ -74,8 +74,8 @@ output_debug_symbol (ui_out *uiout, enum search_domain kind,
{
ui_out_emit_tuple tuple_emitter (uiout, NULL);
- if (SYMBOL_LINE (sym) != 0)
- uiout->field_unsigned ("line", SYMBOL_LINE (sym));
+ if (sym->line () != 0)
+ uiout->field_unsigned ("line", sym->line ());
uiout->field_string ("name", sym->print_name ());
if (kind == FUNCTIONS_DOMAIN || kind == VARIABLES_DOMAIN)
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 747da481a1bf..819a51f7e414 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -221,7 +221,7 @@ sympy_line (PyObject *self, void *closure)
SYMPY_REQUIRE_VALID (self, symbol);
- return gdb_py_object_from_longest (SYMBOL_LINE (symbol)).release ();
+ return gdb_py_object_from_longest (symbol->line ()).release ();
}
/* Implementation of gdb.Symbol.is_valid (self) -> Boolean.
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index d3a1ae990691..c6821f893cbd 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -693,11 +693,11 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
{
/* GCC 2.x puts the line number in desc. SunOS apparently puts in the
number of bytes occupied by a type or object, which we ignore. */
- SYMBOL_LINE (sym) = desc;
+ sym->set_line (desc);
}
else
{
- SYMBOL_LINE (sym) = 0; /* unknown */
+ sym->set_line (0); /* unknown */
}
sym->set_language (get_current_subfile ()->language,
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 8da86b613595..1a39372aad02 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3987,9 +3987,9 @@ skip_prologue_sal (struct symtab_and_line *sal)
b = BLOCK_SUPERBLOCK (b);
}
if (function_block != NULL
- && SYMBOL_LINE (BLOCK_FUNCTION (function_block)) != 0)
+ && BLOCK_FUNCTION (function_block)->line () != 0)
{
- sal->line = SYMBOL_LINE (BLOCK_FUNCTION (function_block));
+ sal->line = BLOCK_FUNCTION (function_block)->line ();
sal->symtab = symbol_symtab (BLOCK_FUNCTION (function_block));
}
}
@@ -4850,7 +4850,7 @@ global_symbol_searcher::add_matching_symbols
&& sym->domain () != MODULE_DOMAIN)
|| (kind == MODULES_DOMAIN
&& sym->domain () == MODULE_DOMAIN
- && SYMBOL_LINE (sym) != 0))))
+ && sym->line () != 0))))
{
if (result_set->size () < m_max_search_results)
{
@@ -5098,8 +5098,8 @@ print_symbol_info (enum search_domain kind,
s_filename));
}
- if (SYMBOL_LINE (sym) != 0)
- printf_filtered ("%d:\t", SYMBOL_LINE (sym));
+ if (sym->line () != 0)
+ printf_filtered ("%d:\t", sym->line ());
else
puts_filtered ("\t");
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 3486803cca8e..d12eee6e9d8c 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1213,6 +1213,16 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
m_type = type;
}
+ unsigned short line () const
+ {
+ return m_line;
+ }
+
+ void set_line (unsigned short line)
+ {
+ m_line = line;
+ }
+
/* Data type of value */
struct type *m_type = nullptr;
@@ -1280,7 +1290,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
to debug files longer than 64K lines? What about machine
generated programs? */
- unsigned short line = 0;
+ unsigned short m_line = 0;
/* An arbitrary data pointer, allowing symbol readers to record
additional information on a per-symbol basis. Note that this data
@@ -1315,7 +1325,6 @@ struct block_symbol
/* Note: There is no accessor macro for symbol.owner because it is
"private". */
-#define SYMBOL_LINE(symbol) (symbol)->line
#define SYMBOL_COMPUTED_OPS(symbol) ((symbol)->impl ().ops_computed)
#define SYMBOL_BLOCK_OPS(symbol) ((symbol)->impl ().ops_block)
#define SYMBOL_REGISTER_OPS(symbol) ((symbol)->impl ().ops_register)
--
2.34.1
More information about the Gdb-patches
mailing list