summaryrefslogtreecommitdiff
path: root/src/target/target.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/target/target.c')
-rw-r--r--src/target/target.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/target/target.c b/src/target/target.c
index ced09e90..8bb9371f 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -378,24 +378,57 @@ target_t* get_current_target(command_context_t *cmd_ctx)
int target_poll(struct target_s *target)
{
+ int retval;
+
/* We can't poll until after examine */
if (!target_was_examined(target))
{
/* Fail silently lest we pollute the log */
return ERROR_FAIL;
}
- return target->type->poll(target);
+
+ retval = target->type->poll(target);
+ if (retval != ERROR_OK)
+ return retval;
+
+ if (target->halt_issued)
+ {
+ if (target->state == TARGET_HALTED)
+ {
+ target->halt_issued = false;
+ } else
+ {
+ long long t = timeval_ms() - target->halt_issued_time;
+ if (t>1000)
+ {
+ target->halt_issued = false;
+ LOG_INFO("Halt timed out, wake up GDB.");
+ target_call_event_callbacks(target, TARGET_EVENT_GDB_HALT);
+ }
+ }
+ }
+
+ return ERROR_OK;
}
int target_halt(struct target_s *target)
{
+ int retval;
/* We can't poll until after examine */
if (!target_was_examined(target))
{
LOG_ERROR("Target not examined yet");
return ERROR_FAIL;
}
- return target->type->halt(target);
+
+ retval = target->type->halt(target);
+ if (retval != ERROR_OK)
+ return retval;
+
+ target->halt_issued = true;
+ target->halt_issued_time = timeval_ms();
+
+ return ERROR_OK;
}
int target_resume(struct target_s *target, int current, uint32_t address, int handle_breakpoints, int debug_execution)
@@ -4236,6 +4269,8 @@ static int target_create(Jim_GetOptInfo *goi)
target->display = 1;
+ target->halt_issued = false;
+
/* initialize trace information */
target->trace_info = malloc(sizeof(trace_t));
target->trace_info->num_trace_points = 0;