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
cff3b9e0
Commit
cff3b9e0
authored
Oct 06, 2009
by
Oswald Buddenhagen
Browse files
centralize some code in AbstractGdbAdapter
parent
ccf4fe9a
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/plugins/debugger/gdb/abstractgdbadapter.cpp
0 → 100644
View file @
cff3b9e0
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include
"abstractgdbadapter.h"
#include
<utils/qtcassert.h>
#include
<QtCore/QObject>
#include
<QtCore/QProcess>
namespace
Debugger
{
namespace
Internal
{
AbstractGdbAdapter
::
AbstractGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
)
:
QObject
(
parent
),
m_engine
(
engine
)
{
}
AbstractGdbAdapter
::~
AbstractGdbAdapter
()
{
disconnect
();
}
// This cannot be in the c'tor, as it would not connect the "virtual" slots
void
AbstractGdbAdapter
::
commonInit
()
{
QTC_ASSERT
(
state
()
==
DebuggerNotReady
,
qDebug
()
<<
state
());
connect
(
&
m_gdbProc
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)),
this
,
SLOT
(
handleGdbError
(
QProcess
::
ProcessError
)));
connect
(
&
m_gdbProc
,
SIGNAL
(
started
()),
this
,
SLOT
(
handleGdbStarted
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)),
this
,
SLOT
(
handleGdbFinished
(
int
,
QProcess
::
ExitStatus
)));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardOutput
()),
this
,
SIGNAL
(
readyReadStandardOutput
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardError
()),
this
,
SIGNAL
(
readyReadStandardError
()));
}
QByteArray
AbstractGdbAdapter
::
readAllStandardOutput
()
{
return
m_gdbProc
.
readAllStandardOutput
();
}
QByteArray
AbstractGdbAdapter
::
readAllStandardError
()
{
return
m_gdbProc
.
readAllStandardError
();
}
void
AbstractGdbAdapter
::
write
(
const
QByteArray
&
data
)
{
m_gdbProc
.
write
(
data
);
}
bool
AbstractGdbAdapter
::
isTrkAdapter
()
const
{
return
false
;
}
}
// namespace Internal
}
// namespace Debugger
src/plugins/debugger/gdb/abstractgdbadapter.h
View file @
cff3b9e0
...
...
@@ -48,15 +48,13 @@ class AbstractGdbAdapter : public QObject
Q_OBJECT
public:
AbstractGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
=
0
)
:
QObject
(
parent
),
m_engine
(
engine
)
{}
virtual
~
AbstractGdbAdapter
()
{
disconnect
();
}
AbstractGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
=
0
);
virtual
~
AbstractGdbAdapter
();
virtual
QByteArray
readAllStandard
Error
()
=
0
;
virtual
QByteArray
readAllStandard
Output
()
=
0
;
virtual
void
write
(
const
QByteArray
&
data
)
=
0
;
virtual
bool
isTrkAdapter
()
const
=
0
;
QByteArray
readAllStandard
Output
()
;
QByteArray
readAllStandard
Error
()
;
virtual
void
write
(
const
QByteArray
&
data
);
virtual
bool
isTrkAdapter
()
const
;
// isUtterlyBrokenAdapter
virtual
void
startAdapter
()
=
0
;
virtual
void
prepareInferior
()
=
0
;
...
...
@@ -83,6 +81,7 @@ signals:
void
readyReadStandardError
();
protected:
void
commonInit
();
DebuggerState
state
()
const
{
return
m_engine
->
state
();
}
void
setState
(
DebuggerState
state
)
...
...
@@ -95,6 +94,8 @@ protected:
{
m_engine
->
showStatusMessage
(
msg
);
}
GdbEngine
*
const
m_engine
;
QProcess
m_gdbProc
;
};
}
// namespace Internal
...
...
src/plugins/debugger/gdb/attachgdbadapter.cpp
View file @
cff3b9e0
...
...
@@ -53,17 +53,7 @@ namespace Internal {
AttachGdbAdapter
::
AttachGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
)
:
AbstractGdbAdapter
(
engine
,
parent
)
{
QTC_ASSERT
(
state
()
==
DebuggerNotReady
,
qDebug
()
<<
state
());
connect
(
&
m_gdbProc
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)),
this
,
SLOT
(
handleGdbError
(
QProcess
::
ProcessError
)));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardOutput
()),
this
,
SIGNAL
(
readyReadStandardOutput
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardError
()),
this
,
SIGNAL
(
readyReadStandardError
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
started
()),
this
,
SLOT
(
handleGdbStarted
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)),
this
,
SLOT
(
handleGdbFinished
(
int
,
QProcess
::
ExitStatus
)));
commonInit
();
}
void
AttachGdbAdapter
::
startAdapter
()
...
...
src/plugins/debugger/gdb/attachgdbadapter.h
View file @
cff3b9e0
...
...
@@ -52,11 +52,6 @@ class AttachGdbAdapter : public AbstractGdbAdapter
public:
AttachGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
=
0
);
private:
QByteArray
readAllStandardError
()
{
return
m_gdbProc
.
readAllStandardError
();
}
QByteArray
readAllStandardOutput
()
{
return
m_gdbProc
.
readAllStandardOutput
();
}
void
write
(
const
QByteArray
&
data
)
{
m_gdbProc
.
write
(
data
,
data
.
size
());
}
bool
isTrkAdapter
()
const
{
return
false
;
}
bool
dumpersAvailable
()
const
{
return
false
;
}
void
startAdapter
();
...
...
@@ -65,6 +60,7 @@ private:
void
interruptInferior
();
void
shutdown
();
private:
void
handleAttach
(
const
GdbResponse
&
response
);
void
handleDetach
(
const
GdbResponse
&
response
);
void
handleExit
(
const
GdbResponse
&
response
);
...
...
@@ -72,8 +68,6 @@ private:
Q_SLOT
void
handleGdbStarted
();
Q_SLOT
void
handleGdbFinished
(
int
,
QProcess
::
ExitStatus
);
Q_SLOT
void
handleGdbError
(
QProcess
::
ProcessError
error
);
QProcess
m_gdbProc
;
};
}
// namespace Internal
...
...
src/plugins/debugger/gdb/coregdbadapter.cpp
View file @
cff3b9e0
...
...
@@ -53,17 +53,7 @@ namespace Internal {
CoreGdbAdapter
::
CoreGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
)
:
AbstractGdbAdapter
(
engine
,
parent
)
{
QTC_ASSERT
(
state
()
==
DebuggerNotReady
,
qDebug
()
<<
state
());
connect
(
&
m_gdbProc
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)),
this
,
SLOT
(
handleGdbError
(
QProcess
::
ProcessError
)));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardOutput
()),
this
,
SIGNAL
(
readyReadStandardOutput
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardError
()),
this
,
SIGNAL
(
readyReadStandardError
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
started
()),
this
,
SLOT
(
handleGdbStarted
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)),
this
,
SLOT
(
handleGdbFinished
(
int
,
QProcess
::
ExitStatus
)));
commonInit
();
}
void
CoreGdbAdapter
::
startAdapter
()
...
...
src/plugins/debugger/gdb/coregdbadapter.h
View file @
cff3b9e0
...
...
@@ -52,11 +52,6 @@ class CoreGdbAdapter : public AbstractGdbAdapter
public:
CoreGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
=
0
);
private:
QByteArray
readAllStandardError
()
{
return
m_gdbProc
.
readAllStandardError
();
}
QByteArray
readAllStandardOutput
()
{
return
m_gdbProc
.
readAllStandardOutput
();
}
void
write
(
const
QByteArray
&
data
)
{
m_gdbProc
.
write
(
data
,
data
.
size
());
}
bool
isTrkAdapter
()
const
{
return
false
;
}
bool
dumpersAvailable
()
const
{
return
false
;
}
void
startAdapter
();
...
...
@@ -65,6 +60,7 @@ private:
void
interruptInferior
();
void
shutdown
();
private:
void
handleTargetCore1
(
const
GdbResponse
&
response
);
void
handleDetach1
(
const
GdbResponse
&
response
);
void
handleFileExecAndSymbols
(
const
GdbResponse
&
response
);
...
...
@@ -75,7 +71,6 @@ private:
Q_SLOT
void
handleGdbError
(
QProcess
::
ProcessError
error
);
Q_SLOT
void
handleGdbFinished
(
int
,
QProcess
::
ExitStatus
);
QProcess
m_gdbProc
;
QString
m_executable
;
};
...
...
src/plugins/debugger/gdb/gdb.pri
View file @
cff3b9e0
...
...
@@ -26,6 +26,7 @@ SOURCES += \
$$PWD/trkoptions.cpp \
$$PWD/trkoptionswidget.cpp \
$$PWD/trkoptionspage.cpp \
$$PWD/abstractgdbadapter.cpp \
$$PWD/attachgdbadapter.cpp \
$$PWD/coregdbadapter.cpp \
$$PWD/plaingdbadapter.cpp \
...
...
src/plugins/debugger/gdb/plaingdbadapter.cpp
View file @
cff3b9e0
...
...
@@ -58,17 +58,7 @@ namespace Internal {
PlainGdbAdapter
::
PlainGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
)
:
AbstractGdbAdapter
(
engine
,
parent
)
{
QTC_ASSERT
(
state
()
==
DebuggerNotReady
,
qDebug
()
<<
state
());
connect
(
&
m_gdbProc
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)),
this
,
SLOT
(
handleGdbError
(
QProcess
::
ProcessError
)));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardOutput
()),
this
,
SIGNAL
(
readyReadStandardOutput
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardError
()),
this
,
SIGNAL
(
readyReadStandardError
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
started
()),
this
,
SLOT
(
handleGdbStarted
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)),
this
,
SLOT
(
handleGdbFinished
(
int
,
QProcess
::
ExitStatus
)));
commonInit
();
m_stubProc
.
setMode
(
Utils
::
ConsoleProcess
::
Debug
);
#ifdef Q_OS_UNIX
...
...
src/plugins/debugger/gdb/plaingdbadapter.h
View file @
cff3b9e0
...
...
@@ -55,10 +55,6 @@ class PlainGdbAdapter : public AbstractGdbAdapter
public:
PlainGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
=
0
);
QByteArray
readAllStandardError
()
{
return
m_gdbProc
.
readAllStandardError
();
}
QByteArray
readAllStandardOutput
()
{
return
m_gdbProc
.
readAllStandardOutput
();
}
void
write
(
const
QByteArray
&
data
)
{
m_gdbProc
.
write
(
data
,
data
.
size
());
}
bool
isTrkAdapter
()
const
{
return
false
;
}
bool
dumpersAvailable
()
const
{
return
true
;
}
void
startAdapter
();
...
...
@@ -81,7 +77,6 @@ private:
Q_SLOT
void
stubStarted
();
Q_SLOT
void
stubError
(
const
QString
&
msg
);
QProcess
m_gdbProc
;
Utils
::
ConsoleProcess
m_stubProc
;
OutputCollector
m_outputCollector
;
};
...
...
src/plugins/debugger/gdb/remotegdbadapter.cpp
View file @
cff3b9e0
...
...
@@ -54,17 +54,7 @@ namespace Internal {
RemoteGdbAdapter
::
RemoteGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
)
:
AbstractGdbAdapter
(
engine
,
parent
)
{
QTC_ASSERT
(
state
()
==
DebuggerNotReady
,
qDebug
()
<<
state
());
connect
(
&
m_gdbProc
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)),
this
,
SLOT
(
handleGdbError
(
QProcess
::
ProcessError
)));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardOutput
()),
this
,
SIGNAL
(
readyReadStandardOutput
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardError
()),
this
,
SIGNAL
(
readyReadStandardError
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
started
()),
this
,
SLOT
(
handleGdbStarted
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)),
this
,
SLOT
(
handleGdbFinished
(
int
,
QProcess
::
ExitStatus
)));
commonInit
();
connect
(
&
m_uploadProc
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)),
this
,
SLOT
(
uploadProcError
(
QProcess
::
ProcessError
)));
...
...
src/plugins/debugger/gdb/remotegdbadapter.h
View file @
cff3b9e0
...
...
@@ -52,11 +52,6 @@ class RemoteGdbAdapter : public AbstractGdbAdapter
public:
RemoteGdbAdapter
(
GdbEngine
*
engine
,
QObject
*
parent
=
0
);
private:
QByteArray
readAllStandardError
()
{
return
m_gdbProc
.
readAllStandardError
();
}
QByteArray
readAllStandardOutput
()
{
return
m_gdbProc
.
readAllStandardOutput
();
}
void
write
(
const
QByteArray
&
data
)
{
m_gdbProc
.
write
(
data
,
data
.
size
());
}
bool
isTrkAdapter
()
const
{
return
false
;
}
bool
dumpersAvailable
()
const
{
return
true
;
}
void
startAdapter
();
...
...
@@ -65,6 +60,7 @@ private:
void
interruptInferior
();
void
shutdown
();
private:
Q_SLOT
void
readUploadStandardOutput
();
Q_SLOT
void
readUploadStandardError
();
Q_SLOT
void
uploadProcError
(
QProcess
::
ProcessError
error
);
...
...
@@ -79,7 +75,6 @@ private:
Q_SLOT
void
handleGdbError
(
QProcess
::
ProcessError
error
);
Q_SLOT
void
handleGdbFinished
(
int
,
QProcess
::
ExitStatus
);
QProcess
m_gdbProc
;
QProcess
m_uploadProc
;
};
...
...
src/plugins/debugger/gdb/trkgdbadapter.cpp
View file @
cff3b9e0
...
...
@@ -203,16 +203,8 @@ TrkGdbAdapter::TrkGdbAdapter(GdbEngine *engine, const TrkOptionsPtr &options) :
const
uid_t
portOffset
=
getuid
();
#endif
m_gdbServerName
=
_
(
"127.0.0.1:%1"
).
arg
(
2222
+
portOffset
);
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardError
()),
this
,
SIGNAL
(
readyReadStandardError
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
readyReadStandardOutput
()),
this
,
SIGNAL
(
readyReadStandardOutput
()));
connect
(
&
m_gdbProc
,
SIGNAL
(
error
(
QProcess
::
ProcessError
)),
this
,
SLOT
(
handleGdbError
(
QProcess
::
ProcessError
)));
connect
(
&
m_gdbProc
,
SIGNAL
(
finished
(
int
,
QProcess
::
ExitStatus
)),
this
,
SLOT
(
handleGdbFinished
(
int
,
QProcess
::
ExitStatus
)));
connect
(
&
m_gdbProc
,
SIGNAL
(
started
()),
this
,
SLOT
(
handleGdbStarted
()));
commonInit
();
connect
(
&
m_gdbProc
,
SIGNAL
(
stateChanged
(
QProcess
::
ProcessState
)),
this
,
SLOT
(
handleGdbStateChanged
(
QProcess
::
ProcessState
)));
...
...
@@ -1830,16 +1822,6 @@ void TrkGdbAdapter::handleRfcommStateChanged(QProcess::ProcessState newState)
// AbstractGdbAdapter interface implementation
//
QByteArray
TrkGdbAdapter
::
readAllStandardError
()
{
return
m_gdbProc
.
readAllStandardError
();
}
QByteArray
TrkGdbAdapter
::
readAllStandardOutput
()
{
return
m_gdbProc
.
readAllStandardOutput
();
}
void
TrkGdbAdapter
::
write
(
const
QByteArray
&
data
)
{
// Write magic packets directly to TRK.
...
...
@@ -1870,7 +1852,7 @@ void TrkGdbAdapter::write(const QByteArray &data)
trkReadMemoryMessage
(
m_session
.
dataseg
,
12
));
return
;
}
m_gdbProc
.
write
(
data
,
data
.
size
()
);
m_gdbProc
.
write
(
data
);
}
uint
oldPC
;
...
...
src/plugins/debugger/gdb/trkgdbadapter.h
View file @
cff3b9e0
...
...
@@ -155,7 +155,6 @@ private:
QString
m_gdbServerName
;
// 127.0.0.1:(2222+uid)
QProcess
m_gdbProc
;
QProcess
m_rfcommProc
;
bool
m_running
;
...
...
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