Chapter 4. API Guides
(continued from previous page)
[Switching to thread 5 (Thread 1073410208)]
#0 0x4000bfea in ?? ()
(gdb)
Then check the backtrace:
(gdb) bt
#0 0x4000bfea in ?? ()
#1 0x40083a85 in vPortCPUReleaseMutex (mux=<optimized out>) at /home/user-name/
,→esp/esp-idf/components/freertos/./port.c:415
#2 0x40083fc8 in vTaskSwitchContext () at /home/user-name/esp/esp-idf/components/
,→freertos/./tasks.c:2846
#3 0x4008532b in _frxt_dispatch ()
#4 0x4008395c in xPortStartScheduler () at /home/user-name/esp/esp-idf/components/
,→freertos/./port.c:222
#5 0x4000000c in ?? ()
#6 0x4000000c in ?? ()
#7 0x4000000c in ?? ()
#8 0x4000000c in ?? ()
(gdb)
As you see, the backtrace may contain several entries. This will let you check what exact sequence of function calls
lead to the code where the target halted. Question marks ?? instead of a function name indicate that application is
available only in binary format, without any source file in C language. The value like 0x4000bfea is the memory
address of the function call.
Using bt, i threads, thread N and list commands we are now able to navigate through the code of entire
application. This comes handy when stepping through the code and working with breakpoints and will be discussed
below.
Setting and clearing breakpoints When debugging, we would like to be able to stop the application at critical
lines of code and then examine the state of specific variables, memory and registers / peripherals. To do so we are
using breakpoints. They provide a convenient way to quickly get to and halt the application at specific line.
Let’s establish two breakpoints when the state of LED changes. Basing on code listing above this happens at lines
33 and 36. Breakpoints may be established using command break M where M is the code line number:
(gdb) break 33
Breakpoint 2 at 0x400db6f6: file /home/user-name/esp/blink/main/./blink.c, line 33.
(gdb) break 36
Breakpoint 3 at 0x400db704: file /home/user-name/esp/blink/main/./blink.c, line 36.
If you new enter c, the processor will run and halt at a breakpoint. Entering c another time will make it run again,
halt on second breakpoint, and so on:
(gdb) c
Continuing.
Target halted. PRO_CPU: PC=0x400DB6F6 (active) APP_CPU: PC=0x400D10D8
Breakpoint 2, blink_task (pvParameter=0x0) at /home/user-name/esp/blink/main/./
,→blink.c:33
33 gpio_set_level(BLINK_GPIO, 0);
(gdb) c
Continuing.
Target halted. PRO_CPU: PC=0x400DB6F8 (active) APP_CPU: PC=0x400D10D8
Target halted. PRO_CPU: PC=0x400DB704 (active) APP_CPU: PC=0x400D10D8
Breakpoint 3, blink_task (pvParameter=0x0) at /home/user-name/esp/blink/main/./
,→blink.c:36
36 gpio_set_level(BLINK_GPIO, 1);
(continues on next page)
Espressif Systems 1406
Submit Document Feedback
Release v4.4