some progress:
A session using gdb from repo of @jcmvbkbc plus prologue hack on some instrumented nodemcu:
Booting the firmware:
user_init done
nodemcu_init
NodeMCU 0.9.5 build 20150606 (dev branch 20150604, pcall protect, ex catch, cal_gdbstub) powered by Lua 5.1.4
lua: cannot open init.lua
>
Doing some lua and setup a timer that gets shot after some time and calls a BREAK.
> =2+3*4
14
> tmr.alarm(1,10000,0, function() node.breakpoint() end)
> =1+2+3+4+5
15
>
$T05#b9
OK, leaving terminal.
.gdbinit:
file app/.output/eagle/debug/image/eagle.app.v6.out
#set debug remote 1
# set a serial line BREAK to remote when typing CTRL-c on gdb prompt.
set remote interrupt-sequence BREAK
#set remote interrupt-on-connect 1
target remote /dev/ttyUSB0
#set remotebaud 115200
set serial baud 115200
add-symbol-file ../esp-elf-rom/esp-elf-rom/bootrom.elf 0x40000000
../../jcmvbkbc/binutils-gdb-xtensa/gdb/gdb
gives
GNU gdb (binutils-gdb-xtensa) 7.9.50.20150529-cvs
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_unknown-linux-gnu --target=xtensa-lx106-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".
gdb_breakpoint () at arch_esp8266.c:35
35 asm("break 0,0");
add symbol table from file "../esp-elf-rom/esp-elf-rom/bootrom.elf" at
.text_addr = 0x40000000
warning: section .text not found in .../esp-elf-rom/esp-elf-rom/bootrom.elf
(gdb)
backtrace:
(gdb) bt
#0 gdb_breakpoint () at arch_esp8266.c:35
#1 0x40254b28 in node_breakpoint (L=<optimized out>) at node.c:33
#2 0x40244583 in luaD_precall (L=L@entry=0x3fff7920, func=<optimized out>, func@entry=0x3fff7b78, nresults=nresults@entry=0) at ldo.c:340
#3 0x4024ae86 in luaV_execute (L=L@entry=0x3fff7920, nexeccalls=nexeccalls@entry=1) at lvm.c:646
#4 0x402446c9 in luaD_call (L=L@entry=0x3fff7920, func=0x3fff7b70, nResults=-1) at ldo.c:430
#5 0x40241245 in f_call (L=L@entry=0x3fff7920, ud=ud@entry=0x3fffff00) at lapi.c:855
#6 0x40243db8 in luaD_rawrunprotected (L=L@entry=0x3fff7920, f=f@entry=0x40241234 <f_call>, ud=ud@entry=0x3fffff00) at ldo.c:123
#7 0x402447f8 in luaD_pcall (L=L@entry=0x3fff7920, func=func@entry=0x40241234 <f_call>, u=u@entry=0x3fffff00, old_top=<optimized out>, ef=<optimized out>) at ldo.c:519
#8 0x40241ee1 in lua_pcall (L=L@entry=0x3fff7920, nargs=nargs@entry=0, nresults=-1, errfunc=errfunc@entry=1) at lapi.c:877
#9 0x40240bfe in cal_ido_lua_call (L=L@entry=0x3fff7920, narg=narg@entry=0, clear=clear@entry=0, line=line@entry=0x3ffeb364 "24") at lua.c:160
#10 0x40241028 in cal_do_lua_call (L=L@entry=0x3fff7920, narg=narg@entry=0, clear=clear@entry=0, line=line@entry=0x3ffeb364 "24") at cal_debug.c:58
#11 0x40255b84 in alarm_timer_common (L=0x3fff7920, id=id@entry=1) at tmr.c:24
#12 0x40255bb0 in alarm_timer_cb1 (arg=<optimized out>) at tmr.c:36
#13 0x40240d49 in func2 (data=<optimized out>) at cal_debug.c:74
#14 0x40002e09 in ets_timer_handler_isr ()
#15 0x40002e51 in ets_timer_handler_isr ()
#16 0x40000f49 in ets_post ()
Some navigation:
(gdb) up 2
#2 0x40244583 in luaD_precall (L=L@entry=0x3fff7920, func=<optimized out>, func@entry=0x3fff7b78, nresults=nresults@entry=0) at ldo.c:340
340 n = ((lua_CFunction)fvalue(ci->func))(L); /* do the actual call */
(gdb) list
335 luaD_callhook(L, LUA_HOOKCALL, -1);
336 lua_unlock(L);
337 if (ttisfunction(ci->func))
338 n = (*curr_func(L)->c.f)(L); /* do the actual call */
339 else
340 n = ((lua_CFunction)fvalue(ci->func))(L); /* do the actual call */
341 lua_lock(L);
342 if (n < 0) /* yielding? */
343 return PCRYIELD;
344 else {
(gdb) print ci
$1 = (CallInfo *) 0x3fff7ac0
(gdb) print *ci
$2 = {base = 0x3fff7b80, func = 0x3fff7b78, top = 0x3fff7c20, savedpc = 0x3fff8aac, nresults = 0, tailcalls = -625713182}
(gdb) print ci->func
$3 = (StkId) 0x3fff7b78
(gdb) print L
$4 = (lua_State *) 0x3fff7920
(gdb) print *L
$5 = {next = 0x0, tt = 10 '\n', marked = 97 'a', status = 0 '\000', top = 0x3fff7b80, base = 0x3fff7b80, l_G = 0x3fff7988, ci = 0x3fff7ac0, savedpc = 0x3fff8e0c, stack_last = 0x3fff7c98, stack = 0x3fff7b60,
end_ci = 0x3fff7b38, base_ci = 0x3fff7a90, stacksize = 45, size_ci = 8, nCcalls = 1, baseCcalls = 0, hookmask = 0 '\000', allowhook = 1 '\001', basehookcount = 0, hookcount = 0, hook = 0x0, l_gt = {value = {
gc = 0x3fff7cd8, p = 0x3fff7cd8, n = 1073708248, b = 1073708248}, tt = 7}, env = {value = {gc = 0x3fff7cd8, p = 0x3fff7cd8, n = 1073708248, b = 1073708248}, tt = 7}, openupval = 0x0, gclist = 0x0,
errorJmp = 0x3ffffe90, errfunc = 8}
Thanks for your help!
Any chance to get a more current gdb into esp8266 esp-open-sdk and/or crosstools ng?
Cal