Skip to content

Commit 5a9ea9c

Browse files
committed
Perl debugger GUI update
1 parent 45d9e1d commit 5a9ea9c

File tree

3 files changed

+114
-5
lines changed

3 files changed

+114
-5
lines changed

REQUIREMENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Compile-time Requirements
2-
GCC compiler and Qt 5.1 - 5.5 headers (including ``QtWebkit`` headers).
3-
The ``QtWebkit`` set of classes is deprecated and removed from all later versions of Qt.
4-
Compiling ``QtWebKit`` for a recent Qt version is possible, but this approach is resource-intensive and is not tested with the PEB sources.
2+
GCC compiler and Qt 5.1 - 5.5 headers (including ``QtWebKit`` headers).
3+
The ``QtWebKit`` set of classes is deprecated and removed from all later versions of Qt.
4+
Compiling ``QtWebKit`` for a recent Qt version is possible, but this approach is not tested with the PEB sources.
55

66
Compiled and tested successfully using:
77
* [Qt Creator 2.8.1 and Qt 5.1.1](http://download.qt.io/official_releases/qt/5.1/5.1.1/) on 32-bit Debian Linux,

src/perl-debugger-handler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public slots:
5050
.queryItemValue("command", QUrl::FullyDecoded);
5151
debuggerCommand.replace("+", " ");
5252

53-
// Clean any previous debugger output:
54-
debuggerAccumulatedOutput = "";
53+
// // Clean any previous debugger output:
54+
// debuggerAccumulatedOutput = "";
5555

5656
if (debuggerHandler.isOpen()) {
5757
if (debuggerCommand.length() > 0) {
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
Perl Executing Browser
3+
4+
This program is free software;
5+
you can redistribute it and/or modify it under the terms of the
6+
GNU Lesser General Public License,
7+
as published by the Free Software Foundation;
8+
either version 3 of the License, or (at your option) any later version.
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY;
11+
without even the implied warranty of MERCHANTABILITY or
12+
FITNESS FOR A PARTICULAR PURPOSE.
13+
Dimitar D. Mitov, 2013 - 2017
14+
Valcho Nedelchev, 2014 - 2016
15+
https://github.com/ddmitov/perl-executing-browser
16+
*/
17+
18+
#ifndef PERLDEBUGGERHANDLER_H
19+
#define PERLDEBUGGERHANDLER_H
20+
21+
#include <QApplication>
22+
#include <QDir>
23+
#include <QDateTime>
24+
#include <QDebug>
25+
#include <QFileDialog>
26+
#include <QInputDialog>
27+
#include <QProcess>
28+
#include <QUrl>
29+
#include <QUrlQuery>
30+
31+
// ==============================
32+
// PERL DEBUGGER HANDLER CONSTRUCTOR:
33+
// Implementation of an idea proposed by Valcho Nedelchev
34+
// ==============================
35+
class QPerlDebuggerHandler : public QObject
36+
{
37+
Q_OBJECT
38+
39+
signals:
40+
void startDebuggerFormatterSignal(QUrl debuggerOutputFormatterUrl,
41+
QByteArray debuggerOutputArray);
42+
43+
public slots:
44+
void qHandleDebuggerSlot(QUrl url)
45+
{
46+
// Get a Perl debugger command:
47+
QUrlQuery scriptQuery(url);
48+
49+
QString debuggerCommand = scriptQuery
50+
.queryItemValue("command", QUrl::FullyDecoded);
51+
debuggerCommand.replace("+", " ");
52+
53+
if (debuggerHandler.isOpen()) {
54+
if (debuggerCommand.length() > 0) {
55+
qDebug() << QDateTime::currentMSecsSinceEpoch()
56+
<< "msecs from epoch: Perl debugger command:"
57+
<< debuggerCommand;
58+
59+
QByteArray debuggerCommandArray;
60+
debuggerCommandArray.append(debuggerCommand.toLatin1());
61+
debuggerCommandArray.append(QString("\n").toLatin1());
62+
debuggerHandler.write(debuggerCommandArray);
63+
}
64+
}
65+
}
66+
67+
void qDebuggerOutputSlot()
68+
{
69+
// Read debugger output:
70+
QString debuggerOutput = debuggerHandler.readAllStandardOutput();
71+
72+
// Append last output of the debugger to
73+
// the accumulated debugger output:
74+
debuggerAccumulatedOutput.append(debuggerOutput);
75+
76+
// qDebug() << QDateTime::currentMSecsSinceEpoch()
77+
// << "msecs from epoch:"
78+
// << "Perl debugger raw output:" << endl
79+
// << debuggerOutput;
80+
81+
// Formatting of Perl debugger output is started only after
82+
// the final command prompt comes out of the debugger:
83+
if (debuggerAccumulatedOutput.contains(QRegExp ("DB\\<\\d{1,5}\\>"))) {
84+
85+
QString debuggerOutputFormatterFilePath =
86+
"http://" +
87+
QString(qApp->property("pseudoDomain").toString()) +
88+
"/perl5dbgui/perl5dbgui.pl";
89+
90+
QByteArray debuggerOutputArray;
91+
debuggerOutputArray.append(debuggerAccumulatedOutput.toLatin1());
92+
93+
94+
startDebuggerFormatterSignal(QUrl(debuggerOutputFormatterFilePath),
95+
debuggerOutputArray);
96+
97+
// Clean any previous debugger output:
98+
debuggerAccumulatedOutput = "";
99+
}
100+
}
101+
private:
102+
QProcess debuggerHandler;
103+
QString debuggerAccumulatedOutput;
104+
105+
public:
106+
QPerlDebuggerHandler();
107+
};
108+
109+
#endif // PERLDEBUGGERHANDLER_H

0 commit comments

Comments
 (0)