diff options
Diffstat (limited to 'examples/debugger/main.cpp')
-rw-r--r-- | examples/debugger/main.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/examples/debugger/main.cpp b/examples/debugger/main.cpp new file mode 100644 index 0000000..3d21995 --- /dev/null +++ b/examples/debugger/main.cpp @@ -0,0 +1,47 @@ +#include <QtGui> +#include <QtScript> +#include <QtNetwork> +#include "qscriptremotetargetdebugger.h" + +void qScriptDebugRegisterMetaTypes(); + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QHostAddress addr(QHostAddress::LocalHost); + quint16 port = 2000; + bool listen = false; + for (int i = 1; i < argc; ++i) { + QString arg(argv[i]); + arg = arg.trimmed(); + if(arg.startsWith("--")) { + QString opt; + QString val; + int split = arg.indexOf("="); + if(split > 0) { + opt = arg.mid(2).left(split-2); + val = arg.mid(split + 1).trimmed(); + } else { + opt = arg.mid(2); + } + if (opt == QLatin1String("address")) + addr.setAddress(val); + else if (opt == QLatin1String("port")) + port = val.toUShort(); + else if (opt == QLatin1String("listen")) + listen = true; + else if (opt == QLatin1String("help")) { + fprintf(stdout, "Usage: remote --address=ADDR --port=NUM [--listen]\n"); + return(-1); + } + } + } + + qScriptDebugRegisterMetaTypes(); + QScriptRemoteTargetDebugger debugger; + qDebug("attaching to %s:%d", qPrintable(addr.toString()), port); + debugger.attachTo(addr, port); + + return app.exec(); +} |