Reviewers: Jakob, ulan, Yang,

Description:
Fix ll_prof.py for static binaries.

BUG=

Please review this at https://codereview.chromium.org/1007613005/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+19, -3 lines):
  M tools/ll_prof.py


Index: tools/ll_prof.py
diff --git a/tools/ll_prof.py b/tools/ll_prof.py
index 409b39691775ff898d4f93ecb3fd2283976a051e..3fcf4174fc09edd5c28f6456fc8d5242d82754f9 100755
--- a/tools/ll_prof.py
+++ b/tools/ll_prof.py
@@ -711,6 +711,22 @@ class LibraryRepo(object):
     self.names = set()
     self.ticks = {}

+
+  def HasDynamicSymbols(self, filename):
+    if filename.endswith(".ko"): return False
+    process = subprocess.Popen(
+      "%s -h %s" % (OBJDUMP_BIN, filename),
+      shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+    pipe = process.stdout
+    try:
+      for line in pipe:
+        match = OBJDUMP_SECTION_HEADER_RE.match(line)
+        if match and match.group(1) == 'dynsym': return True
+    finally:
+      pipe.close()
+    assert process.wait() == 0, "Failed to objdump -h %s" % filename
+
+
   def Load(self, mmap_info, code_map, options):
     # Skip kernel mmaps when requested using the fact that their tid
     # is 0.
@@ -730,10 +746,10 @@ class LibraryRepo(object):
     # Unfortunately, section headers span two lines, so we have to
     # keep the just seen section name (from the first line in each
     # section header) in the after_section variable.
-    if mmap_info.filename.endswith(".ko"):
-      dynamic_symbols = ""
-    else:
+    if self.HasDynamicSymbols(mmap_info.filename):
       dynamic_symbols = "-T"
+    else:
+      dynamic_symbols = ""
     process = subprocess.Popen(
"%s -h -t %s -C %s" % (OBJDUMP_BIN, dynamic_symbols, mmap_info.filename),
       shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to