Debugger: Show simple values with LLDB backend

Change-Id: Iccef8c0ddb1951da1b09b13b1ce2a0cee716c30f
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
hjk
2013-04-04 16:43:25 +02:00
parent fe1f7e4bf6
commit 70fc039796
3 changed files with 106 additions and 59 deletions

View File

@@ -11,10 +11,6 @@ gdbLoaded = False
# #
####################################################################### #######################################################################
def warn(message):
print "XXX: %s\n" % message.encode("latin1")
def showException(msg, exType, exValue, exTraceback): def showException(msg, exType, exValue, exTraceback):
warn("**** CAUGHT EXCEPTION: %s ****" % msg) warn("**** CAUGHT EXCEPTION: %s ****" % msg)
try: try:
@@ -24,6 +20,33 @@ def showException(msg, exType, exValue, exTraceback):
except: except:
pass pass
PointerCode = None
ArrayCode = None
StructCode = None
UnionCode = None
EnumCode = None
FlagsCode = None
FunctionCode = None
IntCode = None
FloatCode = None
VoidCode = None
SetCode = None
RangeCode = None
StringCode = None
BitStringCode = None
ErrorTypeCode = None
MethodCode = None
MethodPointerCode = None
MemberPointerCode = None
ReferenceCode = None
CharCode = None
BoolCode = None
ComplexCode = None
TypedefCode = None
NamespaceCode = None
SimpleValueCode = None # LLDB only
####################################################################### #######################################################################
# #
@@ -36,6 +59,7 @@ try:
cdbLoaded = True cdbLoaded = True
except: except:
#warn("LOADING CDB FAILED")
pass pass
@@ -52,6 +76,11 @@ try:
import gdb import gdb
gdbLoaded = True gdbLoaded = True
def warn(message):
print "XXX: %s\n" % message.encode("latin1")
#warn("LOADING GDB")
####################################################################### #######################################################################
# #
# Infrastructure # Infrastructure
@@ -329,6 +358,30 @@ try:
base += 1 base += 1
return s return s
def extractFields(type):
return type.fields()
## Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=10953:
##fields = type.fields()
## Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=11777:
##fields = defsype).fields()
## This seems to work.
##warn("TYPE 0: %s" % type)
#type = stripTypedefs(type)
#fields = type.fields()
#if len(fields):
# return fields
##warn("TYPE 1: %s" % type)
## This fails for arrays. See comment in lookupType.
#type0 = lookupType(str(type))
#if not type0 is None:
# type = type0
#if type.code == FunctionCode:
# return []
##warn("TYPE 2: %s" % type)
#fields = type.fields()
##warn("FIELDS: %s" % fields)
#return fields
####################################################################### #######################################################################
# #
# Types # Types
@@ -435,6 +488,7 @@ try:
except: except:
#warn("LOADING GDB FAILED")
pass pass
@@ -450,43 +504,33 @@ try:
lldbLoaded = True lldbLoaded = True
PointerCode, \ def warn(message):
ArrayCode, \ print "XXX: %s\n" % message.encode("latin1")
#warn("LOADING LLDB")
SimpleValueCode, \
StructCode, \ StructCode, \
UnionCode, \ PointerCode \
EnumCode, \ = range(3)
FlagsCode, \
FunctionCode, \
IntCode, \
FloatCode, \
VoidCode, \
SetCode, \
RangeCode, \
StringCode, \
BitStringCode, \
ErrorTypeCode, \
MethodCode, \
MethodPointerCode, \
MemberPointerCode, \
ReferenceCode, \
CharCode, \
BoolCode, \
ComplexCode, \
TypedefCode, \
NamespaceCode \
= range(24)
def registerCommand(name, func): def registerCommand(name, func):
pass pass
class Type: class Type:
def __init__(self, type): def __init__(self, var):
self.raw = type self.raw = var
self.code = IntCode if var.num_children == 0:
self.code = SimpleValueCode
else:
self.code = StructCode
self.value_type = var.value_type
def __str__(self): def __str__(self):
return self.raw.name #try:
return self.raw.type.name
#except:
# return "<illegal type>"
def unqualified(self): def unqualified(self):
return self return self
@@ -495,11 +539,11 @@ try:
def __init__(self, var): def __init__(self, var):
self.raw = var self.raw = var
self.is_optimized_out = False self.is_optimized_out = False
self.type = Type(var.type) self.address = var.addr
self.type.value_type = var.value_type self.type = Type(var)
def __str__(self): def __str__(self):
return self.name return str(self.raw.value)
currentThread = None currentThread = None
currentFrame = None currentFrame = None
@@ -519,7 +563,11 @@ try:
items.append(item) items.append(item)
return items return items
def extractFields(type):
return type.fields()
except: except:
#warn("LOADING LLDB FAILED")
pass pass

