public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* objdump -d --line-numbers performance question
@ 2005-02-26  8:25 Emile Snyder
  2005-03-01 11:11 ` Nick Clifton
  0 siblings, 1 reply; 3+ messages in thread
From: Emile Snyder @ 2005-02-26  8:25 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1581 bytes --]

Hello all,

In one project I work on there's some scripts which we use to do
debugging that use objdump to get at debugging symbol info to decode
backtrace dumps from the program.  The application binary is ~50MB when
built with debugging info, and when we moved from developing on RedHat
7.3 to RH 9 or later, the objdump time went through the roof.

I grabbed a binutils-2.14 tarball, and spent a little time digging. 
oprofile reports that some huge proportion of the time is spent in the
bfd/elf.c:elf_find_function() call, which is being called (with some
intermediates) by binutils/objdump.c:show_line().

Looking at elf_find_function() it jumps out that it's doing a linear
search through the entire set of symbols every time it's called.  But
show_line() has access to find_symbol_for_address which does a binary
search on a sorted set of symbols.

So.  The attached patch uses find_symbol_for_address() in show_line(),
and then passes down a fake asymbol** list consisting of just the found
symbol and a null end marker.  So far it always produces identical
'objdump -d --line-numbers' output for me as the stock objdump, but my
run time on one representative file has gone from ~2 hours to ~4
minutes.

Does this look right?  If not, can anyone give me some pointers on the
right way to try to optimize things?

Thanks,
-emile


+----------------------------------------------------------------------
this wine is particularly heavy, and is mostly recommended for
hand-to-hand combat. -- Eric Idle 
+----------------------------------------------------------------------

[-- Attachment #2: binutils-2.14.objdumppatch --]
[-- Type: text/x-patch, Size: 1027 bytes --]

diff -Naur binutils-2.14/binutils/objdump.c binutils-2.14-modified/binutils/objdump.c
--- binutils-2.14/binutils/objdump.c	2003-03-31 16:32:47.000000000 -0800
+++ binutils-2.14-modified/binutils/objdump.c	2005-02-25 12:02:43.617595584 -0800
@@ -980,13 +980,22 @@
   const char *filename;
   const char *functionname;
   unsigned int line;
+  asymbol *foundsym;
+  asymbol *mocksyms[2];
+  long symplace;
 
   if (! with_line_numbers && ! with_source_code)
     return;
 
-  if (! bfd_find_nearest_line (abfd, section, syms, addr_offset, &filename,
-			       &functionname, &line))
-    return;
+  foundsym = find_symbol_for_address(abfd, section, 
+                                     section->vma + addr_offset, 
+                                     FALSE, &symplace);
+  mocksyms[0] = foundsym;
+  mocksyms[1] = NULL;
+
+  if (! bfd_find_nearest_line (abfd, section, mocksyms, addr_offset, &filename,
+  			       &functionname, &line))
+      return;
 
   if (filename != NULL && *filename == '\0')
     filename = NULL;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-03-02 15:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-26  8:25 objdump -d --line-numbers performance question Emile Snyder
2005-03-01 11:11 ` Nick Clifton
2005-03-02 15:27   ` Emile Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).