From: Hui Zhu <teawater@gmail.com>
To: gdb-patches ml <gdb-patches@sourceware.org>
Subject: [PATCH] Fix bug 15433 - GDB crashes when using agent dprintf, %s format, and an in-line string
Date: Sat, 11 May 2013 05:55:00 -0000 [thread overview]
Message-ID: <CANFwon1MsCu4Abzdh75jB5i-+rXZizYb_Rwx++cnBxzJhV5_Cw@mail.gmail.com> (raw)
[-- 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\"." \
next reply other threads:[~2013-05-11 5:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-11 5:55 Hui Zhu [this message]
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
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=CANFwon1MsCu4Abzdh75jB5i-+rXZizYb_Rwx++cnBxzJhV5_Cw@mail.gmail.com \
--to=teawater@gmail.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