public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Adrian Sendroiu <adrian.sendroiu@freescale.com>,
	tromey@redhat.com,        gdb-patches@sourceware.org
Subject: Re: [PATCH v2 2/2] mi-out: Implement mi redirection using a stack.
Date: Thu, 31 Jul 2014 17:11:00 -0000	[thread overview]
Message-ID: <53DA6D73.5050906@redhat.com> (raw)
In-Reply-To: <1406819332-24242-1-git-send-email-adrian.sendroiu@freescale.com>

Awesome!  Thanks for doing this.

This is close.  Some notes on the technicalities below.

On 07/31/2014 04:08 PM, Adrian Sendroiu wrote:
> +# This triggers a nested mi_ui_out redirection, by disabling a breakpoint
> +# inside a python command that has to_string = True.
> +if ![mi_skip_python_tests] {
> +    mi_gdb_test "-break-insert do_nothing" ".*"
> +    mi_gdb_test "-break-commands 2 \"python gdb.execute('disable 2', True, True)\"" ".*"

It's better to use $bpnum instead of hardcoding 2, as otherwise if someone adds a
test that adds another breakpoint before this, this test stops being
effective, silently.

> +
> +    mi_gdb_test "-exec-continue" ".*"

This should use mi_send_resuming_command/mi_expect_stop
or mi_execute_to, so that the test works when the whole MI
testsuite is run in async mode.

> +
> +    set s [string repeat "A" 100]
> +
> +    # This will crash gdb if redirection is not done properly.
> +    mi_gdb_test "echo $s" ".*\\^done" "mi nested redirect"

In addition to that, it'd be good to confirm the breakpoint did
end up disabled, which likewise confirms the breakpoint command
was set on the breakpoint we wanted.  (might not need the "echo"
if that itself already causes a crash.)

> +proc mi_skip_python_tests {} {
> +    global mi_gdb_prompt
> +    global gdb_py_is_py3k
> +    global gdb_py_is_py24
> +
> +    gdb_test_multiple "python print ('test')" "verify python support" {
> +	-re "not supported.*$mi_gdb_prompt$"	{
> +	    unsupported "Python support is disabled."
> +	    return 1
> +	}
> +	-re "$mi_gdb_prompt$"	{}
> +    }
> +
> +    set gdb_py_is_py24 0
> +    gdb_test_multiple "python print (sys.version_info\[0\])" "check if python 3" {
> +	-re "3.*$mi_gdb_prompt$"	{
> +            set gdb_py_is_py3k 1
> +        }
> +	-re ".*$mi_gdb_prompt$"	{
> +            set gdb_py_is_py3k 0
> +        }
> +
> +    }
> +    if { $gdb_py_is_py3k == 0 } {
> +        gdb_test_multiple "python print (sys.version_info\[1\])" "check if python 2.4" {
> +	    -re "\[45\].*$mi_gdb_prompt$" {
> +                set gdb_py_is_py24 1
> +            }
> +	    -re ".*$mi_gdb_prompt$" {
> +                set gdb_py_is_py24 0
> +            }
> +        }
> +    }
> +
> +    return 0
> +}

I think that we can avoid this duplication by renaming
skip_python_tests, adding it a prompt_re parameter, and
using that instead of $gdb_prompt.  Something like:

proc skip_python_tests {} {
   skip_python_tests_prompt "$gdb_prompt $"
}

proc mi_skip_python_tests {
   skip_python_tests_prompt "$mi_gdb_prompt$"
}

Did you try that?

Thanks,
Pedro Alves

  reply	other threads:[~2014-07-31 16:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-23 14:26 [PATCH 0/2] Reimplement redirection for MI Adrian Sendroiu
2014-07-23 14:26 ` [PATCH 2/2] mi-out: Implement mi redirection using a stack Adrian Sendroiu
2014-07-24 20:34   ` Tom Tromey
2014-07-25 11:43     ` [PATCH v2 " Adrian Sendroiu
2014-07-29 15:16       ` Pedro Alves
2014-07-30  8:38         ` Adrian Sendroiu
2014-07-30 12:05           ` Pedro Alves
2014-07-31 16:23             ` Adrian Sendroiu
2014-07-31 17:11               ` Pedro Alves [this message]
2014-08-05 13:54                 ` Adrian Sendroiu
2014-08-28 11:33                   ` Adrian Sendroiu
2014-09-05 16:06                   ` Pedro Alves
2014-09-07 15:45                     ` Adrian Sendroiu
2014-09-08 13:19                   ` Pedro Alves
2014-09-08 18:59                     ` Sergio Durigan Junior
2014-09-09 14:03                     ` Adrian Sendroiu
2014-09-26  9:25                       ` Adrian Sendroiu
2014-09-26 12:51                         ` Pedro Alves
2014-07-23 14:37 ` [PATCH 1/2] cli/cli-logging.c: don't call ui_out_redirect for MI when disabling logging Adrian Sendroiu
2014-07-24 18:19   ` Tom Tromey
2015-08-17 18:47 ` [PATCH 0/2] Reimplement redirection for MI Doug Evans

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=53DA6D73.5050906@redhat.com \
    --to=palves@redhat.com \
    --cc=adrian.sendroiu@freescale.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).