gdb: remove SYMBOL_LINE macro

Add a getter and a setter for a symbol's line.  Remove the corresponding macro
and adjust all callers.

Change-Id: I229f2b8fcf938c07975f641361313a8761fad9a5
This commit is contained in:
Simon Marchi
2022-01-27 22:39:50 -05:00
parent 5f9c5a63ce
commit 5d0027b9ba
13 changed files with 34 additions and 25 deletions

View File

@@ -3355,14 +3355,14 @@ See set/show multiple-symbol."));
if (syms[i].symbol->is_objfile_owned ()) if (syms[i].symbol->is_objfile_owned ())
symtab = symbol_symtab (syms[i].symbol); 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); printf_filtered ("[%d] ", i + first_choice);
ada_print_symbol_signature (gdb_stdout, syms[i].symbol, ada_print_symbol_signature (gdb_stdout, syms[i].symbol,
&type_print_raw_options); &type_print_raw_options);
printf_filtered (_(" at %s:%d\n"), printf_filtered (_(" at %s:%d\n"),
symtab_to_filename_for_display (symtab), symtab_to_filename_for_display (symtab),
SYMBOL_LINE (syms[i].symbol)); syms[i].symbol->line ());
} }
else if (is_enumeral else if (is_enumeral
&& syms[i].symbol->type ()->name () != NULL) && syms[i].symbol->type ()->name () != NULL)

View File

@@ -58,7 +58,7 @@ convert_one_symbol (compile_c_instance *context,
{ {
gcc_type sym_type; gcc_type sym_type;
const char *filename = symbol_symtab (sym.symbol)->filename; 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); context->error_symbol_once (sym.symbol);

View File

@@ -49,7 +49,7 @@ convert_one_symbol (compile_cplus_instance *instance,
/* Squash compiler warning. */ /* Squash compiler warning. */
gcc_type sym_type = 0; gcc_type sym_type = 0;
const char *filename = symbol_symtab (sym.symbol)->filename; 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); instance->error_symbol_once (sym.symbol);

View File

@@ -626,7 +626,7 @@ compile_cplus_convert_struct_or_union_members
continue; continue;
} }
const char *filename = symbol_symtab (sym.symbol)->filename; 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); physaddr = SYMBOL_VALUE_ADDRESS (sym.symbol);
instance->plugin ().build_decl 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; 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)); CORE_ADDR address = BLOCK_START (SYMBOL_BLOCK_VALUE (sym.symbol));
const char *kind; const char *kind;

View File

