Commit Graph

17896 Commits

Author SHA1 Message Date
Raphael Isemann 1ede18fb4d Added test for Core/Range class.
Summary:
We can optimize and refactor some of the classes in RangeMap.h, but first
we should have some tests for all the data structures in there. This adds a first
batch of tests for the Range class itself.

There are some unexpected results happening when mixing invalid and valid ranges, so
I added some FIXME's for that in the tests.

Reviewers: vsk

Reviewed By: vsk

Subscribers: mgorny, lldb-commits

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

llvm-svn: 339611
2018-08-13 20:43:06 +00:00
Stefan Granitz 5e6bd2f8a9 Straight forward FastDemangle replacement in SubsPrimitiveParmItanium
Summary:
Removing FastDemangle will greatly reduce maintenance efforts. This patch replaces the last point of use in LLDB. Semantics should be kept intact.

Once this is agreed upon, we can:
* Remove the FastDemangle sources
* Add more features e.g. substitutions in template parameters, considering all variations, etc.

Depends on LLVM patch https://reviews.llvm.org/D50586

Reviewers: erik.pilkington, friss, jingham, JDevlieghere

Subscribers: kristof.beyls, chrib, lldb-commits

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

llvm-svn: 339583
2018-08-13 16:45:06 +00:00
Raphael Isemann a7f19e5fda Use a DenseMap for looking up functions by UID in CompileUnit::FindFunctionByUID
Summary:
Instead of iterating over our vector of functions, we might as well use a map here to
directly get the function we need.

Thanks to Vedant for pointing this out.

Reviewers: vsk

Reviewed By: vsk

Subscribers: mgrang, lldb-commits

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

llvm-svn: 339504
2018-08-11 23:40:27 +00:00
Raphael Isemann 4b2e0b6c32 Remove copy-pasted and unrelated comment [NFC]
That comment was copied from the
CombineConsecutiveEntriesWithEqualData() implementation below,
and doesn't actually describe what's happening in the current
function.

llvm-svn: 339473
2018-08-10 21:31:44 +00:00
Stella Stamenova 98b75bec71 [tests, libstdcxx] Add missing test category on the TestDataFormatterStdUniquePtr tests
Each test needs to be marked with the add_test_categories decorator individually.

llvm-svn: 339457
2018-08-10 17:52:45 +00:00
Stefan Granitz d051416491 RichManglingContext: Make m_ipd_str_len a local variable and simplify processIPDStrResult + polishing in test and Mangled
llvm-svn: 339440
2018-08-10 15:21:33 +00:00
Tatyana Krasnukha a94f3363ef Amend "Remove unused type Either from Utility library".
llvm-svn: 339430
2018-08-10 13:01:26 +00:00
Raphael Isemann 92be39d382 Added missing null checks to fix r339351
llvm-svn: 339353
2018-08-09 15:57:43 +00:00
Raphael Isemann 879c142130 Also display the output and error output of a failed command
Summary:
Instead of just printing the current "False is not True, ..." message when we
fail to run a certain command, this patch also adds the actual command output or
error output that we received to the assertion message.

Reviewers: davide

Reviewed By: davide

Subscribers: lldb-commits

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

llvm-svn: 339351
2018-08-09 15:29:32 +00:00
Tim Northover aa8377e8a3 Darwin: mark test unsupported while we sort out how to make it generic.
This test relies on communicating with debugserver via an unnamed (pre-opened)
pipe, but macOS's version of debugserver doesn't seem to support that mode of
operation. So disable the test for now.

llvm-svn: 339343
2018-08-09 13:21:05 +00:00
Tatyana Krasnukha 14dc665398 Remove unused type Either from Utility library.
llvm-svn: 339328
2018-08-09 11:42:28 +00:00
Stefan Granitz 4c01eccba2 Add ConstString test FromMidOfBufferStringRef
Summary: It was not immediately clear to me whether or not non-null-terminated StringRef's are supported in ConstString and/or the counterpart mechanism. From this test it seems to be fine. Maybe useful to keep?

Reviewers: labath

Subscribers: lldb-commits

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

llvm-svn: 339292
2018-08-08 21:57:42 +00:00
Stefan Granitz f1a98df6ee Use rich mangling information in Symtab::InitNameIndexes()
Summary:
I set up a new review, because not all the code I touched was marked as a change in old one anymore.

In preparation for this review, there were two earlier ones:
* https://reviews.llvm.org/D49612 introduced the ItaniumPartialDemangler to LLDB demangling without conceptual changes
* https://reviews.llvm.org/D49909 added a unit test that covers all relevant code paths in the InitNameIndexes() function

Primary goals for this patch are:
(1) Use ItaniumPartialDemangler's rich mangling info for building LLDB's name index.
(2) Provide a uniform interface.
(3) Improve indexing performance.

The central implementation in this patch is our new function for explicit demangling:
```
const RichManglingInfo *
Mangled::DemangleWithRichManglingInfo(RichManglingContext &, SkipMangledNameFn *)
```

It takes a context object and a filter function and provides read-only access to the rich mangling info on success, or otherwise returns null. The two new classes are:
* `RichManglingInfo` offers a uniform interface to query symbol properties like `getFunctionDeclContextName()` or `isCtorOrDtor()` that are forwarded to the respective provider internally (`llvm::ItaniumPartialDemangler` or `lldb_private::CPlusPlusLanguage::MethodName`).
* `RichManglingContext` works a bit like `LLVMContext`, it the actual `RichManglingInfo` returned from `DemangleWithRichManglingInfo()` and handles lifetime and configuration. It is likely stack-allocated and can be reused for multiple queries during batch processing.

The idea here is that `DemangleWithRichManglingInfo()` acts like a gate keeper. It only provides access to `RichManglingInfo` on success, which in turn avoids the need to handle a `NoInfo` state in every single one of its getters. Having it stored within the context, avoids extra heap allocations and aids (3). As instantiations of the IPD the are considered expensive, the context is the ideal place to store it too. An efficient filtering function `SkipMangledNameFn` is another piece in the performance puzzle and it helps to mimic the original behavior of `InitNameIndexes`.

