Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hui Zhu <hui_zhu@mentor.com>
To: gdb-patches ml <gdb-patches@sourceware.org>
Cc: Marc Khouzam <marc.khouzam@ericsson.com>
Subject: [PATCH] Fix dprintf work not right if it is pending
Date: Fri, 22 Mar 2013 07:39:00 -0000	[thread overview]
Message-ID: <514BF736.3070706@mentor.com> (raw)

Hi.

I found that dprintf work not right if it is pending, for example:
testsuite$ gdb gdb.base/pending
(gdb) dprintf pendfunc1, "got\n"
Function "pendfunc1" not defined.
Make dprintf pending on future shared library load? (y or [n]) y
Dprintf 1 (pendfunc1, "got\n") pending.
(gdb) r
Starting program: /home/teawater/gdb/bgdbno/gdb/testsuite/gdb.base/pending
(gdb) c
Continuing.
in pendfunc1, x is 3
(gdb) c
Continuing.
in pendfunc1, x is 4
(gdb) c
Continuing.
in pendfunc1, x is 3
[Inferior 1 (process 2370) exited normally]

The dprintf's commands is setup in function init_breakpoint_sal:
       /* Dynamic printf requires and uses additional arguments on the
	 command line, otherwise it's an error.  */
       if (type == bp_dprintf)
	{
	  if (b->extra_string)
	    update_dprintf_command_list (b);
	  else
	    error (_("Format string required"));
	}
       else if (b->extra_string)
	error (_("Garbage '%s' at end of command"), b->extra_string);

But if the dprintf is pending.  When it reset by function bkpt_re_set, there is not code to code to update extra_string to commands.
So I add this code to function update_breakpoint_locations.  The issue is fixed.

Please help me review it.

Best.
Hui

2013-03-22  Hui Zhu  <hui@codesourcery.com>

	* breakpoint.c (update_breakpoint_locations): Add handler for dprintf.

--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -14075,6 +14075,18 @@ update_breakpoint_locations (struct brea
  
  	  new_loc->length = end - sals.sals[0].pc + 1;
  	}
+
+      /* Dynamic printf requires and uses additional arguments on the
+	 command line, otherwise it's an error.  */
+      if (b->type == bp_dprintf)
+	{
+	  if (b->extra_string)
+	    update_dprintf_command_list (b);
+	  else
+	    error (_("Format string required"));
+	}
+      else if (b->extra_string)
+	error (_("Garbage '%s' at end of command"), b->extra_string);
      }
  
    /* Update locations of permanent breakpoints.  */


             reply	other threads:[~2013-03-22  6:17 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-22  7:39 Hui Zhu [this message]
2013-03-22 12:40 ` Yao Qi
2013-03-25  1:00   ` Keith Seitz
2013-03-25  2:14     ` Yao Qi
2013-03-26 14:55     ` Hui Zhu
2013-03-28 17:07       ` Keith Seitz
2013-03-29 15:50         ` Hui Zhu
2013-04-03  3:34           ` Keith Seitz
2013-04-04 18:42             ` Hui Zhu
2013-04-05 18:30             ` Pedro Alves
2013-04-08  7:20               ` Keith Seitz
2013-04-08 17:57                 ` Pedro Alves
2013-04-08  9:34               ` Hui Zhu
2013-04-08 14:35                 ` Hui Zhu
2013-04-08 18:34                   ` Pedro Alves
2013-04-09 15:28                     ` Hui Zhu
2013-04-09 15:28                       ` Pedro Alves
2013-04-10 15:57                         ` Hui Zhu
2013-04-10 16:12                           ` Hui Zhu
2013-04-11  5:46                             ` Joel Brobecker
2013-04-11 17:03                               ` Pedro Alves
2013-04-12 12:21                                 ` Hui Zhu
2013-03-25  8:25   ` Hui Zhu
2013-03-25  8:28     ` Yao Qi

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=514BF736.3070706@mentor.com \
    --to=hui_zhu@mentor.com \
    --cc=gdb-patches@sourceware.org \
    --cc=marc.khouzam@ericsson.com \
    /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