Commit Graph

17458 Commits

Author SHA1 Message Date
Pavel Labath 3ca31ba75a AppleDWARFIndex: Get function method-ness directly from debug info
Summary:
When searching for methods only, we need to do extra work to make sure
the functions we get from the apple tables are indeed methods.
Previously we were resolving the DIE into a SymbolContext and then
checked whether the enclosing CompilerDeclContext is a
class (or struct, or union).

This patch changes that to operate on the debug info directly. This
should be:
- simpler
- faster
- more consistent with the ManualDWARFIndex (which does the same check,
  only at indexing time).

What we lose this ways is for the language plugin to have a say in what
it considers to be a "class", but that's probably more flexibility than
we need (and if we really wanted to do that in the future, we could
implement a more direct way to consult the plugin about this).

This also fixes the find-method-local-struct test, which was failing
because we were not able to construct a CompilerDeclContext for a local
struct correctly.

As a drive-by, I rename the DWARFDIE's IsStructClassOrUnion method to
match the name on the CompilerDeclContext class.

Reviewers: clayborg, JDevlieghere

Subscribers: aprantl, lldb-commits

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

llvm-svn: 333878
2018-06-04 09:05:27 +00:00
Saleem Abdulrasool 23d66ae1e4 Python: adjust the include directories
Restructure the include search order to adjust for libedit.  This
ensures that the variables are not unused if they are not defined.

llvm-svn: 333863
2018-06-04 02:08:12 +00:00
Alexander Polyakov cc92f5038e [lldb, lldm-mi] Fix hanging of -exec-run command.
Summary: -exec-run command hanged in case of invalid or dummy target.

Reviewers: aprantl, stella.stamenova

Reviewed By: aprantl

Subscribers: ki.stfu, llvm-commits, lldb-commits

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

llvm-svn: 333844
2018-06-03 15:15:23 +00:00
Alexander Polyakov 2c5a424150 Test commit. Fix typo in comment.
llvm-svn: 333837
2018-06-03 12:41:00 +00:00
James Y Knight 7177528783 Fix silly error introduced after testing in r333813.
Oops.

llvm-svn: 333816
2018-06-02 04:00:16 +00:00
James Y Knight 9c2d52014c Fix support for distinguishing archive members by timestamp on Darwin.
On Darwin, the binary's symbol table points to debug info in object
files -- potentially object files within a static library. Such a
library may have multiple entries with the same name, distinguished
only by timestamp.

The code was already _attempting_ to handle this case (see the code in
ObjectContainerBSDArchive::Archive::FindObject which disambiguates via
timestamp). But, unfortunately, while the timestamp was taken into
account on the _first_ lookup, the result was then cached in a map
keyed only off of the path.

Added the timestamp to the cache, and added a test case.

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

llvm-svn: 333813
2018-06-02 02:44:10 +00:00
Stella Stamenova b8d861c27a [lit, pdb] Fix two failing PDB tests on Windows
Summary: One of the tests is failing to build because it needs GS-, the second test does not correctly match all the expected function names because newer DIA SDKs annotate the function names with their return type and inputs (e.g. "static long `anonymous namespace'::StaticFunction(int)")

Reviewers: asmith, zturner

Reviewed By: zturner

Subscribers: llvm-commits

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

llvm-svn: 333790
2018-06-01 21:33:27 +00:00
Stella Stamenova 1263949d40 [lit, lldbmi] Skip the new break-insert test on Windows
Summary: Skip the new break-insert test on Windows because it hangs and so the test suite never completes. All other lldb-mi tests in the test suite are also skipped on windows

Reviewers: asmith, aprantl, polyakov.alex

Reviewed By: aprantl

Subscribers: ki.stfu, llvm-commits

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

llvm-svn: 333789
2018-06-01 21:29:43 +00:00
Vedant Kumar 350214674b XFAIL TestIRMemoryMap.test on Windows
I've xfailed this test instead of skipping it by request
(https://reviews.llvm.org/D47646).

Bug: https://bugs.llvm.org/show_bug.cgi?id=37656
llvm-svn: 333787
2018-06-01 20:32:32 +00:00
Frederic Riss 9cd4def1c6 Fix Module::FindTypes to return the correct number of matches.
In r331719, I changed Module::FindTypes not to limit the amount
of types returned by the Symbol provider, because we want all
possible matches to be able to filter them. In one code path,
the filtering was applied to the TypeList without changing the
number of types that gets returned. This is turn could cause
consumers to access beyond the end of the TypeList.

This patch fixes this case and also adds an assertion to
TypeList::GetTypeAtIndex to catch those obvious programming
mistakes.

Triggering the condition in which we performed the incorrect
access was not easy. It happened a lot in mixed Swift/ObjectiveC
code, but I was able to trigger it in pure Objective C++ although
in a contrieved way.

rdar://problem/40254997

llvm-svn: 333786
2018-06-01 20:14:21 +00:00
Vedant Kumar 1943b49c99 Disable TestIRMemoryMap.test on Windows
It's been pointed out in https://reviews.llvm.org/D47646 that lldb-test
fails to create a usable process on Windows when running this test.

llvm-svn: 333785
2018-06-01 20:02:57 +00:00
Stella Stamenova 36d457c20d [lldb, process] Fix occasional hang when launching a process in LLDB
Summary:
Occasionally, when launching a process in lldb (especially on windows, but not limited to), lldb will hang before the process is launched and it will never recover. This happens because the timing of the processing of the state changes can be slightly different. The state changes that are issued are:

1) SetPublicState(eStateLaunching)
2) SetPrivateState(eStateLaunching)
3) SetPublicState(eStateStopped)
4) SetPrivateState(eStateStopped)

What we expect to see is:
public state: launching -> launching -> stopped
private state: launching -> stopped

What we see is:
public state: launching -> stopped -> launching
private state: launching -> stopped

The second launching change to the public state is issued when WaitForProcessStopPrivate calls HandlePrivateEvent on the event which was created when the private state was set to launching. HandlePrivateEvent has logic to determine whether to broadcase the event and a launching event is *always* broadcast. At the same time, when the stopped event is processed by WaitForProcessStopPrivate next, the function exists and that event is never broadcast, so the public state remains as launching.

HandlePrivateEvent does two things: determine whether there's a next action as well as determine whether to broadcast the event that was processed. There's only ever a next action set if we are trying to attach to a process, but WaitForProcessStopPrivate is only ever called when we are launching a process or connecting remotely, so the first part of HandlePrivateEvent (handling the next action) is irrelevant for WaitForProcessStopPrivate. As far as broadcasting the event is concerned, since we are handling state changes that already occurred to the public state (and are now duplicated in the private state), I believe the broadcast step is unnecessary also (and in fact, it causes the hang).

This change removes the call to HandlePrivateEvent from inside WaitForProcessStopPrivate.

Incidentally, there was also a bug filed recently that is the same issue: https://bugs.llvm.org/show_bug.cgi?id=37496

Reviewers: asmith, labath, zturner, jingham

Reviewed By: zturner, jingham

Subscribers: llvm-commits

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

llvm-svn: 333781
2018-06-01 19:14:53 +00:00
Alex Langford 4cb54e96f9 Add dependency on clang-headers when building LLDB.framework using CMake
Summary:
The LLDB.framework generated when building with CMake + Ninja/Make is
completely missing the clang headers. Although the code to copy them exists, we
don't even generate them unless we're building LLDB standalone.

Reviewers: clayborg, labath, sas

Subscribers: mgorny, lldb-commits

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

llvm-svn: 333777
2018-06-01 18:14:49 +00:00
Pavel Labath a041d8483c Add .debug_names section glue code
llvm-svn: 333743
2018-06-01 12:06:45 +00:00
Vedant Kumar 38671237a6 [lit] Remove the *.test suffix from two test inputs
This prevents the test inputs from being marked as unsupported tests,
due to their lack of RUN lines.

llvm-svn: 333701
2018-05-31 22:09:01 +00:00
Vedant Kumar cc5a6163a4 [IRMemoryMap] Test interleaved Mallocs and Frees
This adds a new command to the ir-memory-map tester:

  free <allocation-index>

The argument to free is an index which identifies which live allocation
to free. Index 0 identifies the first live allocation in the address
space, index 1 identifies the second, etc. where the allocations are
sorted in increasing order.

For illustrative purposes, assume malloc returns monotonically
increasing addresses. Here are some examples of how free would work:

Example 1
---------