@@ -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, inlined_func ? DW_AT_call_line : DW_AT_decl_line,
cu); cu);
if (attr != nullptr) if (attr != nullptr)
SYMBOL_LINE (sym) = attr->constant_value (0); sym->set_line (attr->constant_value (0));
attr = dwarf2_attr (die, attr = dwarf2_attr (die,
inlined_func ? DW_AT_call_file : DW_AT_decl_file, inlined_func ? DW_AT_call_file : DW_AT_decl_file,

View File

@@ -2699,10 +2699,10 @@ find_frame_sal (frame_info *frame)
gdb_assert (sym); gdb_assert (sym);
symtab_and_line sal; symtab_and_line sal;
if (SYMBOL_LINE (sym) != 0) if (sym->line () != 0)
{ {
sal.symtab = symbol_symtab (sym); sal.symtab = symbol_symtab (sym);
sal.line = SYMBOL_LINE (sym); sal.line = sym->line ();
} }
else else
/* If the symbol does not have a location, we don't know where /* If the symbol does not have a location, we don't know where

View File

@@ -510,7 +510,7 @@ gdbscm_symbol_line (SCM self)
= syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); = syscm_get_valid_symbol_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
const struct symbol *symbol = s_smob->symbol; 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> /* (symbol-value <gdb:symbol> [#:frame <gdb:frame>]) -> <gdb:value>

View File

@@ -4451,7 +4451,7 @@ symbol_to_sal (struct symtab_and_line *result,
*result = {}; *result = {};
result->symtab = symbol_symtab (sym); result->symtab = symbol_symtab (sym);
result->symbol = sym; result->symbol = sym;
result->line = SYMBOL_LINE (sym); result->line = sym->line ();
result->pc = SYMBOL_VALUE_ADDRESS (sym); result->pc = SYMBOL_VALUE_ADDRESS (sym);
result->pspace = result->symtab->pspace (); result->pspace = result->symtab->pspace ();
result->explicit_pc = 1; result->explicit_pc = 1;
@@ -4461,13 +4461,13 @@ symbol_to_sal (struct symtab_and_line *result,
{ {
/* Nothing. */ /* Nothing. */
} }
else if (SYMBOL_LINE (sym) != 0) else if (sym->line () != 0)
{ {
/* We know its line number. */ /* We know its line number. */
*result = {}; *result = {};
result->symtab = symbol_symtab (sym); result->symtab = symbol_symtab (sym);
result->symbol = sym; result->symbol = sym;
result->line = SYMBOL_LINE (sym); result->line = sym->line ();
result->pc = SYMBOL_VALUE_ADDRESS (sym); result->pc = SYMBOL_VALUE_ADDRESS (sym);
result->pspace = result->symtab->pspace (); result->pspace = result->symtab->pspace ();
return 1; return 1;

View File

@@ -74,8 +74,8 @@ output_debug_symbol (ui_out *uiout, enum search_domain kind,
{ {
ui_out_emit_tuple tuple_emitter (uiout, NULL); ui_out_emit_tuple tuple_emitter (uiout, NULL);
if (SYMBOL_LINE (sym) != 0) if (sym->line () != 0)
uiout->field_unsigned ("line", SYMBOL_LINE (sym)); uiout->field_unsigned ("line", sym->line ());
uiout->field_string ("name", sym->print_name ()); uiout->field_string ("name", sym->print_name ());
if (kind == FUNCTIONS_DOMAIN || kind == VARIABLES_DOMAIN) if (kind == FUNCTIONS_DOMAIN || kind == VARIABLES_DOMAIN)

View File

@@ -221,7 +221,7 @@ sympy_line (PyObject *self, void *closure)
SYMPY_REQUIRE_VALID (self, symbol); 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. /* Implementation of gdb.Symbol.is_valid (self) -> Boolean.

View File

@@ -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 /* 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. */ number of bytes occupied by a type or object, which we ignore. */
SYMBOL_LINE (sym) = desc; sym->set_line (desc);
} }
else else
{ {
SYMBOL_LINE (sym) = 0; /* unknown */ sym->set_line (0); /* unknown */
} }
sym->set_language (get_current_subfile ()->language, sym->set_language (get_current_subfile ()->language,

View File

@@ -3987,9 +3987,9 @@ skip_prologue_sal (struct symtab_and_line *sal)
b = BLOCK_SUPERBLOCK (b); b = BLOCK_SUPERBLOCK (b);
} }
if (function_block != NULL 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)); sal->symtab = symbol_symtab (BLOCK_FUNCTION (function_block));
} }
} }
@@ -4850,7 +4850,7 @@ global_symbol_searcher::add_matching_symbols
&& sym->domain () != MODULE_DOMAIN) && sym->domain () != MODULE_DOMAIN)
|| (kind == MODULES_DOMAIN || (kind == MODULES_DOMAIN
&& sym->domain () == MODULE_DOMAIN && sym->domain () == MODULE_DOMAIN
&& SYMBOL_LINE (sym) != 0)))) && sym->line () != 0))))
{ {
if (result_set->size () < m_max_search_results) if (result_set->size () < m_max_search_results)
{ {
@@ -5098,8 +5098,8 @@ print_symbol_info (enum search_domain kind,
s_filename)); s_filename));
} }
if (SYMBOL_LINE (sym) != 0) if (sym->line () != 0)
printf_filtered ("%d:\t", SYMBOL_LINE (sym)); printf_filtered ("%d:\t", sym->line ());
else else
puts_filtered ("\t"); puts_filtered ("\t");
} }

View File

@@ -1213,6 +1213,16 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
m_type = type; m_type = type;
} }
unsigned short line () const
{
return m_line;
}
void set_line (unsigned short line)
{
m_line = line;
}
/* Data type of value */ /* Data type of value */
struct type *m_type = nullptr; 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 to debug files longer than 64K lines? What about machine
generated programs? */ generated programs? */
unsigned short line = 0; unsigned short m_line = 0;
/* An arbitrary data pointer, allowing symbol readers to record /* An arbitrary data pointer, allowing symbol readers to record
additional information on a per-symbol basis. Note that this data 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 /* Note: There is no accessor macro for symbol.owner because it is
"private". */ "private". */
#define SYMBOL_LINE(symbol) (symbol)->line
#define SYMBOL_COMPUTED_OPS(symbol) ((symbol)->impl ().ops_computed) #define SYMBOL_COMPUTED_OPS(symbol) ((symbol)->impl ().ops_computed)
#define SYMBOL_BLOCK_OPS(symbol) ((symbol)->impl ().ops_block) #define SYMBOL_BLOCK_OPS(symbol) ((symbol)->impl ().ops_block)
#define SYMBOL_REGISTER_OPS(symbol) ((symbol)->impl ().ops_register) #define SYMBOL_REGISTER_OPS(symbol) ((symbol)->impl ().ops_register)