[英]Running gdb with a source file
I have a Linux executable file and I can run it on command line, but at first, I should use 我有一个Linux可执行文件,可以在命令行中运行它,但是首先,我应该使用
source ./somefile
If I don't source
it, the executable crashed. 如果我不
source
它,可执行崩溃。 I also, can run the file under dbg. 我也可以在dbg下运行文件。 But I need to
source somefile
in gdb also. 但是我也需要在gdb中提供
source somefile
。 I mean, I already make source ./somefile
then run the gdb and run the executable in it, the executable crashed like without using source ./somefile. 我的意思是,我已经制作了
source ./somefile
然后运行gdb并在其中运行可执行文件,该可执行文件崩溃了,就像不使用source ./somefile一样。
By the way, somefile that I should source
contains some EXPORT=bla bla definitions. 顺便说一句,somefile我应该做的
source
包括一些出口=喇嘛喇嘛定义。
Executable is an embedded qt software, running on imx6 board. Executable是在imx6板上运行的嵌入式qt软件。 Sourcing somefile makes some definition about qt libraries.
采购somefile对qt库进行了一些定义。 The crash message when I run the executable without sourcing somefile and when sourcing it and then run in gdb is exactly the same.
当我运行可执行文件而不提供一些文件时以及当在gdb中提供它然后在gdb中运行时的崩溃消息是完全相同的。 So I think that after source somefile, if I run the executable in gdb, it seems gdb doesn't know libraries' path.
因此,我认为在源文件之后,如果我在gdb中运行可执行文件,似乎gdb不知道库的路径。 May be a way to source a file for gdb.
可能是为gdb获取文件的一种方法。
I guess you are asking how to set environment variables inside gdb. 我猜您在问如何在gdb中设置环境变量。
You should use set environment
, see builtin help: 您应该使用
set environment
,请参阅内置帮助:
(gdb) help set environment
Set environment variable value to give the program.
Arguments are VAR VALUE where VAR is variable name and VALUE is value.
VALUES of environment variables are uninterpreted strings.
This does not affect the program until the next "run" command.
(gdb)
You will have to take VAR
and VALUE
from ./somefile
. 您将必须从
./somefile
获取VAR
和VALUE
。 You can't simply source
it in gdb prompt because it is shell script, not gdb script. 你不能简单地
source
它在gdb的提示,因为它是shell脚本,而不是GDB脚本。
You might run your source
command, and later, in the same shell (eg same terminal window), run gdb
to debug your program. 您可以运行您的
source
命令,然后在同一外壳(例如,同一终端窗口)中运行gdb
调试程序。 The environment variables setup by your source
builtin command are valid for not only the gdb
process, but also the debugged process. 通过
source
内置命令设置的环境变量不仅对gdb
进程有效,而且对调试进程有效。
Read more about Debugging with GDB . 阅读有关使用GDB进行调试的更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.