HP Ski Simulator, IA-64 manual Viewing Data in Ascii, Looking at Code

Page 20

Ski IA-64 Simulator Reference Manual 1.0L

Another shortcut is the * pointer-dereference operator for indirect addressing. Type “ dj 0” to jump the Data Window to location 0. Then type “ dj *(r12+18)”. Ski will take the contents of r12 (9ffffffffff780, remember?), add 18 (hex) and use that as the address of the operand. The * operator fetches the contents of *(r12+18) and uses that value, 9ffffffffff938, as the address to jump to. Compare the Data Window display resulting from “ dj r12+18” with the display resulting from “ dj *(r12+18)”.

You will use the * operator a lot in debugging C programs because it performs the same function as C’s * operator: it

dereferences pointers. Unlike C’s *, however, Ski’s * operator is not type-specific: you can use it in any context where any kind of address is needed and you can use it to dereference registers like r12, memory locations, or anything that has a value. (This doesn’t always make sense, of course. For example, dereferencing a floating-point register is rarely useful because floating-point registers don’t hold pointers.)

1.2.5Viewing Data in ASCII

Hexadecimal is no fun. To expose the ASCII translation, use your window manager’s standard mechanism to make the Data Window wider. (How you do this depends on the window manager you’re using, but generally this can be accom- plished by grabbing the edge of the Data Window with your mouse cursor and dragging it to the right.) You should see approximately Figure 1-11.Now click on the Main Window, to make it the active window again. Try the “ df” (“ data for- wards”) and “ db” (“ data backwards”) commands without operands to move forwards and backwards in the Data Window, one screenful each time.

Figure 1-11. The Data Window Showing argv and envp Strings in ASCII

1.2.6Looking at Code

Initially, the Program Window shows the beginning of the program. For C programs, this isn’t the first line of user code, it’s the start-up routine from crt1.o that provides an interface between the operating system environment and the ANSI C environment. This routine is named “ _start” and the ELF header in hello names it as the start of the program. That’s what Ski shows in the Program Window by default: the start of the program according to ELF.

You use the “ pj” command (“ program jump”) to jump the program window elsewhere. For example, jump it to the first instruction in the user’s main(), as shown in Figure 1-12.The Program Window now looks like Figure 1-13.You can move the Program Window forwards and backwards through program code with the “ pf” (“ program forwards”) and “ pb” (“ program backwards”) commands, respectively. Try these commands, and then try using “ pj” without an operand: note how it jumps you back and forth between the previous and current locations. The “ dj” command does the same thing in the Data Window. Handy, eh?

1-8

Getting Started: A Ski Tutorial

Copyright © 2000 Hewlett-Packard Co.

