• No results found

Command-Line Interface

In document Simics User Guide for Linux (Page 46-49)

Simics command-line interface uses GNU Readline, which means you can use the usual readline control sequences for history browsing and command-line editing.

You can also tell the prompt to run commands every time a new command is issued with display command. To stop the command from being run, use undisplay number where number is the number written before the command output.

The print command allows you to print out a value in different ways (binary, hex-adecimal, etc.).

The CLI also supports the following Unix shell-like commands: cd, date, dirs, echo, ls, popd, pushd, pwd.

The Command Line Interface

The Simics Command Line Interface (CLI) is an advanced text based user interface with builtin help system, context sensitive tab-completion, and scripting support (us-ing Python).

8.1 Invoking Commands

Commands are invoked by typing them at the command line followed by their argu-ments. The synopsis part of a command documentation (see the Simics Reference Manual) explains how to call a command. Here are two examples:

SYNOPSIS

command1-x -y -small [cpu-name] address (size|name) SYNOPSIS

command2files ...

Arguments starting with a hyphen are flags and are always optional for a command.

Flags can be more than one character long so it is not possible to write-xyfor-x -y.

The order of the flags is not significant and they can appear anywhere in the argument list.

Arguments enclosed within square brackets are optional, thus it is not necessary to specify cpu-name in the example above. address,on the other hand, is required. The last argument to command1 is either a size or a name, but not both. Such arguments are called polyvalues and can be of different types. Size and name are called sub-arguments.

If an argument is followed by tree dots as the file argument in command2 it indicates that the argument can be repeated one or more times.

The type of the arguments, e.g., if they are integers or strings, should be evident from their names. For example size should be an integer and name a string if not documented otherwise.

Integers are written as a sequence of digits beginning with an optional minus charac-ter for negative numbers. Hexadecimal numbers can be written by prefixing them with

8.1. Invoking Commands

0x, octal numbers with0o, and binary numbers with with0b. Strings are written as is or within double quotes if they contain spaces or begin with a non-letter.

Here are some possible invocations of the commands above:

simics> command1 -small cpu0 0x7fffc000 14 -y simics> command1 0x7fffc000 foo

simics> command1 -x "Pentium 4" 0x7fffc000 -8 simics> command2 "/tmp/txt" "../bootdisk" floppy

In the first examplecpu-nameis passed as the stringcpu0andsizeas the inte-ger 14. In the second invocation cpu-namehas been omitted andnameis set to the stringfoo. The third example illustrated the use of a string containing a space. In all command1examples the address is set to the hexadecimal value 0x7fffc000. command2 takes a list of at least 1 string.

A few commonly used commands have aliases. Thus it is possible to write c for continueand si for step-instruction for example. Command aliases are documented with their corresponding command in the Simics Reference Manual.

8.1.1 How are Arguments Resolved?

Simics tries to match the arguments in the order that they appear in the synopsis. If the type of the next argument is the same as what is typed at the command line the argument will match. If there is a mismatch and the argument is optional the argument will be skipped and the next will be matched etc. If not optional, the interpreter will fail and explain what is expected. For polyvalues, the argument will be matched if one of its sub-arguments match.

There are situations however when this method is not sufficient. For example, when two arguments both have the same type and are optional, there is no way to know which argument to match if only one is given. This is resolved by naming the arguments: arg-name=value. For example command1 in the example above can be invoked like this:

simics> command1 size=32 -y address = 0xf000 -small cpu-name=cpu0

Thus there is no ambiguity in what is meant and in fact this is the only way to specify a polyvalue with sub-arguments of the same type. Note also that the named argument can be placed in any order. As stated in the previous section this holds for flags as well.

8.1.2 Namespace Commands

Configuration objects (such as devices or CPUs) that define user commands usually place them in a separate namespace. The namespace is the name of the object.

Namespace commands are invoked by typing the name of the object, followed by a dot and the command name: object.command, e.g.,

All namespace commands are listed in the Simics Reference Manual.

8.1.3 Expressions

The CLI allows expressions to be evaluated, for example:

print -x 2*(0x3e + %g7) + %pc

The precedence order of the operators is as follows (highest first):

% get register value

$ read Simics variable

˜ bitwise not

pow power of

*, / multiplication, division +, - addition, subtraction

<<, >> left, right shift

&, |, ˆ bitwise and, or, xor

Parentheses can be used to override the priorities. Commands which return values can also be used in expressions if they are enclosed within parentheses:

print -x (cpu0.read-reg g7)

Values can be saved in variables for later use. You set a variable by simply giving an assignment command such as var = 15. The value of the variable can be read later with

$var.

8.1.4 Interrupting Commands

Any command which causes the simulation to advance (i.e run) can be interrupted by typing control-C. The simulator will gracefully stop and prompt for a new command. If Simics hangs for some reason, possibly due to some internal error, you can usually force a return to the command line by pressing control-C twice or more times in a row.

Note: Pressing control-C several times may damage some internal state in the simulator so should be used sparingly.

In document Simics User Guide for Linux (Page 46-49)

Related documents