PMD.LST 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. Listing:
  2. 1 (* Release 3.10 *)
  3. 2 (*-------------------------------------------------------------------------*
  4. 3 * *
  5. 4 * PMD.MOD - Post-mortem debugging *
  6. 5 * *
  7. 6 * COPYRIGHT (C) 1987..1992 Clarion Software Corporation. *
  8. 7 * All Rights Reserved *
  9. 8 * *
  10. 9 *--------------------------------------------------------------------------*)
  11. 10
  12. 11 (*# call(seg_name=>null) *)
  13. 12 (*# name(prefix=>c) *)
  14. 13 (*# module(implementation=>off) *)
  15. 14 (*# check(stack=>off,
  16. 15 index=>off,
  17. 16 range=>off,
  18. 17 overflow=>off,
  19. 18 nil_ptr=>off) *)
  20. 19
  21. 20 IMPLEMENTATION MODULE PMD;
  22. 21
  23. 22 (*%F _OS2 *)
  24. 23 IMPORT Str, CoreSig, CoreIO, CorePMD, CoreMain;
  25. 24 (*%E *)
  26. 25 (*%T _OS2 *)
  27. 26 IMPORT Str, Dos, CoreSig, CoreIO, CorePMD, CoreMain;
  28. 27 FROM SYSTEM IMPORT Ret;
  29. 28 (*%E *)
  30. 29
  31. 30 TYPE SegHeader = RECORD
  32. 31 frame: CARDINAL;
  33. 32 SegSize: CARDINAL;
  34. 33 FilePos: LONGCARD;
  35. ***** ^ undeclared identifier
  36. 34 BucketSizes: ARRAY [0..15] OF CARDINAL;
  37. ***** ^ not supported yet
  38. ***** ^ not supported yet
  39. 35 END;
  40. ***** ^ not supported yet
  41. 36
  42. 37 (*%T _OS2 *)
  43. 38 SelInfo = RECORD
  44. 39 selector, size: CARDINAL;
  45. 40 END;
  46. ***** ^ not supported yet
  47. 41
  48. 42 CONST
  49. 43 MAX_SELS = 256;
  50. 44 VAR
  51. 45 selectors: ARRAY [0..MAX_SELS] OF SelInfo;
  52. ***** ^ not supported yet
  53. ***** ^ not supported yet
  54. 46 (*%E *)
  55. 47
  56. 48 CONST
  57. 49 ErrMsg ="Runtime Error - Creating PM_DUMP.$$$";
  58. ***** ^ not supported yet
  59. 50
  60. 51 (*%T _OS2 *)
  61. 52 PROCEDURE Os2Write(handle: CARDINAL; buffer: FarADDRESS; count: CARDINAL): CARDINAL;
  62. ***** ^ undeclared identifier
  63. 53
  64. 54 VAR
  65. 55 NumWrit: CARDINAL;
  66. 56 BEGIN
  67. 57 IF Dos.Write(handle, buffer, count, NumWrit) = 0 THEN
  68. ***** ^ not supported yet
  69. ***** ^ not supported yet
  70. ***** ^ not supported yet
  71. ***** ^ not supported yet
  72. 58 RETURN NumWrit;
  73. 59 END;
  74. 60 RETURN MAX(CARDINAL);
  75. ***** ^ undeclared identifier
  76. ***** ^ not supported yet
  77. 61 END Os2Write;
  78. ***** ^ not supported yet
  79. 62
  80. 63 TYPE A8 = ARRAY[0..7] OF SHORTCARD;
  81. ***** ^ not supported yet
  82. ***** ^ not supported yet
  83. 64 INLINE PROCEDURE lsl(seg: CARDINAL): CARDINAL
  84. 65 = A8(00FH,003H,0C0H,074H,002H,029H,0C0H,Ret);
  85. ***** ^ not supported yet
  86. ***** ^ not supported yet
  87. 66
  88. 67 PROCEDURE GetSelectors(): CARDINAL;
  89. 68
  90. 69 VAR
  91. 70 CurSel: CARDINAL;
  92. 71 attempt, size: CARDINAL;
  93. 72 BEGIN
  94. 73 CurSel:=0;
  95. 74 attempt:=0FH;
  96. 75 WHILE attempt # 0FFFFH DO
  97. 76 size := lsl(attempt);
  98. ***** ^ not supported yet
  99. ***** ^ not supported yet
  100. 77 IF size # 0 THEN
  101. 78 selectors[CurSel].size:=size+1;
  102. ***** ^ not supported yet
  103. ***** ^ not supported yet
  104. ***** ^ not supported yet
  105. 79 selectors[CurSel].selector:=attempt;
  106. ***** ^ not supported yet
  107. ***** ^ not supported yet
  108. ***** ^ not supported yet
  109. 80 INC(CurSel);
  110. ***** ^ undeclared identifier
  111. ***** ^ not supported yet
  112. 81 IF CurSel = MAX_SELS THEN
  113. 82 RETURN CurSel;
  114. 83 END;
  115. 84 END;
  116. 85 INC(attempt, 10H);
  117. ***** ^ undeclared identifier
  118. ***** ^ not supported yet
  119. 86 END;
  120. 87 attempt:=07H;
  121. 88 WHILE attempt # 0FFF7H DO
  122. 89 size := lsl(attempt);
  123. ***** ^ not supported yet
  124. ***** ^ not supported yet
  125. 90 IF size # 0 THEN
  126. 91 selectors[CurSel].size:=size+1;
  127. ***** ^ not supported yet
  128. ***** ^ not supported yet
  129. ***** ^ not supported yet
  130. 92 selectors[CurSel].selector:=attempt;
  131. ***** ^ not supported yet
  132. ***** ^ not supported yet
  133. ***** ^ not supported yet
  134. 93 INC(CurSel);
  135. ***** ^ undeclared identifier
  136. ***** ^ not supported yet
  137. 94 IF CurSel = MAX_SELS THEN
  138. 95 RETURN CurSel;
  139. 96 END;
  140. 97 END;
  141. 98 INC(attempt, 10H);
  142. ***** ^ undeclared identifier
  143. ***** ^ not supported yet
  144. 99 END;
  145. 100 RETURN CurSel;
  146. 101 END GetSelectors;
  147. ***** ^ not supported yet
  148. 102
  149. 103 PROCEDURE WriteStruct(VAR State: ProcessState; fh: INTEGER): INTEGER;
  150. ***** ^ undeclared identifier
  151. 104
  152. 105 BEGIN
  153. 106 IF Os2Write(fh, FarADR(State), SIZE(ProcessState)) # SIZE(ProcessState) THEN
  154. ***** ^ not supported yet
  155. ***** ^ undeclared identifier
  156. ***** ^ not supported yet
  157. ***** ^ undeclared identifier
  158. ***** ^ undeclared identifier
  159. ***** ^ undeclared identifier
  160. ***** ^ undeclared identifier
  161. 107 RETURN -1;
  162. 108 END;
  163. 109 RETURN 0;
  164. 110 END WriteStruct;
  165. ***** ^ not supported yet
  166. 111 (*%E *)
  167. 112
  168. 113 (*%F _OS2 *)
  169. 114 PROCEDURE WriteStruct(VAR State: ProcessState; fh: INTEGER): INTEGER;
  170. 115
  171. 116 BEGIN
  172. 117 IF CoreIO._write(fh, ADR(State), SIZE(ProcessState)) # SIZE(ProcessState) THEN
  173. 118 RETURN -1;
  174. 119 END;
  175. 120 RETURN 0;
  176. 121 END WriteStruct;
  177. 122 (*%E *)
  178. 123
  179. 124 PROCEDURE compress(VAR header: SegHeader; fh: INTEGER): INTEGER;
  180. 125
  181. 126 VAR
  182. 127 SegSize: LONGINT;
  183. 128 offset: CARDINAL;
  184. 129 OutSize, BucketNo, BucketSize, NumWritize, NumWrit: CARDINAL;
  185. 130 BEGIN
  186. 131 SegSize:= LONGCARD(header.SegSize);
  187. ***** ^ undeclared identifier
  188. ***** ^ not supported yet
  189. ***** ^ not supported yet
  190. 132 IF SegSize = 0 THEN
  191. 133 SegSize:=10000H;
  192. 134 END;
  193. 135 offset:=0;
  194. 136 BucketNo:=0;
  195. 137 WHILE SegSize > 0 DO
  196. 138 IF SegSize > 1000H THEN
  197. 139 OutSize:=1000H;
  198. 140 ELSE
  199. 141 OutSize:= CARDINAL(SegSize);
  200. ***** ^ not supported yet
  201. 142 END;
  202. 143 BucketSize:= CorePMD._Pack(OutSize, [header.frame: offset]);
  203. ***** ^ not supported yet
  204. ***** ^ not supported yet
  205. ***** ^ not supported yet
  206. ***** ^ not supported yet
  207. ***** ^ not supported yet
  208. ***** ^ not supported yet
  209. 144 header.BucketSizes[BucketNo]:=BucketSize;
  210. ***** ^ not supported yet
  211. ***** ^ not supported yet
  212. ***** ^ not supported yet
  213. 145 (*%F _OS2 *)
  214. 146 IF CoreIO._dos_write(fh, FarADR(CorePMD._p), BucketSize, NumWrit) # 0 THEN
  215. 147 (*%E *)
  216. 148 (*%T _OS2 *)
  217. 149 IF Os2Write(fh, FarADR(CorePMD._p), BucketSize) # BucketSize THEN
  218. ***** ^ not supported yet
  219. ***** ^ undeclared identifier
  220. ***** ^ not supported yet
  221. ***** ^ not supported yet
  222. ***** ^ not supported yet
  223. 150 (*%E *)
  224. 151 RETURN -1;
  225. 152 END;
  226. 153 DEC(SegSize, 1000H);
  227. ***** ^ undeclared identifier
  228. ***** ^ not supported yet
  229. 154 INC(offset, 1000H);
  230. ***** ^ undeclared identifier
  231. ***** ^ not supported yet
  232. 155 INC(BucketNo);
  233. ***** ^ undeclared identifier
  234. ***** ^ not supported yet
  235. 156 END;
  236. 157 RETURN 0;
  237. 158 END compress;
  238. ***** ^ not supported yet
  239. 159
  240. 160 (*%F _OS2 *)
  241. 161 PROCEDURE WriteCore(fh: INTEGER; top, bottom: CARDINAL);
  242. 162
  243. 163 VAR
  244. 164 h: SegHeader;
  245. 165 TotalParas: CARDINAL;
  246. 166 Segment: CARDINAL;
  247. 167 SegTotal: CARDINAL;
  248. 168 SegNum: CARDINAL;
  249. 169 NumToWrite: CARDINAL;
  250. 170 BEGIN
  251. 171 Segment:=bottom;
  252. 172 SegNum:=0;
  253. 173 TotalParas:=top-bottom;
  254. 174 SegTotal:=(TotalParas+0FFFH) DIV 01000H;
  255. 175 IF CoreIO.lseek(fh, LONGCARD((SIZE(ProcessState)+SIZE(CARDINAL)+(SIZE(SegHeader)*SegTotal))-1), 0) # 0 THEN END;
  256. 176 CoreIO._write(fh, ADR(Segment), 1);
  257. 177 LOOP
  258. 178 IF TotalParas = 0 THEN EXIT END;
  259. 179 h.frame:=Segment;
  260. 180 IF TotalParas < 1000H THEN
  261. 181 NumToWrite:=TotalParas
  262. 182 ELSE
  263. 183 NumToWrite:= 1000H;
  264. 184 END;
  265. 185 h.SegSize:=NumToWrite<<4;
  266. 186 h.FilePos:=CoreIO.lseek(fh, 0, 2);
  267. 187 IF compress(h, fh) = -1 THEN
  268. 188 SegTotal:=0;
  269. 189 EXIT;
  270. 190 END;
  271. 191 IF CoreIO.lseek(fh, LONGCARD(SIZE(ProcessState)+SIZE(CARDINAL)+SIZE(SegHeader)*SegNum), 0) # 0 THEN END;
  272. 192 INC(SegNum);
  273. 193 CoreIO._write(fh, ADR(h), SIZE(SegHeader));
  274. 194 INC(Segment, NumToWrite);
  275. 195 DEC(TotalParas, NumToWrite);
  276. 196 END;
  277. 197 IF CoreIO.lseek(fh, (SIZE(ProcessState)), 0) # 0 THEN END;
  278. 198 CoreIO._write(fh, ADR(SegTotal), SIZE(CARDINAL));
  279. 199 RETURN;
  280. 200 END WriteCore;
  281. 201
  282. 202 PROCEDURE _PMDbody(VAR state: ProcessState);
  283. 203
  284. 204 TYPE
  285. 205 A2 = ARRAY [0..1] OF CHAR;
  286. 206 VAR
  287. 207 fh: INTEGER;
  288. 208 Ln: A2;
  289. 209 BEGIN
  290. 210 Ln[0]:= CHAR(0DH);
  291. 211 Ln[1]:= CHAR(0AH); (* NB *)
  292. 212 IF CoreMain._argc # 0 THEN
  293. 213 Str.Copy(state.ProgName, CoreMain._argv[0]^);
  294. 214 END;
  295. 215 fh:=CoreIO._creat_trunc("PM_DUMP.$$$", 0);
  296. 216 IF fh >= 0 THEN
  297. 217 IF CoreIO._write(2, ADR(ErrMsg), Str.Length(ErrMsg)) # 0 THEN END;
  298. 218 IF CoreIO._write(2, ADR(Ln), 2) # 0 THEN END;
  299. 219 IF WriteStruct(state, fh) = 0 THEN
  300. 220 WriteCore(fh, state.TopLim, state.PSP);
  301. 221 END;
  302. 222 IF CoreIO._close(fh) # 0 THEN END;
  303. 223 END;
  304. 224 RETURN;
  305. 225 END _PMDbody;
  306. 226 (*%E *)
  307. 227
  308. 228 (*%T _OS2 *)
  309. 229 PROCEDURE WriteCore(fh: INTEGER);
  310. 230
  311. 231 VAR
  312. 232 h: SegHeader;
  313. ***** ^ not supported yet
  314. 233 Segment, SegTotal: CARDINAL;
  315. 234
  316. 235 BEGIN
  317. 236 Segment:=0;
  318. 237 SegTotal:=GetSelectors();
  319. ***** ^ not supported yet
  320. ***** ^ not supported yet
  321. 238 IF CoreIO.lseek(fh, LONGCARD((SIZE(ProcessState)+SIZE(CARDINAL)+(SIZE(SegHeader)*SegTotal))-1), 0) # 0 THEN END;
  322. ***** ^ not supported yet
  323. ***** ^ not supported yet
  324. ***** ^ undeclared identifier
  325. ***** ^ undeclared identifier
  326. ***** ^ undeclared identifier
  327. ***** ^ undeclared identifier
  328. ***** ^ not supported yet
  329. ***** ^ undeclared identifier
  330. ***** ^ not supported yet
  331. ***** ^ not supported yet
  332. ***** ^ not supported yet
  333. 239 IF Os2Write(fh, FarADR(Segment), 1) # 0 THEN END;
  334. ***** ^ not supported yet
  335. ***** ^ undeclared identifier
  336. ***** ^ not supported yet
  337. ***** ^ not supported yet
  338. 240 LOOP
  339. 241 IF Segment = SegTotal THEN EXIT END;
  340. 242 h.frame:=selectors[Segment].selector;
  341. ***** ^ not supported yet
  342. ***** ^ not supported yet
  343. ***** ^ not supported yet
  344. ***** ^ not supported yet
  345. ***** ^ not supported yet
  346. 243 h.SegSize:=selectors[Segment].size;
  347. ***** ^ not supported yet
  348. ***** ^ not supported yet
  349. ***** ^ not supported yet
  350. ***** ^ not supported yet
  351. ***** ^ not supported yet
  352. 244 h.FilePos:=CoreIO.lseek(fh, 0, 2);
  353. ***** ^ not supported yet
  354. ***** ^ not supported yet
  355. ***** ^ not supported yet
  356. ***** ^ not supported yet
  357. ***** ^ not supported yet
  358. 245 IF compress(h, fh) = -1 THEN
  359. ***** ^ not supported yet
  360. ***** ^ not supported yet
  361. ***** ^ not supported yet
  362. 246 SegTotal:=0;
  363. 247 EXIT;
  364. 248 END;
  365. 249 IF CoreIO.lseek(fh, LONGCARD(SIZE(ProcessState)+SIZE(CARDINAL)+SIZE(SegHeader)*Segment), 0) # 0 THEN END;
  366. ***** ^ not supported yet
  367. ***** ^ not supported yet
  368. ***** ^ undeclared identifier
  369. ***** ^ undeclared identifier
  370. ***** ^ undeclared identifier
  371. ***** ^ undeclared identifier
  372. ***** ^ not supported yet
  373. ***** ^ undeclared identifier
  374. ***** ^ not supported yet
  375. ***** ^ not supported yet
  376. ***** ^ not supported yet
  377. 250 IF Os2Write(fh, FarADR(h), SIZE(SegHeader)) # 0 THEN END;
  378. ***** ^ not supported yet
  379. ***** ^ undeclared identifier
  380. ***** ^ not supported yet
  381. ***** ^ undeclared identifier
  382. ***** ^ not supported yet
  383. 251 INC(Segment);
  384. ***** ^ undeclared identifier
  385. ***** ^ not supported yet
  386. 252 END;
  387. 253 IF CoreIO.lseek(fh, (SIZE(ProcessState)), 0) # 0 THEN END;
  388. ***** ^ not supported yet
  389. ***** ^ not supported yet
  390. ***** ^ undeclared identifier
  391. ***** ^ undeclared identifier
  392. ***** ^ not supported yet
  393. 254 IF Os2Write(fh, FarADR(SegTotal), SIZE(CARDINAL)) # 0 THEN END;
  394. ***** ^ not supported yet
  395. ***** ^ undeclared identifier
  396. ***** ^ not supported yet
  397. ***** ^ undeclared identifier
  398. ***** ^ not supported yet
  399. 255 RETURN;
  400. 256 END WriteCore;
  401. ***** ^ not supported yet
  402. 257
  403. 258 PROCEDURE _PMDbody(VAR state: ProcessState);
  404. ***** ^ undeclared identifier
  405. 259
  406. 260 TYPE
  407. 261 A2 = ARRAY [0..1] OF CHAR;
  408. ***** ^ not supported yet
  409. ***** ^ not supported yet
  410. 262 VAR
  411. 263 fh: CARDINAL;
  412. 264 action: CARDINAL;
  413. 265 Ln: A2;
  414. ***** ^ not supported yet
  415. 266 BEGIN
  416. 267 Ln[0]:= CHAR(0DH);
  417. ***** ^ not supported yet
  418. ***** ^ not supported yet
  419. ***** ^ not supported yet
  420. 268 Ln[1]:= CHAR(0AH); (* NB *)
  421. ***** ^ not supported yet
  422. ***** ^ not supported yet
  423. ***** ^ not supported yet
  424. 269 IF CoreMain._argc # 0 THEN
  425. ***** ^ not supported yet
  426. ***** ^ not supported yet
  427. 270 Str.Copy(state.ProgName, CoreMain._argv[0]^);
  428. ***** ^ not supported yet
  429. ***** ^ not supported yet
  430. ***** ^ not supported yet
  431. ***** ^ not supported yet
  432. ***** ^ not supported yet
  433. ***** ^ not supported yet
  434. ***** ^ not supported yet
  435. 271 END;
  436. 272 IF Dos.Open("PM_DUMP.$$$", fh, action, LONGCARD(0),
  437. ***** ^ not supported yet
  438. ***** ^ not supported yet
  439. ***** ^ not supported yet
  440. ***** ^ undeclared identifier
  441. ***** ^ not supported yet
  442. 273 0, 012H, 012H, LONGCARD(0)) = 0 THEN
  443. ***** ^ undeclared identifier
  444. ***** ^ not supported yet
  445. 274 IF Os2Write(2, FarADR(ErrMsg), Str.Length(ErrMsg)) # 0 THEN END;
  446. ***** ^ not supported yet
  447. ***** ^ undeclared identifier
  448. ***** ^ not supported yet
  449. ***** ^ not supported yet
  450. ***** ^ not supported yet
  451. ***** ^ not supported yet
  452. 275 IF Os2Write(2, FarADR(Ln), 2) # 0 THEN END;
  453. ***** ^ not supported yet
  454. ***** ^ undeclared identifier
  455. ***** ^ not supported yet
  456. ***** ^ not supported yet
  457. 276 IF WriteStruct(state, fh) = 0 THEN
  458. ***** ^ not supported yet
  459. ***** ^ not supported yet
  460. ***** ^ not supported yet
  461. 277 WriteCore(fh);
  462. ***** ^ not supported yet
  463. ***** ^ not supported yet
  464. 278 END;
  465. 279 IF CoreIO._close(fh) # 0 THEN END;
  466. ***** ^ not supported yet
  467. ***** ^ not supported yet
  468. ***** ^ not supported yet
  469. 280 END;
  470. 281 RETURN;
  471. 282 END _PMDbody;
  472. ***** ^ not supported yet
  473. 283 (*%E *)
  474. 284
  475. 285 PROCEDURE UserFatalError(ErrorCode: CARDINAL);
  476. 286
  477. 287 BEGIN
  478. 288 CoreSig._FatalError(CoreSig._FatalErrorPos(), ErrorCode);
  479. ***** ^ not supported yet
  480. ***** ^ not supported yet
  481. ***** ^ not supported yet
  482. ***** ^ not supported yet
  483. ***** ^ not supported yet
  484. ***** ^ not supported yet
  485. 289 END UserFatalError;
  486. ***** ^ not supported yet
  487. 290
  488. 291
  489. 292 BEGIN
  490. 293 includePMD:=1;
  491. ***** ^ undeclared identifier
  492. 294 END PMD.
  493. ***** ^ not supported yet
  494. 198 errors