From 749beeeb457744416707454bf1f1aa400736560b Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 7 Jan 2010 15:22:06 +0100 Subject: [PATCH] debugger: gracefully handle optimized out values --- share/qtcreator/gdbmacros/dumper.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/share/qtcreator/gdbmacros/dumper.py b/share/qtcreator/gdbmacros/dumper.py index efef1841abc..b7ba0740e6b 100644 --- a/share/qtcreator/gdbmacros/dumper.py +++ b/share/qtcreator/gdbmacros/dumper.py @@ -359,7 +359,8 @@ class FrameCommand(gdb.Command): # Locals # for item in listOfLocals(): - #warn("ITEM %s: " % item.value) + #warn("ITEM NAME %s: " % item.name) + #warn("ITEM VALUE %s: " % item.value) type = item.value.type if type.code == gdb.TYPE_CODE_PTR \ @@ -391,11 +392,24 @@ class FrameCommand(gdb.Command): else: # A "normal" local variable or parameter - d.beginHash() - d.put('iname="%s",' % item.iname) - d.put('addr="%s",' % cleanAddress(item.value.address)) - d.safePutItemHelper(item) - d.endHash() + try: + addr = cleanAddress(item.value.address) + d.beginHash() + d.put('iname="%s",' % item.iname) + d.put('addr="%s",' % addr) + d.safePutItemHelper(item) + d.endHash() + except AttributeError: + # thrown by cleanAddreas with message + # "'NoneType' object has no attribute 'cast'" + # for optimized-out values + d.beginHash() + d.put('iname="%s",' % item.iname) + d.put('name="%s",' % item.name) + d.put('addr="",') + d.put('value="",') + d.put('type="%s"' % item.value.type) + d.endHash() d.pushOutput() locals = d.safeoutput