malloc 16 1
malloc 32 1
free 1      //< Free the 32-byte allocation.
free 0      //< Next, free the 16-byte allocation.

Example 2
---------

malloc 16 1
malloc 32 1
free 0      //< Free the 16-byte allocation.
free 0      //< Next, free the 32-byte allocation.

llvm-svn: 333700
2018-05-31 22:09:01 +00:00
Vedant Kumar 7e4c84a78c [lldb-test] Make logging available to all subcommands
llvm-svn: 333699
2018-05-31 22:09:00 +00:00
Vedant Kumar f616b9db7d [IRMemoryMap] Test host-side allocations
r333583 introduced testing for IRMemoryMap's process-side allocations
(eAllocationPolicyProcessOnly). This adds support for the host-side
variety (eAllocationPolicyHostOnly).

llvm-svn: 333698
2018-05-31 22:09:00 +00:00
Vedant Kumar 5b71e75ed3 [IRMemoryMap] Fix the alignment adjustment in Malloc
This prevents Malloc from allocating the same chunk of memory twice, as
a byproduct of an alignment adjustment which gave the client access to
unallocated memory.

Prior to this patch, the newly-added test failed with:

$ lldb-test ir-memory-map ... ir-memory-map-overlap1.test
...
Command: malloc(size=64, alignment=32)
Malloc: address = 0x1000cd080
Command: malloc(size=64, alignment=8)
Malloc: address = 0x1000cd0b0
Malloc error: overlapping allocation detected, previous allocation at [0x1000cd080, 0x1000cd0c0)

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

llvm-svn: 333697
2018-05-31 22:08:59 +00:00
Jason Molenda a6922415b1 Set m_struct_valid to initial value in ctor.
Patch from Tom Tromey <ttromey@mozilla.com>.

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

llvm-svn: 333690
2018-05-31 20:01:15 +00:00
Jonas Devlieghere f0f53b86d9 Remove infinite recursion due to FileSpec change.
Fixes infinite recursion due to change in how FileSpec deals with
removing the last path component.

Fixes timout for TestMiniDumpNew.py

llvm-svn: 333666
2018-05-31 16:28:29 +00:00
Pavel Labath 0f11db359d Remove the TestSequenceFunctions "example" test
This test was using unittest (not unittest2) as the test framework, and
it worked with dotest only by accident. Remove it as we have a much more
realistic example test in test/testcases/sample_test.

llvm-svn: 333640
2018-05-31 09:56:38 +00:00
Pavel Labath 34cda14b09 Remove append parameter to FindGlobalVariables
Summary:
As discussed in https://bugs.llvm.org/show_bug.cgi?id=37317,
FindGlobalVariables does not properly handle the case where
append=false.  As this doesn't seem to be used in the tree, this patch
removes the parameter entirely.

Reviewers: clayborg, jingham, labath

Reviewed By: clayborg

Subscribers: aprantl, lldb-commits, kubamracek, JDevlieghere

Differential Revision: https://reviews.llvm.org/D46885
Patch by Tom Tromey <ttromey@mozilla.com>.

llvm-svn: 333639
2018-05-31 09:46:26 +00:00
Jan Kratochvil a375349c53 Simplify DWARFUnit::m_die_array swap() to use shrink_to_fit()
rL145086 introduced m_die_array.shrink_to_fit() implemented by
exact_size_die_array.swap, it was before LLVM became written in C++11.

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

llvm-svn: 333636
2018-05-31 08:55:40 +00:00
Vedant Kumar f3b6d2930d [lldb-test] ir-memory-map: Avoid accessing a bad iterator
Do not access Probe.start() when Probe is at the end of the interval
map.

llvm-svn: 333585
2018-05-30 19:46:47 +00:00
Vedant Kumar c1cd826248 [lldb-test] Add a testing harness for the JIT's IRMemoryMap
This teaches lldb-test how to launch a process, set up an IRMemoryMap,
and issue memory allocations in the target process through the map. This
makes it possible to test IRMemoryMap in a targeted way.

This has uncovered two bugs so far. The first bug is that Malloc
performs an adjustment on the pointer returned from AllocateMemory (for
alignment purposes) which ultimately allows overlapping memory regions
to be created. The second bug is that after most of the address space on
the host side is exhausted, Malloc may return the same address multiple
times. These bugs (and hopefully more!) can be uncovered and tested for
with targeted lldb-test commands.

At an even higher level, the motivation for addressing these bugs is
that they can lead to strange user-visible failures (e.g, variables
assume the wrong value during expression evaluation, or the debugger
crashes). See my third comment on this swift-lldb PR for an example:

https://github.com/apple/swift-lldb/pull/652

I hope lldb-test is the right place to add this testing harness. Setting
up a gtest-style unit test proved too cumbersome (you need to recreate
or mock way too much debugger state), as did writing end-to-end tests
(it's hard to write a test that actually hits a buggy path).

With lldb-test, it's easy to read/generate the test input and parse the
test output. I'll attach a simple "fuzz" tester which generates failing
test cases to the Phab review. Here's an example:

```
Command: malloc(size=1024, alignment=32)
Malloc: address = 0xca000
Command: malloc(size=64, alignment=16)
Malloc: address = 0xca400
Command: malloc(size=1024, alignment=16)
Malloc: address = 0xca440
Command: malloc(size=16, alignment=8)
Malloc: address = 0xca840
Command: malloc(size=2048, alignment=16)
Malloc: address = 0xcb000
Command: malloc(size=64, alignment=32)
Malloc: address = 0xca860
Command: malloc(size=1024, alignment=16)
Malloc: address = 0xca890
Malloc error: overlapping allocation detected, previous allocation at [0xca860, 0xca8a0)
```

{F6288839}

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

llvm-svn: 333583
2018-05-30 19:39:10 +00:00
Tim Shen 761abc05aa [LLDB] Re-apply r303907 that's reverted by mistake
llvm-svn: 333552
2018-05-30 14:54:22 +00:00
Jonas Devlieghere df8e291ef9 [FileSpec] Re-implmenet removeLastPathComponent
When reading DBGSourcePathRemapping from a dSYM, we remove the last two
path components to make the source lookup more general. However, when
dealing with a relative path that has less than 2 components, we ended
up with an invalid (empty) FileSpec.

This patch changes the behavior of removeLastPathComponent to remove the
last path component, if possible. It does this by checking whether a
parent path exists, and if so using that as the new path. We rely
entirely on LLVM's path implementation to do the heavy lifting.

We now also return a boolean which indicates whether the operator was
successful or not.

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

rdar://37791687

llvm-svn: 333540
2018-05-30 13:03:16 +00:00
Pavel Labath 7a350207ae @skipUnlessDarwin TestOrderedSet
llvm-svn: 333526
2018-05-30 10:04:32 +00:00
Jan Kratochvil f426fc7000 Fix return value of DWARFUnit::ExtractDIEsIfNeeded()
This is a leftover regression from: https://reviews.llvm.org/D46810

llvm-svn: 333517
2018-05-30 08:54:46 +00:00
Tim Shen 54132d6c9f [LLDB] Revert r303907.
See https://reviews.llvm.org/rL303907 for details about the bug.

llvm-svn: 333478
2018-05-29 23:27:26 +00:00
Davide Italiano 6592c7c921 [ObjC] Add a Makefile for the test added in r333465.
Not strictly necessary, but makes the test more robust in case
we end up changing the defaults.

<rdar://problem/40622096>

llvm-svn: 333466
2018-05-29 22:20:05 +00:00
Davide Italiano d9b9c919bc [ObjC] Fix the formatter for NSOrderedSet.
While I'm here, delete some dead code.

<rdar://problem/40622096>

llvm-svn: 333465
2018-05-29 22:08:07 +00:00
Jan Kratochvil a3ad3c4839 Remove unused DWARFUnit::HasDIEsParsed()
It was not implemented correctly after https://reviews.llvm.org/D46810 but then
it has not been used anywhere anyway.

llvm-svn: 333452
2018-05-29 19:14:46 +00:00
Jan Kratochvil 43b40939fb Fix compiler unused variable warning in DWARFUnit
Alex Langford has reported it from: https://reviews.llvm.org/D46810

llvm-svn: 333449
2018-05-29 18:53:25 +00:00
Alex Langford 47039c460a Remove lldb-private headers when building LLDB.framework with CMake
Summary:
Generating LLDB.framework when building with CMake+Ninja will copy the
lldb-private headers because public_headers contains them, even though we try
to make sure they don't get copied by removing root_private_headers from
root_public_headers.

This patch also removes SystemInitializerFull.h from the LLDB.framework headers when building with CMake.

Reviewers: compnerd, sas, labath, beanz, zturner

Reviewed By: labath

Subscribers: clayborg, mgorny, lldb-commits

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

llvm-svn: 333444
2018-05-29 18:09:09 +00:00
Jan Kratochvil 1bbff4520e Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer
GetUnitDIEPtrOnly() needs to return pointer to the first DIE.
But the first element of m_die_array after ExtractDIEsIfNeeded(true)
may move in memory after later ExtractDIEsIfNeeded(false).

DWARFDebugInfoEntry::collection m_die_array is std::vector,
its data may move during its expansion.

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

llvm-svn: 333437
2018-05-29 17:17:46 +00:00
Jonas Devlieghere 36ab8956f4 [lit] Add support for passing arguments to dotest.py via lit.
The lldb test suite is highly configurable. While part of this
configuration takes place at configure/build-time, a common scenario
involves running the test suite several times with different
configuration. For example, we might want to test the current lldb
against inferiors built with different compilers.

This configuration was already possible for lldb-dotest, but was lacking
for the lit counterpart. It is now possible to pass arguments to pass
  arguments like this:

  ./bin/llvm-lit ../llvm/tools/lldb/lit/Suite/ -Ddotest-args="-foo;-bar"

llvm-svn: 333432
2018-05-29 16:49:07 +00:00
Jonas Devlieghere f6c870a794 [test] Fix --framework argument passed to dotest.
The framework argument was broken when I removed the generator
expressions upstream.  I replaced $<TARGET_FILE_DIR:liblldb> with
${LLVM_LIBRARY_OUTPUT_INTDIR}) which is not correct.

