6 ms·
Stack traces on ESP8266: a GDB server stub
- AstroJetson 11y agoI do most of my work in Lua. So the GDB traces will be to the major Lua routines. I'm going to assume the ports of microPython will have the same problem. Any suggestions for those implementations?
- devbug 11y agoImmediate thoughts go to `debug.traceback` (via xpcall). You're on your own when it comes to Lua<=>C boundaries, however. Now, if you're talking about _manually_ walking the stack... this will point you in the right direction: http://zeuxcg.org/2010/11/07/lua-callstack-with-c-debugger/ http://zeuxcg.org/2010/11/07/lua-callstack-with-c-debugger/
- AstroJetson 11y agoThanks for the hints. I'll need to get to the lab to see how well they work in the ESP8266 environment, that would be a huge bonus win.
- devbug 11y agoHappy to help. To expand upon my 4am ramblings: There's two ways your code is going to fail, (a) Your Lua is going to die in a pcall (or friends); or (b) Your C/C++ (or similar) code has its front fall off. In the former case, you just wrap with an xpcall and append your Lua callstack to your C++ callstack. Nothing fancy. You can of course go further, using lua_Debug to get the value of upvals and all that jazz. However, in the latter case you have no guarantee that your application is in a sane state; you have no (solid) assumption that you can go the lua_Debug route, say from a segfault handler. You'll have to walk the callstack, and when you hit lua_whatever, prod internal state. Both methods are really helpful. Say you're writing a game engine, knowing how to reproduce a catastrophic failure with a small Lua snippet, closes the feedback loop and make debugging a hell of a lot easier. There's definitely a product and SaaS around this (much more expanded), with a Gitlab or Sentry business model.
- StavrosK 11y agoSlightly offtopic, but I wanted a nice breakout board for the ESP8266 and couldn't find one, so I made one: https://github.com/skorokithakis/tiny-ESP8266-breakout https://github.com/skorokithakis/tiny-ESP8266-breakout If you want to just order one, here's a paneled PCB of the earlier versions (the only difference is pretty much the lack of a 3v3 out, plus the traces aren't as pretty): http://dirtypcbs.com/view.php?share=15302&accesskey= http://dirtypcbs.com/view.php?share=15302&accesskey= Technical details: There exist some breakouts like this one[1], but they're crap, stay away from them. They don't include all the necessary pullups/pulldowns for the ESP to start running code, they don't include a capacitor and they don't leave room on the breadboard for connectors, so they're useless. My PCB fixes all these problems by adding 0805 10k Ω resistors, a capacitor and by being less than 2.5cm in each dimension. [1]: http://www.ebay.com/itm/ESP8266-ESP-12-WIFI-UART-Serial-Module-and-Breakout-Board-for-Arduino-TW-/151696756353?hash=item2351d4ce81:g:-dAAAOSwl8NVZ9nQ http://www.ebay.com/itm/ESP8266-ESP-12-WIFI-UART-Serial-Modu...
- paddi91 11y agoJust in case your're lookin' for some other stuff to do with the ESP8266 https://aisler.net/search?query=ESP8266 https://aisler.net/search?query=ESP8266
- StavrosK 11y agoHah, it's odd to see everyone making pretty much the same things. I sent a WiFi-enabled LED strip controller based on the ESP off just yesterday: http://dirtypcbs.com/view.php?share=16892&accesskey=996a11f93e9b6f833112ceedd77168f7 http://dirtypcbs.com/view.php?share=16892&accesskey=996a11f9... You can use it to program your RGB LED strips from your computer! Now you can finally have the entire apartment slowly change color to red in the hours before bed!
- AstroJetson 11y agoVery nice, thanks for posting everything for it.
- 11y ago
- moyix 11y agoIf you can get a gdb stub onto an embedded system, you can do a lot of cool stuff, up to and including running its firmware in an emulator and forwarding I/O accesses to the real hardware (!), which gives you basically unlimited visibility into the code. You can see Jonas Zaddach et al.'s Avatar paper (PDF: http://www.s3.eurecom.fr/docs/ndss14_zaddach.pdf http://www.s3.eurecom.fr/docs/ndss14_zaddach.pdf , code: http://www.s3.eurecom.fr/tools/avatar/ http://www.s3.eurecom.fr/tools/avatar/ ) for more details.