Skip to content

Commit 1b1fc48

Browse files
author
roman_yakovenko
committed
"nm" utility invocation was fixed. Now it handles right relative paths and paths with spaces
1 parent 57ac776 commit 1b1fc48

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

docs/history/history.rest

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Thanks to all the people that have contributed patches, bug reports and suggesti
2222
* Ben Schleimer
2323
* Gustavo Carneiro
2424
* Christopher Bruns
25+
* Alejandro Dubrovsky
2526

2627
-----------
2728
SVN Version
@@ -50,7 +51,11 @@ SVN Version
5051
8. "explicit" property was added to ``declarations.constructor_t`` class.
5152
Many thanks to Christopher Bruns, for finding out how this property
5253
works in `GCC-XML`_.
53-
54+
55+
9. "List symbols" (`nm`) utility invocation was improved and now handles
56+
right relative paths and paths with spaces. Many thanks to Alejandro Dubrovsky
57+
for providing the patch.
58+
5459
-----------
5560
Version 1.0
5661
-----------

pygccxml/binary_parsers/parsers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,20 +216,19 @@ class so_file_parser_t( formated_mapping_parser_t ):
216216
"""parser for Linux .so file"""
217217
nm_executable = 'nm'
218218
#numeric-sort used for mapping between mangled and unmangled name
219-
cmd_mangled = '%(nm)s --extern-only --dynamic --defined-only --numeric-sort %(lib)s'
220-
cmd_demangled = '%(nm)s --extern-only --dynamic --defined-only --demangle --numeric-sort %(lib)s'
219+
cmd_mangled = '%(nm)s --extern-only --dynamic --defined-only --numeric-sort %(lib)s'.split()
220+
cmd_demangled = '%(nm)s --extern-only --dynamic --defined-only --demangle --numeric-sort %(lib)s'.split()
221+
221222
entry = re.compile( r'^(?P<address>(?:\w|\d)+)\s\w\s(?P<symbol>.+)$' )
222223

223224
def __init__( self, global_ns, binary_file ):
224225
formated_mapping_parser_t.__init__( self, global_ns, binary_file, 'nm' )
225226

226227
def __execute_nm( self, cmd ):
227228
process = subprocess.Popen( args=cmd
228-
, shell=True
229229
, stdin=subprocess.PIPE
230230
, stdout=subprocess.PIPE
231-
, stderr=subprocess.STDOUT
232-
, cwd=os.path.dirname( self.binary_file ) )
231+
, stderr=subprocess.STDOUT )
233232
process.stdin.close()
234233

235234
output = []
@@ -254,8 +253,9 @@ def __extract_symbols( self, cmd ):
254253

255254
def load_symbols( self ):
256255
tmpl_args = dict( nm=self.nm_executable, lib=self.binary_file )
257-
mangled_smbls = self.__extract_symbols( self.cmd_mangled % tmpl_args )
258-
demangled_smbls = self.__extract_symbols( self.cmd_demangled % tmpl_args )
256+
mangled_smbls = self.__extract_symbols( [part % tmpl_args for part in self.cmd_mangled] )
257+
demangled_smbls = self.__extract_symbols( [part % tmpl_args for part in self.cmd_demangled] )
258+
259259
result = []
260260
for address, blob in mangled_smbls.iteritems():
261261
if address in demangled_smbls:

0 commit comments

Comments
 (0)