Re: [PATCH 2/2] Try to initialize data-directory by first searching for "data-directory" in the same directory as the gdb binary

Khoo Yit Phang
2012-09-24T15:00:45Z

Hi,

On Sep 24, 2012, at 10:51 AM, Eli Zaretskii wrote:

>> From: Khoo Yit Phang <khooyp@cs.umd.edu>
>> Date: Mon, 24 Sep 2012 10:37:17 -0400
>> Cc: Khoo Yit Phang <khooyp@cs.umd.edu>,
>> brobecker@adacore.com,
>> jan.kratochvil@redhat.com,
>> gdb-patches@sourceware.org
>>
>>> Please don't. Invoking GDB from the build directory should "just
>>> work".
>>
>> What do you mean? If we call the shell script "gdb" (only in the build-directory, to clarify; it will not be installed to /usr/bin), then it will "just work" in almost all cases, except when running gdb on gdb.
>
> First, running gdb on gdb is an important use case.

Yes, and instead of running "gdb gdb/gdb", you'd run "gdb gdb/gdb-the-real-binary", which I think is trivial for GDB developers.

> Second, there are systems (like MS-Windows) which cannot run Unix
> shell scripts natively.

That's easy to fix, write the redirector as a C program and compile it at the same time gdb-the-real-binary is compiled.

> Third, why should I trust random shell scripts that come with the
> distribution?

Why would you trust any random binary, including gdb, that gets installed in the build directory? In my suggestion, the redirector will *never* be installed to /usr/bin.

> Forth, having a shell script that shadows a binary leads to confusion
> and aggravation if the user is not aware of that dichotomy.

No *user* should ever see the redirector once GDB has been installed. It's only ever in the build directory for GDB developers to run GDB from the build directory.

> There are probably more reasons why.
>
>> If we patch the gdb binary and incur the risk that a stray data-directory will lead to bugs.
>
> I don't see how is this different from risk of running a stray shell
> script.

Again, the redirector will never be installed to /usr/bin, whereas gdb-the-real-binary is always installed.

Yit
September 24, 2012