Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix confusing status messages during resume #1031

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions src/target/riscv/riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1709,15 +1709,26 @@ static int oldriscv_step(struct target *target, int current, uint32_t address,
return tt->step(target, current, address, handle_breakpoints);
}

static int old_or_new_riscv_step(struct target *target, int current,
target_addr_t address, int handle_breakpoints)
static int riscv_openocd_step_impl(struct target *target, int current,
target_addr_t address, int handle_breakpoints, int handle_callbacks);

static int old_or_new_riscv_step_impl(struct target *target, int current,
target_addr_t address, int handle_breakpoints, int handle_callbacks)
{
RISCV_INFO(r);
LOG_TARGET_DEBUG(target, "handle_breakpoints=%d", handle_breakpoints);
if (!r->get_hart_state)
return oldriscv_step(target, current, address, handle_breakpoints);
else
return riscv_openocd_step(target, current, address, handle_breakpoints);
return riscv_openocd_step_impl(target, current, address, handle_breakpoints,
handle_callbacks);
}

static int old_or_new_riscv_step(struct target *target, int current,
target_addr_t address, int handle_breakpoints)
{
return old_or_new_riscv_step_impl(target, current, address,
handle_breakpoints, true /* handle callbacks*/);
}

static int riscv_examine(struct target *target)
Expand Down Expand Up @@ -2091,7 +2102,8 @@ static int resume_prep(struct target *target, int current,
/* To be able to run off a trigger, we perform a step operation and then
* resume. If handle_breakpoints is true then step temporarily disables
* pending breakpoints so we can safely perform the step. */
if (old_or_new_riscv_step(target, current, address, handle_breakpoints) != ERROR_OK)
if (old_or_new_riscv_step_impl(target, current, address, handle_breakpoints,
false /* callbacks are not called */) != ERROR_OK)
return ERROR_FAIL;
}

Expand Down Expand Up @@ -3294,8 +3306,8 @@ int riscv_openocd_poll(struct target *target)
return ERROR_OK;
}

int riscv_openocd_step(struct target *target, int current,
target_addr_t address, int handle_breakpoints)
static int riscv_openocd_step_impl(struct target *target, int current,
target_addr_t address, int handle_breakpoints, int handle_callbacks)
{
LOG_TARGET_DEBUG(target, "stepping hart");

Expand Down Expand Up @@ -3361,14 +3373,25 @@ int riscv_openocd_step(struct target *target, int current,

if (success) {
target->state = TARGET_RUNNING;
target_call_event_callbacks(target, TARGET_EVENT_RESUMED);
if (handle_callbacks)
target_call_event_callbacks(target, TARGET_EVENT_RESUMED);

target->state = TARGET_HALTED;
target->debug_reason = DBG_REASON_SINGLESTEP;
target_call_event_callbacks(target, TARGET_EVENT_HALTED);
if (handle_callbacks)
target_call_event_callbacks(target, TARGET_EVENT_HALTED);
}

return success ? ERROR_OK : ERROR_FAIL;
}

int riscv_openocd_step(struct target *target, int current,
target_addr_t address, int handle_breakpoints)
{
return riscv_openocd_step_impl(target, current, address, handle_breakpoints,
true /* handle_callbacks */);
}

/* Command Handlers */
COMMAND_HANDLER(riscv_set_command_timeout_sec)
{
Expand Down
Loading