Re: [patch] Fix for PR gdb/9538 (loading of separate debuginfo and symlinks).

Doug Evans
2012-01-12T23:18:16Z

On Thu, Jan 12, 2012 at 2:26 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
>>> +
>>> +  debugfile = find_separate_debug_file (dir1, canon_dir, debuglink,
>>> +                                     crc32, objfile);
>>> +  xfree (canon_dir);
>>> +
>>> +  if (debugfile != NULL)
>>> +    goto cleanup1;
>>> +
>>> +  /* For PR gdb/9538, try again with realpath (if different from the
>>> +     original).  */
>>> +  dir2 = lrealpath (objfile->name);
>>
>> Maybe some optimization would be helpful.  realpath is expensive and the
>> directory path is already canonicalized.  Something like lstat (objfile->name)
>> and do this step only if it is a symlink.
>
> Wouldn't lstat need a configury #ifdef to make it build?

[for reference sake, one patch in my basenames-may-differ series (not
submitted) had a use for lstat.
IWBN to have lstat in gdb so we could (appropriately of course) use it.

OOC, Jan, what discussion led rise to having braces here:

+ if (strcmp (dir1, dir2) == 0)
+ {
+ /* Same directory, no point retrying. */
+ goto cleanup;
+ }

and does that reasoning apply here:

+ if (debuglink == NULL)
+ /* There's no separate debug info, hence there's no way we could
+ load it => no warning. */
+ return NULL;