6#include <private/qqmldebugconnector_p.h>
7#include <private/qv4debugging_p.h>
8#include <private/qv4engine_p.h>
9#include <private/qv4debugging_p.h>
10#include <private/qv4script_p.h>
11#include <private/qv4string_p.h>
12#include <private/qv4objectiterator_p.h>
13#include <private/qv4identifierhash_p.h>
14#include <private/qv4runtime_p.h>
15#include <private/qversionedpacket_p.h>
16#include <private/qqmldebugserviceinterfaces_p.h>
17#include <private/qv4identifiertable_p.h>
19#include <QtQml/qjsengine.h>
20#include <QtCore/qjsonarray.h>
21#include <QtCore/qjsondocument.h>
22#include <QtCore/qjsonobject.h>
23#include <QtCore/qjsonvalue.h>
24#include <QtCore/qvector.h>
25#include <QtCore/qpointer.h>
28#define TRACE_PROTOCOL(s)
57 return a.lineNumber ==
b.lineNumber &&
a.fileName ==
b.fileName
58 &&
a.enabled ==
b.enabled &&
a.condition ==
b.condition
59 &&
a.ignoreCount ==
b.ignoreCount;
128 bp.lineNumber =
line;
157 return m_pauseRequested
159 || m_stepping >= StepOver;
174 void handleDebuggerDeleted(
QObject *debugger);
177 bool checkCondition(
const QString &expression);
190 void handleContinue(
QJsonObject *reponse, Speed speed);
194 bool reallyHitTheBreakPoint(
const QV4::Function *function,
int lineNumber);
200 bool m_pauseRequested;
206bool NativeDebugger::checkCondition(
const QString &expression)
210 return r->booleanValue();
224 script.strictMode = function->
isStrict();
227 script.inheritContext =
true;
232 script.run(thisObject);
238 m_runningJob =
false;
243 : m_returnedValue(
engine,
QV4::Value::undefinedValue())
245 m_stepping = NotStepping;
246 m_pauseRequested =
false;
247 m_runningJob =
false;
263 for (
const QString &
signal : std::as_const(breakOnSignals)) {
264 if (
signal == signalName) {
281 handleContinue(response, StepIn);
283 handleContinue(response, StepOut);
285 handleContinue(response, StepOver);
287 handleContinue(response, NotStepping);
322 int line =
f->lineNumber();
325 frameArray.push_back(
frame);
327 f =
f->parentFrame();
345 dict.insert(
QStringLiteral(
"type"), typeString->toQStringNoThrow());
347 switch (
value.type()) {
397 if (!
name->isValid())
399 if (
name->isStringOrSymbol()) {
462 v = callContext->getProperty(propName);
506 m_runningJob =
false;
507 if (
result->isUndefined()) {
543void NativeDebugger::pause()
545 m_pauseRequested =
true;
548void NativeDebugger::handleContinue(
QJsonObject *response, Speed speed)
564 if (m_stepping == StepOver) {
570 if (m_stepping == StepIn) {
575 if (m_pauseRequested) {
576 m_pauseRequested =
false;
585 if (reallyHitTheBreakPoint(function, lineNumber))
596 if (m_stepping == StepIn) {
606 if (m_stepping != NotStepping && m_currentFrame == m_engine->
currentStackFrame) {
608 m_stepping = StepOver;
609 m_returnedValue.
set(m_engine, retVal);
635void NativeDebugger::pauseAndWait()
651bool NativeDebugger::reallyHitTheBreakPoint(
const QV4::Function *function,
int lineNumber)
655 if (bp.lineNumber == lineNumber) {
657 if (bp.fileName.endsWith(
base)) {
658 if (bp.condition.isEmpty() || checkCondition(bp.condition)) {
661 if (mbp.hitCount > mbp.ignoreCount)
678 delete m_breakHandler;
689 if (
state() == Enabled)
691 m_debuggers.
append(QPointer<NativeDebugger>(debugger));
702 const auto debuggersCopy = m_debuggers;
704 if (debugger->engine() == executionEngine)
713 if (
state == Enabled) {
717 engine->setDebugger(debugger);
740 debugger->handleCommand(&response, cmd,
arguments);
746 emit messageToClient(s_key,
ba);
755 emit messageToClient(s_key,
ba);
QVector< BreakPoint > m_breakPoints
void setBreakOnThrow(bool onoff)
void removeBreakPoint(int id)
void enableBreakPoint(int id, bool onoff)
void handleRemoveBreakpoint(QJsonObject *response, const QJsonObject &arguments)
void handleSetBreakpoint(QJsonObject *response, const QJsonObject &arguments)
Collector(QV4::ExecutionEngine *engine)
void collect(QJsonArray *output, const QString &parentIName, const QString &name, const QV4::Value &value)
QV4::ExecutionEngine * m_engine
bool isExpanded(const QString &iname) const
void maybeBreakAtInstruction() override
void aboutToThrow() override
void handleCommand(QJsonObject *response, const QString &cmd, const QJsonObject &arguments)
QV4::ExecutionEngine * engine() const
NativeDebugger(QQmlNativeDebugServiceImpl *service, QV4::ExecutionEngine *engine)
void leavingFunction(const QV4::ReturnedValue &retVal) override
void enteringFunction() override
bool pauseAtNextOpportunity() const override
void signalEmitted(const QString &signal)
static QByteArray fromHex(const QByteArray &hexEncoded)
Returns a decoded copy of the hex encoded array hexEncoded.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
QByteArray toHex(char separator='\0') const
Returns a hex encoded copy of the byte array.
The QJSEngine class provides an environment for evaluating JavaScript code.
QV4::ExecutionEngine * handle() const
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
QByteArray toJson(JsonFormat format=Indented) const
void setObject(const QJsonObject &object)
Sets object as the main object of this document.
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
Parses json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it.
\inmodule QtCore\reentrant
iterator insert(const QString &key, const QJsonValue &value)
Inserts a new item with the key key and a value of value.
\inmodule QtCore\reentrant
T value(qsizetype i) const
qsizetype removeAll(const AT &t)
void append(parameter_type t)
const QByteArray & data() const
Returns a reference to the raw packet data.
virtual void stateAboutToBeChanged(State)
virtual void engineAboutToBeAdded(QJSEngine *engine)
virtual void engineAboutToBeRemoved(QJSEngine *engine)
friend class NativeDebugger
void stateAboutToBeChanged(State state) override
void engineAboutToBeRemoved(QJSEngine *engine) override
void engineAboutToBeAdded(QJSEngine *engine) override
void emitAsynchronousMessageToClient(const QJsonObject &message)
QQmlNativeDebugServiceImpl(QObject *parent)
void messageReceived(const QByteArray &message) override
~QQmlNativeDebugServiceImpl() override
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString fileName(ComponentFormattingOptions options=FullyDecoded) const
void set(ExecutionEngine *engine, const Value &value)
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
bool toBool() const
Returns the variant as a bool if the variant has userType() Bool.
list append(new Employee("Blackpool", "Stephen"))
QSet< QString >::iterator it
QList< QVariant > arguments
Combined button and popup list for selecting options.
Scoped< String > ScopedString
static struct AttrInfo attrs[]
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLuint GLsizei const GLchar * message
GLsizei const GLchar *const * string
[0]
static bool isStrict(const QmlIR::Document *doc)
static void setError(QJsonObject *response, const QString &msg)
static QString encodeFrame(QV4::CppStackFrame *f)
#define TRACE_PROTOCOL(s)
size_t qHash(const BreakPoint &b, size_t seed=0) noexcept
bool operator==(const BreakPoint &a, const BreakPoint &b)
static void decodeFrame(const QString &f, QV4::CppStackFrame **frame)
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
QLatin1StringView QLatin1String
#define QStringLiteral(str)
#define TRACE_PROTOCOL(x)
QT_BEGIN_NAMESPACE typedef uchar * output
QTextStream out(stdout)
[7]
QNetworkRequest request(url)
char * toString(const MyType &t)
[31]
\inmodule QtCore \reentrant
ReturnedValue thisObject() const
CppStackFrame * parentFrame() const
static constexpr ReturnedValue undefined()
CppStackFrame * currentStackFrame
ExecutionContext * scriptContext() const
void setDebugger(Debugging::Debugger *)
ExecutionContext * currentContext() const
Pointer< InternalClass *, 0 > internalClass
Q_QML_EXPORT ReturnedValue keyAt(uint index) const
static ReturnedValue call(ExecutionEngine *, const Value &)
QV4_NEARLY_ALWAYS_INLINE constexpr quint32 value() const