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
Marco Bubke
flatpak-qt-creator
Commits
956b5428
Commit
956b5428
authored
Nov 15, 2010
by
hjk
Browse files
debugger: make BreakpointData and BreakpointResult proper value types
parent
8d59cff4
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
src/plugins/debugger/breakhandler.cpp
View file @
956b5428
This diff is collapsed.
Click to expand it.
src/plugins/debugger/breakhandler.h
View file @
956b5428
...
...
@@ -61,10 +61,12 @@ public:
QAbstractItemModel
*
model
()
{
return
this
;
}
// The only way to add a new breakpoint.
void
appendBreakpoint
(
const
BreakpointData
&
data
);
BreakpointIds
allBreakpointIds
()
const
;
BreakpointIds
engineBreakpointIds
(
DebuggerEngine
*
engine
)
const
;
BreakpointIds
unclaimedBreakpointIds
()
const
;
BreakpointData
*
breakpointById
(
BreakpointId
id
)
const
;
int
size
()
const
{
return
m_storage
.
size
();
}
bool
hasPendingBreakpoints
()
const
;
...
...
@@ -107,13 +109,13 @@ public:
PROPERTY
(
QByteArray
,
condition
,
setCondition
)
PROPERTY
(
int
,
ignoreCount
,
setIgnoreCount
)
PROPERTY
(
QByteArray
,
threadSpec
,
setThreadSpec
)
PROPERTY
(
BreakpointState
,
state
,
setState
)
PROPERTY
(
QString
,
fileName
,
setFileName
)
PROPERTY
(
QString
,
functionName
,
setFunctionName
)
PROPERTY
(
BreakpointType
,
type
,
setType
);
PROPERTY
(
quint64
,
address
,
setAddress
);
PROPERTY
(
int
,
lineNumber
,
setLineNumber
);
#undef PROPERTY
BreakpointState
state
(
BreakpointId
id
)
const
;
bool
isEnabled
(
BreakpointId
id
)
const
;
void
setEnabled
(
BreakpointId
id
,
const
bool
&
on
);
void
updateEnabled
(
BreakpointId
id
,
const
bool
&
on
);
...
...
@@ -137,12 +139,16 @@ public:
void
notifyBreakpointRemoveFailed
(
BreakpointId
id
);
void
notifyBreakpointReleased
(
BreakpointId
id
);
// This takes ownership.
void
appendBreakpoint
(
BreakpointData
*
data
);
public:
// FIXME: Make private.
void
setState
(
BreakpointId
id
,
BreakpointState
state
);
private:
friend
class
BreakpointMarker
;
friend
class
BreakWindow
;
// FIXME: remove.
BreakpointData
*
breakpointById
(
BreakpointId
id
);
// QAbstractItemModel
int
columnCount
(
const
QModelIndex
&
parent
)
const
;
int
rowCount
(
const
QModelIndex
&
parent
)
const
;
...
...
@@ -164,10 +170,15 @@ private:
struct
BreakpointItem
{
BreakpointItem
()
:
data
(
0
),
respons
e
(
0
),
marker
(
0
)
{}
BreakpointItem
()
:
state
(
BreakpointNew
),
engin
e
(
0
),
marker
(
0
)
{}
void
destroy
();
BreakpointData
*
data
;
BreakpointResponse
*
response
;
bool
isPending
()
const
{
return
state
==
BreakpointPending
||
state
==
BreakpointNew
;
}
BreakpointData
data
;
BreakpointState
state
;
// Current state of breakpoint.
DebuggerEngine
*
engine
;
// Engine currently handling the breakpoint.
BreakpointResponse
response
;
BreakpointMarker
*
marker
;
};
typedef
QHash
<
BreakpointId
,
BreakpointItem
>
BreakpointStorage
;
...
...
src/plugins/debugger/breakpoint.cpp
View file @
956b5428
...
...
@@ -50,12 +50,10 @@ namespace Internal {
const
char
*
BreakpointData
::
throwFunction
=
"throw"
;
const
char
*
BreakpointData
::
catchFunction
=
"catch"
;
BreakpointData
::
BreakpointData
()
BreakpointData
::
BreakpointData
(
BreakpointType
type
)
{
m_state
=
BreakpointNew
;
m_engine
=
0
;
m_type
=
type
;
m_enabled
=
true
;
m_type
=
BreakpointByFileAndLine
;
m_ignoreCount
=
0
;
m_lineNumber
=
0
;
m_address
=
0
;
...
...
@@ -91,7 +89,7 @@ bool BreakpointData::setFileName(const QString &file)
bool
BreakpointData
::
setEnabled
(
bool
on
)
{
SETIT
(
m_enabled
,
on
);
}
bool
BreakpointData
::
setIgnoreCount
(
bool
count
)
bool
BreakpointData
::
setIgnoreCount
(
int
count
)
{
SETIT
(
m_ignoreCount
,
count
);
}
bool
BreakpointData
::
setFunctionName
(
const
QString
&
name
)
...
...
@@ -112,12 +110,6 @@ bool BreakpointData::setType(BreakpointType type)
bool
BreakpointData
::
setCondition
(
const
QByteArray
&
cond
)
{
SETIT
(
m_condition
,
cond
);
}
bool
BreakpointData
::
setState
(
BreakpointState
state
)
{
SETIT
(
m_state
,
state
);
}
bool
BreakpointData
::
setEngine
(
DebuggerEngine
*
engine
)
{
SETIT
(
m_engine
,
engine
);
}
#undef SETIT
...
...
@@ -156,10 +148,10 @@ QString BreakpointData::toToolTip() const
str
<<
"<html><body><table>"
//<< "<tr><td>" << tr("Id:")
//<< "</td><td>" << m_id << "</td></tr>"
<<
"<tr><td>"
<<
tr
(
"State:"
)
<<
"</td><td>"
<<
m_state
<<
"</td></tr>"
<<
"<tr><td>"
<<
tr
(
"Engine:"
)
<<
"</td><td>"
<<
m_engine
<<
"</td></tr>"
//
<< "<tr><td>" << tr("State:")
//
<< "</td><td>" << m_state << "</td></tr>"
//
<< "<tr><td>" << tr("Engine:")
//
<< "</td><td>" << m_engine << "</td></tr>"
<<
"<tr><td>"
<<
tr
(
"Marker File:"
)
<<
"</td><td>"
<<
QDir
::
toNativeSeparators
(
m_markerFileName
)
<<
"</td></tr>"
<<
"<tr><td>"
<<
tr
(
"Marker Line:"
)
...
...
src/plugins/debugger/breakpoint.h
View file @
956b5428
...
...
@@ -30,10 +30,10 @@
#ifndef DEBUGGER_BREAKPOINT_H
#define DEBUGGER_BREAKPOINT_H
#include
<QtCore/Q
MetaType
>
#include
<QtCore/Q
CoreApplication
>
#include
<QtCore/QList>
#include
<QtCore/QMetaType>
#include
<QtCore/QString>
#include
<QtCore/QCoreApplication>
namespace
Debugger
{
...
...
@@ -62,6 +62,8 @@ enum BreakpointType
BreakpointByFileAndLine
,
BreakpointByFunction
,
BreakpointByAddress
,
//BreakpointAtThrow, // FIXME: actually use this
//BreakpointAtCatch, // FIXME: actually use this
Watchpoint
,
};
...
...
@@ -82,21 +84,14 @@ enum BreakpointState
class
BreakpointData
{
private:
// Intentionally unimplemented. BreakpointData objects are supposed
// to be added to the BreakHandler soon after construction.
BreakpointData
(
const
BreakpointData
&
);
void
operator
=
(
const
BreakpointData
&
);
friend
class
BreakHandler
;
// This should be the only class manipulating data.
friend
class
BreakWindow
;
// FIXME: Remove.
friend
class
BreakpointDialog
;
// FIXME: Remove.
friend
QDataStream
&
operator
>>
(
QDataStream
&
stream
,
BreakpointData
&
data
);
public:
BreakpointData
();
explicit
BreakpointData
(
BreakpointType
=
UnknownType
);
bool
isPending
()
const
{
return
m_state
==
BreakpointPending
||
m_state
==
BreakpointNew
;
}
BreakpointType
type
()
const
{
return
m_type
;
}
quint64
address
()
const
{
return
m_address
;
}
bool
useFullPath
()
const
{
return
m_useFullPath
;
}
...
...
@@ -106,7 +101,6 @@ public:
bool
isLocatedAt
(
const
QString
&
fileName
,
int
lineNumber
,
bool
useMarkerPosition
)
const
;
bool
conditionsMatch
(
const
QString
&
other
)
const
;
BreakpointState
state
()
const
{
return
m_state
;
}
QString
functionName
()
const
{
return
m_functionName
;
}
QString
markerFileName
()
const
{
return
m_markerFileName
;
}
QString
fileName
()
const
{
return
m_fileName
;
}
...
...
@@ -116,7 +110,6 @@ public:
bool
isEnabled
()
const
{
return
m_enabled
;
}
QByteArray
threadSpec
()
const
{
return
m_threadSpec
;
}
QByteArray
condition
()
const
{
return
m_condition
;
}
DebuggerEngine
*
engine
()
const
{
return
m_engine
;
}
bool
isWatchpoint
()
const
{
return
m_type
==
Watchpoint
;
}
bool
isBreakpoint
()
const
{
return
m_type
!=
Watchpoint
;
}
// Enough for now.
...
...
@@ -131,21 +124,17 @@ private:
bool
setMarkerLineNumber
(
int
line
);
bool
setFileName
(
const
QString
&
file
);
bool
setEnabled
(
bool
on
);
bool
setIgnoreCount
(
bool
count
);
bool
setIgnoreCount
(
int
count
);
bool
setFunctionName
(
const
QString
&
name
);
bool
setLineNumber
(
int
line
);
bool
setAddress
(
quint64
address
);
bool
setThreadSpec
(
const
QByteArray
&
spec
);
bool
setType
(
BreakpointType
type
);
bool
setCondition
(
const
QByteArray
&
cond
);
bool
setState
(
BreakpointState
state
);
bool
setEngine
(
DebuggerEngine
*
engine
);
private:
DebuggerEngine
*
m_engine
;
BreakpointType
m_type
;
// Type of breakpoint.
BreakpointState
m_state
;
// Current state of breakpoint.
// This "user requested information" will get stored in the session.
BreakpointType
m_type
;
// Type of breakpoint.
bool
m_enabled
;
// Should we talk to the debugger engine?
bool
m_useFullPath
;
// Should we use the full path when setting the bp?
QString
m_fileName
;
// Short name of source file.
...
...
src/plugins/debugger/breakwindow.cpp
View file @
956b5428
...
...
@@ -363,14 +363,13 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
else
if
(
act
==
addBreakpointAction
)
addBreakpoint
();
else
if
(
act
==
breakAtThrowAction
)
{
// FIXME: Use the proper breakpoint type instead.
BreakpointData
*
data
=
new
BreakpointData
;
data
->
setFunctionName
(
BreakpointData
::
throwFunction
);
BreakpointData
data
;
data
.
setFunctionName
(
BreakpointData
::
throwFunction
);
handler
->
appendBreakpoint
(
data
);
}
else
if
(
act
==
breakAtCatchAction
)
{
// FIXME: Use the proper breakpoint type instead.
BreakpointData
*
data
=
new
BreakpointD
ata
;
data
->
setFunctionName
(
BreakpointData
::
catchFunction
);
BreakpointData
d
ata
;
data
.
setFunctionName
(
BreakpointData
::
catchFunction
);
handler
->
appendBreakpoint
(
data
);
}
}
...
...
@@ -396,25 +395,18 @@ void BreakWindow::deleteBreakpoints(const QModelIndexList &list)
handler
->
removeBreakpoint
(
handler
->
findBreakpointByIndex
(
index
));
}
static
bool
editBreakpointInternal
(
BreakpointData
*
data
,
QWidget
*
parent
)
{
BreakpointDialog
dialog
(
parent
);
return
dialog
.
showDialog
(
data
);
}
bool
BreakWindow
::
editBreakpoint
(
BreakpointId
id
,
QWidget
*
parent
)
void
BreakWindow
::
editBreakpoint
(
BreakpointId
id
,
QWidget
*
parent
)
{
BreakpointDialog
dialog
(
parent
);
return
dialog
.
showDialog
(
breakHandler
()
->
breakpointById
(
id
));
dialog
.
showDialog
(
breakHandler
()
->
breakpointById
(
id
));
}
void
BreakWindow
::
addBreakpoint
()
{
BreakpointData
*
data
=
new
BreakpointData
();
if
(
editBreakpointInternal
(
data
,
this
))
BreakpointData
data
;
BreakpointDialog
dialog
(
this
);
if
(
dialog
.
showDialog
(
&
data
))
breakHandler
()
->
appendBreakpoint
(
data
);
else
delete
data
;
}
void
BreakWindow
::
editBreakpoints
(
const
QModelIndexList
&
list
)
...
...
src/plugins/debugger/breakwindow.h
View file @
956b5428
...
...
@@ -45,7 +45,7 @@ public:
explicit
BreakWindow
(
QWidget
*
parent
=
0
);
~
BreakWindow
();
static
bool
editBreakpoint
(
BreakpointId
id
,
QWidget
*
parent
=
0
);
static
void
editBreakpoint
(
BreakpointId
id
,
QWidget
*
parent
);
private
slots
:
void
resizeColumnsToContents
();
...
...
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