From 40d97ee21fc3e39db73ee8f84b847a22f9d251cc Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 27 May 2022 13:13:41 +0100 Subject: 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 --- gdb/python/py-breakpoint.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'gdb/python/py-breakpoint.c') diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 029ced74..bab1c60 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -839,20 +839,23 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) } else { - struct explicit_location explicit_loc; + std::unique_ptr explicit_loc + (new explicit_location_spec ()); - initialize_explicit_location (&explicit_loc); - explicit_loc.source_filename = source; - explicit_loc.function_name = function; - explicit_loc.label_name = label; + explicit_loc->source_filename + = source != nullptr ? xstrdup (source) : nullptr; + explicit_loc->function_name + = function != nullptr ? xstrdup (function) : nullptr; + explicit_loc->label_name + = label != nullptr ? xstrdup (label) : nullptr; if (line != NULL) - explicit_loc.line_offset = - linespec_parse_line_offset (line.get ()); + explicit_loc->line_offset + = linespec_parse_line_offset (line.get ()); - explicit_loc.func_name_match_type = func_name_match_type; + explicit_loc->func_name_match_type = func_name_match_type; - locspec = new_explicit_location_spec (&explicit_loc); + locspec.reset (explicit_loc.release ()); } const struct breakpoint_ops *ops -- cgit v1.1