HP (Hewlett-Packard) IA-64 Manuale Utente

Pagina di 110
1-8
Getting Started: A Ski Tutorial
Copyright © 2000 Hewlett-Packard Co.
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.5
Viewing 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
” (“
d
ata
f
or-
wards”) and “
db
” (“
d
ata
b
ackwards”) commands without operands to move forwards and backwards in the Data Window,
one screenful each time.
1.2.6
Looking 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 (“
p
rogram
j
ump”) 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
” (“
p
rogram
f
orwards”) and “
pb
(“
p
rogram
b
ackwards”) 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?
Figure 1-11. The Data Window Showing
argv
 and
envp
 Strings in ASCII