public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 3/6] Rename Python variable in py-inferior.exp
Date: Tue, 11 Jul 2023 10:14:03 -0600	[thread overview]
Message-ID: <20230711-py-inf-fixes-30615-v2-3-64a2540864e6@adacore.com> (raw)
In-Reply-To: <20230711-py-inf-fixes-30615-v2-0-64a2540864e6@adacore.com>

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 | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index 723f212ecc3..8762b6992ca 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -88,13 +88,14 @@ 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)" \
-  "read str contents" 1
+gdb_test "python astr = gdb.inferiors()\[0\].read_memory (addr, 5); print(astr)" \
+    "<memory at $hex>" \
+    "read str contents"
 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.

-- 
2.40.1


  parent reply	other threads:[~2023-07-11 16:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 16:14 [PATCH v2 0/6] Fix some Python Inferior methods Tom Tromey
2023-07-11 16:14 ` [PATCH v2 1/6] Minor cleanups in py-inferior.exp Tom Tromey
2023-07-11 16:14 ` [PATCH v2 2/6] Refactor py-inferior.exp Tom Tromey
2023-07-11 16:14 ` Tom Tromey [this message]
2023-07-14 16:34   ` [PATCH v2 3/6] Rename Python variable in py-inferior.exp Pedro Alves
2023-07-11 16:14 ` [PATCH v2 4/6] Remove obsolete comment from gdbthread.h Tom Tromey
2023-07-11 16:14 ` [PATCH v2 5/6] Introduce scoped_restore_current_inferior_for_memory Tom Tromey
2023-07-12 20:35   ` Simon Marchi
2023-07-13 14:01     ` Tom Tromey
2023-07-14 16:33   ` Pedro Alves
2023-07-11 16:14 ` [PATCH v2 6/6] Use correct inferior in Inferior.read_memory et al Tom Tromey
2023-07-14 16:48   ` Pedro Alves
2023-07-14 16:56     ` 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=20230711-py-inf-fixes-30615-v2-3-64a2540864e6@adacore.com \
    --to=tromey@adacore.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).