LUAEditorDebuggerMessages.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #ifndef LUAEDITOR_LUAEditorDebuggerMessages_H
  9. #define LUAEDITOR_LUAEditorDebuggerMessages_H
  10. #include <AzCore/base.h>
  11. #include <AzCore/EBus/EBus.h>
  12. #include <AzCore/Script/ScriptContextDebug.h>
  13. #pragma once
  14. namespace LUAEditor
  15. {
  16. // these are messages going from the lua editor TO the debugger.
  17. // for messages that travel the other way, (from the debugger to the actual lua editor, see Context_DebuggerManagement in LuaEditorContextMessages.h
  18. struct TargetInfo
  19. {
  20. AZStd::string m_displayName; // the name to show the user, like "The Editor" or whatever
  21. AZ::u32 m_identifier; // CRC that uniquely identifies a target. This should remain stable across reboots so that we can remember what the last context was.
  22. // we do not allow debugging of all contexts - sometimes we can execute script but not debug.
  23. // for example, the "local" in-process editor can not debug or else we deadlock, but if its remote, we can debug.
  24. bool m_allowDebug;
  25. TargetInfo(const char* displayName = NULL, AZ::u32 identifier = 0, bool allowDebug = false)
  26. : m_displayName(displayName)
  27. , m_identifier(identifier)
  28. , m_allowDebug(allowDebug) {}
  29. };
  30. class LUAEditorDebuggerMessages
  31. : public AZ::EBusTraits
  32. {
  33. public:
  34. //////////////////////////////////////////////////////////////////////////
  35. // Bus configuration
  36. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; // we have one bus that we always broadcast to
  37. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ:: EBusHandlerPolicy::Multiple; // we can have multiple listeners???
  38. //////////////////////////////////////////////////////////////////////////
  39. typedef AZ::EBus<LUAEditorDebuggerMessages> Bus;
  40. virtual ~LUAEditorDebuggerMessages() {}
  41. // Request enumeration of available script contexts
  42. virtual void EnumerateContexts() = 0;
  43. // Request to be attached to script context
  44. virtual void AttachDebugger(const char* scriptContextName) = 0;
  45. // Request to be detached from current context
  46. virtual void DetachDebugger() = 0;
  47. // Request enumeration of classes registered in the current context
  48. virtual void EnumRegisteredClasses(const char* scriptContextName) = 0;
  49. // Request enumeration of eBuses registered in the current context
  50. virtual void EnumRegisteredEBuses(const char* scriptContextName) = 0;
  51. // Request enumeration of global methods and properties registered in the current context
  52. virtual void EnumRegisteredGlobals(const char* scriptContextName) = 0;
  53. // create a breakpoint. The debugName is the name that was given when the script was executed and represents
  54. // the 'document' (or blob of script) that the breakpoint is for. The line number is relative to the start of that blob.
  55. // the combination of line number and debug name uniquely identify a debug breakpoint.
  56. virtual void CreateBreakpoint(const AZStd::string& debugName, int lineNumber) = 0;
  57. // Remove a previously set breakpoint from the current context
  58. virtual void RemoveBreakpoint(const AZStd::string& debugName, int lineNumber) = 0;
  59. // Set over current line in current context. Can only be called while context is on a breakpoint.
  60. virtual void DebugRunStepOver() = 0;
  61. // Set into current line in current context. Can only be called while context is on a breakpoint.
  62. virtual void DebugRunStepIn() = 0;
  63. // Set out of current line in current context. Can only be called while context is on a breakpoint.
  64. virtual void DebugRunStepOut() = 0;
  65. // Stop execution in current context. Not supported.
  66. virtual void DebugRunStop() = 0;
  67. // Continue execution of current context. Can only be called while context is on a breakpoint.
  68. virtual void DebugRunContinue() = 0;
  69. // Request enumeration of local variables in current context. Can only be called while context is on a breakpoint
  70. virtual void EnumLocals() = 0;
  71. // Get value of a variable in the current context. Can only be called while context is on a breakpoint
  72. virtual void GetValue(const AZStd::string& varName) = 0;
  73. // Set value of a variable in the current context. Can only be called while context is on a breakpoint
  74. // and value should be the structure returned from a previous call to GetValue().
  75. virtual void SetValue(const AZ::ScriptContextDebug::DebugValue& value) = 0;
  76. // Request current callstack in the current context. Can only be called while context is on a breakpoint
  77. virtual void GetCallstack() = 0;
  78. };
  79. using LUAEditorDebuggerMessagesRequestBus = AZ::EBus<LUAEditorDebuggerMessages>;
  80. }
  81. #endif//LUAEDITOR_LUAEditorDebuggerMessages_H