aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <qtc-committer@nokia.com>2009-08-18 11:23:01 +0200
committercon <qtc-committer@nokia.com>2009-08-19 10:01:36 +0200
commit7c5e824ea23e9495d0afc157ad1c4bd51e4e90da (patch)
tree50b393a607ff06a0f11080eb0b5e67b89f445e72
parentf2768940e7e1098eda25a9d8534e5e89b8b6abf0 (diff)
debugger: add a simple syntax highlighter for disassembler output
(cherry picked from commit 39e1113707f9eb7155e66ef79f24955137b728f4)
-rw-r--r--src/plugins/debugger/debuggeragents.cpp31
-rw-r--r--src/plugins/debugger/debuggeroutputwindow.cpp2
-rw-r--r--src/plugins/debugger/gdb/gdbengine.cpp39
-rw-r--r--src/plugins/debugger/gdb/gdbengine.h6
4 files changed, 59 insertions, 19 deletions
diff --git a/src/plugins/debugger/debuggeragents.cpp b/src/plugins/debugger/debuggeragents.cpp
index d00bc5cf39..d74693f279 100644
--- a/src/plugins/debugger/debuggeragents.cpp
+++ b/src/plugins/debugger/debuggeragents.cpp
@@ -44,6 +44,7 @@
#include <QtGui/QPlainTextEdit>
#include <QtGui/QTextCursor>
+#include <QtGui/QSyntaxHighlighter>
#include <limits.h>
@@ -144,6 +145,30 @@ struct DisassemblerViewAgentPrivate
};
/*!
+ \class DisassemblerSyntaxHighlighter
+
+ Simple syntax highlighter to make the disassembler text less prominent.
+*/
+
+class DisassemblerHighlighter : public QSyntaxHighlighter
+{
+public:
+ DisassemblerHighlighter(QPlainTextEdit *parent)
+ : QSyntaxHighlighter(parent->document())
+ {}
+
+private:
+ void highlightBlock(const QString &text)
+ {
+ if (!text.isEmpty() && text.at(0) != ' ') {
+ QTextCharFormat format;
+ format.setForeground(QColor(128, 128, 128));
+ setFormat(0, text.size(), format);
+ }
+ }
+};
+
+/*!
\class DisassemblerViewAgent
Objects from this class are created in response to user actions in
@@ -177,6 +202,7 @@ void DisassemblerViewAgent::setContents(const QString &contents)
using namespace Core;
using namespace TextEditor;
+ QPlainTextEdit *plainTextEdit = 0;
EditorManager *editorManager = EditorManager::instance();
if (!d->editor) {
QString titlePattern = "Disassembler";
@@ -184,12 +210,13 @@ void DisassemblerViewAgent::setContents(const QString &contents)
editorManager->openEditorWithContents(
Core::Constants::K_DEFAULT_TEXT_EDITOR,
&titlePattern));
+ if ((plainTextEdit = qobject_cast<QPlainTextEdit *>(d->editor->widget())))
+ (void) new DisassemblerHighlighter(plainTextEdit);
}
editorManager->activateEditor(d->editor);
- QPlainTextEdit *plainTextEdit =
- qobject_cast<QPlainTextEdit *>(d->editor->widget());
+ plainTextEdit = qobject_cast<QPlainTextEdit *>(d->editor->widget());
if (plainTextEdit)
plainTextEdit->setPlainText(contents);
diff --git a/src/plugins/debugger/debuggeroutputwindow.cpp b/src/plugins/debugger/debuggeroutputwindow.cpp
index 798a1ff15e..54e1b1b141 100644
--- a/src/plugins/debugger/debuggeroutputwindow.cpp
+++ b/src/plugins/debugger/debuggeroutputwindow.cpp
@@ -260,7 +260,7 @@ public:
CombinedPane(QWidget *parent)
: DebuggerPane(parent)
{
- (void)new OutputHighlighter(this);
+ (void) new OutputHighlighter(this);
}
public slots:
diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp
index 0e8dcf448b..2d9842cb9f 100644
--- a/src/plugins/debugger/gdb/gdbengine.cpp
+++ b/src/plugins/debugger/gdb/gdbengine.cpp
@@ -1256,6 +1256,19 @@ void GdbEngine::handleAsyncOutput2(const GdbMi &data)
{
qq->notifyInferiorStopped();
+ // Sometimes we get some interesting extra information. Grab it.
+ GdbMi frame = data.findChild("frame");
+ GdbMi shortName = frame.findChild("file");
+ GdbMi fullName = frame.findChild("fullname");
+ if (shortName.isValid() && fullName.isValid()) {
+ QString file = QFile::decodeName(shortName.data());
+ QString full = QFile::decodeName(fullName.data());
+ if (file != full) {
+ m_shortToFullName[file] = full;
+ m_fullToShortName[full] = file;
+ }
+ }
+
//
// Stack
//
@@ -1263,6 +1276,7 @@ void GdbEngine::handleAsyncOutput2(const GdbMi &data)
updateLocals(); // Quick shot
int currentId = data.findChild("thread-id").data().toInt();
+
reloadStack();
if (supportsThreads())
postCommand(_("-thread-list-ids"), WatchUpdate, CB(handleStackListThreads), currentId);
@@ -1768,7 +1782,7 @@ void GdbEngine::stepExec()
setTokenBarrier();
qq->notifyInferiorRunningRequested();
if (qq->isReverseDebugging())
- postCommand(_("reverse-step"), CB(handleExecContinue));
+ postCommand(_("-reverse-step"), CB(handleExecContinue));
else
postCommand(_("-exec-step"), CB(handleExecContinue));
}
@@ -1778,7 +1792,7 @@ void GdbEngine::stepIExec()
setTokenBarrier();
qq->notifyInferiorRunningRequested();
if (qq->isReverseDebugging())
- postCommand(_("reverse-stepi"), CB(handleExecContinue));
+ postCommand(_("-reverse-stepi"), CB(handleExecContinue));
else
postCommand(_("-exec-step-instruction"), CB(handleExecContinue));
}
@@ -1795,7 +1809,7 @@ void GdbEngine::nextExec()
setTokenBarrier();
qq->notifyInferiorRunningRequested();
if (qq->isReverseDebugging())
- postCommand(_("reverse-next"), CB(handleExecContinue));
+ postCommand(_("-reverse-next"), CB(handleExecContinue));
else
postCommand(_("-exec-next"), CB(handleExecContinue));
}
@@ -1805,9 +1819,9 @@ void GdbEngine::nextIExec()
setTokenBarrier();
qq->notifyInferiorRunningRequested();
if (qq->isReverseDebugging())
- postCommand(_("reverse-nexti"), CB(handleExecContinue));
+ postCommand(_("-reverse-nexti"), CB(handleExecContinue));
else
- postCommand(_("exec-next-instruction"), CB(handleExecContinue));
+ postCommand(_("-exec-next-instruction"), CB(handleExecContinue));
}
void GdbEngine::runToLineExec(const QString &fileName, int lineNumber)
@@ -1921,9 +1935,9 @@ void GdbEngine::breakpointDataFromOutput(BreakpointData *data, const GdbMi &bkpt
else
data->bpAddress = _(child.data());
} else if (child.hasName("file")) {
- files.append(QString::fromLocal8Bit(child.data()));
+ files.append(QFile::decodeName(child.data()));
} else if (child.hasName("fullname")) {
- QString fullName = QString::fromLocal8Bit(child.data());
+ QString fullName = QFile::decodeName(child.data());
#ifdef Q_OS_WIN
fullName = QDir::cleanPath(fullName);
#endif
@@ -2446,8 +2460,8 @@ void GdbEngine::handleStackListFrames(const GdbResultRecord &record, const QVari
const GdbMi frameMi = stack.childAt(i);
StackFrame frame(i);
QStringList files;
- files.append(QString::fromLocal8Bit(frameMi.findChild("fullname").data()));
- files.append(QString::fromLocal8Bit(frameMi.findChild("file").data()));
+ files.append(QFile::decodeName(frameMi.findChild("fullname").data()));
+ files.append(QFile::decodeName(frameMi.findChild("file").data()));
frame.file = fullName(files);
frame.function = _(frameMi.findChild("func").data());
frame.from = _(frameMi.findChild("from").data());
@@ -4035,7 +4049,7 @@ static QByteArray parseLine(const GdbMi &line)
return ba;
}
-static QString parseDisassembler(const GdbMi &lines)
+QString GdbEngine::parseDisassembler(const GdbMi &lines)
{
// ^done,data={asm_insns=[src_and_asm_line={line="1243",file=".../app.cpp",
// line_asm_insn=[{address="0x08054857",func-name="main",offset="27",
@@ -4058,16 +4072,15 @@ static QString parseDisassembler(const GdbMi &lines)
if (child.hasName("src_and_asm_line")) {
// mixed mode
int line = child.findChild("line").data().toInt();
- QByteArray fileName = child.findChild("file").data();
+ QString fileName = QFile::decodeName(child.findChild("file").data());
if (!fileLoaded) {
- QFile file(QFile::decodeName(fileName));
+ QFile file(fullName(fileName));
file.open(QIODevice::ReadOnly);
fileContents = file.readAll().split('\n');
fileLoaded = true;
}
if (line >= 0 && line < fileContents.size())
ba += " " + fileContents.at(line) + '\n';
-
GdbMi insn = child.findChild("line_asm_insn");
foreach (const GdbMi &line, insn.children())
ba += parseLine(line);
diff --git a/src/plugins/debugger/gdb/gdbengine.h b/src/plugins/debugger/gdb/gdbengine.h
index e9a2b41a92..74134e8d37 100644
--- a/src/plugins/debugger/gdb/gdbengine.h
+++ b/src/plugins/debugger/gdb/gdbengine.h
@@ -144,7 +144,6 @@ private:
//
int currentFrame() const;
- //QString currentWorkingDirectory() const { return m_pwd; }
bool supportsThreads() const;
@@ -162,12 +161,12 @@ public: // otherwise the Qt flag macros are unhappy
NeedsStop = 1,
Discardable = 2,
RebuildModel = 4,
- WatchUpdate = Discardable|RebuildModel,
+ WatchUpdate = Discardable | RebuildModel,
EmbedToken = 8
};
Q_DECLARE_FLAGS(GdbCommandFlags, GdbCommandFlag)
-private:
+private:
typedef void (GdbEngine::*GdbCommandCallback)(const GdbResultRecord &record, const QVariant &cookie);
struct GdbCommand
@@ -372,6 +371,7 @@ private:
void setLocals(const QList<GdbMi> &locals);
bool startModeAllowsDumpers() const;
+ QString parseDisassembler(const GdbMi &lines);
int m_pendingRequests;