gdb/
* symfile.c (build_id_to_debug_filename): New variable debugdir. Move variables size, s and data into a new inner block. Change xmalloc for alloca, use direct BUILDID->SIZE there now. Loop for the DEBUG_FILE_DIRECTORY components. (find_separate_debug_file): New variable debugdir and debugdir_end. Loop for the DEBUG_FILE_DIRECTORY components. (_initialize_symfile): For "debug-file-directory" use plural and note one can use multiple components now. gdb/doc/ * gdb.texinfo (set debug-file-directory, show debug-file-directory) (Auto-loading): Use plural and note one can use multiple components now. gdb/testsuite/ * gdb.base/sepdebug.exp: New test_different_dir call for multiple-dirs.
This commit is contained in:
parent
25522fae98
commit
24ddea6286
@ -1,3 +1,14 @@
|
|||||||
|
2009-11-02 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
* symfile.c (build_id_to_debug_filename): New variable debugdir. Move
|
||||||
|
variables size, s and data into a new inner block. Change xmalloc for
|
||||||
|
alloca, use direct BUILDID->SIZE there now. Loop for the
|
||||||
|
DEBUG_FILE_DIRECTORY components.
|
||||||
|
(find_separate_debug_file): New variable debugdir and debugdir_end.
|
||||||
|
Loop for the DEBUG_FILE_DIRECTORY components.
|
||||||
|
(_initialize_symfile): For "debug-file-directory" use plural and note
|
||||||
|
one can use multiple components now.
|
||||||
|
|
||||||
2009-11-02 Jan Kratochvil <jan.kratochvil@redhat.com>
|
2009-11-02 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
* symfile.c (find_separate_debug_file): Initialize dir, debugfile and
|
* symfile.c (find_separate_debug_file): Initialize dir, debugfile and
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2009-11-02 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
* gdb.texinfo (set debug-file-directory, show debug-file-directory)
|
||||||
|
(Auto-loading): Use plural and note one can use multiple components now.
|
||||||
|
|
||||||
2009-11-01 Vladimir Prus <vladimir@codesourcery.com>
|
2009-11-01 Vladimir Prus <vladimir@codesourcery.com>
|
||||||
|
|
||||||
* gdb.texinfo (GDB/MI Stack Manipulation): Make
|
* gdb.texinfo (GDB/MI Stack Manipulation): Make
|
||||||
|
@ -14084,13 +14084,14 @@ name @value{GDBN} is currently using.
|
|||||||
@table @code
|
@table @code
|
||||||
|
|
||||||
@kindex set debug-file-directory
|
@kindex set debug-file-directory
|
||||||
@item set debug-file-directory @var{directory}
|
@item set debug-file-directory @var{directories}
|
||||||
Set the directory which @value{GDBN} searches for separate debugging
|
Set the directories which @value{GDBN} searches for separate debugging
|
||||||
information files to @var{directory}.
|
information files to @var{directory}. Multiple directory components can be set
|
||||||
|
concatenating them by a directory separator.
|
||||||
|
|
||||||
@kindex show debug-file-directory
|
@kindex show debug-file-directory
|
||||||
@item show debug-file-directory
|
@item show debug-file-directory
|
||||||
Show the directory @value{GDBN} searches for separate debugging
|
Show the directories @value{GDBN} searches for separate debugging
|
||||||
information files.
|
information files.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
@ -19382,8 +19383,8 @@ readable, @value{GDBN} will evaluate it as a Python script.
|
|||||||
|
|
||||||
If this file does not exist, and if the parameter
|
If this file does not exist, and if the parameter
|
||||||
@code{debug-file-directory} is set (@pxref{Separate Debug Files}),
|
@code{debug-file-directory} is set (@pxref{Separate Debug Files}),
|
||||||
then @value{GDBN} will use the file named
|
then @value{GDBN} will use for its each separated directory component
|
||||||
@file{@var{debug-file-directory}/@var{real-name}}, where
|
@code{component} the file named @file{@code{component}/@var{real-name}}, where
|
||||||
@var{real-name} is the object file's real name, as described above.
|
@var{real-name} is the object file's real name, as described above.
|
||||||
|
|
||||||
Finally, if this file does not exist, then @value{GDBN} will look for
|
Finally, if this file does not exist, then @value{GDBN} will look for
|
||||||
|
130
gdb/symfile.c
130
gdb/symfile.c
@ -1218,35 +1218,59 @@ build_id_verify (const char *filename, struct build_id *check)
|
|||||||
static char *
|
static char *
|
||||||
build_id_to_debug_filename (struct build_id *build_id)
|
build_id_to_debug_filename (struct build_id *build_id)
|
||||||
{
|
{
|
||||||
char *link, *s, *retval = NULL;
|
char *link, *debugdir, *retval = NULL;
|
||||||
gdb_byte *data = build_id->data;
|
|
||||||
size_t size = build_id->size;
|
|
||||||
|
|
||||||
/* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */
|
/* DEBUG_FILE_DIRECTORY/.build-id/ab/cdef */
|
||||||
link = xmalloc (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1
|
link = alloca (strlen (debug_file_directory) + (sizeof "/.build-id/" - 1) + 1
|
||||||
+ 2 * size + (sizeof ".debug" - 1) + 1);
|
+ 2 * build_id->size + (sizeof ".debug" - 1) + 1);
|
||||||
s = link + sprintf (link, "%s/.build-id/", debug_file_directory);
|
|
||||||
if (size > 0)
|
|
||||||
{
|
|
||||||
size--;
|
|
||||||
s += sprintf (s, "%02x", (unsigned) *data++);
|
|
||||||
}
|
|
||||||
if (size > 0)
|
|
||||||
*s++ = '/';
|
|
||||||
while (size-- > 0)
|
|
||||||
s += sprintf (s, "%02x", (unsigned) *data++);
|
|
||||||
strcpy (s, ".debug");
|
|
||||||
|
|
||||||
/* lrealpath() is expensive even for the usually non-existent files. */
|
/* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
|
||||||
if (access (link, F_OK) == 0)
|
cause "/.build-id/..." lookups. */
|
||||||
retval = lrealpath (link);
|
|
||||||
xfree (link);
|
|
||||||
|
|
||||||
if (retval != NULL && !build_id_verify (retval, build_id))
|
debugdir = debug_file_directory;
|
||||||
|
do
|
||||||
{
|
{
|
||||||
xfree (retval);
|
char *s, *debugdir_end;
|
||||||
retval = NULL;
|
gdb_byte *data = build_id->data;
|
||||||
|
size_t size = build_id->size;
|
||||||
|
|
||||||
|
while (*debugdir == DIRNAME_SEPARATOR)
|
||||||
|
debugdir++;
|
||||||
|
|
||||||
|
debugdir_end = strchr (debugdir, DIRNAME_SEPARATOR);
|
||||||
|
if (debugdir_end == NULL)
|
||||||
|
debugdir_end = &debugdir[strlen (debugdir)];
|
||||||
|
|
||||||
|
memcpy (link, debugdir, debugdir_end - debugdir);
|
||||||
|
s = &link[debugdir_end - debugdir];
|
||||||
|
s += sprintf (s, "/.build-id/");
|
||||||
|
if (size > 0)
|
||||||
|
{
|
||||||
|
size--;
|
||||||
|
s += sprintf (s, "%02x", (unsigned) *data++);
|
||||||
|
}
|
||||||
|
if (size > 0)
|
||||||
|
*s++ = '/';
|
||||||
|
while (size-- > 0)
|
||||||
|
s += sprintf (s, "%02x", (unsigned) *data++);
|
||||||
|
strcpy (s, ".debug");
|
||||||
|
|
||||||
|
/* lrealpath() is expensive even for the usually non-existent files. */
|
||||||
|
if (access (link, F_OK) == 0)
|
||||||
|
retval = lrealpath (link);
|
||||||
|
|
||||||
|
if (retval != NULL && !build_id_verify (retval, build_id))
|
||||||
|
{
|
||||||
|
xfree (retval);
|
||||||
|
retval = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (retval != NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
debugdir = debugdir_end;
|
||||||
}
|
}
|
||||||
|
while (*debugdir != 0);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -1333,7 +1357,7 @@ static char *
|
|||||||
find_separate_debug_file (struct objfile *objfile)
|
find_separate_debug_file (struct objfile *objfile)
|
||||||
{
|
{
|
||||||
asection *sect;
|
asection *sect;
|
||||||
char *basename, *name_copy;
|
char *basename, *name_copy, *debugdir;
|
||||||
char *dir = NULL;
|
char *dir = NULL;
|
||||||
char *debugfile = NULL;
|
char *debugfile = NULL;
|
||||||
char *canon_name = NULL;
|
char *canon_name = NULL;
|
||||||
@ -1410,29 +1434,51 @@ find_separate_debug_file (struct objfile *objfile)
|
|||||||
if (separate_debug_file_exists (debugfile, crc32, objfile->name))
|
if (separate_debug_file_exists (debugfile, crc32, objfile->name))
|
||||||
goto cleanup_return_debugfile;
|
goto cleanup_return_debugfile;
|
||||||
|
|
||||||
/* Then try in the global debugfile directory. */
|
/* Then try in the global debugfile directories.
|
||||||
strcpy (debugfile, debug_file_directory);
|
|
||||||
strcat (debugfile, "/");
|
Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will
|
||||||
strcat (debugfile, dir);
|
cause "/..." lookups. */
|
||||||
strcat (debugfile, basename);
|
|
||||||
|
|
||||||
if (separate_debug_file_exists (debugfile, crc32, objfile->name))
|
debugdir = debug_file_directory;
|
||||||
goto cleanup_return_debugfile;
|
do
|
||||||
|
|
||||||
/* If the file is in the sysroot, try using its base path in the
|
|
||||||
global debugfile directory. */
|
|
||||||
if (canon_name
|
|
||||||
&& strncmp (canon_name, gdb_sysroot, strlen (gdb_sysroot)) == 0
|
|
||||||
&& IS_DIR_SEPARATOR (canon_name[strlen (gdb_sysroot)]))
|
|
||||||
{
|
{
|
||||||
strcpy (debugfile, debug_file_directory);
|
char *debugdir_end;
|
||||||
strcat (debugfile, canon_name + strlen (gdb_sysroot));
|
|
||||||
|
while (*debugdir == DIRNAME_SEPARATOR)
|
||||||
|
debugdir++;
|
||||||
|
|
||||||
|
debugdir_end = strchr (debugdir, DIRNAME_SEPARATOR);
|
||||||
|
if (debugdir_end == NULL)
|
||||||
|
debugdir_end = &debugdir[strlen (debugdir)];
|
||||||
|
|
||||||
|
memcpy (debugfile, debugdir, debugdir_end - debugdir);
|
||||||
|
debugfile[debugdir_end - debugdir] = 0;
|
||||||
strcat (debugfile, "/");
|
strcat (debugfile, "/");
|
||||||
|
strcat (debugfile, dir);
|
||||||
strcat (debugfile, basename);
|
strcat (debugfile, basename);
|
||||||
|
|
||||||
if (separate_debug_file_exists (debugfile, crc32, objfile->name))
|
if (separate_debug_file_exists (debugfile, crc32, objfile->name))
|
||||||
goto cleanup_return_debugfile;
|
goto cleanup_return_debugfile;
|
||||||
|
|
||||||
|
/* If the file is in the sysroot, try using its base path in the
|
||||||
|
global debugfile directory. */
|
||||||
|
if (canon_name
|
||||||
|
&& strncmp (canon_name, gdb_sysroot, strlen (gdb_sysroot)) == 0
|
||||||
|
&& IS_DIR_SEPARATOR (canon_name[strlen (gdb_sysroot)]))
|
||||||
|
{
|
||||||
|
memcpy (debugfile, debugdir, debugdir_end - debugdir);
|
||||||
|
debugfile[debugdir_end - debugdir] = 0;
|
||||||
|
strcat (debugfile, canon_name + strlen (gdb_sysroot));
|
||||||
|
strcat (debugfile, "/");
|
||||||
|
strcat (debugfile, basename);
|
||||||
|
|
||||||
|
if (separate_debug_file_exists (debugfile, crc32, objfile->name))
|
||||||
|
goto cleanup_return_debugfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
debugdir = debugdir_end;
|
||||||
}
|
}
|
||||||
|
while (*debugdir != 0);
|
||||||
|
|
||||||
xfree (debugfile);
|
xfree (debugfile);
|
||||||
debugfile = NULL;
|
debugfile = NULL;
|
||||||
@ -4173,12 +4219,12 @@ Usage: set extension-language .foo bar"),
|
|||||||
|
|
||||||
add_setshow_optional_filename_cmd ("debug-file-directory", class_support,
|
add_setshow_optional_filename_cmd ("debug-file-directory", class_support,
|
||||||
&debug_file_directory, _("\
|
&debug_file_directory, _("\
|
||||||
Set the directory where separate debug symbols are searched for."), _("\
|
Set the directories where separate debug symbols are searched for."), _("\
|
||||||
Show the directory where separate debug symbols are searched for."), _("\
|
Show the directories where separate debug symbols are searched for."), _("\
|
||||||
Separate debug symbols are first searched for in the same\n\
|
Separate debug symbols are first searched for in the same\n\
|
||||||
directory as the binary, then in the `" DEBUG_SUBDIRECTORY "' subdirectory,\n\
|
directory as the binary, then in the `" DEBUG_SUBDIRECTORY "' subdirectory,\n\
|
||||||
and lastly at the path of the directory of the binary with\n\
|
and lastly at the path of the directory of the binary with\n\
|
||||||
the global debug-file directory prepended."),
|
each global debug-file-directory component prepended."),
|
||||||
NULL,
|
NULL,
|
||||||
show_debug_file_directory,
|
show_debug_file_directory,
|
||||||
&setlist, &showlist);
|
&setlist, &showlist);
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2009-11-02 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
* gdb.base/sepdebug.exp: New test_different_dir call for multiple-dirs.
|
||||||
|
|
||||||
2009-11-02 Jan Kratochvil <jan.kratochvil@redhat.com>
|
2009-11-02 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
* gdb.base/sepdebug.exp (CRC mismatch is reported): New test.
|
* gdb.base/sepdebug.exp (CRC mismatch is reported): New test.
|
||||||
|
@ -995,6 +995,12 @@ if ![string compare $build_id_debug_filename ""] then {
|
|||||||
|
|
||||||
test_different_dir build-id "${objdir}/${subdir}" $xfail
|
test_different_dir build-id "${objdir}/${subdir}" $xfail
|
||||||
|
|
||||||
|
# Test also multiple directories can be specified. Without the build-id
|
||||||
|
# reference GDB would find the separate debug info just at the same
|
||||||
|
# location as the executable file.
|
||||||
|
|
||||||
|
test_different_dir multiple-dirs "/doesnotexist:${objdir}/${subdir}" $xfail
|
||||||
|
|
||||||
# Spare debug files may confuse testsuite runs in the future.
|
# Spare debug files may confuse testsuite runs in the future.
|
||||||
remote_exec build "rm -f ${objdir}/${subdir}/${build_id_debug_filename}"
|
remote_exec build "rm -f ${objdir}/${subdir}/${build_id_debug_filename}"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user