[PATCH] D71868: [llvm-locstats][NFC] Support OOP concept
David Stenberg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 7 08:59:00 PST 2020
dstenb accepted this revision.
dstenb added a comment.
This revision is now accepted and ready to land.
Seems like a good refactoring. Two minor inline comments.
================
Comment at: llvm/utils/llvm-locstats/llvm-locstats.py:33
+ print ('No scope bytes found.')
+ sys.exit(0)
+
----------------
Should this be a `return` instead now that this code is moved to a utility function?
================
Comment at: llvm/utils/llvm-locstats/llvm-locstats.py:74
-def locstats_output(
- variables_total,
- variables_total_locstats,
- variables_with_loc,
- scope_bytes_covered,
- scope_bytes,
- variables_coverage_map
- ):
-
- if scope_bytes == 0:
- print ('No scope bytes found.')
- sys.exit(0)
-
- pc_ranges_covered = int(ceil(scope_bytes_covered * 100.0)
- / scope_bytes)
- variables_coverage_per_map = {}
- for cov_bucket in coverage_buckets():
- variables_coverage_per_map[cov_bucket] = \
- int(ceil(variables_coverage_map[cov_bucket] * 100.0) \
- / variables_total_locstats)
-
- print (' =================================================')
- print (' Debug Location Statistics ')
- print (' =================================================')
- print (' cov% samples percentage(~) ')
- print (' -------------------------------------------------')
- for cov_bucket in coverage_buckets():
- print (' {0:10} {1:8d} {2:3d}%'. \
- format(cov_bucket, variables_coverage_map[cov_bucket], \
- variables_coverage_per_map[cov_bucket]))
- print (' =================================================')
- print (' -the number of debug variables processed: ' \
- + str(variables_total_locstats))
- print (' -PC ranges covered: ' + str(pc_ranges_covered) + '%')
-
- # Only if we are processing all the variables output the total
- # availability.
- if variables_total and variables_with_loc:
- total_availability = int(ceil(variables_with_loc * 100.0) \
- / variables_total)
- print (' -------------------------------------------------')
- print (' -total availability: ' + str(total_availability) + '%')
- print (' =================================================')
-
-def parse_program_args(parser):
- parser.add_argument('-only-variables', action='store_true',
- default=False,
- help='calculate the location statistics only for '
- 'local variables'
- )
- parser.add_argument('-only-formal-parameters', action='store_true',
- default=False,
- help='calculate the location statistics only for '
- 'formal parameters'
- )
- parser.add_argument('-ignore-debug-entry-values', action='store_true',
- default=False,
- help='ignore the location statistics on locations with '
- 'entry values'
- )
- parser.add_argument('file_name', type=str, help='file to process')
- return parser.parse_args()
-
-
-def Main():
- parser = argparse.ArgumentParser()
- results = parse_program_args(parser)
-
- if len(sys.argv) < 2:
- print ('error: Too few arguments.')
- parser.print_help()
- sys.exit(1)
-
- if results.only_variables and results.only_formal_parameters:
- print ('error: Please use just one only* option.')
- parser.print_help()
- sys.exit(1)
-
+# Parse the JSON representing the debug statistics, and create an
+# LocationStats object.
----------------
an -> a
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71868/new/
https://reviews.llvm.org/D71868
More information about the llvm-commits
mailing list