Skip to content
Snippets Groups Projects
Commit 2c1c22fb authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Debugger[New CDB]: Move index bookkeeping into SymbolGroup.

To enable creating lightweight value classes for dumping.
Add some fixes for inames (template base classes). Fix
find().
parent 2cd3ba8c
No related branches found
No related tags found
No related merge requests found
...@@ -67,7 +67,7 @@ static inline StringContainer commandTokens(PCSTR args, int *token = 0) ...@@ -67,7 +67,7 @@ static inline StringContainer commandTokens(PCSTR args, int *token = 0)
typedef StringContainer::iterator ContainerIterator; typedef StringContainer::iterator ContainerIterator;
if (token) if (token)
*token = 0; *token = -1; // Handled as 'display' in engine, so that user can type commands
std::string cmd(args); std::string cmd(args);
simplify(cmd); simplify(cmd);
StringContainer tokens; StringContainer tokens;
......
This diff is collapsed.
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
std::ostream &operator<<(std::ostream &, const DEBUG_SYMBOL_PARAMETERS&p); std::ostream &operator<<(std::ostream &, const DEBUG_SYMBOL_PARAMETERS&p);
class SymbolGroupNodeVisitor; class SymbolGroupNodeVisitor;
class SymbolGroup;
// Thin wrapper around a symbol group entry. // Thin wrapper around a symbol group entry.
class SymbolGroupNode { class SymbolGroupNode {
...@@ -53,7 +54,8 @@ public: ...@@ -53,7 +54,8 @@ public:
typedef SymbolGroupNodePtrVector::iterator SymbolGroupNodePtrVectorIterator; typedef SymbolGroupNodePtrVector::iterator SymbolGroupNodePtrVectorIterator;
typedef SymbolGroupNodePtrVector::const_iterator SymbolGroupNodePtrVectorConstIterator; typedef SymbolGroupNodePtrVector::const_iterator SymbolGroupNodePtrVectorConstIterator;
explicit SymbolGroupNode(CIDebugSymbolGroup *symbolGroup, explicit SymbolGroupNode(SymbolGroup *symbolGroup,
ULONG index,
const std::string &name, const std::string &name,
const std::string &iname, const std::string &iname,
SymbolGroupNode *parent = 0); SymbolGroupNode *parent = 0);
...@@ -65,7 +67,7 @@ public: ...@@ -65,7 +67,7 @@ public:
SymbolParameterVector::size_type parameterOffset, SymbolParameterVector::size_type parameterOffset,
const SymbolParameterVector &vec); const SymbolParameterVector &vec);
static SymbolGroupNode *create(CIDebugSymbolGroup *sg, const std::string &name, const SymbolParameterVector &vec); static SymbolGroupNode *create(SymbolGroup *sg, const std::string &name, const SymbolParameterVector &vec);
const std::string &name() const { return m_name; } const std::string &name() const { return m_name; }
std::string fullIName() const; std::string fullIName() const;
...@@ -77,35 +79,36 @@ public: ...@@ -77,35 +79,36 @@ public:
// I/O: Gdbmi dump for Visitors // I/O: Gdbmi dump for Visitors
void dump(std::ostream &str, unsigned child, unsigned depth, void dump(std::ostream &str, unsigned child, unsigned depth,
bool humanReadable, ULONG &index) const; bool humanReadable) const;
void dumpChildrenVisited(std::ostream &str, bool humanReadable) const; void dumpChildrenVisited(std::ostream &str, bool humanReadable) const;
// I/O: debug for Visitors // I/O: debug for Visitors
void debug(std::ostream &os, unsigned verbosity, unsigned depth, ULONG index) const; void debug(std::ostream &os, unsigned verbosity, unsigned depth) const;
std::wstring rawValue(ULONG index) const; std::wstring rawValue() const;
std::wstring fixedValue(ULONG index) const; std::wstring fixedValue() const;
ULONG64 address(ULONG index) const; ULONG64 address() const;
bool accept(SymbolGroupNodeVisitor &visitor, unsigned child, unsigned depth, ULONG &index) const; bool accept(SymbolGroupNodeVisitor &visitor, unsigned child, unsigned depth) const;
// Skip indexes of all children bool expand(std::string *errorMessage);
ULONG recursiveIndexOffset() const;
bool expand(ULONG index, std::string *errorMessage);
ULONG subElements() const { return m_parameters.SubElements; } ULONG subElements() const { return m_parameters.SubElements; }
ULONG index() const { return m_index; }
unsigned flags() const { return m_flags; } unsigned flags() const { return m_flags; }
void setFlags(unsigned f) { m_flags = f; } void setFlags(unsigned f) { m_flags = f; }
private: private:
// Return allocated wide string array of value // Return allocated wide string array of value
wchar_t *getValue(ULONG index, ULONG *obtainedSize = 0) const; wchar_t *getValue(ULONG *obtainedSize = 0) const;
std::string getType(ULONG index) const; std::string getType() const;
bool isArrayElement() const; bool isArrayElement() const;
// Notify about expansion of a node, shift indexes
bool notifyExpanded(ULONG index, ULONG insertedCount);
CIDebugSymbolGroup *const m_symbolGroup; SymbolGroup *const m_symbolGroup;
SymbolGroupNode *m_parent; SymbolGroupNode *m_parent;
ULONG m_index;
DEBUG_SYMBOL_PARAMETERS m_parameters; // Careful when using ParentSymbol. It might not be correct. DEBUG_SYMBOL_PARAMETERS m_parameters; // Careful when using ParentSymbol. It might not be correct.
SymbolGroupNodePtrVector m_children; SymbolGroupNodePtrVector m_children;
const std::string m_name; const std::string m_name;
...@@ -113,7 +116,7 @@ private: ...@@ -113,7 +116,7 @@ private:
unsigned m_flags; unsigned m_flags;
}; };
/* Visitor that takes care of iterating over the nodes and the index bookkeeping. /* Visitor that takes care of iterating over the nodes
* visit() is not called for the (invisible) root node, but starting with the * visit() is not called for the (invisible) root node, but starting with the
* root's children with depth=0. * root's children with depth=0.
* Return true from visit() to terminate the recursion. */ * Return true from visit() to terminate the recursion. */
...@@ -129,7 +132,7 @@ public: ...@@ -129,7 +132,7 @@ public:
virtual ~SymbolGroupNodeVisitor() {} virtual ~SymbolGroupNodeVisitor() {}
private: private:
virtual bool visit(const SymbolGroupNode *node, unsigned child, unsigned depth, ULONG index) = 0; virtual bool visit(const SymbolGroupNode *node, unsigned child, unsigned depth) = 0;
// Helper for formatting output. // Helper for formatting output.
virtual void childrenVisited(const SymbolGroupNode * /* node */, unsigned /* depth */) {} virtual void childrenVisited(const SymbolGroupNode * /* node */, unsigned /* depth */) {}
}; };
...@@ -169,7 +172,8 @@ public: ...@@ -169,7 +172,8 @@ public:
unsigned frame() const { return m_frame; } unsigned frame() const { return m_frame; }
ULONG threadId() const { return m_threadId; } ULONG threadId() const { return m_threadId; }
const SymbolGroupNode *root() { return m_root; } SymbolGroupNode *root() { return m_root; }
const SymbolGroupNode *root() const { return m_root; }
// Expand a node list "locals.i1,locals.i2", expanding all nested child nodes // Expand a node list "locals.i1,locals.i2", expanding all nested child nodes
// (think mkdir -p). // (think mkdir -p).
...@@ -188,6 +192,8 @@ public: ...@@ -188,6 +192,8 @@ public:
const std::string &value, const std::string &value,
std::string *errorMessage); std::string *errorMessage);
CIDebugSymbolGroup *debugSymbolGroup() const { return m_symbolGroup; }
static bool getSymbolParameters(CIDebugSymbolGroup *m_symbolGroup, static bool getSymbolParameters(CIDebugSymbolGroup *m_symbolGroup,
unsigned long start, unsigned long start,
unsigned long count, unsigned long count,
...@@ -195,8 +201,8 @@ public: ...@@ -195,8 +201,8 @@ public:
std::string *errorMessage); std::string *errorMessage);
private: private:
SymbolGroupNode *find(const std::string &iname, ULONG *index = 0) const; SymbolGroupNode *find(const std::string &iname) const;
inline SymbolGroupNode *findI(const std::string &iname, ULONG *index = 0) const; inline SymbolGroupNode *findI(const std::string &iname) const;
static bool getSymbolParameters(CIDebugSymbolGroup *m_symbolGroup, static bool getSymbolParameters(CIDebugSymbolGroup *m_symbolGroup,
SymbolParameterVector *vec, SymbolParameterVector *vec,
std::string *errorMessage); std::string *errorMessage);
...@@ -204,7 +210,7 @@ private: ...@@ -204,7 +210,7 @@ private:
CIDebugSymbolGroup * const m_symbolGroup; CIDebugSymbolGroup * const m_symbolGroup;
const unsigned m_frame; const unsigned m_frame;
const ULONG m_threadId; const ULONG m_threadId;
SymbolGroupNode *const m_root; SymbolGroupNode *m_root;
}; };
// Debug output visitor. // Debug output visitor.
...@@ -213,7 +219,7 @@ public: ...@@ -213,7 +219,7 @@ public:
explicit DebugSymbolGroupNodeVisitor(std::ostream &os, unsigned verbosity = 0); explicit DebugSymbolGroupNodeVisitor(std::ostream &os, unsigned verbosity = 0);
private: private:
virtual bool visit(const SymbolGroupNode *node, unsigned child, unsigned depth, ULONG index); virtual bool visit(const SymbolGroupNode *node, unsigned child, unsigned depth);
std::ostream &m_os; std::ostream &m_os;
const unsigned m_verbosity; const unsigned m_verbosity;
...@@ -225,7 +231,7 @@ public: ...@@ -225,7 +231,7 @@ public:
explicit DumpSymbolGroupNodeVisitor(std::ostream &os, bool humanReadable); explicit DumpSymbolGroupNodeVisitor(std::ostream &os, bool humanReadable);
private: private:
virtual bool visit(const SymbolGroupNode *node, unsigned child, unsigned depth, ULONG index); virtual bool visit(const SymbolGroupNode *node, unsigned child, unsigned depth);
virtual void childrenVisited(const SymbolGroupNode * node, unsigned depth); virtual void childrenVisited(const SymbolGroupNode * node, unsigned depth);
std::ostream &m_os; std::ostream &m_os;
......
...@@ -1420,6 +1420,10 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what ...@@ -1420,6 +1420,10 @@ void CdbEngine::handleExtensionMessage(char t, int token, const QByteArray &what
// Is there a reply expected, some command queued? // Is there a reply expected, some command queued?
if (t == 'R' || t == 'N') { if (t == 'R' || t == 'N') {
if (token == -1) { // Default token, user typed in extension command
showMessage(QString::fromLatin1(message), LogMisc);
return;
}
const int index = indexOfCommand(m_extensionCommandQueue, token); const int index = indexOfCommand(m_extensionCommandQueue, token);
if (index != -1) { if (index != -1) {
// Did the command finish? Take off queue and complete, invoke CB // Did the command finish? Take off queue and complete, invoke CB
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment