From 5e91fe1818c76727b97c973bf2433eb27bc97c4d Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=B8ren=20Sandmann?= Date: Thu, 9 Nov 2006 21:17:59 +0000 Subject: [PATCH] Add debug spew. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Thu Nov 9 16:17:11 2006 Søren Sandmann * binfile.c: Add debug spew. --- ChangeLog | 4 ++++ binfile.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 72bd1af..3135ab5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Nov 9 16:17:11 2006 Søren Sandmann + + * binfile.c: Add debug spew. + Thu Nov 9 16:01:47 2006 Søren Sandmann * sysprof-text.c (main): Die immediately if the output file is a diff --git a/binfile.c b/binfile.c index ca5ae93..8382081 100644 --- a/binfile.c +++ b/binfile.c @@ -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; -- 2.7.4