summaryrefslogtreecommitdiffstats
path: root/lldb/source/Interpreter/OptionGroupVariable.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2012-12-11 22:42:19 +0000
committerEnrico Granata <egranata@apple.com>2012-12-11 22:42:19 +0000
commit9d14084b45320a1b4ff75eec7ede88b15ac3389c (patch)
tree0ee1659d40003336d7b4228117abd670039f5292 /lldb/source/Interpreter/OptionGroupVariable.cpp
parent496970f6eec7697dbda6d02fc4f8dc595a24145f (diff)
downloadbcm5719-llvm-9d14084b45320a1b4ff75eec7ede88b15ac3389c.tar.gz
bcm5719-llvm-9d14084b45320a1b4ff75eec7ede88b15ac3389c.zip
Adding a validation callback mechanism to OptionValueString (such a feature might theoretically be added to the general OptionValue base class should the need arise)
Using this mechanism, making sure that the options to pass a summary string or a named summary to frame variable do not have invalid values <rdar://problem/11576143> llvm-svn: 169927
Diffstat (limited to 'lldb/source/Interpreter/OptionGroupVariable.cpp')
-rw-r--r--lldb/source/Interpreter/OptionGroupVariable.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/lldb/source/Interpreter/OptionGroupVariable.cpp b/lldb/source/Interpreter/OptionGroupVariable.cpp
index 5f1c271525b..e98ff56ec7c 100644
--- a/lldb/source/Interpreter/OptionGroupVariable.cpp
+++ b/lldb/source/Interpreter/OptionGroupVariable.cpp
@@ -15,6 +15,8 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+#include "lldb/Core/DataVisualization.h"
+#include "lldb/Core/Error.h"
#include "lldb/Target/Target.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Utility/Utils.h"
@@ -39,7 +41,22 @@ g_option_table[] =
OptionGroupVariable::OptionGroupVariable (bool show_frame_options) :
OptionGroup(),
- include_frame_options (show_frame_options)
+ include_frame_options (show_frame_options),
+ summary([] (const char* str,void*)->Error
+ {
+ if (!str || !str[0])
+ return Error("must specify a valid named summary");
+ TypeSummaryImplSP summary_sp;
+ if (DataVisualization::NamedSummaryFormats::GetSummaryFormat(ConstString(str), summary_sp) == false)
+ return Error("must specify a valid named summary");
+ return Error();
+ }),
+ summary_string([] (const char* str, void*)->Error
+ {
+ if (!str || !str[0])
+ return Error("must specify a non-empty summary string");
+ return Error();
+ })
{
}
@@ -67,10 +84,10 @@ OptionGroupVariable::SetOptionValue (CommandInterpreter &interpreter,
show_scope = true;
break;
case 'y':
- summary.SetCurrentValue(option_arg);
+ error = summary.SetCurrentValue(option_arg);
break;
case 'z':
- summary_string.SetCurrentValue(option_arg);
+ error = summary_string.SetCurrentValue(option_arg);
break;
default:
error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option);
OpenPOWER on IntegriCloud