lua-debug icon indicating copy to clipboard operation
lua-debug copied to clipboard

如何编译一个debug版本的remotedebug.so

Open waterslang opened this issue 2 years ago • 7 comments

我在使用自己定制的一个lua, 配合使用tcp监听的方式,用remotedebug模式调试。发现进行某些操作之后,使用debugger,会报一个segmentdefault。 目前根据堆栈是由luaD_callhook之后,回调到remotedebug.so 抛出的。 因此我想自己编译一个debug版本调试。 目前我已经编译出luamake,并且可以使用luamake编译lua-debug项目,但是对luamake的配置方式不清楚。 我主要修改了 scripts/gcc.lua的配置。我看里面的规则里面已经有了 -g, 并且,我把 optimize都修改为 '', 但是编译出来的 remotedebug.so 还是没有带调试信息。 请问要如何修改配置? 或者我使用的编译方式哪个步骤不对吗?

waterslang avatar Sep 22 '21 03:09 waterslang

luamake -mode debug

actboy168 avatar Sep 22 '21 03:09 actboy168

非常感谢,这样就编译出来的。 找到dump点了。只是还没有头绪。 我使用的是 lua5.1的版本,脚本那边是一个return语句后出错的。具体原因分析,我还在熟悉lua源码,你也可以参照一下。 这里的出错时的栈。 #0 ci2proto (ci=0x5555563d7700) at src/remotedebug/rdebug_hookmgr.cpp:51 #1 0x00007ffff6f32cd1 in hookmgr::break_update (this=0x55555628e038, hL=0x5555561d0008, ci=0x5555563d7700, event=1) at src/remotedebug/rdebug_hookmgr.cpp:165 #2 0x00007ffff6f32dd4 in hookmgr::break_hook_return (this=0x55555628e038, hL=0x5555561d0008, ar=0x7fffffffe5d0) at src/remotedebug/rdebug_hookmgr.cpp:182 #3 0x00007ffff6f33d1b in hookmgr::full_hook (this=0x55555628e038, hL=0x5555561d0008, ar=0x7fffffffe5d0) at src/remotedebug/rdebug_hookmgr.cpp:453 #4 0x00007ffff6f345dd in hookmgr::full_hook_callback (hL=0x5555561d0008, ar=0x7fffffffe5d0) at src/remotedebug/rdebug_hookmgr.cpp:635

waterslang avatar Sep 22 '21 09:09 waterslang

可能是你的lua和官方版本比有修改,用你改过的lua和remotedebug一起重新编一个。

actboy168 avatar Sep 22 '21 09:09 actboy168

break_update(hL, hL->base_ci + ar->i_ci, ar->event); 这句里面 ar->i_ci 的偏移值是0. 嗯,我用的lua是 lua-coco的版本。 使用我的lua是用我的lua文件替换项目的lua51目录么? 我先试一试。 比较奇怪的是,有些情况是可以正常运行的,做了一些修改后,就会dump。 image dump原因是这一句里的 func,是个未初始化的空值。

waterslang avatar Sep 22 '21 09:09 waterslang

重新编译只能解决你修改了某些struct定义的问题,如果你改得更多,可能某些remotedebug里的代码也得跟着改。当然也可能是remotedebug有bug,毕竟我不用lua51,而lua51和lua54的差别还是很大的。

actboy168 avatar Sep 22 '21 09:09 actboy168

我排查一下,如果有结论,在回来知会。非常感谢你的帮助。

waterslang avatar Sep 22 '21 09:09 waterslang

我也是崩在这里,一模一样的原因。 除非我们刚好用的同一个魔改lua,否则就是前面ci算错了。 我先说个暗号,lua_StdCallCFunction

sumneko avatar Dec 22 '21 19:12 sumneko