This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Fix calling gcore when gdb is not in $PATH.
- From: Luis Machado <lgustavo at codesourcery dot com>
- To: "'gdb-patches at sourceware dot org'" <gdb-patches at sourceware dot org>, Jan Kratochvil <jan dot kratochvil at redhat dot com>
- Date: Fri, 11 Oct 2013 11:10:16 -0300
- Subject: [PATCH] Fix calling gcore when gdb is not in $PATH.
- Authentication-results: sourceware.org; auth=none
- Reply-to: lgustavo at codesourcery dot com
Hi,
Currently, the generated gcore scripts assume the gdb binary they need
to call is present in $PATH, but this may not always be true.
If you want to call the gcore scripts from a relative directory, for
example, it will fail to locate the gdb binary. The attached patch fixes
this.
Before the patch:
$ /tmp/gdb_test_install/bin/gcoreblahbleh 20000
/tmp/gdb_test_install/bin/gcoreblahbleh: 54:
/tmp/gdb_test_install/bin/gcoreblahbleh: gdbblahbleh: not found
gcoreblahbleh: failed to create core.20000
After the patch:
$ /tmp/gdb_test_install/bin/gcoreblahbleh 20000
warning: unable to open /proc file '/proc/20000/status'
warning: unable to open /proc file '/proc/20000/status'
ptrace: No such process.
You can't do that without a process to debug.
The program is not being run.
gcoreblahbleh: failed to create core.20000
How does it look?
Regards,
Luis
2013-10-11 Luis Machado <lgustavo@codesourcery.com>
* gcore.in: Call gdb using the full path to the gcore script.
diff --git a/gdb/gcore.in b/gdb/gcore.in
index 9c5b14d..b82479c 100644
--- a/gdb/gcore.in
+++ b/gdb/gcore.in
@@ -51,7 +51,7 @@ for pid in $*
do
# `</dev/null' to avoid touching interactive terminal if it is
# available but not accessible as GDB would get stopped on SIGTTIN.
- @GDB_TRANSFORM_NAME@ </dev/null --nx --batch \
+ "$(dirname "$0")"/@GDB_TRANSFORM_NAME@ </dev/null --nx --batch \
-ex "set pagination off" -ex "set height 0" -ex "set width 0" \
-ex "attach $pid" -ex "gcore $name.$pid" -ex detach -ex quit