Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Hui Zhu <teawater@gmail.com>
Cc: Tom Tromey <tromey@redhat.com>,
	gdb-patches@sourceware.org,
	       Keith Seitz <keiths@redhat.com>,
	Yao Qi <yao@codesourcery.com>
Subject: Re: [RFC] PR 15075 dprintf interferes with "next"
Date: Tue, 18 Jun 2013 18:16:00 -0000	[thread overview]
Message-ID: <51C0A274.9010808@redhat.com> (raw)
In-Reply-To: <CANFwon2oFaTc0ey4B7z=OXcne42SRwp_mozfOYKU4nx-K+80nA@mail.gmail.com>

On 06/07/2013 04:15 AM, Hui Zhu wrote:

> 2013-06-07  Yao Qi  <yao@codesourcery.com>
> 	    Hui Zhu  <hui@codesourcery.com>
> 	    Pedro Alves  <palves@redhat.com>
> 
> 	PR breakpoints/15075
> 	PR breakpoints/15434
> 	* breakpoint.c (bpstat_stop_status): Call
> 	b->ops->after_condition_true.
> 	(update_dprintf_command_list): Don't append "continue" command
> 	to the command list of dprintf breakpoint.
> 	(base_breakpoint_after_condition_true): New function.
> 	(base_breakpoint_ops): Add base_breakpoint_after_condition_true.
> 	(dprintf_create_breakpoints_sal,
> 	dprintf_after_condition_true): New functions.

Context is split in multiple lines with '()'s, not ','s:

 	(dprintf_create_breakpoints_sal)
 	(dprintf_after_condition_true): New functions.


> 	(initialize_breakpoint_ops): Set dprintf_create_breakpoints_sal
> 	and dprintf_after_condition_true.
> 	* breakpoint.h (breakpoint_ops): Add after_condition_true.
> 
>  };
>  
>  /* Default breakpoint_ops methods.  */
> @@ -13351,6 +13353,76 @@ dprintf_print_recreate (struct breakpoin
>    print_recreate_thread (tp, fp);
>  }
>  
> +/* Implement the "create_breakpoints_sal" breakpoint_ops method for
> +   dprintf.  */
> +
> +static void
> +dprintf_create_breakpoints_sal (struct gdbarch *gdbarch,
> +				struct linespec_result *canonical,
> +				struct linespec_sals *lsal,
> +				char *cond_string,
> +				char *extra_string,
> +				enum bptype type_wanted,
> +				enum bpdisp disposition,
> +				int thread,
> +				int task, int ignore_count,
> +				const struct breakpoint_ops *ops,
> +				int from_tty, int enabled,
> +				int internal, unsigned flags)
> +{
> +  struct breakpoint *b;
> +
> +  create_breakpoints_sal_default (gdbarch, canonical, lsal,
> +				  cond_string, extra_string,
> +				  type_wanted,
> +				  disposition, thread, task,
> +				  ignore_count, ops, from_tty,
> +				  enabled, internal, flags);
> +
> +  b = get_breakpoint (breakpoint_count);
> +  gdb_assert (b != NULL);
> +
> +  breakpoint_set_silent (b, 0);
> +}

When I tried it last, I didn't find making the dprintf
explicitly silent necessary, given:

      /* Print nothing for this entry if we don't stop or don't
	 print.  */
      if (!bs->stop || !bs->print)
	bs->print_it = print_it_noop;

So did it turn out really necessary for some reason?  Please
don't leave such changes between revisions unexplained.

> +gdb_test "next" "\\+\\+x\;.*\/\* Next without dprintf.*" "next 1"
> +gdb_test "next" "\\+\\+x\;.*\/\* Set dprintf here.*" "next 2"

> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/dprintf-non-stop.c
> @@ -0,0 +1,30 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> +   Copyright (C) 2013 Free Software Foundation, Inc.
> +   Contributed by Hui Zhu  <hui@codesourcery.com>

(
IMO, we should stop adding these (like glibc has done so too):
http://sourceware.org/ml/gdb-patches/2013-05/msg00253.html
)

> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/dprintf-non-stop.exp
> @@ -0,0 +1,54 @@
> +#   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/>.
> +
> +if [is_remote target] then {
> +    unsupported "Dprintf with non-stop is not supported."

That's not exactly true.  It's supported, but testing is racy at the moment.
Write instead:

if [is_remote target] then {
   # Testing with remote/non-stop is racy at the moment.
   unsupported "Testing dprintf with remote/non-stop is not supported."
   return 0
}

> +    return 0
> +}
> +
> +standard_testfile
> +
> +if [prepare_for_testing "failed to prepare for dprintf with non-stop" \
> +    ${testfile} ${srcfile} {debug}] {
> +    return -1
> +}
> +
> +gdb_test_no_output "set target-async on"
> +gdb_test_no_output "set non-stop on"
> +
> +if ![runto main] {
> +    fail "Can't run to main"
> +    return -1
> +}
> +
> +gdb_test "dprintf foo,\"At foo entry\\n\"" "Dprintf .*"
> +
> +send_gdb "continue &\n"
> +exec sleep 1
> +
> +set test "interrupt"
> +gdb_test_multiple $test $test {
> +    -re "interrupt\r\n$gdb_prompt " {
> +	pass $test

Hmm, this still looks racy to me, even on native targets.
"continue &" produces a gdb prompt.  gdb_test_multiple
inside has a match for the prompt:

	-re "\r\n$gdb_prompt $" {
	    if ![string match "" $message] then {
		fail "$message"
	    }
	    set result 1
	}

So if the expect happens to read

continue &
(gdb)

from the buffer, we'll hit the fail.  Doesn't the read1 hack catch this?

We need to consume the prompt after that "continue&".

> +    }
> +}
> +
> +set test "inferior stopped"
> +gdb_test_multiple "" $test {
> +    -re "\r\n\\\[.* \[0-9\]+\\\] #1 stopped\\\.\r\n" {
> +	pass $test
> +    }
> +}

Likewise?

-- 
Pedro Alves


  parent reply	other threads:[~2013-06-18 18:10 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-18 13:09 Yao Qi
2013-02-18 21:36 ` Joel Brobecker
2013-02-21 16:36 ` Tom Tromey
2013-04-24  1:24   ` Hui Zhu
2013-04-24  6:06     ` Keith Seitz
2013-04-24 13:30       ` Hui Zhu
2013-04-24 14:03         ` Yao Qi
2013-04-24 14:09           ` Hui Zhu
2013-05-16  7:29             ` Hui Zhu
2013-05-17 21:01               ` Pedro Alves
2013-05-22 10:22                 ` Hui Zhu
2013-05-22 12:46                   ` Pedro Alves
2013-05-28  0:02                     ` Hui Zhu
2013-05-28  3:36                       ` Yao Qi
2013-05-29 10:08                         ` Hui Zhu
2013-06-03  4:07                       ` Hui Zhu
2013-06-03 17:48                         ` Pedro Alves
2013-06-07  3:16                           ` Hui Zhu
2013-06-17  7:36                             ` Hui Zhu
2013-06-18 18:16                             ` Pedro Alves [this message]
2013-06-24  8:36                               ` Hui Zhu
2013-06-24 22:06                                 ` Pedro Alves
2013-06-25  9:14                                   ` Hui Zhu
2013-06-25 11:47                                     ` Pedro Alves
2013-06-25 13:02                                       ` Hui Zhu
2013-06-25 14:06                                         ` Pedro Alves
2013-06-26  2:54                                           ` Hui Zhu
2013-05-22 14:04                   ` Tom Tromey
2013-02-22 17:39 ` DPrintf feedback (was: [RFC] PR 15075 dprintf interferes with "next") Marc Khouzam
2013-02-22 19:32   ` DPrintf feedback Tom Tromey
2013-02-22 20:37     ` Marc Khouzam
2013-02-26 21:12       ` Marc Khouzam
2013-02-28 15:32 ` [PATCH 1/4] Fix dprintf bugs Yao Qi
2013-02-28 13:17   ` [PATCH 2/4] Test case of conditional dprintf Yao Qi
2013-02-28 13:17   ` [PATCH 3/4] Test dprintf breakpoint works correctly with other breakpoints Yao Qi
2013-02-28 14:48   ` [PATCH 4/4] Test case on setting dprintf commands Yao Qi
2013-02-28 16:30   ` [PATCH 1/4] Fix dprintf bugs Eli Zaretskii
2013-03-07  7:45     ` Yao Qi
2013-03-03  2:21   ` Marc Khouzam
2013-03-07  6:47     ` Yao Qi
2013-03-07 14:06       ` Marc Khouzam
2013-03-07 14:36         ` Yao Qi
2013-03-07 14:49           ` Marc Khouzam
2013-03-07 14:59             ` Yao Qi
2013-03-08 15:49               ` Marc Khouzam

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=51C0A274.9010808@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    --cc=teawater@gmail.com \
    --cc=tromey@redhat.com \
    --cc=yao@codesourcery.com \
    /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