Debugger.h 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #ifdef _WIN32
  7. static const char controllerScript[] = {
  8. #include "DbgController.js.encoded"
  9. '\0'
  10. };
  11. #else
  12. static const char controllerScript[] = { '\0' };
  13. #endif
  14. class Debugger
  15. {
  16. public:
  17. static Debugger* GetDebugger(JsRuntimeHandle runtime);
  18. static void CloseDebugger();
  19. static JsRuntimeHandle GetRuntime();
  20. bool StartDebugging(JsRuntimeHandle runtime);
  21. bool StopDebugging(JsRuntimeHandle runtime);
  22. bool HandleDebugEvent(JsDiagDebugEvent debugEvent, JsValueRef eventData);
  23. bool CompareOrWriteBaselineFile(LPCSTR fileName);
  24. bool SourceRunDown();
  25. bool DumpFunctionPosition(JsValueRef functionPosition);
  26. bool IsDetached() const { return m_isDetached; }
  27. private:
  28. Debugger(JsRuntimeHandle runtime);
  29. ~Debugger();
  30. bool Initialize();
  31. JsRuntimeHandle m_runtime;
  32. JsContextRef m_context;
  33. bool m_isDetached;
  34. bool InstallDebugCallbacks(JsValueRef hostDebugObject);
  35. bool SetBaseline();
  36. bool SetInspectMaxStringLength();
  37. bool CallFunction(char const * functionName, JsValueRef *result, JsValueRef arg1 = JS_INVALID_REFERENCE, JsValueRef arg2 = JS_INVALID_REFERENCE);
  38. bool CallFunctionNoResult(char const * functionName, JsValueRef arg1 = JS_INVALID_REFERENCE, JsValueRef arg2 = JS_INVALID_REFERENCE);
  39. public:
  40. static void CALLBACK DebugEventHandler(_In_ JsDiagDebugEvent debugEvent, _In_ JsValueRef eventData, _In_opt_ void* callbackState);
  41. static JsValueRef CALLBACK GetSource(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  42. static JsValueRef CALLBACK SetBreakpoint(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  43. static JsValueRef CALLBACK GetStackTrace(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  44. static JsValueRef CALLBACK GetBreakpoints(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  45. static JsValueRef CALLBACK RemoveBreakpoint(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  46. static JsValueRef CALLBACK SetBreakOnException(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  47. static JsValueRef CALLBACK GetBreakOnException(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  48. static JsValueRef CALLBACK SetStepType(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  49. static JsValueRef CALLBACK GetScripts(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  50. static JsValueRef CALLBACK GetStackProperties(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  51. static JsValueRef CALLBACK GetProperties(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  52. static JsValueRef CALLBACK GetObjectFromHandle(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  53. static JsValueRef CALLBACK Evaluate(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState);
  54. static Debugger* debugger;
  55. };