rdar://40534649

llvm-svn: 333412
2018-05-29 12:30:27 +00:00
Pavel Labath 0bd19ead89 XFAIL TestMachCore for windows hosts
It's been failing since I enabled the test for non-darwin targets. I
made it reference the same bug as the linux core, as it's likely that
the root cause is the same.

llvm-svn: 333401
2018-05-29 09:22:58 +00:00
Bruce Mitchener 6e82c4d6cc Remove Linux-specific includes for posix/FileSystem.cpp
Summary:
This improves the process of cross-compiling from macOS to Linux
since these files aren't used / needed at all.

Reviewers: clayborg, labath

Subscribers: lldb-commits, krytarowski

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

llvm-svn: 333400
2018-05-29 09:14:40 +00:00
Bruce Mitchener 4ebdee0a59 Typo fixes.
Reviewers: javed.absar

Subscribers: ki.stfu, JDevlieghere, lldb-commits

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

llvm-svn: 333399
2018-05-29 09:10:46 +00:00
Pavel Labath 9c3d1f468a ManualDWARFIndex: Treat DW_TAG_subprogram and DW_TAG_inlined_subroutine the same way
Summary:
We were treating subprograms and inlined subroutines differently when
building the index. The difference was in which indexes were individual
tags inserted (subprograms went to all indexes, where as inlined
subroutines only into the basename and full name indexes).

This seems like an error, because an inlined subroutine can still
represent an C++ or an ObjC method. I don't see anything in the
subprogram branch which should not apply to an inlined subroutine, so I
propose to just treat them identically. This makes searching for an
inlined method behave the same way as for the apple index.

I write an assembly-based test because I did not want to depend on
particular clang inlining behavior (and because I wanted to see how hard
would it be).

Reviewers: clayborg, JDevlieghere

Subscribers: eraman, lldb-commits

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

llvm-svn: 333398
2018-05-29 08:16:22 +00:00
Bob Wilson c791417a6d NFC: Fix some comment typos.
llvm-svn: 333364
2018-05-28 04:22:07 +00:00
Raphael Isemann 59949471c9 Fix memory leak in SubsPrimitiveParmItanium
Summary:
FastDemangle gives us a C-string that we own (which is allocated in SymbolDemangler::GetDemangledCopy).
As we are not deleting the string, we leak memory whenever we call SubsPrimitiveParmItanium.

Reviewers: javed.absar

Subscribers: kristof.beyls, chrib, lldb-commits

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

