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.

178 lines
5.7 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Event waiting and processing.
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999-2001.
  6. //
  7. //----------------------------------------------------------------------------
  8. #ifndef __EVENT_H__
  9. #define __EVENT_H__
  10. struct LAST_EVENT_INFO
  11. {
  12. union
  13. {
  14. DEBUG_LAST_EVENT_INFO_BREAKPOINT Breakpoint;
  15. DEBUG_LAST_EVENT_INFO_EXCEPTION Exception;
  16. DEBUG_LAST_EVENT_INFO_EXIT_THREAD ExitThread;
  17. DEBUG_LAST_EVENT_INFO_EXIT_PROCESS ExitProcess;
  18. DEBUG_LAST_EVENT_INFO_LOAD_MODULE LoadModule;
  19. DEBUG_LAST_EVENT_INFO_UNLOAD_MODULE UnloadModule;
  20. DEBUG_LAST_EVENT_INFO_SYSTEM_ERROR SystemError;
  21. };
  22. };
  23. extern ULONG g_EventProcessSysId;
  24. extern ULONG g_EventThreadSysId;
  25. extern ULONG g_LastEventType;
  26. extern char g_LastEventDesc[];
  27. extern PVOID g_LastEventExtraData;
  28. extern ULONG g_LastEventExtraDataSize;
  29. extern LAST_EVENT_INFO g_LastEventInfo;
  30. extern ULONG64 g_EventPc;
  31. extern PDEBUG_EXCEPTION_FILTER_PARAMETERS g_EventExceptionFilter;
  32. extern ULONG g_ExceptionFirstChance;
  33. extern ULONG64 g_ThreadToResume;
  34. extern HANDLE g_EventToSignal;
  35. extern ULONG g_SystemErrorOutput;
  36. extern ULONG g_SystemErrorBreak;
  37. extern ULONG g_ExecutionStatusRequest;
  38. extern ULONG g_PendingBreakInTimeoutLimit;
  39. extern PCHAR g_StateChangeData;
  40. extern PDBGKD_ANY_CONTROL_REPORT g_ControlReport;
  41. extern ULONG64 g_SystemRangeStart;
  42. extern ULONG64 g_SystemCallVirtualAddress;
  43. extern ULONG g_SwitchProcessor;
  44. extern KDDEBUGGER_DATA64 KdDebuggerData;
  45. extern ULONG64 g_KdDebuggerDataBlock;
  46. void DiscardLastEvent(void);
  47. void ClearEventLog(void);
  48. void OutputEventLog(void);
  49. ULONG EventStatusToContinue(ULONG EventStatus);
  50. HRESULT PrepareForWait(ULONG Flags, PULONG ContinueStatus);
  51. void ProcessDeferredWork(PULONG ContinueStatus);
  52. BOOL SuspendExecution(void);
  53. HRESULT ResumeExecution(void);
  54. // PrepareForCalls must gracefully handle failures so that
  55. // it is always possible to enter call-handling mode.
  56. void PrepareForCalls(ULONG64 ExtraStatusFlags);
  57. // PrepareForExecution should report failures so that
  58. // execution is not started until command mode can be left cleanly.
  59. // This biases things towards running in command mode, which
  60. // is the right thing to do.
  61. HRESULT PrepareForExecution(ULONG NewStatus);
  62. HRESULT PrepareForSeparation(void);
  63. void FindEventProcessThread(void);
  64. ULONG MergeVotes(ULONG Cur, ULONG Vote);
  65. ULONG ProcessBreakpointOrStepException(PEXCEPTION_RECORD64 Record,
  66. ULONG FirstChance);
  67. ULONG CheckBreakpointOrStepTrace(PADDR BpAddr, ULONG BreakType);
  68. ULONG CheckStepTrace(PADDR PcAddr, ULONG DefaultStatus);
  69. void AnalyzeDeadlock(EXCEPTION_RECORD64* Exception,
  70. ULONG FirstChance);
  71. void OutputDeadlock(EXCEPTION_RECORD64* Exception,
  72. ULONG FirstChance);
  73. void GetEventName(ULONG64 ImageFile, ULONG64 ImageBase,
  74. ULONG64 NamePtr, WORD Unicode,
  75. PSTR NameBuffer, ULONG BufferSize);
  76. DWORD64 GetKernelModuleBase(ULONG64 Address);
  77. BOOL VerifyKernelBase(BOOL LoadImage);
  78. ULONG ProcessStateChange(PDBGKD_ANY_WAIT_STATE_CHANGE StateChange,
  79. PCHAR StateChangeData);
  80. void ResetConnection(ULONG Reason);
  81. void CreateKernelProcessAndThreads(void);
  82. void AddKernelThreads(ULONG Start, ULONG Count);
  83. ULONG ProcessRunChange(ULONG HaltReason, ULONG ExceptionCode);
  84. ULONG ProcessDebugEvent(DEBUG_EVENT64* Event,
  85. ULONG PendingFlags, ULONG PendingOptions);
  86. ULONG ProcessEventException(DEBUG_EVENT64* Event);
  87. ULONG OutputEventDebugString(OUTPUT_DEBUG_STRING_INFO64* Info);
  88. //----------------------------------------------------------------------------
  89. //
  90. // Event filtering.
  91. //
  92. //----------------------------------------------------------------------------
  93. extern ULONG64 g_UnloadDllBase;
  94. BOOL BreakOnThisImageTail(PCSTR ImagePath, PCSTR FilterArg);
  95. BOOL BreakOnThisDllUnload(ULONG64 DllBase);
  96. BOOL BreakOnThisOutString(PCSTR OutString);
  97. #define FILTER_MAX_ARGUMENT MAX_IMAGE_PATH
  98. #define FILTER_SPECIFIC_FIRST DEBUG_FILTER_CREATE_THREAD
  99. #define FILTER_SPECIFIC_LAST DEBUG_FILTER_DEBUGGEE_OUTPUT
  100. #define FILTER_EXCEPTION_FIRST (FILTER_SPECIFIC_LAST + 1)
  101. #define FILTER_EXCEPTION_LAST (FILTER_SPECIFIC_LAST + 21)
  102. #define FILTER_DEFAULT_EXCEPTION FILTER_EXCEPTION_FIRST
  103. #define FILTER_COUNT (FILTER_EXCEPTION_LAST + 1)
  104. #define IS_EFEXECUTION_BREAK(Execution) \
  105. ((Execution) == DEBUG_FILTER_SECOND_CHANCE_BREAK || \
  106. (Execution) == DEBUG_FILTER_BREAK)
  107. #define FILTER_CHANGED_EXECUTION 0x00000001
  108. #define FILTER_CHANGED_CONTINUE 0x00000002
  109. #define FILTER_CHANGED_COMMAND 0x00000004
  110. struct EVENT_COMMAND
  111. {
  112. DebugClient* Client;
  113. // Both first and second chances have commands.
  114. PSTR Command[2];
  115. ULONG CommandSize[2];
  116. };
  117. struct EVENT_FILTER
  118. {
  119. PCSTR Name;
  120. PCSTR ExecutionAbbrev;
  121. PCSTR ContinueAbbrev;
  122. PCSTR OutArgFormat;
  123. ULONG OutArgIndex;
  124. DEBUG_EXCEPTION_FILTER_PARAMETERS Params;
  125. EVENT_COMMAND Command;
  126. PSTR Argument;
  127. ULONG Flags;
  128. };
  129. #define OTHER_EXCEPTION_LIST_MAX 32
  130. extern EVENT_FILTER g_EventFilters[];
  131. extern DEBUG_EXCEPTION_FILTER_PARAMETERS g_OtherExceptionList[];
  132. extern EVENT_COMMAND g_OtherExceptionCommands[];
  133. extern ULONG g_NumOtherExceptions;
  134. EVENT_FILTER* GetSpecificExceptionFilter(ULONG Code);
  135. void GetOtherExceptionParameters(ULONG Code,
  136. PDEBUG_EXCEPTION_FILTER_PARAMETERS* Params,
  137. EVENT_COMMAND** Command);
  138. void ParseSetEventFilter(DebugClient* Client);
  139. #define SXCMDS_ONE_LINE 0x00000001
  140. void ListFiltersAsCommands(DebugClient* Client, ULONG Flags);
  141. BOOL SyncFiltersWithOptions(void);
  142. BOOL SyncOptionsWithFilters(void);
  143. #endif // #ifndef __EVENT_H__