Reputation: 945
I am using GDB to debug my C program.
And since I am handling SIGUSR1
in my program.
So once I run the gdb with my program executable like -
gdb <my_executable>
under the gdb prompt (gdb)
I need to enter -
handle SIGUSR1 nostop noprint pass
since I need to do this every time, I wanted to place this handle
command in the init script.
So after googling, I got to know about the ~/.gdbrc
and ~/.gdbinit
. I tried to place the handle
command in both the files, but still I don't see that handle command is executed once after gdb reads the symbols from the executable.
What could be wrong with this?
Edit: GNU gdb (GDB) 7.2.2
Edit 2: My .gdbrc file content looks like -
echo "hello from gdbrc"
handle SIGUSR1 nostop noprint pass
run 204
Edit 3: Even I tried with GNU gdb (GDB) 8.1.3 Still I'm facing the same issue.
Edit 4: The ~/.gdbrc
and ~/.gdbinit
are given full access permission -
-rwxrwxrwx 1 darshan grp 68 Oct 9 22:14 .gdbint
-rwxrwxrwx 1 darshan grp 67 Oct 9 22:14 .gdbrc
Edit 5: I had named the file wrongly as ".gdbint
" instead of ".gdbinit
".
After renaming, I found with the GDB 8.1.3
, it is being read at the startup. However, with GDB 7.2.2
still I see the problem - .gdbinit
file is not read at the startup.
And ~/.gdbrc
is NOT a right filename to use and won't be recognized by GDB.
Upvotes: 2
Views: 2319
Reputation: 213937
Can I assume GDB 7.2.2 didnt support .gdbinit?
GDB has supported reading ~/.gdbinit
since forever (at least since version 4.0, but probably much earlier).
You should be able to figure out what's happening by looking at the output from
strace -e file gdb --version |& grep gdbinit
Here is what I see:
stat("/home/employedrussian/.gdbinit", {st_mode=S_IFREG|0640, st_size=629, ...}) = 0
stat(".gdbinit", 0x7ffe51ef72f0) = -1 ENOENT (No such file or directory)
Update:
When I run the command, I see no output with GDB 7.2.2 But with GDB 8.1.3, I see the same output like you.
Ok, it seems that you have a broken version of GDB 7.2.2. Try newer version.
I could not find any bug about GDB not reading .gdbinit
, but maybe it was broken at some point temporarily.
what is the different purposes between ~/.gdbinit and ~/.gdbrc
The former is read by GDB, the latter isn't (where did you get the idea that GDB would read it?).
Update:
I thought just like many other linux application
It is a UNIX shell convention to read ~/.${SHELL}rc
file on startup, and other applications may do so as well. But GDB isn't one of them.
That answer is wrong.
Upvotes: 3