Add debug spew.

Thu Nov  9 16:17:11 2006  Søren Sandmann  <sandmann@redhat.com>

        * binfile.c: Add debug spew.
This commit is contained in:
Søren Sandmann
2006-11-09 21:17:59 +00:00
committed by Søren Sandmann Pedersen
parent 442a9b4f3c
commit 5e91fe1818
2 changed files with 33 additions and 3 deletions

View File

@ -1,3 +1,7 @@
Thu Nov 9 16:17:11 2006 Søren Sandmann <sandmann@redhat.com>
* binfile.c: Add debug spew.
Thu Nov 9 16:01:47 2006 Søren Sandmann <sandmann@redhat.com>
* sysprof-text.c (main): Die immediately if the output file is a

View File

@ -73,8 +73,12 @@ separate_debug_file_exists (const char *name, guint32 crc)
guint32 file_crc;
ElfParser *parser = elf_parser_new (name, NULL);
g_print (" trying %s: ", name);
if (!parser)
{
g_print ("no.\n");
return NULL;
}
file_crc = elf_parser_get_crc32 (parser);
@ -87,6 +91,8 @@ separate_debug_file_exists (const char *name, guint32 crc)
return NULL;
}
g_print ("found\n");
return parser;
}
@ -109,13 +115,15 @@ get_debug_file (ElfParser *elf,
basename = elf_parser_get_debug_link (elf, &crc32);
g_print (" debug link for %s is %s\n", filename, basename);
if (!basename)
return NULL;
dir = g_path_get_dirname (filename);
tries[0] = g_build_filename (dir, basename, NULL);
tries[1] = g_build_filename (dir, ".debug", NULL);
tries[1] = g_build_filename (dir, ".debug", basename, NULL);
tries[2] = g_build_filename (debug_file_directory, dir, basename, NULL);
for (i = 0; i < 3; ++i)
@ -123,6 +131,7 @@ get_debug_file (ElfParser *elf,
result = separate_debug_file_exists (tries[i], crc32);
if (result)
{
g_print (" found debug binary for %s: %s\n", filename, tries[i]);
if (new_name)
*new_name = g_strdup (tries[i]);
break;
@ -167,6 +176,7 @@ find_separate_debug_file (ElfParser *elf,
{
if (list_contains_name (seen_names, fname))
{
g_print (" cycle detected\n");
/* cycle detected, just return the original elf file itself */
break;
}
@ -181,6 +191,10 @@ find_separate_debug_file (ElfParser *elf,
seen_names = g_list_prepend (seen_names, fname);
fname = debug_name;
}
else
{
g_print (" no debug info file for %s\n", fname);
}
}
while (debug);
@ -232,7 +246,7 @@ bin_file_new (const char *filename)
{
bf->elf = elf_parser_new (filename, NULL);
if (!bf->elf)
g_print ("Could not parse file %s\n", bf->elf);
g_print ("Could not parse file %s\n", filename);
}
/* We need the text offset of the actual binary, not the
@ -240,12 +254,24 @@ bin_file_new (const char *filename)
*/
if (bf->elf)
{
ElfParser *oldelf;
bf->text_offset = elf_parser_get_text_offset (bf->elf);
#if 0
g_print ("text offset: %d\n", bf->text_offset);
#endif
oldelf = bf->elf;
if (bf->elf)
g_print ("trying to find separate debug file for %s\n", filename);
bf->elf = find_separate_debug_file (bf->elf, filename);
if (!bf->elf)
g_print (" returned NULL\n");
else if (bf->elf != oldelf)
g_print (" successfully opened a different elf file than the original\n");
else
g_print (" opened the original elf file\n");
}
bf->inode_check = FALSE;