Commit Graph

10423 Commits

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

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

<rdar://problem/38570146> 

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

Fixes rdar://problem/40147002

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

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

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

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

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

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

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

Reviewers: zturner, friss, clayborg, jingham

Subscribers: emaste, lldb-commits

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

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

llvm-svn: 334921
2018-06-18 04:34:33 +00:00
Benjamin Kramer 8ec242f895 One ShortFract ought to be enough for everyone.
llvm-svn: 334755
2018-06-14 19:20:48 +00:00
Fangrui Song a5e59c5481 Add remaining fixed-point types and saturated equivalents to fix -Wswitch of r334718
llvm-svn: 334745
2018-06-14 18:19:40 +00:00
Pavel Labath 234c681686 DebugNamesDWARFIndex: fix handling of compressed sections
This fixes a silly bug where we were accidentally freeing the memory
used to store the decompressed .debug_names data. I had actually
considered this scenario when writing the class and put appropriate
precautions in place -- I just failed to wire it all up correctly.

This was only an issue for compressed sections because in case of
uncompressed ones we would access the data straight out of the mmapped
object file.

llvm-svn: 334717
2018-06-14 14:41:30 +00:00
Pavel Labath 9cf22d03dd Fix includes in PlatformAppleSimulator.h
This unbreaks the cmake build. Other plugins also use the include paths
starting with Plugins/..., so I am hoping this will work for the xcode build
too.

llvm-svn: 334697
2018-06-14 09:08:54 +00:00
Jason Molenda 8f4edde9aa fix cmake include path.
llvm-svn: 334680
2018-06-14 01:29:18 +00:00
Jason Molenda 4c53fffff9 Move the header file to be in the same new place as the .mm file.
llvm-svn: 334667
2018-06-13 22:37:01 +00:00
Jonas Devlieghere dd2f78e34c [FileSpec] Make style argument mandatory for SetFile. NFC
Fix SetFile uses in hosts that I missed in r334663.

llvm-svn: 334664
2018-06-13 22:23:48 +00:00
Jonas Devlieghere 937348cd13 [FileSpec] Make style argument mandatory for SetFile. NFC
SetFile has an optional style argument which defaulted to the native
style. This patch makes that argument mandatory so clients of the
FileSpec class are forced to think about the correct syntax.

At the same time this introduces a (protected) convenience method to
update the file from within the FileSpec class that keeps the current
style.

These two changes together prevent a potential pitfall where the style
might be forgotten, leading to the path being updated and the style
unintentionally being changed to the host style.

llvm-svn: 334663
2018-06-13 22:08:14 +00:00
Jason Molenda 07570f55e4 Fix macos xcode build.
llvm-svn: 334662
2018-06-13 22:05:38 +00:00
Stella Stamenova 9d6fabf9e3 [lit] Split test_set_working_dir TestProcessLaunch into two tests and fix it on Windows
Summary:
test_set_working_dir was testing two scenario: failure to set the working dir because of a non existent directory and succeeding to set the working directory. Since the negative case fails on both Linux and Windows, the positive case was never tested. I split the test into two which allows us to always run both the negative and positive cases. The positive case now succeeds on Linux and the negative case still fails.
During the investigation, it turned out that lldbtest.py will try to execute a process launch command up to 3 times if the command failed. This means that we could be covering up intermittent failures by running any test that does process launch multiple times without ever realizing it. I've changed the counter to 1 (though it can still be overwritten with the environment variable).
This change also fixes both the positive and negative cases on Windows. There were a few issues:
1) In ProcessLauncherWindows::LaunchProcess, the error was not retrieved until CloseHandle was possibly called. Since CloseHandle is also a system API, its success would overwrite any existing error that could be retrieved using GetLastError. So by the time the error was retrieved, it was now a success.
2) In DebuggerThread::StopDebugging TerminateProcess was called on the process handle regardless of whether it was a valid handle. This was causing the process to crash when the handle was LLDB_INVALID_PROCESS (0xFFFFFFFF).
3) In ProcessWindows::DoLaunch we need to check that the working directory exists before launching the process to have the same behavior as other platforms which first check the directory and then launch process. This way we also control the exact error string.

Reviewers: labath, zturner, asmith, jingham

Reviewed By: labath

Subscribers: llvm-commits

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

llvm-svn: 334642
2018-06-13 19:02:44 +00:00
Jonas Devlieghere 20b051ba41 [ObjC] Add dataformatter for NSDecimalNumber
This patch adds a data formatter for NSDecimalNumber. The latter is a
Foundation object used for representing and performing arithmetic on
base-10 numbers that bridges to Decimal.

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

llvm-svn: 334638
2018-06-13 18:47:04 +00:00
Jonas Devlieghere cb38fd644e [ObjC] Use llvm::StringRef in summary providers
Replace const char pointers with llvm::StringRef and use its equality
operator for string comparisons.

llvm-svn: 334631
2018-06-13 18:15:14 +00:00
Jonas Devlieghere 9c1a645adc [FileSpec] Simplify getting extension and stem.
As noted by Pavel on lldb-commits, we don't need the temp path, we can
just pass the filename directly into extension() and path().

