Previous - Up - Next

5   Command-line Interface: Basics

The Simics command-line uses GNU Readline to provide command-line editing and a command history buffer.

Let us go through a list of handy commands for Simics common usage:

Simulation
At the Simics prompt, you can run the simulation with the continue (c) command, followed by the number of steps you want to run. If no argument is provided, the simulation will run until control-C is pressed in the Simics console.

You can also use stepi (si) to make the simulation progress step by step. You can use the step-cycle (sc) command to make the simulation progress cycle by cycle. Note that as long as you do not use timing models, si and sc are equivalent. For more information, see chapter 17.

Simulation State
All processors support the pregs command to show the state of the main registers. The argument -all will allow you to inspect all the registers instead of the usual working set.

If the processor has floating-point registers, pfregs can be used to print them out. By default, the pregs command (and other commands dependent on the CPU) uses the current CPU scheduled by the simulation. You can change the current selected CPU by using the pselect command. This won't affect the simulation scheduling.

You can inspect and change the contents of a register by using the read/write-reg commands. Using % is equivalent to the read-reg command (i.e., %pc, %eax, ...). You can inspect and change the contents of the memory by using the commands get, x and set.

To get statistics concerning the current CPU, you can use the ptime and pstats commands.

Scripts
Simics can execute Python commands directly at the prompt; they just need to be prefixed by the symbol @. You can also evaluate Python expressions in the middle of a command by placing them between backquotes:

    --- this is Python's print()
simics> @print conf.cpu0.name
cpu0
    --- this is CLI's echo
simics> echo `conf.cpu0.name`
cpu0
simics>


Note: '@' will only be recognized as starting a python command if it is the first character on the command-line. It will be treated normally otherwise.

Simics can load both Simics scripts (a file containing a list of acceptable commands for the Simics frontend) or Python script with the commands run-command-file and run-python-file. You can read more about Simics scripting in chapter 8.

Modules
Simics usually handles modules automatically when loading a configuration. You may however want to load a specific module by yourself with the load-module command.

The modules currently loaded are available through the list-modules command. If a module fails to be loaded, it will be listed by the list-failed-modules command, along with an explanation of the problem. You can use the -v argument to get the exact error message preventing the module from loading.

Command-Line Interface
You can ask Simics to run command every time it returns at the prompt, using the display command. For example:

simics> display ptime
display 1: ptime
simics> si
[cpu0] v:0xfffffffff0000024 p:0x000007fff0000024  nop
processor                 steps             cycles    time [s]
cpu0                          1                  1         0.0
simics> c 100
[cpu0] v:0x000007fff0102190 p:0x000007fff0102190  sub %o2, 8, %o2
processor                 steps             cycles    time [s]
cpu0                        101                101         0.0
simics> undisplay 1
simics>

To stop the command from being run every time, use undisplay number where number is the number that was returned by display for this specific command (in the example, 1).

The print command allows you to print out a value in different ways (binary, hexadecimal, etc.). You can control the way the command-line handles numbers with the following commands: output-radix allows you to choose a default base for printing numbers; digit-grouping can be used to group digits in a number in a more readable way.

The CLI also supports the following Unix shell-like commands: cd, date, dirs, echo, ls, popd, pushd, pwd. All of them are performed of the host machine, not on the simulated machine.

Previous - Up - Next