Commit Graph

16288 Commits

Author SHA1 Message Date
Pavel Labath 3f2a08183f [DWARFCallFrameInfo] Add Type enum to differentiate eh/debug_frame sections
Summary:
instead of using a boolean to differentiate between the two section
types, use an enum to make the intent clearer.

I also remove the RegisterKind argument from the constructor, as this
can be deduced from the Type argument.

Reviewers: clayborg, jasonmolenda

Subscribers: lldb-commits

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

llvm-svn: 306521
2017-06-28 09:09:19 +00:00
Ravitheja Addepally 2f797585b5 Linux unit tests should only run on
Linux based systems.

llvm-svn: 306520
2017-06-28 09:01:17 +00:00
Ravitheja Addepally 99e376956d Implementation of Intel(R) Processor Trace support for Linux
Summary:
This patch implements support for Intel(R) Processor Trace
in lldb server. The changes have support for
starting/stopping and reading the trace data. The code
is only available on Linux versions where the perf
attributes for aux buffers are available.

The patch also consists of Unit tests for testing the
core buffer reading function.

Reviewers: lldb-commits, labath, clayborg, zturner, tberghammer

Reviewed By: labath, clayborg

Subscribers: mgorny

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

llvm-svn: 306516
2017-06-28 07:58:31 +00:00
Kuba Mracek ad3d174674 Upstream the 'eInstrumentationRuntimeTypeSwiftRuntimeReporting' value of the 'eInstrumentationRuntimeType' enum from the swift-lldb project (to avoid potential clashes).
llvm-svn: 306469
2017-06-27 21:39:15 +00:00
Sean Callanan 5805d9e9ac [build system] If there's an OVERRIDE, don't guess the current SCM.
This makes automatic checkout work even in situations where the
current repository can't be determined, such as in the case of a 
Git tag.

llvm-svn: 306460
2017-06-27 20:35:53 +00:00
Jim Ingham 3f91be52c3 Fix up the Xcode project:
1) Renaming the InstrumentationRuntime directory & file names
2) Bunch of stuff moved from Core to Utility
3) Deleted a bunch of files records for files that have gone away

llvm-svn: 306445
2017-06-27 18:48:32 +00:00
Pavel Labath 7396ee923e Fix windows build for the Connection move
llvm-svn: 306400
2017-06-27 11:45:32 +00:00
Pavel Labath cdda23eb7c Add debug_frame section support
Summary:
This is a beefed-up version of D33504, which adds support for dwarf 4
debug_frame section format.

The main difference here is that the decision whether to use eh_frame or
debug_frame is done on a per-function basis instead of per-object file.
This is necessary because one module can contain both sections (for
example, the start files added by the linker will typically pull in
eh_frame), but we want to be able to access both, for maximum
information.

I also add unit test for parsing various CFI formats (eh_frame,
debug_frame v3 and debug_frame v4).

Reviewers: jasonmolenda, clayborg

Subscribers: mgorny, aprantl, abidh, lldb-commits, tatyana-krasnukha

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

llvm-svn: 306397
2017-06-27 11:16:26 +00:00
Pavel Labath f2a8bccf85 Move StructuredData from Core to Utility
Summary:
It had a dependency on StringConvert and file reading code, which is not
in Utility. I've replaced that code by equivalent llvm operations.

I've added a unit test to demonstrate that parsing a file still works.

Reviewers: zturner, jingham

Subscribers: kubamracek, mgorny, lldb-commits

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

llvm-svn: 306394
2017-06-27 10:45:31 +00:00
Pavel Labath 4ccd99541b Move Connection and IOObject interfaces to Utility module
Summary:
These interfaces have no dependencies, so it makes sense for them to be
in the lowest level modules, to make sure that other parts of the
codebase can use them without introducing loops.

The only exception here is the Connection::CreateDefaultConnection
method, which I've moved to Host, as it instantiates concrete
implementations, and that's where the implementations live.

Reviewers: jingham, zturner

Subscribers: lldb-commits, mgorny

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

