File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,10 @@ class ValueImpl {
114
114
lldb::ValueObjectSP value_sp = m_valobj_sp;
115
115
116
116
Target *target = value_sp->GetTargetSP ().get ();
117
+ // If this ValueObject holds an error, then it is valuable for that.
118
+ if (value_sp->GetError ().Fail ())
119
+ return value_sp;
120
+
117
121
if (!target)
118
122
return ValueObjectSP ();
119
123
@@ -1047,7 +1051,12 @@ lldb::SBFrame SBValue::GetFrame() {
1047
1051
}
1048
1052
1049
1053
lldb::ValueObjectSP SBValue::GetSP (ValueLocker &locker) const {
1050
- if (!m_opaque_sp || !m_opaque_sp->IsValid ()) {
1054
+ // IsValid means that the SBValue has a value in it. But that's not the
1055
+ // only time that ValueObjects are useful. We also want to return the value
1056
+ // if there's an error state in it.
1057
+ if (!m_opaque_sp || (!m_opaque_sp->IsValid ()
1058
+ && (m_opaque_sp->GetRootSP ()
1059
+ && !m_opaque_sp->GetRootSP ()->GetError ().Fail ()))) {
1051
1060
locker.GetError ().SetErrorString (" No value" );
1052
1061
return ValueObjectSP ();
1053
1062
}
Original file line number Diff line number Diff line change @@ -1250,6 +1250,15 @@ bool ValueObject::DumpPrintableRepresentation(
1250
1250
Stream &s, ValueObjectRepresentationStyle val_obj_display,
1251
1251
Format custom_format, PrintableRepresentationSpecialCases special,
1252
1252
bool do_dump_error) {
1253
+
1254
+ // If the ValueObject has an error, we might end up dumping the type, which
1255
+ // is useful, but if we don't even have a type, then don't examine the object
1256
+ // further as that's not meaningful, only the error is.
1257
+ if (m_error.Fail () && !GetCompilerType ().IsValid ()) {
1258
+ if (do_dump_error)
1259
+ s.Printf (" <%s>" , m_error.AsCString ());
1260
+ return false ;
1261
+ }
1253
1262
1254
1263
Flags flags (GetTypeInfo ());
1255
1264
@@ -1451,6 +1460,8 @@ bool ValueObject::DumpPrintableRepresentation(
1451
1460
if (!str.empty ())
1452
1461
s << str;
1453
1462
else {
1463
+ // We checked for errors at the start, but do it again here in case
1464
+ // realizing the value for dumping produced an error.
1454
1465
if (m_error.Fail ()) {
1455
1466
if (do_dump_error)
1456
1467
s.Printf (" <%s>" , m_error.AsCString ());
Original file line number Diff line number Diff line change @@ -71,6 +71,18 @@ void ValueObjectPrinter::Init(
71
71
}
72
72
73
73
bool ValueObjectPrinter::PrintValueObject () {
74
+ if (!m_orig_valobj)
75
+ return false ;
76
+
77
+ // If the incoming ValueObject is in an error state, the best we're going to
78
+ // get out of it is its type. But if we don't even have that, just print
79
+ // the error and exit early.
80
+ if (m_orig_valobj->GetError ().Fail ()
81
+ && !m_orig_valobj->GetCompilerType ().IsValid ()) {
82
+ m_stream->Printf (" Error: '%s'" , m_orig_valobj->GetError ().AsCString ());
83
+ return true ;
84
+ }
85
+
74
86
if (!GetMostSpecializedValue () || m_valobj == nullptr )
75
87
return false ;
76
88
You can’t perform that action at this time.
0 commit comments