簡體   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