DebugManager.h 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace Js
  7. {
  8. struct InterpreterHaltState;
  9. class DebugManager
  10. {
  11. friend class RecyclableObjectDisplay;
  12. friend class RecyclableArrayWalker;
  13. template <typename TData> friend class RecyclableCollectionObjectWalker;
  14. template <typename TData> friend class RecyclableCollectionObjectDisplay;
  15. friend class RecyclableKeyValueDisplay;
  16. friend class ProbeContainer;
  17. private:
  18. InterpreterHaltState* pCurrentInterpreterLocation; // NULL if not Halted at a Probe
  19. DWORD_PTR secondaryCurrentSourceContext; // For resolving ambiguity among generated files, e.g. eval, anonymous, etc.
  20. ulong debugSessionNumber; // A unique number, which will be used to sync all probecontainer when on break
  21. RecyclerRootPtr<Js::DynamicObject> pConsoleScope;
  22. ThreadContext* pThreadContext;
  23. bool isAtDispatchHalt;
  24. PageAllocator diagnosticPageAllocator;
  25. int evalCodeRegistrationCount;
  26. int anonymousCodeRegistrationCount;
  27. int jscriptBlockRegistrationCount;
  28. bool isDebuggerAttaching;
  29. DebuggingFlags debuggingFlags;
  30. #if DBG
  31. void * dispatchHaltFrameAddress;
  32. #endif
  33. public:
  34. StepController stepController;
  35. AsyncBreakController asyncBreakController;
  36. PropertyId mutationNewValuePid; // Holds the property id of $newValue$ property for object mutation breakpoint
  37. PropertyId mutationPropertyNamePid; // Holds the property id of $propertyName$ property for object mutation breakpoint
  38. PropertyId mutationTypePid; // Holds the property id of $mutationType$ property for object mutation breakpoint
  39. DebugManager(ThreadContext* _pThreadContext, AllocationPolicyManager * allocationPolicyManager);
  40. ~DebugManager();
  41. void Close();
  42. DebuggingFlags* GetDebuggingFlags();
  43. bool IsAtDispatchHalt() const { return this->isAtDispatchHalt; }
  44. void SetDispatchHalt(bool set) { this->isAtDispatchHalt = set; }
  45. ReferencedArenaAdapter* GetDiagnosticArena();
  46. DWORD_PTR AllocateSecondaryHostSourceContext();
  47. void SetCurrentInterpreterLocation(InterpreterHaltState* pHaltState);
  48. void UnsetCurrentInterpreterLocation();
  49. ulong GetDebugSessionNumber() const { return debugSessionNumber; }
  50. #ifdef ENABLE_MUTATION_BREAKPOINT
  51. MutationBreakpoint* GetActiveMutationBreakpoint() const;
  52. #endif
  53. DynamicObject* GetConsoleScope(ScriptContext* scriptContext);
  54. FrameDisplay *GetFrameDisplay(ScriptContext* scriptContext, DynamicObject* scopeAtZero, DynamicObject* scopeAtOne, bool addGlobalThisAtScopeTwo);
  55. void UpdateConsoleScope(DynamicObject* copyFromScope, ScriptContext* scriptContext);
  56. PageAllocator * GetDiagnosticPageAllocator() { return &this->diagnosticPageAllocator; }
  57. #if DBG
  58. void SetDispatchHaltFrameAddress(void * returnAddress) { this->dispatchHaltFrameAddress = returnAddress; }
  59. void ValidateDebugAPICall();
  60. #endif
  61. void SetDebuggerAttaching(bool attaching) { this->isDebuggerAttaching = attaching; }
  62. bool IsDebuggerAttaching() const { return this->isDebuggerAttaching; }
  63. enum DynamicFunctionType
  64. {
  65. DFT_EvalCode,
  66. DFT_AnonymousCode,
  67. DFT_JScriptBlock
  68. };
  69. int GetNextId(DynamicFunctionType eFunc)
  70. {
  71. switch (eFunc)
  72. {
  73. case DFT_EvalCode: return ++evalCodeRegistrationCount;
  74. case DFT_AnonymousCode: return ++anonymousCodeRegistrationCount;
  75. case DFT_JScriptBlock: return ++jscriptBlockRegistrationCount;
  76. }
  77. return -1;
  78. }
  79. };
  80. }