summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2014-03-26 22:35:52 +0000
committerGreg Clayton <gclayton@apple.com>2014-03-26 22:35:52 +0000
commitbc711e0575fb6f1b58bfb0cea6b0647bda679490 (patch)
tree6e54d7ceed99271b3f0028eb1bab2b902531060d /lldb/source/Commands
parent23798a973157494f8ae9c7c9503ef1044de4721c (diff)
downloadbcm5719-llvm-bc711e0575fb6f1b58bfb0cea6b0647bda679490.tar.gz
bcm5719-llvm-bc711e0575fb6f1b58bfb0cea6b0647bda679490.zip
Fixed a crasher when using 1 character type names in “type summary”, “type synthetic” and “type filter”.
Also fixed a missing return when making python summary functions on the fly. <rdar://problem/16265491> llvm-svn: 204867
Diffstat (limited to 'lldb/source/Commands')
-rw-r--r--lldb/source/Commands/CommandObjectType.cpp58
1 files changed, 26 insertions, 32 deletions
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index f1b1d2c1900..a8cef0fb1ba 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -17,6 +17,8 @@
// C++ Includes
+#include "llvm/ADT/StringRef.h"
+
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/IOHandler.h"
@@ -204,7 +206,7 @@ public:
static const char *g_summary_addreader_instructions = "Enter your Python command(s). Type 'DONE' to end.\n"
"def function (valobj,internal_dict):\n"
" \"\"\"valobj: an SBValue which you want to provide a summary for\n"
- " internal_dict: an LLDB support object not to be used\"\"\"";
+ " internal_dict: an LLDB support object not to be used\"\"\"\n";
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
if (output_sp)
@@ -1814,6 +1816,25 @@ CommandObjectTypeSummaryAdd::DoExecute (Args& command, CommandReturnObject &resu
return Execute_StringSummary(command, result);
}
+static bool
+FixArrayTypeNameWithRegex (ConstString &type_name)
+{
+ llvm::StringRef type_name_ref(type_name.GetStringRef());
+
+ if (type_name_ref.endswith("[]"))
+ {
+ std::string type_name_str(type_name.GetCString());
+ type_name_str.resize(type_name_str.length()-2);
+ if (type_name_str.back() != ' ')
+ type_name_str.append(" \\[[0-9]+\\]");
+ else
+ type_name_str.append("\\[[0-9]+\\]");
+ type_name.SetCString(type_name_str.c_str());
+ return true;
+ }
+ return false;
+}
+
bool
CommandObjectTypeSummaryAdd::AddSummary(ConstString type_name,
TypeSummaryImplSP entry,
@@ -1826,17 +1847,8 @@ CommandObjectTypeSummaryAdd::AddSummary(ConstString type_name,
if (type == eRegularSummary)
{
- std::string type_name_str(type_name.GetCString());
- if (type_name_str.compare(type_name_str.length() - 2, 2, "[]") == 0)
- {
- type_name_str.resize(type_name_str.length()-2);
- if (type_name_str.back() != ' ')
- type_name_str.append(" \\[[0-9]+\\]");
- else
- type_name_str.append("\\[[0-9]+\\]");
- type_name.SetCString(type_name_str.c_str());
+ if (FixArrayTypeNameWithRegex (type_name))
type = eRegexSummary;
- }
}
if (type == eRegexSummary)
@@ -3897,17 +3909,8 @@ CommandObjectTypeSynthAdd::AddSynth(ConstString type_name,
if (type == eRegularSynth)
{
- std::string type_name_str(type_name.GetCString());
- if (type_name_str.compare(type_name_str.length() - 2, 2, "[]") == 0)
- {
- type_name_str.resize(type_name_str.length()-2);
- if (type_name_str.back() != ' ')
- type_name_str.append(" \\[[0-9]+\\]");
- else
- type_name_str.append("\\[[0-9]+\\]");
- type_name.SetCString(type_name_str.c_str());
- type = eRegularSynth;
- }
+ if (FixArrayTypeNameWithRegex (type_name))
+ type = eRegexSynth;
}
if (category->AnyMatches(type_name,
@@ -4076,17 +4079,8 @@ private:
if (type == eRegularFilter)
{
- std::string type_name_str(type_name.GetCString());
- if (type_name_str.compare(type_name_str.length() - 2, 2, "[]") == 0)
- {
- type_name_str.resize(type_name_str.length()-2);
- if (type_name_str.back() != ' ')
- type_name_str.append(" \\[[0-9]+\\]");
- else
- type_name_str.append("\\[[0-9]+\\]");
- type_name.SetCString(type_name_str.c_str());
+ if (FixArrayTypeNameWithRegex (type_name))
type = eRegexFilter;
- }
}
if (category->AnyMatches(type_name,
OpenPOWER on IntegriCloud