Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
39e11137
Commit
39e11137
authored
Aug 18, 2009
by
hjk
Browse files
debugger: add a simple syntax highlighter for disassembler output
parent
06140f9c
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/plugins/debugger/debuggeragents.cpp
View file @
39e11137
...
...
@@ -44,6 +44,7 @@
#include <QtGui/QPlainTextEdit>
#include <QtGui/QTextCursor>
#include <QtGui/QSyntaxHighlighter>
#include <limits.h>
...
...
@@ -143,6 +144,30 @@ struct DisassemblerViewAgentPrivate
LocationMark2
*
locationMark
;
};
/*!
\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
...
...
@@ -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
);
...
...
src/plugins/debugger/debuggeroutputwindow.cpp
View file @
39e11137
...
...
@@ -260,7 +260,7 @@ public:
CombinedPane
(
QWidget
*
parent
)
:
DebuggerPane
(
parent
)
{
(
void
)
new
OutputHighlighter
(
this
);
(
void
)
new
OutputHighlighter
(
this
);
}
public
slots
:
...
...
src/plugins/debugger/gdb/gdbengine.cpp
View file @
39e11137
...
...
@@ -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
(
Q
String
::
fromLocal8Bit
(
child
.
data
()));
files
.
append
(
Q
File
::
decodeName
(
child
.
data
()));
}
else
if
(
child
.
hasName
(
"fullname"
))
{
QString
fullName
=
Q
String
::
fromLocal8Bit
(
child
.
data
());
QString
fullName
=
Q
File
::
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
(
Q
String
::
fromLocal8Bit
(
frameMi
.
findChild
(
"fullname"
).
data
()));
files
.
append
(
Q
String
::
fromLocal8Bit
(
frameMi
.
findChild
(
"file"
).
data
()));
files
.
append
(
Q
File
::
decodeName
(
frameMi
.
findChild
(
"fullname"
).
data
()));
files
.
append
(
Q
File
::
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
();
Q
ByteArray
fileName
=
child
.
findChild
(
"file"
).
data
();
Q
String
fileName
=
QFile
::
decodeName
(
child
.
findChild
(
"file"
).
data
()
)
;
if
(
!
fileLoaded
)
{
QFile
file
(
QFile
::
decode
Name
(
fileName
));
QFile
file
(
full
Name
(
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
);
...
...
src/plugins/debugger/gdb/gdbengine.h
View file @
39e11137
...
...
@@ -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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment