[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdevelop/languages/cpp/debugger
From: Vladimir Prus <ghost () cs ! msu ! su>
Date: 2005-07-18 8:34:18
Message-ID: 1121675658.367148.6053.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 435790 by vprus:
Strip type enclosed in {} from the front of the value.
A previous patch stipped type inside (), but it turns out that when
printing values of function, gdb uses {}, so we need to strip
them too.
Ideally, we'd tell gdb to avoid any type decoration, but it's not
possible, even in MI mode.
* gdbparser.cpp (GDBParser::getValue): New parameter 'type'.
The 'type' is pointer (and not array!), strip leading
{}-eclosed part of the value.
Also, when stripping ()-enclosed part, use 'skipDelim' not
manual loop.
M +23 -14 gdbparser.cpp
M +1 -1 gdbparser.h
--- trunk/KDE/kdevelop/languages/cpp/debugger/gdbparser.cpp #435789:435790
@@ -15,6 +15,7 @@
#include "gdbparser.h"
#include "variablewidget.h"
+#include <kdebug.h>
#include <qregexp.h>
@@ -86,7 +87,7 @@
dataType = determineType(buf);
}
- QCString value = getValue(&buf, requested);
+ QCString value = getValue(dataType, &buf, requested);
setItem(parent, varName, dataType, value, requested, params);
}
}
@@ -103,7 +104,7 @@
return;
DataType dataType = determineType(buf);
- QCString value = getValue(&buf, false);
+ QCString value = getValue(dataType, &buf, false);
QString varName = elementRoot.arg(idx);
setItem(parent, varName, dataType, value, false, false);
@@ -133,16 +134,31 @@
// **************************************************************************
-QCString GDBParser::getValue(char **buf, bool requested)
+QCString GDBParser::getValue(DataType type, char **buf, bool requested)
{
char *start = skipNextTokenStart(*buf);
*buf = skipTokenValue(start);
if (*start == '{')
- return QCString(start+1, *buf - start -1);
-
- if (*start == '(')
{
+ // Gdb uses '{' in two cases:
+ // - composites (arrays and structures)
+ // - pointers to functions. In this case type is
+ // enclosed in "{}". Not sure why it's so, as
+ // when printing pointer, type is in parenthesis.
+ if (type == typePointer)
+ {
+ // Looks like type in braces at the beginning. Strip it.
+ start = skipDelim(start, '{', '}');
+ }
+ else
+ {
+ // Looks like composite, strip the braces and return.
+ return QCString(start+1, *buf - start -1);
+ }
+ }
+ else if (*start == '(')
+ {
// Strip the type of the pointer from the value.
//
// When printing values of pointers, gdb prints the pointer
@@ -160,14 +176,7 @@
// characters if its function pointer. So count opening and closing
// parentheses.
- ++start;
- for(unsigned count = 1; *start && count > 0; ++start)
- {
- if (*start == '(')
- ++count;
- else if (*start == ')')
- --count;
- }
+ start = skipDelim(start, '(', ')');
}
QCString value(start, *buf - start + 1);
--- trunk/KDE/kdevelop/languages/cpp/debugger/gdbparser.h #435789:435790
@@ -46,7 +46,7 @@
char *skipNextTokenStart(char *buf) const;
QString getName(char **buf);
- QCString getValue(char **buf, bool requested);
+ QCString getValue(DataType type, char **buf, bool requested);
void setItem(TrimmableItem *parent, const QString &varName, DataType dataType,
const QCString &value, bool requested, bool params);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic