Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Fix bug 15433 - GDB crashes when using agent dprintf, %s format, and an in-line string
@ 2013-05-11  5:55 Hui Zhu
  2013-05-13  7:13 ` Yao Qi
  2013-05-13 16:36 ` Tom Tromey
  0 siblings, 2 replies; 6+ messages in thread
From: Hui Zhu @ 2013-05-11  5:55 UTC (permalink / raw)
  To: gdb-patches ml

[-- Attachment #1: Type: text/plain, Size: 633 bytes --]

Hi,

This issue is because GDB doesn't OP_STRING now.  So
parse_cmd_to_aexpr will got NULL if using agent dprintf, %s format,
and an in-line string.
And this NULL will be push to bl->target_info.tcommands.  Then it make
remote part crash.

So add a check in build_target_command_list for the return of
parse_cmd_to_aexpr.  And add a test for it.

Thanks,
Hui

2013-05-11  Hui Zhu  <hui@codesourcery.com>

	PR gdb/15433
	* breakpoint.c (build_target_command_list): Add check for
	the return of parse_cmd_to_aexpr.

2013-05-11  Hui Zhu  <hui@codesourcery.com>

	PR gdb/15433
	* gdb.base/dprintf.exp: Test unsupport commands on target.

[-- Attachment #2: dprintf-cmd-not-support.txt --]
[-- Type: text/plain, Size: 425 bytes --]

--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2302,6 +2302,9 @@ build_target_command_list (struct bp_loc
 		 need to parse the command to bytecodes again.  */
 	      aexpr = parse_cmd_to_aexpr (bl->address,
 					  loc->owner->extra_string);
+	      if (aexpr == NULL)
+		error (_("Agent is not support commands of breakpoint %d."),
+		       bl->owner->number);
 	      loc->cmd_bytecode = aexpr;
 
 	      if (!aexpr)

[-- Attachment #3: dprintf-cmd-not-support-test.txt --]
[-- Type: text/plain, Size: 526 bytes --]

--- a/gdb/testsuite/gdb.base/dprintf.exp
+++ b/gdb/testsuite/gdb.base/dprintf.exp
@@ -131,6 +131,11 @@ if $target_can_dprintf {
 	"\[\r\n\]\tbreakpoint already hit 2 times"
 	"\[\r\n\]        agent-printf \"arg=%d, g=%d\\\\n\", arg, g"
     }
+
+    # Test unsupport commands.
+    gdb_test "dprintf $dp_location1,\"%s\\n\", \"test\"" "Dprintf .*"
+    gdb_test "continue" "Agent is not support commands of breakpoint .*" \
+      "3rd dprintf, agent"
 }
 
 gdb_test "set dprintf-style foobar" "Undefined item: \"foobar\"." \

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-07-17 20:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-11  5:55 [PATCH] Fix bug 15433 - GDB crashes when using agent dprintf, %s format, and an in-line string Hui Zhu
2013-05-13  7:13 ` Yao Qi
2013-05-13  8:24   ` Hui Zhu
2013-05-13 16:36 ` Tom Tromey
2013-05-14 11:15   ` Hui Zhu
2013-07-17 20:22     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox