JsrtDebugManager.h 4.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #include "../Runtime/Debug/RuntimeDebugPch.h"
  7. #include "JsrtDebuggerObject.h"
  8. #include "JsrtDebugEventObject.h"
  9. class JsrtDebugManager : public Js::HaltCallback, public Js::DebuggerOptionsCallback, public HostDebugContext
  10. {
  11. public:
  12. JsrtDebugManager(ThreadContext* threadContext);
  13. ~JsrtDebugManager();
  14. void SetDebugEventCallback(JsDiagDebugEventCallback debugEventCallback, void* callbackState);
  15. void* GetAndClearCallbackState();
  16. bool IsDebugEventCallbackSet() const;
  17. #if ENABLE_TTD
  18. void ReportScriptCompile_TTD(Js::FunctionBody* body, Js::Utf8SourceInfo* utf8SourceInfo, CompileScriptException* compileException, bool notify);
  19. #endif
  20. void ReportScriptCompile(Js::JavascriptFunction* scriptFunction, Js::Utf8SourceInfo* utf8SourceInfo, CompileScriptException* compileException);
  21. void ReportBreak(Js::InterpreterHaltState* haltState);
  22. void ReportExceptionBreak(Js::InterpreterHaltState* haltState);
  23. void HandleResume(Js::InterpreterHaltState* haltState, BREAKRESUMEACTION resumeAction);
  24. void SetResumeType(BREAKRESUMEACTION resumeAction);
  25. bool EnableAsyncBreak(Js::ScriptContext* scriptContext);
  26. void CallDebugEventCallback(JsDiagDebugEvent debugEvent, Js::DynamicObject* eventDataObject, Js::ScriptContext* scriptContext, bool isBreak);
  27. void CallDebugEventCallbackForBreak(JsDiagDebugEvent debugEvent, Js::DynamicObject* eventDataObject, Js::ScriptContext* scriptContext);
  28. Js::JavascriptArray* GetScripts(Js::ScriptContext* scriptContext);
  29. Js::DynamicObject* GetScript(Js::Utf8SourceInfo* utf8SourceInfo);
  30. Js::DynamicObject* GetSource(Js::ScriptContext* scriptContext, uint scriptId);
  31. Js::JavascriptArray* GetStackFrames(Js::ScriptContext* scriptContext);
  32. bool TryGetFrameObjectFromFrameIndex(Js::ScriptContext *scriptContext, uint frameIndex, JsrtDebuggerStackFrame ** debuggerStackFrame);
  33. Js::DynamicObject* SetBreakPoint(Js::ScriptContext* scriptContext, Js::Utf8SourceInfo* utf8SourceInfo, UINT lineNumber, UINT columnNumber);
  34. void GetBreakpoints(Js::JavascriptArray** bpsArray, Js::ScriptContext* scriptContext);
  35. #if ENABLE_TTD
  36. Js::BreakpointProbe* SetBreakpointHelper_TTD(int64 desiredBpId, Js::ScriptContext* scriptContext, Js::Utf8SourceInfo* utf8SourceInfo, UINT lineNumber, UINT columnNumber, BOOL* isNewBP);
  37. #endif
  38. JsrtDebuggerObjectsManager* GetDebuggerObjectsManager();
  39. void ClearDebuggerObjects();
  40. ArenaAllocator* GetDebugObjectArena();
  41. JsrtDebugDocumentManager* GetDebugDocumentManager();
  42. void ClearDebugDocument(Js::ScriptContext* scriptContext);
  43. void ClearBreakpointDebugDocumentDictionary();
  44. bool RemoveBreakpoint(UINT breakpointId);
  45. void SetBreakOnException(JsDiagBreakOnExceptionAttributes exceptionAttributes);
  46. JsDiagBreakOnExceptionAttributes GetBreakOnException();
  47. JsDiagDebugEvent GetDebugEventFromStopType(Js::StopType stopType);
  48. ThreadContext* GetThreadContext() const { return this->threadContext; }
  49. private:
  50. ThreadContext* threadContext;
  51. JsDiagDebugEventCallback debugEventCallback;
  52. void* callbackState;
  53. BREAKRESUMEACTION resumeAction;
  54. ArenaAllocator* debugObjectArena;
  55. JsrtDebuggerObjectsManager* debuggerObjectsManager;
  56. JsrtDebugDocumentManager* debugDocumentManager;
  57. JsrtDebugStackFrames* stackFrames;
  58. JsDiagBreakOnExceptionAttributes breakOnExceptionAttributes;
  59. // Js::HaltCallback overrides
  60. virtual bool CanHalt(Js::InterpreterHaltState* pHaltState);
  61. virtual void DispatchHalt(Js::InterpreterHaltState* pHaltState);
  62. virtual void CleanupHalt() sealed;
  63. virtual bool CanAllowBreakpoints();
  64. virtual bool IsInClosedState();
  65. // Js::DebuggerOptionsCallback overrides
  66. virtual bool IsExceptionReportingEnabled();
  67. virtual bool IsFirstChanceExceptionEnabled();
  68. // HostDebugContext overrides
  69. virtual void Delete() {}
  70. DWORD_PTR GetHostSourceContext(Js::Utf8SourceInfo* sourceInfo) { return Js::Constants::NoHostSourceContext; }
  71. HRESULT SetThreadDescription(__in LPCWSTR url) { return S_OK; }
  72. HRESULT DbgRegisterFunction(Js::ScriptContext* scriptContext, Js::FunctionBody* functionBody, DWORD_PTR dwDebugSourceContext, LPCWSTR title);
  73. void ReParentToCaller(Js::Utf8SourceInfo* sourceInfo) {}
  74. };