Search code examples
simics

Executing Simics Commands via Shell Script


I want to use simics via a shell script

I mean what I am actually wanting to see if there is a way to run simics like this:

simics file.ext

where file.ext is a file which has the commands that i can execute

Or if I could just write a bash shell script to do it

I have a proj. in my mind but i need to execute shell commands in the target system just like we can do it in Docker
I mean I f you have used docker there is this cmd:
docker exec <container name> <command> where I can execute a command in the target system without actually entering into the system console
I want to do a similar thing using simics

Doing an ssh into the target system is one way but otherwise is there anything else??

Clarifying Comment that Deserves to be in the Question

i guess i did not frame the question clear enough. Let me try this again. Imagine I send a command lets say "ls" to the target OS and now depending o the the answer I receive from the target OS lets say it having N number of files i want to determine the next step , dynamically in the host OS . Is there a way to do this?


Solution

  • The answer to the second question is also yes. Use scripting in Simics to send inputs to the target and retrieve the output, and then make selections about what to do.

    Specifically, you can use the "record" function of the serial console to retrieve a chunk of output from the console, and then you can parse it using either CLI or Python.

    The logic is typically:

    1. Send input to target
    2. Wait for newline or something to note that the target OS took the command
    3. Do record-start on the console object
    4. Wait for end of the output using some appropriate pattern
    5. Do $x = CONSOLEOBJECT.record-stop
    6. Parse out the contents of the CLI variable

    Like in:

    $con = ...
    $con.input "cmd\n"
    bp.console_string.wait-for $con "\n"  ## Wait for newline to echo
    $con.record-start
    bp.console_string.wait-for $con "end of interesting output"
    $output = $con.record-stop
    ## look at $output