我正在x86上Ubuntu上的第三方C库上开发一个Erlang包装器,所以我正在创建一个NIF。有时,我的代码(我认为)崩溃,导致一个核心文件。不幸的是,堆栈跟踪并没有真正的帮助:
(gdb) bt
#0 0x00007fc22229968a in ?? ()
#1 0x0000000060e816d8 in ?? ()
#2 0x0000000007cd48b0 in ?? ()
#3 0x00007fc228031410 in ?? ()
#4 0x00007fc228040b80 in ?? ()
#5 0x00007fc228040c50 in ?? ()
#6 0x00007fc22223de0b in ?? ()
#7 0x0000000000000000 in ?? ()
即使我用调试信息构建了我的NIF .so
文件:
ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=b70dd1f2450f5c0e9980c8396aaad2e1cd29024c, with debug_info, not stripped
beam
还提供了调试信息:
ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=e0a5dba6507b8c2b333faebc89fbc6ea2f7263b9, for GNU/Linux 3.2.0, with debug_info, not stripped
但是,info sharedlibrary
既没有显示NIF,也没有显示第三方库:
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x00007fc28942ed50 0x00007fc289432004 Yes /lib/x86_64-linux-gnu/libgtk3-nocsd.so.0
0x00007fc289429220 0x00007fc28942a179 Yes /lib/x86_64-linux-gnu/libdl.so.2
0x00007fc2892e83c0 0x00007fc28938ef18 Yes /lib/x86_64-linux-gnu/libm.so.6
0x00007fc2892b76a0 0x00007fc2892c517c Yes /lib/x86_64-linux-gnu/libtinfo.so.6
0x00007fc28928dae0 0x00007fc28929d4d5 Yes /lib/x86_64-linux-gnu/libpthread.so.0
0x00007fc2890b9630 0x00007fc28922e20d Yes /lib/x86_64-linux-gnu/libc.so.6
0x00007fc289657100 0x00007fc289679674 Yes (*) /lib64/ld-linux-x86-64.so.2
0x00007fc24459c040 0x00007fc2445ab8ad Yes /home/nar/otp/23.3.4.2/lib/crypto-4.9.0.2/priv/lib/crypto.so
0x00007fc2239e3000 0x00007fc223b7c800 Yes (*) /lib/x86_64-linux-gnu/libcrypto.so.1.1
0x00007fc2896500e0 0x00007fc28965028c Yes /home/nar/otp/23.3.4.2/lib/crypto-4.9.0.2/priv/lib/crypto_callback.so
0x00007fc289649380 0x00007fc28964bc1c Yes /home/nar/otp/23.3.4.2/lib/asn1-5.0.15/priv/lib/asn1rt_nif.so
0x00007fc289638720 0x00007fc28963bd70 Yes /lib/x86_64-linux-gnu/librt.so.1
我找到了这的答案,提到“Erlang不加载带有公开了全局符号的NIF库”。难道这就是我看不到符号的原因吗?有没有办法让gdb
从我的.so
文件中查找符号?
发布于 2021-07-22 04:12:23
我构建了启用调试的Erlang (我使用克尔构建并将KERL_BUILD_DEBUG_VM
设置为true),然后使用-debug
选项启动erlang。这样,一些断言似乎在代码中被启用了,它们崩溃了,这导致了我代码中的错误。从那以后我就没撞车了。
https://stackoverflow.com/questions/68459158
复制相似问题