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