如何调试从gdb中的脚本获取输入的c++程序

How to debug a C++ program that takes input from a script in gdb

本文关键字:脚本 获取 输入 程序 c++ gdb 何调试 调试      更新时间:2023-10-16

背景信息:c++程序(LAMMPS -一个开放源代码)接受一个包含所有要执行的命令的输入脚本。可执行文件名为"lmp_fedora",输入脚本名为"in.hit"。程序的运行命令"。/lmp_fedora & lt;在。点击"

我的问题:我正试图调试LAMMPS中的.cpp文件之一。

My Attempts:我尝试了"gdb lmp_fedora

我的问题:你如何调试一个输入脚本(有命令链接到c++项目)使用gdb?

使用gdb run命令:

$ gdb lmp_fedora
(gdb) run <in.hit

从帮助:

(gdb) help run
Start debugged program.  You may specify arguments to give it.
Args may include "*", or "[...]"; they are expanded using "sh".
Input and output redirection with ">", "<", or ">>" are also allowed.
With no arguments, uses arguments last specified (with "run" or "set args").
To cancel previous arguments and run with no arguments,
use "set args" without arguments.

当您说gdb foo < bar时,这意味着bar输入到gdb,而不是foo

我认为你想使用的是gdb命令set args