I run GDB on object file (e.g exeFile
) and I want to examine it according to several commands . How can I execute these commands according to lines in a file (instead input these each GDN running) ?
For example - I want to set break in -
break *0x8048e19 break *0x8048e32 break *0x8048e6f break *0x8048e90
so I want to save them in a file and then tell the GDB execute them from this file.
Use the run command to start your program under GDB. You must first specify the program name (except on VxWorks) with an argument to GDB (see section Getting In and Out of GDB), or by using the file or exec-file command (see section Commands to specify files).
A command file for GDB is a text file made of lines that are GDB commands. Comments (lines starting with # ) may also be included. An empty line in a command file does nothing; it does not mean to repeat the last command, as it would from the terminal.
Go to your Linux command prompt and type “gdb”. Gdb open prompt lets you know that it is ready for commands. To exit out of gdb, type quit or q. 2.
write the commands in a file and execute gdb with -x switch
gdb -x command_file_name
or run the gdb source command while gdb is running if you dont want to specify a command file from command line
>source [-s] [-v] command_file_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With