6

我在以下 linux 嵌入式系统上运行 dotnet core 2.1 应用程序:

Linux arm 4.14.67-1.0.7+ #52 SMP PREEMPT armv7l GNU/Linux

该应用程序在 futex 上挂了几天:

root@arm:/# strace -p 525
strace: Process 525 attached
futex(0x4a6f4, FUTEX_WAIT_PRIVATE, 29517, NULL
 <detached ...>

我必须在不停止进程的情况下找出哪一行 c# 代码产生了相应的 futex 调用。如何找到返回产生相应 futex 系统调用的 c# 代码行的方法?

/proc/525/maps我发现地址 0x4a6f4 是堆内存的一部分:

00008000-00019000 r-xp 00000000 00:10 6906       /root/dotnet/dotnet
00021000-00022000 r--p 00011000 00:10 6906       /root/dotnet/dotnet
00022000-00023000 rw-p 00012000 00:10 6906       /root/dotnet/dotnet
00023000-001c6000 rw-p 00000000 00:00 0          [heap]
a545c000-a545d000 ---p 00000000 00:00 0
...

但是我怎样才能将这个地址与一行代码联系起来呢?我试图运行gdb -p 525,但我得到了错误

warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.

检查 libpthread 库:

root@arm:~/dotnet# ldd /root/dotnet/dotnet
        libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0xb6f16000)
        libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6ef2000)
        libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6de6000)
        libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6d6e000)
        libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6d45000)
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6c57000)
        /lib/ld-linux-armhf.so.3 (0xb6f29000)

我的 .gdbinit 文件:

root@arm:~/dotnet# cat /root/.gdbinit
set auto-load safe-path /
set libthread-db-search-path /lib/arm-linux-gnueabihf
set env LD_PRELOAD /lib/arm-linux-gnueabihf/libpthread.so.0

因此whereorbt在 gdb 中不起作用:

(gdb) where
#0  0xb6f56344 in pthread_getattr_default_np (out=0xfffffff0) at pthread_getattr_default_np.c:34
#1  0xb2bdf998 in ?? ()

任何想法如何解决这个问题?提前致谢!

4

0 回答 0