How to redirect stdin to a file while passing a factor in gdb

Asked 2 years ago, Updated 2 years ago, 137 views

I usually ./a.out arg1 arg2 <file I'd like to use gdb to debug the program together.

How do I give commands or options?

c++ debugging gdb

2022-09-22 11:01

2 Answers

gdb --args path/to/executable -every -arg you can=think < of After that Enter run to start debugging the gdb command console.


2022-09-22 11:01

In gdb, as shown below

(gdb) r args... < file

When you do this or send the output of the program immediately

(gdb) r args... $(program > file) < file

I think I did it like this, too. However, after the program finishes printing, the output goes into the input.


2022-09-22 11:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.