[Lldb-commits] [lldb] r147741 - in /lldb/trunk: include/lldb/Core/ValueObject.h source/Core/ValueObject.cpp
Greg Clayton
gclayton at apple.com
Sat Jan 7 12:58:08 PST 2012
Author: gclayton
Date: Sat Jan 7 14:58:07 2012
New Revision: 147741
URL: http://llvm.org/viewvc/llvm-project?rev=147741&view=rev
Log:
Recursive calls to ValueObject::GetSummaryAsCString() are causing crashes.
The previous approach to controlling the recursion was doing it from
outside the function which is not reliable. Now it is being done inside
the function. This might not solve all of the crashes that we were seeing
since there are other functions that clear the bit that indicates that
the summary is in the process of being generated, but it might solve some.
Modified:
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/source/Core/ValueObject.cpp
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=147741&r1=147740&r2=147741&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Sat Jan 7 14:58:07 2012
@@ -951,7 +951,7 @@
m_forced_summary_format = format;
m_user_id_of_forced_summary = m_update_point.GetModID();
m_summary_str.clear();
- m_trying_summary_already = false;
+ m_is_getting_summary = false;
}
lldb::SummaryFormatSP
@@ -987,7 +987,7 @@
{
m_last_summary_format = format;
m_summary_str.clear();
- m_trying_summary_already = false;
+ m_is_getting_summary = false;
}
void
@@ -1109,7 +1109,7 @@
m_is_bitfield_for_scalar:1,
m_is_expression_path_child:1,
m_is_child_at_offset:1,
- m_trying_summary_already:1; // used to prevent endless recursion in printing summaries
+ m_is_getting_summary:1;
friend class ClangExpressionDeclMap; // For GetValue
friend class ClangExpressionVariable; // For SetName
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=147741&r1=147740&r2=147741&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Sat Jan 7 14:58:07 2012
@@ -95,7 +95,7 @@
m_is_bitfield_for_scalar(false),
m_is_expression_path_child(false),
m_is_child_at_offset(false),
- m_trying_summary_already(false)
+ m_is_getting_summary(false)
{
m_manager->ManageObject(this);
}
@@ -141,7 +141,7 @@
m_is_bitfield_for_scalar(false),
m_is_expression_path_child(false),
m_is_child_at_offset(false),
- m_trying_summary_already(false)
+ m_is_getting_summary(false)
{
m_manager = new ValueObjectManager();
m_manager->ManageObject (this);
@@ -564,6 +564,13 @@
const char *
ValueObject::GetSummaryAsCString ()
{
+ // Watch for recursion which can happen with summary strings and other
+ // variable formatting options.
+ if (m_is_getting_summary)
+ return NULL;
+
+ m_is_getting_summary = true;
+
if (UpdateValueIfNeeded (true))
{
if (m_summary_str.empty())
@@ -635,6 +642,7 @@
}
}
}
+ m_is_getting_summary = false;
if (m_summary_str.empty())
return NULL;
return m_summary_str.c_str();
@@ -1129,33 +1137,32 @@
case eDisplayValue:
return_value = GetValueAsCString();
break;
+
case eDisplaySummary:
- if (m_trying_summary_already)
- return_value = NULL;
- else
- {
- m_trying_summary_already = true;
- return_value = GetSummaryAsCString();
- m_trying_summary_already = false;
- break;
- }
+ return_value = GetSummaryAsCString();
+ break;
+
case eDisplayLanguageSpecific:
return_value = GetObjectDescription();
break;
+
case eDisplayLocation:
return_value = GetLocationAsCString();
break;
+
case eDisplayChildrenCount:
- {
- alloc_mem.resize(512);
- return_value = &alloc_mem[0];
- int count = GetNumChildren();
- snprintf((char*)return_value, 512, "%d", count);
+ {
+ alloc_mem.resize(512);
+ return_value = &alloc_mem[0];
+ int count = GetNumChildren();
+ snprintf((char*)return_value, 512, "%d", count);
+ }
break;
- }
+
case eDisplayType:
return_value = GetTypeName().AsCString();
break;
+
default:
break;
}
@@ -3742,7 +3749,7 @@
m_value_str.clear();
m_summary_str.clear();
m_object_desc_str.clear();
- m_trying_summary_already = false;
+ m_is_getting_summary = false;
}
SymbolContextScope *
More information about the lldb-commits
mailing list