llvm-svn: 333353
2018-05-27 07:31:06 +00:00
Raphael Isemann 02d4ff4498 Add missing includes to some LLDB headers.
Summary: When compiling with modules, these missing includes cause the build to fail (as the header can't be compiled into a module).

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 333345
2018-05-26 14:59:14 +00:00
Raphael Isemann 81cc13258a Don't include headers from inside a namespace in MIUtilSingletonHelper.h
Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 333343
2018-05-26 14:39:35 +00:00
Raphael Isemann 5d63a10f0c Forward declare DumpValueObjectOptions in ValueObject.h
Summary: This resolves unnecessary the header dependency from
Core to DataFormatters. Patch is necessary for the introduction of
C++ modules to the LLDB build system.

Subscribers: lldb-commits

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

llvm-svn: 333342
2018-05-26 14:34:49 +00:00
Alex Langford b423e9bcb4 Fix Xcode build broken by SystemInitializerFull.h move
llvm-svn: 333322
2018-05-25 23:21:07 +00:00
Alex Langford d17cd90268 Move SystemInitializerFull header to source/API
Summary:
It seems to me that files in include/lldb/API/ are headers that should
be exposed to liblldb users. Because SystemInitializerFull.h exposes details of
lldb_private, I think having it there is not the right thing to do. Since it's
only included from files in source/API, we should move it there and treat it as
private.

Reviewers: labath, clayborg

Reviewed By: labath, clayborg

Subscribers: lldb-commits

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

llvm-svn: 333304
2018-05-25 20:28:16 +00:00
Alex Langford 39bf7d551b Fix typo in CMake comments
llvm-svn: 333299
2018-05-25 18:59:21 +00:00
Jan Kratochvil a185c71959 Remove DWARFUnit::ClearDIEs parameter keep_compile_unit_die
It has been now always passed as true and during planned D46810 it would no
longer make sense.

llvm-svn: 333287
2018-05-25 16:11:45 +00:00
Benjamin Kramer 192fe37599 Fix format string
PRIx64 already has the x inside, so this was creating a nonsensical format
string.

llvm-svn: 333273
2018-05-25 12:59:59 +00:00
Pavel Labath a2aad28f6d ManualDWARFIndex: Fix misclassification of methods in unions
Apple index was already treating them as methods. Not doing the same
seems like an omission.

llvm-svn: 333266
2018-05-25 10:49:11 +00:00
Pavel Labath a3b3533492 ManualDWARFIndex: reduce long parameter lists
Several functions were passing a list of 8 NameToDIE arguments around.
This puts those variables in a struct and passes that instead, reducing
code duplication and the possibility of error (swapping two arguments
accidentally).

llvm-svn: 333264
2018-05-25 09:55:51 +00:00
Adrian Prantl b90f1dfe00 HostInfoMacOSX: Support finding the clang resource directory within CLTools.
rdar://problem/40537961

llvm-svn: 333248
2018-05-25 00:29:01 +00:00
Jim Ingham 98e68a8d9c Add DWARFBaseDie.{h,cpp} to the Xcode build.
This should unbreak the green dragon bot builds.

llvm-svn: 333238
2018-05-24 23:33:27 +00:00
Jan Kratochvil 93afb0598e Use DWARFBaseDIE as a compile-time protection
As suggested by Pavel Labath in D46810 DWARFUnit::GetUnitDIEOnly() returning
a pointer to m_first_die should not permit using methods like GetFirstChild().

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

llvm-svn: 333224
2018-05-24 20:51:13 +00:00
Jan Kratochvil e522c97ef4 DWARFDIE split out to DWARFBaseDIE
This new DWARFBaseDIE is going to be used for DWARFUnit::GetUnitDIEOnly() as
other DIEs are unavailable that time so the caller should not have methods
available to access them.

This patch is only a mechanical split without any use of it.

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

llvm-svn: 333222
2018-05-24 20:44:48 +00:00
Jim Ingham 9465ced2a6 pc's should be printed in hex...
llvm-svn: 333208
2018-05-24 17:06:48 +00:00
Jim Ingham 214eea0ef2 Add SystemInitializerLLGS to the lldb-server target.
This should unbreak the xcode build.

llvm-svn: 333207
2018-05-24 17:06:11 +00:00
Adrian Prantl 512ccd7e6f [lldb-mi] Add possibility to set breakpoints without selecting a target.
Now it's possible to set breakpoints before selecting a target, they
will be set to the dummy target and then copied to an each added one.

Patch by Alexander Polyakov!

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

llvm-svn: 333205
2018-05-24 16:45:59 +00:00
Pavel Labath 5dd5833bd1 Fix windows/mac builds broken by r333182.
I should've known that something was wrong when only one of my plugins
was prefixed by the lldb_private namespace.

llvm-svn: 333183
2018-05-24 13:12:07 +00:00
Pavel Labath fa3fa5b90e Move ObjectFile initialization out of SystemInitializerCommon
Summary:
For lldb-server, it is sufficient to parse only the native object file
format for its target OS (no other file can be loaded into a running
process). This moves the object file initialization code into specific
initializer classes: lldb-test and liblldb get all object files;
lldb-server gets only one of them. For this to work, I've needed to
create a special SystemInitializer for use in lldb-server, instead of it
calling directly into the common one.

This reduces the size of lldb-server by about 2%, which is not
earth-shattering, but it's an easy win, and it helps.

Reviewers: zturner, clayborg

Subscribers: mgorny, lldb-commits

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

llvm-svn: 333182
2018-05-24 12:44:18 +00:00
Pavel Labath b7b2424f2e DWARF: Move indexing code from DWARFUnit to ManualDWARFIndex
Summary:
I think this makes sense for several reasons:
- better separation of concerns: DWARFUnit's job should be to provide a
  nice interface to its users to access the unit contents.
  ManualDWARFIndex can then use this interface to build an index and
  provide it to its users.
- closer alignment with llvm parsers: there is no indexing equivalent in
  llvm, and there probably never will be, as the index is very centered
  around how lldb wants to access debug info. If we ever switch to
  llvm's parser, this will allow us swap out DWARFUnit implementations
  and keep indexing as-is.
- closer proximity of the indexing code to AppleDWARFIndex will make it
  easier to keep the two in sync (e.g. right now the two use very
  different algorithms to determine whether a DW_TAG_subroutine
  represents a "method"). This is my primary motivation for making this
  change now, but I am leaving this work to a separate patch.

The only interface change to DWARFUnit I needed to make was to add an
efficient way to iterate over the list of all DIEs. Adding this also
aligns us closer to the llvm parser.

Reviewers: JDevlieghere, clayborg, aprantl

Subscribers: lldb-commits

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

llvm-svn: 333178
2018-05-24 12:12:49 +00:00
Pavel Labath b3c442a118 Add PPC64le support information
Summary: Add PPC64le support information on LLDB site

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: labath, lldb-commits, lbianc, clayborg

Differential Revision: https://reviews.llvm.org/D47285
Patch by Alexandre Yukio Yamashita <alexandre.yamashita@eldorado.org.br>.

llvm-svn: 333173
2018-05-24 11:17:02 +00:00
James Y Knight bfc51694af Remove unused include, and corresponding library dependency.
llvm-svn: 333151
2018-05-24 03:42:38 +00:00
Zachary Turner 6cef421b34 Add missing include.
llvm-svn: 333145
2018-05-24 00:11:24 +00:00
Zachary Turner 8e8d4b91a8 Break dependency from Core to ObjectFileJIT.
The only reason this was here was so that Module could have a
function called CreateJITModule which created things in a special
order.  Instead of making this specific to creating JIT modules,
I converted this into a template function that can create a module
for any type of object file plugin and just forwards arguments
through.  Since the template is not instantiated in Core, the linker
(and header file) dependency moves to the point where it is
instantiated, which only happens in Expression.  Conceptually, this
location also makes more sense for a dependency on ObjectFileJIT.
After all, we JIT expressions so it's no surprise that Expression
needs to make use of ObjectFileJIT.

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

llvm-svn: 333143
2018-05-23 23:56:09 +00:00
Adrian Prantl 4672849ead Add a --synchronous option to lldb-mi to facilitate reliable testing.
Patch by Alexander Polyakov!

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

llvm-svn: 333140
2018-05-23 23:33:50 +00:00
James Y Knight 1a05affa80 Remove spurious dependency on Process/elf-core from Process/Utility.
These checks do absolutely nothing other than cause a library layering
violation in the code.

llvm-svn: 333134
2018-05-23 22:04:20 +00:00
Pavel Labath fe547e0447 Fix PathMappingList tests on windows
The tests added in r332842 don't work on windows, because they do path
comparisons on strings, and on windows, the paths coming out of the
mappings had backslashes in them.

This switches comparisons to FileSpecs, so the results come out right.

llvm-svn: 333074
2018-05-23 10:32:05 +00:00
Pavel Labath 2eb720f51e ProcessLauncherPosixFork: move setgid call into the if(debug) branch
This call was originally being only made when launching for debug (as an
attempt to make sure we don't impart extra privileges on the launched
process), but after the debug and non-debug paths were merged, it made
it's way into generic code. This was causing problems in locked down
android environments which disallowed calling setgid even if it would be
a no-op. This prevented launching llgs from lldb-server platform.

Overall I'm not sure we should be calling setgid in the first place
(it seems random -- e.g. why don't we call setuid then as well).
However, all our other copies of launch code have it, so I choose to
keep it for now.

llvm-svn: 333073
2018-05-23 10:10:36 +00:00
Aaron Smith 9b5c3db09d [SymbolFilePDB] PDB_BuiltinType::Char16 and Char32 are unsigned in MSVC.
llvm-svn: 333055
2018-05-23 02:48:25 +00:00
Aaron Smith 6de0ca4296 [SymbolFilePDB] Add a test for wchar_t type in PDB.
The wchar_t is unsigned. 

https://msdn.microsoft.com/en-us/library/s3f49ktz.aspx

llvm-svn: 333051
2018-05-23 01:58:23 +00:00
Aaron Smith cab0d23ff7 [SymbolFilePDB] Add support for resolving variable symbols
Summary:
Implement FindGlobalVariables and ParseVariableContext methods.

Compile unit information is necessary for resolving variable context, however some PDB symbols do not have this information. For now an empty DWARFExpression is used to construct a lldb::Variable instance with the limitation that using lldb to lookup the value of a global or local variable is not available.

This commit may slow down lit/SymbolFile/PDB/compilands.test since the test includes MS specific modules that spend more time parsing variables.

Reviewers: rnk, zturner, lldb-commits

Subscribers: aprantl, JDevlieghere, llvm-commits

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

llvm-svn: 333049
2018-05-23 01:52:42 +00:00
Saleem Abdulrasool 9426358ea1 build: use cmake to find the libedit content
Use proper cmake techniques to detect where the libedit package resides.
This allows for the use of libedit from an alternative location which is
needed for supporting cross-compilation.

llvm-svn: 333041
2018-05-22 23:24:46 +00:00
James Y Knight 2ad4821223 Normalize some lldb #include statements.
Most non-local includes of header files living under lldb/sources/
were specified with the full path starting after sources/. However, in
a few instances, other sub-directories were added to include paths, or

Normalize those few instances to follow the style used by the rest of
the codebase, to make it easier to understand.

llvm-svn: 333035
2018-05-22 22:53:50 +00:00
James Y Knight 8fc06c7ab7 Avoid using header from Host/macosx when not testing an apple build.
llvm-svn: 333032
2018-05-22 21:49:41 +00:00
Pavel Labath 4c7763eb2f Enable ProcessMachCore plugin on non-apple platforms
Summary:
The plugin already builds fine on other platforms (linux, at least). All
that was necessary was to revitalize the hack in PlatformDarwinKernel
(not a very pretty hack, but it gets us going at least).

I haven't done a thorough investigation of the state of the plugin on
other platforms, but at least the two core file tests we have seem to
pass, so I enable them.

Reviewers: JDevlieghere, jasonmolenda

Subscribers: lldb-commits, mgorny

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

llvm-svn: 332997
2018-05-22 16:33:43 +00:00
Jim Ingham a435d73349 Work around some odd instruction single-step behavior on macOS.
We've seen some cases on macOS where you go to instruction single
step (over a breakpoint), and single step returns but the instruction
hasn't been executed (and the pc hasn't moved.)  The ThreadPlanStepOverBreakpoint
used to handle this case by accident, but the patches to handle two adjacent
breakpoints broke that accident.

This patch fixes the logic of ExplainsStop to explicitly handle the case where
the pc didn't move.  It also adds a WillPop that re-enables the breakpoint we
were stepping over.  We never want an unexpected path through the plan to
fool us into not doing that.

I have no idea how to make this bug happen.  It is very inconsistent when it
occurs IRL.  We really need a full MockProcess Plugin before we can start to write
tests for this sort of system hiccup.

<rdar://problem/38505726>

llvm-svn: 332922
2018-05-22 00:06:55 +00:00
Jim Ingham 99f7011829 Fix the Xcode project for the refactoring of the
DWARF reader.

llvm-svn: 332914
2018-05-21 22:41:28 +00:00
Zachary Turner f36b128bae Enable Python API for OpenBSD.
Patch by David Carlier

llvm-svn: 332877
2018-05-21 19:47:45 +00:00
Greg Clayton 86188d8a40 Fix PathMappingList for relative and empty paths after recent FileSpec normalization changes
PathMappingList was broken for relative and empty paths after normalization changes in FileSpec. There were also no tests for PathMappingList so I added those.

Changes include:

Change PathMappingList::ReverseRemapPath() to take FileSpec objects instead of ConstString. The only client of this was doing work to convert to and from ConstString objects for no reason.
Normalize all paths prefix and replacements that are added to the PathMappingList vector so they match the paths that have been already normalized in the debug info
Unify code in the two forms of PathMappingList::RemapPath() so only one contains the actual functionality. Prior to this, there were two versions of this code.
Use FileSpec::AppendPathComponent() and remove a long standing TODO so paths are correctly appended to each other.
Added tests for absolute, relative and empty paths.

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

llvm-svn: 332842
2018-05-21 14:14:36 +00:00
Pavel Labath b13f033818 Reland "[DWARF] Extract indexing code into a separate class hierarchy"
After this commit, the xcode project will need to be updated to include
the new files added here.

llvm-svn: 332841
2018-05-21 14:12:52 +00:00
Pavel Labath becc204633 Improve coverage of the apple-tables test
After closer examination, it turns out we mis-classify one of the
methods only if two of the structs have the same name. Since this was
meant to be a basic test, I rename one of the structs in the test so
that we have at least some coverage for the apple tables lookup.
Instead, I create an XFAILed test which specifically targets the
same-name case (and file a bug to track it).

llvm-svn: 332833
2018-05-21 10:09:22 +00:00
Pavel Labath bf5a3f8393 Add some apple-tables lookup tests
Summary:
Now that we are able to parse MachO files everywhere, we can write some
cross-platform tests for handling of apple accelerator tables. This
reruns the same lookup tests we have for manual indexes on MachO files
which will use the accelerator tables instead. This makes sure we return
the same results regardless of the method we used to access the debug
info.

The tests confirm we return the same results for looking up types,
namespaces and variables, but have found an inconsistency in the
treatment of function lookup. In the function case we mis-classify the
method "foo" declared in the local struct sbar (inside function ffbar).
We classify it as a function whereas it really is a method. Preliminary
analysis suggests this is because
DWARFASTParserClang::GetClangDeclContextForDIE returns null when given
the local "struct sbar" DIE. This causes us to get the wrong
CompilerDeclContext when we ask for the context of the inner foo, which
means CompilerDeclContext::ISStructUnionOrClass returns false.

Until this is fixed, I do not include the darwin versions of the "base"
and "method" function lookup tests.

Reviewers: JDevlieghere, clayborg

Subscribers: aprantl, ilya-biryukov, ioeric, lldb-commits

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

llvm-svn: 332831
2018-05-21 09:27:16 +00:00
Eric Liu ff9c4ff117 [lldb] Fix compile warnings in r332702
Summary:
- Fix #include path
- Fix warning:
````
error: format specifies type 'unsigned long long' but the argument has type 'uint64_t'
(aka 'unsigned long') [-Werror,-Wformat]
 ```

Reviewers: labath, javed.absar

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

llvm-svn: 332733
2018-05-18 16:19:52 +00:00
Amara Emerson 29b8df607e Revert "[DWARF] Extract indexing code into a separate class hierarchy"
This reverts commit r332719 due to breaking this green dragon build:
http://green.lab.llvm.org/green/job/lldb-xcode/6644

llvm-svn: 332730
2018-05-18 15:59:42 +00:00
Pavel Labath 1237095b3c [DWARF] Extract indexing code into a separate class hierarchy
Summary:
This places the `if(m_using_apple_tables)` branches inside the
SymbolFileDWARF class behind an abstract DWARFIndex class. The class
currently has two implementations:
- AppleIndex, which searches using .apple_names and friends
- ManualIndex, which searches using a manually built index

Most of the methods of the class are very simple, and simply extract the
list of DIEs for the given name from the appropriate sub-table. The main
exception are the two GetFunctions overloads, which take a couple of
extra paramenters, including some callbacks. It was not possible to
split these up the same way as other methods, as here we were doing a
lot of post-processing on the results. The post-processing is similar
for the two cases, but not identical. I hope to factor these further in
separate patches.

Other interesting methods are:
- Preload(): do any preprocessing to make lookups faster (noop for
  AppleIndex, forces a build of the lookup tables for ManualIndex).
- ReportInvalidDIEOffset(): Used to notify the users of an invalid index
  (prints a message for AppleIndex, noop for ManualIndex).
- Dump(): dumps the index state (noop for AppleIndex, prints the lookup
  tables for ManualIndex).

Reviewers: clayborg, JDevlieghere

Subscribers: mgorny, aprantl, lldb-commits

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

llvm-svn: 332719
2018-05-18 14:15:46 +00:00
Pavel Labath 90da3ce3a9 Add back #ifdef __APPLE__ to RegisterContextDarwin_xxx::NumSupportedHardwareWatchpoints
It turns out these class still contained some os-specific functionality,
but I did not notice that originally, as it was #ifdef arm(64). This
adds back the __APPLE__ condition to these particular functions,
unbreaking arm builds on other OSs.

llvm-svn: 332710
2018-05-18 12:54:21 +00:00
Pavel Labath 981a34c428 Make ObjectFileMachO work on non-darwin platforms
Summary:
Before this patch we were unable to write cross-platform MachO tests
because the parsing code did not compile on other platforms. The reason
for that was that ObjectFileMachO depended on
RegisterContextDarwin_arm(64)? (presumably for core file parsing) and
the two Register Context classes uses constants from the system headers
(KERN_SUCCESS, KERN_INVALID_ARGUMENT).

As far as I can tell, these two files don't actually interact with the
darwin kernel -- they are used only in ObjectFileMachO and MacOSX-Kernel
process plugin (even though it has "kernel" in the name, this one
communicates with it via network packets and not syscalls). For the time
being I have created OS-independent definitions of these constants and
made the register context classes use those. Long term, the error
handling in these classes should be probably changed to use more
standard mechanisms such as Status or Error classes.

This is the only change necessary (apart from build system glue) to make
ObjectFileMachO work on other platforms. To demonstrate that, I remove
REQUIRES:darwin from our (only) cross-platform mach-o test.

Reviewers: jasonmolenda, aprantl, clayborg, javed.absar

Subscribers: mgorny, lldb-commits, kristof.beyls

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

llvm-svn: 332702
2018-05-18 11:35:46 +00:00
Jonas Devlieghere 4574522291 Fix _NSCFBoolean data formatter.
In r265181 the test for the NSCFBoolean data formatter was removed.
Later, in r279353 and r279446 a new implementation was provided for the
formatter, which I believe never worked (and this wasn't caught because
the test was never re-enabled).

This commit fixes the bug and re-enables the old test case.

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

llvm-svn: 332700
2018-05-18 09:14:45 +00:00
Stella Stamenova 5b5350ddee [Windows, Process] LLDB reads wrong registers on 64bit Windows
Summary: LLDB reads wrong registers on 64bit Windows because RegisterContextWindows_x64::GetRegisterInfoAtIndex returns wrong reference.
I encountered broken backtrace when the program stopped at function which does not have prologue code, such as compiled with '-fomit-frame-pointer'.
In this situation, CFA is equal to rsp but LLDB reads r9.

RegisterContextWindows_x64::GetRegisterInfoAtIndex depends the order of lldb_XXX_x86_64 values, but RegisterIndex/g_register_infos/g_gpr_reg_indices does not follow order.

In source/Plugins/Process/Utility/lldb-x86-register-enums.h
The order of GPRs is rax, rbx, rcx, rdx, rdi, rsi, rbp, rsp, r8, ...

In source/Plugins/Process/Windows/Common/x64/RegisterContextWindows_x64.cpp
The order of GPRs is rax, rbx, rcx, rdx, rdi, rsi, r8, r9, r10, ...

Patch by Kenji Koyanagi

llvm-svn: 332671
2018-05-17 21:42:37 +00:00
Stella Stamenova 0fd67b537b [Windows, Process] Fix an issue in windows thread handling that was causing LLDB to hang
Summary: The function ResumeThread on Windows returns a DWORD which is an unsigned int. In TargetThreadWindows::DoResume, there's code that determines how many times to call ResumeThread based on whether the return value is greater than 0. Since the function returns -1 (as an unsigned int) on failure, this was getting stuck in an infinite loop if ResumeThread failed for any reason. The correct thing to do is check whether the return value is -1 and then return the appropriate error instead of ignoring the return value.

Reviewers: asmith, zturner, labath

Reviewed By: zturner

Subscribers: llvm-commits

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

llvm-svn: 332670
2018-05-17 21:34:24 +00:00
Greg Clayton 6dcea6d28f Fix buildbots after it 332618
llvm-svn: 332633
2018-05-17 17:18:11 +00:00
Stella Stamenova 3e79551700 [lit, lldbsuite] Disable tests that are failing because of pr21765 and pr24489
Summary: These three tests are failing on Windows and looking into the failures, they could be mapped to pr21765 and pr24489

Reviewers: asmith, labath, zturner

Reviewed By: zturner

Subscribers: llvm-commits

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

llvm-svn: 332629
2018-05-17 16:58:00 +00:00
Greg Clayton 39d50b72ea FileSpec objects that resolve to "." should have "." in m_filename and m_directory empty.
After switching to LLVM normalization, if we init FileSpec with "." we would end up with m_directory being NULL and m_filename being "".

This patch fixes this by allowing the path to be normalized and if it normalized to nothing, set it to m_filename.

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

llvm-svn: 332618
2018-05-17 16:12:38 +00:00
Pavel Labath ae128b2dc3 [DWARF] Have HashedNameToDIE store a DataExtractor by value
Summary:
The DataExtractors are cheap to copy so there is no reason to store them
by reference. Also, in my upcoming indexing refactor I am planning to
remove the apple tables data extractor members from the SymbolFileDWARF
class, so there will not be a DataExtractor with a suitable lifetime to
refer to.

Reviewers: clayborg, JDevlieghere

Subscribers: aprantl, lldb-commits

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

llvm-svn: 332596
2018-05-17 11:36:08 +00:00
Greg Clayton a8da1f8ee4 Revert 332511 after reverting llvm revision 332508.
llvm-svn: 332556
2018-05-16 23:32:45 +00:00
Greg Clayton 4de94930c3 Fix FileSpecTest after LLVM changes to remove_dots (https://reviews.llvm.org/D46887)
llvm-svn: 332511
2018-05-16 18:37:00 +00:00
Pavel Labath 245dd2e0c7 Reapply "Remove Process references from the Host module"
This re-lands r332250/D46395, after fixing Mac build errors.

llvm-svn: 332353
2018-05-15 13:42:26 +00:00
Stella Stamenova ad9b697898 [lit] Fix several tests that fail when using Python 3 or on Windows
Summary:
1) In logtest.cpp, the name of the file that is reported is not always capitalized, so split the comparison to validate the file (case insensitive) and function (case sensitive) separately
2) Update the gdb remote client tests to work with Python 3. In Python 3, socket sends/receives data as bytes rather than byte strings. This also updates the usage of .hex() - this is no longer available in Python 3, so use hexlify instead

Reviewers: asmith, labath, zturner

Reviewed By: labath

Subscribers: llvm-commits

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

llvm-svn: 332293
2018-05-14 21:04:24 +00:00
Pavel Labath 4f107ba20e Revert "Remove Process references from the Host module"
The first fix wasn't enough, there is still a missing
ProcessInstanceInfo include in Host.mm. I won't be able to test a fix
before leaving work, so I am reverting both commits.

This reverts commit r332250 and the subsequent fix attempt.

llvm-svn: 332261
2018-05-14 16:54:53 +00:00
Pavel Labath 4a20f3b3f9 Fix macosx build broken by r332250
llvm-svn: 332255
2018-05-14 16:01:49 +00:00
Pavel Labath 58b54894c7 Remove Process references from the Host module
The Process class was only being referenced because of the last-ditch
effort in the process launchers to set a process death callback in case
one isn't set already.

Although launching a process for debugging is the most important kind of
"launch" we are doing, it is by far not the only one, so assuming this
particular callback is the one to be used is not a good idea (besides
breaking layering). Instead of assuming a particular exit callback, I
change the launcher code to require the callback to be set by the user (and fix
up the two call sites which did not set the callback already).

Reviewers: jingham, davide

Subscribers: lldb-commits

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

llvm-svn: 332250
2018-05-14 15:13:13 +00:00
Pavel Labath 2cb7cf8e87 FileSpec: Remove PathSyntax enum and use llvm version instead
Summary:
The llvm version of the enum has the same enumerators, with stlightly
different names, so this is mostly just a search&replace exercise. One
concrete benefit of this is that we can remove the function for
converting between the two enums.

To avoid typing llvm::sys::path::Style::windows everywhere I import the
enum into the FileSpec class, so it can be referenced as
FileSpec::Style::windows.

Reviewers: zturner, clayborg

Subscribers: lldb-commits

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

llvm-svn: 332247
2018-05-14 14:52:47 +00:00
Jan Kratochvil 2e5be0cb6f Use const_iterator in DWARFUnit
Function DWARFUnit::GetDIE is using m_die_array only for reading so it can use
DWARFDebugInfoEntry::const_iterator.

llvm-svn: 332201
2018-05-13 19:04:17 +00:00
Jan Kratochvil 03aff468c9 Revert "Protect DWARFCompileUnit::m_die_array by a new mutex"
Pavel Labath found this patch is incomplete and racy.  I think there needs to
be some more mutexes even before considering DW_TAG_partial_unit.

This reverts commit 331229 which was: https://reviews.llvm.org/D40470

llvm-svn: 332200
2018-05-13 18:38:28 +00:00
Davide Italiano 1e6a01fc87 Revert "[LLDB] Support GNU-style compressed debug sections (.zdebug)"
This reverts commit r332162 as it breaks the bots (Ubuntu 14.04)
with the following message:

Build Command Output:
objcopy: option '--compress-debug-sections' doesn't allow an argument

llvm-svn: 332165
2018-05-12 01:25:48 +00:00
Davide Italiano 8b99865034 [LanguageRuntime/ObjC] Turn off ISA logging once and for all.
On behalf of Jim, who's out today.

llvm-svn: 332163
2018-05-12 00:33:12 +00:00
Davide Italiano 56ab68f323 [LLDB] Support GNU-style compressed debug sections (.zdebug)
Patch by Erik Welander!

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

llvm-svn: 332162
2018-05-12 00:29:25 +00:00
Adrian Prantl 66a0b77493 Conditionally compile a Darwin-only test.
llvm-svn: 332140
2018-05-11 21:05:32 +00:00
Adrian Prantl 3a380fb2ff Yet another follow-up to r332111. This also handles the case where an
LLDB.framework is built inside the LLDB build directory (but not
inside an Xcode installation).

llvm-svn: 332126
2018-05-11 19:29:25 +00:00
Adrian Prantl 5103e48bad Fix a regression in r332111. The LLDB.framework path component is not
usually the last component.

llvm-svn: 332120
2018-05-11 19:00:58 +00:00
Frederic Riss d10d3795f7 Add a lock to PlatformPOSIX::DoLoadImage
Summary:
Multiple threads could be calling into DoLoadImage concurrently,
only one should be allowed to create the UtilityFunction.

Reviewers: jingham

Subscribers: emaste, lldb-commits

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

llvm-svn: 332115
2018-05-11 18:21:11 +00:00
Adrian Prantl 7d46f0e4c2 HostInfoMacOSX: Share the clang resource directory with Swift.
Inside Xcode and in Xcode toolchains LLDB is always in lockstep
with the Swift compiler, so it can reuse its Clang resource
directory. This allows LLDB and the Swift compiler to share the
same Clang module cache.

rdar://problem/40039633

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

llvm-svn: 332111
2018-05-11 17:54:09 +00:00
Pavel Labath e7306b105e Remove custom path manipulation functions from FileSpec
Summary:
now that llvm supports host-agnostic path manipulation functions (and
most of their kinks have been ironed out), we can remove our copies of
the path parsing functions in favour of the llvm ones.

This should be NFC except for the slight difference in handling of the
"//" path, which is now normalized to "/" (this only applies to the
literal "//" path; "//net" and friends still get to keep the two
slashes).

Reviewers: zturner, clayborg

Subscribers: lldb-commits

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

llvm-svn: 332088
2018-05-11 11:55:34 +00:00
Adrian Prantl 9702c963ab Retrieve the deployment target when retrieving an object file's triple.
Getting the deployment target can be significant information when
rebuilding clang modules since availability information could depend
on it.

rdar://problem/40039633

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

llvm-svn: 332067
2018-05-11 00:41:20 +00:00
Greg Clayton 19e9884609 Fix the code that gets the Xcode path. After path normalization this could was failing.
This meant if the "debugserver" binary was removed from the LLDB.framework, lldb wouldn't be able to find debugserver.

llvm-svn: 332050
2018-05-10 22:09:01 +00:00
Pavel Labath 60851ec87f Fix one more RunShellcommand occurence in mac code
llvm-svn: 331977
2018-05-10 12:02:24 +00:00
Pavel Labath 70f4eaf699 Fix windows&mac builds broken by r331970 (RunShellCommand/Timeout) refactor
llvm-svn: 331974
2018-05-10 11:27:43 +00:00
Pavel Labath 19dd1a0ea6 Convert all RunShellCommand functions to use the Timeout class
this completes the Timeout migration started in r331880 with the
Predicate class.

llvm-svn: 331970
2018-05-10 10:46:03 +00:00
Pavel Labath 4865ff1e18 CPlusPlusLanguage: Add unit tests for the FindAlternateFunctionManglings method
I was considering modifying this function, so I wrote some tests to make
sure I don't regress its behavior. I am not sure if I will actually
proceed with the modifications, but the tests seem useful nonetheless.

llvm-svn: 331966
2018-05-10 08:59:17 +00:00
Stella Stamenova 42ba76c9f6 [cmake, unittests] Fix the CMake file for the LLDB unittests to support multiple configurations
Summary: The current setup for the unit tests only works correctly when the generator does not support multiple configurations. When the generator supports multiple configurations, the inputs are not copied to the correct per-configuration directory. This change sets up the build to copy the inputs in each configuration directory.

Reviewers: labath, asmith, zturner

Reviewed By: labath

Subscribers: mgorny, llvm-commits

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

llvm-svn: 331914
2018-05-09 19:58:51 +00:00
Greg Clayton f56c30d13b General cleanup to minimize the .debug_types patch
This cleanup is designed to make the https://reviews.llvm.org/D32167 patch smaller and easier to read.

Cleanup in this patch:

Allow DWARFUnit subclasses to hand out the data that should be used when decoding data for a DIE. The information might be in .debug_info or could be in .debug_types. There is a new virtual function on DWARFUnit that each subclass must override:

virtual const lldb_private::DWARFDataExtractor &DWARFUnit::GetData() const;
This allows DWARFCompileUnit and eventually DWARFTypeUnit to hand out different data to be used when decoding the DIE information.

Add a new pure virtual function to get the size of the DWARF unit header:

virtual uint32_t DWARFUnit::GetHeaderByteSize() const = 0;
This allows DWARFCompileUnit and eventually DWARFTypeUnit to hand out different offsets where the first DIE starts when decoding DIE information from the unit.

Added a new function to DWARFDataExtractor to get the size of an offset:

size_t DWARFDataExtractor::GetDWARFSizeOfOffset() const;
Removed dead dumping and parsing code in the DWARFDebugInfo class.
Inlined a bunch of calls in DWARFUnit for accessors that were just returning integer member variables.
Renamed DWARFUnit::Size() to DWARFUnit::GetHeaderByteSize() as it clearly states what it is doing and makes more sense.

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

llvm-svn: 331892
2018-05-09 16:42:53 +00:00
Stella Stamenova 8a36cb3bb2 [lit, lldbsuite] Add a bug reference to the failing TestLinuxCore and fix an undefined property in dotest.py
Summary:
1) In TestLinuxCore rather than skipping the tests on Windows, mark them as expected failures and add a bug reference
2) In dotest.py replace the undefined property in the exceptions with the actual property causing the exception

Reviewers: asmith, labath, zturner

Reviewed By: labath, zturner

Subscribers: llvm-commits

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

llvm-svn: 331886
2018-05-09 15:35:19 +00:00
Pavel Labath 4b13033149 Fix Windows build for the Predicate.h refactor in r331880
llvm-svn: 331882
2018-05-09 14:49:43 +00:00
Pavel Labath 3879fe0099 Modernize and clean-up the Predicate class
Summary:
The comments on this class were out of date with the implementation, and
the implementation itself was inconsistent with our usage of the Timeout
class (I started converting everything to use this class back in D27136,
but I missed this one). I avoid duplicating the waiting logic by
introducing a templated WaitFor function, and make other functions
delegate to that. This function can be also used as a replacement for
the unused WaitForBitToBeSet functions I removed, if it turns out to be
necessary.

As this changes the meaning of a "zero" timeout, I tracked down all the
callers of these functions and updated them accordingly. Propagating the
changes to all the callers of RunShellCommand was a bit too much for
this patch, so I stopped there and will continue that in a follow-up
patch.

I also add some basic unittests for the functions I modified.

Reviewers: jingham, clayborg

Subscribers: mgorny, lldb-commits

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

llvm-svn: 331880
2018-05-09 14:29:30 +00:00
Pavel Labath 80d48155cf [DWARF] Align non-accelerated function fullname searching with the apple-tables path
Summary:
Before this patch the two paths were doing very different things
- the apple path searched the .apple_names section, which contained
  mangled names, as well as basenames of all functions. It returned any
  name it found.
- the non-accelerated path looked in the "full name" index we built
  ourselves, which contained mangled as well as demangled names of all
  functions (but no basenames). Then however, if it did not find a match
  it did an extra search in the basename index, with some special
  handling for anonymous namespaces.

This aligns the two paths by changing the non-accelerated path to return
the same results as in the apple-tables one. In pratice, this means we
will search in both the "basename", "method" and "fullname" indexes (in
the manual indexes these are separate indexes. This means the function
will return some slightly inappropriate results (e.g. bar::baz::foo when
one asks for a "full name" foo), but this can be handled by additional
filtering, independently indexing method. I've also stopped inserting
demangled names into the "fullname" index, as that is inconsistent with
the apple path.

Reviewers: clayborg, JDevlieghere

Subscribers: lldb-commits

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

llvm-svn: 331855
2018-05-09 08:21:25 +00:00
Greg Clayton 2550ca1e93 Add support to object files for accessing the .debug_types section
In an effort to make the .debug_types patch smaller, breaking out the part that reads the .debug_types from object files into a separate patch

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

llvm-svn: 331777
2018-05-08 17:19:24 +00:00
Jonas Devlieghere e6effb199c [test] Re-enable TestUnicodeSymbols
Re-enable TestUnicodeSymbols now that we use the in-tree dsymutil. This
was disabled because the hashing of unicode symbols was out of sync
between llvm (dsymutil) and lldb.

llvm-svn: 331764
2018-05-08 13:28:34 +00:00
Frederic Riss 1739b7d076 Really test type lookup in TestCppTypeLookup.py
Summary:
... and fix one bug found this way. Currently, the test works not because
types are looked up correctly, but because by injecting local variables
we also materialize the types for Clang. If we disable the local variable
injection, then one check fails.

The reason of the failure is that FindTypes is run with max_matches==1
and this value is passed down to the symbol lookup functions. When the
search is performed only on the basename (like it's the case for an
entity defined in the root namespace), then the search will stop after
having found one match on the basename. But that match might be in a
namespace, we were really just looking up the basename in the accelerator
tables.

The solution is to not pass max_matches down, but to search without a
limit and let RemoveMismatchedTypes do its job afterwards. Note the
patch includes 2 hunks with the same change, but only the latter is
tested. I couldn't find a way to create a testcase for the other
branch of the if ('image lookup -t' allows me to get there, but it
only ever returns one type anyway).

Reviewers: clayborg, jingham

Subscribers: lldb-commits

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

llvm-svn: 331719
2018-05-08 03:08:46 +00:00
Stella Stamenova 8380d12a6e [lit, lldbsuite] Fixes for several tests LLDB tests for Python 3 or Windows
Summary:
In decorators.py, when opening streams, open them in text mode. In Py3, if they are not opened in text mode, the data is also expected to be binary, but we always use text data.
In TestLinuxCore, skip the tests that are not applicable on Windows
In the python api main.c, update the code to be compilable on Windows

Reviewers: asmith, zturner

Reviewed By: zturner

Subscribers: zturner

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

llvm-svn: 331686
2018-05-07 21:57:00 +00:00
Stella Stamenova 88ce10b77d Test Commit: fix a comment to be grammatically correct
llvm-svn: 331679
2018-05-07 21:19:14 +00:00
Greg Clayton d68dbd5ad6 Fix "file ./a.out" and file "../a.out" so that is works after recent FileSpec normalization path changes.
Test coming soon, but I want to unbreak people.

llvm-svn: 331637
2018-05-07 14:21:04 +00:00
Jim Ingham 0fd685353d Add children and child[N] properties to SBValue.i.
Also fixed some bad formatting in SBValue.i.

llvm-svn: 331501
2018-05-04 01:31:47 +00:00
Jason Molenda 07580ffe47 The on-ios-device command line lldb has an optimization where
when it and the inferior process both have the same shared cache
(a conglomeration of all libraries at the same fixed address for
all processes), lldb will read data out of its own memory to speed
things up.  The shared cache has a UUID, so lldb currently checks
that the UUID of its own shared cache matches that of the inferior.

This change adds one refinement to that -- it checks that the UUID
is the same and that the base address of the shared cache is the
same.  And only uses its local shared cache if they are both identical.

This involved using a different style of SPI with dyld to get lldb's
shared cache load address, but it's not especially difficult.

One unattractive part of the change is that I'm using the real
underlying types of task_t and kern_return_t instead of picking
them up from mach/mach.h.  The defines that get picked up there (a
lot from machine.h but others too) conflict with llvm/Support/MachO.h
even when I have mach.h included before our SafeMachO.h which
undefines most of the defines before including llvm/Support/MachO.h.
I'll need to augment the #undefs in SafeMachO.h to get this to
compile cleanly, but that'll be another day.

<rdar://problem/39868238> 

llvm-svn: 331497
2018-05-04 00:59:37 +00:00
Adrian Prantl b51804e0d8 DWARFExpression: Convert file addresses to load addresses early on.
This is a change that only affects Swift and is NFC for the language
plugins on llvm.org. In Swift, we can have global variables with a
location such as DW_OP_addr <addr> DW_OP_deref. The DWARF expression
evaluator doesn't know how to apply a DW_OP_deref to a file address,
but at the very end we convert the file address into a load address.

This patch moves the file->load address conversion to right after the
result of the DW_OP_addr is pushed onto the stack so that a subsequent
DW_OP_deref (and potentially other operations) can be interpreted.

rdar://problem/39767528

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

llvm-svn: 331492
2018-05-03 23:32:47 +00:00
Adrian Prantl b78a577179 Revert "DWARFExpression: Convert file addresses to load addresses early on."
This reverts commit 331462 while investigating bot breakage.

llvm-svn: 331480
2018-05-03 20:19:39 +00:00
Adrian Prantl 88fc73d544 Add back condition that was accidentally removed in r331462.
This should make the bots much happier.

llvm-svn: 331479
2018-05-03 20:13:58 +00:00
Jonas Devlieghere 52721286b2 [CMake] Unify and relayer testing
This patch restructures part of LLDB's testing configuration:

1. I moved the test dependencies up the chain so every dotest dependency
   becomes a lit dependency as well. It wouldn't make sense for dotest to
   have other dependencies when it's being run by lit. Lit on the other
   hand can still specify extra dependencies.

2. I replaced as much generator expressions with variables as possible.
   This is consistent with the rest of LLVM and doesn't break generators
   that support multiple targets (MSVC, Xcode). This wasn't a problem
   before, but now we need to expand the dotest arguments in the lit
   configuration and there's only one test suite even with multiple
   targets.

3. I moved lldb-dotest into it's own directory under utils since there's
   no need anymore for it to located under `test/`.

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

llvm-svn: 331463
2018-05-03 16:54:10 +00:00
Adrian Prantl c42fa4be1f DWARFExpression: Convert file addresses to load addresses early on.
This is a change that only affects Swift and is NFC for the language
plugins on llvm.org. In Swift, we can have global variables with a
location such as DW_OP_addr <addr> DW_OP_deref. The DWARF expression
evaluator doesn't know how to apply a DW_OP_deref to a file address,
but at the very end we convert the file address into a load address.

This patch moves the file->load address conversion to right after the
result of the DW_OP_addr is pushed onto the stack so that a subsequent
DW_OP_deref (and potentially other operations) can be interpreted.

rdar://problem/39767528

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

llvm-svn: 331462
2018-05-03 16:51:37 +00:00
Pavel Labath 38d67db39c Remove the timed_out out-argument from Predicate::WaitForValueEqualTo
The function can only return in one of two ways: the Predicate value is
successfully set within the allotted time, or it isn't (the wait times
out). These states can be represented in the return value, and the extra
arg adds no value.

llvm-svn: 331458
2018-05-03 15:33:41 +00:00
Pavel Labath 90b0a53499 lldb-test symbols: Add ability to do name-based lookup
Summary:
lldb-test already had the ability to dump all symbol information in a
module. This is interesting, but it can be too verbose, and it also does
not use the same APIs that lldb uses to query symbol information. The
last part is interesting to me now, because I am about to add DWARF v5
debug_names support, which needs to implement these APIs.

This patch adds a set of arguments to lldb-test, which modify it's
behavior from dumping all symbols to dumping only the requested
information:
- --find={function,namespace,type,variable} - search for the given
  kind of objects.

- --name - the name to search for.

- --regex - whether to treat the "name" as a regular expression. This is
  not available for all lookup types (we do not have the required APIs
  for namespaces and types).

- --context - specifies the context, which can be used to restrict the
  search. This argument takes a variable name (which must be defined and
  be unique), and we then use the context that this variable is defined
  in as the search context.

- --function-flags={auto,full,base,method,selector} - a set of flags to
  further restrict the search for function symbols.

Together, these flags and their combinations cover the main SymbolFile
entry points which I will need to modify for the accelerator table
support, and so I plan to do most of the regression testing this way.
(I've also found this a useful tool for exploration of what the given
APIs are supposed to do.)

I add a couple of tests to demonstrate the usage of the usage of the
various options, and also an xfailed test which demonstrates a bug I
found while playing with this. The only requirement for these tests is
the presence of lld -- the should run on any platform which is able to
build lldb.

These tests use c++ code as input, but this isn't a requirement. It is also
possible to use IR, assembly or json to create the test module.

Reviewers: davide, zturner, asmith, JDevlieghere, clayborg, alexshap

Subscribers: mgorny, aprantl, lldb-commits

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

llvm-svn: 331447
2018-05-03 10:57:16 +00:00
Davide Italiano 1f6277eb4d [NSDictionary] Simplify the formatter. NFCI.
llvm-svn: 331415
2018-05-02 23:36:07 +00:00
Richard Smith fbe748ae86 Use conventional spelling of always-failing assert.
Fixes -Wstring-conversion warning that was breaking -Werror builds.

llvm-svn: 331406
2018-05-02 22:21:11 +00:00
Leonard Mosescu 9fecd37220 Use the UUID from the minidump's CodeView Record for placeholder modules
This change adds support for two types of Minidump CodeView records:

PDB70 (reference: https://crashpad.chromium.org/doxygen/structcrashpad_1_1CodeViewRecordPDB70.html)
This is by far the most common record type.

ELF BuildID (found in Breakpad/Crashpad generated minidumps)
This would set a proper UUID for placeholder modules, in turn enabling
an accurate match with local module images.

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

llvm-svn: 331394
2018-05-02 20:06:17 +00:00
Adrian Prantl 6e9f77126b Silence compiler warning.
llvm-svn: 331375
2018-05-02 17:11:43 +00:00
Pavel Labath 47776cbd2c Fix gdb-remote qMemoryRegionInfo unit tests for xml-enabled builds
In case we are building with xml enabled, the GetMemoryRegionInfo
function will send extra packets to query te extended memory map, which
the tests were not expecting.

Add an expectation for this to the test. Right now, it's just a basic
one which pretends we don't support the extension, however, it would be
also interesting the add a test which verifies the extension-enabled
case.

I also noticed that the test does a pretty lousy job of validating the
returned memory region info, so I add a couple of extra assertions to
improve that.

llvm-svn: 331374
2018-05-02 17:00:33 +00:00