Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Tom Tromey <tromey@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v3 6/6] Use correct inferior in Inferior.read_memory et al
Date: Fri, 14 Jul 2023 17:56:58 +0100	[thread overview]
Message-ID: <d9e835c0-4374-9015-f048-7686ce5c9c73@palves.net> (raw)
In-Reply-To: <20230713-py-inf-fixes-30615-v3-6-26a024f30553@adacore.com>

On 2023-07-13 15:05, Tom Tromey via Gdb-patches wrote:
> --- a/gdb/testsuite/gdb.python/py-inferior.exp
> +++ b/gdb/testsuite/gdb.python/py-inferior.exp
> @@ -91,6 +91,7 @@ gdb_py_test_silent_cmd "python addr = gdb.selected_frame ().read_var ('str')" \
>  gdb_test "python astr = gdb.inferiors()\[0\].read_memory (addr, 5); print(astr)" \
>      "<memory at $hex>" \
>      "read str contents"
> +gdb_test "python print(astr\[0\])" .*

This one game me pause.  Did you really intend to accept any output?  Should the match be a bit
more strict?  Otherwise, could you add a comment?

>  gdb_py_test_silent_cmd "python a = bytes('a', 'ascii')" "" 0
>  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)" \
> @@ -98,6 +99,10 @@ gdb_py_test_silent_cmd "python gdb.inferiors()\[0\].write_memory (addr, astr)" \
>  gdb_test "print str" " = \"hallo, testsuite\"" \
>    "ensure str was changed in the inferior"
>  
> +# Add a new inferior here, so we can test that operations work on the
> +# correct inferior.
> +set num [add_inferior]
> +
>  # Test memory search.
>  
>  set hex_number {0x[0-9a-fA-F][0-9a-fA-F]*}
> @@ -115,6 +120,9 @@ with_test_prefix "string" {
>      gdb_test_no_output "py start_addr = search_buf.address"
>      gdb_test_no_output "py length = search_buf.type.sizeof"
>  
> +    # Switch to the new inferior before testing.
> +    gdb_test "inferior $num" ".*" "switch to inferior $num"

I wouldn't mind making this a little tighter too, since it's so easy, like match:

   "Switching to inferior $num .*"

> +gdb_test "inferior 1" ".*" "switch back to inferior 1"

Ditto.

Otherwise LGTM.


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

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-13 14:05 [PATCH v3 0/6] Fix some Python Inferior methods Tom Tromey via Gdb-patches
2023-07-13 14:05 ` [PATCH v3 1/6] Minor cleanups in py-inferior.exp Tom Tromey via Gdb-patches
2023-07-13 14:05 ` [PATCH v3 2/6] Refactor py-inferior.exp Tom Tromey via Gdb-patches
2023-07-13 14:05 ` [PATCH v3 3/6] Rename Python variable in py-inferior.exp Tom Tromey via Gdb-patches
2023-07-13 14:05 ` [PATCH v3 4/6] Remove obsolete comment from gdbthread.h Tom Tromey via Gdb-patches
2023-07-13 14:05 ` [PATCH v3 5/6] Introduce scoped_restore_current_inferior_for_memory Tom Tromey via Gdb-patches
2023-07-13 14:05 ` [PATCH v3 6/6] Use correct inferior in Inferior.read_memory et al Tom Tromey via Gdb-patches
2023-07-14 16:56   ` Pedro Alves [this message]
2023-07-14 17:05     ` Tom Tromey

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=d9e835c0-4374-9015-f048-7686ce5c9c73@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