调试PIN工具add-symbol-file不起作用

问题描述 投票:0回答:2

要调试使用 PIN 工具的模拟器,通过使用 2 个不同的终端窗口,我执行以下操作:

/home/agy/mcsim/pin/intel64/bin/pinbin -pause_tool 5 -t /home/agy/mcsim/Pthread/mypthreadtool -port 47145 -skip_first 10000 -- McSim/JacNoBoost/JACCARD
Pausing to attach to pid 5465
To load the tool's debug info to gdb use:
   add-symbol-file /home/agy/mcsim/Pthread/mypthreadtool 0x7f86e6c06ee0 -s .data 0x7f86e709f620 -s .bss 0x7f86e70aaac0

在另一个窗口上我执行以下操作:

gdb /home/agy/mcsim/Pthread/mypthreadtool
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 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 "x86_64-linux-gnu".
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"...
Reading symbols from /home/agy/mcsim/Pthread/mypthreadtool...done.
(gdb) attach 5465
Attaching to program: /home/agy/mcsim/Pthread/mypthreadtool, process 5465
0x0000000030592c70 in ?? ()
(gdb) add-symbol-file /home/agy/mcsim/Pthread/mypthreadtool 0x7f86e6c06ee0 -s .data 0x7f86e709f620 -s .bss 0x7f86e70aaac0
add symbol table from file "/home/agy/mcsim/Pthread/mypthreadtool" at
    .text_addr = 0x7f86e6c06ee0
    .data_addr = 0x7f86e709f620
    .bss_addr = 0x7f86e70aaac0
(y or n) y
Reading symbols from /home/agy/mcsim/Pthread/mypthreadtool...done.
(gdb) c
Continuing.

在某些时候,pin 工具冻结,我手动向 pin 工具发送中断信号,并尝试在附加窗口上调试它。为了了解引脚实现卡在哪一行,我尝试了 backtrace 命令,但即使添加了符号文件,它也会返回问号。

Program received signal SIGINT, Interrupt.
0x000000003052c474 in ?? ()
(gdb) backtrace
#0  0x000000003052c474 in ?? ()
#1  0x00007f86e5570850 in ?? ()
#2  0x000000003070c290 in ?? ()
#3  0x0000000001dda880 in ?? ()
#4  0x0000000001dda880 in ?? ()
#5  0x000000000040e03a in ?? ()
#6  0x0000000030643de0 in ?? ()
#7  0x00007f86d5ada0c0 in ?? ()
#8  0x0000000000000012 in ?? ()
#9  0x00007f86e5571350 in ?? ()
#10 0x0000000030aade20 in ?? ()
#11 0x0000000000000000 in ?? ()

我在这里找不到错误的方法。你能帮我吗?

c++ gdb backtrace intel-pin
2个回答
2
投票

我在这里找不到错误的方法。

您告诉 GDB

mypthreadtool
是您的主要可执行文件,但它不是
/home/agy/mcsim/pin/intel64/bin/pinbin
是。

试试这个:

gdb /home/agy/mcsim/pin/intel64/bin/pinbin 5465
(gdb) add-symbol-file /home/agy/mcsim/Pthread/mypthreadtool \
    0x7f86e6c06ee0 -s .data 0x7f86e709f620 -s .bss 0x7f86e70aaac0

0
投票

想要刷新生成的新提示以及如何导航

打开 2 个终端并导航到以下命令:

$ cd source/tools/ManualExamples

在一个终端中

$ make DEBUG=1 lab0.cpp   // compile the pintool to be debugged with this flag
$ ../../../pin -pause_tool 30 -t obj-intel64/lab0.so -- /bin/ls

暂停 30 秒以附加到 pid 31946 的进程
要将调试信息加载到 gdb,请使用:


设置 sysroot /not/existing/dir
文件
添加符号文件 /home/jasneetsingh/Desktop/pintool/pin-experiments/source/tools/ManualExamples/obj-intel64/lab0.so > 0x7f8eef3993d0 -s .data 0x7f8eef51a9c0 -s .bss 0x7f8eef51b3c0


在另一个终端

$ sudo gdb ../../../pin
...
(gdb) attach 31946
(gdb) set sysroot /not/existing/dir
(gdb) file
...
Are you sure you want to change the file? (y or n) y
(gdb) add-symbol-file /home/jasneetsingh/Desktop/pintool/pin-experiments/source/tools/ManualExamples/obj-intel64/lab0.so 0x7f8eef3993d0 -s .data 0x7f8eef51a9c0 -s .bss 0x7f8eef51b3c0
( y or n) y
(gdb) b main

现在可以开始调试了
鸣谢:https://bbs.kanxue.com/thread-272656.htm

© www.soinside.com 2019 - 2024. All rights reserved.