llvm-svn: 306391
2017-06-27 10:33:14 +00:00
Pavel Labath 2a1c09fee9 Shorten sanitizer plugin names
Summary:
The new UndefinedBehaviorSanitizer plugin was breaking file path length
limits, because it's (fairly long name) appears multiple times in the
path. Cmake ends up putting the object file at path
tools/lldb/source/Plugins/InstrumentationRuntime/UndefinedBehaviorSanitizer/CMakeFiles/lldbPluginInstrumentationRuntimeUndefinedBehaviorSanitizer.dir/UndefinedBehaviorSanitizerRuntime.cpp.obj
which is 191 characters long and very dangerously close to the 260
character path limit on windows systems (also, just the include line for
that file was breaking the 80 character line limit).

This renames the sanitizer plugins to use shorter names (asan, ubsan,
tsan). I think this will still be quite understandable to everyone as
those are the names everyone uses to refer to them anyway.

Reviewers: zturner, kubamracek, jingham

Subscribers: lldb-commits, mgorny

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

llvm-svn: 306278
2017-06-26 08:13:22 +00:00
Zachary Turner aaea8ee628 Fix LLDB build.
This was broken due to directly including windows.h, which
caused a problem when someone in LLVM called std::min in a header
file.  LLDB has a windows.h include to work around this, but it
wasn't being used in these two files.

llvm-svn: 306186
2017-06-23 23:55:32 +00:00
Sean Callanan f40da17288 Updated the NSArray and NSDictionary formatters to support new storage formats.
Also un-xfailed a testcase that was affected by this.  Thanks to Jason Molenda for the patch.

<rdar://problem/32827216>

llvm-svn: 306180
2017-06-23 23:15:03 +00:00
Mehdi Amini d16a6e32fb Fix typo: using && instead of & when evaluating a mask
Summary: Reported by coverity, I don't know how to provide a test.

Reviewers: zturner

Subscribers: lldb-commits, emaste

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

llvm-svn: 306134
2017-06-23 18:20:13 +00:00
Pavel Labath 93df2fbeab Simplify the gdb-remote unit tests
Instead of every test creating a client-server combo, do that in the
SetUp method of the test fixture. This also means that we can rely on
gtest to not run the test if the SetUp method fails and delete the
if(HasFailure) calls.

llvm-svn: 306013
2017-06-22 15:54:21 +00:00
Zachary Turner 10a601adb2 Fix a python object leak in SWIG glue.
PyObject_CallFunction returns a PyObject which needs to be
decref'ed when it is no longer needed.

Patch by David Luyer
Differential Revision: https://reviews.llvm.org/D33740

llvm-svn: 305873
2017-06-21 01:52:37 +00:00
Kamil Rytarowski 4bb744156b Correct syntax mistake hidden in assert(3)
wait_status cannot be compared with WaitStatus::Stop,
go for wait_status.type.

llvm-svn: 305794
2017-06-20 13:51:06 +00:00
Pavel Labath df1a0d1180 [linux] Change the way we load vdso pseudo-module
Summary:
This is basically a revert of D16107 and parts of D10800, which were
trying to get vdso loading working. They did this by implementing a
generic load-an-elf-file from memory approach, which is not correct,
since we cannot assume that an elf file is loaded in memory in full (it
usually isn't, as there's no need to load section headers for example).
This meant that we would read garbage instead of section sizes, and if
that garbage happened to be a large number, we would crash while trying
to allocate a buffer to accomodate the hypothetical section.

Instead of this, I add a bit of custom code to load the vdso to
DynamicLoaderPOSIXDYLD (which already needed to handle the vdso
specially). I determine the size of the memory to read using
Process::GetMemoryRegionInfo, which is information coming from the OS,
and cannot be forged by a malicious/misbehaving application.

Reviewers: eugene, clayborg

Subscribers: lldb-commits, ravitheja, tberghammer, emaste

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

llvm-svn: 305780
2017-06-20 08:11:47 +00:00
Pavel Labath f891812b7b Remove home-grown thread-local storage wrappers
Summary:
Use c++11 thread_local variables instead. As far as I am aware, they are
supported by all compilers/targets we care about.

Reviewers: zturner, jingham

Subscribers: lldb-commits

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

