Commit Graph

767 Commits

Author SHA1 Message Date
Enrico Granata 520a422bd8 Add a --element-count option to the expression command
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-25 00:52:47 +00:00
Enrico Granata 612917c784 Fix a bug where LLDB would crash if 'apropos <anything>' was used after spawning an inferior process
llvm-svn: 266911
2016-04-20 20:48:05 +00:00
Enrico Granata 648e438a34 Add help for our regular expression commands when aliased
llvm-svn: 265819
2016-04-08 17:56:26 +00:00
Enrico Granata 7a37df3fc3 Improve the way LLDB escapes arguments before passing them to the shell
Teach LLDB that different shells have different characters they are sensitive to, and use that knowledge to do shell-aware escaping

This helps solve a class of problems on OS X where LLDB would try to launch via sh, and run into problems if the command line being passed to the inferior contained such special markers (hint: the shell would error out and we'd fail to launch)
This makes those launch scenarios work transparently via shell expansion

Slightly improve the error message when this kind of failure occurs to at least suggest that the user try going through 'process launch' directly

Fixes rdar://problem/22749408

llvm-svn: 265357
2016-04-04 22:46:38 +00:00
Enrico Granata 3c110dd6b4 Fix an issue with nested aliases where the help system wouldn't correctly track the fact that an alias is an alias to a dash-dash alias
(and I hope I typed the word 'alias' enough times in this commit message :-)

llvm-svn: 264468
2016-03-25 21:59:06 +00:00
Enrico Granata d033e1cef5 Change 'apropos' such that it doesn't look into the "long help/syntax" 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-23 01:21:55 +00:00
Enrico Granata bfb75e9bbc Make it so that a command alias can actually remove the help/long help from its parent command by setting itself to an empty help string
llvm-svn: 264108
2016-03-22 22:12:59 +00:00
Enrico Granata 660764a060 Fix a bug caused by my alias refactoring where, if an alias was defined in terms of another alias, trying to run the nested command would actually cause a crash in the command interpreter
llvm-svn: 264096
2016-03-22 21:07:54 +00:00
Jim Ingham d23be3d30d Use Enrico's new CommandAlias to give better help to the "sif" command.
llvm-svn: 263865
2016-03-19 00:53:20 +00:00
Enrico Granata ee88b61500 Workaround the fact that "b" is now a separate command object from "_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-15 01:57:10 +00:00
Enrico Granata dbe8d4f339 Improve the way we decide whether an alias is a dashdash alias
llvm-svn: 263519
2016-03-15 01:42:34 +00:00
Enrico Granata 4ebb8a4761 This was printing arguments twice in dash-dash aliases; don't do that
llvm-svn: 263517
2016-03-15 01:17:32 +00:00
Enrico Granata bef55ac8f5 Lots of progress on the CommandAlias refactoring
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-14 22:17:04 +00:00
Enrico Granata 3e271af415 More of the alias refactoring work! CommandAlias is now a CommandObject
llvm-svn: 263468
2016-03-14 19:00:21 +00:00
Jim Ingham 8d94ba0fb1 This change introduces a "ExpressionExecutionThread" to the ThreadList.
Turns out that most of the code that runs expressions (e.g. the ObjC runtime grubber) on
behalf of the expression parser was using the currently selected thread.  But sometimes,
e.g. when we are evaluating breakpoint conditions/commands, we don't select the thread
we're running on, we instead set the context for the interpreter, and explicitly pass
that to other callers.  That wasn't getting communicated to these utility expressions, so
they would run on some other thread instead, and that could cause a variety of subtle and
hard to reproduce problems.  

I also went through the commands and cleaned up the use of GetSelectedThread.  All those
uses should have been trying the thread in the m_exe_ctx belonging to the command object
first.  It would actually have been pretty hard to get misbehavior in these cases, but for
correctness sake it is good to make this usage consistent.

<rdar://problem/24978569>

llvm-svn: 263326
2016-03-12 02:45:34 +00:00
Enrico Granata 4643c01284 Last round of preliminary cleanup in my refactoring of aliases.
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-09 02:27:57 +00:00
Enrico Granata 7cf3b34d45 Add CommandAlias.cpp to CMakeLists
llvm-svn: 262959
2016-03-08 21:29:49 +00:00
Enrico Granata 937631cfdf Move CommandAlias to its own file; also
Store std::unique_ptr<CommandAlias> instead of instances

llvm-svn: 262958
2016-03-08 21:23:30 +00:00
Ewan Crawford 1ab4adb1d3 Use c_str() instead of GetCString() to fix build
llvm-svn: 262920
2016-03-08 10:03:23 +00:00
Enrico Granata 443923b72d This is actually a FileSpec, so use .GetCString() instead
llvm-svn: 262914
2016-03-08 05:59:47 +00:00
Enrico Granata c8fd719e21 Use .c_str() here to unbreak the Linux build
llvm-svn: 262913
2016-03-08 05:57:52 +00:00
Enrico Granata 212130ac4d A few more improvements on the way to the command alias refactoring
- 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-08 05:37:15 +00:00
Enrico Granata 002ab61a47 Turn GetAliasOptions() into GetAlias()
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-08 03:56:12 +00:00
Enrico Granata 4a795920e3 Attempt to fix the Ubuntu buildbot by making FindLongestCommandWord a free template function in lldb_private
llvm-svn: 262905
2016-03-08 03:48:41 +00:00
Jason Molenda 5df5402f94 Unbreak linux build broken by r262901
llvm-svn: 262904
2016-03-08 03:24:13 +00:00
Enrico Granata 5e5503099b Move ProcessAliasOptionsArgs to be a static on CommandAlias; it wasn't using 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-08 03:00:27 +00:00
Enrico Granata 308f73c5a3 Change the way command aliases are stored. Go from a model where a map holds 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-08 02:49:15 +00:00
Jim Ingham 583bbb1dd4 Change over the broadcaster/listener process to hold shared or weak pointers
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-03-07 21:50:25 +00:00
Enrico Granata 7a67ee263f Change the user-visible name for the argument type language to source-language
This makes it so that help language provides help on the language command and help source-language provides the list of source languages one can pass as an option

Fixes rdar://24869942

llvm-svn: 262259
2016-02-29 21:37:01 +00:00
Chaoren Lin 6fc5c7f1f5 Clear alias argument vector for 'p' alias.
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-26 03:36:27 +00:00
Jim Ingham 970bb9e0ec Add the "block" keyword to "thread step-in -e", and an alias that uses it: "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-26 01:37:30 +00:00
Greg Clayton cec91ef921 Fix all of the unannotated switch cases to annotate the fall through or do the right thing and break.
llvm-svn: 261950
2016-02-26 01:20:20 +00:00
Jason Molenda 878ae01889 This patch stops lldb from loading a .lldbinit file from the current
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-19 00:05:17 +00:00
Jason Molenda 62e0681afb Add -Wimplicit-fallthrough command line option to clang in
the xcode project file to catch switch statements that have a
case that falls through unintentionally.

Define LLVM_FALLTHROUGH to indicate instances where a case has code
and intends to fall through.  This should be in llvm/Support/Compiler.h;
Peter Collingbourne originally checked in there (r237766), then
reverted (r237941) because he didn't have time to mark up all the
'case' statements that were intended to fall through.  I put together
a patch to get this back in llvm http://reviews.llvm.org/D17063 but
it hasn't been approved in the past week.  I added a new
lldb-private-defines.h to hold the definition for now.

Every place in lldb where there is a comment that the fall-through
is intentional, I added LLVM_FALLTHROUGH to silence the warning.
I haven't tried to identify whether the fallthrough is a bug or
not in the other places.

I haven't tried to add this to the cmake option build flags.
This warning will only work for clang.

This build cleanly (with some new warnings) on macosx with clang
under xcodebuild, but if this causes problems for people on other
configurations, I'll back it out.

llvm-svn: 260930
2016-02-16 04:14:33 +00:00
Enrico Granata 41571781c0 Per Jim's suggestion, move checks that we're not mixing and matching Debuggers and Commands deeper in the bowels of LLDB
NFC

llvm-svn: 259972
2016-02-06 01:36:07 +00:00
Eugene Zelenko c33088f41e Remove autoconf support from source directories.
Differential revision: http://reviews.llvm.org/D16662

llvm-svn: 259098
2016-01-28 22:05:24 +00:00
Jim Ingham 962260c852 Fix a glitch in the Driver's batch mode when used with "attach".
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
2016-01-08 00:20:47 +00:00
Kate Stone 0167e064f3 Addresses an unsigned underflow situation that can occur when dumping an empty command history.
One example where this occurs in practice is starting the Swift REPL and typing ":command history" since REPL commands aren't stored in the LLDB command prompt history.

llvm-svn: 256888
2016-01-06 00:33:07 +00:00
Todd Fiala f6b2aa5882 remove defunct scripts/build-swig-wrapper-classes.sh; switch autoconf build to prepare_bindings.py.
Xcode moved off of build-swig-wrapper-classes.sh earlier this week.

llvm-svn: 253490
2015-11-18 19:34:03 +00:00
Jim Ingham c77ce7b626 LLDB needs a mutex around getopt_long_only() function calls to avoid multi-threading option parsing issues.
<rdar://problem/17052381>

llvm-svn: 252111
2015-11-05 00:38:39 +00:00
Eugene Zelenko 315b688457 Fix Clang-tidy modernize-use-override warnings in some files in source; other minor fixes.
llvm-svn: 251309
2015-10-26 17:00:13 +00:00
Sean Callanan 6681041d70 Added the concept of a Read-Eval-Print-Loop to LLDB.
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-10-19 23:11:07 +00:00
Saleem Abdulrasool ba507b04e1 Silence -Wqual-cast warnings from GCC 5.2
There were a number of const qualifiers being cast away which caused warnings.
This cluttered the output hiding real errors.  Silence them by explicit casting.
NFC.

llvm-svn: 250662
2015-10-18 19:34:38 +00:00
Zachary Turner 5f3fd800f7 Make some more of the LLDB/SWIG/Python glue Python 3 aware.
Mostly this is just converting some print statements to print
functions.

llvm-svn: 250533
2015-10-16 17:52:32 +00:00
Sean Callanan fe38c8506f Added support for enumerating the languages that actually support TypeSystems
and expressions.  Also wired that into the OptionValue infrastructure, although
it isn't used for tab-completion yet.

llvm-svn: 249769
2015-10-08 23:07:53 +00:00
Enrico Granata f515729a07 Move the "run" alias from process launch --shell to process launch --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-22 22:57:12 +00:00
Bruce Mitchener db25a7a245 [cmake] Remove LLVM_NO_RTTI.
Summary:
This doesn't exist in other LLVM projects any longer and doesn't
do anything.

Reviewers: chaoren, labath

Subscribers: emaste, tberghammer, lldb-commits, danalbert

Differential Revision: http://reviews.llvm.org/D12586

llvm-svn: 246749
2015-09-03 08:46:55 +00:00
Tamas Berghammer 89d3f090b2 Fix tab completion for command arguments containing spaces
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-09-02 10:35:27 +00:00
Jim Ingham 0e0984eebb Move things from the LanguageRuntime that obviously belong in the new Language plugin instead.
llvm-svn: 246611
2015-09-02 01:06:46 +00:00
Zachary Turner 2c1f46dcc6 Convert the ScriptInterpreter system to a plugin-based one.
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-30 20:28:07 +00:00