diff options
author | Pedro Alves <palves@redhat.com> | 2017-09-04 17:10:13 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-09-04 17:11:45 +0100 |
commit | 51abb421302bdd86946827727aebc878b5c756e3 (patch) | |
tree | a858a4e92e66d7dd3e4e196215a422b8756f9e10 /gdb/symtab.c | |
parent | 6c5b2ebeacc2538cf342cfd13c4c98ff018e6c9a (diff) | |
download | gdb-51abb421302bdd86946827727aebc878b5c756e3.zip gdb-51abb421302bdd86946827727aebc878b5c756e3.tar.gz gdb-51abb421302bdd86946827727aebc878b5c756e3.tar.bz2 |
Kill init_sal
Instead, make symtab_and_line initialize its members itself. Many
symtab_and_line declarations are moved to where the object is
initialized at the same time both for clarity and to avoid double
initialization. A few functions, like e.g., find_frame_sal are
adjusted to return the sal using normal function return instead of an
output parameter likewise to avoid having to default-construct a sal
and then immediately have the object overwritten.
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* ada-lang.c (is_known_support_routine): Move sal declaration to
where it is initialized.
* breakpoint.c (create_internal_breakpoint, init_catchpoint)
(parse_breakpoint_sals, decode_static_tracepoint_spec)
(clear_command, update_static_tracepoint): Remove init_sal
references. Move declarations closer to initializations.
* cli/cli-cmds.c (list_command): Move sal declarations closer to
initializations.
* elfread.c (elf_gnu_ifunc_resolver_stop): Remove init_sal
references. Move sal declarations closer to initializations.
* frame.c (find_frame_sal): Return a symtab_and_line via function
return instead of output parameter. Remove init_sal references.
* frame.h (find_frame_sal): Return a symtab_and_line via function
return instead of output parameter.
* guile/scm-frame.c (gdbscm_frame_sal): Adjust.
* guile/scm-symtab.c (stscm_make_sal_smob): Use in-place new
instead of memset.
(gdbscm_find_pc_line): Remove init_sal reference.
* infcall.c (call_function_by_hand_dummy): Remove init_sal
references. Move declarations closer to initializations.
* infcmd.c (set_step_frame): Update. Move declarations closer to
initializations.
(finish_backward): Remove init_sal references. Move declarations
closer to initializations.
* infrun.c (process_event_stop_test, handle_step_into_function)
(insert_hp_step_resume_breakpoint_at_frame)
(insert_step_resume_breakpoint_at_caller): Likewise.
* linespec.c (create_sals_line_offset, decode_digits_ordinary)
(symbol_to_sal): Likewise.
* probe.c (parse_probes_in_pspace): Remove init_sal reference.
* python/py-frame.c (frapy_find_sal): Move sal declaration closer
to its initialization.
* reverse.c (save_bookmark_command): Use new/delete. Remove
init_sal references. Move declarations closer to initializations.
* source.c (get_current_source_symtab_and_line): Remove brace
initialization.
(set_current_source_symtab_and_line): Now takes the sal by const
reference. Remove brace initialization.
(line_info): Remove init_sal reference.
* source.h (set_current_source_symtab_and_line): Now takes a
symtab_and_line via const reference.
* stack.c (set_current_sal_from_frame): Adjust.
(print_frame_info): Adjust.
(get_last_displayed_sal): Return the sal via function return
instead of via output parameter. Simplify.
(frame_info): Adjust.
* stack.h (get_last_displayed_sal): Return the sal via function
return instead of via output parameter.
* symtab.c (init_sal): Delete.
(find_pc_sect_line): Remove init_sal references. Move
declarations closer to initializations.
(find_function_start_sal): Remove init_sal references. Move
declarations closer to initializations.
* symtab.h (struct symtab_and_line): In-class initialize all
fields.
* tracepoint.c (set_traceframe_context)
(print_one_static_tracepoint_marker): Remove init_sal references.
Move declarations closer to initializations.
* tui/tui-disasm.c (tui_show_disassem_and_update_source): Adjust.
* tui/tui-stack.c (tui_show_frame_info): Adjust. Move
declarations closer to initializations.
* tui/tui-winsource.c (tui_update_source_window_as_is): Remove
init_sal references. Adjust.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r-- | gdb/symtab.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index 7ea03d4..8492315 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -947,14 +947,6 @@ symbol_search_name (const struct general_symbol_info *gsymbol) else return symbol_natural_name (gsymbol); } - -/* Initialize the structure fields to zero values. */ - -void -init_sal (struct symtab_and_line *sal) -{ - memset (sal, 0, sizeof (*sal)); -} /* Return 1 if the two sections are the same, or if they could @@ -2938,7 +2930,6 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) int len; int i; struct linetable_entry *item; - struct symtab_and_line val; const struct blockvector *bv; struct bound_minimal_symbol msymbol; @@ -2965,10 +2956,6 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) But what we want is the statement containing the instruction. Fudge the pc to make sure we get that. */ - init_sal (&val); /* initialize to zeroes */ - - val.pspace = current_program_space; - /* It's tempting to assume that, if we can't find debugging info for any function enclosing PC, that we shouldn't search for line number info, either. However, GAS can emit line number info for @@ -3057,6 +3044,8 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent) return find_pc_line (BMSYMBOL_VALUE_ADDRESS (mfunsym), 0); } + symtab_and_line val; + val.pspace = current_program_space; cust = find_pc_sect_compunit_symtab (pc, section); if (cust == NULL) @@ -3469,12 +3458,11 @@ find_pc_line_pc_range (CORE_ADDR pc, CORE_ADDR *startptr, CORE_ADDR *endptr) struct symtab_and_line find_function_start_sal (struct symbol *sym, int funfirstline) { - struct symtab_and_line sal; - struct obj_section *section; - fixup_symbol_section (sym, NULL); - section = SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym); - sal = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), section, 0); + + obj_section *section = SYMBOL_OBJ_SECTION (symbol_objfile (sym), sym); + symtab_and_line sal + = find_pc_sect_line (BLOCK_START (SYMBOL_BLOCK_VALUE (sym)), section, 0); if (funfirstline && sal.symtab != NULL && (COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab)) @@ -3494,7 +3482,7 @@ find_function_start_sal (struct symbol *sym, int funfirstline) can find a line number for after the prologue. */ if (sal.pc < BLOCK_START (SYMBOL_BLOCK_VALUE (sym))) { - init_sal (&sal); + sal = {}; sal.pspace = current_program_space; sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); sal.section = section; |