Skip to content

Commit

Permalink
Report a more useful error if we can't find the current task
Browse files Browse the repository at this point in the history
  • Loading branch information
rocallahan committed May 14, 2024
1 parent 25063eb commit b7c3913
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/GdbServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,19 @@ GdbServer::ContinueOrStop GdbServer::handle_exited_state(
return STOP_DEBUGGING;
}

ReplayTask* GdbServer::require_timeline_current_task() {
if (!timeline_) {
FATAL() << "Timeline required here";
}
ReplayTask* t = timeline_->current_session().current_task();
if (!t) {
FATAL() << "Expected current task but none found; expected task with tid "
<< timeline_->current_session().current_trace_frame().tid()
<< " at event " << timeline_->current_session().current_frame_time();
}
return t;
}

GdbServer::ContinueOrStop GdbServer::debug_one_step(
GdbRequest& last_resume_request) {
if (!timeline_) {
Expand Down Expand Up @@ -1428,7 +1441,7 @@ GdbServer::ContinueOrStop GdbServer::debug_one_step(
}

if (interrupt_pending) {
Task* t = timeline_->current_session().current_task();
Task* t = require_timeline_current_task();
if (t->thread_group()->tguid() == debuggee_tguid) {
interrupt_pending = false;
notify_stop_internal(timeline_->current_session(),
Expand All @@ -1439,7 +1452,7 @@ GdbServer::ContinueOrStop GdbServer::debug_one_step(
}

if (exit_sigkill_pending) {
Task* t = timeline_->current_session().current_task();
Task* t = require_timeline_current_task();
if (t->thread_group()->tguid() == debuggee_tguid) {
exit_sigkill_pending = false;
if (req.cont().run_direction == RUN_FORWARD) {
Expand All @@ -1453,15 +1466,15 @@ GdbServer::ContinueOrStop GdbServer::debug_one_step(

if (req.cont().run_direction == RUN_FORWARD) {
if (is_in_exec(timeline_) &&
timeline_->current_session().current_task()->thread_group()->tguid() ==
require_timeline_current_task()->thread_group()->tguid() ==
debuggee_tguid) {
// Don't go any further forward. maybe_notify_stop will generate a
// stop.
result = ReplayResult();
} else {
int signal_to_deliver;
RunCommand command = compute_run_command_from_actions(
timeline_->current_session().current_task(), req, &signal_to_deliver);
require_timeline_current_task(), req, &signal_to_deliver);
// Ignore gdb's |signal_to_deliver|; we just have to follow the replay.
result = timeline_->replay_step_forward(command);
}
Expand Down Expand Up @@ -1591,7 +1604,7 @@ void GdbServer::activate_debugger() {
}
TraceFrame next_frame = timeline_->current_session().current_trace_frame();
FrameTime completed_event = next_frame.time() - 1;
Task* t = timeline_->current_session().current_task();
Task* t = require_timeline_current_task();
if (target.event || target.pid) {
if (stop_replaying_to_target && *stop_replaying_to_target) {
fprintf(stderr, "\a\n"
Expand Down
1 change: 1 addition & 0 deletions src/GdbServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class GdbServer {
return timeline_ ? timeline_->current_session() :
*emergency_debug_session;
}
ReplayTask* require_timeline_current_task();

void dispatch_regs_request(const Registers& regs,
const ExtraRegisters& extra_regs);
Expand Down

0 comments on commit b7c3913

Please sign in to comment.