STREAMS/UX for the HP 9000 Reference Manual

188
Debugging STREAMS/UX Modules and Drivers
Using adb
Now, edit filename, and search for all instances of the register or stack frame
location of interest. Any instruction which would modify the contents of the
register could potentially overwrite the information you are trying to get.
Below are some examples of modifying instructions. Note that in all cases
the register being modified, also known as the target register, is the last
register in the instruction.
ldw 10(r3),r4 will overwrite r4
ldhs 4(r3),rp will overwrite rp
ldo -1(r20),r22 will overwrite r22
ldwx r31(arg3),r21 will overwrite r21
or r3,r0,arg0 will overwrite arg0
extrs ret1,1F,10,r21 will overwrite r21
zdep r20,1A,1B,r31 will overwrite r31
sub r31,arg1,r31 will overwrite r31
sh3add arg1,r0,r31 will overwrite r31
stw r19,-38(sp) will overwrite memory location sp - 0x38
Sometimes an instruction which modifies the register of interest can appear
to occur between the beginning of the procedure and the call to the next
procedure in the stack because of how the assembly code is laid out.
However, the modifying instruction actually would not have been executed
because it was part of a conditional code path that was not taken. For
example, this C code from ioctl():
if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
u.u_error = EBADF;
return;
}
compiles into this assembly:
ioctl+60: ldws 0(r8),r13
ioctl+64: extru r13,1F,2,r14
ioctl+68: comibf,=,n 0,r14,ioctl+80
ioctl+6C: ldw 68(r3),r19
ioctl+70: ldo 9(r0),r21
ioctl+74: sth r21,312(r19)
ioctl+78: b ioctl+7F0
ioctl+7C: ldw -1D4(sp),rp
ioctl+80: ldws 4(r5),r7
If the if statement is false, the branch at ioctl+68 is taken, and instruction
ioctl+6C is never executed because the ,n in ioctl+68 causes the instruction
in the branch delay slot to be nullified, or not executed. ioctl+70 through
ioctl+7c are never executed because the branch at ioctl+68 branches past
these instructions to ioctl+80. If ioctl+6c through ioctl+7C had been
executed, r19, r21, and rp would have been modified.