Patchwork Search debugfile directly in debug-file-directory if specified

login
register
mail settings
Submitter Mateusz Tabaka
Date April 9, 2014, 8:27 p.m.
Message ID <5345AD48.7080505@wp.pl>
Download mbox | patch
Permalink /patch/469/
State Changes Requested
Headers show

Comments

Mateusz Tabaka - April 9, 2014, 8:27 p.m.
Hi, When I set debug-file-directory, searching for debuglink doesn't 
work when it is located directly in that directory 
(<debug-file-directory>/debuglink). This patch fixes this issue.

Thanks,
Mateusz.


ChangeLog:
2014-04-09  Mateusz Tabaka  <8tab@wp.pl>

         * symfile.c: search debugfile directly in debug-file-directory 
if specified
Joel Brobecker - April 21, 2014, 4:03 p.m.
Hello,

> Hi, When I set debug-file-directory, searching for debuglink doesn't
> work when it is located directly in that directory
> (<debug-file-directory>/debuglink). This patch fixes this issue.

> ChangeLog:
> 2014-04-09  Mateusz Tabaka  <8tab@wp.pl>
> 
>         * symfile.c: search debugfile directly in
> debug-file-directory if specified

Thanks for the patch.

I am not a specialist of this area, but it seems to me that, after
reading the GDB documentation at:
https://www.sourceware.org/gdb/current/onlinedocs/gdb/Separate-Debug-Files.html

... that the current behavior is as documented. See the example
the documentation provides about the various alternatives that
GDB searches for. Sometimes, a case can be made for extending
a bit the behavior to accomodate other situations, but I am having
trouble seeing the benefits in your case. Why not put the debuglink
file in <debug-file-directory>/.debug/<debuglink>?

A couple of comments, while looking at your patch:

  - The ChangeLog entry needs to be adjusted a bit to provide the name
    of the subprogram where the change was made.  Lines should try
    to be within 70 chars, with a maximum length of 80 chars, and
    should all be indented by a tab.

  - Comments should be sentences starting with a capital letter,
    and ending with a period (you forgot the period).

Thank you.

> 
> 
> diff --git a/gdb/symfile.c b/gdb/symfile.c
> index 64a83c6..559ca95 100644
> --- a/gdb/symfile.c
> +++ b/gdb/symfile.c
> @@ -1534,6 +1534,17 @@ find_separate_debug_file (const char *dir,
>               return debugfile;
>             }
>         }
> +      /* If debugfile doesn't exists in all of above paths,
> +         try "<debug-file-directory>/<debuglink>" */
> +      strcpy (debugfile, debugdir);
> +      strcat (debugfile, "/");
> +      strcat (debugfile, debuglink);
> +
> +      if (separate_debug_file_exists (debugfile, crc32, objfile))
> +       {
> +         do_cleanups (back_to);
> +         return debugfile;
> +       }
>      }
> 
>    do_cleanups (back_to);

Patch

diff --git a/gdb/symfile.c b/gdb/symfile.c
index 64a83c6..559ca95 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1534,6 +1534,17 @@  find_separate_debug_file (const char *dir,
               return debugfile;
             }
         }
+      /* If debugfile doesn't exists in all of above paths,
+         try "<debug-file-directory>/<debuglink>" */
+      strcpy (debugfile, debugdir);
+      strcat (debugfile, "/");
+      strcat (debugfile, debuglink);
+
+      if (separate_debug_file_exists (debugfile, crc32, objfile))
+       {
+         do_cleanups (back_to);
+         return debugfile;
+       }
      }

    do_cleanups (back_to);