llvm-svn: 305779
2017-06-20 08:11:43 +00:00
Pavel Labath 6c5c542986 ProcessLauncherPosixFork: Fetch errno early
I was seeing some unlikely errno values here. I am not sure if this will
help, but it nontheless seems like a good idea to stash errno value
before issuing other syscalls.

llvm-svn: 305778
2017-06-20 08:11:37 +00:00
Sean Callanan 18b5d9268c Updated NSNumber formatter for new internal representation.
<rdar://problem/32780109>

llvm-svn: 305727
2017-06-19 18:32:22 +00:00
Pavel Labath 3508fc8cc5 Add pretty-printer for wait(2) statuses and modernize the code handling them
Summary:
A number of places were trying to decode the result of wait(). Add a simple
utility function that does that and a struct that encapsulates the
decoded result. Then also provide a pretty-printer for that class.

Reviewers: zturner, krytarowski, eugene

Subscribers: lldb-commits, mgorny

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

llvm-svn: 305689
2017-06-19 12:47:50 +00:00
Pavel Labath 9376007af7 Tweak SysV_arm64 function entry unwind plan
Summary:
The motivation for this is to make sure the first row of the plan
compares equal to the first row of a generic debug_frame unwind plan.
Right now, the code in FuncUnwinders::GetUnwindPlanAtNonCallSite
considers them unequal because they specify the return address in a
different way (SetReturnAddressRegister(LR) vs. an explicit PC=LR rule).
This means that FuncUnwinders would always choose the debug_frame unwind
plan, which is not correct, as that one is usually not correct at all
locations.

Right now this is basically a noop because we don't have parse any
debug_frame plans, but it fixes some test failures when merging D33504
in.

I have to say I don't understand the full implications of the switch to
SetReturnAddressRegister() way of doing things, but given that all of
our other unwind plans (eh_frame, instruction profiling) do it this way,
it sounds like the right thing to do.

Reviewers: tberghammer, jasonmolenda, omjavaid

Subscribers: aemerson, javed.absar, kristof.beyls, lldb-commits

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

llvm-svn: 305687
2017-06-19 12:39:34 +00:00
Pavel Labath 319b38398e Delete ProcessLauncherPosix
Summary:
ProcessLauncherPosix was using posix_spawn for launching the process,
but this function is not available on all platforms we support, and even
where it was avaialable, it did not support the full range of options we
require for launching (most importantly, launching in stop-on-entry
mode). For these reasons, the set of ifdefs around these functions has
grown untractably large, and we were forced to implement our own
launcher from more basic primitives anyway (ProcessLauncherPosixFork --
used on Linux, Android, and NetBSD).

Therefore, I remove this class, and move the relevant parts of the code
to the darwin-specific Host.mm file. This is the platform that code was
originally written for anyway, and it's the only platform where this
implementation makes sense (e.g. the lack of the "thread-specific
working directory" concept makes these functions racy on all other
platforms). This allows us to remove a lot of ifdefs and simplify the
code.

Effectively, the only change this introduces is that FreeBSD will now
use the fork-based launcher instead of posix_spawnp. That sholdn't be a
problem as this approach works at least on one other BSD-based system
already.

Reviewers: krytarowski, emaste, jingham

Subscribers: srhines, mgorny, lldb-commits

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

llvm-svn: 305686
2017-06-19 12:26:22 +00:00
Sylvestre Ledru f955efc01b Fix a -Wmisleading-indentation warning
llvm-svn: 305664
2017-06-19 06:57:54 +00:00
Kuba Mracek 3abb10268d Fix the CMake files for the new InstrumentationRuntime plugins.
llvm-svn: 305594
2017-06-16 21:18:28 +00:00
Kuba Mracek ef45d8bcd2 Upstreaming the UndefinedBehaviorSanitizerRuntime and MainThreadCheckerRuntime plugins.
llvm-svn: 305589
2017-06-16 20:59:08 +00:00
Jason Molenda bbd1bf9951 Change the code I added to LocateDSYMInVincinityOfExecutable to use
the FileSpec methods for adding/removing file path components instead
of using std::strings; feedback from Sean on the change I added in
r305441.
<rdar://problem/31825940> 

