From e7f46615151c9399c4ac748a5a9b8dd4ced5d735 Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Tue, 2 Jul 2002 03:16:44 +0000 Subject: [PATCH] Print the library name when the library has no symbols. b=154752 r=jim_nance@yahoo.com sr=waterson --- tools/jprof/bfd.cpp | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/tools/jprof/bfd.cpp b/tools/jprof/bfd.cpp index bde3aa78f23..dd3738871a5 100644 --- a/tools/jprof/bfd.cpp +++ b/tools/jprof/bfd.cpp @@ -1,3 +1,4 @@ +// vim:ts=8:sw=2:et: // The contents of this file are subject to the Mozilla Public License // Version 1.1 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License @@ -21,8 +22,32 @@ extern "C" { char *cplus_demangle (const char *mangled, int options); } +#define NEXT_SYMBOL \ + sp++; \ + if (sp >= lastSymbol) { \ + long n = numExternalSymbols + 10000; \ + externalSymbols = (Symbol*) \ + realloc(externalSymbols, (size_t) (sizeof(Symbol) * n)); \ + lastSymbol = externalSymbols + n; \ + sp = externalSymbols + numExternalSymbols; \ + numExternalSymbols = n; \ + } + void leaky::ReadSymbols(const char *aFileName, u_long aBaseAddress) { + int initialSymbols = usefulSymbols; + if (NULL == externalSymbols) { + externalSymbols = (Symbol*) malloc(sizeof(Symbol) * 10000); + numExternalSymbols = 10000; + } + Symbol* sp = externalSymbols + usefulSymbols; + Symbol* lastSymbol = externalSymbols + numExternalSymbols; + + // Create a dummy symbol for the library so, if it doesn't have any + // symbols, we show it by library. + sp->Init(aFileName, aBaseAddress); + NEXT_SYMBOL + static bfd_boolean kDynamic = (bfd_boolean) false; static int firstTime = 1; @@ -49,14 +74,6 @@ void leaky::ReadSymbols(const char *aFileName, u_long aBaseAddress) unsigned int size; long symcount = bfd_read_minisymbols(lib, kDynamic, &minisyms, &size); - int initialSymbols = usefulSymbols; - if (NULL == externalSymbols) { - externalSymbols = (Symbol*) malloc(sizeof(Symbol) * 10000); - numExternalSymbols = 10000; - } - Symbol* sp = externalSymbols + usefulSymbols; - Symbol* lastSymbol = externalSymbols + numExternalSymbols; - // Scan symbols bfd_byte* from = (bfd_byte *) minisyms; bfd_byte* fromend = from + symcount * size; @@ -75,15 +92,7 @@ void leaky::ReadSymbols(const char *aFileName, u_long aBaseAddress) dnm = cplus_demangle(nm, 1); } sp->Init(dnm ? dnm : nm, syminfo.value + aBaseAddress); - sp++; - if (sp >= lastSymbol) { - long n = numExternalSymbols + 10000; - externalSymbols = (Symbol*) - realloc(externalSymbols, (size_t) (sizeof(Symbol) * n)); - lastSymbol = externalSymbols + n; - sp = externalSymbols + numExternalSymbols; - numExternalSymbols = n; - } + NEXT_SYMBOL } // } }