From fb6621ef4bbbf27f51769045de9193e74a6be370 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Fri, 6 Dec 2013 21:59:52 +0000 Subject: [PATCH] Add a setting to allow users to enable expressions that crash LLDB to show up in crash logs. llvm-svn: 196613 --- lldb/include/lldb/Target/Target.h | 3 +++ lldb/source/API/SBFrame.cpp | 22 ++++++++++++---------- lldb/source/Target/Target.cpp | 11 ++++++++++- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index f4e1e4e10066..8a48c10c9be7 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -164,6 +164,9 @@ public: bool GetUseFastStepping() const; + + bool + GetDisplayExpressionsInCrashlogs () const; LoadScriptFromSymFile GetLoadScriptFromSymbolFile() const; diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 1a1a63bd0671..cff460208070 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -1386,20 +1386,22 @@ SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &option frame = exe_ctx.GetFramePtr(); if (frame) { -#ifdef LLDB_CONFIGURATION_DEBUG - StreamString frame_description; - frame->DumpUsingSettingsFormat (&frame_description); - Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s", - expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str()); -#endif - exe_results = target->EvaluateExpression (expr, + if (target->GetDisplayExpressionsInCrashlogs()) + { + StreamString frame_description; + frame->DumpUsingSettingsFormat (&frame_description); + Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s", + expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str()); + } + + exe_results = target->EvaluateExpression (expr, frame, expr_value_sp, options.ref()); expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); -#ifdef LLDB_CONFIGURATION_DEBUG - Host::SetCrashDescription (NULL); -#endif + + if (target->GetDisplayExpressionsInCrashlogs()) + Host::SetCrashDescription (NULL); } else { diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 17e5205efde6..0336f7758591 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -2510,6 +2510,7 @@ g_properties[] = "'complete' is the default value for this setting which will load all sections and symbols by reading them from memory (slowest, most accurate). " "'partial' will load sections and attempt to find function bounds without downloading the symbol table (faster, still accurate, missing symbol names). " "'minimal' is the fastest setting and will load section data with no symbols, but should rarely be used as stack frames in these memory regions will be inaccurate and not provide any context (fastest). " }, + { "display-expression-in-crashlogs" , OptionValue::eTypeBoolean , false, false, NULL, NULL, "Expressions that crash will show up in crash logs if the host system supports executable specific crash log strings and this setting is set to true." }, { NULL , OptionValue::eTypeInvalid , false, 0 , NULL, NULL, NULL } }; enum @@ -2541,7 +2542,8 @@ enum ePropertyHexImmediateStyle, ePropertyUseFastStepping, ePropertyLoadScriptFromSymbolFile, - ePropertyMemoryModuleLoadLevel + ePropertyMemoryModuleLoadLevel, + ePropertyDisplayExpressionsInCrashlogs }; @@ -2920,6 +2922,13 @@ TargetProperties::GetUseFastStepping () const return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0); } +bool +TargetProperties::GetDisplayExpressionsInCrashlogs () const +{ + const uint32_t idx = ePropertyDisplayExpressionsInCrashlogs; + return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0); +} + LoadScriptFromSymFile TargetProperties::GetLoadScriptFromSymbolFile () const {