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] Add breakpoint_created observer to update tracepoint_count.
Date: Wed, 07 Nov 2012 00:50:00 -0000	[thread overview]
Message-ID: <1352249397-15044-1-git-send-email-yao@codesourcery.com> (raw)

Hi,
I noticed a bug that 'tracepoint_count' is out of date if tracepoint
is created by MI command '-break-insert -a'.  This patch is to
install 'update_tracepoint_count' to observer 'breakpoint_created',
and 'update_tracepoint_count' can update 'tracepoint_count' if B
is a tracepoint.

Regression tested on x86_64-linux.  Is it OK?

gdb:

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

	* breakpoint.c (set_tracepoint_count): Renamed to ...
	(update_tracepoint_count): ... it.  New.
	(trace_command): Don't call set_tracepoint_count.  Re-indent.
	(strace_command, ftrace_command):
	(create_tracepoint_from_upload): Likewise.
	(_initialize_breakpoint): Call observer_attach_breakpoint_created
	to install update_tracepoint_count to observer
	'breakpoint_created'.
---
 gdb/breakpoint.c |   85 +++++++++++++++++++++++++++--------------------------
 1 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 092d81e..0f505a9 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -14980,12 +14980,17 @@ catch_syscall_completer (struct cmd_list_element *cmd,
 
 /* Tracepoint-specific operations.  */
 
-/* Set tracepoint count to NUM.  */
+/* Update 'tracepoint_count' if B is a tracepoint.  */
+
 static void
-set_tracepoint_count (int num)
+update_tracepoint_count (struct breakpoint *b)
 {
-  tracepoint_count = num;
-  set_internalvar_integer (lookup_internalvar ("tpnum"), num);
+  if (is_tracepoint (b))
+    {
+      tracepoint_count = breakpoint_count;
+      set_internalvar_integer (lookup_internalvar ("tpnum"),
+			       breakpoint_count);
+    }
 }
 
 static void
@@ -14999,35 +15004,33 @@ trace_command (char *arg, int from_tty)
   else
     ops = &tracepoint_breakpoint_ops;
 
-  if (create_breakpoint (get_current_arch (),
-			 arg,
-			 NULL, 0, NULL, 1 /* parse arg */,
-			 0 /* tempflag */,
-			 bp_tracepoint /* type_wanted */,
-			 0 /* Ignore count */,
-			 pending_break_support,
-			 ops,
-			 from_tty,
-			 1 /* enabled */,
-			 0 /* internal */, 0))
-    set_tracepoint_count (breakpoint_count);
+  create_breakpoint (get_current_arch (),
+		     arg,
+		     NULL, 0, NULL, 1 /* parse arg */,
+		     0 /* tempflag */,
+		     bp_tracepoint /* type_wanted */,
+		     0 /* Ignore count */,
+		     pending_break_support,
+		     ops,
+		     from_tty,
+		     1 /* enabled */,
+		     0 /* internal */, 0);
 }
 
 static void
 ftrace_command (char *arg, int from_tty)
 {
-  if (create_breakpoint (get_current_arch (),
-			 arg,
-			 NULL, 0, NULL, 1 /* parse arg */,
-			 0 /* tempflag */,
-			 bp_fast_tracepoint /* type_wanted */,
-			 0 /* Ignore count */,
-			 pending_break_support,
-			 &tracepoint_breakpoint_ops,
-			 from_tty,
-			 1 /* enabled */,
-			 0 /* internal */, 0))
-    set_tracepoint_count (breakpoint_count);
+  create_breakpoint (get_current_arch (),
+		     arg,
+		     NULL, 0, NULL, 1 /* parse arg */,
+		     0 /* tempflag */,
+		     bp_fast_tracepoint /* type_wanted */,
+		     0 /* Ignore count */,
+		     pending_break_support,
+		     &tracepoint_breakpoint_ops,
+		     from_tty,
+		     1 /* enabled */,
+		     0 /* internal */, 0);
 }
 
 /* strace command implementation.  Creates a static tracepoint.  */
@@ -15044,18 +15047,17 @@ strace_command (char *arg, int from_tty)
   else
     ops = &tracepoint_breakpoint_ops;
 
-  if (create_breakpoint (get_current_arch (),
-			 arg,
-			 NULL, 0, NULL, 1 /* parse arg */,
-			 0 /* tempflag */,
-			 bp_static_tracepoint /* type_wanted */,
-			 0 /* Ignore count */,
-			 pending_break_support,
-			 ops,
-			 from_tty,
-			 1 /* enabled */,
-			 0 /* internal */, 0))
-    set_tracepoint_count (breakpoint_count);
+  create_breakpoint (get_current_arch (),
+		     arg,
+		     NULL, 0, NULL, 1 /* parse arg */,
+		     0 /* tempflag */,
+		     bp_static_tracepoint /* type_wanted */,
+		     0 /* Ignore count */,
+		     pending_break_support,
+		     ops,
+		     from_tty,
+		     1 /* enabled */,
+		     0 /* internal */, 0);
 }
 
 /* Set up a fake reader function that gets command lines from a linked
@@ -15124,8 +15126,6 @@ create_tracepoint_from_upload (struct uploaded_tp *utp)
 			  CREATE_BREAKPOINT_FLAGS_INSERTED))
     return NULL;
 
-  set_tracepoint_count (breakpoint_count);
-  
   /* Get the tracepoint we just created.  */
   tp = get_tracepoint (tracepoint_count);
   gdb_assert (tp != NULL);
@@ -15898,6 +15898,7 @@ _initialize_breakpoint (void)
   observer_attach_solib_unloaded (disable_breakpoints_in_unloaded_shlib);
   observer_attach_inferior_exit (clear_syscall_counts);
   observer_attach_memory_changed (invalidate_bp_value_on_memory_change);
+  observer_attach_breakpoint_created (update_tracepoint_count);
 
   breakpoint_objfile_key
     = register_objfile_data_with_cleanup (NULL, free_breakpoint_probes);
-- 
1.7.7.6


             reply	other threads:[~2012-11-07  0:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-07  0:50 Yao Qi [this message]
2012-11-07 18:13 ` Pedro Alves
2012-11-09  1:09   ` Yao Qi
2012-11-09  2:28     ` Pedro Alves
2012-11-09  7:26       ` Yao Qi
2012-11-09  9:54         ` Pedro Alves

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=1352249397-15044-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