mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-03-07 13:39:43 +08:00
Introduce and use new_breakpoint_from_type
This is a small preparatory patch to factor out a snippet that appears twice. More kinds of breakpoints will need to be created based on bptype, so I think it's a good idea to centralize the instantiation of breakpoint objects. gdb/ChangeLog: * breakpoint.c (new_breakpoint_from_type): New function. (create_breakpoint_sal): Use new_breakpoint_from_type and unique_ptr. (create_breakpoint): Likewise.
This commit is contained in:
parent
e7cd2680e0
commit
a5e364af4a
@ -1,3 +1,10 @@
|
||||
2017-06-02 Simon Marchi <simon.marchi@polymtl.ca>
|
||||
|
||||
* breakpoint.c (new_breakpoint_from_type): New function.
|
||||
(create_breakpoint_sal): Use new_breakpoint_from_type and
|
||||
unique_ptr.
|
||||
(create_breakpoint): Likewise.
|
||||
|
||||
2017-05-31 Simon Marchi <simon.marchi@ericsson.com>
|
||||
|
||||
* memattr.c (mem_info_command): Rename to ...
|
||||
|
@ -1176,6 +1176,22 @@ is_tracepoint (const struct breakpoint *b)
|
||||
return is_tracepoint_type (b->type);
|
||||
}
|
||||
|
||||
/* Factory function to create an appropriate instance of breakpoint given
|
||||
TYPE. */
|
||||
|
||||
static std::unique_ptr<breakpoint>
|
||||
new_breakpoint_from_type (bptype type)
|
||||
{
|
||||
breakpoint *b;
|
||||
|
||||
if (is_tracepoint_type (type))
|
||||
b = (breakpoint *) new tracepoint ();
|
||||
else
|
||||
b = new breakpoint ();
|
||||
|
||||
return std::unique_ptr<breakpoint> (b);
|
||||
}
|
||||
|
||||
/* A helper function that validates that COMMANDS are valid for a
|
||||
breakpoint. This function will throw an exception if a problem is
|
||||
found. */
|
||||
@ -9310,22 +9326,9 @@ create_breakpoint_sal (struct gdbarch *gdbarch,
|
||||
int enabled, int internal, unsigned flags,
|
||||
int display_canonical)
|
||||
{
|
||||
struct breakpoint *b;
|
||||
struct cleanup *old_chain;
|
||||
std::unique_ptr<breakpoint> b = new_breakpoint_from_type (type);
|
||||
|
||||
if (is_tracepoint_type (type))
|
||||
{
|
||||
struct tracepoint *t;
|
||||
|
||||
t = new tracepoint ();
|
||||
b = &t->base;
|
||||
}
|
||||
else
|
||||
b = new breakpoint ();
|
||||
|
||||
old_chain = make_cleanup (xfree, b);
|
||||
|
||||
init_breakpoint_sal (b, gdbarch,
|
||||
init_breakpoint_sal (b.get (), gdbarch,
|
||||
sals, std::move (location),
|
||||
filter, cond_string, extra_string,
|
||||
type, disposition,
|
||||
@ -9333,9 +9336,8 @@ create_breakpoint_sal (struct gdbarch *gdbarch,
|
||||
ops, from_tty,
|
||||
enabled, internal, flags,
|
||||
display_canonical);
|
||||
discard_cleanups (old_chain);
|
||||
|
||||
install_breakpoint (internal, b, 0);
|
||||
install_breakpoint (internal, b.release (), 0);
|
||||
}
|
||||
|
||||
/* Add SALS.nelts breakpoints to the breakpoint table. For each
|
||||
@ -9804,19 +9806,9 @@ create_breakpoint (struct gdbarch *gdbarch,
|
||||
}
|
||||
else
|
||||
{
|
||||
struct breakpoint *b;
|
||||
std::unique_ptr <breakpoint> b = new_breakpoint_from_type (type_wanted);
|
||||
|
||||
if (is_tracepoint_type (type_wanted))
|
||||
{
|
||||
struct tracepoint *t;
|
||||
|
||||
t = new tracepoint ();
|
||||
b = &t->base;
|
||||
}
|
||||
else
|
||||
b = new breakpoint ();
|
||||
|
||||
init_raw_breakpoint_without_location (b, gdbarch, type_wanted, ops);
|
||||
init_raw_breakpoint_without_location (b.get (), gdbarch, type_wanted, ops);
|
||||
b->location = copy_event_location (location);
|
||||
|
||||
if (parse_extra)
|
||||
@ -9848,7 +9840,7 @@ create_breakpoint (struct gdbarch *gdbarch,
|
||||
&& type_wanted != bp_hardware_breakpoint) || thread != -1)
|
||||
b->pspace = current_program_space;
|
||||
|
||||
install_breakpoint (internal, b, 0);
|
||||
install_breakpoint (internal, b.release (), 0);
|
||||
}
|
||||
|
||||
if (VEC_length (linespec_sals, canonical.sals) > 1)
|
||||
|
Loading…
Reference in New Issue
Block a user