简体   繁体   English

是否可以通过命令行将参数传递给GDB?

[英]Is it possible to pass parameters to GDB as the command line?

I am running someone's code and the code crashes on a specific dataset, but the crash message as-is is not informative. 我正在运行某人的代码,并且该代码在特定的数据集上崩溃,但是崩溃消息按原样显示并没有提供信息。 I cannot call GDB and then wait (for GDB) to pass r to it (things are running on a cluster). 我无法调用GDB,然后等待(对于GDB)将r传递给它(事物正在集群上运行)。 Is there a way to pass r to GDB in the runtime by default, something like the following? 有没有一种方法可以在默认情况下在运行时将r传递给GDB,如下所示?

 gdb r ./run

You can load your program in GDB, like: 您可以在GDB中加载程序,例如:

$ gdb your_program_name

and then attach to process which you want to debug 然后附加到您要调试的进程

attach pid

You may use a commands file. 您可以使用命令文件。 Write all the commands you want to execute sequentially in the file. 在文件中编写要顺序执行的所有命令。 And use that file to pass the command to GDB with input redirection: 并使用该文件通过输入重定向将命令传递给GDB:

echo "r" > cmds
gdb r --args ./run -arg1 -arg2 -arg3 < cmds

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM