Commit Graph

17603 Commits

Author SHA1 Message Date
Alexander Polyakov 44a060f8d6 [lldb, lldb-mi] Re-implement MI -exec-continue command.
Summary: Now -exec-continue command uses SB API to resume target's process.

Reviewers: aprantl, clayborg, labath

Reviewed By: clayborg

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

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

llvm-svn: 334350
2018-06-09 15:11:37 +00:00
Alex Langford 6500c693a5 Remove more dead code from NativeProcessLinux
This should have been removed in r334333.

llvm-svn: 334336
2018-06-08 22:28:41 +00:00
Alex Langford bd620effc8 Delete dead code in NativeProcessLinux
As far as I can tell, this code has always been guarded by `#if 0`. If
this is useful code, it can be added back.

llvm-svn: 334333
2018-06-08 22:14:29 +00:00
Alex Langford 9391061fd7 Delete some dead code
llvm-svn: 334320
2018-06-08 21:13:26 +00:00
Tatyana Krasnukha 74fd1a6587 Fix DynamicRegisterInfo copying/moving issue.
Summary:
Default copy/move constructors and assignment operators leave wrong m_sets[i].registers pointers.

Made the class movable and non-copyable (it's difficult to imagine when it needs to be copied).

Reviewers: clayborg

Reviewed By: clayborg

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

llvm-svn: 334282
2018-06-08 11:28:15 +00:00
Pavel Labath 982241097c Fix TestMiExec.py
r334215 changed the error message the tool prints for invalid thread
arguments to -exec-next command. This adjust the test to match that.

llvm-svn: 334279
2018-06-08 10:39:55 +00:00
Pavel Labath a3ee1e7f92 DebugNamesDWARFIndex: Implement regex version of the GetFunctions method
This also fixes a bug where SymbolFileDWARF was returning the same
function multiple times - this can happen if both mangled and demangled
names match the regex. Other lookup lookup functions had code to handle
this case, but it was forgotten here.

llvm-svn: 334277
2018-06-08 10:31:55 +00:00
Pavel Labath 257ff33989 DebugNamesDWARFIndex: Implement GetFunctions method
Summary:
This patch implements the non-regex variant of GetFunctions. To share
more code with the Apple implementation, I've extracted the common
filtering code from that class into a utility function on the DWARFIndex
base class.

The new implementation also searching the accelerator table multiple
times -- previously it could happen that the apple table would return
the same die more than once if one specified multiple search flags in
name_type_mask. This way, I separate table iteration from filtering, and
so we can be sure each die is inserted at most once.

Reviewers: clayborg, JDevlieghere

Subscribers: aprantl, lldb-commits

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

llvm-svn: 334273
2018-06-08 09:10:31 +00:00
Aaron Smith 010edd37f8 PDB support of function-level linking and splitted functions
Summary:
The patch adds support of splitted functions (when MSVC is used with PGO) and function-level linking feature.

SymbolFilePDB::ParseCompileUnitLineTable function relies on fact that ranges of compiled source files in the binary are continuous and don't intersect each other. The function creates LineSequence for each file and inserts it into LineTable, and implementation of last one relies on continuity of the sequence. But it's not always true when function-level linking enabled, e.g. in added input test file test-pdb-function-level-linking.exe there is xstring's std__basic_string_char_std__char_traits_char__std__allocator_char_____max_size (.00454820) between test-pdb-function-level-linking.cpp's foo (.00454770) and main (.004548F0).

To fix the problem this patch renews the sequence on each address gap.

Reviewers: asmith, zturner

Reviewed By: asmith

Subscribers: aleksandr.urakov, labath, mgorny, lldb-commits

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

llvm-svn: 334260
2018-06-08 02:45:25 +00:00
Raphael Isemann e535c14452 Added missing include to LoadedModuleInfoList.h
Subscribers: lldb-commits

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

llvm-svn: 334259
2018-06-08 02:00:27 +00:00
Alexander Polyakov f0f5175518 [lldb-mi] Add overloaded method for setting an error.
Reviewers: aprantl, clayborg

Reviewed By: clayborg

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 334245
2018-06-07 23:03:49 +00:00
Alex Langford 372e3d3e12 Remove commented out line from top-level CMakeLists.txt
llvm-svn: 334225
2018-06-07 20:17:46 +00:00
Zachary Turner 1f67a3cba9 [FileSystem] Split up the OpenFlags enumeration.
This breaks the OpenFlags enumeration into two separate
enumerations: OpenFlags and CreationDisposition.  The first
controls the behavior of the API depending on whether or not
the target file already exists, and is not a flags-based
enum.  The second controls more flags-like values.

This yields a more easy to understand API, while also allowing
flags to be passed to the openForRead api, where most of the
values didn't make sense before.  This also makes the apis more
testable as it becomes easy to enumerate all the configurations
which make sense, so I've added many new tests to exercise all
the different values.

llvm-svn: 334221
2018-06-07 19:58:58 +00:00
Alex Langford 05c10d0def Check for process_vm_readv using CheckSymbolExists
Instead of checking if code compiles, I think it is a better to check
if the symbol exists. This is simpler and should do the same thing.

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

llvm-svn: 334219
2018-06-07 19:53:25 +00:00
Alexander Polyakov 2b08ca76df [lldb-mi] Re-implement MI -exec-next command.
Summary: Now -exec-next command uses SB API for stepping over.

Reviewers: aprantl, clayborg, stella.stamenova, labath

Reviewed By: aprantl, clayborg, labath

Subscribers: labath, ki.stfu, lldb-commits

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

llvm-svn: 334215
2018-06-07 19:09:01 +00:00
Stella Stamenova c3bc63e54b [lit, windows] Disable a number of tests that are failing on Windows
Summary: They all correspond to bugs that are already logged and I've added the appropriate (or most appropriate) bug numbers. This leaves only a handful of failing tests.

Reviewers: asmith, zturner, labath

Reviewed By: zturner

Subscribers: eraman, llvm-commits

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

llvm-svn: 334210
2018-06-07 17:49:22 +00:00
Jonas Devlieghere e6f3ecd52c [Platform] Accept arbitrary kext variants
When loading kexts in PlatformDarwinKernel, we use the BundleID as the
filename to to create shared modules. In GetSharedModule we call
ExamineKextForMatchingUUID for any BundleID it finds that is a match, to
see if the UUID is also a match. Until now we were using
Host::ResolveExecutableInBundle which calls a CoreFoundation API to
obtain the executable. However, it's possible that the executable has a
variant suffix (e.g. foo_development) and these files were ignored.

This patch replaces that call with logic that looks for all the binaries
in the bundle. Because of the way ExamineKextForMatchingUUID works, it's
fine to try to load executables that are not valid and we can just
iterate over the list until we found a match.

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

llvm-svn: 334205
2018-06-07 16:10:42 +00:00
Pavel Labath d44638eb2b DIERef: move trivial constructors into the header
This enables more inlining/optimization opportunities for a fairly
critical class.

NFCI

llvm-svn: 334198
2018-06-07 14:03:30 +00:00
Pavel Labath 6938969223 DebugNamesDWARFIndex: Add type lookup suport
This implements just one of the GetTypes overloads. The other is not
testable from lldb-test so I'm leaving it unimplemented until I figure
out what to do with testing.

llvm-svn: 334190
2018-06-07 12:26:18 +00:00
Pavel Labath 6675e652a3 DebugNamesDWARFIndex: add namespace lookup support
llvm-svn: 334186
2018-06-07 10:56:16 +00:00
Pavel Labath 452bd87cc4 DebugNamesDWARFIndex: Add support for partial indexes
Summary:
It possible that a single module has indexed and non-indexed compile
units. In this case, we can use the fast indexed lookup for the first
ones and fall back to the manual index for the others.

This patch implements this functionality by adding a units_to_avoid
argument to the ManualDWARFIndex constructor. Any units present in that
list will be ignored for the purposes of manual index. Individual
DebugNamesDWARFIndex then always consult both the manual fallback index
as well as the index in the .debug_names section.

Reviewers: JDevlieghere, clayborg

Subscribers: aprantl, lldb-commits

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

llvm-svn: 334185
2018-06-07 10:35:28 +00:00
Pavel Labath e1d18758eb DebugNamesDWARFIndex: Add ability to lookup variables
Summary:
This patch adds the ability to lookup variables to the DWARF v5 index
class.

During review we discovered an inconsistency between how the existing
two indexes handle looking up qualified names of the variables:
- manual index would return a value if the input string exactly matched
  the demangled name of some variable.
- apple index ignored the context and returned any variable with the
  same base name.

So, this patch also rectifies that situation:
- it removes all context handling from the index classes. The
  GetGlobalVariables functions now just take a base name. For manual
  index, this meant we can stop putting demangled names into the
  variable index (this matches the behavior for functions).
- context extraction is put into SymbolFileDWARF, so that it is common
  to all indexes.
- additional filtering based on the context is also done in
  SymbolFileDWARF. This is done via a simple substring search, which is
  not ideal, but it matches what we are doing for functions (cf.
  Module::LookupInfo::Prune).

Reviewers: clayborg, JDevlieghere

Subscribers: aprantl, lldb-commits

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

llvm-svn: 334181
2018-06-07 10:04:44 +00:00
David Carlier 58d05a4d5f [LLDB] Unit tests / typo fix
removing unnecessary comma.

llvm-svn: 334177
2018-06-07 08:58:34 +00:00
Pavel Labath 9337b41cb5 [DWARF] Add (empty) DebugNamesDWARFIndex class and a setting to control its use
Summary:
This patch adds the skeleton for implementing the DWARF v5 name index
class. All of the methods are stubbed out and will be implemented in
subsequent patches. The interesting part of the patch is the addition of
a "ignore-file-indexes" setting to the dwarf plugin which enables a
user to force using manual indexing path in lldb (for example as a
debugging aid). I have also added a test that verifies that file indexes
are used by default.

Reviewers: JDevlieghere, clayborg, jingham

Subscribers: mgorny, mehdi_amini, aprantl, lldb-commits

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

llvm-svn: 334088
2018-06-06 11:35:23 +00:00
Michal Gorny 6dde836844 [lit] Do not run Python tests w/ LLDB_DISABLE_PYTHON
Skip all Python-based tests as unsupported when LLDB_DISABLE_PYTHON is
enabled.  Otherwise, those tests simply fail being unable to import lldb
module.

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

llvm-svn: 334080
2018-06-06 09:44:14 +00:00
Pavel Labath 5583ec4218 Revert "PDB support of function-level linking and splitted functions"
This reverts commit r334030 because it adds a broken test.

llvm-svn: 334076
2018-06-06 09:16:00 +00:00
Aaron Smith a642f8f343 PDB support of function-level linking and splitted functions
Summary:
The patch adds support of splitted functions (when MSVC is used with PGO) and function-level linking feature.

SymbolFilePDB::ParseCompileUnitLineTable function relies on fact that ranges of compiled source files in the binary are continuous and don't intersect each other. The function creates LineSequence for each file and inserts it into LineTable, and implementation of last one relies on continuity of the sequence. But it's not always true when function-level linking enabled, e.g. in added input test file test-pdb-function-level-linking.exe there is xstring's std__basic_string_char_std__char_traits_char__std__allocator_char_____max_size (.00454820) between test-pdb-function-level-linking.cpp's foo (.00454770) and main (.004548F0).

To fix the problem this patch renews the sequence on each address gap.

Reviewers: asmith, zturner

Reviewed By: asmith

Subscribers: mgorny, lldb-commits

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

llvm-svn: 334030
2018-06-05 17:19:21 +00:00
Stella Stamenova f2c14af389 [lit, pdb] Fix func-symbols.test (on Windows)
Summary: This test was failing sporadically on windows because the order in which the symbols are generated was different between builds. To fix the test, we need to run FileCheck twice - once for each set of symbols we want to verify. The test only runs on Windows.

Reviewers: asmith, zturner, labath

Subscribers: stella.stamenova, llvm-commits

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

llvm-svn: 334025
2018-06-05 16:20:36 +00:00
Pavel Labath 6de9c79e71 DWARFIndex: more GetFunctions cleanup
This applies similar simplification as r334004, only it touches the
regex version of the method.

llvm-svn: 334012
2018-06-05 12:13:22 +00:00
Pavel Labath 663773857f dotest: make inline tests compatible with -f
Summary:
This is split off from D47265 where I needed to be able to invoke every test
with -f. That patch is kinda dead now, but this part seems like a good
cleanup anyway.

The problem with inline tests was in the way we were adding methods to
the class, which left them with an incorrect __name__ property. This
prevented dotest from finding them with -f.

I fix this with (what I think is) the correct way of dynamically
creating classes -- passing the list of methods during type construction
instead of fixing up the class afterwards. Among other things this has
the advantage of not needing to do anything special for debug info
variants. As our test method will be visible to the metaclass, it will
automagically do the multiplication for us.

Reviewers: JDevlieghere, aprantl, tberghammer

Subscribers: eraman, lldb-commits

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

llvm-svn: 334009
2018-06-05 10:58:44 +00:00
Pavel Labath df4ca0eeda Fix windows build broken by r334004
The problem was a link error due to a missing =0 on an abstract method.
Interestingly, this was not a problem for clang/linux.

llvm-svn: 334006
2018-06-05 10:49:56 +00:00
Pavel Labath 5af11ab259 DWARFIndex: simplify GetFunctions methods
Now that Apple index determines method-ness straight from the debug
info, we don't need to resolve the functions into SymbolContexts inside
the Index classes. This removes the need for callback arguments and
allows us to pull the common parts out of the two implementations of
these functions back into the SymbolFileDWARF class.

Reviewers: JDevlieghere, clayborg

Subscribers: aprantl, lldb-commits

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

llvm-svn: 334004
2018-06-05 10:33:56 +00:00
Pavel Labath 4e34bfcbeb Really fix ClangParserTest
It turns out the test needs a fixture after all (to initialize HostInfo), so
provide one that does that.

llvm-svn: 334003
2018-06-05 10:29:48 +00:00
Ilya Biryukov fc48ac61fa Silence unhandled enums warning in ClangASTContext::GetEncoding
The warning started firing after r333923, which added new builtin
types (fixed point types) into clang.
This patch merely silences the warning to unblock our integrate, does
not aim to support the new types in lldb.

llvm-svn: 333999
2018-06-05 10:07:07 +00:00
Pavel Labath 3489b1adb3 Fixup r333987
- add #include <atomic> (fixes windows build)
- remove std::move (fixes "using move prevents copy ellision" warnings)

llvm-svn: 333996
2018-06-05 09:56:14 +00:00
Pavel Labath 8d1421d317 Fix ClangParserTest.cpp
The test does not use a test fixture, so it needs to be declared with
the TEST macro.

llvm-svn: 333992
2018-06-05 09:33:26 +00:00
Jan Kratochvil c8e357f796 Protect DWARFCompileUnit::m_die_array by new mutexes
If BuildAddressRangeTable called ExtractDIEsIfNeeded(false), then another
thread started processing data from m_die_array and then the first thread
called final ClearDIEs() the second thread would crash.

It is also required without multithreaded debugger using DW_TAG_partial_unit
for DWZ.

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

llvm-svn: 333987
2018-06-05 08:52:18 +00:00
Jonas Devlieghere a54df26ace Fix Expression unittests on Darwin
Fixes the Expression unittests on Darwin after r333933 was landed.

llvm-svn: 333974
2018-06-05 00:32:41 +00:00
Jim Ingham 34b6798ee2 Add ClangHost.cpp to the Xcode project.
Also add an include that was needed for the if APPLE branch
of the function.

llvm-svn: 333971
2018-06-05 00:19:03 +00:00
Alex Langford 59ad87821a Change SWIG output directory when building LLDB.framework with CMake
Instead of assuming that SWIG generated files (e.g. lldb.py) will live
in scripts, we should set it to $LLDB_PYTHON_TARGET_DIR. This variable is set to
scripts, except when building LLDB.framework when it is set to
LLDB_FRAMEWORK_DIR.

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

llvm-svn: 333968
2018-06-04 23:47:36 +00:00
Alexander Polyakov aa65168419 [lldb, lldb-mi] Enable lldb-mi -break-insert test on Windows.
Summary:
The default name for a compiler output on Linux is `a.out`,
while on Windows it's `a.exe`. But if we add option `-o a.exe`,
the compiler will create the executable `a.exe` on the both systems.

Reviewers: aprantl, stella.stamenova

Reviewed By: stella.stamenova

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

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

llvm-svn: 333963
2018-06-04 22:39:40 +00:00
Zachary Turner bdf089246e Remove dependency from Host to clang.
Host depended on clang because HostInfo had a function to get
the directory where clang was installed.  We move this over to
the clang expression parser plugin where it's more at home.

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

llvm-svn: 333933
2018-06-04 17:41:00 +00:00
Vedant Kumar c418b5cc25 [IRMemoryMap] Use labels in the "malloc" and "free" lldb-test commands
Change the syntax of the malloc and free commands in lldb-test's
ir-memory-map subcommand to:

  <malloc> ::= <label> = malloc <size> <alignment>

  <free> ::= free <label>

This should make it easier to read and extend tests in the future, e.g
to test IRMemoryMap::WriteMemory or double-free behavior.

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

llvm-svn: 333930
2018-06-04 17:11:15 +00:00
David Carlier 04bea33e8c [LLDB] Unit tests basic support for OpenBSD
OpenBSD python module.

llvm-svn: 333889
2018-06-04 11:59:18 +00:00
David Carlier 15aefbd3f6 [LLDB] Unit tests basic support for OpenBSD
Add OpenBSD python module in order to support unit tests.

Reviewers: labath, zturner

Reviewed By: labath

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

llvm-svn: 333888
2018-06-04 11:57:12 +00:00
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
Adrian Prantl d8f460e864 Enable AUTOBRIEF in doxygen configuration.
This brings the LLDB configuration closer to LLVM's and removes visual
clutter in the source code by removing the @brief commands from
comments.

This patch also reflows the paragraphs in all doxygen comments.

See also https://reviews.llvm.org/D46290.

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

llvm-svn: 331373
2018-05-02 16:55:16 +00:00
Pavel Labath e222d92707 Predicate.h: remove unused functions
The functions are unused, their comments are out of date with the
implementation, and the implementation is out of date with the rest of the code
base (it uses seconds(0) to mean infinite wait, whereas elsewhere we use the
Timeout class).

llvm-svn: 331350
2018-05-02 13:14:18 +00:00
Richard Smith 51d12d8885 Update lldb to match clang r331244 (addition of char8_t).
Also fix misclassification of char16_t and char32_t: these are unsigned types,
not signed types.

llvm-svn: 331323
2018-05-02 02:43:22 +00:00
Jason Molenda b81afd6598 Fix the .experimental. settings feature so that we don't return an error
if an experimental setting has been removed/is missing.

Add tests for the .experimental. settings behaviors -- that they correctly
forward through to the real setting if it has become a real setting,
that they don't generate errors when a settig has been removed.

As Pavel notes in https://reviews.llvm.org/D45348, the way I'm suppressing
errors in the setting is not completely correct - if any of the setting
path components include "experimental", a missing setting would be declared
a non-error.  So

settings set target.experimental.setting-that-does-not-exist true

would not generate an error, which is correct.  But as Pavel notes, 

settings set setting-does-not-exist.experimental.run-stopped true

should generate an error because the unknown name occurs before the
"experimental".  The amount of change to do this correctly hasn't
thrilled me, so I'm leaving this as-is for now.

<rdar://problem/39223054> 
Differential Revision: https://reviews.llvm.org/D45348

llvm-svn: 331315
2018-05-01 22:49:01 +00:00
Jonas Devlieghere 5a3c9ee93d Revert "[lit] Replace generator expressions in lit.site.cfg"
Using GENERATE breaks generators that support multiple configurations,
e.g. MSVC. Reverting for now until we find a better solution.

llvm-svn: 331285
2018-05-01 17:08:09 +00:00
Jonas Devlieghere 42b8d26414 [lit] Replace generator expressions in lit.site.cfg
The lit site configuration for the test suite can contain generator
expressions such as $<TARGET_FILE:debugserver> that need to be
substituted.

llvm-svn: 331277
2018-05-01 16:19:48 +00:00
Adrian Prantl e757ddaf3d Remove redundant command.
llvm-svn: 331270
2018-05-01 15:38:01 +00:00
Pavel Labath c1a775419f Split TestGlobalVariables into two and xfail one of them for arm64 linux
Displaying of global pointer variables is not working on arm64 linux
(pr37301).

I've moved this part into a separate test, so it can be xfailed
separately. I then move the "show-variables-with-process-available"
check before the "show-all-variables" command to presrve the intent of
checking that global variable caching works correctly. (I've verified
that the new arrangement still fails when I revert the fix from
r331230.)

llvm-svn: 331250
2018-05-01 10:09:53 +00:00
Eugene Zemtsov 09a1a39874 Fix type_lookup test to make buildbots happy
llvm-svn: 331242
2018-05-01 03:06:05 +00:00
Jason Molenda 3678be89f7 Log to the process channel, not target twice.
llvm-svn: 331239
2018-05-01 00:42:17 +00:00
Jason Molenda c9f7939121 Add logging when ArchSpec::SetArchitecture is given a cputype and
cpusubtype that don't map to any known core definition.

<rdar://problem/39779398> 

llvm-svn: 331236
2018-05-01 00:05:54 +00:00
Adrian Prantl 03219f7f64 Refactor GetNextPersistentVariableName into a non-virtual method
that takes a prefix string. This simplifies the implementation and
allows plugins such as the Swift plugin to supply different prefixes
for return and error variables.

rdar://problem/39299889

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

llvm-svn: 331235
2018-04-30 23:59:17 +00:00
Adrian Prantl 5435f78046 Move the persistent variable counter into Target
so it can be shared across multiple language plugins.

In a multi-language project it is counterintuitive to have a result
variables reuse numbers just because they are using a different
language plugin in LLDB (but not for example, when they are
Objective-C versus C++, since they are both handled by Clang).

This is NFC on llvm.org except for the Go plugin.

rdar://problem/39299889

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

llvm-svn: 331234
2018-04-30 23:59:15 +00:00
Adrian Prantl ce05952943 Remove premature caching of the global variables list in CompileUnit.
This fixes a bug where

  (lldb) target var g_ptr

would populate the global variables list with exactly one entry
because SymbolFileDWARF::ParseVariables() was invoked with a list of
DIEs pre-filtered by name, such that a subsequent call to

  (lldb) fr var --show-globals

would only list that one variable, because CompileUnit::m_variables
was already initialized, fooling CompileUnit::GetVariableList().

CompileUnit::GetVariableList() grabs the *complete* list of variables
via (SymbolFileDWARF, ...)::ParseVariablesForContext and that still
calls CompileUnit::SetVariableList(variables) which acts as the
caching mechanism.

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

llvm-svn: 331230
2018-04-30 21:54:02 +00:00
Jan Kratochvil 32f2d0e564 Protect DWARFCompileUnit::m_die_array by a new mutex
Multiple DW_TAG_compile_unit being indexed in a multithreaded way can request
reading of the same DW_TAG_partial_unit.

Unfortunately one cannot detect DWZ file ahead of time to disable such locking
overhead as DWARFCompileUnit::Extract does not read the first DIE which is the
only place one could find early enough if the DWARF file is using any
DW_TAG_partial_unit.

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

llvm-svn: 331229
2018-04-30 21:37:30 +00:00
Greg Clayton c485f056b7 Fix expression parser to not accept any type whose basename matches for a type that must exist at root level
This patch fixes an issue where we weren't looking for exact matches in the expression parser and also fixed the type lookup logic in the Module.cpp. Tests added to make sure we don't regress.

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

llvm-svn: 331227
2018-04-30 21:06:30 +00:00
Adrian Prantl 05097246f3 Reflow paragraphs in comments.
This is intended as a clean up after the big clang-format commit
(r280751), which unfortunately resulted in many of the comment
paragraphs in LLDB being very hard to read.

FYI, the script I used was:

import textwrap
import commands
import os
import sys
import re
tmp = "%s.tmp"%sys.argv[1]
out = open(tmp, "w+")
with open(sys.argv[1], "r") as f:
  header = ""
  text = ""
  comment = re.compile(r'^( *//) ([^ ].*)$')
  special = re.compile(r'^((([A-Z]+[: ])|([0-9]+ )).*)|(.*;)$')
  for line in f:
      match = comment.match(line)
      if match and not special.match(match.group(2)):
          # skip intentionally short comments.
          if not text and len(match.group(2)) < 40:
              out.write(line)
              continue

          if text:
              text += " " + match.group(2)
          else:
              header = match.group(1)
              text = match.group(2)

          continue

      if text:
          filled = textwrap.wrap(text, width=(78-len(header)),
                                 break_long_words=False)
          for l in filled:
              out.write(header+" "+l+'\n')
              text = ""

      out.write(line)

os.rename(tmp, sys.argv[1])

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

llvm-svn: 331197
2018-04-30 16:49:04 +00:00
Jan Kratochvil 55c84b1a4e Match also DW_TAG_partial_unit when DW_TAG_compile_unit is matched
Code commonly checks if the parent DIE is DW_TAG_compile_unit.
But DW_TAG_partial_unit also acts as DW_TAG_compile_unit for DWZ
as DWZ is using DW_TAG_imported_unit only at the top unit level.

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

llvm-svn: 331194
2018-04-30 16:04:32 +00:00
Pavel Labath d2f36c864e llgs tests: Use noack-mode for communication to avoid pr37294
llvm-svn: 331180
2018-04-30 14:30:02 +00:00
Pavel Labath edb0127629 ObjectFileELF: Add support for arbitrarily named code sections
ObjectFileELF assumes that code section has ".text" name. There is an
exception for kalimba toolchain that can use arbitrary names, but other
toolchains also could use arbitrary names for code sections. For
example, corert uses separate section for compiled managed code. As lldb
doesn't recognize such section it leads to problem with breakpoints on
arm, because debugger cannot determine instruction set (arm/thumb) and
uses incorrect breakpoint opcode that breaks program execution.

This change allows debugger to correctly handle such code sections. We
assume that section is a code section if it has SHF_EXECINSTR flag set
and has SHT_PROGBITS type.

Patch by Konstantin Baladurin <k.baladurin@partner.samsung.com>.
Differential Revision: https://reviews.llvm.org/D44998

llvm-svn: 331173
2018-04-30 13:23:47 +00:00
Pavel Labath 410c5acf27 Fixup r331049 (FileSpec auto-normalization)
A typo in the patch (using syntax instead of m_syntax) resulted in the
normalization not working properly for windows filespecs when the syntax
was passed as host-native. This did not affect the unit tests, as all of
those pass an explicity syntax, but failed gloriously when running the
full test suite.

I also fix an expectation in an lldb-mi test, which was now failing
because it was expecting a path to be echoed verbatim, but we were now
normalizing it.

As a drive-by, this also fixes the default-in-fully-covered-switch
warning and removes an unused argument from the NeedsNormalization
function.

llvm-svn: 331172
2018-04-30 12:59:14 +00:00
Jan Kratochvil e4777a9df5 Support reading section ".gnu_debugaltlink"
Differential revision: https://reviews.llvm.org/D40468

llvm-svn: 331148
2018-04-29 19:47:48 +00:00
Greg Clayton 27a0e10a3e Fix build bots after r331049 broke them.
llvm-svn: 331082
2018-04-27 21:10:07 +00:00
Frederic Riss 60b94c296e [debugserver] Fix the G packet handling.
Of course r331004 needed a counterpart on the write side.

llvm-svn: 331073
2018-04-27 19:59:42 +00:00
Greg Clayton 776cd7ad44 Always normalize FileSpec paths.
Always normalizing lldb_private::FileSpec paths will help us get a consistent results from comparisons when setting breakpoints and when looking for source files. This also removes a lot of complexity from the comparison routines. Modified the DWARF line table parser to use the normalized compile unit directory if needed.

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

llvm-svn: 331049
2018-04-27 15:45:58 +00:00
Frederic Riss ffb8d8711c Mark test as @skipIfOutOfTreeDebugserver
This test will currently fail for people using the system debugserver.

llvm-svn: 331043
2018-04-27 15:30:09 +00:00
Jim Ingham 93979f67f8 Fix a thinko in the iteration over StructuredDataPlugin Create functions.
The code was grabbing the first plugin, and then never getting
another one.

<rdar://problem/39779438>

llvm-svn: 331012
2018-04-27 01:57:40 +00:00
Frederic Riss 34ec0bfb5e [debugserver] Fix handling of the 'g' packet
LLDB doesn't use this packet so we never hit this, but it looks like
some other projects talk to debugserver and are hitting an assert
(https://github.com/derekparker/delve/issues/1015).

We had an off by 1 in the accounting of the FPU structure sizes.
I added a test that basically just check that 'g' doesn't return
an error (currently it assert in debug builds). I didn't make
it an lldb-server test because it looks like lldb-server doesn't
implement the g packet.

llvm-svn: 331004
2018-04-27 00:09:04 +00:00
Frederic Riss 05e8bc85e6 [debugserver] Return 'ios' instead of 'iphoneos' for the ostype.
When I merged the 2 codepaths that return an OS type, I hade
checked that the places accepting 'iphoneos' would also accept
'ios', but then I got it backwards and return 'iphoneos'.

We use this value to build triples, and there 'iphoneos' is
invalid.

This also makes the test slightly simpler.

llvm-svn: 330877
2018-04-25 22:12:12 +00:00
Benjamin Kramer 0d97c225cd Fix -Wswitch warning after r330790.
source/Symbol/ClangASTContext.cpp:391:13: error: enumeration value 'HIP' not handled in switch [-Werror,-Wswitch]
    switch (IK.getLanguage()) {

llvm-svn: 330823
2018-04-25 13:22:47 +00:00
Aaron Smith ba48c9bde1 [lit, lldbsuite] Update the lldbsuite to correctly run tests on windows and windows server
Summary:
The new script to run the lldbtests as part of lit invokes each test by calling dotest.py, however, we cannot rely on the system to always correctly interpret the script as python causing the tests to be unresolved on windows (at least). To fix this, we need to make sure that the first parameter in the command line is the python executable itself.

In Makefile.rules, there are a number of windows specific definitions that rely on the HOST_OS being set as Windows_NT but the logic detecting the OS currently does not detect server versions of windows correctly. This change updates the logic to detect windows server as well.

Reviewers: asmith, labath, JDevlieghere, zturner

Reviewed By: JDevlieghere, zturner

Subscribers: zturner, llvm-commits

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

llvm-svn: 330740
2018-04-24 17:08:05 +00:00
Pavel Labath fdfeefd6c2 [dotest] Make the set of tests independent of the test configuration
Summary:
In the magic test duplicator, we were making the decision whether to
create a test variant based on the compiler and the target platform.
This meant that the set of known tests was different for each test
configuration.

This patch makes the set of generated test variants static and handles
the skipping via runtime checks instead. This is more consistent with
how we do other test-skipping decision (e.g. for libc++ tests), and
makes it easier to expose the full set of tests to lit, which now does
not need to know anything about what things can potentially cause tests
to appear or disappear.

Reviewers: JDevlieghere, aprantl

Subscribers: eraman, lldb-commits

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

llvm-svn: 330708
2018-04-24 10:51:44 +00:00
Davide Italiano e8643a0c91 [CMake] Add the missing `dsymutil` dependency when running tests.
llvm-svn: 330617
2018-04-23 17:06:55 +00:00
Pavel Labath 691d134805 llgs-tests: Increase packet time out
The default packet timeout of 1 second is a bit too small for these
tests, particularly as they are working in ack-mode, which means they
need to fit twice as many packets into the timeslot.

This does not seem to be a problem on the bots, but for some people
these tests are timing out regularly. I can't be sure increasing this
will solve their problem, but this does seem like a likely culprit.

llvm-svn: 330578
2018-04-23 11:22:44 +00:00
Jonas Devlieghere 0d5c5936cb [CMake] Gate 'dsymutil' dependency
Only add `dsymutil` as a test dependency when this is not a stand-alone
build (LLDB_BUILT_STANDALONE).

llvm-svn: 330568
2018-04-23 08:44:06 +00:00
Jonas Devlieghere 49f4aee0e3 [lit] Generate a single lit cfg file for tests that require dotest.py
The current way that the lit configuration is generated for the LLDB
tests that run using dotest causes cmake to fail when using a generator
which supports multiple configurations (such as Visual Studio). The
failure is because file GENERATE will create a file *per possible
configuration* resulting in the same lit configuration file being
overwritten multiple times.

To fix the issue, we need to create a single lit file that is agnostic
of the configurations and can be used for any configuration.

Patch by: Stella Stamenova

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

llvm-svn: 330518
2018-04-21 18:23:04 +00:00
Ed Maste eda6432de6 Temporarily skip Go TestExpressions on FreeBSD as it hangs
llvm.org/pr37194

llvm-svn: 330504
2018-04-21 13:59:07 +00:00
Ed Maste 592d29a3b9 FreeBSD: propagate error to user if memory access fails
Previously, an attempt to read an unreadable address reported zeros.
Now, if DoReadMemory or DoWriteMemory encounters error then return 0
(bytes read or written) so that the error is reported to the user.

llvm.org/pr37190

llvm-svn: 330500
2018-04-21 11:23:56 +00:00
Jim Ingham e477eb6680 Fix the Xcode gtest target for the move of FileSpecTest.cpp.
llvm-svn: 330460
2018-04-20 18:30:31 +00:00
Adrian Prantl 690c828b0b Fix a crash when resolving overloads of C++ virtual methods.
The isOverload() method needs to account for situations where the two
methods being compared don't have the same number of arguments.

rdar://problem/39542960

llvm-svn: 330450
2018-04-20 17:14:05 +00:00
Pavel Labath 0e0906c221 Move FileSpecTest to Utility
FileSpec class was moved to the Utility module a while ago, but the test
file was left behind. This corrects that.

llvm-svn: 330405
2018-04-20 08:27:27 +00:00
Davide Italiano 981ec1d199 [DWARFASTParserClang] Remove dead code. NFCI.
llvm-svn: 330385
2018-04-20 00:44:33 +00:00
Adrian McCarthy 4ee16bfff7 Fix narrowing warning by appending `f` to literal constant.
llvm-svn: 330354
2018-04-19 18:31:57 +00:00
Pavel Labath 5976f30821 Attempt to fix TestMiniDump on windows
It was failing because the modules names were coming out as
C:\Windows\System32/MSVCP120D.dll (last separator is a forward slash) on
windows.

There are two issues at play here:
- the first problem is that the paths in minidump were being parsed as a
  host path. This meant that on posix systems the whole path was
  interpreted as a file name.
- on windows the path was split into a directory-filename pair
  correctly, but then when it was reconsituted, the last separator ended
  up being a forward slash because SBFileSpec.fullpath was joining them
  with '/' unconditionally.

I fix the first issue by parsing the minidump paths according to the
path syntax of the host which produced the dump, which should make the
test behavior on posix&windows identical. The last path will still be a
forward slash because of the second issue. We should probably fix the
"fullpath" property to do something smarter in the future.

llvm-svn: 330314
2018-04-19 09:38:42 +00:00
Leonard Mosescu 47196a25bb Improve LLDB's handling of non-local minidumps
Normally, LLDB is creating a high-fidelity representation of a live
process, including a list of modules and sections, with the 
associated memory address ranges. In order to build the module and
section map LLDB tries to locate the local module image (object file)
and will parse it.

This does not work for postmortem debugging scenarios where the crash
dump (minidump in this case) was captured on a different machine.

Fortunately the minidump format encodes enough information about
each module's memory range to allow us to create placeholder modules.
This enables most LLDB functionality involving address-to-module
translations.

Also, we may want to completly disable the search for matching
local object files if we load minidumps unless we can prove that the
local image matches the one from the crash origin.
(not part of this change, see: llvm.org/pr35193)

Example: Identify the module from a stack frame PC:

Before:
  thread #1, stop reason = Exception 0xc0000005 encountered at address 0x164d14
    frame #0: 0x00164d14
    frame #1: 0x00167c79
    frame #2: 0x00167e6d
    frame #3: 0x7510336a
    frame #4: 0x77759882
    frame #5: 0x77759855

After:
  thread #1, stop reason = Exception 0xc0000005 encountered at address 0x164d14
    frame #0: 0x00164d14 C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe
    frame #1: 0x00167c79 C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe
    frame #2: 0x00167e6d C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe
    frame #3: 0x7510336a C:\Windows\SysWOW64\kernel32.dll
    frame #4: 0x77759882 C:\Windows\SysWOW64\ntdll.dll
    frame #5: 0x77759855 C:\Windows\SysWOW64\ntdll.dll

Example: target modules list

Before:
error: the target has no associated executable images

After:
[ 0] C:\Windows\System32\MSVCP120D.dll 
[ 1] C:\Windows\SysWOW64\kernel32.dll 
[ 2] C:\Users\amccarth\Documents\Visual Studio 2013\Projects\fizzbuzz\Debug\fizzbuzz.exe 
[ 3] C:\Windows\System32\MSVCR120D.dll 
[ 4] C:\Windows\SysWOW64\KERNELBASE.dll 
[ 5] C:\Windows\SysWOW64\ntdll.dll

NOTE: the minidump format also includes the debug info GUID, so we can
fill-in the module UUID from it, but this part was excluded from this change
to keep the changes simple (the LLDB UUID is hardcoded to be either 16 or
20 bytes, while the CodeView GUIDs are normally 24 bytes)

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

llvm-svn: 330302
2018-04-18 23:10:46 +00:00
Jonas Devlieghere 1a928f3fc7 [LIT] Have lit run the lldb test suite
This is the first in what will hopefully become a series of patches to
replace the driver logic in dotest.py with LIT. The motivation for this
change is that there's no point in maintaining two driver
implementations. Since all of the LLVM projects are using lit, this is
the obvious choice.

Obviously the goal is maintain full compatibility with the functionality
offered by dotest. As such we won't be removing anything until that
point has been reached.

This patch is the initial attempt (referred to as v1) to run the lldb
test suite with lit. To do so we introduced a custom LLDB test format
that invokes dotest.py with a single test file.

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

llvm-svn: 330275
2018-04-18 17:08:49 +00:00
Pavel Labath acebc43799 Report more precise error message when attach fails
Summary:
If the remote stub sends a specific error message instead of just a E??
code, we can use this to display a more informative error message
instead of just the generic "unable to attach" message.

I write a test for this using the SB API.
On the console this will show up like:
(lldb) process attach ...
error: attach failed: <STUB-MESSAGE>

if the stub supports error messages, or:
error: attach failed: Error ??

if it doesn't.

Reviewers: jingham, JDevlieghere

Subscribers: lldb-commits

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

llvm-svn: 330247
2018-04-18 11:56:21 +00:00
Jim Ingham 1ecb34f4ab Change PlatformPosix::DoLoadImage to use a UtilityFunction.
That way we won't have to compile a new expression every time we want
dlopen a library.

<rdar://problem/32626584> 

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

llvm-svn: 330214
2018-04-17 20:44:47 +00:00
Jim Ingham 8db2d1cbdf Fix the xcode project for the Args -> Utility move.
llvm-svn: 330211
2018-04-17 20:35:00 +00:00
Pavel Labath 145d95c964 Move Args.cpp from Interpreter to Utility
Summary:
The Args class is used in plenty of places besides the command
interpreter (e.g., anything requiring an argc+argv combo, such as when
launching a process), so it needs to be in a lower layer. Now that the
class has no external dependencies, it can be moved down to the Utility
module.

This removes the last (direct) dependency from the Host module to
Interpreter, so I remove the Interpreter module from Host's dependency
list.

Reviewers: zturner, jingham, davide

Subscribers: mgorny, lldb-commits

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

llvm-svn: 330200
2018-04-17 18:53:35 +00:00
Davide Italiano 080aa11c31 [Statistics] Relax the test output a little bit.
We don't really care about the order as this is a dictionary.
It should be more resilient to changes (adding/shuffling stats
around).

Pointed out by Jason Molenda in a post-commit review (thanks Jason).

llvm-svn: 330170
2018-04-16 23:59:01 +00:00
Davide Italiano 4a6a2b1ce3 [Commands] Expose statistics through the SBAPI.
The API is `SBStructuredData GetStatistics()`. This allows
the command to be used in scripts.

<rdar://problem/36555975>

llvm-svn: 330165
2018-04-16 22:55:34 +00:00
Eugene Zemtsov 9b294d1e90 Make sure deleting all breakpoints clears their sites first
Bug: https://bugs.llvm.org/show_bug.cgi?id=36430

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

llvm-svn: 330163
2018-04-16 22:26:21 +00:00
Davide Italiano 58d5e0c068 [lldb-private] Mark a function as inline to prevent multiple def errors.
llvm-svn: 330149
2018-04-16 19:07:14 +00:00
Davide Italiano 70539360e6 [Statistics] Move GetStatDescription to an header file.
In preparation for using it in the API.

<rdar://problem/36555975>

llvm-svn: 330147
2018-04-16 18:25:57 +00:00