simpleperf: move --proguard-mapping-file into report lib options.
So it can be available on all scripts.
Bug: 222758831
Test: run test/test.py --only-host-test
Change-Id: I40e7effe49a4c4e13b43fbb7979f9affeb594f76
diff --git a/simpleperf/scripts/gecko_profile_generator.py b/simpleperf/scripts/gecko_profile_generator.py
index f6d6854..683a569 100755
--- a/simpleperf/scripts/gecko_profile_generator.py
+++ b/simpleperf/scripts/gecko_profile_generator.py
@@ -295,7 +295,6 @@
record_file: str,
symfs_dir: Optional[str],
kallsyms_file: Optional[str],
- proguard_mapping_file: List[str],
comm_filter: Set[str],
sample_filter: Optional[str],
report_lib_options: ReportLibOptions) -> GeckoProfile:
@@ -303,8 +302,6 @@
lib = ReportLib()
lib.ShowIpForUnknownSymbol()
- for file_path in proguard_mapping_file:
- lib.AddProguardMappingFile(file_path)
if symfs_dir is not None:
lib.SetSymfs(symfs_dir)
lib.SetRecordFile(record_file)
@@ -407,10 +404,6 @@
parser.add_argument('--kallsyms', help='Set the path to find kernel symbols.')
parser.add_argument('-i', '--record_file', nargs='?', default='perf.data',
help='Default is perf.data.')
- parser.add_argument(
- '--proguard-mapping-file', nargs='+',
- help='Add proguard mapping file to de-obfuscate symbols',
- default=[])
sample_filter_group = parser.add_argument_group('Sample filter options')
parser.add_sample_filter_options(sample_filter_group)
sample_filter_group.add_argument('--comm', nargs='+', action='append', help="""
@@ -421,7 +414,6 @@
record_file=args.record_file,
symfs_dir=args.symfs,
kallsyms_file=args.kallsyms,
- proguard_mapping_file=args.proguard_mapping_file,
comm_filter=set(flatten_arg_list(args.comm)),
sample_filter=args.sample_filter,
report_lib_options=args.report_lib_options)
diff --git a/simpleperf/scripts/inferno/inferno.py b/simpleperf/scripts/inferno/inferno.py
index 039c34b..42cbeac 100755
--- a/simpleperf/scripts/inferno/inferno.py
+++ b/simpleperf/scripts/inferno/inferno.py
@@ -111,8 +111,6 @@
lib.SetRecordFile(record_file)
if kallsyms_file:
lib.SetKallsymsFile(kallsyms_file)
- for file_path in args.proguard_mapping_file or []:
- lib.AddProguardMappingFile(file_path)
if args.sample_filter:
lib.SetSampleFilter(args.sample_filter)
lib.SetReportOptions(args.report_lib_options)
@@ -310,8 +308,6 @@
report_group.add_argument('--symfs', help="""Set the path to find binaries with symbols and
debug info.""")
report_group.add_argument('--title', help='Show a title in the report.')
- report_group.add_argument('--proguard-mapping-file', nargs='+',
- help='Add proguard mapping file to de-obfuscate symbols')
parser.add_sample_filter_options(report_group, False)
parser.add_report_lib_options(report_group)
diff --git a/simpleperf/scripts/pprof_proto_generator.py b/simpleperf/scripts/pprof_proto_generator.py
index 4fcb637..e3e2d11 100755
--- a/simpleperf/scripts/pprof_proto_generator.py
+++ b/simpleperf/scripts/pprof_proto_generator.py
@@ -303,8 +303,6 @@
if self.config.get('show_art_frames'):
self.lib.ShowArtFrames()
- for file_path in self.config['proguard_mapping_file'] or []:
- self.lib.AddProguardMappingFile(file_path)
if self.config.get('sample_filter'):
self.lib.SetSampleFilter(self.config['sample_filter'])
self.lib.SetReportOptions(self.config['report_lib_options'])
@@ -635,9 +633,6 @@
Maximum depth of samples to be converted.""") # Large value as infinity standin.
parser.add_argument('--ndk_path', type=extant_dir, help='Set the path of a ndk release.')
parser.add_argument(
- '--proguard-mapping-file', nargs='+',
- help='Add proguard mapping file to de-obfuscate symbols')
- parser.add_argument(
'-j', '--jobs', type=int, default=os.cpu_count(),
help='Use multithreading to speed up source code annotation.')
sample_filter_group = parser.add_argument_group('Sample filter options')
@@ -662,7 +657,6 @@
config['dso_filters'] = flatten_arg_list(args.dso)
config['ndk_path'] = args.ndk_path
config['max_chain_length'] = args.max_chain_length
- config['proguard_mapping_file'] = args.proguard_mapping_file
config['sample_filter'] = args.sample_filter
config['report_lib_options'] = args.report_lib_options
generator = PprofProfileGenerator(config)
diff --git a/simpleperf/scripts/purgatorio/purgatorio.py b/simpleperf/scripts/purgatorio/purgatorio.py
index 93336cb..4e2560a 100755
--- a/simpleperf/scripts/purgatorio/purgatorio.py
+++ b/simpleperf/scripts/purgatorio/purgatorio.py
@@ -172,9 +172,6 @@
lib.SetReportOptions(args.report_lib_options)
- for file_path in args.proguard_mapping_file or []:
- lib.AddProguardMappingFile(file_path)
-
product = lib.MetaInfo().get('product_props')
if product:
@@ -279,9 +276,6 @@
help='Include dso names in backtraces')
parser.add_argument('--include_symbols_addr', '-s', action='store_true',
help='Include addresses of symbols in backtraces')
- parser.add_argument(
- '--proguard-mapping-file', nargs='+',
- help='Add proguard mapping file to de-obfuscate symbols')
parser.add_report_lib_options(default_show_art_frames=True)
args = parser.parse_args()
diff --git a/simpleperf/scripts/report_html.py b/simpleperf/scripts/report_html.py
index 5d96351..9c00131 100755
--- a/simpleperf/scripts/report_html.py
+++ b/simpleperf/scripts/report_html.py
@@ -605,11 +605,10 @@
def __init__(
self, binary_cache_path: Optional[str],
ndk_path: Optional[str],
- build_addr_hit_map: bool, proguard_mapping_files: Optional[List[str]]):
+ build_addr_hit_map: bool):
self.binary_cache_path = binary_cache_path
self.ndk_path = ndk_path
self.build_addr_hit_map = build_addr_hit_map
- self.proguard_mapping_files = proguard_mapping_files
self.meta_info: Optional[Dict[str, str]] = None
self.cmdline: Optional[str] = None
self.arch: Optional[str] = None
@@ -631,8 +630,6 @@
lib.ShowIpForUnknownSymbol()
if self.binary_cache_path:
lib.SetSymfs(self.binary_cache_path)
- for file_path in self.proguard_mapping_files or []:
- lib.AddProguardMappingFile(file_path)
if sample_filter:
lib.SetSampleFilter(sample_filter)
lib.SetReportOptions(report_lib_options)
@@ -986,9 +983,6 @@
parser.add_argument('--aggregate-by-thread-name', action='store_true', help="""aggregate
samples by thread name instead of thread id. This is useful for
showing multiple perf.data generated for the same app.""")
- parser.add_argument(
- '--proguard-mapping-file', nargs='+',
- help='Add proguard mapping file to de-obfuscate symbols')
parser.add_sample_filter_options()
parser.add_report_lib_options()
return parser.parse_args()
@@ -1016,8 +1010,7 @@
log_exit('Invalid --jobs option.')
# 2. Produce record data.
- record_data = RecordData(binary_cache_path, ndk_path, build_addr_hit_map,
- args.proguard_mapping_file)
+ record_data = RecordData(binary_cache_path, ndk_path, build_addr_hit_map)
for record_file in args.record_file:
record_data.load_record_file(record_file, args.report_lib_options, args.sample_filter)
if args.aggregate_by_thread_name:
diff --git a/simpleperf/scripts/report_sample.py b/simpleperf/scripts/report_sample.py
index 550098f..d99bbf9 100755
--- a/simpleperf/scripts/report_sample.py
+++ b/simpleperf/scripts/report_sample.py
@@ -28,7 +28,6 @@
symfs_dir: str,
kallsyms_file: str,
show_tracing_data: bool,
- proguard_mapping_file: List[str],
header: bool,
comm_filter: Set[str],
sample_filter: Optional[str],
@@ -37,8 +36,6 @@
lib = ReportLib()
lib.ShowIpForUnknownSymbol()
- for file_path in proguard_mapping_file:
- lib.AddProguardMappingFile(file_path)
if symfs_dir is not None:
lib.SetSymfs(symfs_dir)
if record_file is not None:
@@ -96,10 +93,6 @@
parser.add_argument('-i', '--record_file', nargs='?', default='perf.data',
help='Default is perf.data.')
parser.add_argument('--show_tracing_data', action='store_true', help='print tracing data.')
- parser.add_argument(
- '--proguard-mapping-file', nargs='+',
- help='Add proguard mapping file to de-obfuscate symbols',
- default=[])
parser.add_argument('--header', action='store_true',
help='Show metadata header, like perf script --header')
parser.add_argument('--comm', nargs='+', action='append', help="""
@@ -112,7 +105,6 @@
symfs_dir=args.symfs,
kallsyms_file=args.kallsyms,
show_tracing_data=args.show_tracing_data,
- proguard_mapping_file=args.proguard_mapping_file,
header=args.header,
comm_filter=set(flatten_arg_list(args.comm)),
sample_filter=args.sample_filter,
diff --git a/simpleperf/scripts/simpleperf_report_lib.py b/simpleperf/scripts/simpleperf_report_lib.py
index f7e7b91..4593888 100644
--- a/simpleperf/scripts/simpleperf_report_lib.py
+++ b/simpleperf/scripts/simpleperf_report_lib.py
@@ -300,6 +300,9 @@
def SetReportOptions(self, options: ReportLibOptions):
""" Set report options in one call. """
+ if options.proguard_mapping_files:
+ for file_path in options.proguard_mapping_files:
+ self.AddProguardMappingFile(file_path)
if options.show_art_frames:
self.ShowArtFrames(True)
if options.trace_offcpu:
diff --git a/simpleperf/scripts/simpleperf_utils.py b/simpleperf/scripts/simpleperf_utils.py
index 4bb8e87..f11d0a0 100644
--- a/simpleperf/scripts/simpleperf_utils.py
+++ b/simpleperf/scripts/simpleperf_utils.py
@@ -1004,6 +1004,7 @@
class ReportLibOptions:
show_art_frames: bool
trace_offcpu: str
+ proguard_mapping_files: List[str]
class BaseArgumentParser(argparse.ArgumentParser):
@@ -1017,6 +1018,9 @@
default_show_art_frames: bool = False):
self.has_report_lib_options = True
parser = group if group else self
+ parser.add_argument(
+ '--proguard-mapping-file', nargs='+',
+ help='Add proguard mapping file to de-obfuscate symbols')
parser.add_argument('--show-art-frames', '--show_art_frames',
action=argparse.BooleanOptionalAction, default=default_show_art_frames,
help='Show frames of internal methods in the ART Java interpreter.')
@@ -1111,7 +1115,8 @@
setattr(namespace, 'sample_filter', self._build_sample_filter(namespace))
if self.has_report_lib_options:
- report_lib_options = ReportLibOptions(namespace.show_art_frames, namespace.trace_offcpu)
+ report_lib_options = ReportLibOptions(
+ namespace.show_art_frames, namespace.trace_offcpu, namespace.proguard_mapping_file)
setattr(namespace, 'report_lib_options', report_lib_options)
if not Log.initialized:
diff --git a/simpleperf/scripts/stackcollapse.py b/simpleperf/scripts/stackcollapse.py
index 4e96c55..ee82a0b 100755
--- a/simpleperf/scripts/stackcollapse.py
+++ b/simpleperf/scripts/stackcollapse.py
@@ -37,7 +37,6 @@
record_file: str,
symfs_dir: str,
kallsyms_file: str,
- proguard_mapping_file: List[str],
event_filter: str,
include_pid: bool,
include_tid: bool,
@@ -52,8 +51,6 @@
if include_addrs:
lib.ShowIpForUnknownSymbol()
- for file_path in proguard_mapping_file:
- lib.AddProguardMappingFile(file_path)
if symfs_dir is not None:
lib.SetSymfs(symfs_dir)
if record_file is not None:
@@ -125,10 +122,6 @@
parser.add_argument('--jit', action='store_true', help='Annotate JIT functions with a _[j]')
parser.add_argument('--addrs', action='store_true',
help='include raw addresses where symbols can\'t be found')
- parser.add_argument(
- '--proguard-mapping-file', nargs='+',
- help='Add proguard mapping file to de-obfuscate symbols',
- default=[])
sample_filter_group = parser.add_argument_group('Sample filter options')
parser.add_sample_filter_options(sample_filter_group, False)
sample_filter_group.add_argument('--event-filter', nargs='?', default='',
@@ -141,7 +134,6 @@
record_file=args.record_file,
symfs_dir=args.symfs,
kallsyms_file=args.kallsyms,
- proguard_mapping_file=args.proguard_mapping_file,
event_filter=args.event_filter,
include_pid=args.pid,
include_tid=args.tid,
diff --git a/simpleperf/scripts/test/pprof_proto_generator_test.py b/simpleperf/scripts/test/pprof_proto_generator_test.py
index 87d650a..8e39d1a 100644
--- a/simpleperf/scripts/test/pprof_proto_generator_test.py
+++ b/simpleperf/scripts/test/pprof_proto_generator_test.py
@@ -217,8 +217,8 @@
binary_cache_builder.build_binary_cache(testdata_file, [TestHelper.testdata_dir])
# Read recording file.
- config = {'ndk_path': None, 'max_chain_length': 1000000, 'proguard_mapping_file': None,
- 'report_lib_options': ReportLibOptions(False, '')}
+ config = {'ndk_path': None, 'max_chain_length': 1000000,
+ 'report_lib_options': ReportLibOptions(False, '', None)}
generator = PprofProfileGenerator(config)
generator.load_record_file(testdata_file)