We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6b0d606 commit 199243dCopy full SHA for 199243d
scripts/pretty-printers/gdb/pretty_printers.py
@@ -24,12 +24,17 @@ def to_string(self):
24
typed_pointer = "((const {} *){})".format(self.val.type, raw_address.split(None, 1)[0])
25
26
# Check that the pointer is not null.
27
- if gdb.parse_and_eval(typed_pointer + " == 0"):
+ null_ptr = gdb.parse_and_eval("{} == 0".format(typed_pointer))
28
+ if null_ptr.is_optimized_out:
29
+ return "<Ptr optimized out>"
30
+ if null_ptr:
31
return ""
32
33
# If it isn't attempt to find the string.
- value = "(*{})".format(typed_pointer)
- return gdb.parse_and_eval(value + ".c_str()")
34
+ value = gdb.parse_and_eval("{}->c_str()".format(typed_pointer))
35
+ if value.is_optimized_out:
36
+ return "<Optimized out>"
37
+ return value
38
except:
39
40
0 commit comments