1
/**************************************************************************
3
** This file is part of Qt Creator
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
7
** Contact: Nokia Corporation (qt-info@nokia.com)
11
** Licensees holding valid Qt Commercial licenses may use this file in
12
** accordance with the Qt Commercial License Agreement provided with the
13
** Software or, alternatively, in accordance with the terms contained in
14
** a written agreement between you and Nokia.
16
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** If you are unsure which license is appropriate for your use, please
26
** contact the sales department at http://www.qtsoftware.com/contact.
28
**************************************************************************/
30
#ifndef CDBDUMPERHELPER_H
31
#define CDBDUMPERHELPER_H
33
#include "watchutils.h"
36
#include <QtCore/QStringList>
37
#include <QtCore/QMap>
42
struct CdbComInterfaces;
43
class IDebuggerManagerAccessForEngines;
44
class DebuggerManager;
46
/* For code clarity, all the stuff related to custom dumpers goes here.
47
* "Custom dumper" is a library compiled against the current
48
* Qt containing functions to evaluate values of Qt classes
49
* (such as QString), taking pointers to their addresses.
50
* The dumper functions produce formatted string output which is
51
* converted into WatchData items with the help of QtDumperHelper.
53
* Usage: When launching the debugger, call reset() with path to dumpers
54
* and enabled flag. From the module load event callback, call
55
* moduleLoadHook() to initialize.
56
* dumpType() is the main query function to obtain a list of WatchData from
57
* WatchData item produced by the smbol context.
58
* Call disable(), should the debuggee crash (as performing debuggee
59
* calls is no longer possible, then).*/
63
Q_DISABLE_COPY(CdbDumperHelper)
66
Disabled, // Disabled or failed
71
Initialized, // List of types, etc. retrieved
74
explicit CdbDumperHelper(DebuggerManager *manager,
75
CdbComInterfaces *cif);
78
State state() const { return m_state; }
79
bool isEnabled() const { return m_state != Disabled; }
81
// Disable in case of a debuggee crash.
84
// Call before starting the debugger
85
void reset(const QString &library, bool enabled);
87
// Call from the module load callback to perform initialization.
88
void moduleLoadHook(const QString &module, HANDLE debuggeeHandle);
90
// Dump a WatchData item.
91
enum DumpResult { DumpNotHandled, DumpOk, DumpError };
92
DumpResult dumpType(const WatchData &d, bool dumpChildren, int source,
93
QList<WatchData> *result, QString *errorMessage);
95
inline CdbComInterfaces *comInterfaces() const { return m_cif; }
98
enum CallLoadResult { CallLoadOk, CallLoadError, CallLoadNoQtApp, CallLoadAlreadyLoaded };
102
bool ensureInitialized(QString *errorMessage);
103
CallLoadResult initCallLoad(QString *errorMessage);
104
bool initResolveSymbols(QString *errorMessage);
105
bool initKnownTypes(QString *errorMessage);
107
bool getTypeSize(const QString &typeName, int *size, QString *errorMessage);
108
bool runTypeSizeQuery(const QString &typeName, int *size, QString *errorMessage);
109
bool callDumper(const QString &call, const QByteArray &inBuffer, const char **outputPtr,
110
bool ignoreAccessViolation, QString *errorMessage);
112
enum DumpExecuteResult { DumpExecuteOk, DumpExecuteSizeFailed, DumpExecuteCallFailed };
113
DumpExecuteResult executeDump(const WatchData &wd,
114
const QtDumperHelper::TypeData& td, bool dumpChildren, int source,
115
QList<WatchData> *result, QString *errorMessage);
117
static bool writeToDebuggee(CIDebugDataSpaces *ds, const QByteArray &buffer, quint64 address, QString *errorMessage);
119
const bool m_tryInjectLoad;
120
const QString m_messagePrefix;
122
DebuggerManager *m_manager;
123
IDebuggerManagerAccessForEngines *m_access;
124
CdbComInterfaces *m_cif;
127
QString m_dumpObjectSymbol;
129
quint64 m_inBufferAddress;
130
unsigned long m_inBufferSize;
131
quint64 m_outBufferAddress;
132
unsigned long m_outBufferSize;
135
QStringList m_failedTypes;
137
QtDumperHelper m_helper;
140
} // namespace Internal
141
} // namespace Debugger
143
#endif // CDBDUMPERHELPER_H