This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix dprintf work not right if it is pending


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. */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]