aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter/CommandInterpreter.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-09-06*** This commit represents a complete reformatting of the LLDB source codeKate Stone1-3085/+2869
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
2016-08-09Delete Host/windows/win32.hZachary Turner1-3/+3
It's always hard to remember when to include this file, and when you do include it it's hard to remember what preprocessor check it needs to be behind, and then you further have to remember whether it's windows.h or win32.h which you need to include. This patch changes the name to PosixApi.h, which is more appropriately named, and makes it independent of any preprocessor setting. There's still the issue of people not knowing when to include this, because there's not a well-defined set of things it exposes other than "whatever is missing on Windows", but at least this should make it less painful to fix when problems arise. This patch depends on LLVM revision r278170. llvm-svn: 278177
2016-07-14LLDB help content has accumulated over time without a recent attempt toKate Stone1-119/+96
review it for consistency, accuracy, and clarity. These changes attempt to address all of the above while keeping the text relatively terse. <rdar://problem/24868841> llvm-svn: 275485
2016-07-11Fix an issue where one could not define a Python command with the same name ↵Enrico Granata1-2/+7
as an existing alias (or rather, one could but the results of invoking the command were far from satisfactory) llvm-svn: 275080
2016-05-02Fix an issue where the apropos command would not print fully qualified ↵Enrico Granata1-1/+1
command names for nested command objects rdar://problem/26020072 llvm-svn: 268309
2016-04-25Add a --element-count option to the expression commandEnrico Granata1-0/+2
This option evaluates an expression and, if the result is of pointer type, treats it as if it was an array of that many elements and displays such elements This has a couple subtle points but is mostly as straightforward as it sounds Add a parray N <expr> alias for this new mode Also, extend the --object-description mode to do the moral equivalent of the above but display each element in --object-description mode Add a poarray N <expr> alias for this llvm-svn: 267372
2016-04-20Fix a bug where LLDB would crash if 'apropos <anything>' was used after ↵Enrico Granata1-1/+1
spawning an inferior process llvm-svn: 266911
2016-04-08Add help for our regular expression commands when aliasedEnrico Granata1-16/+12
llvm-svn: 265819
2016-03-23Change 'apropos' such that it doesn't look into the "long help/syntax" ↵Enrico Granata1-41/+50
strings for commands This solves issues such as 'apropos foo' returning valid matches just because syntax examples happen to use 'foo' as a placeholder token Fixes rdar://9043025 llvm-svn: 264123
2016-03-22Make it so that a command alias can actually remove the help/long help from ↵Enrico Granata1-4/+8
its parent command by setting itself to an empty help string llvm-svn: 264108
2016-03-22Fix a bug caused by my alias refactoring where, if an alias was defined in ↵Enrico Granata1-2/+3
terms of another alias, trying to run the nested command would actually cause a crash in the command interpreter llvm-svn: 264096
2016-03-19Use Enrico's new CommandAlias to give better help to the "sif" command.Jim Ingham1-1/+7
llvm-svn: 263865
2016-03-15Workaround the fact that "b" is now a separate command object from ↵Enrico Granata1-5/+5
"_regexp-break", and thus "help b" doesn't show the possible syntaxes It would be nice to have a longer-term plan for how to handle help for regular expression commands, since their syntax is highly irregular. I can see a few options (*), but for now this is a reasonable stop-gag measure for the most blatant regression. (*) the simplest is, of course, to detect a regex command and inherit the syntax for any aliases thereof; it would be nice if this also didn't show the underlying regex command name when the alias is used llvm-svn: 263523
2016-03-14Lots of progress on the CommandAlias refactoringEnrico Granata1-4/+5
This cleans things up such CommandAlias essentially can work as its own object; the aliases still live in a separate map, but are now just full-fledged CommandObjectSPs This patch also cleans up help generation for aliases, allows aliases to vend their own help, and adds a tweak such that "dash-dash aliases", such as po, don't show the list of options for their underlying command, since those can't be provided anyway I plan to fix up a few more things here, and then add a test case and proclaim victory llvm-svn: 263499
2016-03-14More of the alias refactoring work! CommandAlias is now a CommandObjectEnrico Granata1-14/+13
llvm-svn: 263468
2016-03-09Last round of preliminary cleanup in my refactoring of aliases.Enrico Granata1-98/+3
The next step is to actually turn CommandAlias into a full-blown CommandObject citizen. This is tricky given the current architecture of the CommandInterpreter but I think I have found a reasonable path forward. The current plan is to make class CommandAlias : public CommandObject, and have all the several GetCommand calls not actually traverse through the alias to the underlying command object The only times that an alias will be traversed are: a) execution; when time comes to run an alias, I will just grab the underlying command and options, and make the interpreter execute that according to its current algorithm b) subcommand traversal; if one has an alias to a multiword command, grabbing a subcommand will see through to the subcommand Other operations, e.g. command listing, command names, command helps, ..., will all use the alias directly. This will, in turn, lead to the removal of the separate alias dictionary, and just mix user commands and aliases in one map llvm-svn: 262986
2016-03-08Move CommandAlias to its own file; alsoEnrico Granata1-17/+17
Store std::unique_ptr<CommandAlias> instead of instances llvm-svn: 262958
2016-03-08Use c_str() instead of GetCString() to fix build Ewan Crawford1-1/+1
llvm-svn: 262920
2016-03-08This is actually a FileSpec, so use .GetCString() insteadEnrico Granata1-1/+1
llvm-svn: 262914
2016-03-08Use .c_str() here to unbreak the Linux buildEnrico Granata1-1/+1
llvm-svn: 262913
2016-03-08A few more improvements on the way to the command alias refactoringEnrico Granata1-104/+96
- move alias help generation to CommandAlias, out of CommandInterpreter - make alias creation use argument strings instead of OptionArgVectorSP; the former is a more reasonable currency than the latter - remove m_is_alias from CommandObject, it wasn't actually being used llvm-svn: 262912
2016-03-08Turn GetAliasOptions() into GetAlias()Enrico Granata1-7/+14
Eventually, there will be more things that CommandAlias contains, and I don't want accessors for each of them on the CommandIntepreter Eventually, we also won't pass around copies of CommandAlias, but that's for a later patch llvm-svn: 262909
2016-03-08Attempt to fix the Ubuntu buildbot by making FindLongestCommandWord a free ↵Enrico Granata1-16/+0
template function in lldb_private llvm-svn: 262905
2016-03-08Unbreak linux build broken by r262901Jason Molenda1-1/+1
llvm-svn: 262904
2016-03-08Move ProcessAliasOptionsArgs to be a static on CommandAlias; it wasn't using ↵Enrico Granata1-58/+58
any instance data on the CommandInterpreter anyway This small step removes one piece of alias machinery from the CommandInterpreter into the CommandAlias llvm-svn: 262901
2016-03-08Change the way command aliases are stored. Go from a model where a map holds ↵Enrico Granata1-103/+80
the alias -> underlying command binding and another map holds the alias -> options, to a model where one single map holds the alias -> (all useful data) combination Right now, obviously, this is just the pair of (CommandObjectSP,OptionArgVectorSP), so NFC This is step one of a larger - and tricky - refactoring which will turn command aliases into interesting objects instead of passive storage that the command interpreter does smart things to This refactoring, in turn, will allow us to do interesting things with aliases, such as intelligent and customizable help llvm-svn: 262900
2016-03-07Change over the broadcaster/listener process to hold shared or weak pointersJim Ingham1-1/+1
to each other. This should remove some infrequent teardown crashes when the listener is not the debugger's listener. Processes now need to take a ListenerSP, not a Listener&. This required changing over the Process plugin class constructors to take a ListenerSP, instead of a Listener&. Other than that there should be no functional change. <rdar://problem/24580184> CrashTracer: [USER] Xcode at …ework: lldb_private::Listener::BroadcasterWillDestruct + 39 llvm-svn: 262863
2016-02-26Clear alias argument vector for 'p' alias.Chaoren Lin1-0/+2
Summary: This fixes the 'p' command which should be aliased to 'expresion --'. Reviewers: jingham Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D17634 llvm-svn: 261969
2016-02-26Add the "block" keyword to "thread step-in -e", and an alias that uses it: ↵Jim Ingham1-2/+8
"sif <target function>" - i.e. step-into-function to allow you to step through a complex calling sequence into a particular function that may span multiple lines. Also some test cases for this and the --step-target feature. llvm-svn: 261953
2016-02-26Fix all of the unannotated switch cases to annotate the fall through or do ↵Greg Clayton1-0/+1
the right thing and break. llvm-svn: 261950
2016-02-19This patch stops lldb from loading a .lldbinit file from the currentJason Molenda1-5/+37
working directory by default -- a typical security problem that we need to be more conservative about. It adds a new target setting, target.load-cwd-lldbinit which may be true (always read $cwd/.lldbinit), false (never read $cwd/.lldbinit) or warn (warn if there is a $cwd/.lldbinit and don't read it). The default is set to warn. If this is met with unhappiness, we can look at changing the default to true (to match current behavior) on a different platform. This does not affect reading of ~/.lldbinit - that will still be read, as before. If you run lldb in your home directory, it will not warn about the presence of a .lldbinit file there. I had to add two SB API - SBHostOS::GetUserHomeDirectory and SBFileSpec::AppendPathComponent - for the lldb driver code to be able to get the home directory path in an OS neutral manner. The warning text is There is a .lldbinit file in the current directory which is not being read. To silence this warning without sourcing in the local .lldbinit, add the following to the lldbinit file in your home directory: settings set target.load-cwd-lldbinit false To allow lldb to source .lldbinit files in the current working directory, set the value of this variable to true. Only do so if you understand and accept the security risk. <rdar://problem/24199163> llvm-svn: 261280
2016-02-06Per Jim's suggestion, move checks that we're not mixing and matching ↵Enrico Granata1-1/+9
Debuggers and Commands deeper in the bowels of LLDB NFC llvm-svn: 259972
2016-01-08Fix a glitch in the Driver's batch mode when used with "attach". Jim Ingham1-1/+4
Batch mode is supposed to stop execution and return control to the user when an exceptional stop occurs (crash, signal or instrumentation). But attach always stops with a SIGSTOP on OSX (maybe on Linux too?) which would short circuit the rest of the commands given. This change allows a command result object to indicate that it expected to leave the process stopped with an exceptional stop reason, and it is okay for batch mode to keep going. <rdar://problem/22243143> llvm-svn: 257120
2015-10-19Added the concept of a Read-Eval-Print-Loop to LLDB.Sean Callanan1-1/+10
A REPL takes over the command line and typically treats input as source code. REPLs can also do code completion. The REPL class allows its subclasses to implement the language-specific functionality without having to know about the IOHandler-specific internals. Also added a PluginManager-based way of getting to a REPL given a language and a target. Also brought in some utility code and expression options that are useful for REPLs, such as line offsets for expressions, ANSI terminal coloring of errors, and a few IOHandler convenience functions. llvm-svn: 250753
2015-09-22Move the "run" alias from process launch --shell to process launch ↵Enrico Granata1-0/+8
--shell-expand-args when building on OS X The argdumper-based launching is more friendly to System Integrity Protection, and will work on older releases of OS X as well Leave non-Apple builds alone llvm-svn: 248338
2015-09-02Fix tab completion for command arguments containing spacesTamas Berghammer1-3/+3
If a command argument contains a space then it have to be escaped with backslash signs so the argument parsing logic can parse it properly. This CL fixes the tab completion code for the arguments to create complitions with correctly escaped strings. Differential revision: http://reviews.llvm.org/D12531 llvm-svn: 246639
2015-07-30Convert the ScriptInterpreter system to a plugin-based one.Zachary Turner1-65/+28
Previously embedded interpreters were handled as ad-hoc source files compiled into source/Interpreter. This made it hard to disable a specific interpreter, or to add support for other interpreters and allow the developer to choose which interpreter(s) were enabled for a particular build. This patch converts script interpreters over to a plugin-based system. Script interpreters now live in source/Plugins/ScriptInterpreter, and the canonical LLDB interpreter, ScriptInterpreterPython, is moved there as well. Any new code interfacing with the Python C API must live in this location from here on out. Additionally, generic code should never need to reference or make assumptions about the presence of a specific interpreter going forward. Differential Revision: http://reviews.llvm.org/D11431 Reviewed By: Greg Clayton llvm-svn: 243681
2015-07-24Add UNUSED_IF_ASSERT_DISABLED and apply it.Bruce Mitchener1-2/+1
Summary: This replaces (void)x; usages where they x was subsequently involved in an assertion with this macro to make the intent more clear. Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D11451 llvm-svn: 243074
2015-07-02Add new bugreport command to lldbTamas Berghammer1-0/+2
The new command add functionality to print out domain specific information for reporting a bug. Currently the only supported domain is stack unwinding (with "bugreport unwind") but adding new domains is fairly easy. Differential revision: http://reviews.llvm.org/D10868 llvm-svn: 241252
2015-06-18Fix a variety of typos.Bruce Mitchener1-3/+3
No functional change. llvm-svn: 239995
2015-05-29Don't #include "lldb-python.h" from anywhere.Zachary Turner1-2/+0
Since interaction with the python interpreter is moving towards being more isolated, we won't be able to include this header from normal files anymore, all includes of it should be localized to the python library which will live under source/bindings/API/Python after a future patch. None of the files that were including this header actually depended on it anyway, so it was just a dead include in every single instance. llvm-svn: 238581
2015-05-13Fixed a ton of gcc compile warningsVince Harron1-3/+3
Removed some unused variables, added some consts, changed some casts to const_cast. I don't think any of these changes are very controversial. Differential Revision: http://reviews.llvm.org/D9674 llvm-svn: 237218
2015-05-04Add language command and LanguageRuntime plugin changes to allow vending of ↵Colin Riley1-0/+2
command objects. Differential Revision: http://reviews.llvm.org/D9402 llvm-svn: 236443
2015-04-23Factor resolution of abbreviations and aliases so that they can be tested ↵Adrian McCarthy1-201/+221
directly. http://reviews.llvm.org/D9033 llvm-svn: 235633
2015-04-06Fix check for options in "command alias"Ted Woodward1-3/+3
Summary: "command alias" can add invalid options to the command. "command alias start process launch -s" will add an extra argument, "<no-argument>" to the alias, so it runs "process launch -s <no-argument>", which launches the process with args that include "<no-argument>". This patch changes the text compare of the variable value with "<OptionParser::eNoArgument>" to a compare of variable value_type with OptionParser::eNoArgument. It also moves the previous test inside the if, so it won't add a trailing space if there is no argument. Reviewers: clayborg Reviewed By: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D8844 llvm-svn: 234244
2015-03-23Turn off 'quit' confirmation in lldb-miIlia K1-0/+7
Summary: # Turn off interpreter.prompt-on-quit on startup (MI) # Add CommandInterpreter::SetPromptOnQuit # Add SBCommandInterpreter::GetPromptOnQuit/SetPromptOnQuit All tests pass on OS X. Test Plan: ``` -file-exec-and-symbols ~/p/hello -break-insert -f main -exec-run -interpreter-exec console quit ``` Reviewers: abidh, clayborg Reviewed By: abidh, clayborg Subscribers: lldb-commits, clayborg, abidh Differential Revision: http://reviews.llvm.org/D8444 llvm-svn: 233034
2015-03-17Fix broadcasters for interpreter and process:Ilia K1-1/+1
# Fix CommandInterpreter.Broadcaster name (it should be the same as CommandInterpreter::GetStaticBroadcasterClass()) # Prevent the same error in Process.Broadcaster # Fix SBCommandInterpreter::GetBroadcasterClass (it should call CommandInterpreter::GetStaticBroadcasterClass(), was Communication::GetStaticBroadcasterClass()) llvm-svn: 232500
2015-03-07Help for _regexp-break wasn't very clear. Added more detailed explanations ↵Greg Clayton1-2/+8
of all things that can be typed by the _regexp-break command. <rdar://problem/12281058> llvm-svn: 231537
2015-03-04Further reduce header footprint of Debugger.h.Zachary Turner1-0/+2
llvm-svn: 231202
2015-03-02Fix handling of backslashes in Args parsingPavel Labath1-3/+3
Summary: Presently Args::SetCommandString allows quotes to be escaped with backslash. However, the backslash itself is not removed from the argument, nor there is a way to escape the backslash itself. This leads to surprising results: "a b" c" -> 'a b', 'c' # Here we actually have an unterminated quote, but that is ignored "a b\" c" -> 'a b\" c' # We try to escape the quote. That works but the backslash is not removed. "a b\\" c" -> 'a b\\" c' # Escaping the backslash has no effect. This change changes quote handling to be more shell-like: - single quotes and backquotes are literal and there is no way to escape the closing quote or anything else inside; - inside double quotes you can use backslash to escape the closing quote and another backslash - outside any quotes, you can use backslash to escape quotes, spaces and itself. This makes the parsing more consistent with what the user is familiar and increases the probability that pasting the command line from shell to the "process launch" command "just work". Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D7855 llvm-svn: 230955