Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read and execute GDB commands from a file?

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.

like image 896
URL87 Avatar asked Jan 09 '13 00:01

URL87


People also ask

How do I run a GDB 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).

What is GDB command file?

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.

How do I open a GDB file in Linux?

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.


1 Answers

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 
like image 51
Kanwar Saad Avatar answered Oct 03 '22 20:10

Kanwar Saad