STREAMS/UX for the HP 9000 Reference Manual

186
Debugging STREAMS/UX Modules and Drivers
Using adb
Obtaining Procedure Argument Values
It is often useful in debugging a problem to know what parameter values a
procedure in the stack trace was called with. For example, in the following
stack trace it would be useful to know the arguments flushq() was called
with.
panic+30: addil -1000,dp
trap+0xADC: b trap+1004
$call_trap+20: rsm 1,r0
flushq+60: ldbs 0xD(r21),r22
q_free+1C: ldw -0xA4(sp),r31
Obtaining the First Four Arguments
Arguments 0 through 3 are passed from the calling procedure to the called
procedure by loading the values into registers 23 - 26. These registers are
also known as arg0, arg1, arg2, and arg3. For example, here is bmap()
preparing to call realloccg() by moving realloccg()'s arguments from the
registers they are in to the argument registers by doing an or on the source
registers with r0, which is always zero:
bmap+16C: or r10,r0,arg1
bmap+170: or ret0,r0,arg2
bmap+174: or r8,r0,arg3
bmap+178: or r4,r0,arg0
bmap+17C:
Next, here is flushq() preparing to call rmvq() by loading arg0 and arg1 from
its stack frame. Note that arg1 gets loaded in the delay slot of the branch
instruction bl. See the Assembly Language Reference Manual or the
PA-RISC 1.1 Architecture and Instruction Set Reference Manual for more
information on branch delay slots.
flushq+0xE0: ldw -64(sp),arg0
flushq+0xE4: bl rmvq,rp
flushq+0xE8: ldw -34(sp),arg1
After allocating its stack frame and saving any callee save registers, the
called procedure will usually load the argument registers into some of the
callee save registers that it just saved the values of. For example, here is
realloccg() saving the contents of the callee save registers r3 - r10 and
loading arg0 - arg3 into some callee save registers.