Image 20
Contents Ski IA-64 Simulator Reference Manual Copyright 2000 Hewlett-Packard CoPrinting History TrademarksHow to Use This Manual PrefaceFont 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 How to Run an IA-64 Application Program Getting Started a Ski TutorialSki Simulator Starting xskiStarting xski From the Command Line Exiting Ski Loading Your ProgramLoading the hello Program Inspecting Data Xski Data WindowChanging the Data Window Display Data Window Showing argv and envp Strings in Hexadecimal Viewing Data in Ascii Looking at CodeViewing Source Code Mixed In with Assembly Code 12. Jumping the Program Window to the Beginning of mainControlling Breakpoints 14. The Program Window Showing a Breakpoint at mainRunning a Program 15. The Breakpoint List WindowSingle-stepping a Program 16. The Terminal Window After the hello Program is RunChanging Registers and Memory 18. The Main Window After Reaching the Breakpoint at main+10Ski 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 Getting Help Next StepsCopyright 2000 Hewlett-Packard Co Overview IntroductionWhat You Need to Know to Use This Manual Defects and Defect ReportingUsing bski for Batch Simulations Ski VariationsX Window System, Motif-based xski Interface Command Line Flags Starting SkiXSki File 1.1 Summary of FlagsQuit expression Summary of the Quit CommandQuitting Ski Register Window Screen PresentationSki’s Use of Windows User Registers Pane Register Window in xskiGeneral Registers Pane Floating Point Registers PaneSystem Registers Pane IA-32 Registers PaneResizing Register Window Panes with xski Register Window and skiProgram Window 1 IA-64 Instruction DisplaySki IA-64 Simulator Reference Manual 1.0L 2 IA-32 Instruction Display Changing the Range of Locations Shown in the Program Window Invalid Code and the Program WindowData Window 12. xski’s Program Window Showing Illegal InstructionsChanging the Range of Locations Shown in the Data Window Xski Main Window Command/Main WindowInvalid Code and the Data Window Ski Command Window 16. xski’s Main Command Window17. ski’s Command Window at Bottom Other Windows18. xski’s Symbol List Window Copyright 2000 Hewlett-Packard Co Command Language Command EntryCommand Arguments Command Sequences, Repetition, and AbbreviationArgument Specification Numeric ArgumentsNumbers and Counts ExpressionsSki Simulator Arithmetic and Logic Operators Xski Evaluating ExpressionsAddresses Symbolic ArgumentsProgram-Defined Symbols Resolving Ambiguous Symbols and Numbers Internal VariablesLabels FilenamesSki IA-64 Simulator Reference Manual 1.0L Screen Manipulation Commands Register Window CommandsSummary of Register Window Commands Xski Register Window CommandsProgram Window Commands Summary of Program Window CommandsXski’s Program Window Showing IA-64 Assembly Language Code Xski’s Assembly Language Dump Window Pd startingaddress endingaddress filenameData Window Commands Summary of Data Window CommandsDj address Df countXski Showing Data in Raw Hexadecimal and Ascii Dd startingaddress endingaddress filenameProgram Simulation Application-Mode and System-Mode SimulationSki Support for Application-Mode Programs Ski Support for System-Mode ProgramsSummary of TLB Display Commands System-Mode IA-64 ProgramsSystem-Mode IA-32 Programs System-Mode TLB SimulationProgram Loading Misaligned Data Access TrapHow to Load a Program Summary of Program Loading Commands Load filename args+Adding Information after Loading Creating the argc, argv, and envp ParametersSummary of Program Execution Commands Program ExecutionSki IA-64 Simulator Reference Manual 1.0L Program Simulation Linux Application Environment Linux and MS-DOS ABI EmulationInterruptions Linux System Calls Supported by Ski Linux System Calls Accepted but Ignored by SkiMS-DOS System Calls in Hexadecimal Supported by Ski MS-DOS Application EnvironmentProgram I/O Copyright 2000 Hewlett-Packard Co Changing Registers and Memory with Assignment Commands Summary of Assignment CommandsExamples of Assignment Commands DebuggingOriginal Program Loaded in ski Bit-encoded Registers AllocationSummary of The eval Command Setting Program BreakpointsEvaluating Formulas and Formatting Data Program BreakpointsDeleting Program Breakpoints Listing Program BreakpointsBs address Summary of Program Breakpoint CommandsUnexpected Breakpoints Setting Data Breakpoints Summary of Data Breakpoint CommandsData Breakpoints Deleting Data BreakpointsSymbol Table Commands Summary of Save and Restore CommandsSummary of Symbol Commands Dumping Registers and Memory to a FileSymlist Output from xski Isyms filenameSki IA-64 Simulator Reference Manual 1.0L Debugging Command Files Labels and Control Flow in Command FilesGoto Command and Labels Initialization FileIf Command Comments in Command FilesAn Example Command File Summary of Command File Commands filename# comment LabelSki IA-64 Simulator Reference Manual 1.0L Command Files Command Reference =s address stringwithoutspacesDbs address length rwrw Dbd breakpointnumberHelp commandname Eval expressionwithoutspaces+Quit returnvalueforshell Rest filenameStep until expressionwithoutspaces Ski IA-64 Simulator Reference Manual 1.0L Register Names IA-64 RegistersRegister 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 Variable Names Internal VariablesCopyright 2000 Hewlett-Packard Co Simulator Status and Error Messages All breakpoints deletedSimulator 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