llvm-svn: 305547
2017-06-16 04:19:36 +00:00
Pavel Labath 3adc40876e Add llvm::Error assignment operator to Status class
This enables writing "status = std::move(some_llvm_error)".

llvm-svn: 305462
2017-06-15 11:23:26 +00:00
Pavel Labath 054243f75a [swig] Improve the native module import logic
The simple module import logic was not sufficient for our distribution
model of lldb, which is without the _lldb.pyd file (normally that would
be a symlink to the shared library, but symlinks are not really a thing
on windows).

With the older swigs it worked (loading of the python scripting
machinery from within lldb) because the normal swig import logic
contained a last-ditch import of a global module _lldb (which is defined
when you run python from lldb). Add back the last-ditch import to our
custom import logic as well.

llvm-svn: 305461
2017-06-15 11:23:22 +00:00
Jason Molenda 244b6bb6cb Change how LocateDSYMInVincinityOfExecutable strips off path
components to not depend on "." characters in the fileanme
(e.g. "Foundation.framework") but instead to just use path
separators.  The names of the files themselves may have dots
in them ("com.apple.sbd") which would break the old scheme.

Also add a test case for this (macosx/find-dsym/bundle-with-dot-in-filename)
as well as a test case for r304520 (macosx/find-dsym/deep-bundle)
which needed a similar setup to test correctly on a single machine.
(both of these are really testing remote debug session situations
where the binary can't be found on the system where lldb is running,
complicating the test case a bit.)

<rdar://problem/31825940> 

llvm-svn: 305441
2017-06-15 01:42:48 +00:00
Sean Callanan 4d04b9cd97 [testsuite] xfailed two tests that depend on NSString conforming to NSCopying.
NSString is loaded from the DWARF, which doesn't have the concept of protocols.
When this is used with the NSMutableDictionary type from Objective-C modules,
this produces errors of the form

error: cannot initialize a parameter of type 'id<NSCopying> _Nonnull' with an rvalue of type 'NSString *'

