1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
37 #include "symbolgroupnode.h"
43 typedef std::vector<DEBUG_SYMBOL_PARAMETERS> SymbolParameterVector;
46 SymbolGroup(const SymbolGroup &);
47 SymbolGroup &operator=(const SymbolGroup &);
50 explicit SymbolGroup(CIDebugSymbolGroup *,
51 const SymbolParameterVector &vec,
52 const std::string &rootModule,
53 const char *rootName);
56 typedef AbstractSymbolGroupNode::AbstractSymbolGroupNodePtrVector AbstractSymbolGroupNodePtrVector;
58 virtual ~SymbolGroup();
61 std::string dump(const SymbolGroupValueContext &ctx,
62 const DumpParameters &p = DumpParameters()) const;
63 // Expand node and dump
64 std::string dump(const std::string &iname, const SymbolGroupValueContext &ctx,
65 const DumpParameters &p, std::string *errorMessage);
66 std::string debug(const std::string &iname = std::string(),
67 const std::string &filter = std::string(),
68 unsigned verbosity = 0) const;
70 SymbolGroupNode *root() { return m_root; }
71 const SymbolGroupNode *root() const { return m_root; }
72 AbstractSymbolGroupNode *find(const std::string &iname) const;
74 // Expand a single node "locals.A.B" requiring that "locals.A.B" is already visible
75 // (think mkdir without -p).
76 bool expand(const std::string &node, std::string *errorMessage);
77 bool expandRunComplexDumpers(const std::string &node, const SymbolGroupValueContext &ctx, std::string *errorMessage);
78 // Expand a node list "locals.i1,locals.i2", expanding all nested child nodes
80 unsigned expandList(const std::vector<std::string> &nodes, std::string *errorMessage);
81 unsigned expandListRunComplexDumpers(const std::vector<std::string> &nodes,
82 const SymbolGroupValueContext &ctx,
83 std::string *errorMessage);
85 // Mark uninitialized (top level only)
86 void markUninitialized(const std::vector<std::string> &nodes);
88 // Cast an (unexpanded) node
89 bool typeCast(const std::string &iname, const std::string &desiredType, std::string *errorMessage);
90 // Add a symbol by name expression
91 SymbolGroupNode *addSymbol(const std::string &module,
92 const std::string &name, // Expression like 'myarray[1]'
93 const std::string &displayName, // Name to be displayed, defaults to name
94 const std::string &iname, // Desired iname, defaults to name
95 std::string *errorMessage);
96 // Convenience overload for name==displayName
97 SymbolGroupNode *addSymbol(const std::string &module,
98 const std::string &name, // Expression like 'myarray[1]'
99 const std::string &iname,
100 std::string *errorMessage);
102 bool accept(SymbolGroupNodeVisitor &visitor) const;
104 // Assign a value by iname
105 bool assign(const std::string &node,
106 const std::string &value,
107 std::string *errorMessage);
109 CIDebugSymbolGroup *debugSymbolGroup() const { return m_symbolGroup; }
111 static bool getSymbolParameters(CIDebugSymbolGroup *m_symbolGroup,
114 SymbolParameterVector *vec,
115 std::string *errorMessage);
118 static bool getSymbolParameters(CIDebugSymbolGroup *m_symbolGroup,
119 SymbolParameterVector *vec,
120 std::string *errorMessage);
121 bool removeSymbol(AbstractSymbolGroupNode *n, std::string *errorMessage);
124 inline AbstractSymbolGroupNode *findI(const std::string &iname) const;
126 CIDebugSymbolGroup * const m_symbolGroup;
127 SymbolGroupNode *m_root;
130 class LocalsSymbolGroup : public SymbolGroup {
132 explicit LocalsSymbolGroup(CIDebugSymbolGroup *,
133 const SymbolParameterVector &vec,
134 ULONG threadId, unsigned frame,
135 const std::string &function);
137 unsigned frame() const { return m_frame; }
138 std::string function() const { return m_function; }
139 std::string module() const;
140 ULONG threadId() const { return m_threadId; }
142 static LocalsSymbolGroup *create(CIDebugControl *control,
146 std::string *errorMessage);
149 const unsigned m_frame;
150 const ULONG m_threadId;
151 std::string m_function;
154 class WatchesSymbolGroup : public SymbolGroup {
156 typedef std::map<std::string, std::string> InameExpressionMap;
158 static const char *watchInamePrefix;
160 // Add a symbol as 'watch.0' or '0' with expression
161 bool addWatch(CIDebugSymbols *s, std::string iname, const std::string &expression, std::string *errorMessage);
162 // Synchronize watches passing on a map of '0' -> '*(int *)(0xA0)'
163 bool synchronize(CIDebugSymbols *s, const InameExpressionMap &m, std::string *errorMessage);
165 static WatchesSymbolGroup *create(CIDebugSymbols *, std::string *errorMessage);
167 static std::string fixWatchExpression(CIDebugSymbols *s, const std::string &ex);
170 explicit WatchesSymbolGroup(CIDebugSymbolGroup *);
171 InameExpressionMap currentInameExpressionMap() const;
172 inline SymbolGroupNode *rootChildByIname(const std::string &iname) const;
173 static inline std::string fixWatchExpressionI(CIDebugSymbols *s, const std::string &ex);
176 #endif // SYMBOLGROUP_H