STREAMS/UX for the HP 9000 Reference Manual
189
Debugging STREAMS/UX Modules and Drivers
Using adb
Suppose you have determined that the procedure whose arguments you are
interested in does not modify the registers it loaded the arguments into
before the next procedure call in your stack. You can look at the appropriate
location in the stack frame of the next procedure call in the stack to get the
value. For example, if a routine whose registers you are interested in has
called panic, you look at the beginning of panic's assembly to see which
callee save registers it saves in its stack.
panic: stw rp,-14(sp)
panic+4: stwm r3,40(sp)
panic+8: stw r4,-3C(sp)
panic+0xC: stw r5,-38(sp)
panic+10: stw r6,-34(sp)
Obtain panic's sp by manual stack back-tracing, and then r3 is at sp - 0x40,
r4 at sp - 0x3C, and so on.
Obtaining Arguments 5 through N
Only the first four arguments to a procedure are passed via registers. Any
remaining arguments are pushed onto the calling procedure's stack frame,
where the called procedure will retrieve them. If you have the calling
procedure's sp you can use adb to get the values of the arguments. For
example, symlink() calls lookuppn(), which has six arguments. Here is the
assembly code which sets up the six arguments:
symlink+40: stw r4,-34(sp)
symlink+44: stw r3,-38(sp)
symlink+48: ldo -3C(sp),arg2
symlink+4C: ldo -9C(sp),arg0
symlink+50: or r0,r0,arg1
symlink+54: bl rename+34,rp (lookuppn)
symlink+58: or r0,r0,arg3
If you want to get the fifth argument, you see that symlink() places it in its
stack frame at sp - 0x34. Argument 5 is at -0x34 because the procedure
calling convention specifies that arguments get placed in the stack frame in
reverse order, so arg6 is at sp - 0x38, just above arg5, and if lookuppn() had
seven arguments, arg7 would be placed at sp - 0x3C. If you know
symlink()'s sp from doing a manual stack back-trace, you can use it to get the
value of argument 5:
7FFE6B98-0x34/X
7FFE6B64: 2D7298 # adb's response