From: Hui Zhu <teawater@gmail.com>
To: gdb-patches ml <gdb-patches@sourceware.org>
Subject: [PATCH] fix PR 15180 "May only run agent-printf on the target"
Date: Mon, 17 Jun 2013 10:12:00 -0000 [thread overview]
Message-ID: <CANFwon1CBRpQYOCzUD16JX-4spE-cMJFq4PF0oGd8m1irJndoA@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 643 bytes --]
Hi,
This patch is for PR 15180 too. Because it depends on patch in
http://sourceware.org/ml/gdb-patches/2013-06/msg00139.html
So I post it in another thread.
It make dprintf_after_condition_true doesn't do actions if dprintf
style is agent. Because the actions is already did in agent.
The test patch test the issue about 15180.
Thanks,
Hui
2013-06-17 Hui Zhu <hui@codesourcery.com>
PR gdb/15180
* breakpoint.c (dprintf_after_condition_true): Check dprintf style
before do actions.
2013-06-17 Hui Zhu <hui@codesourcery.com>
PR gdb/15180
* gdb.base/dprintf-same-addr.c: New file.
* gdb.base/dprintf-same-addr.exp: New file.
[-- Attachment #2: dprintf-same-addr.txt --]
[-- Type: text/plain, Size: 709 bytes --]
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -13465,7 +13465,12 @@ dprintf_after_condition_true (struct bps
bs->commands = NULL;
old_chain = make_cleanup_decref_counted_command_line (&tmp_bs.commands);
- bpstat_do_actions_1 (&tmp_bs_p);
+ /* If dprintf-style is set to agent, the actions of dprintf has been
+ executed in agent. They should not be execued in GDB side.
+ So the actions should be executed only when dprintf-style is not
+ set to agent. */
+ if (strcmp (dprintf_style, dprintf_style_agent) != 0)
+ bpstat_do_actions_1 (&tmp_bs_p);
/* 'tmp_bs.commands' will usually be NULL by now, but
bpstat_do_actions_1 may return early without processing the whole
[-- Attachment #3: dprintf-same-addr-test.txt --]
[-- Type: text/plain, Size: 3741 bytes --]
--- /dev/null
+++ b/gdb/testsuite/gdb.base/dprintf-same-addr.c
@@ -0,0 +1,35 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright (C) 2013 Free Software Foundation, Inc.
+ Contributed by Hui Zhu <hui@codesourcery.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+
+int
+main ()
+{
+ int i;
+
+ for (i=0; i < 99; i++)
+ {
+ printf("Hello\n"); /* test line */
+
+ /* Without this line, test with fprintf will not work. */
+ fprintf (stderr, "world\n");
+ }
+
+ return 0;
+}
--- /dev/null
+++ b/gdb/testsuite/gdb.base/dprintf-same-addr.exp
@@ -0,0 +1,82 @@
+# Copyright (C) 2013 Free Software Foundation, Inc.
+# Contributed by Hui Zhu <hui@codesourcery.com>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile
+
+if [prepare_for_testing "failed to prepare for dprintf with non-stop" \
+ ${testfile} ${srcfile} {debug}] {
+ return -1
+}
+
+set bp_location [gdb_get_line_number "test line"]
+
+proc continue_dprintf {args} {
+ with_test_prefix $args {
+ global bp_location
+
+ gdb_test "dprintf $bp_location,\"Hello\\n\"" "Dprintf .*"
+ gdb_test_no_output {set $bpnum1=$bpnum}
+ gdb_breakpoint $bp_location
+ gdb_test_no_output {set $bpnum2=$bpnum}
+
+ gdb_test "continue" "Breakpoint \[0-9\]+, main .*" "First continue"
+
+ gdb_test_no_output "condition \$bpnum1 i>10"
+ gdb_test_no_output "condition \$bpnum2 i>15"
+
+ gdb_test "continue" "Breakpoint \[0-9\]+, main .*" "Second continue"
+
+ gdb_test "p i" "\[0-9\]+ = 16" "check i"
+ }
+}
+
+if ![runto main] {
+ return -1
+}
+gdb_test_no_output "set dprintf-style gdb" "Set dprintf style to gdb"
+continue_dprintf "gdb"
+
+if ![target_info exists gdb,noinferiorio] {
+ if ![runto main] {
+ return -1
+ }
+ gdb_test_no_output "set dprintf-style call" "Set dprintf style to call"
+ continue_dprintf "call"
+
+ if ![runto main] {
+ return -1
+ }
+ gdb_test_no_output "set dprintf-function fprintf" "set dprintf-channel stderr"
+ gdb_test_no_output "set dprintf-channel stderr" "set dprintf channel"
+ continue_dprintf "fprintf"
+} else {
+ unsupported "test dprintf-style call"
+}
+
+if ![runto main] {
+ return -1
+}
+gdb_test "dprintf main,\"Hello\\n\"" "Dprintf .*"
+set msg "Set dprintf style to agent"
+gdb_test_multiple "set dprintf-style agent" $msg {
+ -re "warning: Target cannot run dprintf commands.*\r\n$gdb_prompt $" {
+ unsupported $msg
+ }
+ -re ".*$gdb_prompt $" {
+ pass $msg
+ continue_dprintf "agent"
+ }
+}
next reply other threads:[~2013-06-17 7:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-17 10:12 Hui Zhu [this message]
2013-06-26 18:00 ` Pedro Alves
2013-06-30 17:15 ` Hui Zhu
2013-07-01 8:10 ` Pedro Alves
2013-07-01 8:51 ` Hui Zhu
2013-07-01 14:29 ` Pedro Alves
2013-07-01 16:08 ` Hui Zhu
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=CANFwon1CBRpQYOCzUD16JX-4spE-cMJFq4PF0oGd8m1irJndoA@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