Future potential:
* `DemangleWithRichManglingInfo()` is thread-safe, IFF using different contexts in different threads. This may be exploited in the future. (It's another thing that it has in common with `LLVMContext`.)
* The old implementation only parsed and indexed Itanium mangled names. The new `RichManglingInfo` can be extended for various mangling schemes and languages.

One problem with the implementation of RichManglingInfo is the inaccessibility of class `CPlusPlusLanguage::MethodName` (defined in source/Plugins/Language/..), from within any header in the Core components of LLDB. The rather hacky solution is to store a type erased reference and cast it to the correct type on access in the cpp - see `RichManglingInfo::get<ParserT>()`. At the moment there seems to be no better way to do it. IMHO `CPlusPlusLanguage::MethodName` should be a top-level class in order to enable forward delcarations (but that is a rather big change I guess).

First simple profiling shows a good speedup. `target create clang` now takes 0.64s on average. Before the change I observed runtimes between 0.76s an 1.01s. This is still no bulletproof data (I only ran it on one machine!), but it's a promising indicator I think.

Reviewers: labath, jingham, JDevlieghere, erik.pilkington

Subscribers: zturner, clayborg, mgorny, lldb-commits

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

llvm-svn: 339291
2018-08-08 21:57:37 +00:00
Vedant Kumar f71dd3445b [IRMemoryMap] Shrink Allocation and make it move-only (NFC)
Profiling data show that Allocation::operator= is hot (see the data
attached to the Phab review).

Reorder a few fields within Allocation to avoid implicit structure
padding and shrink the structure. This should make copies a bit cheaper.

Also, given that an Allocation contains a std::vector (by way of
DataBufferHeap), it's preferable to make it move-only instead of
permitting expensive copies. As an added benefit this allows us to have
a single Allocation constructor instead of two.

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

llvm-svn: 339290
2018-08-08 21:26:49 +00:00
Vedant Kumar 6504d4390f Delete a dead Function constructor (NFC)
llvm-svn: 339206
2018-08-07 23:48:40 +00:00
Vedant Kumar 33e51b142c [StackFrame] Add more clarifying comments to StackFrameList (NFC)
llvm-svn: 339205
2018-08-07 23:48:25 +00:00
Raphael Isemann ab48bd2a8d Removed doxygen comment that doesn't fit to function signature
llvm-svn: 339204
2018-08-07 23:47:05 +00:00
Raphael Isemann 12d74b911d Removed duplicated commented-out code [NFC]
llvm-svn: 339202
2018-08-07 23:24:24 +00:00
Alexander Polyakov a320e39acd Add documentation for SBTarget::AppendImageSearchPath
llvm-svn: 339189
2018-08-07 21:41:59 +00:00
Jim Ingham 7aa4ed9b5f If a function starts with line number 0, don't try to check if a breakpoint crossed function boundaries.
clang doesn't use line number 0 (to mean artifically generated code) very often, but swift does it
quite often.  We were rejecting all by line breakpoints in functions that started at line 0.  But that's
a special marker so we can just not do this test in that case.

llvm-svn: 339182
2018-08-07 21:09:55 +00:00
Jim Ingham b303009b9f Fix the Xcode project for the Core -> Utility moves.
Scalar.{h,cpp}, RegisterValue.{h,cpp}, State.{h,cpp} were moved.

llvm-svn: 339181
2018-08-07 21:05:34 +00:00
Stella Stamenova 5fa14d971d [lit, python] Change the order of the quotes in the lit cfg file
Double quotes are always correct in paths on windows while single quotes only work sometimes. By swapping the order of the quotes in the subsitution we guarantee that the quotes will be correct on Windows. Both sets work correctly on Linux in the test environment.

llvm-svn: 339180
2018-08-07 20:58:02 +00:00
Alexander Polyakov 65bd2f6c85 [lldb-mi] Re-implement target-select command
Now target-select uses SB API instead of HandleCommand.

This patch has been reviewed along with the r339175.

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

llvm-svn: 339178
2018-08-07 20:45:46 +00:00
Alexander Polyakov 3e7b9db2d9 Add new API to SBTarget class
Summary:
The new API appends an image search path to the
target's path mapping list.

Reviewers: aprantl, clayborg, labath

Reviewed By: aprantl

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 339175
2018-08-07 20:23:57 +00:00
Leonard Mosescu 9ba51579fb Misc module/dwarf logging improvements
This change improves the logging for the lldb.module category to note a few interesting cases:

1. Local object file found, but specs not matching
2. Local object file not found, using a placeholder module

The handling and logging for the cases wehre we fail to load compressed dwarf
symbols is also improved.

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

llvm-svn: 339161
2018-08-07 18:00:30 +00:00
Alexander Polyakov 57e6dd7222 [lldb-mi] Re-implement MI HandleProcessEventStateSuspended.
Summary: Now this function uses SB API instead of HandleCommand.

Reviewers: aprantl, clayborg, labath

Reviewed By: aprantl

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 339160
2018-08-07 17:55:26 +00:00
Alex Langford 8e5e2af33b Add instructions for building LLDB on Mac OS X with CMake
Summary:
There were previously no instructions for building LLDB on Mac OS X
with CMake. It's sufficiently close to building on Linux/FreeBSD/NetBSD that a
well-motivated developer could figure out the steps themselves. However, having
an explicit guide is better and can provide Mac OS X specific configurations
(e.g. LLDB_BUILD_FRAMEWORK).

Reviewers: labath, clayborg

Subscribers: emaste, krytarowski

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

llvm-svn: 339155
2018-08-07 17:34:13 +00:00
Tatyana Krasnukha f174259ec2 Check result after setting PC value.
llvm-svn: 339153
2018-08-07 16:46:11 +00:00
Pavel Labath 87730a6391 Move ScalarTest to follow the class being tested
This should have been a part of r339127, but I missed it somehow.

llvm-svn: 339136
2018-08-07 13:10:16 +00:00
Pavel Labath 1e4b50d40b Fix a couple of extended-offsetof warnings that had slipped through
llvm-svn: 339130
2018-08-07 12:16:49 +00:00
Pavel Labath d821c997aa Move RegisterValue,Scalar,State from Core to Utility
These three classes have no external dependencies, but they are used
from various low-level APIs. Moving them down to Utility improves
overall code layering (although it still does not break any particular
dependency completely).

The XCode project will need to be updated after this change.

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

llvm-svn: 339127
2018-08-07 11:07:21 +00:00
Stella Stamenova f0db95499b [lit, python] Always add quotes around the python path in lit
Summary:
The issue with the python path is that the path to python on Windows can contain spaces. To make the tests always work, the path to python needs to be surrounded by quotes.

This is a companion change to: https://reviews.llvm.org/D50206

Reviewers: asmith, zturner

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

llvm-svn: 339076
2018-08-06 22:37:53 +00:00
Stephane Sezer 0c679b7108 Revert "Add a relocation for R_AARCH64_ABS32 in ObjectFileELF"
This reverts commit f055ce7eb893cd0d17ebcfd4125018f46f983aff.

llvm-svn: 339071
2018-08-06 22:21:28 +00:00
Stephane Sezer b015ca6f52 Add a relocation for R_AARCH64_ABS32 in ObjectFileELF
Summary:
.rela.debug_info relocations are being done via
ObjectFileELF::ApplyRelocations for aarch64. Currently, the switch case
that iterates over the relocation type is only implemented for a few
different types and `assert(false)`es over the rest.

Implement the relocation for R_AARCH64_ABS32 in ApplyRelocations

Reviewers: sas, xiaobai, peter.smith, clayborg, javed.absar, espindola

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

Change by Nathan Lanza <lanza@fb.com>

llvm-svn: 339068
2018-08-06 22:04:08 +00:00
Vedant Kumar 9452359887 [IRMemoryMap] Avoid redundant zero-init in the Allocation constructor (NFC)
In the lldb-bench/arithmetic benchmark, 1.7% of the total running time
is spent zero-initializing a std::vector that has already been zeroed.

llvm-svn: 339051
2018-08-06 20:13:52 +00:00
Greg Clayton 1508dd8b86 Fix more offsetof issues.
llvm-svn: 339034
2018-08-06 17:26:53 +00:00
Greg Clayton d6836209a7 Fix offsetof usage that got lost when passing patches between linux and mac.
llvm-svn: 339033
2018-08-06 17:07:50 +00:00
Greg Clayton 19c8f394bc Add support for ARM and ARM64 breakpad generated minidump files (version 2).
In this patch I add support for ARM and ARM64 break pad files. There are two flavors of ARM: Apple where FP is R7, and non Apple where FP is R11. Added minimal tests that load up ARM64 and the two flavors or ARM core files with a single thread and known register values in each register. Each register is checked for the exact value.

This is a fixed version of: https://reviews.llvm.org/D49750

The changes from D49750 are:

Don't init the m_arch in the Initialize call as a system info isn't required. This keeps the thread list, module list and other tests from failing
Added -Wextended-offsetof to Xcode project so we catch use extended usages of offsetof before submission
Fixed any extended offset of warnings

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

llvm-svn: 339032
2018-08-06 16:56:10 +00:00
Stefan Granitz c238ca24b0 Fix Mangled::Compare()
llvm-svn: 339015
2018-08-06 14:15:21 +00:00
Stefan Granitz 4af5a83a48 Add ConstString::IsNull() to tell between null vs. empty strings and fix usage in Mangled::GetDemangledName()
Summary: `IsEmpty()` and `operator bool() == false` have equal semantics. Usage in Mangled::GetDemangledName() was incorrect. What it actually wants is a check for null-string. Split this off of D50071 and added a test to clarify usage.

Reviewers: labath, jingham

Subscribers: erik.pilkington, lldb-commits

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

llvm-svn: 339014
2018-08-06 14:15:17 +00:00
Pavel Labath 19a357adf8 Change ConstString::SetCStringWithMangledCounterpart to use StringRef
This should simplify the upcoming demangling patch (D50071). While I was
in there, I also added a quick test for the function.

llvm-svn: 338995
2018-08-06 08:27:59 +00:00
Raphael Isemann 7022b5369d Remove duplicated code in CommandObjectQuit
Summary:
We already have the same check directly before, so this code can never be
reached (as seen in the test coverage).

Subscribers: lldb-commits

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

llvm-svn: 338976
2018-08-06 00:04:51 +00:00
Raphael Isemann 13ff0d8d58 Added unit test for StringList
Reviewers: labath

Reviewed By: labath

Subscribers: mgorny, lldb-commits

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

llvm-svn: 338961
2018-08-04 17:28:21 +00:00
Raphael Isemann 5b9c465d7e Fixed header of StringLexer.h
llvm-svn: 338952
2018-08-04 05:53:07 +00:00
Leonard Mosescu 3da16f8393 Fix a bug in VMRange
I noticed a suspicious failure:

[ RUN ] VMRange.CollectionContains
llvm/src/tools/lldb/unittests/Utility/VMRangeTest.cpp:146: Failure
Value of: VMRange::ContainsRange(collection, VMRange(0x100, 0x104))

Actual: false
Expected: true

Looking at the code, it is a very real bug:

class RangeInRangeUnaryPredicate {
public:
  RangeInRangeUnaryPredicate(VMRange range) : _range(range) {} // note that _range binds to a temporary!
  bool operator()(const VMRange &range) const {
    return range.Contains(_range);
  }
  const VMRange &_range;
};

This change fixes the bug.

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

llvm-svn: 338949
2018-08-04 02:15:26 +00:00
Alex Langford 72cb10c364 Modify lldb_suite.py to enable python debugging
Summary:
pudb and pdb interfere with the behavior of the inspect module. calling
`inspect.getfile(inspect.currentframe())` returns a different result
depending on whether or not you're in a debugger. Calling
`os.path.abspath` on the result of `inspect.getfile(...)` normalizes the
result between the two environments.

Patch by Nathan Lanza <lanza@fb.com>

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

llvm-svn: 338923
2018-08-03 21:37:01 +00:00
Raphael Isemann 79e9921ce2 Replace LLDB's LEB128 implementation with the one from LLVM
Reviewers: davide, labath

Reviewed By: labath

Subscribers: lldb-commits

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

llvm-svn: 338920
2018-08-03 20:51:31 +00:00
Raphael Isemann 286ac07199 Add raw_ostream wrapper to the Stream class
Summary:
This wrapper will allow us in the future to reuse LLVM methods from within the
Stream class.

Currently no test as this is intended to be an internal class that shouldn't have any
NFC. The test for this change will be the follow up patch that migrates LLDB's
LEB128 implementation to the one from LLVM.

This change also adds custom move/assignment methods to Stream, as LLVM
raw_ostream doesn't support these. As our internal stream has anyway no state,
we can just keep the same stream object around.

Reviewers: davide, labath

Reviewed By: labath

Subscribers: xiaobai, labath, lldb-commits

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

llvm-svn: 338901
2018-08-03 16:56:33 +00:00
Pavel Labath 659cee52fc Revert "Add support for ARM and ARM64 breakpad generated minidump files"
This reverts commit r338734 (and subsequent fixups in r338772 and
r338746), because it breaks some minidump unit tests and introduces a
lot of compiler warnings.

llvm-svn: 338828
2018-08-03 08:47:22 +00:00
David L. Jones f0a57378aa [lldb] Remove unused variable.
The use of this variable was removed in r338734. It now causes unused variable warnings.

llvm-svn: 338772
2018-08-02 21:45:05 +00:00
Stella Stamenova 0faca0f09f [lldbsuite, windows] Mark tests as XFAIL on Windows or skip them
Summary:
1) Several tests that are flakey on windows fail the run even if they are marked as expected to be flakey. This is because they fail frequently enough that even a retry won't help
2) Skip several tests on Windows that will occasionally hang rather than failing or exiting. This is causing the entire test suite to hang

Reviewers: asmith, labath, zturner

Reviewed By: zturner

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

llvm-svn: 338769
2018-08-02 21:26:19 +00:00
Zachary Turner af3367d2ff Fix CMake build.
Some new files were committed to the repository but not added
to the CMakeLists.txt, so this patch fixes the build.

llvm-svn: 338746
2018-08-02 17:44:41 +00:00
Greg Clayton 2d953f22a0 Add support for ARM and ARM64 breakpad generated minidump files
In this patch I add support for ARM and ARM64 break pad files. There are two flavors of ARM: Apple where FP is R7, and non Apple where FP is R11. Added minimal tests that load up ARM64 and the two flavors or ARM core files with a single thread and known register values in each register. Each register is checked for the exact value.

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

llvm-svn: 338734
2018-08-02 16:46:15 +00:00
Raphael Isemann 92b16738a1 Add byte counting mechanism to LLDB's Stream class.
Summary:
This patch allows LLDB's Stream class to count the bytes it has written to so far.

There are two major motivations for this patch:

The first one is that this will allow us to get rid of all the handwritten byte counting code
we have in LLDB so far. Examples for this are pretty much all functions in LLDB that
take a Stream to write to and return a size_t, which usually represents the bytes written.

By moving to this centralized byte counting mechanism, we hopefully can avoid some
tricky errors that happen when some code forgets to count the written bytes while
writing something to a stream.

The second motivation is that this is needed for the migration away from LLDB's `Stream`
and towards LLVM's `raw_ostream`. My current plan is to start offering a fake raw_ostream
class that just forwards to a LLDB Stream.

However, for this raw_ostream wrapper we need to fulfill the raw_ostream interface with
LLDB's Stream, which currently lacks the ability to count the bytes written so far (which
raw_ostream exposes by it's `tell()` method). By adding this functionality it is trivial to start
rolling out our raw_ostream wrapper (and then eventually completely move to raw_ostream).

Also, once this fake raw_ostream is available, we can start replacing our own code writing
to LLDB's Stream by LLVM code writing to raw_ostream. The best example for this is the
LEB128 encoding we currently ship, which can be replaced with by LLVM's version which
accepts an raw_ostream.

From the point of view of the pure source changes this test does, we essentially just renamed
the Write implementation in Stream to `WriteImpl` while the `Write` method everyone is using
to write its raw bytes is now just forwarding and counting the written bytes.

Reviewers: labath, davide

Reviewed By: labath

Subscribers: JDevlieghere, lldb-commits

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

llvm-svn: 338733
2018-08-02 16:38:34 +00:00
Tim Northover ccb06e720d Move ClangHighlighter.cpp to hopefully better place in Xcode project.
But with a write-only format, who can really say?

llvm-svn: 338712
2018-08-02 12:50:23 +00:00
Stefan Granitz 149fede165 Unit test for Symtab::InitNameIndexes
Summary: In order to exploit the potential of LLVM's new ItaniumPartialDemangler for indexing in LLDB, we expect conceptual changes in the implementation of the InitNameIndexes function. Here is a unit test that aims at covering all relevant code paths in that function.

Reviewers: labath, jingham, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: friss, teemperor, davide, clayborg, erik.pilkington, lldb-commits, mgorny

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

llvm-svn: 338695
2018-08-02 10:13:18 +00:00
Raphael Isemann 0d7e7166b8 Added missing highlighter files to XCode project
llvm-svn: 338669
2018-08-02 03:01:09 +00:00
Raphael Isemann 566afa0ab2 [LLDB] Added syntax highlighting support
Summary:
This patch adds syntax highlighting support to LLDB. When enabled (and lldb is allowed
to use colors), printed source code is annotated with the ANSI color escape sequences.

So far we have only one highlighter which is based on Clang and is responsible for all
languages that are supported by Clang. It essentially just runs the raw lexer over the input
and then surrounds the specific tokens with the configured escape sequences.

Reviewers: zturner, davide

Reviewed By: davide

Subscribers: labath, teemperor, llvm-commits, mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 338662
2018-08-02 00:30:15 +00:00
Raphael Isemann 8fa58b1d17 Remove unnecessary target from TestCompletion patch
As Jim pointed out, we don't need to manually create a target
here because we already create a target implicitly in the very
next line (which means we just created a target and don't use it).

This patch just removes the line that creates the first unused target.

llvm-svn: 338657
2018-08-01 23:54:37 +00:00
Davide Italiano 6699fc34dd [DWARFASTParser] Remove special cases for `llvm-gcc`
Reviewed by: aprantl, labath.

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

llvm-svn: 338638
2018-08-01 21:13:45 +00:00
Raphael Isemann f4590de992 Fix out-of-bounds read in Stream::PutCStringAsRawHex8
Summary:
When I added the Stream unit test (r338488), the build bots failed due to an out-of-
bound reads when passing an empty string to the PutCStringAsRawHex8 method.
In r338491 I removed the test case to fix the bots.

This patch fixes this in PutCStringAsRawHex8 by always checking for the terminating
null character in the given string (instead of skipping it the first time). It also re-adds the
test case I removed.

Reviewers: vsk

Reviewed By: vsk

Subscribers: vsk, lldb-commits

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

llvm-svn: 338637
2018-08-01 21:07:18 +00:00
Raphael Isemann 95d8c464d8 Fixed documentation for PutHex8 [NFC]
The previous documentation was just copied from PrintfAsRawHex8
but doesn't actually fit to the PutHex8 method.

llvm-svn: 338611
2018-08-01 18:38:19 +00:00
Raphael Isemann a4c88c8484 Remove outdated documentation for Stream's LEB128 methods
There is no format parameter for any of these methods.

llvm-svn: 338605
2018-08-01 18:28:54 +00:00
Alex Langford 36706fd977 Introduce install-lldb-framework target
Summary:
Previously, I thought that install-liblldb would fail because CMake had
a bug related to installing frameworks. In actuality, I misunderstood the
semantics of `add_custom_target`: the DEPENDS option refers to specific files,
not targets. Therefore `install-liblldb` should rely on the actual liblldb
getting generated rather than the target.

This means that the previous patch I committed (to stop relying on CMake's
framework support) is no longer needed and has been reverted. Using CMake's
framework support greatly simplifies the implementation.

`install-lldb-framework` (and the stripped variant) is as simple as
depending on `install-liblldb` because CMake knows that liblldb was built as a
framework and will install the whole framework for you. The stripped variant
will depend on the stripped variants of individual tools only to ensure they
actually are stripped as well.

Reviewers: labath, sas

Subscribers: mgorny, lldb-commits

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

llvm-svn: 338594
2018-08-01 17:21:18 +00:00
Raphael Isemann 0bb8d83c89 Don't ignore byte_order in Stream::PutMaxHex64
Reviewers: labath

Reviewed By: labath

Subscribers: zturner, lldb-commits

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

llvm-svn: 338591
2018-08-01 17:12:58 +00:00
Vedant Kumar b3b7b1bff0 [StackFrame] Add doxygen comments to the StackFrameList API (NFC)
Clarify how StackFrameList works by documenting its methods. Also,
delete some dead code and insert some TODOs.

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

llvm-svn: 338590
2018-08-01 17:08:11 +00:00
Vedant Kumar e7167e03ad [StackFrame] Use early returns in ResetCurrentInlinedDepth (NFC)
Using early returns in this function substantially reduces the nesting
level, making the logic easier to understand.

llvm-svn: 338589
2018-08-01 17:07:56 +00:00
Vedant Kumar eb8fa58e97 [StackFrame] Factor GetOnlyConcreteFramesUpTo out of GetFramesUpTo (NFC)
Splitting GetOnlyConcreteFramesUpTo will make it easier to implement
support for synthetic tail call frames in backtraces. This is just a
prep change, no functionality is affected.

llvm-svn: 338588
2018-08-01 17:07:40 +00:00
Raphael Isemann 7dd0aba0b2 Removed failing StreamTest case
The suspicious behavior is obviously because this method reads
OOB memory, so I'll remove it for now and re-add the test alongside
the fix later.

llvm-svn: 338491
2018-08-01 06:35:27 +00:00
Raphael Isemann b1dfad0601 Added initial unit test for LLDB's Stream class.
Summary:
This adds an initial small unit test for LLDB's Stream class, which should at least cover
most of the functions in the Stream class. StreamString is always in big endian
mode, so that's the only stream byte order path this test covers as of now. Also,
the binary mode still needs to be tested for all print methods.

Also adds some FIXMEs for wrong/strange result values of the Stream class that we hit
while testing those functions.

Reviewers: labath

Reviewed By: labath

Subscribers: probinson, labath, mgorny, lldb-commits

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

llvm-svn: 338488
2018-08-01 06:04:48 +00:00
Eric Christopher 83c49e8ed4 Android is an environment and we were comparing the android triple
against the OS rather than the environment. Also update other
uses of OS when we meant environment in the android local code.

NFC intended.

llvm-svn: 338460
2018-07-31 23:53:24 +00:00
Eric Christopher 852e88ad85 Tidy up comment.
llvm-svn: 338459
2018-07-31 23:53:24 +00:00
Eric Christopher 926b7c71f3 Use UnknownVendor rather than UnknownArch since they're in two different enums
and we're switching on vendor and not arch.

llvm-svn: 338458
2018-07-31 23:53:23 +00:00
Raphael Isemann 56bf356a4b Remove Stream::UnitTest
Summary: No one is using this method, and it also doesn't really make a lot of sense to have it around.

Reviewers: davide

Reviewed By: davide

Subscribers: davide, lldb-commits

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

llvm-svn: 338345
2018-07-31 01:21:36 +00:00
Raphael Isemann 129fe89ffb Remove unnecessary newlines from break command help text.
Summary:
We usually don't have trailing newlines in the short help strings. This just adds
unnecessary extra lines when printing the help text of these commands.

Subscribers: lldb-commits

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

llvm-svn: 338311
2018-07-30 21:41:13 +00:00
Jan Kratochvil cd9c15cda1 Remove friend class declarations from DWARFUnit and DWARFCompileUnit
They are no longer needed since D45170.

llvm-svn: 338224
2018-07-29 19:32:36 +00:00
Raphael Isemann 7bb4de47c9 Add the actually calculated completions to COMPLETION_MSG
Summary: Otherwise this assertion message is not very useful to whoever is reading the log.

Subscribers: lldb-commits

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

llvm-svn: 338179
2018-07-27 23:42:34 +00:00
Alex Langford 2f6a1018e0 Revert "Stop building liblldb with CMake's framework functionality"
This reverts r338154. This change is actually unnecessary, as the CMake
bug I referred to was actually not a bug but a misunderstanding of
CMake.

Original Differential Revision: https://reviews.llvm.org/D49888

llvm-svn: 338178
2018-07-27 23:38:58 +00:00
Raphael Isemann d4ff5ba926 Add missing boundary checks to variable completion.
Summary: Stopgap patch to at least stop all the crashes I get from this code.

Subscribers: lldb-commits

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

llvm-svn: 338177
2018-07-27 23:37:08 +00:00
Raphael Isemann 23d7a9ebbe Fix whitespace in the python test suite.
Summary:
The test suite has often unnecessary trailing whitespace, and sometimes
unnecessary trailing lines or a missing final new line. This patch just strips
trailing whitespace/lines and adds missing newlines at the end.

Subscribers: ki.stfu, JDevlieghere, christof, lldb-commits

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

llvm-svn: 338171
2018-07-27 22:20:59 +00:00
Davide Italiano 2d396a912a Revert "Recommit [DataFormatters] Add formatter for C++17 std::optional."
This broke a linux bot which doesn't support -std=c++17. The solution
is to add a decorator to skip these tests on machines with older compilers.

llvm-svn: 338162
2018-07-27 20:38:01 +00:00
Davide Italiano 1d44c46539 Recommit [DataFormatters] Add formatter for C++17 std::optional.
This should have all the correct files now.
<rdar://problem/41471112>
Patch by Shafik Yaghmour.

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

llvm-svn: 338156
2018-07-27 19:57:30 +00:00
Alex Langford c1d4311c1b Stop building liblldb with CMake's framework functionality
Summary:
CMake has a bug in its ninja generator that prevents you from
installing targets that are built with framework support. Therefore, I want to
not rely on CMake's framework support.
See https://gitlab.kitware.com/cmake/cmake/issues/18216

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

llvm-svn: 338154
2018-07-27 19:41:17 +00:00
Raphael Isemann 1a6d7ab55d Narrow the CompletionRequest API to being append-only.
Summary:
We currently allow any completion handler to read and manipulate the list of matches we
calculated so far. This leads to a few problems:

Firstly, a completion handler's logic can now depend on previously calculated results
by another handlers. No completion handler should have such an implicit dependency,
but the current API makes it likely that this could happen (or already happens). Especially
the fact that some completion handler deleted all previously calculated results can mess
things up right now.

Secondly, all completion handlers have knowledge about our internal data structures with
this API. This makes refactoring this internal data structure much harder than it should be.
Especially planned changes like the support of descriptions for completions are currently
giant patches because we have to refactor every single completion handler.

This patch narrows the contract the CompletionRequest has with the different handlers to:

1. A handler can suggest a completion.
2. A handler can ask how many suggestions we already have.

Point 2 obviously means we still have a  dependency left between the different handlers, but
getting rid of this is too large to just append it to this patch.

Otherwise this patch just completely hides the internal StringList to the different handlers.

The CompletionRequest API now also ensures that the list of completions is unique and we
don't suggest the same value multiple times to the user. This property has been so far only
been ensured by the `Option` handler, but is now applied globally. This is part of this patch
as the OptionHandler is no longer able to implement this functionality itself.

Reviewers: jingham, davide, labath

Reviewed By: davide

Subscribers: lldb-commits

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

llvm-svn: 338151
2018-07-27 18:42:46 +00:00
Alex Langford 60bdd09d10 Add back lldb-framework-headers target
In r338058 we removed the target `lldb-framework-headers`, which mean
lldb-framework no longer depended on `framework_headers`, so they never
actually got generated. This is a partial revert of r338058: I added
back the lldb-framework-headers target, but the framework-header-fix.sh
script still runs on the copied headers.

llvm-svn: 338074
2018-07-26 21:55:14 +00:00
Alex Langford 10c9e0e0d8 Make framework-header-fix process copied headers
Summary:
Previously the framework-header-fix script would change the sources
before they were copied, leading to unnecessary rebuilds on repeat
`ninja lldb` invocations. This runs the script on the headers after
they're copied into the produced LLDB.framework, meaning it doesn't
affect any files being built.

Patch by Keith Smiley <keithbsmiley@gmail.com>!

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

llvm-svn: 338058
2018-07-26 19:04:46 +00:00
Raphael Isemann 223d921c6a Fix duplicate suggestions after an ambiguous command
Summary:
So far lldb is printing this when it finds an ambiguous command:
```
(lldb) g
Ambiguous command 'g'. Possible matches:
        gdb-remote
        gui
        gdb-remote
        gui
```
The duplicates come from the fact that we call the same query twice with the same parameters
and add it to the same list. This patch just removes the second query call to `GetCommandObject`.

As `GetCommandObject` is const and the name parameter is also not modified, this shouldn't break
anything else. I didn't merge the remaining if statement into the else as I think otherwise the
`if obj==nullptr do X else Y` pattern in there becomes hard to recognize.

Reviewers: davide

Reviewed By: davide

Subscribers: lldb-commits

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

llvm-svn: 338043
2018-07-26 17:14:18 +00:00
Raphael Isemann 6fcc7d703b Don't print two errors for unknown commands.
Summary:
We always print two error messages when we hit an unknown command. As the function
`CommandInterpreter::HandleCommand` that prints the second error message unconditionally called the `CommandInterpreter::ResolveCommandImpl` before (which prints the first error message), we can just remove
that second error message.

Fixes https://bugs.llvm.org/show_bug.cgi?id=38312

Reviewers: labath

Reviewed By: labath

Subscribers: labath, lldb-commits

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

llvm-svn: 338040
2018-07-26 16:32:05 +00:00
Davide Italiano 4b58867d06 Revert "[DataFormatters] Add formatter for C++17 std::optional."
I forgot to git add some files. I'm going to recommit the correct
version at once soon.

llvm-svn: 337963
2018-07-25 21:18:20 +00:00
Davide Italiano 1d4a78ef04 [DataFormatters] Add formatter for C++17 std::optional.
<rdar://problem/41471112>

Patch by Shafik Yaghmour.

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

llvm-svn: 337959
2018-07-25 20:46:29 +00:00
Jonas Devlieghere 03772dd87b [ProcessGDBRemote] handle result from ConnectToDebugserver
We ignored the result from ConnectToDebugserver, causing certain errors
(like a failed handshake) not to surface.

llvm-svn: 337932
2018-07-25 15:20:15 +00:00
Stefan Granitz 2f842d68df Use LLVM's new ItaniumPartialDemangler in LLDB
Summary:
Replace the existing combination of FastDemangle and the fallback to llvm::itaniumDemangle() with LLVM's new ItaniumPartialDemangler. It slightly reduces complexity and slightly improves performance, but doesn't introduce conceptual changes. This patch is preparing for more fundamental improvements on LLDB's demangling approach.

Reviewers: friss, jingham, erik.pilkington, labath, clayborg, mgorny, davide, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: teemperor, JDevlieghere, labath, clayborg, davide, lldb-commits, mgorny, erik.pilkington

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

llvm-svn: 337931
2018-07-25 15:19:04 +00:00
Pavel Labath 5457b426f5 Fix PythonString::GetString for >=python-3.7
The return value of PyUnicode_AsUTF8AndSize is now "const char *".

Thanks to Brett Neumeier for testing the patch out on python 3.7.

llvm-svn: 337908
2018-07-25 11:35:28 +00:00
Raphael Isemann bae7367cd9 Add unit tests for VMRange
Subscribers: clayborg, labath, mgorny, lldb-commits

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

llvm-svn: 337873
2018-07-24 23:52:39 +00:00
Jason Molenda d5522568e4 Add DumpRegisterValue.cpp.
llvm-svn: 337865
2018-07-24 23:19:56 +00:00
Raphael Isemann ea832b9578 Remove unused History class
Summary: This class doesn't seem to be used anywhere, so we might as well remove the code.

Reviewers: labath

Reviewed By: labath

Subscribers: labath, mgorny, lldb-commits

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

llvm-svn: 337855
2018-07-24 21:09:17 +00:00
Pavel Labath e03334cf6a Move dumping code out of RegisterValue class
Summary:
The dump function was the only part of this class which depended on
high-level functionality. This was due to the DumpDataExtractor
function, which uses info from a running target to control dump format
(although, RegisterValue doesn't really use the high-level part of
DumpDataExtractor).

This patch follows the same approach done for the DataExtractor class,
and extracts the dumping code into a separate function/file. This file
can stay in the higher level code, while the RegisterValue class and
anything that does not depend in dumping can stay go to lower layers.

The XCode project will need to be updated after this patch.

Reviewers: zturner, jingham, clayborg

Subscribers: lldb-commits, mgorny

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

llvm-svn: 337832
2018-07-24 15:48:13 +00:00
Pavel Labath 082bab1cff Reimplement EventDataBytes::Dump to avoid DumpDataExtractor
This is the only external non-trivial dependency of the Event classes.

llvm-svn: 337819
2018-07-24 10:49:14 +00:00
Raphael Isemann 6188a42592 Added unit test for StreamTee
Reviewers: davide

Reviewed By: davide

Subscribers: davide, mgorny, lldb-commits

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

llvm-svn: 337778
2018-07-24 00:01:32 +00:00
Jason Molenda b794fc78fc Change sort-pbxproj.rb to find the project.pbxproj in the
most likely locations.  And have it overwrite the original
file with the sorted output.

llvm-svn: 337774
2018-07-23 23:34:50 +00:00
Greg Clayton 247aac81ab Fix Xcode project for unit tests.
llvm-svn: 337758
2018-07-23 22:22:46 +00:00
Raphael Isemann 9df80e8248 [cmake] Remove unused ${LLDB_PLUGINS} dependency from our Objective-C++ CMake config
Summary:
LLDB_PLUGINS doesn't exist as a variable, so this line doesn't add any dependencies and is
just confusing. It seems this slipped in from the gdb-remote CMake I was using as a CMake template.

The gdb-remote CMake itself is using a local LLDB_PLUGINS variable, so that code is fine.

Reviewers: davide

Reviewed By: davide

Subscribers: davide, mgorny, lldb-commits

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

llvm-svn: 337741
2018-07-23 21:14:52 +00:00
Raphael Isemann 17af5b6e20 [NFC] Minor code refactoring.
Subscribers: lldb-commits

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

llvm-svn: 337737
2018-07-23 20:56:49 +00:00
Greg Clayton 2dd7e5e222 Add support for parsing Breakpad minidump files that can have extra padding in the module, thread and memory lists.
Differential Revision: https://reviews.llvm.org/D49579

llvm-svn: 337694
2018-07-23 14:16:08 +00:00
Alexander Polyakov 19150571c5 Fix windows build after r337689
Added missing header.

llvm-svn: 337692
2018-07-23 14:10:30 +00:00
Alexander Polyakov e2183d508a [lldb-mi] Re-implement data-info-line command.
Summary: Now data-info-line command uses SB API instead of HandleCommand.

Reviewers: aprantl, clayborg, jingham

Reviewed By: aprantl

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 337689
2018-07-23 13:02:41 +00:00
Jim Ingham 40fa4a1a55 Defend LoadImageUsingPaths against a path list
with empty paths on it.

llvm-svn: 337515
2018-07-20 01:20:18 +00:00
Raphael Isemann 3914833099 Added unit tests for Flags
Reviewers: labath

Reviewed By: labath

Subscribers: labath, mgorny, lldb-commits

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

llvm-svn: 337475
2018-07-19 17:45:51 +00:00
Pavel Labath a274452924 ELF: Replace the header-extension unit test with a lit one
The new test checks that we are actually able to read data from these
kinds of elf headers correctly instead of just that we read the section
number correctly. It is also easier to figure out what's going on in the
test.

llvm-svn: 337459
2018-07-19 14:38:30 +00:00
Pavel Labath 67b8f573a7 Fix whitespace formatting in DWARFExpression::DumpLocation
we were printing an extra space before the start for the expression and
an extra space after some dwarf operators. This makes sure we only print
exactly one space **between** operators and nowhere else.

llvm-svn: 337452
2018-07-19 13:30:56 +00:00
Stella Stamenova a633e9dbde Fix variables.test after D49018
Summary: This one fixes variables.test after D49018. The test was broken because D49018 adds a location information to variables, but I hadn't noticed that, because I used 32-bit build to run tests, so the test looked to me already broken before that commit (the test relies on mangled names, but the mangling schemes are different for 32-bit and 64-bit).

Reviewers: stella.stamenova, lldb-commits

Reviewed By: stella.stamenova

Patch By: Aleksandr Urakov

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

llvm-svn: 337397
2018-07-18 15:50:24 +00:00
Stella Stamenova 027a9fc2c5 [windows] Use a well-known path for ComSpec if we fail to retrieve it
Summary: Right now we always try to retrieve ComSpec and if we fail, we give up. This rarely fails, but we can update the logic so that we fail even less frequently. Since there is a well-known path (albeit not always correct), try the path when we failed to retrieve it. Note that on other platforms, we generally just return a well-known path without any checking.

Reviewers: asmith, zturner, labath

Reviewed By: zturner, labath

Subscribers: llvm-commits

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

llvm-svn: 337395
2018-07-18 15:21:54 +00:00
Stella Stamenova 0f97581af7 [lit, lldbsuite] Remove tests that are duplicated between lit and lldb-suite
Summary: Several tests exist in both lit and lldbsuite. This removes the lit version of the duplicated tests.

Reviewers: asmith, zturner

Subscribers: llvm-commits

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

llvm-svn: 337393
2018-07-18 15:16:54 +00:00
Jason Molenda c6ab25deef Link the lldb driver ("lldb") against the llvm static
libraries because of the new prettystackprinter dependency.

llvm-svn: 337335
2018-07-17 23:44:09 +00:00
Alex Langford 97ba3b64dd Invert dependency between lldb-framework and lldb-suite
Summary:
Currently, if you build lldb-framework the entire framework doesn't
actually build. In order to build the entire framework, you need to actually
build lldb-suite. This abstraction doesn't feel quite right because
lldb-framework truly does depend on lldb-suite (liblldb + related tools).

In this change I want to invert their dependency. This will mean that lldb and
finish_swig will depend on lldb-framework in a framework build, and lldb-suite
otherwise. Instead of adding conditional logic everywhere to handle this, I
introduce LLDB_SUITE_TARGET to handle it.

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

llvm-svn: 337311
2018-07-17 18:28:51 +00:00
Jonas Devlieghere 4ab5731973 [CMake] Have check-lldb-unit use CMAKE_CURRENT_BINARY_DIR
llvm-lit uses `map_config` directives (generated at configuration-time) to
make it possible to pass a test path relative to the source instead of
the build folder (CMAKE_CURRENT_BINARY_DIR).

However, this doesn't work in the case of swift where the build
directory layout prevents llvm-lit from knowing about lldb and its test
paths. This caused check-lldb-unit to fail in this configuration, while
everything was working as expected upstream. This patch fixes the issue
by passing a path relative to the build directory. This was already the
case for check-lldb-lit.

llvm-svn: 337291
2018-07-17 15:11:15 +00:00
Jonas Devlieghere 2ad6e0a696 Move pretty stack trace printer into driver.
We used to have a pretty stack trace printer in SystemInitializerCommon.
This was disabled on Apple because we didn't want the library to be
setting signal handlers, as this was causing issues when loaded into
Xcode. However, I think it's useful to have this for the LLDB driver, so
I moved it up to use the PrettyStackTraceProgram in the driver's main.

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

llvm-svn: 337261
2018-07-17 10:04:19 +00:00
Alex Langford 8d33a085c3 [CMake] Give lldb tools functional install targets when building LLDB.framework
Summary:
This change makes the install targets for lldb tools functional when
building for the framework.

I am currently working on the install rules for lldb-framework and this will
let me make `install-lldb-framework` rely on `install-lldb-argdumper` for
instance. This is especially important for `install-lldb-framework-stripped`. It
is much better for `install-lldb-framework-stripped` to rely on
`install-lldb-argdumper-stripped` than to copy and strip lldb-argdumper
manually.

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

llvm-svn: 337202
2018-07-16 19:19:56 +00:00
Raphael Isemann 2d42579886 Fix some crashes and deadlocks in FormatAnsiTerminalCodes
Summary:
This patch fixes a few problems with the FormatAnsiTerminalCodes function:

* It does an infinite loop on an unknown color value.
* It crashes when the color value is at the end of the string.
* It deletes the first character behind the color token.

Also added a few tests that reproduce those problems (and test some other corner cases).

Reviewers: davide, labath

Reviewed By: labath

Subscribers: labath, lldb-commits, mgorny

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

llvm-svn: 337189
2018-07-16 16:38:30 +00:00
Pavel Labath 94d84088e9 Fix typo in find-basic-function test
Wrong FileCheck header meant that we were not matching what we should.

This allows us to get rid of the -allow-deprecated-dag-overlap flag in
the test.

llvm-svn: 337188
2018-07-16 16:18:52 +00:00
Pavel Labath 7cb4dfb083 Fix TestDataFormatterUnordered for older libc++ versions
clang recently started diagnosing "exception specification in
declaration does not match previous declaration" errors. Unfortunately
old libc++ versions had a bug, where they violated this rule, which
means that tests using this library version now fail due to build
errors.

Since it was easy to work around the bug by compiling this test with
-fno-exceptions, I do that here. If supporting old libc++ versions
becomes a burden, we'll have to revisit this.

llvm-svn: 337173
2018-07-16 14:37:58 +00:00
Sterling Augustine 94c4512a8c Rollback r337070.
Someone simultaneously fixed the breakage it was designed to fix.

llvm-svn: 337071
2018-07-13 23:03:15 +00:00
Sterling Augustine df28c9f12b Update ClangASTContext for the new DependentVector type.
https://reviews.llvm.org/D49326

llvm-svn: 337070
2018-07-13 22:54:41 +00:00
Alexander Polyakov f5b1c2fa39 [lldb-mi] Make symbol-list-lines.test XFAIL on Windows
It's a temporary decision until we reach out what causes
a failure.

llvm-svn: 337064
2018-07-13 22:41:16 +00:00
Fangrui Song 8f28488594 Fix -Wswitch after introduction of clang;:Type::DependentVector in r337036
llvm-svn: 337063
2018-07-13 22:40:40 +00:00
Jim Ingham c685f6c17f Make these tests c++ tests so they can be skipped on systems that don't support those tests.
llvm-svn: 337058
2018-07-13 22:31:59 +00:00
Jim Ingham 393fe62e33 Fix the libcxx set, multiset, vector and bitset formatters to work on references.
The synthetic child providers for these classes had a type expression that matched
pointers & references to the type, but the Front End only worked on the actual object.

I fixed this by adding a way for the Synthetic Child FrontEnd provider to request dereference,
and then had these formatters use that mode.

<rdar://problem/40849836>

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

llvm-svn: 337035
2018-07-13 19:28:32 +00:00
Jim Ingham 0925c1fdff Add the new PDBLocationToDWARFExpression.{cpp,h} to the Xcode project.
llvm-svn: 337034
2018-07-13 19:24:26 +00:00
Raphael Isemann 291e6c5db6 Add includes for CompletionRequest to every file that uses it
Summary: Should fix the builds (and prevent future builds from failing when people try to reduce includes).

Reviewers: jingham

Reviewed By: jingham

Subscribers: jingham, lldb-commits

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

llvm-svn: 337032
2018-07-13 18:54:55 +00:00
Raphael Isemann a2e76c0bfc Replaced more boilerplate code with CompletionRequest (NFC)
Summary:
As suggested in D48796, this patch replaces even more internal calls that were using the old
completion API style with a single CompletionRequest. In some cases we also pass an option
vector/index, but as we don't always have this information, it currently is not part of the
CompletionRequest class.

The constructor of the CompletionRequest is now also more sensible. You only pass the
user input, cursor position and your list of matches to the request and the rest will be
inferred (using the same code we used before to calculate this). You also have to pass these
match window parameters to it, even though they are unused right now.

The patch shouldn't change any behavior.

Reviewers: jingham

Reviewed By: jingham

Subscribers: lldb-commits

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

llvm-svn: 337031
2018-07-13 18:28:14 +00:00
Raphael Isemann d6c062bce1 No longer pass a StringRef to the Python API
Summary:
The refactoring patch for DoExecute missed this case of a variadic function that just silently
accepts a StringRef which it then tries to reinterpret as a C-string.

This should fix the Windows builds.

Reviewers: stella.stamenova

Reviewed By: stella.stamenova

Subscribers: lldb-commits

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

llvm-svn: 337030
2018-07-13 18:13:46 +00:00
Frederic Riss 8e04d937b0 Fix TestAttachDenied on macOS Mojave
TestAttachDenied tries to attach to a process that is ptracing itself and
verifies that we error out. Starting with macOS Mojave, processes need
an entitlement to be able to ptrace. This commit adds the entitlement for
the test binary when building on Darwin.

llvm-svn: 337029
2018-07-13 17:45:43 +00:00
Tatyana Krasnukha 0b8bea311f Adjust thread name column width depending on real name length.
Make 16-byte aligned field instead of truncating a name to 16 byte.

llvm-svn: 336993
2018-07-13 11:49:28 +00:00
Tatyana Krasnukha 1a728f66ef Add abbreviated name for Debugger::EventHandlerThread.
On OS's where thread names are limited to 16 bytes, the full name was truncated to not very meaningful "r.event-handler".

llvm-svn: 336991
2018-07-13 11:21:06 +00:00
Jonas Devlieghere 924d560867 Convert a location information from PDB to a DWARF expression
The current version of SymbolFilePDB::ParseVariableForPDBData function
always initializes variables with an empty location. This patch adds the
converter of a location information from PDB to a DWARF expression, so
it becomes possible to watch values of variables of primitive data
types. At the moment the converter supports only Static, TLS, RegRel,
Enregistered and Constant PDB location types, but it seems that it's
enough for most cases. There are still some problems with retrieving
values of variables (e.g. we can't watch variables of composite types),
but they look not relevant to the conversion to DWARF.

Patch by: Aleksandr Urakov

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

llvm-svn: 336988
2018-07-13 10:29:27 +00:00
Stella Stamenova 7b68fa7fcd [lldbsuite] The test inside TestOverloadedFunctions.py has the wrong class name
Summary: It looks like the test file was copied from TestCPPStaticMethods.py because they have the same name. This means that the two tests will try to write to the same output files and will either overwrite each other's output or occasionally cause failures because they can't both access the same file.

Reviewers: asmith, zturner

Reviewed By: zturner

Subscribers: llvm-commits

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

llvm-svn: 336960
2018-07-12 23:02:33 +00:00
Jason Molenda a2476ab7c9 Remove incorrect thread-pc-values clearing
from ProcessGDBRemote::UpdateThreadIDsFromStopReplyThreadsValue.

Patch by Venkata Ramanaiah.

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

llvm-svn: 336956
2018-07-12 22:45:41 +00:00
Raphael Isemann 4d51a90297 Get rid of the C-string parameter in DoExecute
Summary:
This patch gets rid of the C-string parameter in the RawCommandObject::DoExecute function,
making the code simpler and less memory unsafe.

There seems to be a assumption in some command objects that this parameter could be a nullptr,
but from what I can see the rest of the API doesn't actually allow this (and other command
objects and related code pieces dereference this parameter without any checks).

Especially CommandObjectRegexCommand has error handling code for a nullptr that is now gone.

Reviewers: davide, jingham, teemperor

Reviewed By: teemperor

Subscribers: jingham, lldb-commits

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

llvm-svn: 336955
2018-07-12 22:28:52 +00:00
Stella Stamenova 4835a02b80 [process] Update the documentation for ReadMemory and DoReadMemory to include the error parameter
Summary: The current documentation does not include the error parameter.

Reviewers: jingham, asmith

Reviewed By: jingham

Subscribers: llvm-commits

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

llvm-svn: 336948
2018-07-12 21:27:56 +00:00
Leonard Mosescu 2ae3ec3b81 Restructure the minidump loading path and add early & explicit consistency checks
Corrupted minidumps was leading to unpredictable behavior.

This change adds explicit consistency checks for the minidump early on. The
checks are not comprehensive but they should catch obvious structural violations:

streams with type == 0
duplicate streams (same type)
overlapping streams
truncated minidumps

Another early check is to make sure we actually support the minidump architecture
instead of crashing at a random place deep inside LLDB.

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

llvm-svn: 336918
2018-07-12 17:27:18 +00:00
Eric Christopher b860318198 Remove the unused m_signal member variable, but leave the code that gets it out of the json.
llvm-svn: 336885
2018-07-12 03:52:46 +00:00
Eric Christopher 4bfb8011f7 Remove unused variable m_header as it hasn't been used since it was
added in 2016.

llvm-svn: 336884
2018-07-12 03:52:45 +00:00
Davide Italiano a9d84cb9d8 [IRInterpreter] Fix misevaluation of interpretation expressions with `urem`.
Scalar::MakeUnsigned was implemented incorrectly so it didn't
really change the sign of the type (leaving signed types signed).
This showed up as a misevaluation when IR-interpreting urem but
it's likely to arise in other contexts.

This commit fixes the definition, and adds a test to make
sure this won't regress in future (hopefully).

Fixes rdar://problem/42038760 and LLVM PR38076

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

llvm-svn: 336872
2018-07-12 00:31:04 +00:00
Stella Stamenova 62c76db4ee [windows] Fix out-of-memory failure in some of the tests
Summary: When ReadProcessMemory fails, bytes_read is sometimes set to a large garbage value. In that case, we need to set it back to zero before returning or the garbage value will be used to allocate memory later causing LLDB to crash with an out of memory error.

Reviewers: asmith, zturner

Reviewed By: zturner

Subscribers: zturner, asmith, stella.stamenova, llvm-commits

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

llvm-svn: 336865
2018-07-11 22:47:35 +00:00
Joel E. Denny a9088f7c33 [FileCheck] Add -allow-deprecated-dag-overlap to failing lldb tests
See https://reviews.llvm.org/D47106 for details.

Reviewed By: probinson

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

llvm-svn: 336846
2018-07-11 20:27:05 +00:00
Raphael Isemann c094d23f6f Allow specifying an exit code for the 'quit' command
Summary:
This patch adds the possibility to specify an exit code when calling quit.
We accept any int, even though it depends on the user what happens if the int is
out of the range of what the operating system supports as exit codes.

Fixes rdar://problem/38452312

Reviewers: davide, jingham, clayborg

Reviewed By: jingham

Subscribers: clayborg, jingham, lldb-commits

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

llvm-svn: 336824
2018-07-11 17:18:01 +00:00
Raphael Isemann ba800e7db5 Refactor ClangUserExpression::Parse [NFC]
Summary:
This patch splits out functionality from the `Parse` method into different methods.
This benefits the code completion work (which should reuse those methods) and makes the
code a bit more readable.

Note that this patch is as minimal as possible. Some of the code in the new methods definitely
needs more refactoring.

Subscribers: lldb-commits

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

llvm-svn: 336734
2018-07-10 22:12:39 +00:00
Stella Stamenova 45d8134c3b [windows] LLDB shows the wrong values when register read is executed at a frame other than zero
Summary:
This is a clean version of the change suggested here: https://bugs.llvm.org/show_bug.cgi?id=37495

The main change is to follow the same pattern as non-windows targets and use an unwinder object to retrieve the register context. I also changed a couple of the comments to actually log, so that issues with unsupported scenarios can be tracked down more easily. Lastly, ClearStackFrames is implemented in the base class, so individual thread implementations don't have to override it.

Reviewers: asmith, zturner, aleksandr.urakov

Reviewed By: aleksandr.urakov

Subscribers: emaste, stella.stamenova, tatyana-krasnukha, llvm-commits

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

llvm-svn: 336732
2018-07-10 22:05:33 +00:00
Davide Italiano 87951b6693 [testsuite] Implement a category to skip libstdcxx tests
On systems where it's not supported.
As far as I understand Linux is the only systems which now ships
with libstdcxx (maybe NetBSD?, but I'm not entirely sure of the
state of lldb on the platform).
We could make this more fine grained looking for the header as
we do for libcxx. This is a little tricky as there's no such
thing as /usr/include/c++/v1, but libstdcxx encodes the version
number in the path (i.e. /usr/include/c++/5.4). I guess we might
match a regex, but it seems fragile to me.

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

llvm-svn: 336724
2018-07-10 20:37:24 +00:00
Raphael Isemann 3a0e12700b Refactor parsing of option lists with a raw string suffix.
Summary:
A subset of the LLDB commands follows this command line interface style:
   <command name> [arguments] -- <string suffix>
The parsing code for this interface has been so far been duplicated into the different
command objects which makes it hard to maintain and reuse elsewhere.

This patches improves the situation by adding a OptionsWithRaw class that centralizes
the parsing logic and allows easier testing. The different commands now just call this class to
extract the arguments and the raw suffix from the provided user input.

Reviewers: jingham

Reviewed By: jingham

Subscribers: mgorny, lldb-commits

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

llvm-svn: 336723
2018-07-10 20:17:38 +00:00
Davide Italiano ec34220f5c Rollback [test-suite] Add a decorator for the lack of libstdcxx on the system.
Pavel suggested an alternative approach that I'll try to implement.

llvm-svn: 336608
2018-07-09 21:56:28 +00:00
Davide Italiano 0eddbf8f95 [ObjCRuntime] Add support for obfuscation in tagged pointers.
This is the default in MacOS Mojave. No testcases, as basically
we have a lot of coverage (and the testsuite fails quite a bit
without this change in Beta 3).

Thanks to Fred Riss for helping me with this patch (fixing
bugs/nondeterminism).

<rdar://problem/38305553>

llvm-svn: 336607
2018-07-09 21:53:43 +00:00
Raphael Isemann b69854f01c Don't take the address of an xvalue when printing an expr result
Summary:
If we have an xvalue here, we will always hit the `err_typecheck_invalid_lvalue_addrof` error
in 'Sema::CheckAddressOfOperand' when trying to take the address of the result. This patch
uses the fallback code path where we store the result in a local variable instead when we hit
this case.

Fixes rdar://problem/40613277

Reviewers: jingham, vsk

Reviewed By: vsk

Subscribers: vsk, friss, lldb-commits

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

llvm-svn: 336582
2018-07-09 18:57:11 +00:00
Stella Stamenova 67a19dfbcb Retrieve a function PDB symbol correctly from nested blocks
Summary:
This patch fixes a problem with retrieving a function symbol by an address in a nested block. In the current implementation of ResolveSymbolContext function it retrieves a symbol with PDB_SymType::None and then checks if found symbol's tag equals to PDB_SymType::Function. So, if nested block's symbol was found, ResolveSymbolContext does not resolve a function.

It is very simple to reproduce this. For example, in the next program

```
int main() {
  auto r = 0;
  for (auto i = 1; i <= 10; i++) {
    r += i & 1 + (i - 1) & 1 - 1;
  }

  return r;
}
```

if we will stop inside the cycle and will do a backtrace, the top element will be broken. But how we can test this? I thought to add an option to lldb-test to allow search a function by address, but the address may change when the compiler will be changed.

Patch by: Aleksandr Urakov

Reviewers: asmith, labath, zturner

Reviewed By: asmith, labath

Subscribers: stella.stamenova, llvm-commits

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

llvm-svn: 336564
2018-07-09 17:36:33 +00:00
Alexander Polyakov f906809496 Add LLDB_API to SBAddress's operator==.
Summary: Add LLDB_API to SBAddress's operator== to fix lldb-mi build on Windows.

Patch by Aleksandr Urakov!

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

llvm-svn: 336494
2018-07-07 18:54:44 +00:00
Tatyana Krasnukha 2bdcf581c1 Fix build on Windows with SDK build version >= 17134.
Platform.h doesn't define signal() and SIGINT since commit r263858. Code was compiled successfully because signal.h didn't have "ifndef" include guard in previous versions of Windows SDK. Now it does.

llvm-svn: 336483
2018-07-07 14:58:13 +00:00
Davide Italiano 975c711358 [test-suite] Add a decorator for the lack of libstdcxx on the system.
This generalizes a bunch of target-specific tests. MacOS has no
libstdcxx anymore, and neither does FreeBSD (or Windows).

<rdar://problem/41896105>

llvm-svn: 336463
2018-07-06 20:40:00 +00:00
Jim Ingham a5bdba4fa5 Remove a bunch more references to _LIBCPP_INLINE_VISIBILITY
and adjust the tests that needed it to set their breakpoints more robustly.

<rdar://problem/41867390>

llvm-svn: 336403
2018-07-06 00:16:21 +00:00
Jim Ingham 03856dd9c6 Address a few post facto review comments from Adrian.
Thanks, Adrian!

llvm-svn: 336398
2018-07-05 23:23:06 +00:00
Jim Ingham 9555351339 Don't muck with _LIBCPP_INLINE_VISIBILITY just to get predictable line table entries.
This test was trying to stop at a variety of std::vector calls.  It looks like the test
was failing because various inlined std functions left no line table entries for the line that
invoked the inlined function.  The author worked around that by undefining _LIBCPP_INLINE_VISIBILITY.

That's an internal libcxx macro, we really shouldn't be playing around with it.  Better to just force
ourselves to stop where we want using some other non-inlineable statement.  printf seems a good candidate...

<rdar://problem/41867390>

llvm-svn: 336397
2018-07-05 23:11:27 +00:00
Alex Langford bd09f772eb [CMake] Simplify a few framework build rules
llvm-svn: 336395
2018-07-05 22:16:15 +00:00
Raphael Isemann 22f5b9f124 Fixed redefinition warnings with LLVM_ENABLE_MODULES
Summary:
It seems we both have the HAVE_LIBCOMPRESSION define in the config header
and in the source files definitions of some files. This causes that the
Config.h header emits the following warning when we compile the Host module:

```
In file included from <module-includes>:21:
In file included from /Users/teemperor/llvm/llvm/tools/lldb/include/lldb/Host/MainLoop.h:13:
tools/lldb/include/lldb/Host/Config.h:33:9: warning: 'HAVE_LIBCOMPRESSION' macro redefined [-Wmacro-redefined]
        ^
<command line>:1:9: note: previous definition is here
        ^
```

It's not really clear why the define is in both places (the commit message
just says it fixes some unspecified bug), but we can easily work around this
by just guarding our define in Config.h.

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: mgorny, lldb-commits

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

