[go: up one dir, main page]

Menu

[d56ae5]: / datawindow.h  Maximize  Restore  History

Download this file

176 lines (159 with data), 6.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#ifndef DATAWINDOW_H
#define DATAWINDOW_H
#include "types.h"
#include <QtGui>
#include "variable.h"
#include <QTreeWidget>
class DataGroup;
class DataItem;
/**
* \typedef DataMap
*
* A \c DataMap is a \c QHash mapping the name of a \c DataItem
* to the pointer to the \c DataItem in the tree widget displayed in
* the data window. Maps of this type allow updating a \c DataItem
* rapidly starting with the name of the \c DataItem.
*/
typedef QHash<QString, DataItem*> DataMap;
/**
* \class DataItem
*
* \brief The \c DataItem class define one item in the \c QTreeWidget
* corresponding to one variable, array element or class member.
*
* \c DataItem is derived from the \c QTreeWidgetItem class which is
* the type for the individual items in a \c QTreeWidget. In a tree
* widget some items can be expanded into multiple sub-items and others
* cannot be expanded. In the data tree the simple data items like
* char, short, double, etc can't be expanded while complex data items
* like arrays, classes and structs can be expanded into sub-items.
*
* Internally a \c DataItem with simple data holds it in binary form
* in an anonymous union of size 8 bytes. The data received from
* \c gdb is in hexadecimal format and is stored in an unsigned
* portion of the union of the proper * size with all the remaining
* bits set to 0. The union has all the simple types in it and,
* depending on the format, the proper member of the union is used
* to retrieve the formatted value of the \c DataItem.
*
* In addition to the anonymous union a \c DataItem holds the name
* of the data item. For an array with name "stuff", when expanded
* to show 3 array elements with indexes 0, 1 and 2, the child nodes
* would have names "stuff[0]", "stuff[1]" and "stuff[2]". Likewise
* if the array is an array of class items, the child nodes of "stuff[0]"
* might be named "stuff[0].name" and "stuff[0].address". This
* strategy simplifies the expansion of nodes to arbitrary depth.
*
* There are 4 categories of data in the data window: globals, locals,
* parameters and user-defined. Each of these categories has an
* associated DataMap and item \c DataItem contains a pointer to its
* \c DataMap.
*/
class DataItem: public QTreeWidgetItem
{
public:
DataItem();
QString value();
QString name; ///< Full name of the \c DataItem
QString type; ///< Type as reported by \c gdb
QString address; ///< For user-defined variables
QString format; ///< How the \c DataItem should look
QVector<Limits> dimensions; ///< Array limits
bool isSimple; ///< Is the data simple, like char or int
bool isFortran; ///< Was this a fortran variable
int size; ///< Number of bytes of data
int first; ///< First index to expand for arrays/pointers
int last; ///< Last index to expand for arrays/pointers
bool userDefined; ///< Is this defined by the user during debugging
void setName(QString n);
void setValue(QString v);
void setType(QString t);
void setRange(int f, int l);
void removeSubTree();
QString valueFromGdb();
DataMap *map; ///< Map containing this \c DataItem
QString stringValue; ///< Value printed by \c gdb
AllTypes a; ///< Union of all basic types
};
/**
* \class DataTree
*
* \c DataTree is derived from the Qt \c QTreeWidget class which
* provides a tree view for displaying data.
*
* There is one \c DataTree in the data window and it contains
* 4 top-level items: \c globals, \c locals, \c parameters and
* \c userDefined. Each of these \c DataItems serves as the root
* of their associated data items.
*
* Global data is any variable defined outside a function (or class) or defined
* as \c static inside a function (or class). These items are discovered
* by inspecting the object files for a program before linking to avoid
* cluttering the screen with a large number of global data associated with
* library functions.
*
* Local data means variable defined without the keyword \c static inside
* a function. These are provided by \c gdb at each point that the debugger
* stops and reports the state of the debugged program.
*
* Parameters are the data items enclosed in parentheses
*/
class DataTree: public QTreeWidget
{
Q_OBJECT
public:
DataTree(QWidget *parent = 0);
~DataTree();
void contextMenuEvent(QContextMenuEvent *event);
DataItem *globals;
DataItem *locals;
DataItem *parameters;
DataItem *userDefined;
DataMap *globalMap;
DataMap *localMap;
DataMap *parameterMap;
DataMap *userDefinedMap;
DataItem *addDataItem(DataMap *map, QString n, QString t, QString v);
QList<Limits> dimensions;
public slots:
void expandDataItem(QTreeWidgetItem*);
void collapseDataItem(QTreeWidgetItem*);
void editUserVariable();
void deleteUserVariable();
void setDecimal();
void setFloatingPoint();
void setBool();
void setBinary();
void setBinaryFP();
void setFields();
void setCharacter();
void setUnsignedDecimal();
void setHexadecimal();
private:
signals:
};
class DataWindow: public QFrame
{
Q_OBJECT
public:
DataWindow(QWidget *parent = 0);
void setFontHeightAndWidth(int height, int width);
void request(DataItem *item);
int level;
QVBoxLayout *layout;
private slots:
void receiveVariableDefinition(QStringList);
void resetData();
void receiveClasses(QHash<QString, ClassDefinition> c);
void receiveVar(DataMap *group, QString name, QString value);
void receiveGlobals(QList<VariableDefinition>);
void receiveLocals(QList<VariableDefinition>);
void receiveParameters(QList<VariableDefinition>);
private:
QSize sizeHint() const;
int fontHeight;
int fontWidth;
signals:
void requestVar(DataMap*,QString,QString,QString,QString,int,int,int);
};
#endif