HP IA-64, Ski Simulator manual Initialization File, Labels and Control Flow in Command Files

Page 85

Ski IA-64 Simulator Reference Manual 1.0L

9

Command Files

 

 

 

 

The dot (“ .”) command temporarily redirects command input to the simulator so that input is taken from the file provided as an argument to the command. Into this file (a “command file”), you put commands as if you had typed them from the keyboard. Several commands are specifically applicable to command files and are described below. Command files may be nested; i.e., one command file may invoke another. The maximum nesting depth is operating-system-dependent.

Some syntax rules that apply to keyboard input don’t make sense or would be cumbersome in command files. Most nota- bly, in ski, a shortcut for re-executing the previous command is to hit the enter/return key on an empty line. This rule is removed in command files, so you are free to put in blank lines for readability. You can also indent lines as necessary.

The ability to assign values to registers and memory and the flow control features provide the simulator with a powerful Church-Turing-complete command language; i.e., tasks which can be accomplished in any programming language, sub- ject to memory constraints, can be accomplished in the command language of the simulator. Command files are particu- larly appropriate for initializing the state of the simulator and for implementing complex facilities on top of Ski’s native commands. For example, you can write command files to setup the machine state just before an I/O interrupt, to create sophisticated breakpointing, and to take complex performance measurements.

9.1Initialization File

If you start Ski with a -ioption followed by a filename, the named file will be executed as a command file before the first prompt (see Section 2.5.1, “Command Line Flags”). This feature is particularly important for bski, because without a command file to guide it, bski will only run your program and then quit. If you want to do anything else, you need a command file. When you combine the -ioption with Ski’s ability to load a program on the command line, you can create a powerful debugging environment. For example, this command line:

bski -i test.init -stats -icnt instruction_counts

combined with this test.init command file:

load ia_test 0x26c50

romload test.com etext test.map

uses the command file test.init to load an IA-64 Platform Support File named ia_test (filling in Ski’s symbol table for program-defined symbols), and then loads the IA-32 system-mode program test.com, putting it at the location corre- sponding to the symbol “ etext” in ia_test. The command file finishes and bski automatically executes a run com- mand followed by a quit command. To start the run, the ia_test program receives 0x26c50 as its argv[1] value. This corresponds to the value of the symbol “ etext” and tells ia_test where test.com was loaded. The IA-64 program completes its initialization and transfers control to the IA-32 program, setting the psr.is bit appropriately. When the IA-32 program completes, bski prints out end-of-run performance statistics and writes an instruction frequency count to the file

instruction_counts.

9.2Labels and Control Flow in Command Files

Command files are useful as macro sequences of simple commands and, more interestingly, to create small programs that do useful things for you: create formatted displays of data structures, create complete breakpoints, and gather run-time statistics, for example. Two commands provide the ability to change the flow of control in a command file: goto and if.

9.2.1The goto Command and Labels

A label identifies a particular line in a command file. Labels are defined in Section 4.4.2.4, “Labels”. No other text can appear on a label line.

The goto command takes a label as an argument and searches the command file for a line with that label. Execution resumes at the first command after the label. There is no good reason to have a label appear more than once in a particular command file; if this condition occurs, only the first occurrence of the label will be noticed and all subsequent occurrences will be ignored. The goto command can only be executed in a command file. A goto may go forward or backward. An

Copyright © 2000 Hewlett-Packard Co.

Command Files 9-1

