Need to put a breakpoint in gdb using bash shell

I want a way to put a break point in gdb by runing a shell script.

Actualy I wanted to do certain automisation of a long manual process, which includes starting of a process in background and then taking the process ID of that process and then attach the gdb to that process ID. Then finaly put a break point at a specific location.

Is there any way to do it?

Why don't you just start the program from within gdb? That way you could set up all the breakpoints you need before the program even starts running.

So that just run the script. Don't had to start the gdb and then put a breakpoint.

Option 1: start the program from within gdb using a script you passed along using -x
Option 2: start the program in the background, start gdb using the process id ($!) and -x gdbfile, where gdbfile contains "break <line number>"

Since both options use the -x switch, I suggest taking a look at the gdb man page on what it does exactly.

Thanks alot for your great help pludi