如何在GDB中“重新加载"源文件 [英] How to 'reload' source files in GDB
问题描述
gdb
中是否有一个我可以用来(重新)加载/刷新"源文件的命令? (据我所见,根据)
Is there a command in gdb
that I can use to (re)load / "refresh" source files? (As far as I can see, gdb
works only with source directories, according to Debugging with GDB: Source - and there is no specific command to "refresh")
我使用带有调试内核的虚拟机,因此我可以连接到gdb
的本地实例,并且可以调试内核模块.使用调试信息编译模块,并指定保留模块源的文件夹(
I use a virtual machine with a debug kernel, so I can connect to a local instance of gdb
, and can debug kernel modules. The modules are compiled with debug info on, and this specifies folders where the source of the modules is kept (Instruct GDB 6.5 to use source embedded in object file - Stack Overflow). I have the source directories in the same path(s) in both VM and local machine.
问题是这样的-我需要做很多步骤才能使模块出现segfault-并将远程gdb放入堆栈.然后进行回溯,我可以看到引用的源文件,即
The problem is this - I need to do quite a bit of steps in order to get the module to segfault - and the remote gdb to go into the stack. Then I do a backtrace, and I can see the source files referenced, i.e.
#0 0xc0132a13 in ?? ()
#1 0xc056e551 in ?? ()
#2 0xc056e506 in ?? ()
#3 0xd8be53f3 in mymodule_func1 (var1=0xd79f9b44, var2=0x0, var3=825269148)
at /media/src/mymodule.h:954
#4 0xd8be53d0 in mymodule_func2 (data=3617561412)
at /media/src/mymodule.h:936
#5 0xc014fe87 in ?? ()
#6 0xc0151478 in ?? ()
然后我试着说list /media/src/mymodule.h:954
-我意识到我已经更改了本地版本的mymodule.h
文件的内容!
Then I try to do say, list /media/src/mymodule.h:954
- and I realize that I have changed stuff on the local version of mymodule.h
file!!
因此,我撤消了更改-但不幸的是,GDB没有看到这些更改!而且,当然,我不想重新启动GDB-因为这意味着我必须重新启动VM,并完成整个过程才能再次使内核模块进行segfault :( !!
So I undo the changes - but unfortunately, GDB does not see these changes! And, of course, I don't want to restart GDB - because that means I have to restart the VM, and go through the entire procedure in order to get the kernel module to segfault again :( !!
然后我尝试执行以下操作:
Then I try to do something like this:
(gdb) show symbol-reloading
Dynamic symbol table reloading multiple times in one run is off.
(gdb) set symbol-reloading on
(gdb) add-symbol-file ~/mymodule.o 0xd8be4000
add symbol table from file "/media/src/mymodule.o" at
.text_addr = 0xd8be4000
(y or n) y
Reading symbols from /media/src/mymodule.o...done.
...希望它能以某种方式重新加载"源文件-但不幸的是,list /media/src/mymodule.h:954
表明它没有,没有任何改变-即使gdb
可以识别发生了什么变化,例如warning: Source file is more recent than executable.
...( ,因此,暂时,我还必须重新启动整个VM和gdb
:( :( )
... in hope that it will somehow "reload" the source files - but unfortunately, list /media/src/mymodule.h:954
shows that it doesn't, nothing is changed - even though gdb
does recognize that something has changed, as in warning: Source file is more recent than executable.
... (so, for the time being, I have to restart entire VM and gdb
as well :( :( )
推荐答案
使用 directory
命令似乎具有预期的效果.
Resetting the directory list using the directory
command appears to have the desired effect.
这篇关于如何在GDB中“重新加载"源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!