如何使用gdb进行调试时获取所有缺少的信息

时间:2017-11-21 12:50:19

标签: c# debugging mono gdb

调试使用gdb:

在mono上运行的C#应用​​程序时,我有这个调用跟踪
User
  .joins(:memberships)
  .where.not(id: user.id)
  .where(
    memberships: {
      group_id: user.memberships.select(:group_id)})

我想消除所有未知数(这些部分user_groups_rel = user .memberships .select(:group_id) groups_users_rel = Membership .select(:user_id) .where(group_id: user_groups_rel) User .where.not(id: user.id) .where(id: groups_users_rel) ),主要是因为我在代码中看到了CPU挂钩问题,问题就是我所看到的,例如:

Thread 104 (Thread 0x7f37edec8700 (LWP 16281)):
#0  pthread_cond_timedwait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:239
#1  0x00000000006e3ba6 in mono_os_cond_timedwait (cond=0x184a1f8, mutex=0x184a1d0, timeout_ms=9435) at ../../mono/utils/mono-os-mutex.h:216
#2  0x00000000006e55d9 in mono_w32handle_timedwait_signal_naked (cond=0x184a1f8, mutex=0x184a1d0, timeout=9435, poll=0, alerted=0x7f37edec6ed0) at w32handle.c:956
#3  0x00000000006e58b1 in mono_w32handle_timedwait_signal_handle (handle=0x401, timeout=9435, poll=0, alerted=0x7f37edec6ed0) at w32handle.c:1071
#4  0x00000000006e5ca0 in mono_w32handle_wait_one (handle=0x401, timeout=9435, alertable=1) at w32handle.c:1190
#5  0x00000000006e5d60 in mono_w32handle_wait_multiple (handles=0x7f37edec7318, nhandles=1, waitall=0, timeout=9435, alertable=1) at w32handle.c:1224
#6  0x00000000006b6b48 in mono_wait_uninterrupted (thread=0x7f37f15a03c0, numhandles=1, handles=0x7f37edec7318, waitall=0, ms=9435, error=0x7f37edec7320) at threads.c:1892
#7  0x00000000006b6f26 in ves_icall_System_Threading_WaitHandle_WaitOne_internal (handle=0x401, ms=9435) at threads.c:2017
#8  0x0000000040461366 in ?? ()
#9  0x00007f37edec7410 in ?? ()
#10 0x00007f37e0002190 in ?? ()
#11 0x00007f37edec7370 in ?? ()
#12 0x00007f37edec7410 in ?? ()
#13 0x00007f37edec73c0 in ?? ()
#14 0x0000000000000000 in ?? ()

问题:基于低内存地址,如in ?? ()我会认为这是用户空间代码。我已经在调试模式下安装了mono * w / o编译器优化(Thread 100 (Thread 0x7f37aad33700 (LWP 10397)): #0 0x00000000406adc9f in ?? () #1 0x00007f37aad31ad0 in ?? () #2 0x00007f37ed69eed8 in ?? () #3 0x00007f37dd85b250 in ?? () #4 0x00007f37dd85b230 in ?? () #5 0x00007f37ed69eed8 in ?? () #6 0x00007f37dd85b250 in ?? () #7 0x00007f37f11812a0 in ?? () #8 0x00007f37ed69eec0 in ?? () #9 0x00007f37ed3405e0 in ?? () #10 0x00007f37ed6aaa18 in ?? () #11 0x00007f37f11812a0 in ?? () #12 0x00007f37f117c4f8 in ?? () #13 0x00007f37aad31b60 in ?? () #14 0x00000000406bb2c8 in ?? () #15 0x00007f37f11812a0 in ?? () #16 0x00007f37f11812a0 in ?? () #17 0x0000000000000098 in ?? () #18 0x00007f37f117f890 in ?? () #19 0x00007f37f117e770 in ?? () #20 0x00007f37f117f330 in ?? () #21 0x0000000000000000 in ?? () )。这是否意味着这不是功能卡住的单声道代码,而是单声道托管的应用程序?什么是最终的方式来证明它?

我的方式就是这样 - 但这是否正确?:

0x00007f37f117f330

1 个答案:

答案 0 :(得分:1)

您可以打印每个地址的方法名称 使用

p mono_pmip(0x0000000040461366)
p mono_pmip(0x00007f37edec7410)

等...

或者

要打印所有方法名称,请将以下代码放在" .gdbinit"您的主目录。然后你可以调用mono_backtrace命令..

define mono_backtrace
 select-frame 0
 set $i = 0
 while ($i < $arg0)
   set $foo = (char*) mono_pmip ($pc)
   if ($foo)
     printf "#%d %p in %s\n", $i, $pc, $foo
   else
     frame
   end
   up-silently
   set $i = $i + 1
 end
end

我在单声道项目文档中找到了上述信息 http://www.mono-project.com/docs/debug+profile/debug/