diff options
author | Enrico Granata <granata.enrico@gmail.com> | 2011-11-07 22:57:04 +0000 |
---|---|---|
committer | Enrico Granata <granata.enrico@gmail.com> | 2011-11-07 22:57:04 +0000 |
commit | 0a305db796fcd8b0cb6e3f7918de24f0753e2708 (patch) | |
tree | b004601a03a562bdd4be760ac8871bc848365315 /lldb/source/Interpreter/CommandInterpreter.cpp | |
parent | 55a86d32d381a077f7a7356182cae1cdb4dd44df (diff) | |
download | bcm5719-llvm-0a305db796fcd8b0cb6e3f7918de24f0753e2708.tar.gz bcm5719-llvm-0a305db796fcd8b0cb6e3f7918de24f0753e2708.zip |
this patch addresses several issues with "command script" subcommands:
a) adds a new --synchronicity (-s) setting for "command script add" that allows the user to decide if scripted commands should run synchronously or asynchronously (which can make a difference in how events are handled)
b) clears up several error messages
c) adds a new --allow-reload (-r) setting for "command script import" that allows the user to reload a module even if it has already been imported before
d) allows filename completion for "command script import" (much like what happens for "target create")
e) prevents "command script add" from replacing built-in commands with scripted commands
f) changes AddUserCommand() to take an std::string instead of a const char* (for performance reasons)
plus, it fixes an issue in "type summary add" command handling which caused several test suite errors
llvm-svn: 144035
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index b94c4099a9e..73a7085e47b 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -516,19 +516,23 @@ CommandInterpreter::AddCommand (const char *name, const lldb::CommandObjectSP &c } bool -CommandInterpreter::AddUserCommand (const char *name, +CommandInterpreter::AddUserCommand (std::string name, const lldb::CommandObjectSP &cmd_sp, bool can_replace) { - if (name && name[0]) + if (!name.empty()) { - std::string name_sstr(name); - if (!can_replace) - { - if (m_user_dict.find (name_sstr) != m_user_dict.end()) - return false; - } - m_user_dict[name_sstr] = cmd_sp; + + const char* name_cstr = name.c_str(); + + // do not allow replacement of internal commands + if (CommandExists(name_cstr)) + return false; + + if (can_replace == false && UserCommandExists(name_cstr)) + return false; + + m_user_dict[name] = cmd_sp; return true; } return false; |