WSF
ScriptDebugger.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2016 Infoscitex, a DCS Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef SCRIPTDEBUGGER_HPP
13#define SCRIPTDEBUGGER_HPP
14
15#include <vector>
16
17#include "TextSource.hpp"
20
21namespace wizard
22{
23
25{
26public:
33
35 {
36 public:
38
39 bool operator==(const Breakpoint& aRhs) const
40 {
41 return mId == aRhs.mId && mPosition == aRhs.mPosition && mPath == aRhs.mPath &&
42 mCondition == aRhs.mCondition && mIsEnabled == aRhs.mIsEnabled;
43 }
44 int mId; // unique ID for the breakpoint
45 size_t mPosition = ut::npos; // character position of the breakpoint
46 TextSource* mSourcePtr = nullptr; // pointer to the Text Source
47 std::string mPath; // path of the file name the breakpoint is in
48 std::string mCondition;
49 size_t mActualLine = ut::npos; // line the breakpoint is on after the debugger assigns it to an instruction
50 // -1 if the breakpoint is not yet active
51 bool mToggleLocked = false; // controls if breakpoint is able to be toggled
52 bool mWasUserEnabled = false; // saved state of breakpoint before debug modifications
53
54 bool IsEnabled() const noexcept { return mIsEnabled; }
55
56 void SetIsEnabled(bool aIsEnabled)
57 {
58 if (!mToggleLocked)
59 {
60 mIsEnabled = aIsEnabled;
61 }
62 }
63
64 size_t GetLine() const
65 {
66 if (mSourcePtr != nullptr)
67 {
68 return mSourcePtr->PositionToLineNumber(mPosition);
69 }
70 return 0;
71 }
72
73 void SetPositionByLineNumber(size_t aLine)
74 {
75 if (mSourcePtr != nullptr)
76 {
77 mPosition = mSourcePtr->GetLinePosition(aLine);
78 }
79 else
80 {
81 mPosition = 0;
82 }
83 }
84
85 private:
86 bool mIsEnabled = true;
87 };
88
89 virtual ~ScriptDebugger() = default;
90
91 virtual void StepInto() = 0;
92 virtual void StepOut() = 0;
93 virtual void StepOver() = 0;
94 virtual void Resume() = 0;
96 virtual void ForceDetatch() = 0;
97 virtual std::vector<CallstackEntry>& Callstack() = 0;
98 virtual const CallstackEntry* CurrentCallFrame() = 0;
99 virtual int CurrentCallFrameIndex() const = 0;
101 virtual ScriptInfo* FindScriptInfo(int64_t aScriptHandle) = 0;
102 virtual void SelectStackFrame(int aFrameIndex) = 0;
103 virtual bool IsAtBreak() const = 0;
104 virtual int BreakSequenceNumber() = 0;
105};
106
107} // namespace wizard
108
109#endif
Definition WsfXIO_Connection.hpp:37
size_t mActualLine
Definition ScriptDebugger.hpp:49
std::string mPath
Definition ScriptDebugger.hpp:47
void SetIsEnabled(bool aIsEnabled)
Definition ScriptDebugger.hpp:56
size_t mPosition
Definition ScriptDebugger.hpp:45
bool mWasUserEnabled
Definition ScriptDebugger.hpp:52
int mId
Definition ScriptDebugger.hpp:44
bool operator==(const Breakpoint &aRhs) const
Definition ScriptDebugger.hpp:39
TextSource * mSourcePtr
Definition ScriptDebugger.hpp:46
std::string mCondition
Definition ScriptDebugger.hpp:48
bool IsEnabled() const noexcept
Definition ScriptDebugger.hpp:54
bool mToggleLocked
Definition ScriptDebugger.hpp:51
size_t GetLine() const
Definition ScriptDebugger.hpp:64
void SetPositionByLineNumber(size_t aLine)
Definition ScriptDebugger.hpp:73
Definition ScriptDebugger.hpp:25
virtual ScriptInfo * FindScriptInfo(int64_t aScriptHandle)=0
virtual bool IsAtBreak() const =0
virtual void Resume()=0
virtual void StepInto()=0
virtual int CurrentCallFrameIndex() const =0
virtual const CallstackEntry * CurrentCallFrame()=0
virtual void SelectStackFrame(int aFrameIndex)=0
virtual void ForceDetatch()=0
virtual std::vector< CallstackEntry > & Callstack()=0
virtual WsfXIO_Connection * Connection()=0
virtual ~ScriptDebugger()=default
virtual void StepOut()=0
virtual int BreakSequenceNumber()=0
virtual void StepOver()=0
WsfXIO_RequestScriptDataResponsePkt::ScriptDetails ScriptInfo
Definition ScriptDebugger.hpp:100
Definition TextSource.hpp:48
Definition Runner.hpp:22
Definition WsfXIO_PacketRegistry.hpp:1613
Definition ScriptDebugger.hpp:28
size_t mLineNumber
Definition ScriptDebugger.hpp:31
int64_t mScriptHandle
Definition ScriptDebugger.hpp:29
TextSource * mSourcePtr
Definition ScriptDebugger.hpp:30
Copyrights Multiple, All Rights Reserved