From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eaVbBIOgD2q1sQ0AWB0awg (envelope-from ) for ; Thu, 21 May 2026 20:17:07 -0400 Received: by simark.ca (Postfix, from userid 112) id 0EB481E024; Thu, 21 May 2026 20:17:07 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1A7B41E024 for ; Thu, 21 May 2026 20:17:06 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3FB748F52D2 for ; Fri, 22 May 2026 00:17:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3FB748F52D2 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by sourceware.org (Postfix) with ESMTPS id 33CD048F6659 for ; Fri, 22 May 2026 00:16:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 33CD048F6659 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 33CD048F6659 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779409000; cv=none; b=sj+pzVqWE8qMMujVU7wcnZMSeAfY71jbWNeChawxFMGJLZxdnNa3uMje/V31P0Yf7MsAkzddGmZfrD637k9K/xcNvq4r96ydWhA2OJlCe34r+clIaid1Ev3qv3+JSgyOfEtzdVuyyaR42XDY8rrurXCRqVXhBwWU+3S/ccRBOlA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779409000; c=relaxed/simple; bh=syHqas2lAYSpR8Ab2A3dMX/2hoAb3DzH4FiJCoz9ajc=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=F+Hi7up88J1D706RZNlReptmT2vGT2U98Bf9esyfwTBoXwoyBYfzBrKDs7Nfves+6RoHicuClNV2ot72KgZMyvI3DtcLqge/zeUPQKaXPyZGhUSo4vLZble2Brv7UhBXfORpmLfMdWFzvStYGU6RDY7WcFO4GcW6zw+kSWjo/c4= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 33CD048F6659 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-44e1ebb3122so4131620f8f.2 for ; Thu, 21 May 2026 17:16:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779408999; x=1780013799; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=kaY8hi3y29CjtTuME3dfffBIT8MGQ8chdKybPwYdooQ=; b=Kl/4DLWmY48NjrEGC+rvm8Ok1Z6xAeLgSjIQJNnI8zCS+N6gP+ii1CcL8XW6FKiQHO s9yGAvewZMyVqIelnVaT+86/iLtYFZUGC1UiXSOZoxwxKM4O5qTyMkN72EngTixcAJRI +Hm5K4HTqOpTkS9F1FzFvlMpO/M6toN8vKTJA/+xK2hgVqeIUYCMjzU3ijHfuuWMTwV3 HEj4YMeB46TyKxqAdG+hQH8XQGr5GUBZXeT4h9NRdQO6T51De8XnQDYYHVDFqlKUcErQ HOTfkcvjh7K8HtDBOzHzBIZ831MeS1qzN+SlVlHZslT5JMyrfMIlv6ChtHFfzqeDAuPg +T8g== X-Gm-Message-State: AOJu0Ywyp+xT/7pjpcxNWBSpPNWlbHmyVzRzOBwDlqe2aMSlWwkB3Ajf wr7Q0JXuZWqN0yiZxekjsl5KtkczySUapwCSNczeuVCdyp5MFHedQn0/dMEaag== X-Gm-Gg: Acq92OEsccS1MUfabywq0jT1DXWDlfa64h17FqU1fGONhCWDMwFv2Db0+5aFfyeml8G b6FxtkFN+Dz284+tQFna4C7BOkjgOnojUAG4KqyQ9mFzq1wtdKiUiiMwIjXLq3CMlH9euRb4OBp ZASsapjzOyAHOxekRxtzb2UIHRpNGer5U7g6w53M48WJISo2gfkUe+XJ8sJJzqpAn2ignHNVNDD S5ztEFjd6cyC/qoCOowSt5H8431L+MCEVSDRE0e66ox/XEPkgrwIoT310IeVK2l02g7siIQ+eBB oq8G9cIG7eJHqHVzc0CVbNw99z6YxGhsJletQpZk5yhgDtUp+4x/pTOF8BZ1mrKp8fDKwqtGQZb NDVYGZL4XCeAq5NCDMK4lFOrVm/q0l2HnuoUY8F8AezS0jY3oxQ6itvjzW3VZZY+oZxhLoZjc9P lXfkr5zTh3F4sh5xUUOh0BXg== X-Received: by 2002:a05:6000:2481:b0:43c:d665:3830 with SMTP id ffacd0b85a97d-45eb39e963bmr1356869f8f.32.1779408998994; Thu, 21 May 2026 17:16:38 -0700 (PDT) Received: from localhost ([2001:8a0:fae3:2600:cb04:347e:aaad:ca08]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-45eb497810dsm862965f8f.15.2026.05.21.17.16.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 May 2026 17:16:38 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 5/5] Adjust gdb.python/py-events.exp for Cygwin/MinGW Date: Fri, 22 May 2026 01:16:26 +0100 Message-ID: <20260522001626.393908-6-pedro@palves.net> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260522001626.393908-1-pedro@palves.net> References: <20260522001626.393908-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 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 This commit fixes several issues in gdb.python/py-events.exp for Cygwin and MinGW. With these fixed, the testcase passes cleanly on Cygwin. I haven't tested on MinGW, but at least the test should be able to compile & run there now. 1) - GDB prints Windows thread IDs in hex: (gdb) thread [Current thread is 1 (Thread 9528.0xa9c)] The corrent code assume decimal, so we only (incorrectly) extract the "0" after the dot. 2) - Thread and process ID number spaces are different. The current code assumes that the extract thread is is the same number as the extracted process id, which is not true on Windows. 3) - there is no "info proc" command on Windows The testcase is using "info proc" to extract the inferior's process it. But "info proc" does not exist on all targets, including Windows. Switch to using "inferior" instead. 4) - The testcase uses fork, and relies on "set detach-on-fork off" There is fork on Cygwin, but GDB can't follow forks there, so "detach-on-fork off" has no effect. And also, there is no fork on native Windows, which makes the testcase unusable on MinGW currently. I don't see any reason the testcase needs to use fork or multiple inferiors: - To test the clear_objfiles event, test a more directed "file" command instead of testing that following a fork emits it. - There's a test that quits gdb while some inferiors are being debugged, and it test that GDB emits gdb.ExitedEvent with no 'exit_code' attribute. Quitting while an inferior is being debugged makes GDB kill the inferior. So what that is really being tested is that killing an inferior emits such an event. So write such an explicit test. Also tested on x86_64-unknown-linux-gnu. Change-Id: I21ee8af7b52653c6fdff9b4c1596cdde3cfe751a commit-id: de2bf164 --- gdb/testsuite/gdb.python/py-events.c | 3 -- gdb/testsuite/gdb.python/py-events.exp | 73 ++++++++++++++------------ 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/gdb/testsuite/gdb.python/py-events.c b/gdb/testsuite/gdb.python/py-events.c index b1910f75ed9..6a0b407042a 100644 --- a/gdb/testsuite/gdb.python/py-events.c +++ b/gdb/testsuite/gdb.python/py-events.c @@ -15,12 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include - extern void do_nothing (void); int second(){ - fork() ; return 12; } diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index 16a290c31c2..5a40ee4ac97 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -45,8 +45,6 @@ gdb_breakpoint "main" {temporary} gdb_test "run" ".*event type: new_objfile.*new objfile name.*" "new objfile notification" -gdb_test_no_output "set detach-on-fork off" "" - gdb_test "test-events" "Event testers registered." gdb_breakpoint "first" @@ -76,17 +74,23 @@ delete_breakpoints # Test inferior call events set process_id "invalid" +set thread_id "invalid" gdb_test_multiple "thread" "get current thread" { -re -wrap "process ($decimal).*" { set process_id $expect_out(1,string) + set thread_id $process_id pass $gdb_test_name } -re -wrap "Thread $hex \\(LWP ($decimal)\\).*" { set process_id $expect_out(1,string) + set thread_id $process_id pass $gdb_test_name } - -re -wrap "Thread $decimal\.($decimal).*" { + -re -wrap "Thread ($decimal)\.($hex|$decimal).*" { set process_id $expect_out(1,string) + set thread_id $expect_out(2,string) + # Convert from hex to decimal. + set thread_id [expr {$thread_id}] pass $gdb_test_name } } @@ -99,9 +103,9 @@ gdb_test_multiple "print do_nothing" "get address of do_nothing" { } set expected [list "event type: pre-call"] -lappend expected "ptid: \\($process_id, $process_id, 0\\)" "address: $addr" +lappend expected "ptid: \\($process_id, $thread_id, 0\\)" "address: $addr" lappend expected "event type: post-call" -lappend expected "ptid: \\($process_id, $process_id, 0\\)" "address: $addr" +lappend expected "ptid: \\($process_id, $thread_id, 0\\)" "address: $addr" gdb_test_sequence "call do_nothing()" "" $expected # Test register changed event @@ -202,7 +206,7 @@ gdb_test_no_output "delete $second_breakpoint" #test exited event. proc get_process_id {test} { global gdb_prompt - gdb_test_multiple "info proc" $test { + gdb_test_multiple "inferior" $test { -re "process (\\d+).*$gdb_prompt $" { set process_id $expect_out(1,string) pass $gdb_test_name @@ -211,24 +215,13 @@ proc get_process_id {test} { return ${process_id} } -set process_id [get_process_id "get inferior 1 process id"] +set process_id [get_process_id "get inferior process id"] gdb_test "continue" ".*event type: continue.* -.*clear_objfiles\[\r\n\]*progspace: .*py-events.* .*event type: exit.* .*exit code: 12.* .*exit inf: 1.* .*exit pid: $process_id.* -dir ok: True.*" "Inferior 1 terminated." - -gdb_test "inferior 2" ".*Switching to inferior 2.*" -set process_id [get_process_id "get inferior 2 process id"] -gdb_test "continue" ".*event type: continue.* -.*event type: exit.* -.*exit code: 12.* -.*exit inf: 2.* -.*exit pid: $process_id.* -dir ok: True.*" "Inferior 2 terminated." - +dir ok: True.*" "inferior terminated" # Test before_prompt event. gdb_test_multiline "define new user command" \ @@ -280,29 +273,30 @@ with_test_prefix "inferior continue exit" { gdb_test "print \$_foo" "= 2" "check foo after start continue" } -# Check that when GDB exits, we see gdb.ExitedEvent objects with no -# 'exit_code' attribute, and that a gdb.GdbExitingEvent is emitted. -with_test_prefix "gdb exiting: normal" { +# Check that when GDB kills an inferior, we see gdb.ExitedEvent +# objects with no 'exit_code' attribute. +with_test_prefix "kill inferior" { + if {![runto_main]} { + return + } gdb_test "test-exiting-event normal" "GDB exiting event registered\\." + gdb_test "with confirm off -- kill" \ + "event type: exit\r\nexit code: not-present\r\nexit inf: $decimal\r\nexit pid: $decimal\r\ndir ok: False\r\n.*" \ + "exit code not present" +} + +# Check that when GDB exits, we see that a gdb.GdbExitingEvent is +# emitted. +with_test_prefix "gdb exiting: normal" { set saw_exiting_event 0 - set saw_inferior_exit 0 - gdb_test_multiple "quit" "" { - -re "Quit anyway\\? \\(y or n\\) $" { - send_gdb "y\n" - exp_continue - } + gdb_test_multiple "with confirm off -- quit" "quit" { -re "event type: gdb-exiting\r\nexit code: $decimal" { incr saw_exiting_event exp_continue } - -re "event type: exit\r\nexit code: not-present\r\nexit inf: $decimal\r\nexit pid: $decimal\r\ndir ok: False\r\n" { - incr saw_inferior_exit - exp_continue - } eof { gdb_assert { $saw_exiting_event == 1 } - gdb_assert { $saw_inferior_exit == 2 } pass $gdb_test_name } } @@ -348,3 +342,16 @@ with_test_prefix "gdb exiting: error" { } } } + +# Test clear_objfiles event. + +with_test_prefix "clear_objfiles" { + clean_restart ${testfile} + + gdb_test_no_output "source ${pyfile}" "load python file" + gdb_test "test-objfile-events" "Object file events registered." + + gdb_test "with confirm off -- file" \ + "event type: clear_objfiles\r\nprogspace: None\r\n.*" \ + "file cleared" +} -- 2.53.0