aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-06-22 17:12:32 +0000
committerPedro Alves <palves@redhat.com>2011-06-22 17:12:32 +0000
commite29a4733b9fbfd7f003287f0c195b6c7a4836a1b (patch)
treece29cb981d6a7c006e035ea5d7b3ff0fe0a80d7e
parent346774a91ffaa367db6982f19cc9b5bcafaa3686 (diff)
downloadgdb-e29a4733b9fbfd7f003287f0c195b6c7a4836a1b.zip
gdb-e29a4733b9fbfd7f003287f0c195b6c7a4836a1b.tar.gz
gdb-e29a4733b9fbfd7f003287f0c195b6c7a4836a1b.tar.bz2
2011-06-22 Pedro Alves <pedro@codesourcery.com>
* breakpoint.h (struct breakpoint): Delete forked_inferior_pid field. * breakpoint.c (init_raw_breakpoint_without_location): Remove reference to forked_inferior_pid. (struct fork_catchpoint): New type. (breakpoint_hit_catch_fork, print_it_catch_fork) (print_one_catch_fork, breakpoint_hit_catch_vfork) (print_it_catch_vfork, print_one_catch_vfork): Adjust. (create_fork_vfork_event_catchpoint): Adjust to use init_catchpoint.
-rw-r--r--gdb/ChangeLog13
-rw-r--r--gdb/breakpoint.c57
-rw-r--r--gdb/breakpoint.h5
3 files changed, 56 insertions, 19 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 545b3d2..65427c1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,18 @@
2011-06-22 Pedro Alves <pedro@codesourcery.com>
+ * breakpoint.h (struct breakpoint): Delete forked_inferior_pid
+ field.
+ * breakpoint.c (init_raw_breakpoint_without_location): Remove
+ reference to forked_inferior_pid.
+ (struct fork_catchpoint): New type.
+ (breakpoint_hit_catch_fork, print_it_catch_fork)
+ (print_one_catch_fork, breakpoint_hit_catch_vfork)
+ (print_it_catch_vfork, print_one_catch_vfork): Adjust.
+ (create_fork_vfork_event_catchpoint): Adjust to use
+ init_catchpoint.
+
+2011-06-22 Pedro Alves <pedro@codesourcery.com>
+
* breakpoint.c (add_to_breakpoint_chain)
(init_raw_breakpoint_without_location): New functions, factored
out from ...
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index fd5890c..27030fc 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5826,7 +5826,6 @@ init_raw_breakpoint_without_location (struct breakpoint *b,
b->ignore_count = 0;
b->commands = NULL;
b->frame_id = null_frame_id;
- b->forked_inferior_pid = null_ptid;
b->exec_pathname = NULL;
b->syscalls_to_be_caught = NULL;
b->ops = NULL;
@@ -6284,6 +6283,23 @@ disable_breakpoints_in_unloaded_shlib (struct so_list *solib)
/* FORK & VFORK catchpoints. */
+/* An instance of this type is used to represent a fork or vfork
+ catchpoint. It includes a "struct breakpoint" as a kind of base
+ class; users downcast to "struct breakpoint *" when needed. A
+ breakpoint is really of this type iff its ops pointer points to
+ CATCH_FORK_BREAKPOINT_OPS. */
+
+struct fork_catchpoint
+{
+ /* The base class. */
+ struct breakpoint base;
+
+ /* Process id of a child process whose forking triggered this
+ catchpoint. This field is only valid immediately after this
+ catchpoint has triggered. */
+ ptid_t forked_inferior_pid;
+};
+
/* Implement the "insert" breakpoint_ops method for fork
catchpoints. */
@@ -6309,7 +6325,9 @@ static int
breakpoint_hit_catch_fork (const struct bp_location *bl,
struct address_space *aspace, CORE_ADDR bp_addr)
{
- return inferior_has_forked (inferior_ptid, &bl->owner->forked_inferior_pid);
+ struct fork_catchpoint *c = (struct fork_catchpoint *) bl->owner;
+
+ return inferior_has_forked (inferior_ptid, &c->forked_inferior_pid);
}
/* Implement the "print_it" breakpoint_ops method for fork
@@ -6318,9 +6336,11 @@ breakpoint_hit_catch_fork (const struct bp_location *bl,
static enum print_stop_action
print_it_catch_fork (struct breakpoint *b)
{
+ struct fork_catchpoint *c = (struct fork_catchpoint *) b;
+
annotate_catchpoint (b->number);
printf_filtered (_("\nCatchpoint %d (forked process %d), "),
- b->number, ptid_get_pid (b->forked_inferior_pid));
+ b->number, ptid_get_pid (c->forked_inferior_pid));
return PRINT_SRC_AND_LOC;
}
@@ -6330,6 +6350,7 @@ print_it_catch_fork (struct breakpoint *b)
static void
print_one_catch_fork (struct breakpoint *b, struct bp_location **last_loc)
{
+ struct fork_catchpoint *c = (struct fork_catchpoint *) b;
struct value_print_options opts;
get_user_print_options (&opts);
@@ -6341,11 +6362,11 @@ print_one_catch_fork (struct breakpoint *b, struct bp_location **last_loc)
ui_out_field_skip (uiout, "addr");
annotate_field (5);
ui_out_text (uiout, "fork");
- if (!ptid_equal (b->forked_inferior_pid, null_ptid))
+ if (!ptid_equal (c->forked_inferior_pid, null_ptid))
{
ui_out_text (uiout, ", process ");
ui_out_field_int (uiout, "what",
- ptid_get_pid (b->forked_inferior_pid));
+ ptid_get_pid (c->forked_inferior_pid));
ui_out_spaces (uiout, 1);
}
}
@@ -6409,7 +6430,9 @@ static int
breakpoint_hit_catch_vfork (const struct bp_location *bl,
struct address_space *aspace, CORE_ADDR bp_addr)
{
- return inferior_has_vforked (inferior_ptid, &bl->owner->forked_inferior_pid);
+ struct fork_catchpoint *c = (struct fork_catchpoint *) bl->owner;
+
+ return inferior_has_vforked (inferior_ptid, &c->forked_inferior_pid);
}
/* Implement the "print_it" breakpoint_ops method for vfork
@@ -6418,9 +6441,11 @@ breakpoint_hit_catch_vfork (const struct bp_location *bl,
static enum print_stop_action
print_it_catch_vfork (struct breakpoint *b)
{
+ struct fork_catchpoint *c = (struct fork_catchpoint *) b;
+
annotate_catchpoint (b->number);
printf_filtered (_("\nCatchpoint %d (vforked process %d), "),
- b->number, ptid_get_pid (b->forked_inferior_pid));
+ b->number, ptid_get_pid (c->forked_inferior_pid));
return PRINT_SRC_AND_LOC;
}
@@ -6430,6 +6455,7 @@ print_it_catch_vfork (struct breakpoint *b)
static void
print_one_catch_vfork (struct breakpoint *b, struct bp_location **last_loc)
{
+ struct fork_catchpoint *c = (struct fork_catchpoint *) b;
struct value_print_options opts;
get_user_print_options (&opts);
@@ -6440,11 +6466,11 @@ print_one_catch_vfork (struct breakpoint *b, struct bp_location **last_loc)
ui_out_field_skip (uiout, "addr");
annotate_field (5);
ui_out_text (uiout, "vfork");
- if (!ptid_equal (b->forked_inferior_pid, null_ptid))
+ if (!ptid_equal (c->forked_inferior_pid, null_ptid))
{
ui_out_text (uiout, ", process ");
ui_out_field_int (uiout, "what",
- ptid_get_pid (b->forked_inferior_pid));
+ ptid_get_pid (c->forked_inferior_pid));
ui_out_spaces (uiout, 1);
}
}
@@ -6856,12 +6882,15 @@ create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch,
int tempflag, char *cond_string,
struct breakpoint_ops *ops)
{
- struct breakpoint *b
- = create_catchpoint (gdbarch, tempflag, cond_string, ops);
+ struct fork_catchpoint *c = XNEW (struct fork_catchpoint);
- /* FIXME: We should put this information in a breakpoint private data
- area. */
- b->forked_inferior_pid = null_ptid;
+ init_catchpoint (&c->base, gdbarch, tempflag, cond_string, ops);
+
+ c->forked_inferior_pid = null_ptid;
+
+ mention (&c->base);
+ observer_notify_breakpoint_created (&c->base);
+ update_global_location_list (1);
}
/* Exec catchpoints. */
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 55c9c34..80374dd 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -604,11 +604,6 @@ struct breakpoint
aborting, so you can back up to just before the abort. */
int hit_count;
- /* Process id of a child process whose forking triggered this
- catchpoint. This field is only valid immediately after this
- catchpoint has triggered. */
- ptid_t forked_inferior_pid;
-
/* Filename of a program whose exec triggered this catchpoint.
This field is only valid immediately after this catchpoint has
triggered. */