Jelle Sels | 83f141e | 2022-08-01 15:17:40 +0000 | [diff] [blame] | 1 | # !/usr/bin/env python |
| 2 | ############################################################################## |
| 3 | # Copyright (c) 2022, ARM Limited and Contributors. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | ############################################################################## |
| 7 | import iris.debug as debug |
| 8 | import iris.iris as iris |
| 9 | import argparse |
| 10 | import textwrap |
| 11 | |
| 12 | def arg_parser(): |
| 13 | parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, |
| 14 | description = textwrap.dedent('''\ |
| 15 | Tool to change the plugin parameters of the FVP coverage-plugin. |
| 16 | |
| 17 | To be able to connect to the model, the model needs to have the iris-servier active. |
| 18 | The -p of the model can be used to show the port to connect to. |
| 19 | When starting a model with the iris-server, the model will wait until a debugger |
| 20 | is connect and ran. We can start the model automatically by using the -R option. |
| 21 | Example: |
| 22 | MODEL --iris-server -R -p |
| 23 | ''')) |
| 24 | parser.add_argument( |
| 25 | "-p", |
| 26 | "--port", |
| 27 | type=int, |
| 28 | default=7100, |
| 29 | help="set the port of the running model" |
| 30 | ) |
| 31 | parser.add_argument( |
| 32 | "-m", |
| 33 | "--mode", |
| 34 | type=lambda x: int(x,0), |
| 35 | default=-1, |
| 36 | help="set the mode to trace as a hex number." |
| 37 | ) |
| 38 | parser.add_argument( |
| 39 | "-f", |
| 40 | "--file", |
| 41 | default="", |
| 42 | help="set the file-prefix of the trace files" |
| 43 | ) |
| 44 | parser.add_argument( |
| 45 | "-s", |
| 46 | "--save", |
| 47 | action='store_true', |
| 48 | help="Save the current trace" |
| 49 | ) |
| 50 | return parser.parse_args() |
| 51 | |
| 52 | def main(): |
| 53 | parsed_args = arg_parser() |
| 54 | model = debug.NetworkModel("localhost", parsed_args.port) |
| 55 | |
| 56 | components = model.get_targets() |
| 57 | for component in components: |
| 58 | if "coverage_trace" in component.instName: |
| 59 | trace_component = component |
| 60 | |
| 61 | if trace_component: |
| 62 | if parsed_args.mode != -1: |
| 63 | trace_component.parameters['trace-mode'] = parsed_args.mode |
| 64 | print("Changed trace mode to " + hex(parsed_args.mode)) |
| 65 | elif parsed_args.file != "": |
| 66 | trace_component.parameters['trace-file-prefix'] = parsed_args.file |
| 67 | print("Changed trace prefix to" + parsed_args.file) |
| 68 | elif parsed_args.save: |
| 69 | trace_component.parameters['trace-file-prefix'] = trace_component.parameters['trace-file-prefix'] |
| 70 | print("Saved trace files to " + trace_component.parameters['trace-file-prefix']) |
| 71 | else: |
| 72 | print("Nothing to do") |
| 73 | else: |
| 74 | print("Could not find plugin component") |
| 75 | |
| 76 | |
| 77 | if __name__ == "__main__": |
| 78 | main() |