home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dumptool.zip / SAMPLRPN.ZIP / logxcpt.rpn next >
Text File  |  1997-04-29  |  3KB  |  106 lines

  1. ;log any user exception before the excption handlers have a go
  2. ;
  3. major=252
  4. hmte=6 ;os2krnl
  5. vars=4
  6. ;
  7. minor=0x1000
  8. opcode=0x55         ;push
  9. object=0xf          ;GA Merlin 9.023 ALLSTRICT Kernel
  10. offset=0x46daf      ;   _XCPTBuildR3DispatcherStack segment:offset
  11. ;
  12. ;
  13. push w,8            ;log 2 dwords
  14. push ss
  15. push esp
  16. push w,4            
  17. add                 ;bump past the return eip
  18. log  mrs            ;log the exception number and trap number
  19. ;
  20. ;    
  21. ; get current TCB address via the SAS
  22. ; requires 2 variables to be defined for temporary use.
  23. ;
  24. ; Actually there is a better way to get the current TCB address. 
  25. ; Pete Guy pointed this out. The variable CurrTCB is always at the
  26. ; same relative offset to selector 30. CurrTCB contains the offset 
  27. ; (fff0) from sel 30 to the aliased current TCB.  I'll change the
  28. ; following code when I get time!
  29. ;
  30. push  w,0x70;SAS selector (used later)
  31. push  w,0x70;SAS selector
  32. push  w,0x0e;offset to tasking section offset 
  33. push  wis
  34. move  v,0   ;save tasking section offset
  35. push  w,0xa ;offset to slot no address
  36. add         ;TOS=sel:off-> @tasknumber
  37. push  sis   ;(using first push w,0x70)
  38. cnvrt sxd   ;TOS->tasknumber
  39. push  fif   ;fetch slot number
  40. push  w,4   ;scale by 4
  41. mul         ;convert to index into tcb ptrs table
  42. move  v,1   ;save offset into TCB table
  43. pop   n,1
  44. push  w,0x70
  45. push  v,0   ;offset into tasking section
  46. push  w,0x6 ;offset to @TCB ptrs addr
  47. add
  48. push  sis 
  49. cnvrt sxd   ;address of @tcb table on stack 
  50. push  fif   ;addres of tcb table on TOS
  51. push  v,1   ;offset into table for current thread
  52. add
  53. push  fif   ;current tcb address on stack
  54. move  v,0   ;save tcb address
  55. ; have now arived at current TCB address
  56. ; save the stack frame address in v3
  57. push w,0x3c  ;tcb offset to stack frame address
  58. add          ;tos points to stack frame address
  59. push fif     ;tos=stack frame addr
  60. move v,3     ;save stack frame address
  61. ;
  62. ; save the CRI address in v1. Log the cri
  63. push  w,0x58 ;cri size
  64. push v,0     ;tcb address
  65. push  w,0x38;tcb offset to cri pointer
  66. add
  67. push  fif   ;cri ptr on tos
  68. move  v,1   ;saved cri address
  69. log   mrf    ;cri logged
  70. ;
  71. ; save client stake frame size in v2
  72. push  v,1   ;cri addr
  73. push  fif   ;cri type/size on tos
  74. move  v,2   ;cri stack type/size saved in v2
  75. ;
  76. ; leave cbargs on TOS 
  77. push  v,1    ;cri addr
  78. push  w,0x44 ;cbargs rip offset
  79. add
  80. push fif     ;cbargs rip on tos
  81. cnvrt dxs    ;beak into two stack entries
  82. push w,0x3
  83. and
  84. jmp  zn,cbarg
  85. ;
  86. ;nocbarg:
  87. push d,0
  88. jmp n,logstack
  89. ;
  90. cbarg:
  91. pop  n,1     ;leave tos=cbargs offset
  92. push v,3     ;stack frame address
  93. add          ;tos=address of cbargs
  94. push fif     ;tos=cbargs
  95. ;
  96. ;
  97. ; Log the client stack frame + args + ss:esp
  98. logstack:
  99. push v,2     ;stack size
  100. add
  101. push w,8     ;allow for stack switch (ss:esp)
  102. add          ;tos=length of stack to log
  103. push v,3     ;address of stack frame
  104. log mrf
  105.  
  106.