misc: Added line wrapping functionality for Sim-Object desc

Descriptions were previously printed on one line, unless explicitly broken
when writing the description of the Sim-Object. In this commit, line
wrapping is enabled when printing these descriptions. Developers, when
writing the Sim-Object descriptions, may now over multiple lines with
triple double-quotes and still have the description output correctly when
viewing the Sim-Objects within the CLI.

E.g.: X86System previously had the following load_addr_mask component which
was output as:

load_addr_mask
            default: 18446744073709551615
               desc: Address to mask loading binaries with, if 0, system \
auto-calculates the mask to be the most restrictive, otherwise it obeys a \
custom mask.

This was defined by the developer via:

load_addr_mask = Param.UInt64(0xffffffffffffffff,
            "Address to mask loading binaries with, if 0, system "
            "auto-calculates the mask to be the most restrictive, "
            "otherwise it obeys a custom mask.")

This is now displayed as:

load_addr_mask
            default: 18446744073709551615
               desc: Address to mask loading binaries with, if 0,
                     system auto-calculates the mask to be the most
                     restrictive, otherwise it obeys a custom mask.

JiraID: Gem5-57
Built: Linux (GCC)
Tested: Ran quick tests for X86, ARM, and RISC-V
Change-Id: If012304e50af60f6ba10c1fa2b44da8bac1c09cf
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21179
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
This commit is contained in:
Bobby R. Bruce
2019-09-24 14:28:29 -07:00
parent a2286fe344
commit 772ca27a97
3 changed files with 142 additions and 4 deletions

View File

@@ -227,6 +227,7 @@ def main(*args):
from . import trace
from .util import inform, fatal, panic, isInteractive
from m5.util.terminal_formatter import TerminalFormatter
if len(args) == 0:
options, arguments = parse_options()
@@ -306,18 +307,21 @@ def main(*args):
print("SimObjects:")
objects = list(SimObject.allClasses.keys())
objects.sort()
terminal_formatter = TerminalFormatter()
for name in objects:
obj = SimObject.allClasses[name]
print(" %s" % obj)
print(terminal_formatter.format_output(str(obj), indent=4))
params = list(obj._params.keys())
params.sort()
for pname in params:
param = obj._params[pname]
default = getattr(param, 'default', '')
print(" %s" % pname)
print(terminal_formatter.format_output(pname, indent=8))
if default:
print(" default: %s" % default)
print(" desc: %s" % param.desc)
print(terminal_formatter.format_output(
str(default), label="default: ", indent=21))
print(terminal_formatter.format_output(
param.desc, label="desc: ", indent=21))
print()
print()