llvm-svn: 334618
2018-06-13 16:36:07 +00:00
Jonas Devlieghere ad8d48f903 [FileSpec] Delegate common operations to llvm::sys::path
With the recent changes in FileSpec to use LLVM's path style, it is
possible to delegate a bunch of common path operations to LLVM's path
helpers. This means we only have to maintain a single implementation and
at the same time can benefit from the efforts made by the rest of the
LLVM community.

This is part one of a set of patches. There was no obvious way to split
this so I just worked from top to bottom.

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

llvm-svn: 334615
2018-06-13 16:23:21 +00:00
Adrian Prantl 4e8be2c98e Fix/unify the spelling of Objective-C.
llvm-svn: 334614
2018-06-13 16:21:24 +00:00
Raphael Isemann 2c77eefe85 Add modules support for lldb headers in include/
Summary:
This patch adds a modulemap which allows compiling the lldb headers into C++ modules
(for example in builds with LLVM_ENABLE_MODULES=On).

Even though most of the affected code has been cleaned up to work with the more strict
C++ module semantics, there are still some workarounds left in the current modulemap
(the most obvious one is the big `lldb` wrapper module).

It also moves the Obj-C++ files in lldb to their own subdirectories. This was necessary
because we need to filter out the modules flags for this code.

Note: With the latest clang and libstdc++ it seems necessary to have a STL C++ module
to get a working LLVM_ENABLE_MODULES build for lldb. Otherwise clang will falsely
detect ODR violations in the textually included STL code inside the lldb modules.

Reviewers: aprantl, bruno

Reviewed By: aprantl, bruno

Subscribers: mgorny, yamaguchi, v.g.vassilev, lldb-commits

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

llvm-svn: 334611
2018-06-13 15:50:45 +00:00
Raphael Isemann 5714504ab2 Disable warnings for the generated LLDB wrapper source
Summary:
This source files emits all kind of compiler warnings on different platforms. As the source code
in the file is generated and we therefore can't actually fix the warnings, we might as well disable
them.

Reviewers: aprantl, davide

Reviewed By: davide

Subscribers: davide, mgorny, lldb-commits

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

llvm-svn: 334557
2018-06-12 22:51:20 +00:00
Pavel Labath 0e33a0cd58 DebugNamesDWARFIndex: Implement DWARFDeclContext variant of GetTypes method
This method is used to find complete definitions of a type when one
parses a compile unit with only forward declaration available.

Since it is only accessed from DWARFASTParserClang, it was not
possible/easy to trigger this codepath from lldb-test. Therefore, I
adapt add a debug-names variant to an existing dotest test to cover this
scenario.

llvm-svn: 334516
2018-06-12 16:50:01 +00:00
Pavel Labath dc4bd2e441 DWARFDebugNames: Implement last GetGlobalVariables overload
This function implements the search for all global variables within a
given compilation unit.

llvm-svn: 334500
2018-06-12 13:11:25 +00:00
Jason Molenda 808490138b Document how lldb uses the DBGSourcePathRemapping
source path remapping src/dest path pairs with
respect to the DBGVersion number in the plist.

llvm-svn: 334442
2018-06-11 21:36:40 +00:00
Leonard Mosescu e1bb51789d Add a new SBTarget::LoadCore() overload which surfaces errors if the load fails
There was no way to find out what's wrong if SBProcess SBTarget::LoadCore(const char *core_file) failed. 
Additionally, the implementation was unconditionally setting sb_process, so it wasn't even possible to check if the return SBProcess is valid.

This change adds a new overload which surfaces the errors and also returns a valid SBProcess only if the core load succeeds:

SBProcess SBTarget::LoadCore(const char *core_file, SBError &error);

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

llvm-svn: 334439
2018-06-11 21:19:26 +00:00
Pavel Labath cb512a3072 Fix tuple getter in std unique pointer pretty-printer
Summary: Check case when _M_t child member is not present.

Reviewers: labath, tberghammer

Reviewed By: labath, tberghammer

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

llvm-svn: 334411
2018-06-11 14:52:52 +00:00
Pavel Labath 08dae4bb3c DWARFDebugNames: Fix lookup in dwo files
The getDIESectionOffset function is not correct for split dwarf files
(and will probably be removed in D48009).

This patch implements correct section offset computation for split and
non-split compile units -- we first need to check if the referenced unit
is a skeleton unit, and if it is, we add the die offset to the full unit
base offset (as the full unit is the one which contains the die).

llvm-svn: 334402
2018-06-11 13:22:31 +00:00
Pavel Labath d8c6290ba4 Move VersionTuple from clang/Basic to llvm/Support
Summary:
This kind of functionality is useful to other project apart from clang.
LLDB works with version numbers a lot, but it does not have a convenient
abstraction for this. Moving this class to a lower level library allows
it to be freely used within LLDB.

Since this class is used in a lot of places in clang, and it used to be
in the clang namespace, it seemed appropriate to add it to the list of
adopted classes in LLVM.h to avoid prefixing all uses with "llvm::".

Also, I didn't find any tests specific for this class, so I wrote a
couple of quick ones for the more interesting bits of functionality.

Reviewers: zturner, erik.pilkington

Subscribers: mgorny, cfe-commits, llvm-commits

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

llvm-svn: 334399
2018-06-11 10:28:04 +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 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
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
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
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
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
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