Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
b90bb97f
Commit
b90bb97f
authored
Dec 14, 2010
by
hjk
Browse files
debugger: make location markers engine-specific
parent
d31fcda2
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/plugins/debugger/breakhandler.cpp
View file @
b90bb97f
...
...
@@ -852,16 +852,17 @@ void BreakHandler::gotoLocation(BreakpointId id) const
{
ConstIterator
it
=
m_storage
.
find
(
id
);
QTC_ASSERT
(
it
!=
m_storage
.
end
(),
return
);
DebuggerEngine
*
engine
=
debuggerCore
()
->
currentEngine
();
if
(
it
->
data
.
type
==
BreakpointByAddress
)
{
StackFrame
frame
;
frame
.
address
=
it
->
data
.
address
;
DebuggerEngine
*
engine
=
debuggerCore
()
->
currentEngine
();
if
(
engine
)
engine
->
gotoLocation
(
frame
,
false
);
}
else
{
const
QString
fileName
=
it
->
markerFileName
();
const
int
lineNumber
=
it
->
markerLineNumber
();
debuggerCore
()
->
gotoLocation
(
fileName
,
lineNumber
,
false
);
if
(
engine
)
engine
->
gotoLocation
(
fileName
,
lineNumber
,
false
);
}
}
...
...
src/plugins/debugger/debuggercore.h
View file @
b90bb97f
...
...
@@ -93,11 +93,6 @@ public:
// void runTest(const QString &fileName);
virtual
void
showMessage
(
const
QString
&
msg
,
int
channel
,
int
timeout
=
-
1
)
=
0
;
virtual
void
gotoLocation
(
const
QString
&
fileName
,
int
lineNumber
=
-
1
,
bool
setMarker
=
false
)
=
0
;
virtual
void
resetLocation
()
=
0
;
virtual
void
removeLocationMark
()
=
0
;
virtual
bool
isReverseDebugging
()
const
=
0
;
virtual
void
runControlStarted
(
DebuggerEngine
*
engine
)
=
0
;
...
...
src/plugins/debugger/debuggerengine.cpp
View file @
b90bb97f
...
...
@@ -56,6 +56,8 @@
#include
<projectexplorer/toolchaintype.h>
#include
<texteditor/itexteditor.h>
#include
<texteditor/basetexteditor.h>
#include
<texteditor/basetextmark.h>
#include
<utils/environment.h>
#include
<utils/savedaction.h>
...
...
@@ -165,6 +167,28 @@ const char *DebuggerEngine::stateName(int s)
}
///////////////////////////////////////////////////////////////////////
//
// LocationMark
//
///////////////////////////////////////////////////////////////////////
// Used in "real" editors
class
LocationMark
:
public
TextEditor
::
BaseTextMark
{
public:
LocationMark
(
const
QString
&
fileName
,
int
linenumber
)
:
BaseTextMark
(
fileName
,
linenumber
)
{}
QIcon
icon
()
const
{
return
debuggerCore
()
->
locationMarkIcon
();
}
void
updateLineNumber
(
int
/*lineNumber*/
)
{}
void
updateBlock
(
const
QTextBlock
&
/*block*/
)
{}
void
removedFromEditor
()
{}
};
//////////////////////////////////////////////////////////////////////
//
// DebuggerEnginePrivate
...
...
@@ -192,7 +216,9 @@ public:
m_isSlaveEngine
(
false
),
m_disassemblerViewAgent
(
engine
),
m_memoryViewAgent
(
engine
)
{}
{
connect
(
&
m_locationTimer
,
SIGNAL
(
timeout
()),
SLOT
(
doRemoveLocationMark
()));
}
~
DebuggerEnginePrivate
()
{}
...
...
@@ -240,6 +266,18 @@ public slots:
m_runControl
->
bringApplicationToForeground
(
m_inferiorPid
);
}
void
removeLocationMark
()
{
m_locationTimer
.
setSingleShot
(
true
);
m_locationTimer
.
start
(
80
);
}
void
doRemoveLocationMark
()
{
m_locationTimer
.
stop
();
m_locationMark
.
reset
();
}
public:
DebuggerState
state
()
const
{
return
m_state
;
}
...
...
@@ -270,6 +308,8 @@ public:
bool
m_isSlaveEngine
;
DisassemblerViewAgent
m_disassemblerViewAgent
;
MemoryViewAgent
m_memoryViewAgent
;
QScopedPointer
<
TextEditor
::
BaseTextMark
>
m_locationMark
;
QTimer
m_locationTimer
;
};
...
...
@@ -493,12 +533,27 @@ void DebuggerEngine::breakByFunction(const QString &functionName)
void
DebuggerEngine
::
resetLocation
()
{
d
->
m_disassemblerViewAgent
.
resetLocation
();
d
ebuggerCore
()
->
removeLocationMark
();
d
->
removeLocationMark
();
}
void
DebuggerEngine
::
gotoLocation
(
const
QString
&
file
Name
,
int
line
Number
,
bool
setMarker
)
void
DebuggerEngine
::
gotoLocation
(
const
QString
&
file
,
int
line
,
bool
setMarker
)
{
debuggerCore
()
->
gotoLocation
(
fileName
,
lineNumber
,
setMarker
);
// CDB might hit on breakpoints while shutting down.
//if (m_shuttingDown)
// return;
d
->
doRemoveLocationMark
();
bool
newEditor
=
false
;
ITextEditor
*
editor
=
BaseTextEditor
::
openEditorAt
(
file
,
line
,
0
,
QString
(),
EditorManager
::
IgnoreNavigationHistory
,
&
newEditor
);
if
(
!
editor
)
return
;
if
(
newEditor
)
editor
->
setProperty
(
Constants
::
OPENED_BY_DEBUGGER
,
true
);
if
(
setMarker
)
d
->
m_locationMark
.
reset
(
new
LocationMark
(
file
,
line
));
}
void
DebuggerEngine
::
gotoLocation
(
const
StackFrame
&
frame
,
bool
setMarker
)
...
...
@@ -506,7 +561,7 @@ void DebuggerEngine::gotoLocation(const StackFrame &frame, bool setMarker)
if
(
debuggerCore
()
->
boolSetting
(
OperateByInstruction
)
||
!
frame
.
isUsable
())
d
->
m_disassemblerViewAgent
.
setFrame
(
frame
,
true
,
setMarker
);
else
debuggerCore
()
->
gotoLocation
(
frame
.
file
,
frame
.
line
,
setMarker
);
gotoLocation
(
frame
.
file
,
frame
.
line
,
setMarker
);
}
// Called from RunControl.
...
...
src/plugins/debugger/debuggerengine.h
View file @
b90bb97f
...
...
@@ -279,11 +279,13 @@ public:
void
handleCommand
(
int
role
,
const
QVariant
&
value
);
// Convenience
Q_SLOT
void
showMessage
(
const
QString
&
msg
,
int
channel
=
LogDebug
,
int
timeout
=
-
1
)
const
;
Q_SLOT
void
showMessage
(
const
QString
&
msg
,
int
channel
=
LogDebug
,
int
timeout
=
-
1
)
const
;
Q_SLOT
void
showStatusMessage
(
const
QString
&
msg
,
int
timeout
=
-
1
)
const
;
void
resetLocation
();
virtual
void
gotoLocation
(
const
QString
&
fileName
,
int
lineNumber
,
bool
setMarker
);
virtual
void
gotoLocation
(
const
QString
&
fileName
,
int
lineNumber
=
-
1
,
bool
setMarker
=
false
);
virtual
void
gotoLocation
(
const
Internal
::
StackFrame
&
frame
,
bool
setMarker
);
virtual
void
quitDebugger
();
// called by DebuggerRunControl
...
...
src/plugins/debugger/debuggerplugin.cpp
View file @
b90bb97f
...
...
@@ -95,7 +95,6 @@
#include
<qt4projectmanager/qt4projectmanagerconstants.h>
#include
<texteditor/basetexteditor.h>
#include
<texteditor/basetextmark.h>
#include
<texteditor/fontsettings.h>
#include
<texteditor/texteditorsettings.h>
...
...
@@ -531,27 +530,6 @@ private:
};
///////////////////////////////////////////////////////////////////////
//
// LocationMark
//
///////////////////////////////////////////////////////////////////////
// Used in "real" editors
class
LocationMark
:
public
TextEditor
::
BaseTextMark
{
public:
LocationMark
(
const
QString
&
fileName
,
int
linenumber
)
:
BaseTextMark
(
fileName
,
linenumber
)
{}
QIcon
icon
()
const
{
return
debuggerCore
()
->
locationMarkIcon
();
}
void
updateLineNumber
(
int
/*lineNumber*/
)
{}
void
updateBlock
(
const
QTextBlock
&
/*block*/
)
{}
void
removedFromEditor
()
{}
};
///////////////////////////////////////////////////////////////////////
//
// CommonOptionsPage
...
...
@@ -1068,8 +1046,6 @@ public slots:
void
updateWatchersWindow
();
void
onCurrentProjectChanged
(
ProjectExplorer
::
Project
*
project
);
void
gotoLocation
(
const
QString
&
file
,
int
line
,
bool
setMarker
);
void
clearStatusMessage
();
void
sessionLoaded
();
...
...
@@ -1085,31 +1061,31 @@ public slots:
void
handleExecDetach
()
{
resetLocation
();
currentEngine
()
->
resetLocation
();
currentEngine
()
->
detachDebugger
();
}
void
handleExecContinue
()
{
resetLocation
();
currentEngine
()
->
resetLocation
();
currentEngine
()
->
continueInferior
();
}
void
handleExecInterrupt
()
{
resetLocation
();
currentEngine
()
->
resetLocation
();
currentEngine
()
->
requestInterruptInferior
();
}
void
handleExecReset
()
{
resetLocation
();
currentEngine
()
->
resetLocation
();
currentEngine
()
->
notifyEngineIll
();
// FIXME: Check.
}
void
handleExecStep
()
{
resetLocation
();
currentEngine
()
->
resetLocation
();
if
(
boolSetting
(
OperateByInstruction
))
currentEngine
()
->
executeStepI
();
else
...
...
@@ -1118,7 +1094,7 @@ public slots:
void
handleExecNext
()
{
resetLocation
();
currentEngine
()
->
resetLocation
();
if
(
boolSetting
(
OperateByInstruction
))
currentEngine
()
->
executeNextI
();
else
...
...
@@ -1127,20 +1103,20 @@ public slots:
void
handleExecStepOut
()
{
resetLocation
();
currentEngine
()
->
resetLocation
();
currentEngine
()
->
executeStepOut
();
}
void
handleExecReturn
()
{
resetLocation
();
currentEngine
()
->
resetLocation
();
currentEngine
()
->
executeReturn
();
}
void
handleExecJumpToLine
()
{
//removeTooltip();
resetLocation
();
currentEngine
()
->
resetLocation
();
QString
fileName
;
int
lineNumber
;
if
(
currentTextEditorPosition
(
&
fileName
,
&
lineNumber
))
...
...
@@ -1150,7 +1126,7 @@ public slots:
void
handleExecRunToLine
()
{
//removeTooltip();
resetLocation
();
currentEngine
()
->
resetLocation
();
QString
fileName
;
int
lineNumber
;
if
(
currentTextEditorPosition
(
&
fileName
,
&
lineNumber
))
...
...
@@ -1159,7 +1135,7 @@ public slots:
void
handleExecRunToFunction
()
{
resetLocation
();
currentEngine
()
->
resetLocation
();
ITextEditor
*
textEditor
=
currentTextEditor
();
QTC_ASSERT
(
textEditor
,
return
);
QPlainTextEdit
*
ed
=
qobject_cast
<
QPlainTextEdit
*>
(
textEditor
->
widget
());
...
...
@@ -1274,9 +1250,6 @@ public slots:
return
m_mainWindow
->
activeDebugLanguages
()
&
lang
;
}
void
resetLocation
();
void
removeLocationMark
();
void
doRemoveLocationMark
();
QVariant
sessionValue
(
const
QString
&
name
);
void
setSessionValue
(
const
QString
&
name
,
const
QVariant
&
value
);
QIcon
locationMarkIcon
()
const
{
return
m_locationMarkIcon
;
}
...
...
@@ -1297,7 +1270,6 @@ public:
DebuggerRunControlFactory
*
m_debuggerRunControlFactory
;
QString
m_previousMode
;
QScopedPointer
<
TextEditor
::
BaseTextMark
>
m_locationMark
;
Context
m_continuableContext
;
Context
m_interruptibleContext
;
Context
m_undisturbableContext
;
...
...
@@ -1344,7 +1316,6 @@ public:
bool
m_busy
;
QTimer
m_statusTimer
;
QTimer
m_locationTimer
;
QString
m_lastPermanentStatusMessage
;
mutable
CPlusPlus
::
Snapshot
m_codeModelSnapshot
;
...
...
@@ -1999,6 +1970,8 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
if
(
m_currentEngine
==
engine
)
return
;
if
(
m_currentEngine
)
m_currentEngine
->
resetLocation
();
m_currentEngine
=
engine
;
m_localsWindow
->
setModel
(
engine
->
localsModel
());
...
...
@@ -2284,26 +2257,6 @@ void DebuggerPluginPrivate::updateDebugActions()
m_debugAction
->
setEnabled
(
pe
->
canRun
(
project
,
Constants
::
DEBUGMODE
));
}
void
DebuggerPluginPrivate
::
gotoLocation
(
const
QString
&
file
,
int
line
,
bool
setMarker
)
{
// CDB might hit on breakpoints while shutting down.
if
(
m_shuttingDown
)
return
;
doRemoveLocationMark
();
bool
newEditor
=
false
;
ITextEditor
*
editor
=
BaseTextEditor
::
openEditorAt
(
file
,
line
,
0
,
QString
(),
EditorManager
::
IgnoreNavigationHistory
,
&
newEditor
);
if
(
!
editor
)
return
;
if
(
newEditor
)
editor
->
setProperty
(
Constants
::
OPENED_BY_DEBUGGER
,
true
);
if
(
setMarker
)
m_locationMark
.
reset
(
new
LocationMark
(
file
,
line
));
}
void
DebuggerPluginPrivate
::
onModeChanged
(
IMode
*
mode
)
{
// FIXME: This one gets always called, even if switching between modes
...
...
@@ -2438,23 +2391,6 @@ const CPlusPlus::Snapshot &DebuggerPluginPrivate::cppCodeModelSnapshot() const
return
m_codeModelSnapshot
;
}
void
DebuggerPluginPrivate
::
resetLocation
()
{
currentEngine
()
->
resetLocation
();
}
void
DebuggerPluginPrivate
::
removeLocationMark
()
{
m_locationTimer
.
setSingleShot
(
true
);
m_locationTimer
.
start
(
80
);
}
void
DebuggerPluginPrivate
::
doRemoveLocationMark
()
{
m_locationTimer
.
stop
();
m_locationMark
.
reset
();
}
void
DebuggerPluginPrivate
::
setSessionValue
(
const
QString
&
name
,
const
QVariant
&
value
)
{
QTC_ASSERT
(
sessionManager
(),
return
);
...
...
@@ -3180,10 +3116,6 @@ void DebuggerPluginPrivate::extensionsInitialized()
SIGNAL
(
startupProjectChanged
(
ProjectExplorer
::
Project
*
)),
SLOT
(
onCurrentProjectChanged
(
ProjectExplorer
::
Project
*
)));
connect
(
&
m_locationTimer
,
SIGNAL
(
timeout
()),
SLOT
(
doRemoveLocationMark
()));
QTC_ASSERT
(
m_coreSettings
,
/**/
);
m_watchersWindow
->
setVisible
(
false
);
m_returnWindow
->
setVisible
(
false
);
...
...
src/plugins/debugger/moduleswindow.cpp
View file @
b90bb97f
...
...
@@ -72,7 +72,9 @@ ModulesWindow::ModulesWindow(QWidget *parent)
void
ModulesWindow
::
moduleActivated
(
const
QModelIndex
&
index
)
{
debuggerCore
()
->
gotoLocation
(
index
.
data
().
toString
());
DebuggerEngine
*
engine
=
debuggerCore
()
->
currentEngine
();
QTC_ASSERT
(
engine
,
return
);
engine
->
gotoLocation
(
index
.
data
().
toString
());
}
void
ModulesWindow
::
contextMenuEvent
(
QContextMenuEvent
*
ev
)
...
...
@@ -85,6 +87,7 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
name
=
index
.
data
().
toString
();
DebuggerEngine
*
engine
=
debuggerCore
()
->
currentEngine
();
QTC_ASSERT
(
engine
,
return
);
const
bool
enabled
=
engine
->
debuggerActionsEnabled
();
const
unsigned
capabilities
=
engine
->
debuggerCapabilities
();
...
...
@@ -167,7 +170,7 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
else
if
(
act
==
actLoadSymbolsForModule
)
engine
->
loadSymbols
(
name
);
else
if
(
act
==
actEditFile
)
debuggerCore
()
->
gotoLocation
(
name
);
engine
->
gotoLocation
(
name
);
else
if
(
act
==
actShowModuleSymbols
)
engine
->
requestModuleSymbols
(
name
);
}
...
...
src/plugins/debugger/sourcefileswindow.cpp
View file @
b90bb97f
...
...
@@ -81,15 +81,19 @@ SourceFilesWindow::SourceFilesWindow(QWidget *parent)
void
SourceFilesWindow
::
sourceFileActivated
(
const
QModelIndex
&
index
)
{
debuggerCore
()
->
gotoLocation
(
index
.
data
().
toString
());
DebuggerEngine
*
engine
=
currentEngine
();
QTC_ASSERT
(
engine
,
return
);
engine
->
gotoLocation
(
index
.
data
().
toString
());
}
void
SourceFilesWindow
::
contextMenuEvent
(
QContextMenuEvent
*
ev
)
{
DebuggerEngine
*
engine
=
currentEngine
();
QTC_ASSERT
(
engine
,
return
);
QModelIndex
index
=
indexAt
(
ev
->
pos
());
index
=
index
.
sibling
(
index
.
row
(),
0
);
QString
name
=
index
.
data
().
toString
();
bool
engineActionsEnabled
=
currentE
ngine
()
->
debuggerActionsEnabled
();
bool
engineActionsEnabled
=
e
ngine
->
debuggerActionsEnabled
();
QMenu
menu
;
QAction
*
act1
=
new
QAction
(
tr
(
"Reload Data"
),
&
menu
);
...
...
@@ -113,9 +117,9 @@ void SourceFilesWindow::contextMenuEvent(QContextMenuEvent *ev)
QAction
*
act
=
menu
.
exec
(
ev
->
globalPos
());
if
(
act
==
act1
)
currentE
ngine
()
->
reloadSourceFiles
();
e
ngine
->
reloadSourceFiles
();
else
if
(
act
==
act2
)
debuggerCore
()
->
gotoLocation
(
name
);
engine
->
gotoLocation
(
name
);
}
}
// namespace Internal
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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