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 2/2] Try to initialize data-directory by first searching for "data-directory" in the same directory as the gdb binary


Hi Jan,

On Sep 22, 2012, at 7:08 AM, Jan Kratochvil wrote:

> On Fri, 21 Sep 2012 21:05:36 +0200, Khoo Yit Phang wrote:
>> On Sep 21, 2012, at 2:31 PM, Jan Kratochvil wrote:
>>> Also it could check for /usr/gdb/data-directory which is less likely to be
>>> present than /usr/bin/data-directory .
>> 
>> That does not happen, since the first part of relocate_gdb_data_directory finds BINDIR/data-directory by finding the directory containing the gdb binary, then appending "data-directory" to it. But in your patch:
>> 
>>> +     build directory.  */
>>> +  datadir = ldirname (BINDIR);
>>> +  datadir = reconcat (datadir, datadir,
>>> +		      SLASH_STRING "gdb" SLASH_STRING "data-directory", NULL);
>>> +  dir = relocate_path (gdb_program_name, datadir, 1, 1);
>> 
>> Doesn't this have a possibility of finding /usr/gdb/data-directory?
> 
> Your patch may find /usr/bin/data-directory, my patch may find
> /usr/gdb/data-directory, I find the latter as a less possibly existing my
> mistake.  But maybe it does not matter much.

Personally, I'm not fond of either my patch or yours, since they hard code parts of the build directory into the binary (whether "data-directory" or "gdb/data-directory"). In either case, they can lead to weird, difficult-to-understand behavior (possibly even dangerous) in the off chance that one those directory exist. I'd rather leave it out.

Yit
September 22, 2012


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