aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2017-06-02 23:16:20 +0200
committerSimon Marchi <simon.marchi@ericsson.com>2017-06-02 23:16:20 +0200
commit3b0871f44a3402f4e1e811ae81c8ba1293c1c7be (patch)
treef6e40bc552474f0bd53dcbca597b501cbe393b8c
parenta5e364af4a3d745bb79cfc9a1d533632d4d04b57 (diff)
downloadgdb-3b0871f44a3402f4e1e811ae81c8ba1293c1c7be.zip
gdb-3b0871f44a3402f4e1e811ae81c8ba1293c1c7be.tar.gz
gdb-3b0871f44a3402f4e1e811ae81c8ba1293c1c7be.tar.bz2
Create struct type for longjmp breakpoint
The longjmp kind of breakpoint has a destructor, but doesn't have an associated structure. The next patch converts breakpoint destructors from breakpoint_ops::dtor to actual destructors, but to do that it is needed for longjmp_breakpoint to have a structure that will contain such destructor. This patch adds it. According to initialize_breakpoint_ops, a longjmp breakpoint derives from "momentary breakpoints", so eventually a momentary_breakpoint struct/class should probably be created. It's not necessary for the destructor though, so a structure type for this abstract kind of breakpoint can be added when we fully convert breakpoint ops into methods of the breakpoint type hierarchy. It is now necessary to instantiate different kinds of breakpoint objects in set_raw_breakpoint_without_location based on bptype (sometimes a breakpoint, sometimes a longjmp_breakpoint), so it now uses new_breakpoint_from_type to do that. I also changed set_raw_breakpoint to use it, even though I don't think that it can ever receive a bptype that actually requires it. However, I think it's good if all breakpoint object instantion is done in a single place. gdb/ChangeLog: * breakpoint.c (struct longjmp_breakpoint): New struct. (is_tracepoint_type): Change return type to bool. (is_longjmp_type): New function. (new_breakpoint_from_type): Handle longjmp kinds of breakpoints. (set_raw_breakpoint_without_location): Use new_breakpoint_from_type. (set_raw_breakpoint): Likewise.
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/breakpoint.c35
2 files changed, 35 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7334ae4..597b0fb 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
2017-06-02 Simon Marchi <simon.marchi@polymtl.ca>
+ * breakpoint.c (struct longjmp_breakpoint): New struct.
+ (is_tracepoint_type): Change return type to bool.
+ (is_longjmp_type): New function.
+ (new_breakpoint_from_type): Handle longjmp kinds of breakpoints.
+ (set_raw_breakpoint_without_location): Use
+ new_breakpoint_from_type.
+ (set_raw_breakpoint): Likewise.
+
+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.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index d120290..31931e8 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1160,16 +1160,27 @@ check_no_tracepoint_commands (struct command_line *commands)
}
}
+struct longjmp_breakpoint
+{
+ breakpoint base;
+};
+
/* Encapsulate tests for different types of tracepoints. */
-static int
-is_tracepoint_type (enum bptype type)
+static bool
+is_tracepoint_type (bptype type)
{
return (type == bp_tracepoint
|| type == bp_fast_tracepoint
|| type == bp_static_tracepoint);
}
+static bool
+is_longjmp_type (bptype type)
+{
+ return type == bp_longjmp || type == bp_exception;
+}
+
int
is_tracepoint (const struct breakpoint *b)
{
@@ -1186,6 +1197,8 @@ new_breakpoint_from_type (bptype type)
if (is_tracepoint_type (type))
b = (breakpoint *) new tracepoint ();
+ else if (is_longjmp_type (type))
+ b = (breakpoint *) new longjmp_breakpoint ();
else
b = new breakpoint ();
@@ -7446,11 +7459,12 @@ set_raw_breakpoint_without_location (struct gdbarch *gdbarch,
enum bptype bptype,
const struct breakpoint_ops *ops)
{
- struct breakpoint *b = new breakpoint ();
+ std::unique_ptr<breakpoint> b = new_breakpoint_from_type (bptype);
- init_raw_breakpoint_without_location (b, gdbarch, bptype, ops);
- add_to_breakpoint_chain (b);
- return b;
+ init_raw_breakpoint_without_location (b.get (), gdbarch, bptype, ops);
+ add_to_breakpoint_chain (b.get ());
+
+ return b.release ();
}
/* Initialize loc->function_name. EXPLICIT_LOC says no indirect function
@@ -7562,11 +7576,12 @@ set_raw_breakpoint (struct gdbarch *gdbarch,
struct symtab_and_line sal, enum bptype bptype,
const struct breakpoint_ops *ops)
{
- struct breakpoint *b = new breakpoint ();
+ std::unique_ptr<breakpoint> b = new_breakpoint_from_type (bptype);
- init_raw_breakpoint (b, gdbarch, sal, bptype, ops);
- add_to_breakpoint_chain (b);
- return b;
+ init_raw_breakpoint (b.get (), gdbarch, sal, bptype, ops);
+ add_to_breakpoint_chain (b.get ());
+
+ return b.release ();
}
/* Call this routine when stepping and nexting to enable a breakpoint