Question:
How to load program reading stdin and taking parameters in gdb?
Ludovic_han
2007-11-02 16:20:16 UTC
I have a program that takes input from stdin and also takes some parameters from command line. It looks like this:

cat input.txt > myprogram -path "/home/user/work"

I try to debug the code with gdb inside emacs, by M-x gdb, I try to load the program with the command:

gdb cat input.txt > myprogram -path "/home/user/work"

However, gdb does not like it.

I'm pretty new to gdb, so please anyone tell me how to start my program in gdb correctly. Thanks!
Four answers:
sofarsogood
2007-11-02 16:32:30 UTC
gdb under emacs - great!



You are making it too complicated. M-x gdb starts emacs, then just type the program name as arg: .



At the gdb command line just start the program with



r -path "/home/user/work"



stdio should all work correctly.



You don't say what platform you are on. If you are on windows you want to make sure the program is not compiled as a windows application, but is a console one. If you use gcc the switch for this is -windows (that is, do *not* use -windows on your build line)
anonymous
2016-12-25 00:03:42 UTC
1
?
2016-04-30 02:58:01 UTC
The quandary that numerous parents find themselves in is they don't have enough time to find the proper eBook s and understanding structure with which to instruct their children but with this specific plan https://tr.im/mFcrw , Children Learning Reading this problem is come to a end.

Children Learning Reading is really extensive, and your son or daughter will have number problems assimilating the lessons while the lessons are well-designed. Because the system is dependant on phonetics, the educational method is gradual.

In Children Learning Reading program the instructions are unique and can not be found in other learning methods.
anonymous
2007-11-02 23:56:25 UTC
while running gdb, reading from stdin is same as reading from stdin while the program runs under a terminal.



for passing command line args, use set command of gdb. look at help set for details.



gdb should be run like, well, as said in the man page. If you use gdb under emacs, learn reading manpages and info documents from emacs as well. It comes in handy many times.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...