Function call backtracing with esp-idf

User avatar
MickPF
Posts: 45
Joined: Tue Apr 03, 2018 8:47 pm

Function call backtracing with esp-idf

Postby MickPF » Wed May 02, 2018 12:05 pm

Hello,

I have written a (correct/well formed) program that triggers error messages in the depths of esp-idf. These parts of esp-idf are located in "esp-idf/components" and can therefore be changed in the source code before compiling. Since the called functions are called via callbacks, debugging is not possible or very difficult. A pure examination of the source code is too tedious.
Is there a call in esp-idf that works like the calls "backtrace_symbols" and/or "backtrace_symbols_fd" under linux?

Thanks in advance,
Michael
Nobody is perfect!
My name is NOT Nobody...


Nobody lives forever to correct his mistakes someday in the future, if not right now!
Covid-19 is not responsible for any human failures!

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Function call backtracing with esp-idf

Postby kolban » Wed May 02, 2018 1:59 pm

This may be an excellent opportunity to get to grips with JTAG debugging. If I had your puzzle, I'd engage JTAG and set a breakpoint where I wanted to gather information. When the breakpoint is reached deep in the bowels, the JTAG debugger can show my call path.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

markwj
Posts: 90
Joined: Tue Mar 08, 2016 5:03 am

Re: Function call backtracing with esp-idf

Postby markwj » Thu May 03, 2018 1:16 am

What you want is not trivial. But, here are some notes which may help:

1. There are no symbols in the .bin file in flash. But, if your running App outputs something that looks like an address, the 'make monitor' part of esp idf will convert it to a symbol and show it.

2. As an alternative to [1], the xtensa tools have a utility to convert an address to a symbol. It is not very accurate on the line number, but close enough:

Code: Select all

xtensa-esp32-elf-addr2line -pfiaC -e build/<MYAPP>.elf 0x<ADDRESS>
3. See panic.c doBacktrace() for how to do a backtrace.

4. If you can trigger the issue yourself, then gdb is your friend. Make menuconfig and set the gdbstub option. Use abort() in your code, and you'll be in gdb with a full backtrace and examination capability.

There is also jtag...

User avatar
MickPF
Posts: 45
Joined: Tue Apr 03, 2018 8:47 pm

Re: Function call backtracing with esp-idf

Postby MickPF » Thu May 03, 2018 9:54 am

As I see, using an JTAG would be the best way. According to the esp-idf docs it's possible to connect an JTAG adapter to the Feather.
My handycap is, I don't have anyone and I don't know which one and where to buy it!

Can you give me some advices?
Nobody is perfect!
My name is NOT Nobody...


Nobody lives forever to correct his mistakes someday in the future, if not right now!
Covid-19 is not responsible for any human failures!

Who is online

Users browsing this forum: ESP_Roland, Google [Bot] and 245 guests