Debugging on Mac with GDB w/o JTAG

Paladin
Posts: 16
Joined: Fri Jan 13, 2017 8:45 pm

Debugging on Mac with GDB w/o JTAG

Postby Paladin » Tue Mar 28, 2017 10:38 pm

Between Kolban's "Attaching GDB for debugging" and this forum post on GDB debugging issues on Mac,
I thought I'd be able to use gdb to debug an issue I'm having with a simple wifi program adapted from
Luca Dentella's WiFi example code...

However, when I try to follow the example, which I've followed stepwise, (alter configuration options for esp32 menuconfig, run the program, disconnect the serial connection...)

Code: Select all

xtensa-esp32-elf-gdb ./build/app-template.elf -b 115200 -ex '/dev/cu.usbserial-DN01J4DD'
I get this output:

Code: Select all

GNU gdb (crosstool-NG crosstool-ng-1.22.0-61-gab8375a) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_apple-darwin16.0.0 --target=xtensa-esp32-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./build/app-template.elf...done.
Undefined command: "".  Try "help".
Which is supremely unhelpful.
I need some help getting gdb to work correctly with the ESP32 (using the SparkFun dev board right now) so that I can move forward on debugging effectively, and I don't know how to troubleshoot this on my own.

ESP_Angus
Posts: 1860
Joined: Sun May 08, 2016 4:11 am

Re: Debugging on Mac with GDB w/o JTAG

Postby ESP_Angus » Tue Mar 28, 2017 10:58 pm

Hi Paladin,

To use the serial gdbstub, the ESP32 has to have crashed (with the gdbstub panic handler set in the menuconfig), or manually triggered (which also halts execution). Is this the case when you are running gdb?

In recent esp-idf (master branch) the "make monitor" target contains functionality to automatically detect when the gdbstub starts running, and will launch gdb automatically. This is much more convenient than the old way of juggling between the serial program and gdb. Details: http://esp-idf.readthedocs.io/en/latest ... nitor.html

Angus

ESP_Sprite
Posts: 2843
Joined: Thu Nov 26, 2015 4:08 am

Re: Debugging on Mac with GDB w/o JTAG

Postby ESP_Sprite » Wed Mar 29, 2017 3:40 am

You've accidentally a word:
xtensa-esp32-elf-gdb ./build/app-template.elf -b 115200 -ex 'target /dev/cu.usbserial-DN01J4DD'

Paladin
Posts: 16
Joined: Fri Jan 13, 2017 8:45 pm

Re: Debugging on Mac with GDB w/o JTAG

Postby Paladin » Wed Mar 29, 2017 7:56 pm

ESP_Angus,
I get a Guru Meditation Error of type LoadProhibited occurred on core 0 ...followed by the register dump and the back trace...then the chip resets.

Thanks for pointing me to the make monitor tool. when I run make monitor, I get the following:

Code: Select all

my bash prompt$ make monitor

MONITOR
--- idf_monitor on /dev/cu.usbserial-DN01J4DD 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/alwynsmith/esp/esp-idf/tools/idf_monitor.py", line 116, in _run_outer
    self.run()
  File "/Users/username/esp/esp-idf/tools/idf_monitor.py", line 185, in run
    if not self.serial.is_open:
AttributeError: 'Serial' object has no attribute 'is_open' 
ESP_Sprite,
Thanks for the catch...that's a little embarassing :oops:
Here's what I'm getting now:

Code: Select all

my bash prompt$ xtensa-esp32-elf-gdb ./build/app-template.elf -b 115200 -ex 'target /dev/cu.usbserial-DN01J4DD'
/* Some deleted lines for brevity */
Reading symbols from ./build/app-template.elf...done.
Undefined target command: "/dev/cu.usbserial-DN01J4DD".  Try "help target".
(gdb) 
I don't know what to do next

ESP_Angus
Posts: 1860
Joined: Sun May 08, 2016 4:11 am

Re: Debugging on Mac with GDB w/o JTAG

Postby ESP_Angus » Wed Mar 29, 2017 10:20 pm

Paladin wrote: AttributeError: 'Serial' object has no attribute 'is_open'
Looks like you have an older version of pyserial. To upgrade will depend on how Python is installed, but something like "sudo python -m pip install -U pyserial" should do the trick.

I'll look at modifying idf_monitor so it provides a more helpful error message in this case.

Angus

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

Re: Debugging on Mac with GDB w/o JTAG

Postby ESP_igrr » Thu Mar 30, 2017 1:17 am

Regarding invalid command: it should be target remote <port_name>, now you're missing 'remote' I think.

ESP_Sprite
Posts: 2843
Joined: Thu Nov 26, 2015 4:08 am

Re: Debugging on Mac with GDB w/o JTAG

Postby ESP_Sprite » Thu Mar 30, 2017 5:40 am

Aye, seems my brain glitched while correcting you, it should be 'target remote'. Sorry for only correcting you halfway. First time I've run into Muphrys law while doing something programming-related :)

Paladin
Posts: 16
Joined: Fri Jan 13, 2017 8:45 pm

Re: Debugging on Mac with GDB w/o JTAG

Postby Paladin » Thu Mar 30, 2017 3:46 pm

Alright! I updated pyserial and now idf_monitor works like a dream. Thank you! On to debugging...

Who is online

Users browsing this forum: Bing [Bot] and 13 guests