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
9318459b
Commit
9318459b
authored
Apr 06, 2009
by
hjk
Browse files
debugger: allow short stack to be expanded by a context menu item or
double click on the "<...>" line
parent
45677525
Changes
11
Hide whitespace changes
Inline
Side-by-side
src/plugins/debugger/debuggeractions.cpp
View file @
9318459b
...
...
@@ -314,6 +314,10 @@ DebuggerSettings *theDebuggerSettings()
item
->
setDefaultValue
(
20
);
instance
->
insertItem
(
MaximalStackDepth
,
item
);
item
=
new
SavedAction
(
instance
);
item
->
setText
(
QObject
::
tr
(
"Reload full stack"
));
instance
->
insertItem
(
ExpandStack
,
item
);
item
=
new
SavedAction
(
instance
);
item
->
setText
(
QObject
::
tr
(
"Execute line"
));
instance
->
insertItem
(
ExecuteCommand
,
item
);
...
...
src/plugins/debugger/debuggeractions.h
View file @
9318459b
...
...
@@ -79,6 +79,7 @@ enum DebuggerActionCode
// Stack
MaximalStackDepth
,
ExpandStack
,
// Watchers & Locals
WatchExpression
,
...
...
src/plugins/debugger/debuggermanager.cpp
View file @
9318459b
...
...
@@ -1372,7 +1372,7 @@ void DebuggerManager::disassemblerDockToggled(bool on)
//////////////////////////////////////////////////////////////////////
//
// Sour
e
c files specific stuff
// Sourc
e
files specific stuff
//
//////////////////////////////////////////////////////////////////////
...
...
src/plugins/debugger/debuggerplugin.cpp
View file @
9318459b
...
...
@@ -797,7 +797,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
void
DebuggerPlugin
::
extensionsInitialized
()
{
// time gdb -i mi -ex 'debuggerplugin.cpp:800' -ex r -ex q bin/qtcreator.bin
qDebug
()
<<
"EXTENSIONS INITIALIZED"
;
//
qDebug() << "EXTENSIONS INITIALIZED";
QByteArray
env
=
qgetenv
(
"QTC_DEBUGGER_TEST"
);
if
(
!
env
.
isEmpty
())
m_manager
->
runTest
(
QString
::
fromLocal8Bit
(
env
));
...
...
src/plugins/debugger/gdbengine.cpp
View file @
9318459b
...
...
@@ -230,6 +230,9 @@ void GdbEngine::initializeConnections()
this
,
SLOT
(
reloadRegisters
()));
connect
(
theDebuggerAction
(
FormatNatural
),
SIGNAL
(
triggered
()),
this
,
SLOT
(
reloadRegisters
()));
connect
(
theDebuggerAction
(
ExpandStack
),
SIGNAL
(
triggered
()),
this
,
SLOT
(
reloadFullStack
()));
}
void
GdbEngine
::
initializeVariables
()
...
...
@@ -803,7 +806,7 @@ void GdbEngine::handleResult(const GdbResultRecord & record, int type,
break
;
case
StackListFrames
:
handleStackListFrames
(
record
);
handleStackListFrames
(
record
,
cookie
.
toBool
()
);
break
;
case
StackListThreads
:
handleStackListThreads
(
record
,
cookie
.
toInt
());
...
...
@@ -1301,12 +1304,18 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
#endif
}
void
GdbEngine
::
reloadFullStack
()
{
QString
cmd
=
"-stack-list-frames"
;
sendSynchronizedCommand
(
cmd
,
StackListFrames
,
true
);
}
void
GdbEngine
::
reloadStack
()
{
QString
cmd
=
"-stack-list-frames"
;
if
(
int
stackDepth
=
theDebuggerAction
(
MaximalStackDepth
)
->
value
().
toInt
())
cmd
+=
" 0 "
+
QString
::
number
(
stackDepth
);
sendSynchronizedCommand
(
cmd
,
StackListFrames
);
sendSynchronizedCommand
(
cmd
,
StackListFrames
,
false
);
}
void
GdbEngine
::
handleAsyncOutput2
(
const
GdbMi
&
data
)
...
...
@@ -2450,7 +2459,7 @@ void GdbEngine::handleStackSelectThread(const GdbResultRecord &record, int)
}
void
GdbEngine
::
handleStackListFrames
(
const
GdbResultRecord
&
record
)
void
GdbEngine
::
handleStackListFrames
(
const
GdbResultRecord
&
record
,
bool
isFull
)
{
QList
<
StackFrame
>
stackFrames
;
...
...
@@ -2501,30 +2510,11 @@ void GdbEngine::handleStackListFrames(const GdbResultRecord &record)
topFrame
=
i
;
}
if
(
n
>=
theDebuggerAction
(
MaximalStackDepth
)
->
value
().
toInt
())
{
StackFrame
frame
(
n
);
frame
.
file
=
"..."
;
frame
.
function
=
"..."
;
frame
.
from
=
"..."
;
frame
.
line
=
0
;
frame
.
address
=
"..."
;
stackFrames
.
append
(
frame
);
}
qq
->
stackHandler
()
->
setFrames
(
stackFrames
);
bool
canExpand
=
!
isFull
&&
(
n
>=
theDebuggerAction
(
MaximalStackDepth
)
->
value
().
toInt
());
theDebuggerAction
(
ExpandStack
)
->
setEnabled
(
canExpand
);
qq
->
stackHandler
()
->
setFrames
(
stackFrames
,
canExpand
);
#if 0
if (0 && topFrame != -1) {
// updates of locals already triggered early
const StackFrame &frame = qq->stackHandler()->currentFrame();
if (frame.isUsable())
q->gotoLocation(frame.file, frame.line, true);
else
qDebug() << "FULL NAME NOT USABLE 0: " << frame.file;
} else {
activateFrame(topFrame);
}
#else
if
(
topFrame
!=
-
1
)
{
// updates of locals already triggered early
const
StackFrame
&
frame
=
qq
->
stackHandler
()
->
currentFrame
();
...
...
@@ -2533,7 +2523,6 @@ void GdbEngine::handleStackListFrames(const GdbResultRecord &record)
else
qDebug
()
<<
"FULL NAME NOT USABLE 0: "
<<
frame
.
file
<<
topFrame
;
}
#endif
}
void
GdbEngine
::
selectThread
(
int
index
)
...
...
@@ -2562,6 +2551,10 @@ void GdbEngine::activateFrame(int frameIndex)
//qDebug() << "ACTIVATE FRAME: " << frameIndex << oldIndex
// << stackHandler->currentIndex();
if
(
frameIndex
==
stackHandler
->
stackSize
())
{
reloadFullStack
();
return
;
}
QTC_ASSERT
(
frameIndex
<
stackHandler
->
stackSize
(),
return
);
if
(
oldIndex
!=
frameIndex
)
{
...
...
src/plugins/debugger/gdbengine.h
View file @
9318459b
...
...
@@ -277,10 +277,11 @@ private:
//
// Stack specific stuff
//
void
handleStackListFrames
(
const
GdbResultRecord
&
record
);
void
handleStackListFrames
(
const
GdbResultRecord
&
record
,
bool
isFull
);
void
handleStackSelectThread
(
const
GdbResultRecord
&
record
,
int
cookie
);
void
handleStackListThreads
(
const
GdbResultRecord
&
record
,
int
cookie
);
void
reloadStack
();
Q_SLOT
void
reloadStack
();
Q_SLOT
void
reloadFullStack
();
//
...
...
src/plugins/debugger/stackhandler.cpp
View file @
9318459b
...
...
@@ -57,12 +57,13 @@ StackHandler::StackHandler(QObject *parent)
{
m_emptyIcon
=
QIcon
(
":/gdbdebugger/images/empty.svg"
);
m_positionIcon
=
QIcon
(
":/gdbdebugger/images/location.svg"
);
m_canExpand
=
false
;
}
int
StackHandler
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
// Since the stack is not a tree, row count is 0 for any valid parent
return
parent
.
isValid
()
?
0
:
m_stackFrames
.
size
();
return
parent
.
isValid
()
?
0
:
(
m_stackFrames
.
size
()
+
m_canExpand
)
;
}
int
StackHandler
::
columnCount
(
const
QModelIndex
&
parent
)
const
...
...
@@ -72,9 +73,15 @@ int StackHandler::columnCount(const QModelIndex &parent) const
QVariant
StackHandler
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
if
(
!
index
.
isValid
()
||
index
.
row
()
>=
m_stackFrames
.
size
())
if
(
!
index
.
isValid
()
||
index
.
row
()
>=
m_stackFrames
.
size
()
+
m_canExpand
)
return
QVariant
();
if
(
index
.
row
()
==
m_stackFrames
.
size
())
{
if
(
role
==
Qt
::
DisplayRole
&&
index
.
column
()
==
0
)
return
"<...>"
;
return
QVariant
();
}
const
StackFrame
&
frame
=
m_stackFrames
.
at
(
index
.
row
());
if
(
role
==
Qt
::
DisplayRole
)
{
...
...
@@ -123,10 +130,12 @@ QVariant StackHandler::headerData(int section, Qt::Orientation orientation, int
Qt
::
ItemFlags
StackHandler
::
flags
(
const
QModelIndex
&
index
)
const
{
if
(
index
.
row
()
>=
m_stackFrames
.
size
())
if
(
index
.
row
()
>=
m_stackFrames
.
size
()
+
m_canExpand
)
return
0
;
if
(
index
.
row
()
==
m_stackFrames
.
size
())
return
QAbstractTableModel
::
flags
(
index
);
const
StackFrame
&
frame
=
m_stackFrames
.
at
(
index
.
row
());
const
bool
isValid
=
!
frame
.
file
.
isEmpty
()
&&
!
frame
.
function
.
isEmpty
();
const
bool
isValid
=
(
!
frame
.
file
.
isEmpty
()
&&
!
frame
.
function
.
isEmpty
()
)
;
return
isValid
?
QAbstractTableModel
::
flags
(
index
)
:
Qt
::
ItemFlags
(
0
);
}
...
...
@@ -160,8 +169,9 @@ void StackHandler::removeAll()
reset
();
}
void
StackHandler
::
setFrames
(
const
QList
<
StackFrame
>
&
frames
)
void
StackHandler
::
setFrames
(
const
QList
<
StackFrame
>
&
frames
,
bool
canExpand
)
{
m_canExpand
=
canExpand
;
m_stackFrames
=
frames
;
if
(
m_currentIndex
>=
m_stackFrames
.
size
())
m_currentIndex
=
m_stackFrames
.
size
()
-
1
;
...
...
src/plugins/debugger/stackhandler.h
View file @
9318459b
...
...
@@ -64,7 +64,7 @@ class StackHandler : public QAbstractTableModel
public:
StackHandler
(
QObject
*
parent
=
0
);
void
setFrames
(
const
QList
<
StackFrame
>
&
frames
);
void
setFrames
(
const
QList
<
StackFrame
>
&
frames
,
bool
canExpand
=
false
);
QList
<
StackFrame
>
frames
()
const
;
void
setCurrentIndex
(
int
index
);
int
currentIndex
()
const
{
return
m_currentIndex
;
}
...
...
@@ -88,6 +88,7 @@ private:
int
m_currentIndex
;
QIcon
m_positionIcon
;
QIcon
m_emptyIcon
;
bool
m_canExpand
;
};
...
...
src/plugins/debugger/stackwindow.cpp
View file @
9318459b
...
...
@@ -98,6 +98,7 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev)
act2
->
setCheckable
(
true
);
act2
->
setChecked
(
m_alwaysResizeColumnsToContents
);
menu
.
addAction
(
theDebuggerAction
(
ExpandStack
));
menu
.
addAction
(
act0
);
menu
.
addSeparator
();
menu
.
addAction
(
act1
);
...
...
src/plugins/debugger/watchhandler.cpp
View file @
9318459b
...
...
@@ -871,10 +871,11 @@ void WatchHandler::watchExpression(const QString &exp)
{
// FIXME: 'exp' can contain illegal characters
//MODEL_DEBUG("WATCH: " << exp);
static
int
counter
=
0
;
WatchData
data
;
data
.
exp
=
exp
;
data
.
name
=
exp
;
data
.
iname
=
QLatin1String
(
"watch."
)
+
exp
;
data
.
iname
=
QLatin1String
(
"watch."
)
+
QString
::
number
(
counter
++
)
;
insertData
(
data
);
m_watchers
.
append
(
exp
);
saveWatchers
();
...
...
@@ -993,7 +994,6 @@ void WatchHandler::reinitializeWatchersHelper()
data
.
variable
.
clear
();
data
.
setAllNeeded
();
data
.
valuedisabled
=
false
;
data
.
iname
=
QLatin1String
(
"watch."
)
+
QString
::
number
(
i
);
data
.
name
=
exp
;
data
.
exp
=
exp
;
insertData
(
data
);
...
...
tests/auto/debugger/main.cpp
View file @
9318459b
...
...
@@ -85,7 +85,6 @@ private slots:
void
tst_Debugger
::
runQtc
()
{
QString
test
=
QFileInfo
(
qApp
->
arguments
().
at
(
0
)).
absoluteFilePath
();
//QString qtc = QFileInfo(test + "../../bin/qtcreator.bin").absoluteFilePath();
QString
qtc
=
QFileInfo
(
test
).
absolutePath
()
+
"/../../../bin/qtcreator.bin"
;
qtc
=
QFileInfo
(
qtc
).
absoluteFilePath
();
QProcess
proc
;
...
...
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