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-21T19:05:59Z

Hi,

On Sep 21, 2012, at 2:31 PM, Jan Kratochvil wrote:

> I am not happy from the code duplication with existing function:

Yeah, it's not pretty, but I'm not sure how to eliminate the redundancy since if "data-directory" is found, it may have to be canonicalized as well.

> 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?

Yit
September 21, 2012