libdebugger/target: Move global stepping variables in to the target data

Updates #5098
This commit is contained in:
Chris Johns
2024-08-05 11:34:29 +10:00
parent f29986391d
commit 6a367f4689
3 changed files with 40 additions and 23 deletions

View File

@@ -1538,11 +1538,11 @@ remote_breakpoints(bool insert, uint8_t* buffer, int size)
const char* comma2; const char* comma2;
comma2 = strchr(comma1 + 1, ','); comma2 = strchr(comma1 + 1, ',');
if (comma2 != NULL) { if (comma2 != NULL) {
uint32_t capabilities; uint32_t capabilities;
uintptr_t addr; uintptr_t addr;
DB_UINT kind; DB_UINT kind;
addr = hex_decode_addr((const uint8_t*) comma1 + 1); addr = hex_decode_addr((const uint8_t*) comma1 + 1);
kind = hex_decode_uint((const uint8_t*)comma2 + 1); kind = hex_decode_uint((const uint8_t*) comma2 + 1);
capabilities = rtems_debugger_target_capabilities(); capabilities = rtems_debugger_target_capabilities();
switch (buffer[1]) { switch (buffer[1]) {
case '0': case '0':
@@ -1797,6 +1797,7 @@ rtems_debugger_session(void)
if (rtems_debugger_server_flag(RTEMS_DEBUGGER_FLAG_RESET)) { if (rtems_debugger_server_flag(RTEMS_DEBUGGER_FLAG_RESET)) {
rtems_debugger_printf("rtems-db: shutdown\n"); rtems_debugger_printf("rtems-db: shutdown\n");
sleep(2);
rtems_fatal_error_occurred(1122); rtems_fatal_error_occurred(1122);
} }

View File

@@ -349,11 +349,8 @@ rtems_debugger_target_swbreak_remove(void)
return r; return r;
} }
uintptr_t saved_break_address = 0;
rtems_id saved_tid = 0;
static rtems_debugger_target_exc_action static rtems_debugger_target_exc_action
soft_step_and_continue(CPU_Exception_frame* frame) rtems_debugger_soft_step_and_continue(CPU_Exception_frame* frame)
{ {
uintptr_t break_address; uintptr_t break_address;
rtems_debugger_target *target = rtems_debugger->target; rtems_debugger_target *target = rtems_debugger->target;
@@ -378,43 +375,57 @@ soft_step_and_continue(CPU_Exception_frame* frame)
return rtems_debugger_target_exc_cascade; return rtems_debugger_target_exc_cascade;
} }
/* Remove the current breakpoint */ /*
* Remove the current breakpoint
*/
rtems_debugger_target_swbreak_control( rtems_debugger_target_swbreak_control(
false, false,
break_address, break_address,
target->breakpoint_size target->breakpoint_size
); );
/* Save off thread ID and break address for later usage */ /*
saved_tid = tid; * Save the thread ID and break address to recover after stepping
saved_break_address = break_address; */
target->step_tid = tid;
target->step_bp_address = break_address;
/* Populate the fake rtems_debugger_thread */ /*
* Populate the fake rtems_debugger_thread
*/
fake_debugger_thread.flags |= RTEMS_DEBUGGER_THREAD_FLAG_STEP; fake_debugger_thread.flags |= RTEMS_DEBUGGER_THREAD_FLAG_STEP;
fake_debugger_thread.frame = frame; fake_debugger_thread.frame = frame;
target_printk("rtems-db: stepping to the next instruction\n"); target_printk("rtems-db: stepping to the next instruction\n");
rtems_debugger_target_thread_stepping(&fake_debugger_thread); rtems_debugger_target_thread_stepping(&fake_debugger_thread);
/* rtems_debugger_unlock() not called until the step is resolved */ /*
* rtems_debugger_unlock() not called until the step is resolved
*/
return rtems_debugger_target_exc_step; return rtems_debugger_target_exc_step;
} }
rtems_debugger_target_exc_action rtems_debugger_target_exc_action
rtems_debugger_target_exception(CPU_Exception_frame* frame) rtems_debugger_target_exception(CPU_Exception_frame* frame)
{ {
Thread_Control* thread = _Thread_Get_executing(); rtems_debugger_target *target = rtems_debugger->target;
const rtems_id tid = thread->Object.id; Thread_Control* thread = _Thread_Get_executing();
const rtems_id tid = thread->Object.id;
/* Resolve outstanding step+continue */ /*
if ( saved_break_address != 0 && tid == saved_tid ) { * Resolve outstanding step+continue
*/
if (target->step_bp_address != 0 && target->step_tid == tid) {
rtems_debugger_target_swbreak_control( rtems_debugger_target_swbreak_control(
true, true,
saved_break_address, target->step_bp_address,
rtems_debugger->target->breakpoint_size rtems_debugger->target->breakpoint_size
); );
saved_break_address = saved_tid = 0; target->step_bp_address = 0;
target->step_tid = 0;
/* Release the debugger lock now that the step+continue is complete */ /*
* Release the debugger lock now that the step+continue is complete
*/
target_printk("rtems-db: resuming after step\n"); target_printk("rtems-db: resuming after step\n");
rtems_debugger_unlock(); rtems_debugger_unlock();
return rtems_debugger_target_exc_consumed; return rtems_debugger_target_exc_consumed;
@@ -524,8 +535,10 @@ rtems_debugger_target_exception(CPU_Exception_frame* frame)
target_printk("[} tid:%08" PRIx32 ": exception in interrupt context\n", tid); target_printk("[} tid:%08" PRIx32 ": exception in interrupt context\n", tid);
/* soft_step_and_continue releases the debugger lock */ /*
return soft_step_and_continue( frame ); * Soft_step_and_continue releases the debugger lock
*/
return rtems_debugger_soft_step_and_continue(frame);
} }
void void

View File

@@ -107,6 +107,9 @@ typedef struct rtems_debugger_target {
rtems_debugger_block swbreaks; /*<< The software breakpoint block. */ rtems_debugger_block swbreaks; /*<< The software breakpoint block. */
bool memory_access; /*<< Accessing target memory. */ bool memory_access; /*<< Accessing target memory. */
jmp_buf access_return; /*<< Return from an access fault. */ jmp_buf access_return; /*<< Return from an access fault. */
uintptr_t step_bp_address; /*<< Stepping break point address */
rtems_id step_tid; /*<< Stepping task id */
} rtems_debugger_target; } rtems_debugger_target;
/** /**