We're aware of these problems and have an internal bug report filed
(<rdar://problem/32777981>)

llvm-svn: 305424
2017-06-14 23:01:43 +00:00
Nitesh Jain 1680ea4c1f [LLDB][MIPS] Skip TestGdbRemoteSingleStep and TestGdbRemote_vCont.py.
The step count depends on code generated by compiler (GCC/Clang).
It will also vary for different MIPS arch variant. Hence skipping these test for MIPS.

Subscribers: jaydeep, bhushan, lldb-commits, slthakur
llvm-svn: 305383
2017-06-14 12:21:26 +00:00
Nitesh Jain 3dcc9e0930 [LLDB][MIPS] Fix TestNoreturnUnwind.py.
bugnumber=llvm.org/pr33452

Subscribers: jaydeep, bhushan, lldb-commits, slthakur
llvm-svn: 305380
2017-06-14 10:47:25 +00:00
Nitesh Jain 0c29ef1b80 [LLDB][MIPS] Fix TestRegisterVariables.py.
Clang does not accept regparm attribute on these platforms.
Fortunately, the default calling convention passes arguments
in registers any way

Subscribers: jaydeep, bhushan, lldb-commits, slthakur
llvm-svn: 305378
2017-06-14 10:02:56 +00:00
Pavel Labath ba6a10fdcc Mark TestCallThatRestarts as flaky on android
This test started being flaky since r303848 (RunThreadPlan: Fix halting
logic in IgnoreBreakpoints = false). I am not reverting that, as I am
confident that actually fixed a problem. A more likely explanation is
that there is still one corner case that is not handled correctly there.

Marking the test as flaky until I get a chance to investigate. I also
mark the test as no-debug-info-dependend -- it stresses expression
evaluation, as far as debug info goes, the test if extremely simple.

llvm-svn: 305286
2017-06-13 11:13:11 +00:00
Pavel Labath 7f1c12118f Introduce new command: thread backtrace unique
This patch introduces a new thread backtrace command "unique".
The command is based off of "thread backtrace all" but will instead
find all threads which share matching call stacks and de-duplicate
their output, listing call stack and all the threads which share it.
This is especially useful for apps which use thread/task pools
sitting around waiting for work and cause excessive duplicate output.
I needed this behavior recently when debugging a core with 700+ threads.

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

Reviewers: clayborg, jingham
Patch by Brian Gianforcaro <b.gianfo@gmail.com>

llvm-svn: 305197
2017-06-12 16:25:24 +00:00
Davide Italiano 0d54c46cdd [VMRange] Remove unused FindRangeIndexThatContainsValue().
llvm-svn: 305111
2017-06-09 21:01:55 +00:00
Davide Italiano e8111778c1 [VMRange] Implement comparison operators using `==` and `<`.
llvm-svn: 305109
2017-06-09 20:49:11 +00:00
Davide Italiano 5ccf12e65f [VMRange] Use llvm::find_if. Thanks to Zachary for the suggestion.
llvm-svn: 305099
2017-06-09 19:14:59 +00:00
Pavel Labath 54d405033a Skip TestNoreturnUnwind on linux+clang+arm
I was over-eager to unable this test in r304976. It still fails in this
combination, at there does not seem to be anything we can do about it,
as the generated code does not preserve the link register.

llvm-svn: 305062
2017-06-09 08:33:59 +00:00
Davide Italiano 983c3d8ed3 [VMRange] Simplify a couple of member functions. NFCI.
llvm-svn: 305035
2017-06-08 23:49:56 +00:00
Pavel Labath c3c721222d Fix backtrace of noreturn functions situated at the end of a module
Summary:
When a call instruction is the last instruction in a function, the
backtrace PC will point past the end of the function. We already had
special code to handle that, but we did not handle the case where the PC
ends up outside of the bounds of the module containing the function,
which is a situation that occured in TestNoreturnUnwind on android for
some arch/compiler combinations.

I fix this by adding an argument to Address resolution code which states
that we are ok with addresses pointing to the end of a module/section to
resolve to that module/section.

I create a reproducible test case for this situation by hand-crafting an
executable which has a noreturn function at the end of a module.

Reviewers: jasonmolenda, jingham

Subscribers: lldb-commits

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

llvm-svn: 304976
2017-06-08 13:26:35 +00:00
Pavel Labath 92f6677159 Switch TaskMapOverInt to llvm::function_ref
The function does not persist the callback, so using a lighter-weight
asbtraction seems appropriate.

Also tweak the signatures of the lambdas to match what the TaskMap
interface expects.

llvm-svn: 304924
2017-06-07 16:28:08 +00:00
Zachary Turner 264b5d9e88 Move Object format code to lib/BinaryFormat.
This creates a new library called BinaryFormat that has all of
the headers from llvm/Support containing structure and layout
definitions for various types of binary formats like dwarf, coff,
elf, etc as well as the code for identifying a file from its
magic.

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

llvm-svn: 304864
2017-06-07 03:48:56 +00:00
Vadim Chugunov 98e3e6003d Use exact equality for category language matching, for all languages, except those specifically mentioned.
llvm-svn: 304832
2017-06-06 20:40:24 +00:00
Pavel Labath 32f29fac41 Fix assorted compiler warnings. NFC
llvm-svn: 304796
2017-06-06 14:06:22 +00:00
Pavel Labath 10c41f37b5 replace uses of strerror with llvm::sys::StrError
strerror is not thread-safe. llvm's StrError tries hard to retrieve the
string in a thread-safe way and falls back to strerror only if it does
not have another way.

llvm-svn: 304795
2017-06-06 14:06:17 +00:00
Pavel Labath 9f9422b699 Remove unused variables. NFC
llvm-svn: 304794
2017-06-06 13:40:21 +00:00
Pavel Labath 015f17d3cc New framework for lldb client-server communication tests.
Summary:
This is a new C++ test framework based on Google Test, and one working
example test.
The intention is to replace the existing tests in
packages/Python/lldbsuite/test/tools/lldb-server/ with this suite
and use this framework for all new client server tests.

Reviewers: labath, beanz

Reviewed By: labath, beanz

Subscribers: beanz, emaste, zturner, tberghammer, takuto.ikuta, krytarowski, mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D32930
Patch by Jason Majors <jmajors@google.com>

llvm-svn: 304793
2017-06-06 13:40:18 +00:00