Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH] breakpoint always inserted in record target
Date: Wed, 11 Apr 2012 13:16:00 -0000	[thread overview]
Message-ID: <1334149619-2738-1-git-send-email-yao@codesourcery.com> (raw)

So far, breakpoint always-inserted is not supported in target record.
This patch is to teach GDB to support breakpoint always-inserted in
record.  When switch to target record, the existing breakpoints are
unknown to record target, so this causes errors when removing breakpoint.
In this patch, we sync existing breakpoints to record_breakpoints
when change to record target.

Tested on native gdb and remote with native gdbserver, with setting this
line in testsuite/site.exp

  set GDBFLAGS "-ex \"set breakpoint always-inserted on\""

`record' is new to me, am I missing something else to support break
aways-inserted in record?

gdb:

2012-04-11  Yao Qi  <yao@codesourcery.com>

	* breakpoint.c (iterate_over_bp_locations): New.
	* breakpoint.h: Declare.
	* record.c (record_open): Call record_init_record_breakpoints.
	(record_sync_record_breakpoints): New.
	(record_init_record_breakpoints): New.
---
 gdb/breakpoint.c |   13 +++++++++++++
 gdb/breakpoint.h |    2 ++
 gdb/record.c     |   30 ++++++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index be536bc..c5109d6 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2425,6 +2425,19 @@ insert_breakpoints (void)
     insert_breakpoint_locations ();
 }
 
+/* Invoke CALLBACK for each of bp_location.  */
+
+void
+iterate_over_bp_locations (void (*callback) (struct bp_location *))
+{
+  struct bp_location *loc, **loc_tmp;
+
+  ALL_BP_LOCATIONS (loc, loc_tmp)
+    {
+      callback (loc);
+    }
+}
+
 /* This is used when we need to synch breakpoint conditions between GDB and the
    target.  It is the case with deleting and disabling of breakpoints when using
    always-inserted mode.  */
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index e0eeeaa..3fe6a63 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1131,6 +1131,8 @@ extern void delete_breakpoint (struct breakpoint *);
 
 extern void breakpoint_auto_delete (bpstat);
 
+extern void iterate_over_bp_locations (void (*callback) (struct bp_location *));
+
 /* Return the chain of command lines to execute when this breakpoint
    is hit.  */
 extern struct command_line *breakpoint_commands (struct breakpoint *b);
diff --git a/gdb/record.c b/gdb/record.c
index 9b7ee2f..3429d83 100644
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -896,6 +896,8 @@ record_open_1 (char *name, int from_tty)
   push_target (&record_ops);
 }
 
+static void record_init_record_breakpoints (void);
+
 /* "to_open" target method.  Open the process record target.  */
 
 static void
@@ -993,6 +995,8 @@ record_open (char *name, int from_tty)
   record_async_inferior_event_token
     = create_async_event_handler (record_async_inferior_event_handler,
 				  NULL);
+
+  record_init_record_breakpoints ();
 }
 
 /* "to_close" target method.  Close the process record target.  */
@@ -1744,6 +1748,32 @@ DEF_VEC_P(record_breakpoint_p);
    active.  */
 VEC(record_breakpoint_p) *record_breakpoints = NULL;
 
+static void
+record_sync_record_breakpoints (struct bp_location *loc)
+{
+  if (loc->inserted)
+    {
+      struct record_breakpoint *bp = XNEW (struct record_breakpoint);
+
+      bp->addr = loc->target_info.placed_address;
+      bp->address_space = loc->target_info.placed_address_space;
+
+      bp->in_target_beneath = 1;
+
+      VEC_safe_push (record_breakpoint_p, record_breakpoints, bp);
+    }
+}
+
+/* Sync existing breakpoints to record_breakpoints.  */
+
+static void
+record_init_record_breakpoints (void)
+{
+  VEC_free (record_breakpoint_p, record_breakpoints);
+
+  iterate_over_bp_locations (record_sync_record_breakpoints);
+}
+
 /* Behavior is conditional on RECORD_IS_REPLAY.  We will not actually
    insert or remove breakpoints in the real target when replaying, nor
    when recording.  */
-- 
1.7.0.4


             reply	other threads:[~2012-04-11 13:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-11 13:16 Yao Qi [this message]
2012-04-11 18:15 ` Keith Seitz
2012-04-13  2:03   ` Yao Qi
2012-04-13  9:47     ` Eli Zaretskii
2012-04-13 16:00     ` Pedro Alves
2012-04-23  6:57       ` Yao Qi
2012-04-24 13:18         ` Pedro Alves
2012-04-24 15:00           ` [committed]: " Yao Qi
2012-04-12  5:16 ` Doug Evans
2012-04-12  5:33   ` Yao Qi
2012-04-12 19:40     ` Doug Evans
2012-04-12 20:22       ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1334149619-2738-1-git-send-email-yao@codesourcery.com \
    --to=yao@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox