Commit Graph

1041 Commits

Author SHA1 Message Date
Jonas Devlieghere f38234ed8b [lldb/CMake] Fix variable naming in FindLibEdit
The current FOUND_VAR for FindLibEdit is libedit_FOUND but wasn't set by
find_package_handle_standard_args. However this isn't valid for the
package name.

  The argument for FOUND_VAR is "libedit_FOUND", but only "LibEdit_FOUND" and
  "LIBEDIT_FOUND" are valid names.

This fixes all the variables set by FindLibEdit to match the desired
naming scheme.
2020-01-02 13:39:57 -08:00
Pavel Labath fbccef6b25 [lldb] Fix a -Wreturn-type gcc warning in ScriptInterpreter.cpp 2019-12-23 11:07:35 +01:00
Jonas Devlieghere 1562511275 [lldb/ScriptInterpreter] Remove can_reload which is always true (NFC)
The `-r` option for `command script import` is there for legacy
compatibility, however the can_reload flag is always set to true. This
patch removes the flag and any code that relies on it being false.
2019-12-22 21:36:03 -08:00
Jonas Devlieghere bd5c8d167b [lldb/ScriptInterpreter] Unify error message for command script import
Rather than checking for Python explicitly, let the script interpreter
handle things and print an error if the functionality is not supported.
2019-12-22 16:47:28 -08:00
Jonas Devlieghere ba0eb7b66f [lldb/ScriptInterpreter] Fix stale/bogus error messages
Fix the nonsensical error messages for when breakpoint and watchpoint
callbacks are not supported.
2019-12-21 22:33:02 -08:00
Jonas Devlieghere acdda1344a [lldb/Lua] Add missing boiler plate to ScriptInterpreter.
- Fix enum entry order.
 - Fix missing enum case in CommandObjectBreakpointCommand.
 - Add Lua entry to swtich in LanguageToString and simplify the code.
2019-12-21 21:54:44 -08:00
Jonas Devlieghere 67de896229 [lldb/Lua] Add Boilerplate for a Lua Script Interpreter
This adds the boilerplate necessary to support the Lua script
interpreter. The interpreter is not functional yet and just reports that
it's not implemented.

Discussion on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2019-December/015812.html

Differential revision: https://reviews.llvm.org/D71232
2019-12-19 10:13:51 -08:00
Jonas Devlieghere 56ab485a31 [lldb/Scripting] Simplify code by removing the #if.
The "none" script interpreter does not depend on Python so it doesn't
make sense to have it withing the if-block. The only goal seems to be to
have a slightly different error for when there's no script interpreter,
but as per the comment this doesn't make sense for more than one
scripting language. I think the existing error is perfectly clear, so I
just removed this altogether.
2019-12-18 16:46:38 -08:00
Jonas Devlieghere 4e26cf2cfb [lldb/CMake] Rename LLDB_DISABLE_PYTHON to LLDB_ENABLE_PYTHON
This matches the naming scheme used by LLVM and all the other optional
dependencies in LLDB.

Differential revision: https://reviews.llvm.org/D71482
2019-12-13 13:41:11 -08:00
Jonas Devlieghere 62456e579e [lldb/CMake] Rename LLDB_DISABLE_LIBEDIT to LLDB_ENABLE_LIBEDIT
This matches the naming scheme used by LLVM.

Differential revision: https://reviews.llvm.org/D71380
2019-12-12 09:23:06 -08:00
Jonas Devlieghere 59998b7b7f [lldb/Host] Use Host/Config.h entries instead of a global define.
As suggested by Pavel in a code review:

> Can we replace this (and maybe python too, while at it) with a
> Host/Config.h entry? A global definition means that one has to
> recompile everything when these change in any way, whereas in
> practice only a handful of files need this..

Differential revision: https://reviews.llvm.org/D71280
2019-12-10 11:16:52 -08:00
Raphael Isemann 4dac97eb1e [lldb][NFC] Migrate FileSpec::Dump to raw_ostream 2019-12-06 09:40:42 +01:00
Jim Ingham 3151d7af72 Clear out the python class name in OptionParsingStarted for the OptionGroupPythonClassWithDict
options class.  This value was hanging around so for instance if you made a scripted breakpoint
resolver, then went to set another breakpoint, it would still think you had passed in a class
name and the breakpoint wouldn't do what you expected.
2019-12-04 17:40:57 -08:00
Jason Molenda e001bf6330 Add help text for parray and poarray aliases. 2019-12-04 15:33:54 -08:00
Raphael Isemann db5074dc10 [lldb][NFC] Give some parameters in CommandInterpreter more descriptive names 2019-11-05 09:21:10 +01:00
Davide Italiano d46c65592e [ValueObjectDisplay] Generalize the description of an option. 2019-10-29 13:05:56 -07:00
Jim Ingham 738af7a624 Add the ability to pass extra args to a Python breakpoint callback.
For example, it is pretty easy to write a breakpoint command that implements "stop when my caller is Foo", and
    it is pretty easy to write a breakpoint command that implements "stop when my caller is Bar". But there's no
    way to write a generic "stop when my caller is..." function, and then specify the caller when you add the
    command to a breakpoint.

    With this patch, you can pass this data in a SBStructuredData dictionary. That will get stored in
    the PythonCommandBaton for the breakpoint, and passed to the implementation function (if it has the right
    signature) when the breakpoint is hit. Then in lldb, you can say:

    (lldb) break com add -F caller_is -k caller_name -v Foo

    More generally this will allow us to write reusable Python breakpoint commands.

    Differential Revision: https://reviews.llvm.org/D68671
2019-10-25 14:05:07 -07:00
Adrian Prantl 917b8df0e5 Replace static const StringRef with StringRef (NFC)
Differential Revision: https://reviews.llvm.org/D68597

llvm-svn: 374081
2019-10-08 16:29:36 +00:00
Jim Ingham ebaa3eb127 Python3 doesn't seem to allow you to tell whether an object is a class
PyClass_Check and everything it relied on seems gone from Python3.7.  So
I won't check whether it is a class first...

Also cleaned up a couple of warnings.

llvm-svn: 373679
2019-10-03 23:57:34 +00:00
Jim Ingham f9d8bbee89 Forgot to change the header guards on OptionGroupPythonClassWithDict.
I think that's what is confusing the modules build on the bots.

llvm-svn: 373677
2019-10-03 23:32:42 +00:00
Jim Ingham 943a24812d Break out the Python class & key/value options into a separate OptionGroup.
Use this in the scripted breakpoint command.  Added some tests for parsing
the key/value options.  This uncovered a bug in handling parsing errors mid-line.
I also fixed that bug.

Differential Revision: https://reviews.llvm.org/D68363

llvm-svn: 373673
2019-10-03 22:18:51 +00:00
Lawrence D'Anna 7ca15ba73f remove File::SetStream(), make new files instead.
Summary:
This patch removes File::SetStream() and File::SetDescriptor(),
and replaces most direct uses of File with pointers to File.
Instead of calling SetStream() on a file, we make a new file and
replace it.

My ultimate goal here is to introduce a new API class SBFile, which
has full support for python io.IOStream file objects.   These can
redirect read() and write() to python code, so lldb::Files will
need a way to dispatch those methods.   Additionally it will need some
form of sharing and assigning files, as a SBFile will be passed in and
assigned to the main IO streams of the debugger.

In my prototype patch queue, I make File itself copyable and add a
secondary class FileOps to manage the sharing and dispatch.  In that
case SBFile was a unique_ptr<File>.
(here: https://github.com/smoofra/llvm-project/tree/files)

However in review, Pavel Labath suggested that it be shared_ptr instead.
(here: https://reviews.llvm.org/D67793)

In order for SBFile to use shared_ptr<File>, everything else should
as well.

If this patch is accepted, I will make SBFile use a shared_ptr
I will remove FileOps from future patches and use subclasses of File
instead.

Reviewers: JDevlieghere, jasonmolenda, zturner, jingham, labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D67891

llvm-svn: 373090
2019-09-27 14:33:35 +00:00
Lawrence D'Anna 2fce1137c7 Convert FileSystem::Open() to return Expected<FileUP>
Summary:
This patch converts FileSystem::Open from this prototype:

Status
Open(File &File, const FileSpec &file_spec, ...);

to this one:

llvm::Expected<std::unique_ptr<File>>
Open(const FileSpec &file_spec, ...);

This is beneficial on its own, as llvm::Expected is a more modern
and recommended error type than Status.  It is also a necessary step
towards https://reviews.llvm.org/D67891, and further developments
for lldb_private::File.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D67996

llvm-svn: 373003
2019-09-26 17:54:59 +00:00
Tatyana Krasnukha a11668e87b Don't stop execution in batch mode when process stops with SIGINT or SIGSTOP
Summary: Usually, SIGINT and SIGSTOP don't imply a crash, e.g. SIGSTOP is sent on process launch and attach on some platforms.

Differential Revision: https://reviews.llvm.org/D67776

llvm-svn: 372961
2019-09-26 10:57:11 +00:00
Raphael Isemann 7f9ac3372c [lldb][NFC] Remove CompletionRequest::GetCursorArgument and GetRawLineUntilCursor
They both return the same result as another function (GetCursorArgumentPrefix
and GetRawLine). They were only added because the old API allowed to look
(in theory) behind the cursor position which is no longer possible.

llvm-svn: 372861
2019-09-25 12:55:30 +00:00
Raphael Isemann 823fd9508a [lldb][NFC] Add CompletionRequest::AppendEmptyArgument
This is the only legitimate use we currently have for modifying
a CompletionRequest. Add a utility function for this purpose
and remove the remaining setters which go against the idea of
having an immutable CompletionRequest.

llvm-svn: 372858
2019-09-25 12:40:01 +00:00
Raphael Isemann 0ba85fdb4f [lldb][NFC] Remove useless cursor shifting in Options::HandleOptionCompletion
The cursor position is always at the end of the current argument (as the
argument cut off after the cursor position). So this code is a no-op and
can be removed.

llvm-svn: 372851
2019-09-25 12:04:48 +00:00
Raphael Isemann ef06dd4328 [lldb] Remove redundant argument lists in CompletionRequest
We currently have two lists in the CompletionRequest that we
inherited from the old API: The complete list of arguments ignoring
where the user requested completion and the list of arguments that
stops at the cursor. Having two lists of arguments is confusing
and can lead to subtle errors, so let's remove the complete list
until we actually need it.

llvm-svn: 372692
2019-09-24 07:22:44 +00:00
Raphael Isemann db6617ddb7 [lldb][NFC] Remove unused variable in Options::HandleOptionArgumentCompletion
llvm-svn: 372574
2019-09-23 10:02:26 +00:00
Raphael Isemann 48d38ca6ac [lldb][NFC] Remove dead code in Options::HandleOptionArgumentCompletion
llvm-svn: 372572
2019-09-23 09:56:53 +00:00
Raphael Isemann 14f6465c15 [lldb] Make cursor index in CompletionRequest unsigned
The fact that index==-1 means "no arguments" is not obvious and only
used in one place from what I can tell. Also fixes several warnings
about using the cursor index as if it was a size_t when comparing.

Not fully NFC as we now also correctly update the partial argument list
when injecting the fake empty argument in the CompletionRequest
constructor.

llvm-svn: 372566
2019-09-23 09:46:17 +00:00
Raphael Isemann 93ca36d756 [lldb][NFC] Remove argument prefix checking boilerplate when adding completions
llvm-svn: 372561
2019-09-23 08:59:21 +00:00
Raphael Isemann f8e733f149 [lldb] Reduce some dangerous boilerplate with CompletionRequest::ShiftArguments
We should in general not allow external code to fiddle with the internals of
CompletionRequest, but until this is gone let's at least provide a utility
function that makes this less dangerous.

This also now correct updates the partially parsed argument list,
but it doesn't seem to be used by anything that is behind one of
the current shift/SetCursorIndex calls, so this doesn't seeem to
fix any currently used completion.

llvm-svn: 372556
2019-09-23 08:16:19 +00:00
Raphael Isemann 0d9a201e26 [lldb][NFC] Remove ArgEntry::ref member
The StringRef should always be identical to the C string, so we
might as well just create the StringRef from the C-string. This
might be slightly slower until we implement the storage of ArgEntry
with a string instead of a std::unique_ptr<char[]>. Until then we
have to do the additional strlen on the C string to construct the
StringRef.

llvm-svn: 371842
2019-09-13 11:26:48 +00:00
Raphael Isemann a024f5e370 [lldb][NFC] Make ArgEntry::quote private and provide a getter
llvm-svn: 371823
2019-09-13 08:26:00 +00:00
Jonas Devlieghere f5687d7c12 Remove `bugreport` command
The bugreport command exists to create domain-specific bug reports.
Currently it has one implementation for filing bugs on the unwinder. As
far as we can tell, it has never been of use. Although not exactly the
same as the reproducers, it's a bit confusing to have two parallel
command trees for (kind of) the same thing.

Differential revision: https://reviews.llvm.org/D65469

llvm-svn: 371132
2019-09-05 21:43:32 +00:00
Raphael Isemann 6897a814e6 [lldb] Add description to option completions.
Summary:
Right now our argument completions are rather cryptic for command options as they only list the letters:

```
(lldb) breakpoint set -
Available completions:
	-G
	-C
	-c
	-d
	-i
	-o
	-q
	-t
	-x
[...]
```

With the new completion API we can easily extend this with the flag description so that it looks like this now:

```
(lldb) breakpoint set -
Available completions:
	-G -- The breakpoint will auto-continue after running its commands.
	-C -- A command to run when the breakpoint is hit, can be provided more than once, the commands will get run in order left to right.
	-c -- The breakpoint stops only if this condition expression evaluates to true.
	-d -- Disable the breakpoint.
	-i -- Set the number of times this breakpoint is skipped before stopping.
	-o -- The breakpoint is deleted the first time it stop causes a stop.
	-q -- The breakpoint stops only for threads in the queue whose name is given by this argument.
	-t -- The breakpoint stops only for the thread whose TID matches this argument.
	-x -- The breakpoint stops only for the thread whose index matches this argument.
```

The same happens with --long-options now.

Reviewers: #lldb, labath

Reviewed By: labath

Subscribers: labath, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D67063

llvm-svn: 370628
2019-09-02 08:34:57 +00:00
Raphael Isemann 04a4c0910b [lldb] Unify target checking in CommandObject
Summary:
We currently have several CommandObjects that manually reimplement the checking for a selected target
or a target in the execution context (which is the selected target when they are invoked). This patch removes
all these checks and replaces them by setting the eCommandRequiresTarget flag that Pavel suggested. With
this flag we are doing the same check but without having to duplicate this code in all these CommandObjects.

I also added a `GetSelectedTarget()` variant of the `GetSelectedOrDummyTarget()` function to the
CommandObject that checks that the flag is set and then returns a reference to the target. I didn't rewrite
all the `target` variables from `Target *` to `Target &` in this patch as last time this change caused a lot of merge
conflicts in Swift and I would prefer having that in a separate NFC commit.

Reviewers: labath, clayborg

Reviewed By: labath, clayborg

Subscribers: clayborg, JDevlieghere, jingham, amccarth, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D66863

llvm-svn: 370571
2019-08-31 09:41:25 +00:00
Raphael Isemann efb8b7b1ec [lldb] Fix and test completion for ambiguous long options
The refactoring patch for the option completion broke the completion
for ambiguous long options. As this feature was also untested (as
testing ambiguous options with the current test methods is impossible),
I just noticed now. This patch restores the old behavior and adds a
test for this feature.

llvm-svn: 370185
2019-08-28 10:17:23 +00:00
Raphael Isemann ac5a475b53 [lldb][NFC] Get rid of C-strings in HandleOptionCompletion
llvm-svn: 370179
2019-08-28 09:32:30 +00:00
Raphael Isemann cb2380c9fa [lldb][NFC] Remove dead code that handles situations where LLDB has no dummy target
Summary:
We always have a dummy target, so any error handling regarding a missing dummy target is dead code now.
Also makes the CommandObject methods that return Target& to express this fact in the API.

This patch just for the CommandObject part of LLDB. I'll migrate the rest of LLDB in a follow-up patch that's WIP.

Reviewers: labath

Reviewed By: labath

Subscribers: abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D66737

llvm-svn: 369939
2019-08-26 18:12:44 +00:00
Adrian Prantl aa97a89d83 Extend FindTypes with CompilerContext to allow filtering by language.
This patch is also motivated by the Swift branch and is effectively NFC for the single-TypeSystem llvm.org branch.

In multi-language projects it is extremely common to have, e.g., a
Clang type and a similarly-named rendition of that same type in
another language. When searching for a type It is much cheaper to pass
a set of supported languages to the SymbolFile than having it
materialize every result and then rejecting the materialized types
that have the wrong language.

Differential Revision: https://reviews.llvm.org/D66546

<rdar://problem/54471165>

This reapplies r369690 with a previously missing constructor for LanguageSet.

llvm-svn: 369710
2019-08-22 21:45:58 +00:00
Adrian Prantl b041602e3f Revert Extend FindTypes with CompilerContext to allow filtering by language.
This reverts r369690 (git commit aa3a564efa)

llvm-svn: 369702
2019-08-22 20:41:16 +00:00
Adrian Prantl 83108e7556 Rename lldb/source/Interpreter/OptionValueFileSpecListTmp.cpp to
lldb/source/Interpreter/OptionValueFileSpecList.cpp (NFC)

llvm-svn: 369699
2019-08-22 20:10:24 +00:00
Adrian Prantl 06d778f00a Rename lldb/source/Interpreter/OptionValueFileSpecLIst.cpp to
lldb/source/Interpreter/OptionValueFileSpecListTmp.cpp (NFC)

llvm-svn: 369698
2019-08-22 20:08:46 +00:00
Adrian Prantl aa3a564efa Extend FindTypes with CompilerContext to allow filtering by language.
This patch is also motivated by the Swift branch and is effectively NFC for the single-TypeSystem llvm.org branch.

In multi-language projects it is extremely common to have, e.g., a
Clang type and a similarly-named rendition of that same type in
another language. When searching for a type It is much cheaper to pass
a set of supported languages to the SymbolFile than having it
materialize every result and then rejecting the materialized types
that have the wrong language.

Differential Revision: https://reviews.llvm.org/D66546

<rdar://problem/54471165>

llvm-svn: 369690
2019-08-22 19:24:55 +00:00
Raphael Isemann 494370c101 [lldb][NFC] Remove unused return value from HandleOptionArgumentCompletion
llvm-svn: 369635
2019-08-22 09:14:42 +00:00
Raphael Isemann 1153dc9603 [lldb][NFC] NFC cleanup for the completion code
llvm-svn: 369632
2019-08-22 09:02:54 +00:00
Raphael Isemann 36162014c4 [lldb][NFC] Remove dead code that is supposed to handle invalid command options
Summary:
We currently have a bunch of code that is supposed to handle invalid command options, but
all this code is unreachable because invalid options are already handled in `Options::Parse`.
The only way we can reach this code is when we declare but then not implement an option
(which will be made impossible with D65386, which is also when we can completely remove
the `default` cases).

This patch replaces all this code with `llvm_unreachable` to make clear this is dead code
that can't be reached.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D66522

llvm-svn: 369625
2019-08-22 08:08:05 +00:00
Raphael Isemann ae34ed2c0d [lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values
Summary:
We still have some leftovers of the old completion API in the internals of
LLDB that haven't been replaced by the new CompletionRequest. These leftovers
are:

* The return values (int/size_t) in all completion functions.
* Our result array that starts indexing at 1.
* `WordComplete` mode.

I didn't replace them back then because it's tricky to figure out what exactly they
are used for and the completion code is relatively untested. I finally got around
to writing more tests for the API and understanding the semantics, so I think it's
a good time to get rid of them.

A few words why those things should be removed/replaced:

* The return values are really cryptic, partly redundant and rarely documented.
  They are also completely ignored by Xcode, so whatever information they contain will end up
  breaking Xcode's completion mechanism. They are also partly impossible to even implement
  as we assign negative values special meaning and our completion API sometimes returns size_t.

  Completion functions are supposed to return -2 to rewrite the current line. We seem to use this
  in some untested code path to expand the history repeat character to the full command, but
  I haven't figured out why that doesn't work at the moment.
  Completion functions return -1 to 'insert the completion character', but that isn't implemented
  (even though we seem to activate this feature in LLDB sometimes).
  All positive values have to match the number of results. This is obviously just redundant information
  as the user can just look at the result list to get that information (which is what Xcode does).

* The result array that starts indexing at 1 is obviously unexpected. The first element of the array is
  reserved for the common prefix of all completions (e.g. "foobar" and "footar" -> "foo"). The idea is
  that we calculate this to make the life of the API caller easier, but obviously forcing people to have
  1-based indices is not helpful (or even worse, forces them to manually copy the results to make it
  0-based like Xcode has to do).

* The `WordComplete` mode indicates that LLDB should enter a space behind the completion. The
  idea is that we let the top-level API know that we just provided a full completion. Interestingly we
  `WordComplete` is just a single bool that somehow represents all N completions. And we always
  provide full completions in LLDB, so in theory it should always be true.
  The only use it currently serves is providing redundant information about whether we have a single
  definitive completion or not (which we already know from the number of results we get).

This patch essentially removes `WordComplete` mode and makes the result array indexed from 0.
It also removes all return values from all internal completion functions. The only non-redundant information
they contain is about rewriting the current line (which is broken), so that functionality was moved
to the CompletionRequest API. So you can now do `addCompletion("blub", "description", CompletionMode::RewriteLine)`
to do the same.

For the SB API we emulate the old behaviour by making the array indexed from 1 again with the common
prefix at index 0. I didn't keep the special negative return codes as we either never sent them before (e.g. -2) or we
didn't even implement them in the Editline handler (e.g. -1).

I tried to keep this patch minimal and I'm aware we can probably now even further simplify a bunch of related code,
but I would prefer doing this in follow-up NFC commits

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: arphaman, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D66536

llvm-svn: 369624
2019-08-22 07:41:23 +00:00