InxaneNinja
InxaneNinja

Reputation: 161

Is there a way to completely disable gdb output?

I have a C++ program a which has a win function, which is never being called.
I can call it with gdb, by simply executing jump *win.
The problem is, I'm trying to automate this process, with a one liner:
gdb -q a -ex "break *main" -ex "run" -ex "jump *(_Z3winv)"
Is there a way to see only the output from the program itself, without this:

inxane@root:~/mysecretfolder$ gdb -q a -ex "break *main" -ex "run" -ex "jump *(_Z3winv)"

warning: /mysecretfolder/pwndbg/gdbinit.py: No such file or directory
Reading symbols from a...(no debugging symbols found)...done.
Breakpoint 1 at 0x8e9
Starting program: /mysecretfolder/a 

Breakpoint 1, 0x00005555555548e9 in main ()
Continuing at 0x5555555548ba.
You won!
[Inferior 1 (process 15866) exited with code 040]

(i just want this)

You won!

If it's necessary, here is the source code:

#include <iostream>
using namespace std;
void win()
{
    cout << "You won!" << endl;
}
int main()
{
    cout << "You failed!" << endl;
    return 0;
}

Upvotes: 1

Views: 1184

Answers (1)

OznOg
OznOg

Reputation: 4732

Try adding the option -batch-silent to your gdb command

see documentation 'gdb documentation'

Upvotes: 3

Related Questions