public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 3/5] Rename Python variable in py-inferior.exp
Date: Fri, 7 Jul 2023 19:14:50 +0100	[thread overview]
Message-ID: <d28ef1aa-f1d0-f70b-cdf5-61e70fb617df@palves.net> (raw)
In-Reply-To: <20230707-py-inf-fixes-30615-v1-3-7792ab559530@adacore.com>

On 2023-07-07 16:07, Tom Tromey via Gdb-patches wrote:
> py-inferior.exp creates a Python variable named 'str'.  This clashes
> with the built-in type of the same name and can be confusing when
> trying to evaluate Python code when debugging the test case.  This
> patch renames it.
> ---
>  gdb/testsuite/gdb.python/py-inferior.exp | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
> index a29624f4fd5..41e26878031 100644
> --- a/gdb/testsuite/gdb.python/py-inferior.exp
> +++ b/gdb/testsuite/gdb.python/py-inferior.exp
> @@ -88,13 +88,13 @@ gdb_continue_to_breakpoint "cont to Break here." ".*Break here\..*"
>  
>  gdb_py_test_silent_cmd "python addr = gdb.selected_frame ().read_var ('str')" \
>    "read str address" 0
> -gdb_py_test_silent_cmd "python str = gdb.inferiors()\[0\].read_memory (addr, 5); print(str)" \
> +gdb_py_test_silent_cmd "python astr = gdb.inferiors()\[0\].read_memory (addr, 5); print(str)" \

Shouldn't the "print(str)" after the ; be adjusted as well?  How can this pass as is?

>    "read str contents" 1
>  gdb_py_test_silent_cmd "python a = bytes('a', 'ascii')" "" 0
> -gdb_py_test_silent_cmd "python str\[1\] = a" "change str" 0
> -gdb_py_test_silent_cmd "python gdb.inferiors()\[0\].write_memory (addr, str)" \
> +gdb_py_test_silent_cmd "python astr\[1\] = a" "change str" 0
> +gdb_py_test_silent_cmd "python gdb.inferiors()\[0\].write_memory (addr, astr)" \
>    "write str" 1
> -gdb_test "print (str)" " = \"hallo, testsuite\"" \
> +gdb_test "print str" " = \"hallo, testsuite\"" \
>    "ensure str was changed in the inferior"
>  
>  # Test memory search.
> 


  reply	other threads:[~2023-07-07 18:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-07 15:07 [PATCH 0/5] Fix some Python Inferior methods Tom Tromey
2023-07-07 15:07 ` [PATCH 1/5] Minor cleanups in py-inferior.exp Tom Tromey
2023-07-07 18:06   ` Pedro Alves
2023-07-11 15:05     ` Tom Tromey
2023-07-07 15:07 ` [PATCH 2/5] Refactor py-inferior.exp Tom Tromey
2023-07-07 18:12   ` Pedro Alves
2023-07-07 15:07 ` [PATCH 3/5] Rename Python variable in py-inferior.exp Tom Tromey
2023-07-07 18:14   ` Pedro Alves [this message]
2023-07-11 15:19     ` Tom Tromey
2023-07-07 15:08 ` [PATCH 4/5] Remove obsolete comment from gdbthread.h Tom Tromey
2023-07-07 18:15   ` Pedro Alves
2023-07-07 15:08 ` [PATCH 5/5] Use correct inferior in Inferior.read_memory et al Tom Tromey
2023-07-07 18:26   ` Pedro Alves
2023-07-07 18:27     ` Pedro Alves

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=d28ef1aa-f1d0-f70b-cdf5-61e70fb617df@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@adacore.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).