llvm-svn: 336377
2018-07-05 17:12:11 +00:00
Jonas Devlieghere 12543bd023 [lit] Don't require semicolon separator
This patch removes the requirement for a semicolon as a separator when
passing arguments to lit. It relies on the shlex module that is part of
Python to do simple lexical analysis, similar to what happens in a Unix
shell.

llvm-svn: 336290
2018-07-04 17:14:52 +00:00
Dave Lee 8ab5c2db8a Fix and simplify lldb.command decorator
Summary:
This change fixes one issue with `lldb.command`, and also reduces the implementation.

The fix: a command function's docstring was not shown when running `help <command_name>`. This is because the docstring attached the source function is not propagated to the decorated function (`f.__call__`). By returning the original function, the docstring will be properly displayed by `help`.

Also with this change, the command name is assumed to be the function's name, but can still be explicitly defined as previously.

Additionally, the implementation was updated to:

* Remove inner class
* Remove use of `inspect` module
* Remove `*args` and `**kwargs`

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: keith, xiaobai, lldb-commits

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

llvm-svn: 336287
2018-07-04 16:11:43 +00:00
Jonas Devlieghere 441d289a5c [CMake] Remove redundant path component
Fixes spurious path component introduced in r336278. The variable is
cached so might require you to re-run CMake.

