Leaked source code of windows server 2003
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.

172 lines
5.5 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Event waiting and processing.
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999-2002.
  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 TargetInfo* g_EventTarget;
  24. extern ProcessInfo* g_EventProcess;
  25. extern ThreadInfo* g_EventThread;
  26. extern MachineInfo* g_EventMachine;
  27. extern ULONG g_EventProcessSysId;
  28. extern ULONG g_EventThreadSysId;
  29. extern ULONG g_LastEventType;
  30. extern char g_LastEventDesc[MAX_IMAGE_PATH + 64];
  31. extern PVOID g_LastEventExtraData;
  32. extern ULONG g_LastEventExtraDataSize;
  33. extern LAST_EVENT_INFO g_LastEventInfo;
  34. extern ULONG64 g_TargetEventPc;
  35. extern PDEBUG_EXCEPTION_FILTER_PARAMETERS g_EventExceptionFilter;
  36. extern ULONG g_ExceptionFirstChance;
  37. extern ADDR g_EventPc;
  38. extern ADDR g_PrevEventPc;
  39. extern ADDR g_PrevRelatedPc;
  40. extern ULONG64 g_ThreadToResume;
  41. extern PUSER_DEBUG_SERVICES g_ThreadToResumeServices;
  42. extern HANDLE g_EventToSignal;
  43. extern ULONG g_SystemErrorOutput;
  44. extern ULONG g_SystemErrorBreak;
  45. extern ULONG g_ExecutionStatusRequest;
  46. extern ULONG g_PendingBreakInTimeoutLimit;
  47. extern char g_OutputCommandRedirectPrefix[];
  48. extern ULONG g_OutputCommandRedirectPrefixLen;
  49. extern PCHAR g_StateChangeData;
  50. extern PDBGKD_ANY_CONTROL_REPORT g_ControlReport;
  51. void DiscardLastEvent(void);
  52. void ClearEventLog(void);
  53. void DotEventLog(PDOT_COMMAND Cmd, DebugClient* Client);
  54. BOOL AnyEventsPossible(void);
  55. ULONG EventStatusToContinue(ULONG EventStatus);
  56. HRESULT PrepareForWait(ULONG Flags, PULONG ContinueStatus);
  57. void ProcessDeferredWork(PULONG ContinueStatus);
  58. BOOL SuspendExecution(void);
  59. HRESULT ResumeExecution(void);
  60. // PrepareForCalls must gracefully handle failures so that
  61. // it is always possible to enter call-handling mode.
  62. void PrepareForCalls(ULONG64 ExtraStatusFlags);
  63. // PrepareForExecution should report failures so that
  64. // execution is not started until command mode can be left cleanly.
  65. // This biases things towards running in command mode, which
  66. // is the right thing to do.
  67. HRESULT PrepareForExecution(ULONG NewStatus);
  68. HRESULT PrepareForSeparation(void);
  69. void FindEventProcessThread(void);
  70. ULONG MergeVotes(ULONG Cur, ULONG Vote);
  71. ULONG ProcessBreakpointOrStepException(PEXCEPTION_RECORD64 Record,
  72. ULONG FirstChance);
  73. ULONG CheckBreakpointOrStepTrace(PADDR BpAddr, ULONG BreakType);
  74. ULONG CheckStepTrace(PADDR PcAddr, ULONG DefaultStatus);
  75. void AnalyzeDeadlock(EXCEPTION_RECORD64* Exception,
  76. ULONG FirstChance);
  77. void OutputDeadlock(EXCEPTION_RECORD64* Exception,
  78. ULONG FirstChance);
  79. void GetEventName(ULONG64 ImageFile, ULONG64 ImageBase,
  80. ULONG64 NamePtr, WORD Unicode,
  81. PSTR NameBuffer, ULONG BufferSize);
  82. //----------------------------------------------------------------------------
  83. //
  84. // Event filtering.
  85. //
  86. //----------------------------------------------------------------------------
  87. extern ULONG64 g_UnloadDllBase;
  88. BOOL BreakOnThisImageTail(PCSTR ImagePath, PCSTR FilterArg);
  89. BOOL BreakOnThisDllUnload(ULONG64 DllBase);
  90. BOOL BreakOnThisOutString(PCSTR OutString);
  91. #define FILTER_MAX_ARGUMENT MAX_IMAGE_PATH
  92. #define FILTER_SPECIFIC_FIRST DEBUG_FILTER_CREATE_THREAD
  93. #define FILTER_SPECIFIC_LAST DEBUG_FILTER_DEBUGGEE_OUTPUT
  94. #define FILTER_EXCEPTION_FIRST (FILTER_SPECIFIC_LAST + 1)
  95. #define FILTER_EXCEPTION_LAST (FILTER_SPECIFIC_LAST + 25)
  96. #define FILTER_DEFAULT_EXCEPTION FILTER_EXCEPTION_FIRST
  97. #define FILTER_COUNT (FILTER_EXCEPTION_LAST + 1)
  98. #define IS_EFEXECUTION_BREAK(Execution) \
  99. ((Execution) == DEBUG_FILTER_SECOND_CHANCE_BREAK || \
  100. (Execution) == DEBUG_FILTER_BREAK)
  101. #define FILTER_CHANGED_EXECUTION 0x00000001
  102. #define FILTER_CHANGED_CONTINUE 0x00000002
  103. #define FILTER_CHANGED_COMMAND 0x00000004
  104. struct EVENT_COMMAND
  105. {
  106. DebugClient* Client;
  107. // Both first and second chances have commands.
  108. PSTR Command[2];
  109. ULONG CommandSize[2];
  110. };
  111. struct EVENT_FILTER
  112. {
  113. PCSTR Name;
  114. PCSTR ExecutionAbbrev;
  115. PCSTR ContinueAbbrev;
  116. PCSTR OutArgFormat;
  117. ULONG OutArgIndex;
  118. DEBUG_EXCEPTION_FILTER_PARAMETERS Params;
  119. EVENT_COMMAND Command;
  120. PSTR Argument;
  121. ULONG Flags;
  122. };
  123. #define OTHER_EXCEPTION_LIST_MAX 32
  124. extern EVENT_FILTER g_EventFilters[];
  125. extern DEBUG_EXCEPTION_FILTER_PARAMETERS g_OtherExceptionList[];
  126. extern EVENT_COMMAND g_OtherExceptionCommands[];
  127. extern ULONG g_NumOtherExceptions;
  128. EVENT_FILTER* GetSpecificExceptionFilter(ULONG Code);
  129. ULONG GetOtherExceptionParameters(ULONG Code, BOOL DefaultOnNotFound,
  130. PDEBUG_EXCEPTION_FILTER_PARAMETERS* Params,
  131. EVENT_COMMAND** Command);
  132. void RemoveOtherException(ULONG Index);
  133. void ParseSetEventFilter(DebugClient* Client);
  134. #define SXCMDS_ONE_LINE 0x00000001
  135. void ListFiltersAsCommands(DebugClient* Client, ULONG Flags);
  136. BOOL SyncFiltersWithOptions(void);
  137. BOOL SyncOptionsWithFilters(void);
  138. #endif // #ifndef __EVENT_H__