<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Thanks a lot, Steve! Great explanation :-) <div class=""><br class=""></div><div class="">I’m using Mac, so please send the binary and library. </div><div class=""><br class=""></div><div class="">Best regards,</div><div class="">Geir</div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">22. nov. 2017 kl. 23:03 skrev Stephen Casner <<a href="mailto:casner@acm.org" class="">casner@acm.org</a>>:</div><br class="Apple-interchange-newline"><div class=""><div class="">On Wed, 22 Nov 2017, Geir ?yvind V?lidalo wrote:<br class=""><br class=""><blockquote type="cite" class="">I see some of your are talking about gdb-stub, but I have never used<br class="">gbd and need some help.<br class="">How do I debug? What options do I have?<br class=""></blockquote><br class="">Happy to help with that. To use the gdb-stub you change the parameter<br class="">in menuconfig / Component Config / ESP32-specific / Panic handler<br class="">behavior / Invoke GDBStub.<br class=""><br class="">When the crash occurs, you'll be presented with a "gdb>" command<br class="">prompt. You can find references for "gdb commands" online. Here is<br class="">one: <a href="http://www.yolinux.com/TUTORIALS/GDB-Commands.html" class="">http://www.yolinux.com/TUTORIALS/GDB-Commands.html</a><br class=""><br class="">The first command I would expect you will want is "bt" which displays<br class="">a stack backtrace telling in which function each call is made,<br class="">including the source line number. The frames on the stack are<br class="">numbered; you can give the command "frame N" where N is a frame number<br class="">to change to the context of that frame, since the lowest one might not<br class="">be the place where things started to go wrong.<br class=""><br class="">When you're at the right frame, you can use the "print" command to<br class="">look at the value of variables. If variable foo is a pointer, you can<br class="">say "print *foo" to display the contents of the object foo points to.<br class="">In many cases this will be enough to figure out the problem. I also<br class="">use the "x" command to examine memory by address in various ways.<br class=""><br class="">You can also use the "list" command to see a few lines of source code<br class="">around the point in the code referenced by that stack frame. Usually<br class="">I just look at my source in a separate window.<br class=""><br class="">When using gdb on a real computer you can set breakpoints before<br class="">starting the program, but I have not learned whether that is possible<br class="">to do with the ESP32.<br class=""><br class="">As I mentioned in one of the emails, if you are running on a Mac you<br class="">should use the gdb binary that I made which references the newer<br class="">libiconv library in order to avoid gdb getting stuck in an infinite<br class="">loop. If so, let me know and I'll send the binary and library to you.<br class="">If you are running on a different platform, you should check to see<br class="">what version of libiconv DLL (Windows) or shared library (Linux) is<br class="">referenced. On my Mac the new one is 9.0.0 vs. 7.0.0. The old one is<br class="">usable, but you have to be careful not to give any command that might<br class="">result in gdb tryinging to display a variable value that has non-ASCII<br class="">chars.<br class=""><br class=""> -- Steve<br class="">_______________________________________________<br class="">OvmsDev mailing list<br class=""><a href="mailto:OvmsDev@lists.teslaclub.hk" class="">OvmsDev@lists.teslaclub.hk</a><br class="">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev<br class=""></div></div></blockquote></div><br class=""></div></body></html>