Commit Graph

16272 Commits

Author SHA1 Message Date
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
Stephane Sezer ca5e153fb1 Avoid invalid string access in ObjCLanguage::MethodName::SetName
Summary:
Don't access `name[1]  if the string is only of length 1.  Avoids a
crash/assertion failure when parsing the string `-`.

Test Plan:
Debug a swift binary, set a breakpoint, watch lldb not crash

Original change by Paul Menage <menage@fb.com>

Reviewers: lldb-commits, clayborg

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

llvm-svn: 304725
2017-06-05 17:44:04 +00:00
Pavel Labath 090b8616e2 cmake: Put PROCESS_VM_READV detection results into Config.h
Reviewers: beanz, eugene

Subscribers: mgorny, lldb-commits

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

llvm-svn: 304544
2017-06-02 12:29:08 +00:00
Arnaud A. de Grandmaison af199153cc Remove vestigial CLANG_USED_LIBS.
The actual definition was removed 4 months ago with r294515.

llvm-svn: 304527
2017-06-02 07:48:35 +00:00
Jason Molenda 5f52e10204 Move the code to find a binary in a bundle in the target.exec-search-paths
from PlatformRemoteDarwinDevice into PlatformDarwin, and have both
PlatformRemoteDarwinDevice and PlatformMacOSX call it there.
<rdar://problem/31825940> 

llvm-svn: 304520
2017-06-02 05:17:19 +00:00
Sean Callanan ddf802a04d [TypeSystem] Handle Clang AttributedTypes
When parsing types originating in modules, it is possible to encounter AttributedTypes 
(such as the type generated for NSString *_Nonnull). Some of LLDB's ClangASTContext 
methods deal with them; others do not. In particular, one function that did not was 
GetTypeInfo, causing TestObjCNewSyntax to fail.

This fixes that, treating AttributedType as essentially transparent and getting the 
information for the modified type.

In addition, however, TestObjCNewSyntax is a monolithic test that verifies a bunch of 
different things, all of which can break independently of one another. I broke it 
apart into smaller tests so that we get more precise failures when something (like 
this) breaks.

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

llvm-svn: 304510
2017-06-02 01:24:18 +00:00
Pavel Labath 02f290f652 cmake: Enable process_vm_readv detection on android
Only android and linux can have this function as far as I am aware, but
it seems cleaner to enable this code for all platforms.

llvm-svn: 304405
2017-06-01 11:20:17 +00:00
Hafiz Abid Qadeer f64177ea83 Fix a small issue with -var-update.
If the variable was a pointer, code was ignoring the change in the
pointee.

Discussed in
http://lists.llvm.org/pipermail/lldb-dev/2017-May/012435.html

llvm-svn: 304400
2017-06-01 10:33:13 +00:00
Jim Ingham ab194a26da Forgot to mention rewriting CommandObject::DoExecute
using the SB API's not the lldb_private API's.

llvm-svn: 304379
2017-06-01 01:05:30 +00:00
Sean Callanan a77826c298 Added a testcase for local/namespaced name conflicts.
This works on SVN but is a bit fragile on the Swift branch.
I'm adding the test to both, so we have this path covered.

<rdar://problem/32372372>

llvm-svn: 304314
2017-05-31 17:18:10 +00:00
Benjamin Kramer f3b84c4ebe Replace forward decl with include to unbreak the build.
llvm-svn: 304158
2017-05-29 14:40:07 +00:00
Abhishek Aggarwal d2746dda60 Replaced StructuredData::Type with eStructuredDataType
...missing from r304138 "Added new API to SBStructuredData class"

llvm-svn: 304147
2017-05-29 11:13:30 +00:00
Stephan Bergmann cf4321a44d More StructuredData::Type::eTypeDictionary -> lldb::eStructuredDataTypeDictionary
...missing from previous r304138 "Added new API to SBStructuredData class"

llvm-svn: 304142
2017-05-29 08:51:58 +00:00
Abhishek Aggarwal 5bfee5f1c8 Added new API to SBStructuredData class
Summary:
 - Added API to access data types
    -- integer, double, array, string, boolean and dictionary data types
    -- Earlier user had to parse through the string output to get these
       values

 - Added Test cases for API testing

 - Added new StructuredDataType enum in public include file
   -- Replaced locally-defined enum in StructuredData.h with this new
      one       
   -- Modified other internal files using this locally-defined enum

Signed-off-by: Abhishek Aggarwal <abhishek.a.aggarwal@intel.com>

Reviewers: clayborg, lldb-commits

Reviewed By: clayborg

Subscribers: labath

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

llvm-svn: 304138
2017-05-29 08:25:46 +00:00
Ravitheja Addepally 0e62a125bd Fixing Memory Leak
llvm-svn: 303991
2017-05-26 14:26:14 +00:00
Pavel Labath 4c950235b2 Fix 32-bit builds
r303972 used GetValueForKeyAsInteger with mismatched types (e.g.
instantiating with uint64_t, but passing a size_t argument), which
manifested itself on 32-bit architectures.

The intended usage of these functions was to not specify the type
explicitly, and let the compiler figure that out, so switch to that kind
of usage instead.

llvm-svn: 303988
2017-05-26 13:53:39 +00:00
Ravitheja Addepally e714c4f535 Implementation of remote packets for Trace data.
Summary:
The changes consist of new packets for trace manipulation and
trace collection. The new packets are also documented. The packets
are capable of providing custom trace specific parameters to start
tracing and also retrieve such configuration from the server.

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

Reviewed By: clayborg, labath

Subscribers: krytarowski, lldb-commits

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

llvm-svn: 303972
2017-05-26 11:46:27 +00:00