[PATCH] Fix bug 15433 - GDB crashes when using agent dprintf, %s format, and an in-line string

Hui Zhu teawater@gmail.com
Sat May 11 05:55:00 GMT 2013


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.
-------------- next part --------------
--- 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)
-------------- next part --------------
--- 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\"." \


More information about the Gdb-patches mailing list