llvm-svn: 336279
2018-07-04 14:38:21 +00:00
Jonas Devlieghere cfc2377333 [CMake] Use LLVM_RUNTIME_OUTPUT_INTDIR for LLDB exectuable
Apparently there's a difference between using LLVM_RUNTIME_OUTPUT_INTDIR
and LLVM_BINARY_DIR. The former will point to the current binary
directory (i.e. that where lldb is built) while the former will always
point to LLVM's. This was causing trouble for the swift build but should
be a transparent for upstream lldb.

llvm-svn: 336278
2018-07-04 14:34:32 +00:00
Jonas Devlieghere 60cbbb4440 [CMake] Move some variables around
This improves consistency by creating a CMake variable for the dsymutil
path. The motivation is that for Swift, the dsymutil binary and the lldb
binary live in different directories and we need an option to configure
this from the build script.

llvm-svn: 336272
2018-07-04 13:59:25 +00:00
Alexander Polyakov 67cdc92d43 Ammend "Fix MSVC2015 compilation failure after r336206 patch".
llvm-svn: 336235
2018-07-03 22:51:01 +00:00
Alexander Polyakov 83e3ec5413 Fix MSVC2015 compilation failure after r336206 patch.
Added missing headers.

llvm-svn: 336212
2018-07-03 16:07:30 +00:00
Alexander Polyakov 8c670ec73f [lldb-mi] Re-implement symbol-list-lines command.
Summary: Now this command uses SB API instead of HandleCommand.

Reviewers: aprantl, clayborg

Reviewed By: aprantl, clayborg

Subscribers: ki.stfu, eraman, lldb-commits

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

llvm-svn: 336206
2018-07-03 15:40:20 +00:00
Alexander Polyakov da0c081f7e Add new API to SBTarget and SBModule classes.
Summary: The new API allows to find a list of compile units related to target/module.

Reviewers: aprantl, clayborg

Reviewed By: aprantl

Subscribers: jingham, lldb-commits

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

llvm-svn: 336200
2018-07-03 14:22:44 +00:00
Jason Molenda 6021469727 Re-sort the lldb.xcodeproj project file and commit the script
that I used to sort it to scripts/sort-pbxproj.rb.  It turns
out that Xcode will perturb the order of the file lists 
every time we add a file, following its own logic, and unfortunately
we'll still end up with lots of merge conflicts when that tries
to merge to the github swift repositories.  We talked this over
and we're going to keep it in a canonical state by running this
script over it when Xcode tries to reorder it.

llvm-svn: 336158
2018-07-03 00:43:57 +00:00
Alexander Polyakov fc018b071b [lldb-mi] Re-implement a few MI commands.
Summary: This patch updates exec-next-instruction, exec-step-instruction,
exec-finish, exec-interrupt commands to use SB API instead of HandleCommand.

Reviewers: aprantl, clayborg

Reviewed By: aprantl

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 336155
2018-07-02 23:54:06 +00:00
Raphael Isemann d4a1bd7d87 FIx XCode project files for lldb
Summary:
Fixes the XCode builds that started failing when i added CompletionRequest.cpp/.h.

The patch is so large because XCode decided to write the lines back in its own order, but essentially we only added on e file.

Subscribers: srhines, lldb-commits

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

llvm-svn: 336154
2018-07-02 23:27:29 +00:00
Raphael Isemann 9f02a94dad Fixed compilation failure after the code completion refactor patch
Subscribers: lldb-commits

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

llvm-svn: 336149
2018-07-02 22:18:18 +00:00
Stella Stamenova 696ce3770b [lldbsuite, windows] Don't crash LLDB when we try to retrieve a register on Windows
Summary:
1) When ReadRegister is called with a null register into on Windows, rather than crashing due to an access violation, simply return false. Not all registers and properties will be read or calculated correctly, but that is consistent with other platforms that also return false in that case
2) Update a couple of tests to reference pr37995 as their reason for failure since it is much more accurate. Support for floating point registers doesn't exist on Windows at all, rather than having issues.

Reviewers: asmith, labath, zturner

Subscribers: llvm-commits

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

llvm-svn: 336147
2018-07-02 21:50:31 +00:00
Raphael Isemann 2443bbd4aa Refactoring for for the internal command line completion API (NFC)
Summary:
This patch refactors the internal completion API. It now takes (as far as possible) a single
CompletionRequest object instead o half a dozen in/out/in-out parameters. The CompletionRequest
contains a common superset of the different parameters as far as it makes sense. This includes
the raw command line string and raw cursor position, which should make the `expr` command
possible to implement (at least without hacks that reconstruct the command line from the args).

This patch is not intended to change the observable behavior of lldb in any way. It's also as
minimal as possible and doesn't attempt to fix all the problems the API has.

Some Q&A:

Q: Why is this not fixing all the problems in the completion API?
A: Because is a blocker for the expr command completion which I want to get in ASAP. This is the
smallest patch that unblocks the expr completion patch and which allows trivial refactoring in the future.
The patch also doesn't really change the internal information flow in the API, so that hopefully
saves us from ever having to revert and resubmit this humongous patch.

Q: Can we merge all the copy-pasted code in the completion methods
(like computing the current incomplete arg) into CompletionRequest class?
A: Yes, but it's out of scope for this patch.

Q: Why the `word_complete = request.GetWordComplete(); ... ` pattern?
A: I don't want to add a getter that returns a reference to the internal integer. So we have
to use a temporary variable and the Getter/Setter instead. We don't throw exceptions
from what I can tell, so the behavior doesn't change.

Q: Why are we not owning the list of matches?
A: Because that's how the previous API works. But that should be fixed too (in another patch).

Q: Can we make the constructor simpler and compute some of the values from the plain command?
A: I think this works, but I rather want to have this in a follow up commit. Especially when making nested
request it's a bit awkward that the parsed arguments behave as both input/output (as we should in theory
propagate the changes on the nested request back to the parent request if we don't want to change the
behavior too much).

Q: Can't we pass one const request object and then just return another result object instead of mixing
them together in one in/out parameter?
A: It's hard to get keep the same behavior with that pattern, but I think we can also get a nice API with just
a single request object. If we make all input parameters read-only, we have a clear separation between what
is actually an input and what an output parameter (and hopefully we get rid of the in-out parameters).

Q: Can we throw out the 'match' variables that are not implemented according to the comment?
A: We currently just forward them as in the old code to the different methods, even though I think
they are really not used. We can easily remove and readd them once every single completion method just
takes a CompletionRequest, but for now I prefer NFC behavior from the perspective of the API user.

Reviewers: davide, jingham, labath

Reviewed By: jingham

Subscribers: mgorny, friss, lldb-commits

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

llvm-svn: 336146
2018-07-02 21:29:56 +00:00
Alexander Polyakov 4bbb820e22 [lldb-mi] Clean up and update a few MI commands.
Summary:
This patch updates a few MI commands using a new way of
handling an errors in lldb-mi and removes unnecessary
m_lldbResult variables.

Reviewers: aprantl, clayborg, labath

Reviewed By: aprantl, clayborg

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 336009
2018-06-29 19:58:31 +00:00
Pavel Labath 62a7f80af7 Add a test for reading lld-generated build-ids
Summary:
This test makes sure we are able to read the shorter build-ids which are
generated by lld.

To make this work, I've extended lldb-test to print the UUID of the
loaded object file. I've renamed the lldb-test subcommand from
"module-sections" to "object-file" to reflect the fact it prints more
than just the sections.

I've also added the module Architecture to the output, so we could avoid
printing the entire symbol file information just to get the ArchSpec
details in the lc_version_min test (which was also the only test in it's
folder not using the module-sections command).

Reviewers: aprantl, zturner

Subscribers: lldb-commits

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

llvm-svn: 335967
2018-06-29 12:15:54 +00:00
Pavel Labath 77c397f465 UUID: Add support for arbitrary-sized module IDs
Summary:
The data structure is optimized for the case where the UUID size is <=
20 bytes (standard length emitted by the GNU linkers), but larger sizes
are also possible.

I've modified the string conversion function to support the new sizes as
well. For standard UUIDs it maintains the traditional formatting
(4-2-2-2-6). If a UUID is shorter, we just cut this sequence short, and
for longer UUIDs it will just repeat the last 6-byte block as long as
necessary.

I've also modified ObjectFileELF to take advantage of the new UUIDs and
avoid manually padding the UUID to 16 bytes. While there, I also made
sure the computed UUID does not depend on host endianness.

Reviewers: clayborg, lemo, sas, davide, espindola

Subscribers: emaste, arichardson, lldb-commits

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

llvm-svn: 335963
2018-06-29 11:20:29 +00:00
Pavel Labath 88ec2e4ee7 Fix use-after-free in CommandCompletions.cpp
The code was creating a StringRef to a temporary std::string. The
solution is to just drop the .str() from the original StringRef.

This manifested it self as the new TestCompletions test failing in some
configurations.

llvm-svn: 335960
2018-06-29 10:27:18 +00:00
Pavel Labath 564a33a6e8 Fix TestLoadUsingPaths on linux
we need to explicitly link the test program with -ldl for the dlopen
function to be available.

llvm-svn: 335956
2018-06-29 09:22:07 +00:00
Pavel Labath e17e9579eb Modernize completion tests
Now that we have gmock, we can use its matchers to better express the
test assertions. The main advantage of this is that when things fail,
the test will now print the expected and actual lists of completed
strings instead of just a not-very-helpful "false is not true" message.

llvm-svn: 335955
2018-06-29 09:06:42 +00:00
Raphael Isemann 517c22041e Fix path completion test case added in rL335905 on Windows
Summary:
The test fails because we don't rewrite the slash behind `foo` to the OS specific
separator (as the completion API doesn't support this kind of rewriting). However,
we assume that this part of the string is rewritten in the test case, which broke
on Windows.

Reviewers: stella.stamenova

Reviewed By: stella.stamenova

Subscribers: lldb-commits

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

llvm-svn: 335934
2018-06-28 22:40:10 +00:00
Jim Ingham 0d231f7161 Add a way to load an image using a library name and list of paths.
This provides an efficient (at least on Posix platforms) way to offload to the
target process the search & loading of a library when all we have are the 
library name and a set of potential candidate locations.

<rdar://problem/40905971>

llvm-svn: 335912
2018-06-28 20:02:11 +00:00
Stella Stamenova aa6c3f50e3 [lldbsuite] Fix TestBreakpointHitCount on Windows
Summary: On Windows, the newer DIA SDKs end up producing function names that contain the return type as well. This means that the function name returned in the test will contain the return type (int) in addition to the name of the function and the type of the input (a(int)). To account for the possibility of both, the test should pass if the function name matches either pattern.

Reviewers: zturner, asmith

Subscribers: llvm-commits

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

llvm-svn: 335906
2018-06-28 19:42:30 +00:00
Raphael Isemann 2476374c61 Added test case for: r334978 - Fixed file completion for paths that start with '~'
Reviewers: labath

Reviewed By: labath

Subscribers: lldb-commits

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

llvm-svn: 335905
2018-06-28 19:34:49 +00:00
Pavel Labath abc0c6ad09 Skip core file tests on build configurations lacking necessary components
Summary:
To successfully open a core file, we need to have LLVM built with
support for the relevant target. Right now, if one does not have the
appropriate targets configured, the tests will fail.

This patch uses the GetBuildConfiguration SB API to inform the test (and
anyone else who cares) about the list of supported LLVM targets. The
test then uses this information to approriately skip the tests.

Reviewers: clayborg, jingham

Subscribers: martong, lldb-commits

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

llvm-svn: 335859
2018-06-28 14:23:04 +00:00
Pavel Labath 9ea80d259f Retrieve a function PDB symbol correctly from nested blocks
Summary:
This patch fixes a problem with retrieving a function symbol by an
address in a nested block. In the current implementation of
ResolveSymbolContext function it retrieves a symbol with
PDB_SymType::None and then checks if found symbol's tag equals to
PDB_SymType::Function. So, if nested block's symbol was found,
ResolveSymbolContext does not resolve a function.

Reviewers: asmith, labath, zturner

Reviewed By: asmith, labath

Differential Revision: https://reviews.llvm.org/D47939
Patch by Aleksandr Urakov <aleksandr.urakov@jetbrains.com>

llvm-svn: 335822
2018-06-28 10:03:42 +00:00
Jonas Devlieghere 8e93917e8d [SymbolFile] Implement GetCompleteObjCClass for .debug_names
When running the test suite with .debug_names a bunch of tests were
failing because GetCompleteObjCClass was not yet implemented for
DebugNamesDWARFIndex. This patch adds the required logic.

We use the .debug_names to find the Objective-C class and then rely on
DW_AT_APPLE_objc_complete_type to find the complete type. If we can't
find it or the attribute is not supported, we return a list of potential
complete types.

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

llvm-svn: 335776
2018-06-27 19:58:39 +00:00
Tatyana Krasnukha 3da0f21875 Add missing constness.
llvm-svn: 335711
2018-06-27 07:01:07 +00:00
Tatyana Krasnukha 9e1a117d4b Move AddressClass to private enums since API doesn't provide any functions to manage it.
This change allows to make AddressClass strongly typed enum and not to have issues with old versions of SWIG that don't support enum classes.

llvm-svn: 335710
2018-06-27 06:50:10 +00:00
Dave Lee 02a5191cda Fix a single typo in SBSymbolContext
Summary: Fix a "Manay" in SBSymbolContext.i

Reviewers: xiaobai

Reviewed By: xiaobai

Subscribers: lldb-commits

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

llvm-svn: 335709
2018-06-27 06:46:09 +00:00
Jim Ingham d7e126c491 Use the API's to get the TargetSP.
llvm-svn: 335690
2018-06-26 23:54:50 +00:00
Jim Ingham b87b9e6a83 The Process class ivar ivar was changed to a weak pointer, but was still _sp.
Fix that to _wp.

llvm-svn: 335689
2018-06-26 23:38:58 +00:00
Jim Ingham d6cbdc3767 This is not a debug info sensitive test.
llvm-svn: 335688
2018-06-26 23:31:44 +00:00
Jim Ingham 504be79168 Reverting r335656, SWIG doesn't like "enum class".
llvm-svn: 335659
2018-06-26 20:40:29 +00:00
Tatyana Krasnukha b76dcd17d1 Amend "Change AddressClass type from 'enum' to 'enum class'".
r335599 changes usages of AddressClass, but doesn't change the type itself.

llvm-svn: 335656
2018-06-26 20:08:05 +00:00
Pavel Labath 2f93fd1f50 Represent invalid UUIDs as UUIDs with length zero
Summary:
During the previous attempt to generalize the UUID class, it was
suggested that we represent invalid UUIDs as length zero (previously, we
used an all-zero UUID for that). This meant that some valid build-ids
could not be represented (it's possible however unlikely that a checksum of
some file would be zero) and complicated adding support for variable
length build-ids (should a 16-byte empty UUID compare equal to a 20-byte
empty UUID?).

This patch resolves these issues by introducing a canonical
representation for an invalid UUID. The slight complication here is that
some clients (MachO) actually use the all-zero notation to mean "no UUID
has been set". To keep this use case working (while making it very
explicit about which construction semantices are wanted), replaced the
UUID constructors and the SetBytes functions with named factory methods.
- "fromData" creates a UUID from the given data, and it treats all bytes
  equally.
- "fromOptionalData" first checks the data contents - if all bytes are
  zero, it treats this as an invalid/empty UUID.

Reviewers: clayborg, sas, lemo, davide, espindola

Subscribers: emaste, lldb-commits, arichardson

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

llvm-svn: 335612
2018-06-26 15:12:20 +00:00
Tatyana Krasnukha 04803b3ef2 Change AddressClass type from 'enum' to 'enum class'.
If we have a function with signature f(addr_t, AddressClass), it is easy to muddle up the order of arguments without any warnings from compiler. 'enum class' prevents passing integer in place of AddressClass and vice versa.

llvm-svn: 335599
2018-06-26 13:06:54 +00:00
Jason Molenda 32a914256e A little cleanup in ObjectFileMachO::GetSDKVersion.
This method does one of two things:

1. finds a minimum os deployment version # in a Mach-O load
command and saves the three parts in the m_sdk_version, or

2. finds no valid min os version # load command, pushes a 
sentinel value on the m_sdk_version vector so we don't search
the same load commands multiple times.

There was a little bug when we found a load command with 
a version of 0.0.0 - the method would not add anything to
the m_sdk_version vector but would declare that a success.
It would not push the sentinel value to the vector.
There was code later in the method which assumed that
the vector always had a sentinel value, at least, and that
code could crash when this method was called back when
evaluating a Swift expression.  (these version #'s are 
fetched lazily so it wouldn't happen when the object file
was parsed, only when doing an expression that needed
the version #).

<rdar://problem/41372699> 

llvm-svn: 335556
2018-06-25 23:45:39 +00:00
Alexander Polyakov 32447ff5b9 Fix windows build for r335541.
I didn't include <functional> header and used std::function.

llvm-svn: 335552
2018-06-25 23:29:52 +00:00
Alexander Polyakov 9bca7483a5 Implement new methods for handling an error in MI commands.
Summary:
The new methods take SBError object and call handler,
specified by user, depending on SBError status.

Reviewers: aprantl, clayborg, labath

Reviewed By: aprantl, clayborg

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 335541
2018-06-25 22:01:44 +00:00
David Carlier 1c79e4e959 [LLDB] Select helper sign comparison fix
The constant could be unsigned thus explicit cast to silent compilation warnings

Reviewers: aprantl

Reviewed By: aprantl

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

llvm-svn: 335489
2018-06-25 16:10:20 +00:00
Pavel Labath f104d6b224 Fix TestThreadExit for gcc&libc++ combo
pseudo_barrier_wait() begins by decrementing an atomic variable. Since
these are always_inline in libc++, there is no line table anchor to
break on before we decrement it. This meant that on gcc we stopped after
the variable has been decremented, which meant that thread2 could have
exited, violating the test setup. On clang this wasn't a problem
because it generated some line table entries for the do{}while(0) loop
in the macro, so we still ended up stopping, before we touched the
variable.

I fix this by adding a dummy statement before the pseudo_barrier_wait()
command and setting the breakpoint there.

llvm-svn: 335476
2018-06-25 14:28:38 +00:00
Jonas Devlieghere c1cc3173d3 Revert "[FileSpec] Always normalize"
This reverts r335432 because remove_dots() is expensive and measuring
its impact showed an observable performance regression
(https://reviews.llvm.org/D45977#1078510).

llvm-svn: 335448
2018-06-25 10:11:53 +00:00
Jonas Devlieghere 4c92584eb2 [FileSpec] Always normalize
Removing redundant components from the path seems pretty harmless.
Rather than checking whether this is necessary and then actually doing
so, always invoke remove_dots to start with a normalized path.

llvm-svn: 335432
2018-06-24 13:31:44 +00:00
Jan Kratochvil 8fbb1fc229 Make testcase classnames unique
Filenames with test results contain only the class name which makes it more
difficult to find it if the same class name is present in multiple *.py files.

packages/Python/lldbsuite/test/functionalities/step-avoids-no-debug/TestStepNoDebug.py
-class ReturnValueTestCase(TestBase):
+class StepAvoidsNoDebugTestCase(TestBase):
as ReturnValueTestCase is already present in:
packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py

packages/Python/lldbsuite/test/functionalities/thread/crash_during_step/TestCrashDuringStep.py
-class CreateDuringStepTestCase(TestBase):
+class CrashDuringStepTestCase(TestBase):
as CreateDuringStepTestCase is already present in:
packages/Python/lldbsuite/test/functionalities/thread/create_during_step/TestCreateDuringStep.py

packages/Python/lldbsuite/test/functionalities/thread/step_until/TestStepUntil.py
-class TestCStepping(TestBase):
+class StepUntilTestCase(TestBase):
as TestCStepping is already present in:
packages/Python/lldbsuite/test/lang/c/stepping/TestStepAndBreakpoints.py

llvm-svn: 335431
2018-06-24 10:36:44 +00:00
Jonas Devlieghere 24bd63c462 [FileSpec] Refactor append and prepend implemenetations. NFC
Replaces custom implementations of append and prepend with calls to
llvm's path library. This is part of a series of patches (started in
D48084) to delegate common operations to llvm::sys::path.

llvm-svn: 335430
2018-06-24 10:18:01 +00:00
Greg Clayton ef115de629 Update cmdtemplate.py to use best pratices.
Fixes include:
- fix all lint errors
- add code that will automatically register and LLDB command classes by detecting the classes and any classes that have a "register_lldb_command" function
  - automatically fill in the correct module name when registering commands
  - automatically fill in the class name when registering command

llvm-svn: 335401
2018-06-22 23:34:24 +00:00
Adrian Prantl 56a196c020 Mark this test as no debuginfo
llvm-svn: 335386
2018-06-22 20:26:53 +00:00
Pavel Labath 733ad45b9f Android.rules: Use libc++ by default
libstdc++ will soon be dropped from the android NDK. This patch makes
sure we are prepared for that by using libc++ in tests by default (i.e.,
except for libstdc++ data formatter tests).

Only a couple of small tweaks were needed to make this work:
- Add the libc++ include paths to CXXFLAGS only. This was necessary to
  make the tests compile with -fmodules. The modules tests have been
  disabled, but this way, they will be ready for them if they are
  enabled.
- in one test I had to add an explicit std::string copy to make sure the
  copy constructor is there for the expression evaluator to find it.

llvm-svn: 335344
2018-06-22 13:13:29 +00:00
Tatyana Krasnukha a0fa299d68 ResolveAddress: check returned value of resolving functions.
llvm-svn: 335341
2018-06-22 12:24:57 +00:00
Frederic Riss adc94a8846 Remove dead code
Our DWARF parsing code had a workaorund for Objective-C "self" not
being marked as artifial by the compiler. Clang has been doing this
since 2010, so let's just drop the workaround.

llvm-svn: 335313
2018-06-22 00:22:50 +00:00
Tatyana Krasnukha be73fd6b5d Remove duplicated check and shared_ptr copying.
llvm-svn: 335273
2018-06-21 19:19:57 +00:00
Jonas Devlieghere 702e140d68 [DataFormatter] Add CFDictionary data formatter
Add data formatter for NSCFDictionary/CFDictionaryRef.

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

llvm-svn: 335271
2018-06-21 19:13:47 +00:00
Greg Clayton 59a1be3acf Fix an issue where DW_OP_deref might be dereferencing a file address. Convert the file address to a load address so this works.
https://bugs.llvm.org/show_bug.cgi?id=36871

llvm-svn: 335263
2018-06-21 17:58:06 +00:00
Pavel Labath d68983e3d5 Partially revert r335236
Jim pointed out that XCode has build configurations that build without
python and removing the ifdefs around the python code breaks them.

This reverts the #ifdef part of the above patch, while keeping the cmake
parts.

llvm-svn: 335260
2018-06-21 17:36:32 +00:00
Pavel Labath 9092cc96d4 Fix macos build for r335244
I've made the code accept only 16 byte UUIDs, which is technically not
NFC (previously it would also accept 20 byte ones, but use only the
first 16 bytes), but this should be more correct as mac UUIDs are always
16 byte long.

llvm-svn: 335247
2018-06-21 15:40:33 +00:00
Pavel Labath a174bcbf03 Remove UUID::SetFromCString
Replace uses with SetFromStringRef. NFC.

llvm-svn: 335246
2018-06-21 15:24:39 +00:00
Pavel Labath 470b286ee5 Modernize UUID class
Instead of a separate GetBytes + GetByteSize methods I introduce a
single GetBytes method returning an ArrayRef.

This is NFC cleanup now, but it should make handling arbitrarily-sized
UUIDs cleaner, should we choose to go that way. I also took the
opportunity to add some unit tests for this class.

llvm-svn: 335244
2018-06-21 15:07:43 +00:00
Pavel Labath bcadb5a3d1 ScriptInterpreterPython cleanup
Instead of #ifdef-ing the contents of all files in the plugin for all
non-python builds, just disable the plugin at the cmake level. Also,
remove spurious extra linking of the Python plugin in liblldb. This
plugin is already included as a part of LLDB_ALL_PLUGINS variable.

llvm-svn: 335236
2018-06-21 14:09:15 +00:00
Pavel Labath 30f2e61b97 Disable gmodules tests on linux
These tests are extremely environment-dependent. if the environment is
not module-enabled (which is the likely scenario), they won't test
anything. If one happens to have a module-enabled libc++, then the he
will start running into problems.

The first one is that the debug info in pcm file contains relocations
that ObjectFileELF doesn't handle (particularly on non-x86
architectures), but even after that is resolved, it seems we still are
unable to pull debug info out of the pcm file. I've filed pr37893 to
track that, and I am disabling gmodules tests on linux until these
issues are resolved.

