From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cDJPO29+sWQTqyEAWB0awg (envelope-from ) for ; Fri, 14 Jul 2023 12:57:19 -0400 Received: by simark.ca (Postfix, from userid 112) id EF6F11E0BD; Fri, 14 Jul 2023 12:57:19 -0400 (EDT) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id D635B1E00F for ; Fri, 14 Jul 2023 12:57:17 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3E993385841E for ; Fri, 14 Jul 2023 16:57:17 +0000 (GMT) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by sourceware.org (Postfix) with ESMTPS id B8F093858C52 for ; Fri, 14 Jul 2023 16:57:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B8F093858C52 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-3142a9ff6d8so2167122f8f.3 for ; Fri, 14 Jul 2023 09:57:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689353820; x=1691945820; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=va68I7klKReD3DN04fllOyEc2DMUvLDq8irnUY1ezmI=; b=lMUWswnwJNzkimiE4oUgETYDn2wJDriBO/XTi2a48exnV+jtXmpW+5e8AjhYA0IVMf cfPYJiKe1AWEtoZSRytotbUqXSYwB2rhGdLAvw8W32YsE6/wgPzIyx0d6+mnfmcvbAGH SBxxA8a7v9FUHGnw1C852nAKOMlfKB/fAI3WeoaU8L+vZVsZjsMf5fSUEsTZYP0uhbHA YVMG3unpWLBjJKxxsaBaiuHncUl4A1+MJGQw/NAMNoTj7O9B70WdCIavrqZT10tVn2OS xDS2+FL0vfBBqo3NoOhHEs7EuVQovXO8D0E2Y9cY5blRypBVhLIIfMoNC5MPd64FsVir Ex7Q== X-Gm-Message-State: ABy/qLZrDPQZby7MBw4RrMpwzpvxCxBv/UHSLZIMr/i/IO/d2AuYX5AM 4YOeD+9Mxhy/DGzyLTxkbvo= X-Google-Smtp-Source: APBJJlEfh9z0VktaGU8mRjqyJELFh1s+ASZDi4R8UDbbYJU4GK4VzPBMvRHPbeKxCRd26/xwsjVWtQ== X-Received: by 2002:a5d:40ce:0:b0:313:f61c:42ab with SMTP id b14-20020a5d40ce000000b00313f61c42abmr4823779wrq.56.1689353820203; Fri, 14 Jul 2023 09:57:00 -0700 (PDT) Received: from ?IPV6:2001:8a0:f91d:bc00:98b3:dfb7:8070:8955? ([2001:8a0:f91d:bc00:98b3:dfb7:8070:8955]) by smtp.gmail.com with ESMTPSA id o6-20020adfeac6000000b00314145e6d61sm11459771wrn.6.2023.07.14.09.56.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Jul 2023 09:56:59 -0700 (PDT) Message-ID: Date: Fri, 14 Jul 2023 17:56:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v3 6/6] Use correct inferior in Inferior.read_memory et al Content-Language: en-US To: Tom Tromey , gdb-patches@sourceware.org References: <20230713-py-inf-fixes-30615-v3-0-26a024f30553@adacore.com> <20230713-py-inf-fixes-30615-v3-6-26a024f30553@adacore.com> From: Pedro Alves In-Reply-To: <20230713-py-inf-fixes-30615-v3-6-26a024f30553@adacore.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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)" \ > "" \ > "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.