繁体   English   中英

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

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

背景信息:C ++程序(LAMMPS - 一个开源)接受一个包含要执行的所有命令的输入脚本。 可执行文件名为“lmp_fedora”,输入脚本名为“in.hit”。 程序的运行命令“./lmp_fedora <in.hit”

我的问题:我正在尝试调试LAMMPS中的一个.cpp文件。

我的尝试:1。我试过“gdb lmp_fedora <in.hit”,但它失败了。 2.还尝试使用ps aux找到正在运行的程序的pid,但不确定它是哪个id。

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

您使用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

暂无
暂无

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

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