Skip to content

Commit

Permalink
Make 'info threads' after a failed run not try to print threads
Browse files Browse the repository at this point in the history
  • Loading branch information
dzaima committed Feb 23, 2024
1 parent 2e4b211 commit 0590bc8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/GdbServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ void GdbServer::dispatch_debugger_request(Session& session,
return;
case DREQ_GET_THREAD_LIST: {
vector<GdbThreadId> tids;
if (state != REPORT_THREADS_DEAD) {
if (state != REPORT_THREADS_DEAD && !failed_restart) {
for (auto& kv : session.tasks()) {
tids.push_back(get_threadid(session, kv.second->tuid()));
}
Expand Down Expand Up @@ -1504,6 +1504,7 @@ void GdbServer::restart_session(const GdbRequest& req) {
DEBUG_ASSERT(req.type == DREQ_RESTART);
DEBUG_ASSERT(dbg);

failed_restart = false;
in_debuggee_end_state = false;
timeline.remove_breakpoints_and_watchpoints();

Expand All @@ -1517,6 +1518,7 @@ void GdbServer::restart_session(const GdbRequest& req) {
cout << " " << c.first;
}
cout << "\n";
failed_restart = true;
dbg->notify_restart_failed();
return;
}
Expand All @@ -1528,6 +1530,7 @@ void GdbServer::restart_session(const GdbRequest& req) {
FrameTime time = compute_time_from_ticks(timeline, ticks);
if (time == -1) {
cout << "No event found matching specified ticks target.\n";
failed_restart = true;
dbg->notify_restart_failed();
return;
}
Expand Down
2 changes: 2 additions & 0 deletions src/GdbServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ class GdbServer {
// siginfo for last notified stop.
siginfo_t stop_siginfo;
bool in_debuggee_end_state;
// True when a restart was attempted but didn't succeed.
bool failed_restart;
// True when the user has interrupted replaying to a target event.
volatile bool stop_replaying_to_target;
// True when a DREQ_INTERRUPT has been received but not handled, or when
Expand Down
6 changes: 6 additions & 0 deletions src/test/restart_invalid_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
send_gdb('checkpoint')
expect_gdb('Checkpoint 1 at')
send_gdb('restart 8')

send_gdb('info threads')
# Don't expect anything specific from 'info threads', but make sure gdb at least functions
send_gdb('p 987654321+1')
expect_gdb('987654322')

send_gdb('restart -1')
send_gdb('restart abc')
send_gdb('restart 1')
Expand Down
6 changes: 6 additions & 0 deletions src/test/seekticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,10 @@
if ticks8 != ticks7:
failed("ERROR: seek-ticks didn't go to correct tick on test %d" % i)

send_gdb('seek-ticks 2000000000')
expect_gdb('No event found matching specified ticks target')
send_gdb('info threads')
# don't expect anything specific from 'info threads', but make sure gdb at least functions
send_gdb('p 123456789+1')
expect_gdb('123456790')
ok()
15 changes: 13 additions & 2 deletions src/test/seekticks_threads.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from util import *
import re, os

send_gdb('restart 9')
expect_gdb(re.compile(r'Checkpoint 9 not found'))

def curr_thread():
send_gdb('thread')
expect_gdb(re.compile(r'\[Current thread is \d+ \(Thread (.*?)\)\]'))
Expand Down Expand Up @@ -44,12 +47,15 @@ def expect_stopped():
[event_C, tick_B, tick_D]]

threads = set()
is_first = True
for [start_event, initial_tick, other_tick] in tests:
center_tick = (initial_tick + other_tick) // 2

send_gdb('run %d' % start_event)
expect_gdb('from the beginning')
send_gdb('y')
if not is_first:
expect_gdb('from the beginning')
send_gdb('y')
is_first = False
expect_stopped()

thread = curr_thread()
Expand Down Expand Up @@ -82,6 +88,11 @@ def expect_stopped():
send_gdb('seek-ticks %d' % other_tick)
expect_stopped()
expect_thread_tick(thread, other_tick)

send_gdb('info threads')
expect_gdb(r'\d\s*Thread')
expect_gdb(r'\d\s*Thread')

if len(threads) != 2:
failed('ERROR: Tested events had the same thread')

Expand Down

0 comments on commit 0590bc8

Please sign in to comment.