View File

@@ -512,7 +512,8 @@ def isSimpleType(typeobj):
or code == CharCode \ or code == CharCode \
or code == IntCode \ or code == IntCode \
or code == FloatCode \ or code == FloatCode \
or code == EnumCode or code == EnumCode \
or code == SimpleValueCode
def simpleEncoding(typeobj): def simpleEncoding(typeobj):
code = typeobj.code code = typeobj.code
@@ -1494,7 +1495,7 @@ class Dumper:
self.putNumChild(0) self.putNumChild(0)
return return
if type.code == IntCode or type.code == CharCode: if type.code == IntCode or type.code == CharCode or type.code == SimpleValueCode:
self.putType(typeName) self.putType(typeName)
if value.is_optimized_out: if value.is_optimized_out:
self.putValue("<optimized out>") self.putValue("<optimized out>")

View File

@@ -853,35 +853,33 @@ void LldbEngine::handleBacktrace(const LldbResponse &response)
void LldbEngine::handleListLocals(const LldbResponse &response) void LldbEngine::handleListLocals(const LldbResponse &response)
{ {
//qDebug() << " LOCALS: '" << response.data << "'"; //qDebug() << " LOCALS: '" << response.data << "'";
QByteArray out = response.data.trimmed(); QByteArray out = response.data;
// GdbMi all; {
// all.fromStringMultiple(out); int pos = out.indexOf("data=");
// //qDebug() << "ALL: " << all.toString(); if (pos == -1) {
showMessage(_("UNEXPECTED LOCALS OUTPUT:" + out));
return;
}
// //GdbMi data = all.findChild("data"); // The value in 'out' should be single-quoted as this is
// QList<WatchData> list; // what the command line does with strings.
// WatchHandler *handler = watchHandler(); if (pos != 1) {
// foreach (const GdbMi &child, all.children()) { showMessage(_("DISCARDING JUNK AT BEGIN OF RESPONSE: "
// WatchData dummy; + out.left(pos)));
// dummy.iname = child.findChild("iname").data(); }
// dummy.name = _(child.findChild("name").data());
// //qDebug() << "CHILD: " << child.toString();
// parseWatchData(handler->expandedINames(), dummy, child, &list);
// }
// handler->insertData(list);
const bool partial = response.cookie.toBool();
int pos = out.indexOf("data=");
if (pos != 0) {
showMessage(_("DISCARDING JUNK AT BEGIN OF RESPONSE: "
+ out.left(pos)));
out = out.mid(pos); out = out.mid(pos);
if (out.endsWith('\''))
out.chop(1);
else
showMessage(_("JUNK AT END OF RESPONSE: " + out));
} }
GdbMi all; GdbMi all;
all.fromStringMultiple(out); all.fromStringMultiple(out);
GdbMi data = all.findChild("data"); GdbMi data = all.findChild("data");
const bool partial = response.cookie.toBool();
WatchHandler *handler = watchHandler(); WatchHandler *handler = watchHandler();
QList<WatchData> list; QList<WatchData> list;