forked from auracaster/openocd
WIP on hardware breakpoints.
This is messy, but contains at least some bugfixes. 39/43 tests pass now. Change-Id: Ic9e8dad2a0ceb237e28c93906d1cd60876a5766d
This commit is contained in:
+17
-3
@@ -91,8 +91,11 @@ static int hwthread_update_threads(struct rtos *rtos)
|
||||
int64_t current_thread = 0;
|
||||
enum target_debug_reason current_reason = DBG_REASON_UNDEFINED;
|
||||
|
||||
LOG_DEBUG("current_thread=%i", (int)rtos->current_thread);
|
||||
LOG_DEBUG("current_threadid=%i", (int)rtos->current_threadid);
|
||||
|
||||
if (rtos == NULL)
|
||||
return -1;
|
||||
return ERROR_FAIL;
|
||||
|
||||
target = rtos->target;
|
||||
|
||||
@@ -109,6 +112,7 @@ static int hwthread_update_threads(struct rtos *rtos)
|
||||
} else
|
||||
thread_list_size = 1;
|
||||
|
||||
#if 0
|
||||
if (thread_list_size == rtos->thread_count) {
|
||||
/* Nothing changed. Exit early.
|
||||
* This is important because if we do recreate the data, we potentially
|
||||
@@ -122,9 +126,12 @@ static int hwthread_update_threads(struct rtos *rtos)
|
||||
*/
|
||||
return ERROR_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* wipe out previous thread details if any */
|
||||
/* Wipe out previous thread details if any, but preserve threadid. */
|
||||
int64_t current_threadid = rtos->current_threadid;
|
||||
rtos_free_threadlist(rtos);
|
||||
rtos->current_threadid = current_threadid;
|
||||
|
||||
/* create space for new thread details */
|
||||
rtos->thread_details = malloc(sizeof(struct thread_detail) * thread_list_size);
|
||||
@@ -194,6 +201,8 @@ static int hwthread_update_threads(struct rtos *rtos)
|
||||
}
|
||||
|
||||
threads_found++;
|
||||
LOG_DEBUG(">>> tid=%ld, debug_reason=%d, current_thread=%ld, current_reason=%d",
|
||||
tid, curr->debug_reason, current_thread, current_reason);
|
||||
}
|
||||
} else {
|
||||
hwthread_fill_thread(rtos, target, threads_found);
|
||||
@@ -211,7 +220,8 @@ static int hwthread_update_threads(struct rtos *rtos)
|
||||
else
|
||||
rtos->current_thread = threadid_from_target(target);
|
||||
|
||||
LOG_DEBUG("%s current_thread=%i", __func__, (int)rtos->current_thread);
|
||||
LOG_DEBUG("current_thread=%i", (int)rtos->current_thread);
|
||||
LOG_DEBUG("current_threadid=%i", (int)rtos->current_threadid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -358,7 +368,10 @@ static int hwthread_thread_packet(struct connection *connection, const char *pac
|
||||
struct target *curr = NULL;
|
||||
int64_t current_threadid;
|
||||
|
||||
LOG_DEBUG(">>> %s", packet);
|
||||
|
||||
if (packet[0] == 'H' && packet[1] == 'g') {
|
||||
/* Never reached, because this case is handled by rtos_thread_packet(). */
|
||||
sscanf(packet, "Hg%16" SCNx64, ¤t_threadid);
|
||||
|
||||
if (current_threadid > 0) {
|
||||
@@ -373,6 +386,7 @@ static int hwthread_thread_packet(struct connection *connection, const char *pac
|
||||
target->rtos->current_thread = threadid_from_target(target);
|
||||
|
||||
target->rtos->current_threadid = current_threadid;
|
||||
LOG_DEBUG("current_threadid=%ld", current_threadid);
|
||||
|
||||
gdb_put_packet(connection, "OK", 2);
|
||||
return ERROR_OK;
|
||||
|
||||
@@ -432,6 +432,7 @@ int rtos_thread_packet(struct connection *connection, char const *packet, int pa
|
||||
target->rtos->current_threadid = target->rtos->current_thread;
|
||||
else
|
||||
target->rtos->current_threadid = threadid;
|
||||
LOG_DEBUG("current_threadid=%ld", target->rtos->current_threadid);
|
||||
}
|
||||
gdb_put_packet(connection, "OK", 2);
|
||||
return ERROR_OK;
|
||||
@@ -516,6 +517,7 @@ int rtos_get_gdb_reg_list(struct connection *connection)
|
||||
{
|
||||
struct target *target = get_target_from_connection(connection);
|
||||
int64_t current_threadid = target->rtos->current_threadid;
|
||||
LOG_DEBUG("current_threadid=%ld", target->rtos->current_threadid);
|
||||
if ((target->rtos != NULL) && (current_threadid != -1) &&
|
||||
(current_threadid != 0) &&
|
||||
((current_threadid != target->rtos->current_thread) ||
|
||||
|
||||
@@ -50,7 +50,9 @@ struct rtos {
|
||||
symbol_table_elem_t *symbols;
|
||||
struct target *target;
|
||||
/* add a context variable instead of global variable */
|
||||
/* The thread currently selected by gdb. */
|
||||
int64_t current_threadid;
|
||||
/* The currently selected thread according to the target. */
|
||||
threadid_t current_thread;
|
||||
struct thread_detail *thread_details;
|
||||
int thread_count;
|
||||
|
||||
Reference in New Issue
Block a user