Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

825 lines
24 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. vwdebug.c
  5. Abstract:
  6. Contains debug routines for VWIPXSPX.DLL
  7. Contents:
  8. VwDebugStart
  9. VwDebugEnd
  10. VwDebugPrint
  11. VwDumpData
  12. VwDumpEcb
  13. VwDumpFragment
  14. VwDumpPacketHeader
  15. VwDumpXecb
  16. VwDumpSocketInfo
  17. VwDumpConnectionInfo
  18. VwDumpConnectionStats
  19. VwLog
  20. CheckInterrupts
  21. Author:
  22. Richard L Firth (rfirth) 5-Oct-1993
  23. Environment:
  24. User-mode Win32
  25. Revision History:
  26. 5-Oct-1993 rfirth
  27. Created
  28. --*/
  29. #include "vw.h"
  30. #pragma hdrstop
  31. #if DBG
  32. //
  33. // private prototypes
  34. //
  35. int PokeLevelString(LPSTR, DWORD, DWORD, LPSTR);
  36. LPSTR StripNameFromPath(LPSTR);
  37. //
  38. // private data
  39. //
  40. DWORD VwDebugFlags = 0;
  41. DWORD VwDebugFunctions = 0;
  42. DWORD VwShow = SHOW_ECBS | SHOW_HEADERS;
  43. DWORD VwDebugLevel = IPXDBG_MIN_LEVEL;
  44. DWORD VwDebugDump = 0;
  45. BOOL VwDebugInitialized = FALSE;
  46. FILE* hVwDebugLog = NULL;
  47. DWORD DebugFlagsEx = 0 ;
  48. //
  49. // functions
  50. //
  51. VOID VwDebugStart() {
  52. //
  53. // a little run-time diagnostication, madam?
  54. //
  55. LPSTR ptr;
  56. if (VwDebugInitialized) {
  57. return;
  58. }
  59. //
  60. // override VwDebugFlags from VWFLAGS environment variable
  61. //
  62. if (ptr = getenv("VWFLAGS")) {
  63. VwDebugFlags = (DWORD)strtoul(ptr, NULL, 0);
  64. }
  65. if (ptr = getenv("VWFUNCS")) {
  66. VwDebugFunctions = (DWORD)strtoul(ptr, NULL, 0);
  67. }
  68. if (ptr = getenv("VWSHOW")) {
  69. VwShow = (DWORD)strtoul(ptr, NULL, 0);
  70. }
  71. if (ptr = getenv("VWLEVEL")) {
  72. VwDebugLevel = strtoul(ptr, NULL, 0);
  73. if (VwDebugLevel > IPXDBG_MAX_LEVEL) {
  74. VwDebugLevel = IPXDBG_MAX_LEVEL;
  75. }
  76. }
  77. if (ptr = getenv("VWDUMP")) {
  78. VwDebugDump = strtoul(ptr, NULL, 0);
  79. }
  80. IF_DEBUG(TO_FILE) {
  81. if ((hVwDebugLog = fopen(VWDEBUG_FILE, "w+")) == NULL) {
  82. VwDebugFlags &= ~DEBUG_TO_FILE;
  83. } else {
  84. #if 0
  85. char currentDirectory[256];
  86. int n;
  87. currentDirectory[0] = 0;
  88. if (n = GetCurrentDirectory(sizeof(currentDirectory), currentDirectory)) {
  89. if (currentDirectory[n-1] == '\\') {
  90. currentDirectory[n-1] = 0;
  91. }
  92. }
  93. DbgPrint("VWIPXSPX: Writing debug output to %s\\" VWDEBUG_FILE "\n", currentDirectory);
  94. #endif
  95. }
  96. }
  97. VwDebugInitialized = TRUE;
  98. }
  99. VOID VwDebugEnd() {
  100. IF_DEBUG(TO_FILE) {
  101. fflush(hVwDebugLog);
  102. fclose(hVwDebugLog);
  103. }
  104. }
  105. VOID VwDebugPrint(LPSTR Module, DWORD Line, DWORD Function, DWORD Level, LPSTR Format, ...) {
  106. char buf[1024];
  107. va_list p;
  108. IF_DEBUG(NOTHING) {
  109. return;
  110. }
  111. //
  112. // only log something if we are tracking this Function and Level is above
  113. // (or equal to) the filter cut-off or Level >= minimum alert level (error)
  114. //
  115. if (((Function & VwDebugFunctions) && (Level >= VwDebugLevel)) || (Level >= IPXDBG_LEVEL_ERROR)) {
  116. va_start(p, Format);
  117. vsprintf(buf+PokeLevelString(Module, Line, Level, buf), Format, p);
  118. VwLog(buf);
  119. va_end(p);
  120. }
  121. }
  122. int PokeLevelString(LPSTR Module, DWORD Line, DWORD Level, LPSTR Buffer) {
  123. int length;
  124. static char levelString[4] = " : ";
  125. char level;
  126. switch (Level) {
  127. case IPXDBG_LEVEL_INFO:
  128. level = 'I';
  129. break;
  130. case IPXDBG_LEVEL_WARNING:
  131. level = 'W';
  132. break;
  133. case IPXDBG_LEVEL_ERROR:
  134. level = 'E';
  135. break;
  136. case IPXDBG_LEVEL_FATAL:
  137. level = 'F';
  138. break;
  139. }
  140. levelString[0] = level;
  141. strcpy(Buffer, levelString);
  142. length = strlen(levelString);
  143. if (Level >= IPXDBG_LEVEL_ERROR) {
  144. length += sprintf(Buffer + length, "%s [% 5d]: ", StripNameFromPath(Module), Line);
  145. }
  146. return length;
  147. }
  148. LPSTR StripNameFromPath(LPSTR Path) {
  149. LPSTR p;
  150. p = strrchr(Path, '\\');
  151. return p ? p+1 : Path;
  152. }
  153. VOID VwDumpData(ULPBYTE Address, WORD Seg, WORD Off, BOOL InVdm, WORD Size) {
  154. char buf[128];
  155. int i, len;
  156. IF_NOT_DEBUG(DATA) {
  157. return;
  158. }
  159. while (Size) {
  160. len = min(Size, 16);
  161. if (InVdm) {
  162. sprintf(buf, "%04x:%04x ", Seg, Off);
  163. } else {
  164. sprintf(buf, "%p ", Address);
  165. }
  166. for (i = 0; i < len; ++i) {
  167. sprintf(&buf[10+i*3], "%02.2x ", Address[i] & 0xff);
  168. }
  169. for (i = len; i < 17; ++i) {
  170. strcat(buf, " ");
  171. }
  172. for (i = 0; i < len; ++i) {
  173. char ch;
  174. ch = Address[i];
  175. buf[61+i] = ((ch < 32) || (ch > 127)) ? '.' : ch;
  176. }
  177. buf[61+i++] = '\n';
  178. buf[61+i] = 0;
  179. VwLog(buf);
  180. Address += len;
  181. Size -= (WORD)len;
  182. Off += (WORD)len;
  183. }
  184. VwLog("\n");
  185. }
  186. VOID VwDumpEcb(LPECB pEcb, WORD Seg, WORD Off, BYTE Type, BOOL Frags, BOOL Data, BOOL Mode) {
  187. char buf[512];
  188. int n;
  189. char* bufptr;
  190. IF_NOT_DEBUG(ECB) {
  191. return;
  192. }
  193. IF_NOT_SHOW(ECBS) {
  194. VwDumpData((ULPBYTE)pEcb,
  195. Seg,
  196. Off,
  197. TRUE,
  198. (WORD)((Type == ECB_TYPE_AES)
  199. ? sizeof(AES_ECB)
  200. : (sizeof(IPX_ECB) + sizeof(FRAGMENT) * (pEcb->FragmentCount - 1)))
  201. );
  202. return;
  203. }
  204. n = sprintf(buf,
  205. "\n"
  206. "%s ECB @ %04x:%04x:\n"
  207. "LinkAddress %04x:%04x\n"
  208. "EsrAddress %04x:%04x\n"
  209. "InUse %02x\n",
  210. (Type == ECB_TYPE_AES)
  211. ? "AES"
  212. : (Type == ECB_TYPE_IPX)
  213. ? "IPX"
  214. : "SPX",
  215. Seg,
  216. Off,
  217. GET_SEGMENT(&pEcb->LinkAddress),
  218. GET_OFFSET(&pEcb->LinkAddress),
  219. GET_SEGMENT(&pEcb->EsrAddress),
  220. GET_OFFSET(&pEcb->EsrAddress),
  221. pEcb->InUse
  222. );
  223. bufptr = buf + n;
  224. if (Type == ECB_TYPE_AES) {
  225. sprintf(bufptr,
  226. "AesWorkspace %02x-%02x-%02x-%02x-%02x\n",
  227. ((LPAES_ECB)pEcb)->AesWorkspace[0] & 0xff,
  228. ((LPAES_ECB)pEcb)->AesWorkspace[1] & 0xff,
  229. ((LPAES_ECB)pEcb)->AesWorkspace[2] & 0xff,
  230. ((LPAES_ECB)pEcb)->AesWorkspace[3] & 0xff,
  231. ((LPAES_ECB)pEcb)->AesWorkspace[4] & 0xff
  232. );
  233. } else {
  234. sprintf(bufptr,
  235. "CompletionCode %02x\n"
  236. "SocketNumber %04x\n"
  237. "IpxWorkspace %08x\n"
  238. "DriverWorkspace %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n"
  239. "ImmediateAddress %02x-%02x-%02x-%02x-%02x-%02x\n"
  240. "FragmentCount %04x\n",
  241. pEcb->CompletionCode,
  242. B2LW(pEcb->SocketNumber),
  243. pEcb->IpxWorkspace,
  244. pEcb->DriverWorkspace[0] & 0xff,
  245. pEcb->DriverWorkspace[1] & 0xff,
  246. pEcb->DriverWorkspace[2] & 0xff,
  247. pEcb->DriverWorkspace[3] & 0xff,
  248. pEcb->DriverWorkspace[4] & 0xff,
  249. pEcb->DriverWorkspace[5] & 0xff,
  250. pEcb->DriverWorkspace[6] & 0xff,
  251. pEcb->DriverWorkspace[7] & 0xff,
  252. pEcb->DriverWorkspace[8] & 0xff,
  253. pEcb->DriverWorkspace[9] & 0xff,
  254. pEcb->DriverWorkspace[10] & 0xff,
  255. pEcb->DriverWorkspace[11] & 0xff,
  256. pEcb->ImmediateAddress[0] & 0xff,
  257. pEcb->ImmediateAddress[1] & 0xff,
  258. pEcb->ImmediateAddress[2] & 0xff,
  259. pEcb->ImmediateAddress[3] & 0xff,
  260. pEcb->ImmediateAddress[4] & 0xff,
  261. pEcb->ImmediateAddress[5] & 0xff,
  262. pEcb->FragmentCount
  263. );
  264. }
  265. VwLog(buf);
  266. if ((Type != ECB_TYPE_AES) && Frags) {
  267. ASSERT(pEcb->FragmentCount < 10);
  268. VwDumpFragment(pEcb->FragmentCount,
  269. (LPFRAGMENT)(pEcb + 1),
  270. Type,
  271. Data,
  272. Mode
  273. );
  274. }
  275. }
  276. VOID VwDumpFragment(WORD Count, LPFRAGMENT pFrag, BYTE Type, BOOL Data, BOOL Mode) {
  277. char buf[256];
  278. int i;
  279. IF_NOT_DEBUG(FRAGMENTS) {
  280. return;
  281. }
  282. for (i = 0; i < Count; ++i) {
  283. sprintf(buf,
  284. "Fragment %d:\n"
  285. " Address %04x:%04x\n"
  286. " Length %04x\n",
  287. i + 1,
  288. GET_SEGMENT(&pFrag->Address),
  289. GET_OFFSET(&pFrag->Address),
  290. pFrag->Length
  291. );
  292. VwLog(buf);
  293. if (Data) {
  294. ULPBYTE ptr;
  295. WORD size;
  296. WORD offset;
  297. ptr = GET_FAR_POINTER(&pFrag->Address, Mode);
  298. size = pFrag->Length;
  299. offset = GET_OFFSET(&pFrag->Address);
  300. //
  301. // this allows us to show headers vs. raw data
  302. //
  303. IF_SHOW(HEADERS) {
  304. if (i == 0) {
  305. VwDumpPacketHeader(ptr, Type);
  306. if (Type == ECB_TYPE_IPX) {
  307. ptr += IPX_HEADER_LENGTH;
  308. size -= IPX_HEADER_LENGTH;
  309. offset += IPX_HEADER_LENGTH;
  310. } else {
  311. ptr += SPX_HEADER_LENGTH;
  312. size -= SPX_HEADER_LENGTH;
  313. offset += SPX_HEADER_LENGTH;
  314. }
  315. }
  316. }
  317. VwDumpData(ptr,
  318. GET_SEGMENT(&pFrag->Address),
  319. offset,
  320. TRUE,
  321. size
  322. );
  323. }
  324. ++pFrag;
  325. }
  326. }
  327. VOID VwDumpPacketHeader(ULPBYTE pPacket, BYTE Type) {
  328. char buf[512];
  329. IF_NOT_DEBUG(HEADERS) {
  330. return;
  331. }
  332. sprintf(buf,
  333. "Checksum %04x\n"
  334. "Length %04x\n"
  335. "TransportControl %02x\n"
  336. "PacketType %02x\n"
  337. "Destination %02x-%02x-%02x-%02x : %02x-%02x-%02x-%02x-%02x-%02x : %04x\n"
  338. "Source %02x-%02x-%02x-%02x : %02x-%02x-%02x-%02x-%02x-%02x : %04x\n",
  339. ((LPIPX_PACKET)pPacket)->Checksum,
  340. B2LW(((LPIPX_PACKET)pPacket)->Length),
  341. ((LPIPX_PACKET)pPacket)->TransportControl,
  342. ((LPIPX_PACKET)pPacket)->PacketType,
  343. ((LPIPX_PACKET)pPacket)->Destination.Net[0] & 0xff,
  344. ((LPIPX_PACKET)pPacket)->Destination.Net[1] & 0xff,
  345. ((LPIPX_PACKET)pPacket)->Destination.Net[2] & 0xff,
  346. ((LPIPX_PACKET)pPacket)->Destination.Net[3] & 0xff,
  347. ((LPIPX_PACKET)pPacket)->Destination.Node[0] & 0xff,
  348. ((LPIPX_PACKET)pPacket)->Destination.Node[1] & 0xff,
  349. ((LPIPX_PACKET)pPacket)->Destination.Node[2] & 0xff,
  350. ((LPIPX_PACKET)pPacket)->Destination.Node[3] & 0xff,
  351. ((LPIPX_PACKET)pPacket)->Destination.Node[4] & 0xff,
  352. ((LPIPX_PACKET)pPacket)->Destination.Node[5] & 0xff,
  353. B2LW(((LPIPX_PACKET)pPacket)->Destination.Socket),
  354. ((LPIPX_PACKET)pPacket)->Source.Net[0] & 0xff,
  355. ((LPIPX_PACKET)pPacket)->Source.Net[1] & 0xff,
  356. ((LPIPX_PACKET)pPacket)->Source.Net[2] & 0xff,
  357. ((LPIPX_PACKET)pPacket)->Source.Net[3] & 0xff,
  358. ((LPIPX_PACKET)pPacket)->Source.Node[0] & 0xff,
  359. ((LPIPX_PACKET)pPacket)->Source.Node[1] & 0xff,
  360. ((LPIPX_PACKET)pPacket)->Source.Node[2] & 0xff,
  361. ((LPIPX_PACKET)pPacket)->Source.Node[3] & 0xff,
  362. ((LPIPX_PACKET)pPacket)->Source.Node[4] & 0xff,
  363. ((LPIPX_PACKET)pPacket)->Source.Node[5] & 0xff,
  364. B2LW(((LPIPX_PACKET)pPacket)->Source.Socket)
  365. );
  366. VwLog(buf);
  367. if (Type == ECB_TYPE_SPX) {
  368. sprintf(buf,
  369. "ConnectControl %02x\n"
  370. "DataStreamType %02x\n"
  371. "SourceConnectId %04x\n"
  372. "DestConnectId %04x\n"
  373. "SequenceNumber %04x\n"
  374. "AckNumber %04x\n"
  375. "AllocationNumber %04x\n",
  376. ((LPSPX_PACKET)pPacket)->ConnectionControl,
  377. ((LPSPX_PACKET)pPacket)->DataStreamType,
  378. B2LW(((LPSPX_PACKET)pPacket)->SourceConnectId),
  379. B2LW(((LPSPX_PACKET)pPacket)->DestinationConnectId),
  380. B2LW(((LPSPX_PACKET)pPacket)->SequenceNumber),
  381. B2LW(((LPSPX_PACKET)pPacket)->AckNumber),
  382. B2LW(((LPSPX_PACKET)pPacket)->AllocationNumber)
  383. );
  384. VwLog(buf);
  385. }
  386. VwLog("\n");
  387. }
  388. VOID VwDumpXecb(LPXECB pXecb) {
  389. char buf[512];
  390. IF_NOT_DEBUG(XECB) {
  391. return;
  392. }
  393. sprintf(buf,
  394. "XECB @ %p:\n"
  395. "Next %p\n"
  396. "Ecb %p\n"
  397. "EcbAddress %08x\n"
  398. "EsrAddress %08x\n"
  399. "Buffer %p\n"
  400. "Data %p\n"
  401. "FrameLength %04x\n"
  402. "ActualLength %04x\n"
  403. "Length %04x\n"
  404. "Ticks %04x\n"
  405. "SocketNumber %04x\n"
  406. "Owner %04x\n"
  407. "TaskId %08x\n"
  408. "Flags %08x\n"
  409. "QueueId %08x\n"
  410. "OwningObject %p\n"
  411. "RefCount %08x\n",
  412. pXecb,
  413. pXecb->Next,
  414. pXecb->Ecb,
  415. pXecb->EcbAddress,
  416. pXecb->EsrAddress,
  417. pXecb->Buffer,
  418. pXecb->Data,
  419. pXecb->FrameLength,
  420. pXecb->ActualLength,
  421. pXecb->Length,
  422. pXecb->Ticks,
  423. B2LW(pXecb->SocketNumber),
  424. pXecb->Owner,
  425. pXecb->TaskId,
  426. pXecb->Flags,
  427. pXecb->QueueId,
  428. pXecb->OwningObject,
  429. pXecb->RefCount
  430. );
  431. VwLog(buf);
  432. }
  433. VOID VwDumpSocketInfo(LPSOCKET_INFO pSocketInfo) {
  434. char buf[512];
  435. IF_NOT_DEBUG(SOCKINFO) {
  436. return;
  437. }
  438. sprintf(buf,
  439. "SOCKET_INFO @ %p:\n"
  440. "Next %p\n"
  441. "SocketNumber %04x\n"
  442. "Owner %04x\n"
  443. "TaskId %08x\n"
  444. "Socket %08x\n"
  445. "Flags %08x\n"
  446. "LongLived %d\n"
  447. "SpxSocket %d\n"
  448. "PendingSends %08x\n"
  449. "PendingListens %08x\n"
  450. "ListenQueue %p, %p\n"
  451. "SendQueue %p, %p\n"
  452. "HeaderQueue %p, %p\n"
  453. "Connections %p\n",
  454. pSocketInfo,
  455. pSocketInfo->Next,
  456. B2LW(pSocketInfo->SocketNumber),
  457. pSocketInfo->Owner,
  458. pSocketInfo->TaskId,
  459. pSocketInfo->Socket,
  460. pSocketInfo->Flags,
  461. pSocketInfo->LongLived,
  462. pSocketInfo->SpxSocket,
  463. pSocketInfo->PendingSends,
  464. pSocketInfo->PendingListens,
  465. pSocketInfo->ListenQueue.Head,
  466. pSocketInfo->ListenQueue.Tail,
  467. pSocketInfo->SendQueue.Head,
  468. pSocketInfo->SendQueue.Tail,
  469. pSocketInfo->HeaderQueue.Head,
  470. pSocketInfo->HeaderQueue.Tail,
  471. pSocketInfo->Connections
  472. );
  473. VwLog(buf);
  474. }
  475. VOID VwDumpConnectionInfo(LPCONNECTION_INFO pConnectionInfo) {
  476. char buf[512];
  477. IF_NOT_DEBUG(CONNINFO) {
  478. return;
  479. }
  480. sprintf(buf,
  481. "CONNECTION_INFO @ %p:\n"
  482. "Next %p\n"
  483. "List %p\n"
  484. "OwningSocket %p\n"
  485. "Socket %08x\n"
  486. "TaskId %08x\n"
  487. "ConnectionId %04x\n"
  488. "Flags %02x\n"
  489. "State %02x\n"
  490. "ConnectQueue %p, %p\n"
  491. "AcceptQueue %p, %p\n"
  492. "SendQueue %p, %p\n"
  493. "ListenQueue %p, %p\n",
  494. pConnectionInfo,
  495. pConnectionInfo->Next,
  496. pConnectionInfo->List,
  497. pConnectionInfo->OwningSocket,
  498. pConnectionInfo->Socket,
  499. pConnectionInfo->TaskId,
  500. pConnectionInfo->ConnectionId,
  501. pConnectionInfo->Flags,
  502. pConnectionInfo->State,
  503. pConnectionInfo->ConnectQueue.Head,
  504. pConnectionInfo->ConnectQueue.Tail,
  505. pConnectionInfo->AcceptQueue.Head,
  506. pConnectionInfo->AcceptQueue.Tail,
  507. pConnectionInfo->SendQueue.Head,
  508. pConnectionInfo->SendQueue.Tail,
  509. pConnectionInfo->ListenQueue.Head,
  510. pConnectionInfo->ListenQueue.Tail
  511. );
  512. VwLog(buf);
  513. }
  514. VOID VwDumpConnectionStats(LPSPX_CONNECTION_STATS pStats) {
  515. char buf[1024];
  516. IF_NOT_DEBUG(STATS) {
  517. return;
  518. }
  519. sprintf(buf,
  520. "State %02x\n"
  521. "WatchDog %02x\n"
  522. "LocalConnectionId %04x\n"
  523. "RemoteConnectionId %04x\n"
  524. "LocalSequenceNumber %04x\n"
  525. "LocalAckNumber %04x\n"
  526. "LocalAllocNumber %04x\n"
  527. "RemoteAckNumber %04x\n"
  528. "RemoteAllocNumber %04x\n"
  529. "LocalSocket %04x\n"
  530. "ImmediateAddress %02x-%02x-%02x-%02x-%02x-%02x\n"
  531. "RemoteNetwork %02x-%02x-%02x-%02x\n"
  532. "RemoteNode %02x-%02x-%02x-%02x-%02x-%02x\n"
  533. "RemoteSocket %04x\n"
  534. "RetransmissionCount %04x\n"
  535. "EstimatedRoundTripDelay %04x\n"
  536. "RetransmittedPackets %04x\n",
  537. pStats->State,
  538. pStats->WatchDog,
  539. B2LW(pStats->LocalConnectionId),
  540. B2LW(pStats->RemoteConnectionId),
  541. B2LW(pStats->LocalSequenceNumber),
  542. B2LW(pStats->LocalAckNumber),
  543. B2LW(pStats->LocalAllocNumber),
  544. B2LW(pStats->RemoteAckNumber),
  545. B2LW(pStats->RemoteAllocNumber),
  546. B2LW(pStats->LocalSocket),
  547. pStats->ImmediateAddress[0] & 0xff,
  548. pStats->ImmediateAddress[1] & 0xff,
  549. pStats->ImmediateAddress[2] & 0xff,
  550. pStats->ImmediateAddress[3] & 0xff,
  551. pStats->ImmediateAddress[4] & 0xff,
  552. pStats->ImmediateAddress[5] & 0xff,
  553. pStats->RemoteNetwork[0] & 0xff,
  554. pStats->RemoteNetwork[1] & 0xff,
  555. pStats->RemoteNetwork[2] & 0xff,
  556. pStats->RemoteNetwork[3] & 0xff,
  557. pStats->RemoteNode[0] & 0xff,
  558. pStats->RemoteNode[1] & 0xff,
  559. pStats->RemoteNode[2] & 0xff,
  560. pStats->RemoteNode[3] & 0xff,
  561. pStats->RemoteNode[4] & 0xff,
  562. pStats->RemoteNode[5] & 0xff,
  563. B2LW(pStats->RemoteSocket),
  564. B2LW(pStats->RetransmissionCount),
  565. B2LW(pStats->EstimatedRoundTripDelay),
  566. B2LW(pStats->RetransmittedPackets)
  567. );
  568. VwLog(buf);
  569. }
  570. VOID VwLog(LPSTR buf) {
  571. IF_DEBUG(NOTHING) {
  572. return;
  573. }
  574. IF_DEBUG(TO_FILE) {
  575. fputs(buf, hVwDebugLog);
  576. IF_DEBUG(FLUSH) {
  577. fflush(hVwDebugLog);
  578. }
  579. } else IF_DEBUG(TO_DBG) {
  580. OutputDebugString(buf);
  581. }
  582. }
  583. VOID CheckInterrupts(LPSTR name) {
  584. IF_DEBUG(CHECK_INT) {
  585. LPWORD pDosIntFlag = (LPWORD)GET_POINTER(0x40, 0x314, 2, FALSE);
  586. if ((getIF() == 0) || !(*pDosIntFlag & 0x200)) {
  587. IPXDBGPRINT((__FILE__, __LINE__,
  588. FUNCTION_ANY,
  589. IPXDBG_LEVEL_ERROR,
  590. "*** CheckInterrupts: ints off in %s (IF=%d, 40:314=%04x)\n",
  591. name,
  592. getIF(),
  593. *pDosIntFlag
  594. ));
  595. }
  596. }
  597. }
  598. extern LPCONNECTION_INFO ConnectionList ;
  599. extern LPSOCKET_INFO SocketList ;
  600. VOID VwDumpAll(VOID)
  601. {
  602. char buf[512];
  603. LPCONNECTION_INFO pConnectionInfo;
  604. LPSOCKET_INFO pSocketInfo;
  605. if (DebugFlagsEx == 0)
  606. return ;
  607. DebugFlagsEx = 0 ;
  608. RequestMutex();
  609. pSocketInfo = SocketList;
  610. while (pSocketInfo) {
  611. LPXECB pXecb ;
  612. if (!(pSocketInfo->SpxSocket)) {
  613. pSocketInfo = pSocketInfo->Next;
  614. continue ;
  615. }
  616. sprintf(buf,
  617. "%sSOCKET_INFO @ %p:\n"
  618. " SocketNumber %04x\n"
  619. " Owner %04x\n"
  620. " TaskId %08x\n"
  621. " Socket %08x\n"
  622. " Flags %08x\n"
  623. " LongLived %d\n"
  624. " PendingSends %08x\n"
  625. " PendingListens %08x\n"
  626. " ListenQueue %p, %p\n"
  627. " SendQueue %p, %p\n"
  628. " HeaderQueue %p, %p\n"
  629. " Connections %p\n\n",
  630. (pSocketInfo->SpxSocket)?"SPX ":"",
  631. pSocketInfo,
  632. B2LW(pSocketInfo->SocketNumber),
  633. pSocketInfo->Owner,
  634. pSocketInfo->TaskId,
  635. pSocketInfo->Socket,
  636. pSocketInfo->Flags,
  637. pSocketInfo->LongLived,
  638. pSocketInfo->PendingSends,
  639. pSocketInfo->PendingListens,
  640. pSocketInfo->ListenQueue.Head,
  641. pSocketInfo->ListenQueue.Tail,
  642. pSocketInfo->SendQueue.Head,
  643. pSocketInfo->SendQueue.Tail,
  644. pSocketInfo->HeaderQueue.Head,
  645. pSocketInfo->HeaderQueue.Tail,
  646. pSocketInfo->Connections
  647. );
  648. OutputDebugString(buf);
  649. pConnectionInfo = pSocketInfo->Connections ;
  650. while(pConnectionInfo) {
  651. sprintf(buf,
  652. "CONNECTION_INFO @ %p:\n"
  653. " List %p\n"
  654. " OwningSocket %p\n"
  655. " Socket %08x\n"
  656. " TaskId %08x\n"
  657. " ConnectionId %04x\n"
  658. " Flags %02x\n"
  659. " State %02x\n"
  660. " ConnectQueue %p, %p\n"
  661. " AcceptQueue %p, %p\n"
  662. " SendQueue %p, %p\n"
  663. " ListenQueue %p, %p\n\n",
  664. pConnectionInfo,
  665. pConnectionInfo->List,
  666. pConnectionInfo->OwningSocket,
  667. pConnectionInfo->Socket,
  668. pConnectionInfo->TaskId,
  669. pConnectionInfo->ConnectionId,
  670. pConnectionInfo->Flags,
  671. pConnectionInfo->State,
  672. pConnectionInfo->ConnectQueue.Head,
  673. pConnectionInfo->ConnectQueue.Tail,
  674. pConnectionInfo->AcceptQueue.Head,
  675. pConnectionInfo->AcceptQueue.Tail,
  676. pConnectionInfo->SendQueue.Head,
  677. pConnectionInfo->SendQueue.Tail,
  678. pConnectionInfo->ListenQueue.Head,
  679. pConnectionInfo->ListenQueue.Tail
  680. );
  681. OutputDebugString(buf);
  682. pConnectionInfo = pConnectionInfo->Next ;
  683. }
  684. pXecb = pSocketInfo->ListenQueue.Head ;
  685. while(pXecb) {
  686. sprintf(buf,
  687. " XECB @ %p: (Ecb %p)\n"
  688. " EcbAddress/EsrAddress %08x %08x\n"
  689. " Flags/RefCount %08x %08x\n"
  690. " Buffer/QueueId %p %08x\n"
  691. " OwningObject %p\n",
  692. pXecb,
  693. pXecb->Ecb,
  694. pXecb->EcbAddress,
  695. pXecb->EsrAddress,
  696. pXecb->Flags,
  697. pXecb->RefCount,
  698. pXecb->Buffer,
  699. pXecb->QueueId,
  700. pXecb->OwningObject
  701. );
  702. OutputDebugString(buf);
  703. pXecb = pXecb->Next ;
  704. }
  705. pSocketInfo = pSocketInfo->Next;
  706. }
  707. ReleaseMutex();
  708. }
  709. #endif // DBG