Image 85
Contents Copyright 2000 Hewlett-Packard Co Ski IA-64 Simulator Reference ManualTrademarks Printing HistoryPreface How to Use This ManualFont Conventions Syntax ConventionsItalic+ Table of Contents Ski IA-64 Simulator Reference Manual Vii Ski IA-64 Simulator Reference Manual Viii Table of Contents List of Figures Ski IA-64 Simulator Reference Manual 1.0L List of Tables Ski IA-64 Simulator Reference Manual 1.0L Xii List of Tables Getting Started a Ski Tutorial How to Run an IA-64 Application ProgramSki Simulator Starting xskiStarting xski From the Command Line Loading Your Program Exiting SkiLoading the hello Program Xski Data Window Inspecting DataChanging the Data Window Display Data Window Showing argv and envp Strings in Hexadecimal Looking at Code Viewing Data in Ascii12. Jumping the Program Window to the Beginning of main Viewing Source Code Mixed In with Assembly Code14. The Program Window Showing a Breakpoint at main Controlling Breakpoints15. The Breakpoint List Window Running a Program16. The Terminal Window After the hello Program is Run Single-stepping a Program18. The Main Window After Reaching the Breakpoint at main+10 Changing Registers and MemorySki IA-64 Simulator Reference Manual 1.0L 20. The xski Register Window After Changing the ip Register 21. The xski Data Window Widened to Show Ascii Next Steps Getting HelpCopyright 2000 Hewlett-Packard Co Introduction OverviewWhat You Need to Know to Use This Manual Defects and Defect ReportingSki Variations Using bski for Batch SimulationsX Window System, Motif-based xski Interface Starting Ski Command Line Flags1.1 Summary of Flags XSki FileQuitting Ski Summary of the Quit CommandQuit expression Ski’s Use of Windows Screen PresentationRegister Window Register Window in xski User Registers PaneFloating Point Registers Pane General Registers PaneIA-32 Registers Pane System Registers PaneRegister Window and ski Resizing Register Window Panes with xski1 IA-64 Instruction Display Program WindowSki IA-64 Simulator Reference Manual 1.0L 2 IA-32 Instruction Display Invalid Code and the Program Window Changing the Range of Locations Shown in the Program Window12. xski’s Program Window Showing Illegal Instructions Data WindowChanging the Range of Locations Shown in the Data Window Invalid Code and the Data Window Command/Main WindowXski Main Window 16. xski’s Main Command Window Ski Command WindowOther Windows 17. ski’s Command Window at Bottom18. xski’s Symbol List Window Copyright 2000 Hewlett-Packard Co Command Entry Command LanguageCommand Arguments Command Sequences, Repetition, and AbbreviationNumeric Arguments Argument SpecificationNumbers and Counts ExpressionsXski Evaluating Expressions Ski Simulator Arithmetic and Logic OperatorsProgram-Defined Symbols Symbolic ArgumentsAddresses Internal Variables Resolving Ambiguous Symbols and NumbersLabels FilenamesSki IA-64 Simulator Reference Manual 1.0L Register Window Commands Screen Manipulation CommandsSummary of Register Window Commands Xski Register Window CommandsSummary of Program Window Commands Program Window CommandsXski’s Program Window Showing IA-64 Assembly Language Code Pd startingaddress endingaddress filename Xski’s Assembly Language Dump WindowSummary of Data Window Commands Data Window CommandsDj address Df countDd startingaddress endingaddress filename Xski Showing Data in Raw Hexadecimal and AsciiApplication-Mode and System-Mode Simulation Program SimulationSki Support for Application-Mode Programs Ski Support for System-Mode ProgramsSystem-Mode IA-64 Programs Summary of TLB Display CommandsSystem-Mode IA-32 Programs System-Mode TLB SimulationHow to Load a Program Misaligned Data Access TrapProgram Loading Load filename args+ Summary of Program Loading CommandsAdding Information after Loading Creating the argc, argv, and envp ParametersProgram Execution Summary of Program Execution CommandsSki IA-64 Simulator Reference Manual 1.0L Program Simulation Interruptions Linux and MS-DOS ABI EmulationLinux Application Environment Linux System Calls Accepted but Ignored by Ski Linux System Calls Supported by SkiProgram I/O MS-DOS Application EnvironmentMS-DOS System Calls in Hexadecimal Supported by Ski Copyright 2000 Hewlett-Packard Co Summary of Assignment Commands Changing Registers and Memory with Assignment CommandsExamples of Assignment Commands DebuggingOriginal Program Loaded in ski Allocation Bit-encoded RegistersSetting Program Breakpoints Summary of The eval CommandEvaluating Formulas and Formatting Data Program BreakpointsListing Program Breakpoints Deleting Program BreakpointsUnexpected Breakpoints Summary of Program Breakpoint CommandsBs address Summary of Data Breakpoint Commands Setting Data BreakpointsData Breakpoints Deleting Data BreakpointsSummary of Save and Restore Commands Symbol Table CommandsSummary of Symbol Commands Dumping Registers and Memory to a FileIsyms filename Symlist Output from xskiSki IA-64 Simulator Reference Manual 1.0L Debugging Labels and Control Flow in Command Files Command FilesGoto Command and Labels Initialization FileAn Example Command File Comments in Command FilesIf Command filename Summary of Command File Commands# comment LabelSki IA-64 Simulator Reference Manual 1.0L Command Files =s address stringwithoutspaces Command ReferenceDbd breakpointnumber Dbs address length rwrwEval expressionwithoutspaces+ Help commandnameRest filename Quit returnvalueforshellStep until expressionwithoutspaces Ski IA-64 Simulator Reference Manual 1.0L IA-64 Registers Register NamesRegister Names Copyright 2000 Hewlett-Packard Co Register Names B-3 Ski IA-64 Simulator Reference Manual 1.0L Copyright 2000 Hewlett-Packard Co Register Names B-5 Ski IA-64 Simulator Reference Manual 1.0L Register Names Internal Variables Internal Variable NamesCopyright 2000 Hewlett-Packard Co All breakpoints deleted Simulator Status and Error MessagesSimulator Status and Error Messages Expression Help Unknown command %s Missing ELF header Not an IA-64 file Stopping at %s due to unimplemented instruction Usage %s options file args