Files
seer/src/SeerGdbLogWidget.cpp
T

164 lines
3.5 KiB
C++
Raw Normal View History

2022-02-14 20:44:54 -06:00
#include "SeerGdbLogWidget.h"
2021-09-01 14:01:00 -05:00
#include "SeerUtl.h"
#include <QtWidgets/QScrollBar>
#include <QtCore/QRegExp>
2021-09-01 14:01:00 -05:00
#include <QtCore/QDebug>
2022-02-14 20:44:54 -06:00
SeerGdbLogWidget::SeerGdbLogWidget (QWidget* parent) : SeerLogWidget(parent) {
2021-09-01 14:01:00 -05:00
}
2022-02-14 20:44:54 -06:00
SeerGdbLogWidget::~SeerGdbLogWidget () {
2021-09-01 14:01:00 -05:00
}
2022-02-14 20:44:54 -06:00
void SeerGdbLogWidget::processText (const QString& text) {
2021-09-01 14:01:00 -05:00
QString str;
// Remove leading "~"
// ~"For help, type "help".
// "
2022-10-07 00:15:12 -04:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
2021-09-01 14:01:00 -05:00
if (text.front() == '~') {
2022-10-07 00:15:12 -04:00
#else
if (text.at(0) == '~') {
#endif
2021-09-01 14:01:00 -05:00
str = text.mid(1);
// Remove leading """
2022-10-07 00:15:12 -04:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
2021-09-01 14:01:00 -05:00
if (str.front() == '"') {
2022-10-07 00:15:12 -04:00
#else
if (str.at(0) == '"') {
#endif
2021-09-01 14:01:00 -05:00
str = str.mid(1);
}
// Remove trailing """
2022-10-07 00:15:12 -04:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
2021-09-01 14:01:00 -05:00
if (str.back() == '"') {
2022-10-07 00:15:12 -04:00
#else
if (str.at(str.size() - 1) == '"') {
#endif
2021-09-01 14:01:00 -05:00
str.chop(1);
}
// Remove trailing "\n"
2022-10-07 00:15:12 -04:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
2021-09-01 14:01:00 -05:00
if (str.back() == '\n') {
2022-10-07 00:15:12 -04:00
#else
if (str.at(str.size() - 1) == '\n') {
#endif
2021-09-01 14:01:00 -05:00
str.chop(1);
}
// Remove leading "&"
// &"p name
// "
2022-10-07 00:15:12 -04:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
} else if (text.front() == '&') {
#else
} else if (text.at(0) == '&') {
#endif
2021-09-01 14:01:00 -05:00
str = text.mid(1);
// Remove leading """
2022-10-07 00:15:12 -04:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
2021-09-01 14:01:00 -05:00
if (str.front() == '"') {
2022-10-07 00:15:12 -04:00
#else
if (str.at(0) == '"') {
#endif
2021-09-01 14:01:00 -05:00
str = str.mid(1);
}
// Remove trailing """
2022-10-07 00:15:12 -04:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
2021-09-01 14:01:00 -05:00
if (str.back() == '"') {
2022-10-07 00:15:12 -04:00
#else
if (str.at(str.size() - 1) == '"') {
#endif
2021-09-01 14:01:00 -05:00
str.chop(1);
}
// Remove trailing "\n"
2022-10-07 00:15:12 -04:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
2021-09-01 14:01:00 -05:00
if (str.back() == '\n') {
2022-10-07 00:15:12 -04:00
#else
if (str.at(str.size() - 1) == '\n') {
#endif
2021-09-01 14:01:00 -05:00
str.chop(1);
}
2022-10-17 17:43:09 -05:00
// Remove leading "@"
// @"memcheck monitor commands:
// "
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
} else if (text.front() == '@') {
#else
} else if (text.at(0) == '@') {
#endif
str = text.mid(1);
// Remove leading """
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
if (str.front() == '"') {
#else
if (str.at(0) == '"') {
#endif
str = str.mid(1);
}
// Remove trailing """
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
if (str.back() == '"') {
#else
if (str.at(str.size() - 1) == '"') {
#endif
str.chop(1);
}
// Remove trailing "\n"
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
if (str.back() == '\n') {
#else
if (str.at(str.size() - 1) == '\n') {
#endif
str.chop(1);
}
2021-09-01 14:01:00 -05:00
// Use string as it is.
}else{
str = text;
}
// Filter escape characters.
str = Seer::filterEscapes(str);
// Remove trailing "\n"
2022-10-07 00:15:12 -04:00
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
2021-09-01 14:01:00 -05:00
while (str.back() == '\n') {
2022-10-07 00:15:12 -04:00
#else
while (str.at(str.size() - 1) == '\n') {
#endif
2021-09-01 14:01:00 -05:00
str.chop(1);
break;
}
// Write the string to the log.
textEdit->append(str);
// If there is breakpoint message (via a manual command), ask
// for the breakpoint list to be refreshed.
//
// Breakpoint 2 at 0x403a40: file explorer.cpp, line 78.
//
if (str.contains(QRegExp("^Breakpoint ([0-9]+) at (0[xX][0-9a-fA-F]+): file (.*\\,) (line) ([0-9]+)"))) {
emit refreshBreakpointsList();
}
2021-09-01 14:01:00 -05:00
}