From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7BE643858D3C; Sun, 1 Oct 2023 03:53:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BE643858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696132411; bh=Tj6/oi34YMfedp2YoHi1GX/jiD2u4iOM7VUcde3Z6s8=; h=From:To:Subject:Date:From; b=Dr0B6C61rqE7sYuz+W6apRkVj2PCDWkOxEiY0Pt4xVPUXbfXQj1o+gQflhah69k6u DQrtBKdo9bNPqe1bT9iwj5enixIh6wy3+BtyWO7Qi40LZQ5JIeWZO2ClVZY+9KHNDV X4qsgGfcEycae5qwgiuVUYjP2Mb1VE2ugk4ypihs= From: "simark at simark dot ca" To: gdb-prs@sourceware.org Subject: [Bug gdb/30926] New: FAIL: gdb.threads/detach-step-over.exp: breakpoint-condition-evaluation=host: target-non-stop=on: non-stop=on: displaced=off: test_detach_command: iter 921: attach (GDB internal error) Date: Sun, 01 Oct 2023 03:53:27 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: simark at simark dot ca X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30926 Bug ID: 30926 Summary: FAIL: gdb.threads/detach-step-over.exp: breakpoint-condition-evaluation=3Dhost: target-non-stop=3Don: non-stop=3Don: displaced=3Doff: test_detach_command: iter 921: attach (GDB internal error) Product: gdb Version: HEAD Status: NEW Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: simark at simark dot ca Target Milestone: --- I often see gdb.threads/detach-step-over.exp failing in my test runs. I isolated one of them: FAIL: gdb.threads/detach-step-over.exp: breakpoint-condition-evaluation=3Dh= ost: target-non-stop=3Don: non-stop=3Don: displaced=3Doff: test_detach_command: = iter 921: attach (GDB internal error) I made the following changes to make the investigation easier: ~~~ diff --git a/gdb/debug.c b/gdb/debug.c index ca8fb1072712..d9978974fe6b 100644 --- a/gdb/debug.c +++ b/gdb/debug.c @@ -20,6 +20,7 @@ #include "defs.h" #include "gdbsupport/common-debug.h" +#include "gdbsupport/filestuff.h" /* See gdbsupport/common-debug.h. */ @@ -30,5 +31,15 @@ int debug_print_depth =3D 0; void debug_vprintf (const char *fmt, va_list ap) { - gdb_vprintf (gdb_stdlog, fmt, ap); + static gdb_file_up f; + static std::unique_ptr u; + if (!f) + { + f =3D gdb_fopen_cloexec ("/tmp/log", "w"); + gdb_assert (f); + u =3D gdb::make_unique (f.get (), true); + } + + gdb_vprintf (u.get(), fmt, ap); + u->flush (); } diff --git a/gdb/infrun.c b/gdb/infrun.c index 4730d2904423..e2f9369b9e3b 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -1423,6 +1423,7 @@ struct step_over_info /* The thread's global number. */ int thread =3D -1; + ptid_t ptid =3D minus_one_ptid; }; /* The step-over info of the location that is being stepped over. @@ -1459,12 +1460,13 @@ static struct step_over_info step_over_info; static void set_step_over_info (const address_space *aspace, CORE_ADDR address, int nonsteppable_watchpoint_p, - int thread) + thread_info *thread) { step_over_info.aspace =3D aspace; step_over_info.address =3D address; step_over_info.nonsteppable_watchpoint_p =3D nonsteppable_watchpoint_p; - step_over_info.thread =3D thread; + step_over_info.thread =3D thread ? thread->global_num : -1; + step_over_info.ptid =3D thread ? thread->ptid : minus_one_ptid; } /* Called when we're not longer stepping over a breakpoint / an @@ -1478,6 +1480,7 @@ clear_step_over_info (void) step_over_info.address =3D 0; step_over_info.nonsteppable_watchpoint_p =3D 0; step_over_info.thread =3D -1; + step_over_info.ptid =3D minus_one_ptid; } /* See infrun.h. */ @@ -2649,7 +2652,7 @@ resume_1 (enum gdb_signal sig) stop_all_threads ("displaced stepping falling back on inline stepping"); set_step_over_info (regcache->aspace (), - regcache_read_pc (regcache), 0, tp->global_nu= m); + regcache_read_pc (regcache), 0, tp); step =3D maybe_software_singlestep (gdbarch); @@ -8526,10 +8529,10 @@ keep_going_pass_signal (struct execution_control_st= ate *ecs) { set_step_over_info (regcache->aspace (), regcache_read_pc (regcache), remove_wps, - ecs->event_thread->global_num); + ecs->event_thread); } else if (remove_wps) - set_step_over_info (nullptr, 0, remove_wps, -1); + set_step_over_info (nullptr, 0, remove_wps, nullptr); /* If we now need to do an in-line step-over, we need to stop all other threads. Note this must be done before diff --git a/gdb/testsuite/gdb.threads/detach-step-over.exp b/gdb/testsuite/gdb.threads/detach-step-over.exp index 345c77e2c690..4806e20a5a6f 100644 --- a/gdb/testsuite/gdb.threads/detach-step-over.exp +++ b/gdb/testsuite/gdb.threads/detach-step-over.exp @@ -214,7 +214,8 @@ proc_with_prefix test_detach_command {condition_eval target_non_stop non_stop di } } - set attempts 3 + set attempts 1000 + gdb_test "set debug infrun" for {set attempt 1} { $attempt <=3D $attempts } { incr attempt } { with_test_prefix "iter $attempt" { gdb_test "inferior 1" "Switching to .*" @@ -377,24 +378,22 @@ gdb_test_multiple $cmd "probe condition-evaluation ta= rget support" { } } -foreach_with_prefix breakpoint-condition-evaluation {"host" "target"} { +foreach_with_prefix breakpoint-condition-evaluation {"host"} { if {!$supports_condition_eval_target && ${breakpoint-condition-evaluat= ion} =3D=3D "target"} { continue } - foreach_with_prefix target-non-stop {"off" "on"} { - foreach_with_prefix non-stop {"off" "on"} { + foreach_with_prefix target-non-stop {"on"} { + foreach_with_prefix non-stop {"on"} { if {${non-stop} && !${target-non-stop}} { # "set non-stop" overrides "maint set # target-non-stop", no use testing this combination. continue } - foreach_with_prefix displaced {"off" "auto"} { + foreach_with_prefix displaced {"off"} { test_detach_command ${breakpoint-condition-evaluation} \ ${target-non-stop} ${non-stop} ${displaced} - test_detach_quit ${breakpoint-condition-evaluation} \ - ${target-non-stop} ${non-stop} ${displaced} } } } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index de22da8d8a8c..ecf0f236585e 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1212,6 +1212,9 @@ proc gdb_test_multiple { command message args } { append code { -re ".*A problem internal to GDB has been detected" { fail "$message (GDB internal error)" + # Let us attach to GDB while it's still in the internal error c= all stack + set ::timeout 888888 + sleep 1231231 gdb_internal_error_resync set result -1 } ~~~ The tail end of /tmp/log is: [infrun] fetch_inferior_event: enter [infrun] scoped_disable_commit_resumed: reason=3Dhandling event [infrun] random_resumed_with_pending_wait_status: Found 9 events, selecti= ng #6 [infrun] random_pending_event_thread: Found 4185505.4185515.0. [infrun] do_target_wait_1: Using pending wait status status->kind =3D STO= PPED, sig =3D GDB_SIGNAL_TRAP for 4185505.4185515.0. [infrun] maybe_remove_resumed_with_pending_wait_status: removing from res= umed threads with event list: 4185505.4185515.0 [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1], sta= tus) =3D [infrun] print_target_wait_results: 4185505.4185515.0 [Thread 0x7ffff44b76c0 (LWP 4185515)], [infrun] print_target_wait_results: status->kind =3D STOPPED, sig =3D GDB_SIGNAL_TRAP [infrun] handle_inferior_event: status->kind =3D STOPPED, sig =3D GDB_SIG= NAL_TRAP [infrun] start_step_over: enter [infrun] start_step_over: stealing global queue of threads to step, len= gth =3D 0 [infrun] operator(): step-over queue now empty [infrun] start_step_over: exit [infrun] context_switch: Switching context from 0.0.0 to 4185505.4185515.0 [infrun] handle_signal_stop: stop_pc=3D0x5555555551af [infrun] bpstat_check_breakpoint_conditions: enter [infrun] bpstat_check_breakpoint_conditions: thread =3D 4185505.4185515= .0, breakpoint 921.1 [infrun] bpstat_check_breakpoint_conditions: condition_result =3D false= , not stopping [infrun] bpstat_check_breakpoint_conditions: exit [infrun] process_event_stop_test: BPSTAT_WHAT_SINGLE [infrun] process_event_stop_test: no stepping, continue [infrun] stop_all_threads: start: reason=3Dstarting in-line step-over, in= f=3D-1 [infrun] infrun_debug_show_threads: enter [infrun] infrun_debug_show_threads: non-exited threads: [infrun] infrun_debug_show_threads: thread 4185505.4185505.0, execu= ting =3D 1, resumed =3D 1, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185505.4185508.0, execu= ting =3D 0, resumed =3D 1, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185505.4185509.0, execu= ting =3D 0, resumed =3D 1, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185505.4185510.0, execu= ting =3D 0, resumed =3D 1, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185505.4185511.0, execu= ting =3D 0, resumed =3D 1, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185505.4185512.0, execu= ting =3D 0, resumed =3D 0, state =3D STOPPED [infrun] infrun_debug_show_threads: thread 4185505.4185513.0, execu= ting =3D 0, resumed =3D 1, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185505.4185514.0, execu= ting =3D 0, resumed =3D 1, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185505.4185515.0, execu= ting =3D 0, resumed =3D 0, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185505.4185516.0, execu= ting =3D 0, resumed =3D 1, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185505.4185517.0, execu= ting =3D 0, resumed =3D 1, state =3D RUNNING [infrun] infrun_debug_show_threads: exit [infrun] stop_all_threads: pass=3D0, iterations=3D0 [infrun] stop_all_threads: 4185505.4185505.0 executing, need stop [infrun] stop_all_threads: 4185505.4185508.0 not executing [infrun] maybe_remove_resumed_with_pending_wait_status: removing from resumed threads with event list: 4185505.4185508.0 [infrun] stop_all_threads: 4185505.4185509.0 not executing [infrun] maybe_remove_resumed_with_pending_wait_status: removing from resumed threads with event list: 4185505.4185509.0 [infrun] stop_all_threads: 4185505.4185510.0 not executing [infrun] maybe_remove_resumed_with_pending_wait_status: removing from resumed threads with event list: 4185505.4185510.0 [infrun] stop_all_threads: 4185505.4185511.0 not executing [infrun] maybe_remove_resumed_with_pending_wait_status: removing from resumed threads with event list: 4185505.4185511.0 [infrun] stop_all_threads: 4185505.4185512.0 not executing [infrun] stop_all_threads: 4185505.4185513.0 not executing [infrun] maybe_remove_resumed_with_pending_wait_status: removing from resumed threads with event list: 4185505.4185513.0 [infrun] stop_all_threads: 4185505.4185514.0 not executing [infrun] maybe_remove_resumed_with_pending_wait_status: removing from resumed threads with event list: 4185505.4185514.0 [infrun] stop_all_threads: 4185505.4185515.0 not executing [infrun] stop_all_threads: 4185505.4185516.0 not executing [infrun] maybe_remove_resumed_with_pending_wait_status: removing from resumed threads with event list: 4185505.4185516.0 [infrun] stop_all_threads: 4185505.4185517.0 not executing [infrun] maybe_remove_resumed_with_pending_wait_status: removing from resumed threads with event list: 4185505.4185517.0 [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1], status) =3D [infrun] print_target_wait_results: 4185505.4185505.0 [Thread 0x7ffff7cbf740 (LWP 4185505)], [infrun] print_target_wait_results: status->kind =3D STOPPED, sig =3D GDB_SIGNAL_0 [infrun] handle_one: status->kind =3D STOPPED, sig =3D GDB_SIGNAL_0 4185505.4185505.0 [infrun] stop_all_threads: 4185505.4185505.0 not executing [infrun] stop_all_threads: 4185505.4185508.0 not executing [infrun] stop_all_threads: 4185505.4185509.0 not executing [infrun] stop_all_threads: 4185505.4185510.0 not executing [infrun] stop_all_threads: 4185505.4185511.0 not executing [infrun] stop_all_threads: 4185505.4185512.0 not executing [infrun] stop_all_threads: 4185505.4185513.0 not executing [infrun] stop_all_threads: 4185505.4185514.0 not executing [infrun] stop_all_threads: 4185505.4185515.0 not executing [infrun] stop_all_threads: 4185505.4185516.0 not executing [infrun] stop_all_threads: 4185505.4185517.0 not executing [infrun] stop_all_threads: pass=3D1, iterations=3D1 [infrun] stop_all_threads: 4185505.4185505.0 not executing [infrun] stop_all_threads: 4185505.4185508.0 not executing [infrun] stop_all_threads: 4185505.4185509.0 not executing [infrun] stop_all_threads: 4185505.4185510.0 not executing [infrun] stop_all_threads: 4185505.4185511.0 not executing [infrun] stop_all_threads: 4185505.4185512.0 not executing [infrun] stop_all_threads: 4185505.4185513.0 not executing [infrun] stop_all_threads: 4185505.4185514.0 not executing [infrun] stop_all_threads: 4185505.4185515.0 not executing [infrun] stop_all_threads: 4185505.4185516.0 not executing [infrun] stop_all_threads: 4185505.4185517.0 not executing [infrun] stop_all_threads: done [infrun] stop_all_threads: end: reason=3Dstarting in-line step-over, inf= =3D-1 [infrun] should_be_inserted: skipping breakpoint: stepping past insn at: 0x5555555551af [infrun] should_be_inserted: skipping breakpoint: stepping past insn at: 0x5555555551af [infrun] should_be_inserted: skipping breakpoint: stepping past insn at: 0x5555555551af [infrun] resume_1: step=3D1, signal=3DGDB_SIGNAL_0, trap_expected=3D1, cu= rrent thread [4185505.4185515.0] at 0x5555555551af [infrun] do_target_resume: resume_ptid=3D4185505.4185515.0, step=3D1, sig=3DGDB_SIGNAL_0 [infrun] prepare_to_wait: prepare_to_wait [infrun] reset: reason=3Dhandling event [infrun] maybe_set_commit_resumed_all_targets: enabling commit-resumed for target native [infrun] maybe_call_commit_resumed_all_targets: calling commit_resumed for target native [infrun] fetch_inferior_event: exit [infrun] fetch_inferior_event: enter [infrun] scoped_disable_commit_resumed: reason=3Dhandling event [infrun] random_pending_event_thread: None found. [infrun] fetch_inferior_event: do_target_wait returned no event [infrun] reset: reason=3Dhandling event [infrun] maybe_set_commit_resumed_all_targets: enabling commit-resumed for target native [infrun] maybe_call_commit_resumed_all_targets: calling commit_resumed for target native [infrun] fetch_inferior_event: exit [infrun] scoped_disable_commit_resumed: reason=3Dattaching [infrun] infrun_debug_show_threads: enter [infrun] infrun_debug_show_threads: immediately after attach: [infrun] infrun_debug_show_threads: thread 4185444.4185444.0, executing= =3D 1, resumed =3D 0, state =3D STOPPED [infrun] infrun_debug_show_threads: thread 4185444.4185449.0, executing= =3D 1, resumed =3D 0, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185444.4185450.0, executing= =3D 1, resumed =3D 0, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185444.4185451.0, executing= =3D 1, resumed =3D 0, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185444.4185452.0, executing= =3D 1, resumed =3D 0, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185444.4185453.0, executing= =3D 1, resumed =3D 0, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185444.4185454.0, executing= =3D 1, resumed =3D 0, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185444.4185455.0, executing= =3D 1, resumed =3D 0, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185444.4185456.0, executing= =3D 1, resumed =3D 0, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185444.4185457.0, executing= =3D 1, resumed =3D 0, state =3D RUNNING [infrun] infrun_debug_show_threads: thread 4185444.4185458.0, executing= =3D 1, resumed =3D 0, state =3D RUNNING [infrun] infrun_debug_show_threads: exit [infrun] clear_proceed_status_thread: 4185444.4185444.0 [infrun] reset: reason=3Dattaching [infrun] maybe_set_commit_resumed_all_targets: enabling commit-resumed for target native [infrun] fetch_inferior_event: enter [infrun] scoped_disable_commit_resumed: reason=3Dhandling event [infrun] do_target_wait: Found 2 inferiors, starting at #1 [infrun] random_pending_event_thread: None found. [infrun] print_target_wait_results: target_wait (-1.0.0 [process -1], sta= tus) =3D [infrun] print_target_wait_results: 4185444.4185444.0 [LWP 4185444], [infrun] print_target_wait_results: status->kind =3D STOPPED, sig =3D GDB_SIGNAL_STOP [infrun] handle_inferior_event: status->kind =3D STOPPED, sig =3D GDB_SIG= NAL_STOP [infrun] infrun_async: enable=3D0 My interpretation of the situation is: - We start an inline step for a thread of inferior 2 - We attach to a process with inferior 1 - The initial post-attach stop event for inferior 1 gets reported before inferior 2's "done stepping" event - The assertion that verifies that "if a thread is doing an in-line step o= ver, any event must be for that thread" fails --=20 You are receiving this mail because: You are on the CC list for the bug.=