diff options
author | Greg Clayton <gclayton@apple.com> | 2011-11-09 23:25:03 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-11-09 23:25:03 +0000 |
commit | 93c62e6607eda45628bc25b2ce9cb312c59700d0 (patch) | |
tree | 8d33cfa42b4efc39a030d58dc77d10364b864f69 /lldb/source/Interpreter/CommandInterpreter.cpp | |
parent | 856977cb1537e37a37eff9da2f26171a06dca3e0 (diff) | |
download | bcm5719-llvm-93c62e6607eda45628bc25b2ce9cb312c59700d0.tar.gz bcm5719-llvm-93c62e6607eda45628bc25b2ce9cb312c59700d0.zip |
<rdar://problem/10374840>
Fixed an issue with the gdb format stuff for any aliases that expand to
contain a "--".
llvm-svn: 144240
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 52 |
1 files changed, 49 insertions, 3 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 73a7085e47b..88696571c93 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -898,6 +898,36 @@ StripLeadingSpaces (std::string &s) } } +static size_t +FindArgumentTerminator (const std::string &s) +{ + printf ("FindArgumentTerminator( s = '%s') => ", s.c_str()); + const size_t s_len = s.size(); + size_t offset = 0; + while (offset < s_len) + { + size_t pos = s.find ("--", offset); + if (pos == std::string::npos) + break; + if (pos > 0) + { + if (isspace(s[pos-1])) + { + // Check if the string ends "\s--" (where \s is a space character) + // or if we have "\s--\s". + if ((pos + 2 >= s_len) || isspace(s[pos+2])) + { + printf ("%zu\n", pos); + return pos; + } + } + } + offset = pos + 2; + } + printf ("-1\n"); + return std::string::npos; +} + static bool ExtractCommand (std::string &command_string, std::string &command, std::string &suffix, char "e_char) { @@ -1367,9 +1397,25 @@ CommandInterpreter::HandleCommand (const char *command_line, Options *command_options = cmd_obj->GetOptions(); if (command_options && command_options->SupportsLongOption("gdb-format")) { - revised_command_line.Printf (" --gdb-format=%s", suffix.c_str() + 1); - if (wants_raw_input && command_string.find ("-- ") == std::string::npos) - revised_command_line.Printf (" --"); + std::string gdb_format_option ("--gdb-format="); + gdb_format_option += (suffix.c_str() + 1); + + bool inserted = false; + std::string &cmd = revised_command_line.GetString(); + size_t arg_terminator_idx = FindArgumentTerminator (cmd); + if (arg_terminator_idx != std::string::npos) + { + // Insert the gdb format option before the "--" that terminates options + gdb_format_option.append(1,' '); + cmd.insert(arg_terminator_idx, gdb_format_option); + inserted = true; + } + + if (!inserted) + revised_command_line.Printf (" %s", gdb_format_option.c_str()); + + if (wants_raw_input && FindArgumentTerminator(cmd) == std::string::npos) + revised_command_line.PutCString (" --"); } else { |