debugging - How to passing input data in GDB mode for programming C. Already passed parameters and run program -


i know how pass parameters in gdb mode running: "run parameters". however, when continuing debug using n or s go, pass data program, let text/string. example, want send string "testing" program because program waits receive command console. if type "testing" "undefined command: "testing". try help".

(gdb) b 100 (gdb) run "pass parameters program here" (gdb) n  (gdb) want send string program, how can it? 

so how can send text program while debugging gdb in step mode? much.

for real, type in. sample session:

paul@local:~/src/c/scratch$ gdb ./deb gnu gdb (gdb) 7.4.1-debian copyright (c) 2012 free software foundation, inc. license gplv3+: gnu gpl version 3 or later <http://gnu.org/licenses/gpl.html> free software: free change , redistribute it. there no warranty, extent permitted law.  type "show copying" , "show warranty" details. gdb configured "x86_64-linux-gnu". bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... reading symbols /home/paul/src/c/scratch/deb...done. (gdb) list 1   #include <stdio.h> 2    3   int main(void) { 4       char buffer[100]; 5       fgets(buffer, 100, stdin); 6       printf("you entered: %s", buffer); 7       return 0; 8   } (gdb) break 4 breakpoint 1 @ 0x400644: file deb.c, line 4. (gdb) run starting program: /home/paul/src/c/scratch/deb   breakpoint 1, main () @ deb.c:5 5       fgets(buffer, 100, stdin); (gdb) n hello, world! 6       printf("you entered: %s", buffer); (gdb) n entered: hello, world! 7       return 0; (gdb) continue continuing. [inferior 1 (process 4290) exited normally] (gdb)  

the hello, world! after first n typed in normally.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -