Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a .sh (shell script) file in GDB?

Tags:

shell

gdb

I have a script file named simple. I can run it using ./simple and everything works fine as it should.

I need to run this file in GDB to back trace how one particular parameter is changed and by what functions is it called. when I try

(gdb) file simple

"/home/examples/simple": not in executable format: File format not recognized

(gdb) r simple

Starting program: simple

No executable file specified.

Use the "file" or "exec-file" command.`

How can I overcome this?

like image 963
unix_kid Avatar asked Sep 23 '13 09:09

unix_kid


People also ask

How do I debug bash?

Bash provides extensive debugging features. The most common is to start up the subshell with the -x option, which will run the entire script in debug mode. Traces of each command plus its arguments are printed to standard output after the commands have been expanded but before they are executed.


1 Answers

GDB is debugger for compiled languages (like C/C++) not for shell scripts. If you need debug Bash script you can use -x flag.

like image 75
Hauleth Avatar answered Sep 21 '22 11:09

Hauleth