diff options
author | pcc <pcc@chromium.org> | 2015-11-25 17:08:37 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-26 01:10:34 +0000 |
commit | 2dacf7decbc26266d695943b4bc4a57c37429e58 (patch) | |
tree | 7132698d6bf7d3cbd33c82f3b9a820780fe0d679 | |
parent | 94833c007d0ba7f4814df63739fd062ba49d6523 (diff) | |
download | chromium_src-2dacf7decbc26266d695943b4bc4a57c37429e58.zip chromium_src-2dacf7decbc26266d695943b4bc4a57c37429e58.tar.gz chromium_src-2dacf7decbc26266d695943b4bc4a57c37429e58.tar.bz2 |
cygprofile: Allow $ character in symbol names.
Clang's symbol names sometimes contain the $ character, which we previously
disallowed. We continue to forbid the $ character at the start of the symbol
name, as these are ARM mapping symbols [1] which should not appear in our
orderfile.
At the same time, fix an issue where an exception can cause a deadlock when
waiting for the objdump process by closing stdout before waiting on it.
[1] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0474f/CHDGFCDI.html
BUG=539408
R=pasko@chromium.org
Review URL: https://codereview.chromium.org/1458853004
Cr-Commit-Position: refs/heads/master@{#361779}
-rwxr-xr-x | tools/cygprofile/symbol_extractor.py | 9 | ||||
-rwxr-xr-x | tools/cygprofile/symbol_extractor_unittest.py | 16 |
2 files changed, 23 insertions, 2 deletions
diff --git a/tools/cygprofile/symbol_extractor.py b/tools/cygprofile/symbol_extractor.py index d709117..452548e 100755 --- a/tools/cygprofile/symbol_extractor.py +++ b/tools/cygprofile/symbol_extractor.py @@ -54,7 +54,13 @@ def _FromObjdumpLine(line): section = parts[3] size = int(parts[4], 16) name = parts[-1].rstrip('\n') - assert re.match('^[a-zA-Z0-9_.]+$', name) + # Forbid ARM mapping symbols and other unexpected symbol names, but allow $ + # characters in a non-initial position, which can appear as a component of a + # mangled name, e.g. Clang can mangle a lambda function to: + # 02cd61e0 l F .text 000000c0 _ZZL11get_globalsvENK3$_1clEv + # The equivalent objdump line from GCC is: + # 0325c58c l F .text 000000d0 _ZZL11get_globalsvENKUlvE_clEv + assert re.match('^[a-zA-Z0-9_.][a-zA-Z0-9_.$]*$', name) return SymbolInfo(name=name, offset=offset, section=section, size=size) @@ -90,6 +96,7 @@ def SymbolInfosFromBinary(binary_filename): result = _SymbolInfosFromStream(p.stdout) return result finally: + p.stdout.close() p.wait() diff --git a/tools/cygprofile/symbol_extractor_unittest.py b/tools/cygprofile/symbol_extractor_unittest.py index 986a187..bd2db4a 100755 --- a/tools/cygprofile/symbol_extractor_unittest.py +++ b/tools/cygprofile/symbol_extractor_unittest.py @@ -29,7 +29,10 @@ class TestSymbolInfo(unittest.TestCase): line = ('00c1b228 l F .text 00000060 _ZN20trace_event too many') self.assertRaises(AssertionError, symbol_extractor._FromObjdumpLine, line) # This line has invalid characters in the symbol. - line = ('00c1b228 l F .text 00000060 _ZN20trace_$bad') + line = ('00c1b228 l F .text 00000060 _ZN20trace_?bad') + self.assertRaises(AssertionError, symbol_extractor._FromObjdumpLine, line) + # This line has an invalid character at the start of the symbol name. + line = ('00c1b228 l F .text 00000060 $_ZN20trace_bad') self.assertRaises(AssertionError, symbol_extractor._FromObjdumpLine, line) def testSymbolInfo(self): @@ -60,6 +63,17 @@ class TestSymbolInfo(unittest.TestCase): self.assertEquals(test_name, symbol_info.name) self.assertEquals(test_section, symbol_info.section) + def testDollarInSymbolName(self): + # A $ character elsewhere in the symbol name is fine. + # This is an example of a lambda function name from Clang. + line = ('00c1b228 l F .text 00000060 _ZZL11get_globalsvENK3$_1clEv') + symbol_info = symbol_extractor._FromObjdumpLine(line) + self.assertIsNotNone(symbol_info) + self.assertEquals(0xc1b228, symbol_info.offset) + self.assertEquals(0x60, symbol_info.size) + self.assertEquals('_ZZL11get_globalsvENK3$_1clEv', symbol_info.name) + self.assertEquals('.text', symbol_info.section) + class TestSymbolInfosFromStream(unittest.TestCase): def testSymbolInfosFromStream(self): |