Debugger: Centralize handling of optimized out values with GDB

There were a couple of situation where the is_optimized_out flag
was not used and later produced (caught) exceptions on access,
or where the still availably type was not shown.

Change-Id: I7ad5aa09a19357e50739d9fdf32f7423e30fe011
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2014-11-18 15:38:05 +01:00
parent 005f5116a5
commit 298e2de7df

View File

@@ -100,18 +100,14 @@ def listOfLocals():
try:
item.value = frame.read_var(name, block)
#warn("READ 1: %s" % item.value)
if not item.value.is_optimized_out:
#warn("ITEM 1: %s" % item.value)
items.append(item)
continue
except:
pass
try:
item.value = frame.read_var(name)
#warn("READ 2: %s" % item.value)
if not item.value.is_optimized_out:
#warn("ITEM 2: %s" % item.value)
item.value = frame.read_var(name)
items.append(item)
continue
except:
@@ -998,6 +994,13 @@ class Dumper(DumperBase):
type = value.type.unqualified()
typeName = str(type)
if value.is_optimized_out:
self.putValue("<optimized out>")
self.putType(typeName)
self.putNumChild(0)
return
tryDynamic &= self.useDynamicType
self.addToCache(type) # Fill type cache
if tryDynamic:
@@ -1049,9 +1052,7 @@ class Dumper(DumperBase):
if type.code == IntCode or type.code == CharCode:
self.putType(typeName)
if value.is_optimized_out:
self.putValue("<optimized out>")
elif type.sizeof == 1:
if type.sizeof == 1:
# Force unadorned value transport for char and Co.
self.putValue(int(value) & 0xff)
else:
@@ -1061,27 +1062,18 @@ class Dumper(DumperBase):
if type.code == FloatCode or type.code == BoolCode:
self.putType(typeName)
if value.is_optimized_out:
self.putValue("<optimized out>")
else:
self.putValue(value)
self.putNumChild(0)
return
if type.code == EnumCode:
self.putType(typeName)
if value.is_optimized_out:
self.putValue("<optimized out>")
else:
self.putValue("%s (%d)" % (value, value))
self.putNumChild(0)
return
if type.code == ComplexCode:
self.putType(typeName)
if value.is_optimized_out:
self.putValue("<optimized out>")
else:
self.putValue("%s" % value)
self.putNumChild(0)
return
@@ -1118,10 +1110,6 @@ class Dumper(DumperBase):
if type.code == PointerCode:
# This could still be stored in a register and
# potentially dereferencable.
if value.is_optimized_out:
self.putValue("<optimized out>")
return
self.putFormattedPointer(value)
return