[Lldb-commits] [lldb] r148491 - in /lldb/trunk: source/Commands/CommandObjectSettings.cpp source/Commands/CommandObjectSettings.h source/Interpreter/Args.cpp test/functionalities/abbreviation/TestAbbreviations.py test/functionalities/abbreviation/change_prompt.lldb test/settings/TestSettings.py
Johnny Chen
johnny.chen at apple.com
Thu Jan 19 11:22:41 PST 2012
Author: johnny
Date: Thu Jan 19 13:22:41 2012
New Revision: 148491
URL: http://llvm.org/viewvc/llvm-project?rev=148491&view=rev
Log:
rdar://problem/10712130
Fixed an issue where backtick char is not properly honored when setting the frame-format variable, like the following:
(lldb) settings set frame-format frame #${frame.index}: ${frame.pc}{ ${module.file.basename}{`${function.name-with-args}${function.pc-offset}}}{ at ${line.file.basename}:${line.number}}\n
(lldb) settings show frame-format
frame-format (string) = "frame #${frame.index}: ${frame.pc}{ `${module.file.basename}{${function.name-with-args}${function.pc-offset}}}{` at ${line.file.basename}:${line.number}}\n"
(lldb)
o CommandObjectSettings.h/.cpp:
Modify the command object impl to require raw command string instead of parsed command string,
which also fixes an outstanding issue that customizing the prompt with trailing spaces doesn't
work.
o Args.cpp:
During CommandInterpreter::HandleCommand(), there is a PreprocessCommand phase which already
strips/processes pairs of backticks as an expression eval step. There's no need to treat
a backtick as starting a quote.
o TestAbbreviations.py and change_prompt.lldb:
Fixed incorrect test case/logic.
o TestSettings.py:
Remove expectedFailure decorator.
Modified:
lldb/trunk/source/Commands/CommandObjectSettings.cpp
lldb/trunk/source/Commands/CommandObjectSettings.h
lldb/trunk/source/Interpreter/Args.cpp
lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py
lldb/trunk/test/functionalities/abbreviation/change_prompt.lldb
lldb/trunk/test/settings/TestSettings.py
Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=148491&r1=148490&r2=148491&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Thu Jan 19 13:22:41 2012
@@ -108,13 +108,24 @@
}
+#include "llvm/ADT/StringRef.h"
+static inline void StripLeadingSpaces(llvm::StringRef &Str)
+{
+ while (!Str.empty() && isspace(Str[0]))
+ Str = Str.substr(1);
+}
bool
-CommandObjectSettingsSet::Execute (Args& command, CommandReturnObject &result)
+CommandObjectSettingsSet::ExecuteRawCommandString (const char *raw_command, CommandReturnObject &result)
{
UserSettingsControllerSP usc_sp (Debugger::GetSettingsController ());
- const int argc = command.GetArgumentCount ();
+ Args cmd_args(raw_command);
+
+ // Process possible options.
+ if (!ParseOptions (cmd_args, result))
+ return false;
+ const int argc = cmd_args.GetArgumentCount ();
if ((argc < 2) && (!m_options.m_reset))
{
result.AppendError ("'settings set' takes more arguments");
@@ -122,8 +133,7 @@
return false;
}
- const char *var_name = command.GetArgumentAtIndex (0);
- std::string var_name_string;
+ const char *var_name = cmd_args.GetArgumentAtIndex (0);
if ((var_name == NULL) || (var_name[0] == '\0'))
{
result.AppendError ("'settings set' command requires a valid variable name; No value supplied");
@@ -131,17 +141,15 @@
return false;
}
- var_name_string = var_name;
- command.Shift();
-
- const char *var_value;
- std::string value_string;
-
- command.GetQuotedCommandString (value_string);
- var_value = value_string.c_str();
+ // Split the raw command into var_name and value pair.
+ std::string var_name_string = var_name;
+ llvm::StringRef raw_str(raw_command);
+ llvm::StringRef value_str = raw_str.split(var_name_string).second;
+ StripLeadingSpaces(value_str);
+ std::string value_string = value_str.str();
if (!m_options.m_reset
- && var_value == NULL)
+ && value_string.empty())
{
result.AppendError ("'settings set' command requires a valid variable value unless using '--reset' option;"
" No value supplied");
@@ -150,7 +158,7 @@
else
{
Error err = usc_sp->SetVariable (var_name_string.c_str(),
- var_value,
+ value_string.c_str(),
eVarSetOperationAssign,
m_options.m_override,
m_interpreter.GetDebugger().GetInstanceName().AsCString());
Modified: lldb/trunk/source/Commands/CommandObjectSettings.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.h?rev=148491&r1=148490&r2=148491&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectSettings.h (original)
+++ lldb/trunk/source/Commands/CommandObjectSettings.h Thu Jan 19 13:22:41 2012
@@ -50,7 +50,15 @@
virtual bool
Execute (Args& command,
- CommandReturnObject &result);
+ CommandReturnObject &result)
+ { return false; }
+
+ virtual bool
+ WantsRawCommandString() { return true; }
+
+ virtual bool
+ ExecuteRawCommandString (const char *raw_command,
+ CommandReturnObject &result);
virtual Options *
GetOptions ();
Modified: lldb/trunk/source/Interpreter/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=148491&r1=148490&r2=148491&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Args.cpp (original)
+++ lldb/trunk/source/Interpreter/Args.cpp Thu Jan 19 13:22:41 2012
@@ -168,7 +168,7 @@
if (command && command[0])
{
static const char *k_space_separators = " \t";
- static const char *k_space_separators_with_slash_and_quotes = " \t \\'\"`";
+ static const char *k_space_separators_with_slash_and_quotes = " \t \\'\"";
const char *arg_end = NULL;
const char *arg_pos;
for (arg_pos = command;
@@ -280,10 +280,7 @@
first_quote_char = quote_char;
arg_pos = arg_end;
-
- if (quote_char != '`')
- ++arg_pos; // Skip the quote character if it is not a backtick
-
+ ++arg_pos; // Skip the quote character
arg_piece_start = arg_pos; // Note we are starting from later in the string
// Skip till the next quote character
@@ -298,13 +295,7 @@
if (end_quote)
{
if (end_quote > arg_piece_start)
- {
- // Keep the backtick quote on commands
- if (quote_char == '`')
- arg.append (arg_piece_start, end_quote + 1 - arg_piece_start);
- else
- arg.append (arg_piece_start, end_quote - arg_piece_start);
- }
+ arg.append (arg_piece_start, end_quote - arg_piece_start);
// If the next character is a space or the end of
// string, this argument is complete...
Modified: lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py?rev=148491&r1=148490&r2=148491&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py (original)
+++ lldb/trunk/test/functionalities/abbreviation/TestAbbreviations.py Thu Jan 19 13:22:41 2012
@@ -38,7 +38,7 @@
patterns = ["Executing commands in '.*change_prompt.lldb'"])
self.expect("settings show prompt",
- startstr = 'prompt (string) = "[old-oak]"')
+ startstr = 'prompt (string) = "[with-three-trailing-spaces] "')
self.runCmd("settings set -r prompt")
@@ -51,7 +51,7 @@
self.runCmd("se se prompt Sycamore> ")
self.expect("se sh prompt",
- startstr = 'prompt (string) = "Sycamore>"')
+ startstr = 'prompt (string) = "Sycamore> "')
self.runCmd("se se -r prompt")
self.expect("set sh prompt",
Modified: lldb/trunk/test/functionalities/abbreviation/change_prompt.lldb
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/abbreviation/change_prompt.lldb?rev=148491&r1=148490&r2=148491&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/abbreviation/change_prompt.lldb (original)
+++ lldb/trunk/test/functionalities/abbreviation/change_prompt.lldb Thu Jan 19 13:22:41 2012
@@ -1 +1,2 @@
-settings set prompt [old-oak]
+settings set prompt [with-three-trailing-spaces]
+
Modified: lldb/trunk/test/settings/TestSettings.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=148491&r1=148490&r2=148491&view=diff
==============================================================================
--- lldb/trunk/test/settings/TestSettings.py (original)
+++ lldb/trunk/test/settings/TestSettings.py Thu Jan 19 13:22:41 2012
@@ -58,7 +58,6 @@
substrs = ["term-width (int) = 70"])
#rdar://problem/10712130
- @unittest2.expectedFailure
def test_set_frame_format(self):
"""Test that 'set frame-format' with a backtick char in the format string works as well as fullpath."""
self.buildDefault()
More information about the lldb-commits
mailing list