IDebugger.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using MoonSharp.Interpreter.Execution.VM;
  6. namespace MoonSharp.Interpreter.Debugging
  7. {
  8. /// <summary>
  9. /// Interface for debuggers to implement, in order to provide debugging facilities to Scripts.
  10. /// </summary>
  11. public interface IDebugger
  12. {
  13. /// <summary>
  14. /// Called by the script engine when a source code is added or changed.
  15. /// </summary>
  16. /// <param name="sourceCode">The source code object.</param>
  17. void SetSourceCode(SourceCode sourceCode);
  18. /// <summary>
  19. /// Called by the script engine when the bytecode changes.
  20. /// </summary>
  21. /// <param name="byteCode">The bytecode source</param>
  22. void SetByteCode(string[] byteCode);
  23. /// <summary>
  24. /// Called by the script engine at execution time to check if a break has
  25. /// been requested. Should return pretty fast as it's called A LOT.
  26. /// </summary>
  27. bool IsPauseRequested();
  28. /// <summary>
  29. /// Called by the script engine when a runtime error occurs.
  30. /// The debugger can return true to signal the engine that it wants to break
  31. /// into the source of the error. If it does so, it should also return true
  32. /// to subsequent calls to IsPauseRequested().
  33. /// </summary>
  34. /// <param name="ex">The runtime exception.</param>
  35. /// <returns>True if this error should break execution.</returns>
  36. bool SignalRuntimeException(ScriptRuntimeException ex);
  37. /// <summary>
  38. /// Called by the script engine to get what action to do next.
  39. /// </summary>
  40. /// <param name="ip">The instruction pointer in bytecode.</param>
  41. /// <param name="sourceref">The source reference.</param>
  42. /// <returns>T</returns>
  43. DebuggerAction GetAction(int ip, SourceRef sourceref);
  44. /// <summary>
  45. /// Called by the script engine when the execution ends.
  46. /// </summary>
  47. void SignalExecutionEnded();
  48. /// <summary>
  49. /// Called by the script engine to update watches of a given type. Note
  50. /// that this method is not called only for watches in the strictest term,
  51. /// but also for the stack, etc.
  52. /// </summary>
  53. /// <param name="watchType">Type of the watch.</param>
  54. /// <param name="items">The items.</param>
  55. void Update(WatchType watchType, IEnumerable<WatchItem> items);
  56. /// <summary>
  57. /// Called by the script engine to get which expressions are active
  58. /// watches in the debugger.
  59. /// </summary>
  60. /// <returns>A list of watches</returns>
  61. List<DynamicExpression> GetWatchItems();
  62. /// <summary>
  63. /// Called by the script engine to refresh the breakpoint list.
  64. /// </summary>
  65. void RefreshBreakpoints(IEnumerable<SourceRef> refs);
  66. }
  67. }