aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.h
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-11-08 12:32:51 +0000
committerAndrew Burgess <aburgess@redhat.com>2023-08-17 16:42:39 +0100
commitb080fe54fb3414b488b8ef323c6c50def061f918 (patch)
tree7b0b54ca4a9a44fb37e3838fb68a01b572380b3d /gdb/breakpoint.h
parent0c9546b152f6b01756475ce259c895d3fa446774 (diff)
downloadbinutils-b080fe54fb3414b488b8ef323c6c50def061f918.zip
binutils-b080fe54fb3414b488b8ef323c6c50def061f918.tar.gz
binutils-b080fe54fb3414b488b8ef323c6c50def061f918.tar.bz2
gdb: add inferior-specific breakpoints
This commit extends the breakpoint mechanism to allow for inferior specific breakpoints (but not watchpoints in this commit). As GDB gains better support for multiple connections, and so for running multiple (possibly unrelated) inferiors, then it is not hard to imagine that a user might wish to create breakpoints that apply to any thread in a single inferior. To achieve this currently, the user would need to create a condition possibly making use of the $_inferior convenience variable, which, though functional, isn't the most user friendly. This commit adds a new 'inferior' keyword that allows for the creation of inferior specific breakpoints. Inferior specific breakpoints are automatically deleted when the associated inferior is removed from GDB, this is similar to how thread-specific breakpoints are deleted when the associated thread is deleted. Watchpoints are already per-program-space, which in most cases mean watchpoints are already inferior specific. There is a small window where inferior-specific watchpoints might make sense, which is after a vfork, when two processes are sharing the same address space. However, I'm leaving that as an exercise for another day. For now, attempting to use the inferior keyword with a watchpoint will give an error, like this: (gdb) watch a8 inferior 1 Cannot use 'inferior' keyword with watchpoints A final note on the implementation: currently, inferior specific breakpoints, like thread-specific breakpoints, are inserted into every inferior, GDB then checks once the inferior stops if we are in the correct thread or inferior, and resumes automatically if we stopped in the wrong thread/inferior. An obvious optimisation here is to only insert breakpoint locations into the specific program space (which mostly means inferior) that contains either the inferior or thread we are interested in. This would reduce the number times GDB has to stop and then resume again in a multi-inferior setup. I have a series on the mailing list[1] that implements this optimisation for thread-specific breakpoints. Once this series has landed I'll update that series to also handle inferior specific breakpoints in the same way. For now, inferior specific breakpoints are just slightly less optimal, but this is no different to thread-specific breakpoints in a multi-inferior debug session, so I don't see this as a huge problem. [1] https://inbox.sourceware.org/gdb-patches/cover.1685479504.git.aburgess@redhat.com/
Diffstat (limited to 'gdb/breakpoint.h')
-rw-r--r--gdb/breakpoint.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index f489629..1a73d08 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -583,7 +583,7 @@ struct breakpoint_ops
struct linespec_result *,
gdb::unique_xmalloc_ptr<char>,
gdb::unique_xmalloc_ptr<char>,
- enum bptype, enum bpdisp, int, int,
+ enum bptype, enum bpdisp, int, int, int,
int, int, int, int, unsigned);
};
@@ -863,6 +863,10 @@ struct breakpoint : public intrusive_list_node<breakpoint>
care. */
int thread = -1;
+ /* Inferior number for inferior-specific breakpoint, or -1 if this
+ breakpoint is for all inferiors. */
+ int inferior = -1;
+
/* Ada task number for task-specific breakpoint, or -1 if don't
care. */
int task = -1;
@@ -921,7 +925,7 @@ struct code_breakpoint : public breakpoint
gdb::unique_xmalloc_ptr<char> cond_string,
gdb::unique_xmalloc_ptr<char> extra_string,
enum bpdisp disposition,
- int thread, int task, int ignore_count,
+ int thread, int task, int inferior, int ignore_count,
int from_tty,
int enabled, unsigned flags,
int display_canonical);
@@ -1601,6 +1605,7 @@ enum breakpoint_create_flags
extern int create_breakpoint (struct gdbarch *gdbarch,
struct location_spec *locspec,
const char *cond_string, int thread,
+ int inferior,
const char *extra_string,
bool force_condition,
int parse_extra,
@@ -1744,6 +1749,11 @@ extern void breakpoint_set_silent (struct breakpoint *b, int silent);
extern void breakpoint_set_thread (struct breakpoint *b, int thread);
+/* Set the inferior for breakpoint B to INFERIOR. If INFERIOR is -1, make
+ the breakpoint work for any inferior. */
+
+extern void breakpoint_set_inferior (struct breakpoint *b, int inferior);
+
/* Set the task for this breakpoint. If TASK is -1, make the breakpoint
work for any task. Passing a value other than -1 for TASK should only
be done if b->thread is -1; it is not valid to try and set both a thread