Commit 298e2de7 authored by hjk's avatar hjk

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: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 005f5116
......@@ -100,20 +100,16 @@ 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
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)
items.append(item)
continue
item.value = frame.read_var(name)
items.append(item)
continue
except:
# RuntimeError: happens for
# void foo() { std::string s; std::wstring w; }
......@@ -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,28 +1062,19 @@ 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.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.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.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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment