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.

176 lines
8.2 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // AMD64 machine implementation.
  4. //
  5. // Copyright (C) Microsoft Corporation, 2000-2002.
  6. //
  7. //----------------------------------------------------------------------------
  8. #ifndef __AMD64_MACH_HPP__
  9. #define __AMD64_MACH_HPP__
  10. //
  11. // NOTE: Be very careful when using machine-specific header files
  12. // such as nt<plat>.h. The machine implementation class is
  13. // compiled for all platforms so the nt<plat>.h file will be the
  14. // one for the build platform, not necessarily the platform
  15. // of the machine implementation. ntdbg.h contains many cross-platform
  16. // types and definitions that can be used to avoid problems.
  17. //
  18. #define AMD64_MAX_INSTRUCTION_LEN 16
  19. class Amd64MachineInfo : public BaseX86MachineInfo
  20. {
  21. public:
  22. Amd64MachineInfo(TargetInfo* Target);
  23. // MachineInfo.
  24. virtual HRESULT Initialize(void);
  25. virtual void GetSystemTypeInfo(PSYSTEM_TYPE_INFO Info);
  26. virtual void GetDefaultKdData(PKDDEBUGGER_DATA64 KdData);
  27. virtual void InitializeContext
  28. (ULONG64 Pc, PDBGKD_ANY_CONTROL_REPORT ControlReport);
  29. virtual HRESULT KdGetContextState(ULONG State);
  30. virtual HRESULT KdSetContext(void);
  31. virtual HRESULT ConvertContextFrom(PCROSS_PLATFORM_CONTEXT Context,
  32. ULONG FromSver,
  33. ULONG FromSize, PVOID From);
  34. virtual HRESULT ConvertContextTo(PCROSS_PLATFORM_CONTEXT Context,
  35. ULONG ToSver, ULONG ToSize, PVOID To);
  36. virtual void InitializeContextFlags(PCROSS_PLATFORM_CONTEXT Context,
  37. ULONG Version);
  38. virtual HRESULT GetContextFromThreadStack(ULONG64 ThreadBase,
  39. PCROSS_PLATFORM_CONTEXT Context,
  40. ULONG64 Stack);
  41. virtual HRESULT GetContextFromFiber(ProcessInfo* Process,
  42. ULONG64 FiberBase,
  43. PCROSS_PLATFORM_CONTEXT Context,
  44. BOOL Verbose);
  45. virtual HRESULT GetContextFromTrapFrame(ULONG64 TrapBase,
  46. PCROSS_PLATFORM_CONTEXT Context,
  47. BOOL Verbose);
  48. virtual void GetScopeFrameFromContext(PCROSS_PLATFORM_CONTEXT Context,
  49. PDEBUG_STACK_FRAME ScopeFrame);
  50. virtual HRESULT GetScopeFrameRegister(ULONG Reg,
  51. PDEBUG_STACK_FRAME ScopeFrame,
  52. PULONG64 Value);
  53. virtual HRESULT SetScopeFrameRegister(ULONG Reg,
  54. PDEBUG_STACK_FRAME ScopeFrame,
  55. ULONG64 Value);
  56. virtual HRESULT GetExdiContext(IUnknown* Exdi,
  57. PEXDI_CONTEXT Context,
  58. EXDI_CONTEXT_TYPE CtxType);
  59. virtual HRESULT SetExdiContext(IUnknown* Exdi,
  60. PEXDI_CONTEXT Context,
  61. EXDI_CONTEXT_TYPE CtxType);
  62. virtual void ConvertExdiContextFromContext(PCROSS_PLATFORM_CONTEXT Context,
  63. PEXDI_CONTEXT ExdiContext,
  64. EXDI_CONTEXT_TYPE CtxType);
  65. virtual void ConvertExdiContextToContext(PEXDI_CONTEXT ExdiContext,
  66. EXDI_CONTEXT_TYPE CtxType,
  67. PCROSS_PLATFORM_CONTEXT Context);
  68. virtual void ConvertExdiContextToSegDescs(PEXDI_CONTEXT ExdiContext,
  69. EXDI_CONTEXT_TYPE CtxType,
  70. ULONG Start, ULONG Count,
  71. PDESCRIPTOR64 Descs);
  72. virtual void ConvertExdiContextFromSpecial
  73. (PCROSS_PLATFORM_KSPECIAL_REGISTERS Special,
  74. PEXDI_CONTEXT ExdiContext,
  75. EXDI_CONTEXT_TYPE CtxType);
  76. virtual void ConvertExdiContextToSpecial
  77. (PEXDI_CONTEXT ExdiContext,
  78. EXDI_CONTEXT_TYPE CtxType,
  79. PCROSS_PLATFORM_KSPECIAL_REGISTERS Special);
  80. virtual int GetType(ULONG Reg);
  81. virtual HRESULT GetVal(ULONG Reg, REGVAL* Val);
  82. virtual HRESULT SetVal(ULONG Reg, REGVAL* Val);
  83. virtual void GetPC(PADDR Address);
  84. virtual void SetPC(PADDR Address);
  85. virtual void GetFP(PADDR Address);
  86. virtual void GetSP(PADDR Address);
  87. virtual ULONG64 GetArgReg(void);
  88. virtual ULONG64 GetRetReg(void);
  89. virtual ULONG GetSegRegNum(ULONG SegReg);
  90. virtual HRESULT GetSegRegDescriptor(ULONG SegReg, PDESCRIPTOR64 Desc);
  91. virtual void OutputAll(ULONG Mask, ULONG OutMask);
  92. virtual HRESULT SetAndOutputTrapFrame(ULONG64 TrapBase,
  93. PCROSS_PLATFORM_CONTEXT Context);
  94. virtual TRACEMODE GetTraceMode(void);
  95. virtual void SetTraceMode(TRACEMODE Mode);
  96. virtual BOOL IsStepStatusSupported(ULONG Status);
  97. virtual void KdUpdateControlSet
  98. (PDBGKD_ANY_CONTROL_SET ControlSet);
  99. virtual ULONG ExecutingMachine(void);
  100. virtual HRESULT SetPageDirectory(ThreadInfo* Thread,
  101. ULONG Idx, ULONG64 PageDir,
  102. PULONG NextIdx);
  103. virtual HRESULT GetVirtualTranslationPhysicalOffsets
  104. (ThreadInfo* Thread, ULONG64 Virt, PULONG64 Offsets, ULONG OffsetsSize,
  105. PULONG Levels, PULONG PfIndex, PULONG64 LastVal);
  106. virtual HRESULT GetBaseTranslationVirtualOffset(PULONG64 Offset);
  107. virtual void DecodePte(ULONG64 Pte, PULONG64 PageFrameNumber,
  108. PULONG Flags);
  109. virtual HRESULT NewBreakpoint(DebugClient* Client,
  110. ULONG Type,
  111. ULONG Id,
  112. Breakpoint** RetBp);
  113. virtual void InsertThreadDataBreakpoints(void);
  114. virtual void RemoveThreadDataBreakpoints(void);
  115. virtual ULONG IsBreakpointOrStepException(PEXCEPTION_RECORD64 Record,
  116. ULONG FirstChance,
  117. PADDR BpAddr,
  118. PADDR RelAddr);
  119. virtual void OutputFunctionEntry(PVOID RawEntry);
  120. virtual HRESULT ReadDynamicFunctionTable(ProcessInfo* Process,
  121. ULONG64 Table,
  122. PULONG64 NextTable,
  123. PULONG64 MinAddress,
  124. PULONG64 MaxAddress,
  125. PULONG64 BaseAddress,
  126. PULONG64 TableData,
  127. PULONG TableSize,
  128. PWSTR OutOfProcessDll,
  129. PCROSS_PLATFORM_DYNAMIC_FUNCTION_TABLE RawTable);
  130. virtual PVOID FindDynamicFunctionEntry(PCROSS_PLATFORM_DYNAMIC_FUNCTION_TABLE Table,
  131. ULONG64 Address,
  132. PVOID TableData,
  133. ULONG TableSize);
  134. virtual HRESULT GetUnwindInfoBounds(ProcessInfo* Process,
  135. ULONG64 TableBase,
  136. PVOID RawTableEntries,
  137. ULONG EntryIndex,
  138. PULONG64 Start,
  139. PULONG Size);
  140. virtual HRESULT ReadKernelProcessorId
  141. (ULONG Processor, PDEBUG_PROCESSOR_IDENTIFICATION_ALL Id);
  142. // Amd64MachineInfo.
  143. static HRESULT StaticGetExdiContext(IUnknown* Exdi, PEXDI_CONTEXT Context,
  144. EXDI_CONTEXT_TYPE CtxType);
  145. BOOL IsIa32CodeSegment(void)
  146. {
  147. return GetReg16(AMD64_CS) == m_Target->m_KdDebuggerData.Gdt64R3CmCode;
  148. }
  149. };
  150. extern BOOL g_Amd64InCode64;
  151. #endif // #ifndef __AMD64_MACH_HPP__