Wait for debugger

ojoj42
Posts: 4
Joined: Tue Jun 02, 2020 8:19 am

Wait for debugger

Postby ojoj42 » Wed Aug 19, 2020 8:16 am

Hi,

Is it somehow possible to generate a break point in code and than wait for the debugger (jtag) to connect to target and start debugging at that point?

Kind Regards
Daniel Moberg

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Wait for debugger

Postby ESP_igrr » Wed Aug 19, 2020 8:21 pm

Hi Daniel, first you can use cpu_hal_is_debugger_attached function to check whether OpenOCD has connected to the chip. If not connected, print some message, delay, repeat the check.
Once OpenOCD is connected, cpu_hal_is_debugger_attached returns 'true'.
Then call cpu_hal_set_breakpoint function to set a breakpoint at the point where you would like the program to stop.

Something along these lines:

Code: Select all

while(!cpu_hal_is_debugger_attached()) {
  printf("waiting for debugger\n");
  usleep(1000000);
}
cpu_hal_set_breakpoint(0, &next);

next: // label used to get the address of the next line of code

some_other_func();

Who is online

Users browsing this forum: No registered users and 165 guests