diff options
author | Pedro Alves <pedro@palves.net> | 2022-05-27 13:13:41 +0100 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2022-06-17 09:55:39 +0100 |
commit | 40d97ee21fc3e39db73ee8f84b847a22f9d251cc (patch) | |
tree | 13d9f949b41d4550d1a8ba18333ed5bd4244bdfc /gdb/breakpoint.c | |
parent | 264f98902f27497f7494933628b0f5c4e117fe59 (diff) | |
download | binutils-40d97ee21fc3e39db73ee8f84b847a22f9d251cc.zip binutils-40d97ee21fc3e39db73ee8f84b847a22f9d251cc.tar.gz binutils-40d97ee21fc3e39db73ee8f84b847a22f9d251cc.tar.bz2 |
Eliminate the two-level data structures behind location_specs
Currently, there's the location_spec hierarchy, and then some
location_spec subclasses have their own struct type holding all their
data fields.
I.e., there is this:
location_spec
explicit_location_spec
linespec_location_spec
address_location_spec
probe_location_spec
and then these separate types:
explicit_location
linespec_location
where:
explicit_location_spec
has-a explicit_location
linespec_location_spec
has-a linespec_location
This patch eliminates explicit_location and linespec_location,
inlining their members in the corresponding location_spec type.
The location_spec subclasses were the ones currently defined in
location.c, so they are moved to the header. Since the definitions of
the classes are now visible, we no longer need location_spec_deleter.
Some constructors that are used for cloning location_specs, like:
explicit explicit_location_spec (const struct explicit_location *loc)
... were converted to proper copy ctors.
In the process, initialize_explicit_location is eliminated, and some
functions that returned the "data type behind a locspec", like
get_linespec_location are converted to downcast functions, like
as_linespec_location_spec.
Change-Id: Ia31ccef9382b25a52b00fa878c8df9b8cf2a6c5a
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r-- | gdb/breakpoint.c | 44 |
1 files changed, 16 insertions, 28 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ab88a38..82937a3 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3364,7 +3364,6 @@ create_overlay_event_breakpoint (void) struct breakpoint *b; struct breakpoint_objfile_data *bp_objfile_data; CORE_ADDR addr; - struct explicit_location explicit_loc; bp_objfile_data = get_breakpoint_objfile_data (objfile); @@ -3388,9 +3387,7 @@ create_overlay_event_breakpoint (void) addr = bp_objfile_data->overlay_msym.value_address (); b = create_internal_breakpoint (objfile->arch (), addr, bp_overlay_event); - initialize_explicit_location (&explicit_loc); - explicit_loc.function_name = ASTRDUP (func_name); - b->locspec = new_explicit_location_spec (&explicit_loc); + b->locspec = new_explicit_location_spec_function (func_name); if (overlay_debugging == ovly_auto) { @@ -3473,7 +3470,6 @@ create_longjmp_master_breakpoint_names (objfile *objfile) struct breakpoint *b; const char *func_name; CORE_ADDR addr; - struct explicit_location explicit_loc; if (msym_not_found_p (bp_objfile_data->longjmp_msym[i].minsym)) continue; @@ -3495,9 +3491,7 @@ create_longjmp_master_breakpoint_names (objfile *objfile) addr = bp_objfile_data->longjmp_msym[i].value_address (); b = create_internal_breakpoint (gdbarch, addr, bp_longjmp_master); - initialize_explicit_location (&explicit_loc); - explicit_loc.function_name = ASTRDUP (func_name); - b->locspec = new_explicit_location_spec (&explicit_loc); + b->locspec = new_explicit_location_spec_function (func_name); b->enable_state = bp_disabled; installed_bp++; } @@ -3553,7 +3547,6 @@ create_std_terminate_master_breakpoint (void) { struct breakpoint *b; struct breakpoint_objfile_data *bp_objfile_data; - struct explicit_location explicit_loc; bp_objfile_data = get_breakpoint_objfile_data (objfile); @@ -3578,9 +3571,7 @@ create_std_terminate_master_breakpoint (void) addr = bp_objfile_data->terminate_msym.value_address (); b = create_internal_breakpoint (objfile->arch (), addr, bp_std_terminate_master); - initialize_explicit_location (&explicit_loc); - explicit_loc.function_name = ASTRDUP (func_name); - b->locspec = new_explicit_location_spec (&explicit_loc); + b->locspec = new_explicit_location_spec_function (func_name); b->enable_state = bp_disabled; } } @@ -3648,7 +3639,6 @@ create_exception_master_breakpoint_hook (objfile *objfile) struct gdbarch *gdbarch; struct breakpoint_objfile_data *bp_objfile_data; CORE_ADDR addr; - struct explicit_location explicit_loc; bp_objfile_data = get_breakpoint_objfile_data (objfile); @@ -3675,9 +3665,7 @@ create_exception_master_breakpoint_hook (objfile *objfile) addr = gdbarch_convert_from_func_ptr_addr (gdbarch, addr, current_inferior ()->top_target ()); b = create_internal_breakpoint (gdbarch, addr, bp_exception_master); - initialize_explicit_location (&explicit_loc); - explicit_loc.function_name = ASTRDUP (func_name); - b->locspec = new_explicit_location_spec (&explicit_loc); + b->locspec = new_explicit_location_spec_function (func_name); b->enable_state = bp_disabled; return true; @@ -8467,7 +8455,7 @@ parse_breakpoint_sals (location_spec *locspec, if (location_spec_type (locspec) == LINESPEC_LOCATION_SPEC) { - const char *spec = get_linespec_location (locspec)->spec_string; + const char *spec = as_linespec_location_spec (locspec)->spec_string; if (spec == NULL) { @@ -8518,7 +8506,7 @@ parse_breakpoint_sals (location_spec *locspec, const char *spec = NULL; if (location_spec_type (locspec) == LINESPEC_LOCATION_SPEC) - spec = get_linespec_location (locspec)->spec_string; + spec = as_linespec_location_spec (locspec)->spec_string; if (!cursal.symtab || (spec != NULL @@ -12005,7 +11993,7 @@ strace_marker_create_sals_from_location_spec (location_spec *locspec, struct linespec_sals lsal; const char *arg_start, *arg; - arg = arg_start = get_linespec_location (locspec)->spec_string; + arg = arg_start = as_linespec_location_spec (locspec)->spec_string; lsal.sals = decode_static_tracepoint_spec (&arg); std::string str (arg_start, arg - arg_start); @@ -12073,7 +12061,7 @@ std::vector<symtab_and_line> static_marker_tracepoint::decode_location_spec (location_spec *locspec, program_space *search_pspace) { - const char *s = get_linespec_location (locspec)->spec_string; + const char *s = as_linespec_location_spec (locspec)->spec_string; std::vector<symtab_and_line> sals = decode_static_tracepoint_spec (&s); if (sals.size () > static_trace_marker_id_idx) @@ -12381,7 +12369,6 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal) struct symbol *sym; struct static_tracepoint_marker *tpmarker; struct ui_out *uiout = current_uiout; - struct explicit_location explicit_loc; tpmarker = &markers[0]; @@ -12418,13 +12405,14 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal) b->loc->line_number = sal2.line; b->loc->symtab = sym != NULL ? sal2.symtab : NULL; - b->locspec.reset (nullptr); - initialize_explicit_location (&explicit_loc); - explicit_loc.source_filename - = ASTRDUP (symtab_to_filename_for_display (sal2.symtab)); - explicit_loc.line_offset.offset = b->loc->line_number; - explicit_loc.line_offset.sign = LINE_OFFSET_NONE; - b->locspec = new_explicit_location_spec (&explicit_loc); + std::unique_ptr<explicit_location_spec> els + (new explicit_location_spec ()); + els->source_filename + = xstrdup (symtab_to_filename_for_display (sal2.symtab)); + els->line_offset.offset = b->loc->line_number; + els->line_offset.sign = LINE_OFFSET_NONE; + + b->locspec = std::move (els); /* Might be nice to check if function changed, and warn if so. */ |