llvm-svn: 335235
2018-06-21 13:55:19 +00:00
Alexander Polyakov 859f54b3f8 Improve SBThread's stepping API using SBError parameter.
Summary: The new methods will allow to get error messages from stepping API.

Reviewers: aprantl, clayborg, labath, jingham

Reviewed By: aprantl, clayborg, jingham

Subscribers: apolyakov, labath, jingham, clayborg, lemo, lldb-commits

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

llvm-svn: 335180
2018-06-20 21:43:16 +00:00
Pavel Labath fbb142852c Remove some instances of manual UUID pretty-printing
Identical functionality is already offered by the UUID::getAsString
method.

llvm-svn: 335163
2018-06-20 20:13:04 +00:00
Pavel Labath 0583d7a56c Make test sources compatible with android+libcxx+modules
In a modules build, android is very picky about which symbols are
visible after including libc++ headers (e.g. <cstdio> defines only
std::printf and not ::printf).

This consolidates the tests where this was an issue to always include
the <c???> version of the headers and prefixes the symbols with std:: as
necessary.

Apart from that, there is no functional change in the tests.

llvm-svn: 335149
2018-06-20 17:32:48 +00:00
Pavel Labath 13c07c62d1 Make sure TestNumThreads works with libc++
The problem was that with libc++ the std::unique_lock declaration was
completely inlined, so there was no line table entry in the main.cpp
file to set a breakpoint on. Therefore, the breakpoint got moved to the
next line, but that meant the test would deadlock as the thread would
stop with the lock already held.

I fix that issue by adding a dummy statement before the std::unique_lock
line to anchor the breakpoint.

I think this should fix the issue because of which this test was
disabled on darwin, but someone should verify that before enabling it.

llvm-svn: 335132
2018-06-20 14:54:34 +00:00
Pavel Labath c7c9d76187 IRInterpreter: fix sign extension of small types (pr37840)
Sign-extension of small types (e.g. short) was not handled correctly.
The reason for that was that when we were assigning the a value to the
Scalar object, we would accidentally promote the type to int (even
though the assignment code in AssignTypeToMatch tried to cast the value
to the appropriate type, it would still invoke the "int" version of
operator=). Instead, I use the APInt version of operator=, where the
bitwidth is specified explicitly. Among other things, this allows us to
fold the individual size cases into one.

llvm-svn: 335114
2018-06-20 10:45:29 +00:00
Pavel Labath 031c748bdb Fix compilation with mingw-w64 (pr37873)
llvm-svn: 335112
2018-06-20 09:53:30 +00:00
Pavel Labath af8b24fa41 Fix windows build broken by r335104
lldb-python.h needs to be included first to work around some
incompatibilities between windows and python headers.

llvm-svn: 335106
2018-06-20 09:00:30 +00:00
Pavel Labath 2df331b0f7 Remove dependency from Host to python
Summary:
The only reason python was used in the Host module was to compute the
python path. I resolve this the same way as D47384 did for clang, by
moving the path computation into the python plugin and modifying
SBHostOS class to call into this module for ePathTypePythonDir.

Reviewers: zturner, jingham, davide

Subscribers: mgorny, lldb-commits

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

llvm-svn: 335104
2018-06-20 08:35:45 +00:00
Pavel Labath 16662f3c6e BreakpointIDList: Use llvm::ArrayRef instead of pointer+length pair
NFC

llvm-svn: 335102
2018-06-20 08:12:50 +00:00
Jason Molenda 85afc93f8a Correct the pathname that PlatformDarwinKernel::ExamineKextForMatchingUUID
passes to the recursive search function so we only recursively
search the kext bundle directory, instead of its parent directory.

<rdar://problem/41227170> 

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

llvm-svn: 335079
2018-06-19 21:39:10 +00:00
Raphael Isemann 1246890964 Refactor OnExit utility class in ClangUserExpression
Summary:
OnExit ensures we call `ResetDeclMap` before this method ends. However,
we also have a few manual calls to ResetDeclMap in there that are actually unnecessary
because of this (calling the method multiple times has no effect). This patch also moves
the class out of the method that we can reuse it for the upcoming method that handles
parsing for completion.

Subscribers: lldb-commits

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

llvm-svn: 335078
2018-06-19 21:25:59 +00:00
Pavel Labath 61547259de Scalar: Use llvm integer conversion functions
StringConvert was the only non-Utility dependency of this class. Getting
rid of it means it will be easy to move this class to a lower layer.

While I was in there, I also added a couple of unit tests for the Scalar
string conversion function.

llvm-svn: 335060
2018-06-19 17:24:03 +00:00
Pavel Labath 60f028ff03 Replace HostInfo::GetLLDBPath with specific functions
Summary:
Instead of a function taking an enum value determining which path to
return, we now have a suite of functions, each returning a single path
kind. This makes it easy to move the python-path function into a
specific plugin in a follow-up commit.

All the users of GetLLDBPath were converted to call specific functions
instead. Most of them were hard-coding the enum value anyway, so this
conversion was simple. The only exception was SBHostOS, which I've
changed to use a switch on the incoming enum value.

Reviewers: clayborg, zturner

Subscribers: lldb-commits

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

llvm-svn: 335052
2018-06-19 15:09:07 +00:00
Pavel Labath 7bbedb8023 Make TestCommandScript.py NO_DEBUG_INFO_TESTCASE
llvm-svn: 335051
2018-06-19 15:07:22 +00:00
Pavel Labath 8779968805 Attempt to fix windows build broken by r334968
The issue was that there was no dependency from lldb-suite target to liblldb in
the no-framework scenario. This caused the finish-swig target to be executed
prematurely and fail (because it cannot copy liblldb to the python folder). On
other platforms this did not matter because there just creates a symlink.

The extra lldb-suite -> liblldb edge should fix this. Technically, I could add
this just to the !framework case as the framework target will take care of the
transitive dep, but it seemed more clear to make the dep unconditional.

llvm-svn: 335047
2018-06-19 14:23:31 +00:00
Alex Langford f66a36d2dc Fix up Info.plist when building LLDB.framework with CMake
Summary:
We weren't using the Info.plist template in resources previously.
When using that template, some of the key's values weren't being populated
because some variables were not being defined. In one case, CMake didn't
like the substring expansion syntax of CFBundleIdentifier so I got rid of that.

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

llvm-svn: 335014
2018-06-19 02:59:30 +00:00
Jason Molenda 87f0f95e4c Some NFC changes to how we scan of kexts & kernels in memory in the
DynamicLoaderDarwinKernel plugin.  Created a new function ReadMachHeader
and instead of reading through the target cached memory reader,
start by reading only a mach header sized chunk of memory, then
check it for a valid mach-o magic # and use the size of the load
commands to pre-fetch the entire load commands of the kext which
is the only thing we're going to read, instead of letting the generic
mach-o parser read it in 512 byte chunks.

Functionally this is doing exactly the same thing as before, but by
cutting down on the # of packets going back and forth, even on a 
local connection it's close to a quarter faster than it was before.

<rdar://problem/38570146> 

llvm-svn: 334995
2018-06-18 23:30:03 +00:00
Raphael Isemann 4621e0b058 Fixed file completion for paths that start with '~'.
We didn't add the remaining path behind the '~' to the completion string,
causing it to just complete directories inside the user home directory. This
patch just adds the directory of the remaining path if there is one.

Fixes rdar://problem/40147002

llvm-svn: 334978
2018-06-18 20:11:38 +00:00
Alex Langford 27510c18ad Introduce lldb-framework CMake target and centralize its logic
Summary:
In this patch I aim to do the following:

1) Create an lldb-framework target that acts as the target that handles generating LLDB.framework. Previously, liblldb acted as the target for generating the framework in addition to generating the actual lldb library. This made the target feel overloaded.
2) Centralize framework generation as much as it makes sense to do so.
3) Create a target lldb-suite, which depends on every tool and library that makes liblldb fully functional. One result of having this target is it makes tracking dependencies much clearer.

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

llvm-svn: 334968
2018-06-18 18:27:16 +00:00
Pavel Labath 6682979c04 Fix macosx build broken by the VersionTuple refactor
I actually did check that macos builds before committing, but this error
was in conditionally compiled code that did not seem to be used on my
machine.

I also fix a typo in the previous speculative NetBSD patch.

llvm-svn: 334955
2018-06-18 16:10:20 +00:00
Pavel Labath 76ba497177 Fix netbsd build broken by r334950
This also includes one more build fix for windows.

llvm-svn: 334953
2018-06-18 15:44:36 +00:00
Pavel Labath 9d4758ecdd Attempt to fix windows&freebsd builds broken by r334950
llvm-svn: 334952
2018-06-18 15:29:42 +00:00
Pavel Labath 2272c4811f Use llvm::VersionTuple instead of manual version marshalling
Summary:
This has multiple advantages:
- we need only one function argument/instance variable instead of three
- no need to default initialize variables
- no custom parsing code
- VersionTuple has comparison operators, which makes version comparisons much
  simpler

Reviewers: zturner, friss, clayborg, jingham

Subscribers: emaste, lldb-commits

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

llvm-svn: 334950
2018-06-18 15:02:23 +00:00
Frederic Riss 49c9d8b849 Fix the 'tb' alias command
No idea when this broke or if it ever worked. Added a small test
for one-shot breakpoints while I was there.

llvm-svn: 334921
2018-06-18 04:34:33 +00:00
Jason Molenda 94405ddb95 Sort the files in the PBXBuildFile and PBXFileReference sections
of debugserver's xcode project file to reduce automerger issues
with the github swift repository of lldb where the order of these
entries has drifted significantly over the years.

llvm-svn: 334873
2018-06-15 23:32:37 +00:00
Jason Molenda 6d722ca828 Sort the files in the PBXBuildFile and PBXFileReference
sections of lldb's xcode project file to reduce automerger
issues with the github swift repository of lldb where 
the order of these entries has drifted significantly
over the years.

llvm-svn: 334872
2018-06-15 23:29:32 +00:00
Frederic Riss ecba8846aa Fix TestExec after r334783
The second makefile that was added has implicit rules which meant
that secondprog.cpp would be built once into a secondprog binary,
but it would also be compiled as a.out overwriting the main binary.
This lead to spurious failures.

This commit simplifies the Makefile to build only once with the correct
executable name.

llvm-svn: 334861
2018-06-15 20:36:03 +00:00