Skip to content

Commit 2330753

Browse files
Merge pull request #8139 from PortalPete/apple/misc/StackFrame-error-handling
[lldb] Correctly check and report error states in StackFrame.cpp
2 parents 608f140 + b42ae55 commit 2330753

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

lldb/source/Target/StackFrame.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -650,15 +650,15 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
650650
Status deref_error;
651651
if (valobj_sp->GetCompilerType().IsReferenceType()) {
652652
valobj_sp = valobj_sp->GetSyntheticValue()->Dereference(deref_error);
653-
if (error.Fail()) {
653+
if (!valobj_sp || deref_error.Fail()) {
654654
error.SetErrorStringWithFormatv(
655655
"Failed to dereference reference type: %s", deref_error);
656656
return ValueObjectSP();
657657
}
658658
}
659659

660660
valobj_sp = valobj_sp->Dereference(deref_error);
661-
if (error.Fail()) {
661+
if (!valobj_sp || deref_error.Fail()) {
662662
error.SetErrorStringWithFormatv(
663663
"Failed to dereference sythetic value: {0}", deref_error);
664664
return ValueObjectSP();
@@ -793,9 +793,9 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
793793
// what we have is *ptr[low]. the most similar C++ syntax is to deref
794794
// ptr and extract bit low out of it. reading array item low would be
795795
// done by saying ptr[low], without a deref * sign
796-
Status error;
797-
ValueObjectSP temp(valobj_sp->Dereference(error));
798-
if (error.Fail()) {
796+
Status deref_error;
797+
ValueObjectSP temp(valobj_sp->Dereference(deref_error));
798+
if (!temp || deref_error.Fail()) {
799799
valobj_sp->GetExpressionPath(var_expr_path_strm);
800800
error.SetErrorStringWithFormat(
801801
"could not dereference \"(%s) %s\"",
@@ -811,9 +811,8 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
811811
// arr[0] (an operation that is equivalent to deref-ing arr) and
812812
// extract bit low out of it. reading array item low would be done by
813813
// saying arr[low], without a deref * sign
814-
Status error;
815814
ValueObjectSP temp(valobj_sp->GetChildAtIndex(0));
816-
if (error.Fail()) {
815+
if (!temp) {
817816
valobj_sp->GetExpressionPath(var_expr_path_strm);
818817
error.SetErrorStringWithFormat(
819818
"could not get item 0 for \"(%s) %s\"",
@@ -1001,9 +1000,9 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
10011000
// deref ptr and extract bits low thru high out of it. reading array
10021001
// items low thru high would be done by saying ptr[low-high], without a
10031002
// deref * sign
1004-
Status error;
1005-
ValueObjectSP temp(valobj_sp->Dereference(error));
1006-
if (error.Fail()) {
1003+
Status deref_error;
1004+
ValueObjectSP temp(valobj_sp->Dereference(deref_error));
1005+
if (!temp || deref_error.Fail()) {
10071006
valobj_sp->GetExpressionPath(var_expr_path_strm);
10081007
error.SetErrorStringWithFormat(
10091008
"could not dereference \"(%s) %s\"",
@@ -1018,9 +1017,8 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
10181017
// get arr[0] (an operation that is equivalent to deref-ing arr) and
10191018
// extract bits low thru high out of it. reading array items low thru
10201019
// high would be done by saying arr[low-high], without a deref * sign
1021-
Status error;
10221020
ValueObjectSP temp(valobj_sp->GetChildAtIndex(0));
1023-
if (error.Fail()) {
1021+
if (!temp) {
10241022
valobj_sp->GetExpressionPath(var_expr_path_strm);
10251023
error.SetErrorStringWithFormat(
10261024
"could not get item 0 for \"(%s) %s\"",

0 commit comments

Comments
 (0)