Merge lp:~ben-hutchings/ensoft-sextant/objdump-parser-nogrep-opt into lp:ensoft-sextant

Proposed by Ben Hutchings
Status: Merged
Approved by: Robert
Approved revision: 71
Merged at revision: 42
Proposed branch: lp:~ben-hutchings/ensoft-sextant/objdump-parser-nogrep-opt
Merge into: lp:ensoft-sextant
Prerequisite: lp:~ben-hutchings/ensoft-sextant/objdump-filepath-fix
Diff against target: 46 lines (+15/-7)
1 file modified
src/sextant/objdump_parser.py (+15/-7)
To merge this branch: bzr merge lp:~ben-hutchings/ensoft-sextant/objdump-parser-nogrep-opt
Reviewer Review Type Date Requested Status
Robert Approve
Review via email: mp+245088@code.launchpad.net

Commit message

Added an option to run_objdump to disable grepping the objdump output.

Description of the change

Added an option to run_objdump to disable grepping the objdump output.

To post a comment you must log in.
Revision history for this message
Robert (rjwills) :
review: Approve
Revision history for this message
Martin Morrison (isoschiz) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/sextant/objdump_parser.py'
2--- src/sextant/objdump_parser.py 2014-12-18 10:45:17 +0000
3+++ src/sextant/objdump_parser.py 2014-12-18 10:45:17 +0000
4@@ -350,7 +350,7 @@
5 return result
6
7
8-def run_objdump(input_file, add_file_paths=False):
9+def run_objdump(input_file, add_file_paths=False, do_grep=True):
10 """
11 Run the objdump command on the file with the given path.
12
13@@ -363,6 +363,10 @@
14 add_file_paths:
15 Whether to call with -l option to extract line numbers and source
16 files from the binary. VERY SLOW on large binaries (~15 hours for ios).
17+ do_grep:
18+ Whether to filter the output of objdump through grep to remove
19+ everything except section headers, function definitions, function
20+ calls and filepaths.
21
22 """
23 print('input file: {}'.format(input_file))
24@@ -373,12 +377,16 @@
25 args += ['--line-numbers']
26
27 p = subprocess.Popen(args, stdout=subprocess.PIPE)
28- # Egrep filters out the section headers (Disassembly of section...),
29- # the call lines (... [l]call[q] ...), the function declarations
30- # (... <function>:$) and the file paths (^/file_path).
31- g = subprocess.Popen(['egrep', 'Disassembly|call(q)? |>:$|^/'],
32- stdin=p.stdout, stdout=subprocess.PIPE)
33- return input_file, g.stdout
34+
35+ if do_grep:
36+ # Egrep filters out the section headers (Disassembly of section...),
37+ # the call lines (... [l]call[q] ...), the function declarations
38+ # (... <function>:$) and the file paths (^/file_path).
39+ g = subprocess.Popen(['egrep', 'Disassembly|call(q)? |>:$|^/'],
40+ stdin=p.stdout, stdout=subprocess.PIPE)
41+ return input_file, g.stdout
42+ else:
43+ return input_file, p.stdout
44
45
46 def main():

Subscribers

People subscribed via source and target branches