This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix calling gcore when gdb is not in $PATH.


On 10/11/2013 11:31 AM, Jan Kratochvil wrote:
On Fri, 11 Oct 2013 16:10:16 +0200, Luis Machado wrote:
--- 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 \

I have only some concern if $0 does not contain a directory name.
Then `dirname basename` will be . and gdb -> ./gdb will be a regression as
./gdb will typically not be found.

For example if you run:
	$ sh gcore foo
then sh (or bash) executes /usr/bin/gcore but $0 is still just "gcore".

It IMO even corresponds to the sh $0 POSIX description ("command_file"):
	http://pubs.opengroup.org/onlinepubs/007908799/xcu/sh.html


Right. That situation can indeed happen. Though it looks a little awkward to call something in your path like that.

I suppose we can extend the check to cover that case as well. Let me go back to the drawing board.

Thanks,
Luis


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]