Commit Graph

16602 Commits

Author SHA1 Message Date
Chris Bieneman 04f3910537 Fix GreenDragon bots
This commit removes a very old deprecated API that was causing compile failures for LLDB on Darwin. Since the comment says we only needed to keep the old API around for a few Xcode builds, and the comment was written 6 years ago... I think this can safely go away.

Failure URL:
http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/29936/console

llvm-svn: 308509
2017-07-19 18:57:16 +00:00
Saleem Abdulrasool f76e099ca7 silence a couple of -Wqual-cast warning from GCC (NFC)
Cast to `const uint8_t *` instead of `uint8_t *` to avoid the warning
from GCC.

  EmulationStateARM.cpp:206:34: warning: cast from type 'const void*' to type 'uint8_t* {aka unsigned char*}' casts away qualifiers [-Wcast-qual]

Cast to `const uint32_t *` and the explicitly cast away the const-ness
of the value.  This seems pretty sketchy as the `DataExtractor` holds a
const reference to the data.  However, this is no worse than before.

  ObjectFilePECOFF.cpp:540:78: warning: cast from type 'const uint8_t* {aka const unsigned char*}' to type 'uint32_t* {aka unsigned int*}' casts away qualifiers [-Wcast-qual]

llvm-svn: 308489
2017-07-19 15:46:21 +00:00
Bruce Mitchener ccbf7987a3 Expose hit count via SBBreakpointLocation.
Summary:
SBBreakpointLocation exposed the ignore count, but didn't expose
the hit count. Both values were exposed by SBBreakpoint and
SBWatchpoint, so this makes things a bit more consistent.

Reviewers: lldb-commits

Subscribers: lldb-commits

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

llvm-svn: 308480
2017-07-19 14:31:19 +00:00
Bruce Mitchener e54a9a268d Fix typos in documentation.
Reviewers: lldb-commits

Subscribers: lldb-commits

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

llvm-svn: 308426
2017-07-19 09:35:58 +00:00
Bruce Mitchener c92c508fd7 Update API headers.
Summary:
* Provide API doc for SBProcess::SaveCore.
* Fix typo in SBAttachInfo doc comments.
* SBBreakpointList: Name some variables same as C++.

Subscribers: lldb-commits

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

llvm-svn: 308425
2017-07-19 09:30:04 +00:00
Tim Hammerquist c635cb223e cmake build needs to run tests AND collect results
CMake target "check-lldb" runs the lldb dotest.py suite, but doesn't
collect the results in a usable format. In adding the arguments
necessary to collect these results, I found some minor bugs in CMake
that prevented dotest overrides from being used. This patch fixes them.

<rdar://problem/33389717> cmake build needs to run tests AND collect results

llvm-svn: 308393
2017-07-18 23:45:06 +00:00
Chris Bieneman f6b8ac28ab [CMake] A few fixups to support building LLDB for iOS
These changes enable proper configuration of LLDB targeting iOS.

llvm-svn: 308378
2017-07-18 21:15:53 +00:00
Chris Bieneman f396708f4c [CMake] Refactor debugserver build system
This refactoring changes two significant things about how the debugserver build system works:

(1) debugserver will include all appropriate architecture support, so we can now build arm or ppc debugservers
(2) debugserver can be built by itself, so you don't have to configure all of LLDB in order to generate debugserver.

llvm-svn: 308377
2017-07-18 21:15:27 +00:00
Chris Bieneman 154a5ff15b [CMake] [NFC] Remove out of date and redundant version requirement
Since we set the minimum required version elsewhere to be higher this actually has meaningful good impact.

llvm-svn: 308376
2017-07-18 21:15:14 +00:00
Pavel Labath f40f8fc415 Fix NetBSD/FreeBSD build after r308304
llvm-svn: 308307
2017-07-18 14:03:47 +00:00
Pavel Labath b6dbe9a99c Clean up lldb-types.h
Summary:
It defined a couple of types (condition_t) which we don't use anymore,
as we have c++11 goodies now. I remove these definitions.

Also it unnecessarily included a couple of headers which weren't
necessary for it's operation. I remove these, and place the includes in
the relevant files (usually .cpp, usually in Host code) which use them.
This allows us to reduce namespace pollution in most of the lldb files
which don't need the OS-specific definitions.

Reviewers: zturner, jingham

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 308304
2017-07-18 13:14:01 +00:00
Pavel Labath 4e138e1d8c Fix linux arm and mips builds broken by r308282
llvm-svn: 308292
2017-07-18 10:42:36 +00:00
Pavel Labath 82abefa4b1 Remove shared pointer from NativeProcessProtocol
Summary:
The usage of shared_from_this forces us to separate construction and
initialization phases, because shared_from_this() is not available in
the constructor (or destructor). The shared semantics are not necessary,
as we always have a clear owner of the native process class
(GDBRemoteCommunicationServerLLDB object). Even if we need shared
semantics in the future (which I think we should strongly avoid),
reverting this will not be necessary -- the owners can still easily
store the native process object in a shared pointer if they really want
to -- this just prevents the knowledge of that from leaking into the
class implementation.

After this a NativeThread object will hold a reference to the parent
process (instead of a weak_ptr) -- having a process instance always
available allows us to simplify some logic in this class (some of it was
already simplified because we were asserting that the process is
available, but this makes it obvious).

Reviewers: krytarowski, eugene, zturner

Subscribers: lldb-commits

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

llvm-svn: 308282
2017-07-18 09:24:48 +00:00
Eugene Zemtsov 20d28a168e Fixing LLDB build after refactoring of clang's MacroInfo
llvm-svn: 308219
2017-07-17 20:50:21 +00:00
Chris Bieneman 7dc58b238d Fix debugserver accepting remote connections
While adding IPv6 support to debugserver I broke handling wildcard addresses and fully qualified address filtering. This patch resolves that bug and adds a test for matching the address "*".

<rdar://problem/32947613>

llvm-svn: 307957
2017-07-13 20:58:13 +00:00
Jim Ingham 055e65f0d4 Enable parsing C++ names generated by lambda functions.
https://reviews.llvm.org/D34911 from Weng Xuetian.

llvm-svn: 307944
2017-07-13 19:48:43 +00:00
Jim Ingham 61949c9f6f Convert a few more tests to use run_to_source_breakpoint.
llvm-svn: 307943
2017-07-13 19:46:21 +00:00
Jim Ingham 30bac79162 Fix a deadlock in the Python interpreter vrs. SIGINT.
The interpreter gets invoked in the sigint handler to cancel
long-running Python operations.  That requires the interpreter
lock, but that may be held by the Python operation that's getting
interrupted, so the mutex needs to be recursive.

<rdar://problem/33179086>

llvm-svn: 307942
2017-07-13 19:45:54 +00:00
Kuba Mracek b244c2bafe Upstreaming a patch from Github: When evaluation user expressions, ignore InstrumentationRuntime breakpoints. (#235)
llvm-svn: 307881
2017-07-13 04:35:27 +00:00
Jim Ingham a6c57dd989 The llvm.org bugzilla moved.
llvm-svn: 307870
2017-07-13 00:36:21 +00:00
Petr Pavlu 8c5dafde49 [MainLoop] Fix possible use of an invalid iterator
Store file descriptors from loop.m_read_fds (if FORCE_PSELECT is
defined) and signals from loop.m_signals that need to be processed in
MainLoop::RunImpl::ProcessEvents() into a separate vector and then
iterate over this container to invoke the callbacks.

This prevents a problem where when the code iterated directly over
m_read_fds/m_signals, a callback invoked from within the loop could
modify these variables and invalidate the loop iterator. This would then
result in an assertion failure in llvm::DenseMapIterator::operator++().

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

llvm-svn: 307782
2017-07-12 12:38:31 +00:00
Ravitheja Addepally fa73e34082 Fixing Android builder
llvm-svn: 307773
2017-07-12 11:54:17 +00:00
Ravitheja Addepally dab1d5f3cd Adding Support for Error Strings in Remote Packets
Summary:
This patch adds support for sending strings along with
error codes in the reply packets. The implementation is
based on the feedback recieved in the lldb-dev mailing
list. The patch also adds an extra packet for the client
to query if the server has the capability to provide
strings along with error replys.

Reviewers: labath, jingham, sas, lldb-commits, clayborg

Reviewed By: labath, clayborg

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

llvm-svn: 307768
2017-07-12 11:15:34 +00:00
Tim Hammerquist 95c003b96f switch on enum should be exhaustive and warning-free
Summary:
Testing the value of type_code against the closed enum TypeCodes
provides statically verifiable completeness of testing. However, one
branch assigns to type_code by casting directly from a masked integer
value. This is currently handled by adding a default: case after
checking each TypeCodes instance. This patch introduces a bool variable
containing the "default" state value, allowing the switch to be
exhaustive, protect against future instances not being handled in the
switch, and preserves the original logic.

This addresses the warning:
warning: default label in switch which covers all enumeration values
[-Wcovered-switch-default]

As an issue of maintainability, the bitmask on line 524 handles the
current values of TypeCodes enum, but this will be invalid if the enum
is extended. This patch does not address this, and a more closed
conversion from cfinfoa -> TypeCodes would help protect against this.

Reviewers: spyffe, lhames, sas

Reviewed By: sas

Subscribers: sas, lldb-commits

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

llvm-svn: 307712
2017-07-11 21:06:20 +00:00
Pavel Labath 21a365ba59 NativeProcessLinux: Fix handling of raise(SIGTRAP)
In NativeProcessLinux::MonitorSIGTRAP we were asserting that the si_code
value is one of the codes we know about. However, that list was very
incomplete -- for example, we were not handling SI_TKILL/SI_USER,
generated by raise(SIGTRAP). A cursory examination show there are at
least a dozen codes like these that an app can generate, and more can be
added at any point.

So, instead of trying to play catchup, I change the default behavior to
treat an unknown si_code like an ordinary signal. The only reason we
needed to inspect si_code in the first place is because
watchpoint/breakpoints are notified as SIGTRAP, but we already know
about those, and us starting to use a new debug event is far less likely
than somebody introducing a new non-debug event.

I add a test case to TestRaise to verify we are handling raise(SIGTRAP)
in an application properly.

llvm-svn: 307644
2017-07-11 10:38:40 +00:00
Pavel Labath 993f2a4299 NativeProcessLinux: Fix some compiler warnings
llvm-svn: 307636
2017-07-11 09:03:38 +00:00
Pavel Labath cc72ede081 [LLDB][ppc64le] Rename enums in AuxVector
Summary:
On linux on ppc64le some of the enums in AuxVector have the same name
as macros defined in the system.

Reviewers: mikesart, labath

Reviewed By: labath

Subscribers: joerg, gut, krytarowski, lldb-commits

Differential Revision: https://reviews.llvm.org/D35065
Patch by Bruno Rosa <bruno.rosa@eldorado.org.br>

llvm-svn: 307632
2017-07-11 08:39:44 +00:00
Jason Molenda 529d235cfc Pass in the disassembler flavor when disassembling in
DumpDataExtractor.  Patch from Jeffrey Crowell,

https://reviews.llvm.org/D34929

llvm-svn: 307618
2017-07-11 04:22:31 +00:00
Zachary Turner ac43c1bb87 Don't access Python objects while not holding the GIL.
Patch by Tatyana Krasnukha
Differential Revision: https://reviews.llvm.org/D34942

llvm-svn: 307512
2017-07-09 23:32:15 +00:00
Kuba Mracek e21b03daea Update message that Main Thread Checker produces.
llvm-svn: 307464
2017-07-08 05:18:19 +00:00
Jason Molenda f62080451c The x86 instruction unwinder can be asked to disassemble non-instruction
blocks of memory, and if the final bytes of that block look like a long
x86 instruction, it can cause the llvm disassembler to read past the end
of the buffer.  Use the maximum allowed instruction length that we pass
to the llvm disassembler as a way to limit this to the size of the buffer.

An example of how to trigger this is when lldb does a function call, it
puts a breakpoint on the beginning of main() and uses that as the return
address from the function call.  When we stop at that location, lldb may
try to find the first frame up the stack.  Because this is on the first
instruction of a function, it will get the word-size value at the stack
pointer and assume that this was the caller's pc value.  But this is random
stack memory and could point to anything - an object in memory, something
in the data section, whatever.  And if we have a symbol for that thing,
we'll try to disassemble it.

This was leading to infrequent crashes in customer scenarios; figured out
what was happening with address sanitizer.

<rdar://problem/30463256> 

llvm-svn: 307454
2017-07-08 00:12:15 +00:00
Pavel Labath daf42491e6 Disable TestGoASTContext
it fails with go 1.8 and we don't seem to have a maintainer of that
functionality.

llvm-svn: 307391
2017-07-07 11:02:28 +00:00
Pavel Labath 96e600fcf5 Add a NativeProcessProtocol Factory class
Summary:
This replaces the static functions used for creating
NativeProcessProtocol instances with a factory pattern, and modernizes
the interface of the new class in the process -- I use llvm::Expected
instead of the Status+value combo. I also move some of the common code
(like the Delegate registration into the base class). The new
arrangement has multiple benefits:
- it removes the NativeProcess*** dependency from Process/gdb-remote
  (which for example means that liblldb no longer pulls in this code).
- it enables unit testing of the GDBRemoteCommunicationServerLLGS class
  (by providing a mock Native Process).
- serves as another example on how to use the llvm::Expected class (I
  couldn't get rid of the Initialize-type functions completely here
  because of the use of shared_from_this, but that's the next thing on
  my list here)

Tests still pass on Linux and I've made sure NetBSD compiles after this.

Reviewers: zturner, eugene, krytarowski

Subscribers: srhines, lldb-commits, mgorny

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

llvm-svn: 307390
2017-07-07 11:02:19 +00:00
Tim Hammerquist 85ca1df472 Fix Xcode project file for gtest schemes.
<rdar://problem/33066993>

llvm-svn: 307335
2017-07-06 23:25:35 +00:00
David L. Jones d4053fb2ec Change remaining references to lit.util.capture to use subprocess.check_output.
Summary:
The capture() function was removed in r306625. This should fix PGO breakages
reported by Michael Zolotukhin.

Reviewers: mzolotukhin

Subscribers: sanjoy, llvm-commits

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

llvm-svn: 307320
2017-07-06 21:46:47 +00:00
Jim Ingham 19c28eee46 Working through testcases, converting to run_to_source_breakpoint.
llvm-svn: 307287
2017-07-06 18:06:25 +00:00
Pavel Labath 21fb07b715 Fix a copy-paste error in r307161
llvm-svn: 307253
2017-07-06 11:43:25 +00:00
Pavel Labath 0fa8396165 Revert "Android.rules: build x86 tests with -mstackrealign"
Starting with android ndk r15, clang much more tests are affected by the
-mstackrealign bugl (now nearly all functions are affected, and not just
the ones requiring 16-byte alignment). Due to their numbers, Xfailing
all of them is not a viable option, so we will just have to declare this
configuration unsupported, and wait until ndk ships a clang version that
has this bug fixed.

llvm-svn: 307252
2017-07-06 11:43:20 +00:00
Jim Ingham a15e7f296b Add a lldbutils routine that gathers up the boiler-plate
to make a target, set a source regex breakpoint, run to 
the breakpoint and find the thread that hit the breakpoint.

Start the process of replacing the boiler plate with this
routine.

llvm-svn: 307234
2017-07-06 02:18:16 +00:00
Tim Hammerquist 42a96a286c add googlemock include dir to lldb-gtest Xcode target
Add the googlemock include directory from LLVM to CFLAGS arguments in
Xcode's lldb-gtest.

<rdar://problem/33066993>

llvm-svn: 307228
2017-07-06 00:08:54 +00:00
Kuba Mracek c40ca13519 [lldb] Add a testcase for MainThreadCheckerRuntime plugin
This adds a simple testcase for MainThreadCheckerRuntime. The tool (Main Thread Checker) is only available on Darwin, so the test also detects the presence of libMainThreadChecker.dylib and is skipped if the tool is not available.

llvm-svn: 307170
2017-07-05 16:29:36 +00:00
Pavel Labath ef7aff507b Fix assorted compiler warnings (mismatched signedness and printf specifiers)
llvm-svn: 307161
2017-07-05 14:54:46 +00:00
Pavel Labath d37c946991 Fix "process load" on new android targets
Summary:
On older android targets, we needed a dlopen rename workaround to get
"process load" working. Since API 26 this is not required as the targets
have a proper libdl so with the function names one would expect.

To make this work I've had to remove the const qualifier from the
GetLibdlFunctionDeclarations function (as now the declarations can
depend on the connected target). Since I was already modifying the
prototype (and the lower levels were already converted to StringRef) I
took the oportunity to convert this function as well.

llvm-svn: 307160
2017-07-05 14:54:41 +00:00
Pavel Labath 11b16c8110 Update lldb architecture docs
Summary:
Due to recent refactors, the descriptions of various modules were wildly
out of date. With this patch, I am not trying to legislate anything,
I am merely documenting the current state of affairs.

I am also deleting one copy of the architecture docs. AFAIK, this one is
not referenced from the web page.

Reviewers: zturner, jingham

Subscribers: lldb-commits

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

llvm-svn: 307072
2017-07-04 12:29:34 +00:00
Pavel Labath 88c6534877 Fix some warnings in ProcessorTraceTest.cpp
llvm-svn: 307071
2017-07-04 12:29:30 +00:00
Ravitheja Addepally f4ffae91cb Fixing warnings for unused variables and copy ellision
Summary:
The std::move was preventing copy ellision when compiled with
clang, the patch fixes the warning along with rearranging code
to remove unused variables warnings on Linux machines with
older perf_event interface.

Reviewers: labath, ted

Reviewed By: labath

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

llvm-svn: 307030
2017-07-03 15:07:36 +00:00
Pavel Labath 9bf0e0362f Fix typo/unbreak windows build broken by r307009
llvm-svn: 307018
2017-07-03 11:01:49 +00:00
Pavel Labath c1a6b128c7 Use llvm::sys::RetryAfterSignal instead of a manual while errno!=EINTR loop
Reviewers: zturner, eugene, krytarowski

Subscribers: emaste, mgorny, lldb-commits

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

llvm-svn: 307009
2017-07-03 09:25:55 +00:00
Pavel Labath f1fb38b746 Remove dead Core/StreamFile includes
llvm-svn: 306817
2017-06-30 11:31:13 +00:00
Pavel Labath cc78ea6985 Fix a cmake typo to unbreak windows unit tests
llvm-svn: 306802
2017-06-30 07:54:35 +00:00
Sean Callanan 48bccc9448 [Data formatters] Make NSSetM support both old- and new-style representation
NSSetM has two in-memory representations depending on what Foundation version is in use.
This patch separates the two.

rdar://33057292

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

llvm-svn: 306773
2017-06-30 00:39:17 +00:00
Tim Hammerquist 0a94072e4d Fix some type-based warnings
llvm-svn: 306765
2017-06-29 23:33:40 +00:00
Jason Molenda d2d4c8db45 Update default cpu subtype for armv7 processes to armv7k, the most
likely cpu subtype at this point.

llvm-svn: 306752
2017-06-29 22:50:53 +00:00
Jim Ingham 804eb1fbab Timer.{h,cpp} moved, find them again in the project file.
llvm-svn: 306725
2017-06-29 18:54:40 +00:00
Pavel Labath ef9fc29d4e Speculative fix for windows build broken by r306668
llvm-svn: 306693
2017-06-29 16:15:42 +00:00
Pavel Labath 480907248e Fix Mac build for the Timer move
llvm-svn: 306686
2017-06-29 15:24:38 +00:00
Pavel Labath 217a763bb2 Android.rules: build x86 tests with -mstackrealign
All android builds systems have switched to -mstackrealign for building
x86 binaries, so follow their cue with our mini build system.

This presently breaks just one test (TestReturnValue), and this is due
to a compiler bug, which has already been fixed in clang, but it hasn't
made it yet into the official NDK compiler. While I'm touching that
test, I also remove an android-specific XFAIL, which is not relevant
anymore.

llvm-svn: 306683
2017-06-29 14:32:23 +00:00
Pavel Labath 38d0632e6a Move Timer and TraceOptions from Core to Utility
Summary:
The classes have no dependencies, and they are used both by lldb and
lldb-server, so it makes sense for them to live in the lowest layers.

Reviewers: zturner, jingham

Subscribers: emaste, mgorny, lldb-commits

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

llvm-svn: 306682
2017-06-29 14:32:17 +00:00
Pavel Labath 0e44cff13b Make scripts/analyze-project-deps.py executable
llvm-svn: 306669
2017-06-29 13:02:15 +00:00
Pavel Labath 7ed3e22f00 [unittests] Add a helper function for getting an input file
Summary:
Fetching an input file required about five lines of code, and this was
repeated in multiple unit tests, with slight variations. Add a helper
function for doing that into the lldbUtilityMocks module (which I rename
to lldbUtilityHelpers to commemorate the fact it includes more than
mocks)

Reviewers: zturner, eugene

Subscribers: emaste, mgorny, lldb-commits

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

llvm-svn: 306668
2017-06-29 13:02:11 +00:00
Pavel Labath 8996346bba [UnwindAssembly/x86] Add support for "lea imm(%ebp), %esp" pattern
Summary:
The instruction pattern:
and $-16, %esp
sub $imm, %esp
...
lea imm(%ebp), %esp

appears when the compiler is realigning the stack (for example in
main(), or almost everywhere with -mstackrealign switch). The "and"
instruction is very difficult to model, but that's not necessary, as
these frames are always %ebp-based (the compiler also needs a way to
restore the original %esp). Therefore the plans we were generating for
these function were almost correct already. The only place we were doing
it wrong were the last instructions of the epilogue (usually just
"ret"), where we had to revert to %esp-based unwinding, as the %ebp had
been popped already.

This was wrong because our "distance of esp from cfa" counter had picked
up the "sub" instruction (and incremented the counter) but it had not
seen that the register was reset by the "lea" instruction.

This patch fixes that shortcoming, and adds a test for handling
functions like this.

I have not been able to tickle the compiler into producing a 64-bit
function with this pattern, but I don't see a reason why it couldn't
produce it, if it chose to, so I add a x86_64 test as well.

Reviewers: jasonmolenda, tberghammer

Subscribers: lldb-commits

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

llvm-svn: 306666
2017-06-29 12:40:13 +00:00
Jason Molenda 7f5bd34b18 Fix two places in RegisterContextLLDB::InitializeNonZerothFrame where
I'm not running the saved pc through FixCodeAddress as soon as I should.

<rdar://problem/30686307> 

llvm-svn: 306634
2017-06-29 03:02:24 +00:00
Jason Molenda 43294c9f48 Change the ABI class to have a weak pointer to its Process;
some methods in the ABI need a Process to do their work.
Instead of passing it in as a one-off argument to those
methods, this patch puts it in the base class and the methods
can retrieve if it needed.

Note that ABI's are sometimes built without a Process 
(e.g. SBTarget::GetStackRedZoneSize) so it's entirely
possible that the process weak pointer will not be
able to reconsistitue into a strong pointer.

<rdar://problem/32526754> 

llvm-svn: 306633
2017-06-29 02:57:03 +00:00
Sean Callanan 5a5c14ab94 Added a project for the unified IR interpreter.
llvm-svn: 306611
2017-06-28 22:51:16 +00:00
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
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
Ed Maste d6fa2c3b4d FreeBSD ProcessMonitor: map TRAP_CAP to a trace trap
In the absense of a more specific handler for TRAP_CAP (generated by
ENOTCAPABLE or ECAPMODE while in capability mode) treat it as a trace
trap. Obtained from FreeBSD r318884.

We should later add an option to have LLDB control the trapcap procctl 
(as with ASLR), as well as report a specific stop reason. For now this
change eliminates an assertion failure from LLDB.

llvm-svn: 303965
2017-05-26 03:15:46 +00:00
Kamil Rytarowski 8855c2ca19 Fix bug #28898
lldb: libedit produces garbled, unusable input on Linux

Apply patch from Christos Zoulas, upstream libedit developer.
It has been tested on NetBSD/amd64.

New code supports combination of wide libedit and disabled
LLDB_EDITLINE_USE_WCHAR, which was the popular case on Linux
systems.

llvm-svn: 303907
2017-05-25 20:12:30 +00:00
Pavel Labath e8cd2cca91 Revert "Fix FDE indexing while scan debug_info section."
This reverts commit r303847 as it introduces a number of regressions.
Investigation has showed that we are parsing the CIE entries in the
debug_frame section incorrectly -- we are parsing them the same way as
eh_frame, but the entries in debug_frame have a couple of extra entries
which have not been taken into account.

llvm-svn: 303854
2017-05-25 13:13:12 +00:00
Pavel Labath 45dde23756 Recommit "RunThreadPlan: Fix halting logic in IgnoreBreakpoints = false"
This is a resubmit of r303732, which was reverted due to a regression.

The original patch caused a regression in TestLoadUnload, which has only showed
up when running the remote test suite. The problem there was that we interrupted
the target just as it has hit the rendezvous breakpoint in the dlopen call. This
meant that the stop reason was set to "breakpoint" even though the event would
not have been broadcast if we had not stopped the process. I fix this by
checking StopInfo->ShouldNotify() before stopping.

I also add a new test for the handling of conditional breakpoints in
expressions, which I noticed to be broken (pr33164)

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

llvm-svn: 303848
2017-05-25 10:50:06 +00:00
Hafiz Abid Qadeer 0b5d6e5d0e Fix FDE indexing while scan debug_info section.
There are some differences between eh_frame and debug_frame formats that
are not considered by DWARFCallFrameInfo::GetFDEIndex. An FDE entry
contains CIE_pointer in debug_frame in same place as cie_id in eh_frame.
As described in dwarf standard (section 6.4.1), CIE_pointer is an
"offset into the .debug_frame section". So, variable cie_offset should
be equal cie_id for debug_frame.

FDE entries with zeroth CIE pointer (which is actually placed in cie_id
variable) shouldn't be ignored also.

I have also added a little change which allow to use debug_info section
when eh_frame is absent. This case really can take place on some platforms.

Patch from tatyana-krasnukha.
https://reviews.llvm.org/D33504

llvm-svn: 303847
2017-05-25 10:21:29 +00:00
Jim Ingham d2a7e8538b Fix the warning when you pass -c to step/next/si/ni.
During some cleanup the test for whether the thread plan
accepted an iteration count was reversed, so we give a 
warning when it will actually work, and don't when it won't.

<rdar://problem/32379280>

llvm-svn: 303832
2017-05-25 02:24:18 +00:00
Kamil Rytarowski 269eec03d6 Correct compiler warnings and Debug build of the NetBSD target
Correct files present only in the NetBSD build.

llvm-svn: 303823
2017-05-24 23:59:50 +00:00
Pavel Labath 7417558f59 Revert "RunThreadPlan: Fix halting logic in IgnoreBreakpoints = false"
This reverts commit r303732, as it introduces a regression in
TestLoadUnload on android.

llvm-svn: 303740
2017-05-24 11:57:28 +00:00
Pavel Labath 0dc2ad1b13 RunThreadPlan: Fix halting logic in IgnoreBreakpoints = false
Summary:
The function had logic to handle the case when the expression terminated
while we were trying to halt the process, but it failed to take into
account the possibility that the expression stopped because it hit a
breakpoint. This was caused by the fact that the handling of the stopped
events was duplicated for the "halting" and regular cases (the regular
case handled this situation correctly). I've tried to merge these two
cases into one to make sure they stay in sync.

I should call out that the two cases were checking whether the thread
plan has completed in slightly different ways. I am not sure what is the
difference between them, but I think the check should be the same in
both cases, whatever it is, so I just took the one from the regular
case, as that is probably more tested.

For the test, I modified TestUnwindExpression to run the expression with
a smaller timeout (this is how I found this bug originally). With a 1ms
one thread timeout, the test failed consistently without this patch.

Reviewers: jingham

Subscribers: lldb-commits

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

llvm-svn: 303732
2017-05-24 09:46:48 +00:00
Stephane Sezer e3bb52bb2e Fix bad change in RenderScriptx86ABIFixups.cpp, forgot to change everything necessary
Summary: I didn't change all instances of i to I in this loop. I am a bad person and should feel bad. :(

Reviewers: sas

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

Change by Alex Langford <apl@fb.com>

llvm-svn: 303677
2017-05-23 19:22:31 +00:00
Stephane Sezer 02295000c2 hange RenderScriptx86ABIFixups.cpp to use llvm::AttributeList iterator
LLVM::AttributeList recently had getNumSlots() removed, which broke the
build. This fixes the build using functions introduced in the
update to LLVM::AttributeList.

Change by Alex Langford <apl@fb.com>

llvm-svn: 303674
2017-05-23 18:54:03 +00:00
Jim Ingham c1dd88c2e6 We shouldn't put actual tests in directories that contain
other test directories.

llvm-svn: 303643
2017-05-23 16:11:21 +00:00
Pavel Labath b8372cfa33 Add support for new (3.0.11+) swigs
Summary:
A change in swig 3.0.9 has caused it to generate modules incompatible
with us using them as __init__.py (bug #769). Swig 3.0.11 adds a setting to help
fix this problem, so use that. Support for older versions of swig remains
unaffected.

Reviewers: zturner

Subscribers: lldb-commits

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

llvm-svn: 303627
2017-05-23 10:55:17 +00:00
Pavel Labath 6bb7e21f10 Fix incorrect Status -> Error rename in IOHandler
Change 302872 was a massive rename of the Error class to Status.

The change included an incorrect rename of the "Status" window
in the LLDB GUI from "Status to "Error". This patch undoes this incorrect
rename and restores the status window's correct name.

Differential Revision: https://reviews.llvm.org/D33241
Patch by Brian Gianforcaro.

llvm-svn: 303553
2017-05-22 14:13:38 +00:00
Jason Molenda 631a0bb924 Don't override the SDKs and force the use of /System/Library/Frameworks to
find the python headers when buiding crashinfo.c
<rdar://problem/32288076> 

llvm-svn: 303465
2017-05-19 23:00:42 +00:00
Pavel Labath a24a3a30d0 Add Status -- llvm::Error glue
Summary:
This adds functions to convert between llvm::Error and Status classes.
Posix errors in Status are represented as llvm::ECError, and the rest as
llvm::StringError.

For the conversion from Error to Status, ECError is again represented as
a posix error in Status, while other errors are stored as generic errors
and only the string value is preserved.

Reviewers: zturner, jingham

Subscribers: lldb-commits

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

llvm-svn: 303348
2017-05-18 12:46:50 +00:00
Ted Woodward c8556788a0 Fix error string set in AddName to take a StringRef.
llvm-svn: 303278
2017-05-17 17:48:55 +00:00
Pavel Labath 1b8fe5ec8d Make TestConflictingSymbol run on non-darwin targets
For remote targets we need to call registerSharedLibrariesWithTarget to
make sure they are installed alongside main executable. This also
required a small fixup in the the mentioned function as in this case
"One" was both a directory name and a library name template. I fixed it
to make sure it checks that the string refers to a file before it
assumed it was a full library path.

llvm-svn: 303248
2017-05-17 11:47:44 +00:00
Sean Callanan 9c99faa856 [Expression parser] Look up module symbols before hunting globally
When it resolves symbol-only variables, the expression parser
currently looks only in the global module list. It should prefer
the current module.

I've fixed that behavior by making it search the current module
first, and only search globally if it finds nothing. I've also
added a test case.

After review, I moved the core of the lookup algorithm into
SymbolContext for use by other code that needs it.

Thanks to Greg Clayton and Pavel Labath for their help.

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

llvm-svn: 303223
2017-05-16 23:46:13 +00:00
Pavel Labath 26d49a640a Skip TestWatchedVarHitWhenInScope on android arm because it triggers a kernel bug
llvm-svn: 303160
2017-05-16 11:58:18 +00:00
Sean Callanan 732a6f432e [TypeSystem] Fix inspection of Objective-C object types
ptr_refs exposed a problem in ClangASTContext's implementation: it
uses an accessor to downcast a QualType to an
ObjCObjectPointerType, but the accessor is not fully general.
getAs() is the safer way to go.

I've added a test case that uses ptr_refs in a way that would
crash before the fix.

<rdar://problem/31363513>

llvm-svn: 303110
2017-05-15 19:55:20 +00:00
Pavel Labath b5c2a2d959 Disable a test in TestReturnValue on arm64 linux
as described in pr33042, we cannot reliably retrieve the return value on
arm64 in cases it is returned via x8 pointer. I tried to do this as
surgically as possible and disabled it only on targets I know to be
affected, as the code is still useful, even though it can only work on
best-effort basis.

llvm-svn: 303076
2017-05-15 16:25:28 +00:00
Pavel Labath e9ac335192 Fix darwin build for r303058
llvm-svn: 303061
2017-05-15 13:41:38 +00:00
Pavel Labath f9d1647657 Remove an expensive lock from Timer
The Timer destructor would grab a global mutex in order to update
execution time. Add a class to define a category once, statically; the
class adds itself to an atomic singly linked list, and thus subsequent
updates only need to use an atomic rather than grab a lock and perform a
hashtable lookup.

Differential Revision: https://reviews.llvm.org/D32823
Patch by Scott Smith <scott.smith@purestorage.com>.

llvm-svn: 303058
2017-05-15 13:02:37 +00:00
Sean Callanan 0ef7bb1b57 Fixed the OS X build after Error -> Status rename.
llvm-svn: 302954
2017-05-12 21:53:44 +00:00
Eugene Zemtsov d7048988d7 Fix build on Mac OS.
llvm-svn: 302948
2017-05-12 20:44:09 +00:00
Zachary Turner 2833321f09 Update StructuredData::String to return StringRefs.
It was returning const std::string& which was leading to
unnecessary copies all over the place, and preventing people
from doing things like Dict->GetValueForKeyAsString("foo", ref);

llvm-svn: 302875
2017-05-12 05:49:54 +00:00
Zachary Turner 41c9936460 Fix Linux Buildbot.
llvm-svn: 302874
2017-05-12 05:48:54 +00:00
Zachary Turner 97206d5727 Rename Error -> Status.
This renames the LLDB error class to Status, as discussed
on the lldb-dev mailing list.

A change of this magnitude cannot easily be done without
find and replace, but that has potential to catch unwanted
occurrences of common strings such as "Error".  Every effort
was made to find all the obvious things such as the word "Error"
appearing in a string, etc, but it's possible there are still
some lingering occurences left around.  Hopefully nothing too
serious.

llvm-svn: 302872
2017-05-12 04:51:55 +00:00
Sean Callanan 0f01fb39e3 xfail TestClassTemplateParameterPack on gcc to mollify lldb-x86_64-ubuntu-14.04-cmake.
llvm-svn: 302850
2017-05-11 23:38:21 +00:00
Sean Callanan 09e91ac6ab [DWARF parser] Produce correct template parameter packs
Templates can end in parameter packs, like this

template <class T...> struct MyStruct 
  { /*...*/ };

LLDB does not currently support these parameter packs; 
it does not emit them into the template argument list
at all. This causes problems when you specialize, e.g.:

template <> struct MyStruct<int> 
  { /*...*/ };
template <> struct MyStruct<int, int> : MyStruct<int> 
  { /*...*/ };

LLDB generates two template specializations, each with 
no template arguments, and then when they are imported 
by the ASTImporter into a parser's AST context we get a 
single specialization that inherits from itself, 
causing Clang's record layout mechanism to smash its
stack.

This patch fixes the problem for classes and adds
tests. The tests for functions fail because Clang's
ASTImporter can't import them at the moment, so I've
xfailed that test.

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

llvm-svn: 302833
2017-05-11 22:08:05 +00:00
Lang Hames a088f2fbcc Import sys in repo.py.
The find function in repo.py calls sys.exit on error. Without this import that
call to exit will fail, masking the actual error message. This patch fixes that.

llvm-svn: 302584
2017-05-09 20:37:01 +00:00
Jim Ingham abc5d72f02 Be a little more permissive in DynamicLoaderMacOS::CanLoadImage
If we can't find the "is dyld locked" symbol, assume it is safe
to load the image unless we only have 1 image loaded - in which case
we are in _dyld_start and it is definitely NOT safe.

Also add a little better errors to that function, and better logging
in SBProcess.cpp.

<rdar://problem/30174817>

llvm-svn: 302327
2017-05-06 01:15:47 +00:00
Jim Ingham f414671c70 Added "info threads", "thread 1" and "apropos".
llvm-svn: 302323
2017-05-05 23:38:26 +00:00
Lang Hames 8b38565b2f Add DidStartExecuting/WillFinishExecuting methods to Expression.
These methods can be used by the derived expression types to perform expression
specific and/or language specific actions before and after the expression runs.
(ThreadPlanCallUserExpression is modified to call these methods on the
expression immediately before/after execution of the expression).

The immediate motivation is allowing Swift expressions to notify the swift
runtime that exclusivity enforcement should be suspended while the expression
runs (we want LLDB expressions to be able to access variables even when they're
considered exclusively owned by someone else in the original program).

Reviewed in https://reviews.llvm.org/D32889

llvm-svn: 302314
2017-05-05 22:42:13 +00:00
Chris Bieneman 8d0c7fafdb Fix UDP Socket connections
Some of the refactoring in r301492 broke UDP socket connections. This is a partial revert of that refactoring. At some point I'll spend more time diagnosing where the refactoring went wrong and how to better clean up this code, but I don't have time to do that today.

llvm-svn: 302282
2017-05-05 20:35:50 +00:00
Francis Ricci f88bf5acfe Add missing 'arch' key to valid qHostInfo keys
Summary:
'arch' is a valid qHostInfo key, but the unit
test for qHostInfo did not include it in the set of possible keys.

Reviewers: tfiala, labath

Subscribers: lldb-commits

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

llvm-svn: 302260
2017-05-05 17:18:08 +00:00
Pavel Labath 38c2059aec Fix segfault resulting from empty print prompt
Summary:
I have found a way to segfault lldb in 7 keystrokes! Steps to reproduce:
1) Launch lldb
2) Type `print` and hit enter. lldb will now prompt you to type a list of
    expressions, followed by an empty line.
3) Hit enter, indicating the end of your input.
4) Segfault!

After some investigation, I've found the issue in Host/common/Editline.cpp.
Editline::MoveCursor() relies on m_input_lines not being empty when the `to`
argument is CursorPosition::BlockEnd. This scenario, as far as I can tell,
occurs in one specific instance: In Editline::EndOrAddLineCommand() when the
list of lines being processed contains exactly one string (""). Meeting this
condition is fairly simple, I have posted steps to reproduce above.

Reviewers: krytarowski, zturner, labath

Reviewed By: labath

Subscribers: scott.smith, lldb-commits

Differential Revision: https://reviews.llvm.org/D32421
Patch by Alex Langford.

llvm-svn: 302225
2017-05-05 11:51:21 +00:00
Pavel Labath 5c913e9973 Add TaskMap for iterating a function over a set of integers
Summary:
Many parallel tasks just want to iterate over all the possible numbers from 0 to N-1.  Rather than enqueue N work items, instead just "map" the function across the requested integer space.

Reviewers: clayborg, labath, tberghammer, zturner

Reviewed By: clayborg, zturner

Subscribers: zturner, lldb-commits

Differential Revision: https://reviews.llvm.org/D32757
Patch by Scott Smith <scott.smith@purestorage.com>.

llvm-svn: 302223
2017-05-05 11:16:59 +00:00
Pavel Labath 3559f20f17 ABISysV_arm64: compute return value for large vectors correctly
Summary:
Arm64 Procedure Call Standard specifies than only vectors up to 16 bytes
are stored in v0 (which makes sense, as that's the size of the
register). 32-byte vector types are passed as regular structs via x8
pointer. Treat them as such.

This fixes TestReturnValue for arm64-clang. I also split the test case
into two so I can avoid the if(gcc) line, and annotate each test
instead. (It seems the vector type tests fail with gcc only when
targetting x86 arches).

Reviewers: tberghammer, eugene

Subscribers: aemerson, omjavaid, rengolin, srhines, lldb-commits

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

llvm-svn: 302220
2017-05-05 10:50:02 +00:00
Nitesh Jain dd12594345 [LLDB][MIPS] Fix TestStepOverBreakpoint.py failure.
Reviewers: jingham, labath

Subscribers: jaydeep, bhushan, lldb-commits, slthakur

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

llvm-svn: 302139
2017-05-04 11:34:42 +00:00
Pavel Labath 4f1f64174b MainLoop: Add unit tests
Summary:
This adds a couple of unit tests to the MainLoop class. To get the
kqueue based version of the signal handling passing, I needed to
modify the implementation a bit to make the queue object persistent.
Otherwise, only the signals which are send during the Run call would get
processed, which did not match the ppoll behaviour.

I also took the opportunity to remove the ForEach template functions and
replace them with something more reasonable.

Reviewers: beanz, eugene

Subscribers: lldb-commits, mgorny

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

llvm-svn: 302133
2017-05-04 10:11:33 +00:00
Francis Ricci decd2d7701 Don't attempt to use mpx registers on unsupported platforms
Summary:
The existing cpp-level checks using PR_MPX_ENABLE_MANAGEMENT aren't sufficient,
as this isn't defined for linux kernel versions below 3.19.

Reviewers: valentinagiusti, zturner, labath

Subscribers: lldb-commits

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

llvm-svn: 302027
2017-05-03 15:00:04 +00:00
Pavel Labath 6b09f9d603 Windows fix for TestConflictingDefinition makefile
gnuwin32 rm does not like wildcards that match nothing even if we
specify -f (probably because the wildcard expansion happens in-process
there). We could use make $(wildcard) here, but it seems safer to
explicitly list the files here, just like the normal Makefile.rules
does.

llvm-svn: 302013
2017-05-03 11:27:35 +00:00
Pavel Labath 9075f52c78 Check for lack of C++ context first when demangling
Summary: It seems that if we have no context, then it can't possibly be a method.  Check that first.

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: labath, lldb-commits

Differential Revision: https://reviews.llvm.org/D32708
Patch by Scott Smith <scott.smith@purestorage.com>.

llvm-svn: 302008
2017-05-03 10:00:00 +00:00
Sean Callanan 40d067cd7f Fixed a bug where we did not properly use the complete versions of Objective-C classes.
Also added a test case, thanks to Greg Clayton.

<rdar://problem/18913551>

llvm-svn: 301993
2017-05-03 00:41:43 +00:00
Pavel Labath 59bc6d1ce0 Android.rules: set "ar" path correctly
llvm-svn: 301918
2017-05-02 13:14:45 +00:00
Pavel Labath efddda3d8d ObjectFileELF: Fix symbol lookup in bss section
Summary:
If we have symbol information in a separate file, we need to be very
careful about presenting a unified section view of module to the rest of
the debugger. ObjectFileELF had code to handle that, but it was being
overly cautious -- the section->GetFileSize()!=0 meant that the
unification would fail for sections which do not occupy any space in the
object file (e.g., .bss). In my case, that manifested itself as not
being able to display the values of .bss variables properly as the
section associated with the variable did not have it's load address set
(because it was not present in the unified section list).

I test this by making sure the unified section list and the variables
refer to the same section.

Reviewers: eugene, zturner

Subscribers: tberghammer, lldb-commits, mgorny

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

llvm-svn: 301917
2017-05-02 12:40:31 +00:00
Pavel Labath 4d35d6b3b3 Change UniqueCStringMap to use ConstString as the key
Summary:
UniqueCStringMap "sorts" the entries for fast lookup, but really it only cares about uniqueness.  ConstString can be compared by pointer alone, rather than with strcmp, resulting in much faster comparisons.  Change the interface to take ConstString instead, and propagate use of the type to the callers where appropriate.

Reviewers: #lldb, clayborg

Reviewed By: clayborg

Subscribers: labath, jasonmolenda, lldb-commits

Differential Revision: https://reviews.llvm.org/D32316
Patch by Scott Smith <scott.smith@purestorage.com>.

llvm-svn: 301908
2017-05-02 10:17:30 +00:00
Pavel Labath a193a4c8b3 Remove unused code related to CPlusPlusLanguage::FindEquivalentNames
Summary: It is simply unused, and the header for it is private, so there should be no external dependencies.

Reviewers: #lldb, zturner

Reviewed By: zturner

Subscribers: zturner, tberghammer, jingham, lldb-commits

Differential Revision: https://reviews.llvm.org/D32503
Patch by Scott Smith <scott.smith@purestorage.com>.

llvm-svn: 301903
2017-05-02 09:00:52 +00:00
Tim Hammerquist 267ba94ce6 Public headers need to be public.
llvm-svn: 301686
2017-04-28 21:03:18 +00:00
Tim Hammerquist 15a50d34cd Add remaining SBTrace headers to LLDB framework
llvm-svn: 301664
2017-04-28 18:10:53 +00:00
Pavel Labath 8070bf0a54 Remove lock from ConstString::GetLength
Summary: ConstStrings are immutable, so there is no need to grab even a reader lock in order to read the length field.

Reviewers: #lldb, labath

Reviewed By: labath

Subscribers: zturner, labath, lldb-commits

Differential Revision: https://reviews.llvm.org/D32306
Patch by Scott Smith <scott.smith@purestorage.com>

llvm-svn: 301642
2017-04-28 12:08:28 +00:00
Pavel Labath 836ad03fa5 Resurrect pselect MainLoop implementation
Summary:
It turns out that even though ppoll is available on all the android
devices we support, it does not seem to be working properly on all of
them -- MainLoop just does a busy loop with ppoll returning EINTR and
not making any progress.

This brings back the pselect implementation and makes it available on
android. I could not do any cmake checks for this as the ppoll symbol is
actually avaiable -- it just does not work.

Reviewers: beanz, eugene

Subscribers: srhines, lldb-commits

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

llvm-svn: 301636
2017-04-28 10:26:06 +00:00
Jim Ingham 7fca8c0757 Provide a mechanism to do some pre-loading of symbols up front.
Loading a shared library can require a large amount of work; rather than do that serially for each library,
this patch will allow parallelization of the symbols and debug info name indexes.

From scott.smith@purestorage.com

https://reviews.llvm.org/D32598

llvm-svn: 301609
2017-04-28 00:51:06 +00:00
Jim Ingham b242e93541 Add a newline to suppress compiler warnings.
llvm-svn: 301608
2017-04-28 00:44:07 +00:00
Kamil Rytarowski 9f3dd7593d Resurrect the standalone build of LLDB
Switch includes "llvm/Config/config.h" to "llvm/Config/llvm-config.h".

Tested on NetBSD 7.99.70 amd64

llvm-svn: 301603
2017-04-28 00:29:54 +00:00
Tim Hammerquist 981ade7909 integrate SBTrace changes into Xcode project
llvm-svn: 301600
2017-04-27 23:09:08 +00:00
Chris Bieneman 9a98df63f4 Fixing Windows bot
URL:
http://lab.llvm.org:8011/builders/lldb-x86-windows-msvc2015/builds/8700

llvm-svn: 301581
2017-04-27 19:56:54 +00:00
Chris Bieneman 2961877986 NFC. Add comment about debugserver usage
This just adds a comment to SocketAddress about it being used by debugserver and the implications of that.

If we need to make changes to this class that make it unsuitable for debugserver we can re-implement the minimal abstractions we need from this file in debugserver. I would prefer not to do that because code duplication is bad. Nuff said.

llvm-svn: 301580
2017-04-27 19:45:16 +00:00
Chris Bieneman dc9e8d2249 Fix GreenDragon bots
We don't actually need to include Compiler.h here because it is only used on Windows and Windows/PosixAPI.h includes it.

llvm-svn: 301579
2017-04-27 19:45:13 +00:00
Chris Bieneman 51978f5ba2 Update GDB remote command regex for IPv6
This updates the regular expression used to match host/port pairs for the gdb-remote command to also match IPv6 addresses.

The IPv6 address matcher is very generic and does not really check for structural validity of the address. It turns out that IPv6 addresses are very complicated.

llvm-svn: 301559
2017-04-27 16:13:58 +00:00
Chris Bieneman 2246972ecc [CMake] Abstract Config.h generation for Xcode
This patch abstracts the generation of Config.h and creates a dummy project entry point to allow generation of LLDB's Config header without performing a full CMake configuration.

This will enable the Xcode project to generate LLDB's Config header.

llvm-svn: 301553
2017-04-27 16:04:26 +00:00
Nitesh Jain 63a978ff09 [LLDB][MIPS] Forgot to add check in commit rl301530
Reviewers: ki.stfu, labath
Subscribers: jaydeep, bhushan, lldb-commits, slthakur

llvm-svn: 301537
2017-04-27 12:27:42 +00:00
Pavel Labath f57453aece TCPSocket: add back support for "*" address
before r301492, we could specify "*:1234" as an address to lldb-server
and it would interpret that as "any". I am not sure that's a good idea,
but we have usages of that in the test suite, and without this the
remote test suite fails.

I'm adding that back, as it does not seem it was an intended side-effect
of that change, but I am open to removing it in the future, after
discussion and test suite fixup.

llvm-svn: 301534
2017-04-27 11:32:25 +00:00
Nitesh Jain 93d7ab9d82 [LLDB][MIPS] Fix TestMiExec.py failure.
Reviewers: ki.stfu, labath

Subscribers: jaydeep, bhushan, lldb-commits, slthakur

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

llvm-svn: 301530
2017-04-27 10:21:46 +00:00
Pavel Labath 4716854687 Fix build for clang r301507
LangStandard::lang_opencl -> LangStandard::lang_opencl10

llvm-svn: 301524
2017-04-27 08:49:19 +00:00
Chris Bieneman 26beacc19e One more try at the whole compiling thing...
Need to actually use the right type in both parts of the cast.

llvm-svn: 301506
2017-04-27 00:47:19 +00:00
Chris Bieneman 2d1f6e1191 One more attempt to fix the broken bots.
llvm-svn: 301504
2017-04-27 00:23:41 +00:00
Chris Bieneman 7ba4d851b0 Fix Windows bots broken by r301492
http://lab.llvm.org:8011/builders/lldb-x86-windows-msvc2015/builds/8644/

llvm-svn: 301502
2017-04-27 00:03:27 +00:00
Lang Hames 6cc3354dd6 Fix libcxx formatters for changes in r300140.
Summary:
LLVM r300140 changed the layout and field names of __compressed_pair, which
broke LLDB's std::vector, std::map and std::unsorted_map formatters.

This patch attempts to fix these formatters by having them interogate the
__compressed_pair values to determine whether they're pre- or post-r300140
variants, then access them accordingly.

Reviewers: jingham, EricWF

Reviewed By: jingham

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

llvm-svn: 301493
2017-04-26 23:29:59 +00:00
Chris Bieneman 1182779917 Re-landing IPv6 support for LLDB Host
This support was landed in r300579, and reverted in r300669 due to failures on the bots.

The failures were caused by sockets not being properly closed, and this updated version of the patches should resolve that.

Summary from the original change:

This patch adds IPv6 support to LLDB/Host's TCP socket implementation. Supporting IPv6 involved a few significant changes to the implementation of the socket layers, and I have performed some significant code cleanup along the way.

This patch changes the Socket constructors for all types of sockets to not create sockets until first use. This is required for IPv6 support because the socket type will vary based on the address you are connecting to. This also has the benefit of removing code that could have errors from the Socket subclass constructors (which seems like a win to me).

The patch also slightly changes the API and behaviors of the Listen/Accept pattern. Previously both Listen and Accept calls took an address specified as a string. Now only listen does. This change was made because the Listen call can result in opening more than one socket. In order to support listening for both IPv4 and IPv6 connections we need to open one AF_INET socket and one AF_INET6 socket. During the listen call we construct a map of file descriptors to addrin structures which represent the allowable incoming connection address. This map removes the need for taking an address into the Accept call.

This does have a change in functionality. Previously you could Listen for connections based on one address, and Accept connections from a different address. This is no longer supported. I could not find anywhere in LLDB where we actually used the APIs in that way. The new API does still support AnyAddr for allowing incoming connections from any address.

The Listen implementation is implemented using kqueue on FreeBSD and Darwin, WSAPoll on Windows and poll(2) everywhere else.

https://reviews.llvm.org/D31823

llvm-svn: 301492
2017-04-26 23:17:20 +00:00
Richard Smith 8186cd43e2 Update lldb to match clang r301442.
This code really doesn't make any sense: there is only ever one InputKind here.
Plus, this is an incomplete and out-of-date copy-paste of some Clang code. This
really ought to be revisited, but this change should get the bots green again.

llvm-svn: 301483
2017-04-26 22:10:53 +00:00
Sean Callanan 5652d5eb09 Fixed a crash when dealing with an empty method name in the ObjC runtime.
I've filed a bug covering better unit testing of our runtime metadata reader, which will allow this to be testable.. 

<rdar://problem/31793264>

llvm-svn: 301461
2017-04-26 20:36:47 +00:00
Lang Hames 088d001f05 Use llvm::ArrayRef rather than std::vector/std::initializer lists for some
ValueObject methods.

Using ArrayRef allows us to remove some overloads, work with more array-like
types, and avoid some std::vector temporaries.

https://reviews.llvm.org/D32518

llvm-svn: 301441
2017-04-26 18:15:40 +00:00
Ravitheja Addepally d5d8d91c1d Initial implementation of SB APIs for Tracing support.
Summary:
This patch introduces new SB APIs for tracing support
inside LLDB. The idea is to gather trace data from
LLDB and provide it through this APIs to external
tools integrating with LLDB. These tools will be
responsible for interpreting and presenting the
trace data to their users.

The patch implements the following new SB APIs ->
-> StartTrace - starts tracing with given parameters
-> StopTrace - stops tracing.
-> GetTraceData - read the trace data .
-> GetMetaData - read the meta data assosciated with the trace.
-> GetTraceConfig - read the trace configuration

Tracing is associated with a user_id that is returned
by the StartTrace API and this id needs to be used
for accessing the trace data and also Stopping
the trace. The user_id itself may map to tracing
the complete process or just an individual thread.
The APIs require an additional thread parameter
when the user of these APIs wishes to perform
thread specific manipulations on the tracing instances.
The patch also includes the corresponding
python wrappers for the C++ based APIs.

Reviewers: k8stone, lldb-commits, clayborg

Reviewed By: clayborg

Subscribers: jingham, mgorny

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

llvm-svn: 301389
2017-04-26 08:48:50 +00:00
Pavel Labath 2933d7b0d2 Remove the home-grown android toolchain file and all references to it
Summary:
The toolchain file has been deprecated in favor of the "official"
toolchain file present in the Android NDK. Also update the web
build instructions to reflect this.

Reviewers: eugene

Subscribers: srhines, mgorny, dgross, tberghammer, lldb-commits

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

llvm-svn: 301306
2017-04-25 12:58:49 +00:00
Nitesh Jain b43729bc39 [LLDB][MIPS] Fix typo in TestStepOverWatchpoint.py.
Subscribers: jaydeep, bhushan, lldb-commits, slthakur
llvm-svn: 301295
2017-04-25 06:12:59 +00:00
Sean Callanan 831c72f4a9 Name the C++ source files for two tests correctly.
llvm-svn: 301280
2017-04-24 23:58:36 +00:00
Sean Callanan c0dd0181d3 Fixed two bad Makefiles that might be breaking Linux.
llvm-svn: 301277
2017-04-24 23:49:06 +00:00
Sean Callanan c02a1c0312 [Expression parser] Return both types and variables
Many times a user wants to access a type when there's a variable of
the same name, or a variable when there's a type of the same name.
Depending on the precise context, currently the expression parser
can fail to resolve one or the other.

This is because ClangExpressionDeclMap has logic to limit the
amount of information it searches, and that logic sometimes cuts
down the search prematurely. This patch removes some of those early
exits.

In that sense, this patch trades performance (early exit is faster)
for correctness.

I've also included two new test cases showing examples of this
behavior – as well as modifying an existing test case that gets it
wrong.

llvm-svn: 301273
2017-04-24 23:14:04 +00:00
Sean Callanan b494578afb [DWARF] Fix lookup in the abstract origins of inlined blocks/functions
LLDB uses clang::DeclContexts for lookups, and variables get put into
the DeclContext for their abstract origin. (The abstract origin is a 
DWARF pointer that indicates the unique definition of inlined code.) 
When the expression parser is looking for variables, it locates the 
DeclContext for the current context. This needs to be done carefully, 
though, e.g.:

__attribute__ ((always_inline)) void f(int a) {
  {
    int b = a * 2;
  }
}

void g() {
  f(3);
}
Here, if we're stopped in the inlined copy of f, we have to find the 
DeclContext corresponding to the definition of f – its abstract 
origin. Clang doesn't allow multiple functions with the same name and 
arguments to exist. It also means that any variables we see must be 
placed in the appropriate DeclContext.

[Bug 1]: When stopped in an inline block, the function 
GetDeclContextDIEContainingDIE for that block doesn't properly
construct a DeclContext for the abstract origin for inlined
subroutines. That means we get duplicated function DeclContexts, but
function arguments only get put in the abstract origin's DeclContext, 
and as a result when we try to look for them in nested contexts they 
aren't found.

[Bug 2]: When stopped in an inline block, the DWARF (for space 
reasons) doesn't explicitly point to the abstract origin for that 
block. This means that the function GetClangDeclContextForDIE returns
a different DeclContext for each place the block is inlined. However, 
any variables defined in the block have abstract origins, so they 
will only get placed in the DeclContext for their abstract origin.

In this fix, I've introduced a test covering both of these issues,
and fixed them.

Bug 1 could be resolved simply by making sure we look up the abstract
origin for inlined functions when looking up their DeclContexts on 
behalf of nested blocks.

For Bug 2, I've implemented an algorithm that makes the DeclContext 
for a block be the containing DeclContext for the closest entity we
would find during lookup that has an abstract origin pointer. That
means that in the following situation:

{ // block 1
  int a;
  { // block 2
    int b;
  }
}
if we looked up the DeclContext for block 2, we'd find the block 
containing the abstract origin of b, and lookup would proceed 
correctly because we'd see b and a. However, in the situation

{ // block 1
  int a;
  { // block 2
  }
}
since there isn't anything to look up in block 2, we can't determine 
its abstract origin (and there is no such pointer in the DWARF for 
blocks). However, we can walk up the parent chain and find a, and its 
abstract origin lives in the abstract origin of block 1. So we simply 
say that the DeclContext for block 2 is the same as the DeclContext 
for block 1, which contains a. Lookups will return the same results.

Thanks to Jim Ingham for review and suggestions.

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

llvm-svn: 301263
2017-04-24 22:11:10 +00:00
Pavel Labath b4f6a95680 Update two android XFAILS
- XFAIL on TestNoreturnUnwind on all architectures
- TestStaticVariables fails with clang-3.8 as well

llvm-svn: 301186
2017-04-24 15:23:21 +00:00
Pavel Labath 27d1528758 Fix the new SocketAddressTest on Windows
we need to call WSAStartup before we can use getaddrinfo.

llvm-svn: 301179
2017-04-24 13:34:35 +00:00
Nitesh Jain 4c5fb05503 [LLDB][MIPS] Move it into HandleLLVMOptions.cmake.
The revison https://reviews.llvm.org/D32125 will fixed the off_t for GNU specific 32 bit platform. This fixed the difference in definition of off_t in LLDB and LLVM

Subscribers: jaydeep, bhushan, lldb-commits, slthakur, llvm-commits, krytarowski, emaste, zturner
llvm-svn: 301172
2017-04-24 10:56:01 +00:00
Pavel Labath df0497c4aa Add more arguments to SocketAddress::GetAddressInfo
Summary:
the reason for this is two-fold:
- getaddrinfo without the extra arguments will return the same
(network-level) address multiple times, once for each supported
transport protocol, which is not what is usually intended (it certainly
wasn't in D31823)
- it enables us to rewrite the getaddrinfo member function in terms of
the static GetAddressInfo function.

Reviewers: beanz, tberghammer

Subscribers: lldb-commits

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

llvm-svn: 301168
2017-04-24 09:39:56 +00:00
Ed Maste f6a29894a2 Simplify FreeBSD Host.cpp with early returns
Based on NetBSD's Host.cpp. Also tidy up comments to match NetBSD.

llvm-svn: 301100
2017-04-23 02:28:28 +00:00
Ed Maste de06ec5449 ThreadSanitizer plugin: match for loop variable with expected type
Removes Clang warning ThreadSanitizerRuntime.cpp:591:21: warning:
comparison of integers of different signs: 'int' and 'size_t' (aka
'unsigned long') [-Wsign-compare]

llvm-svn: 301067
2017-04-22 01:38:54 +00:00
Jason Molenda 11506a9d1c Correct the names of some target conditional defines in debugserver.
llvm-svn: 301034
2017-04-21 20:19:28 +00:00
Jim Ingham f77bb46dc0 Add an example command to toggle between disassembly-only and source mode.
Sometimes you are debugging in source, but you really only want to see
the disassembly.  That's easy to do but you have to set a few variables.
This command toggles between your old values, and a disassembly only mode.

llvm-svn: 300902
2017-04-20 21:51:27 +00:00
Sean Callanan ac3254aec5 Changed a use of APInt::getSignBit to APInt::getSignMask.
llvm-svn: 300862
2017-04-20 18:07:51 +00:00
Kamil Rytarowski 37283039cd Resurrect LLDB Standalone build on NetBSD
Include CheckIncludeFile for check_include_file() in CMake.

Detect <sys/event.h> in CMake.
This header is available on NetBSD.

llvm-svn: 300853
2017-04-20 16:35:36 +00:00
Davide Italiano 04e7c08d9e [Utility] Placate another GCC warning.
Differential Revision:  https://reviews.llvm.org/D32137

llvm-svn: 300845
2017-04-20 14:45:33 +00:00
Pavel Labath 69883aa043 Skip TestLibCxxAtomic with gcc
older versions of libc++ (still used on some linux systems) are not
compatible with gcc.

llvm-svn: 300837
2017-04-20 12:30:30 +00:00
Pavel Labath 68e3886e57 Recompute ArchSpec core after MergeFrom
Summary:
MergeFrom was updating the architecture if the target triple did not
have it set. However, it was leaving the core field as invalid. This
resulted in assertion failures in core file tests as a missing core
meant we were unable to compute the address byte size properly.

Add a unit test for the new behaviour.

Reviewers: jingham, clayborg

Subscribers: lldb-commits

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

llvm-svn: 300836
2017-04-20 12:30:18 +00:00
Pavel Labath 7b46633c4b Make TestStaticVariables XFAIL more specific
The test fails because an older clang did not emit the required debug
info (I am not sure when this got added, but clang-3.7 certainly did not
work yet). The actual platform has nothing to do with this.

llvm-svn: 300834
2017-04-20 11:28:07 +00:00
Pavel Labath a93310ad2a Add libc++ category the three more tests
I thought my previous commit got the last ones but somehow I missed
these. This also resurrects TestDataFormatterLibcxxSet, which got
commented out in r263859 as a part of some seemingly unrelated change.

llvm-svn: 300833
2017-04-20 11:27:58 +00:00
Jason Molenda 36162d0ffb Add extra logging for when lldb is looking for kernels and kexts.
<rdar://problem/26863256> 

llvm-svn: 300810
2017-04-20 02:02:25 +00:00
Jim Ingham aab5be0505 Fix !N and !-N commands and add a test case.
<rdar://problem/31713267>

llvm-svn: 300785
2017-04-19 23:21:04 +00:00
Jim Ingham 56454b592d Add CopyDiagnostic to the DiagnosticManager.
From Gregor Milos (gmilos@apple.com), for:

https://reviews.llvm.org/D32078

llvm-svn: 300733
2017-04-19 18:56:44 +00:00
Davide Italiano a5b9d3c11a [Utility/StringLexer] Remove dead code.
Differential Revision:  https://reviews.llvm.org/D32148

llvm-svn: 300729
2017-04-19 18:18:25 +00:00
David Gross 36d783ebfe Teach RenderScriptRuntime about changed context representation.
Summary:
The runtime discovers contexts through RenderScriptRuntime::Capture*()
methods.  These methods see the low-level context representation.
However, the runtime calls APIs that require the high-level context
representation.  Therefore, it needs to call yet another API to find
the high-level representation associated with a given low-level
representation.

Subscribers: lldb-commits

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

llvm-svn: 300727
2017-04-19 18:14:21 +00:00
Pavel Labath 7c437023ca Fix TestRegisterVariables for clang/arm
Clang rejects __attribute__((regparm)) when targetting arm. The default
calling convention passes arguments in registers anyway, so we can just
remove them in this case.

llvm-svn: 300670
2017-04-19 10:13:29 +00:00
Pavel Labath 107e694271 Revert yesterdays IPv6 patches
The break the linux bots (and probably any other machine which would
run the test suite in a massively parallel way). The problem is that it
can happen that we only successfully create an IPv6 listening socket
(because the relevant IPv4 port is used by another process) and then the
connecting side attempts to connect to the IPv4 port and fails.

It's not very obvious how to fix this problem, so I am reverting this
until we come up with a solution.

llvm-svn: 300669
2017-04-19 10:13:22 +00:00
Chris Bieneman 94c1708110 [CMake] Add configure check for sys/event.h
This enables the kqueue path in MainLoop for Darwin and BSD.

llvm-svn: 300654
2017-04-19 02:53:53 +00:00
Chris Bieneman c2a9e5b4ed One more attempt and Windows
This is the last Windows compile error, so... Hit me with your best shot.

llvm-svn: 300647
2017-04-19 01:32:08 +00:00
Chris Bieneman 9317c64768 Another netbsd build failure...
llvm-svn: 300640
2017-04-19 01:17:29 +00:00
Chris Bieneman 32ed478d40 Buildbot wack-a-mole!
This should fix the netbsd bot I just broke.

llvm-svn: 300638
2017-04-19 01:15:17 +00:00
Chris Bieneman dd94972890 ifdefing out the signal handling code on Windows
*fingers crossed*

This might fix the Window bots, but I really don't know...

llvm-svn: 300636
2017-04-19 01:00:16 +00:00
Chris Bieneman 08adf13d29 Define HAVE_SIGACTION to 1 in Xcode build
This is needed to make the Xcode project build since it doesn't have auto-generated Config header.

llvm-svn: 300618
2017-04-18 22:37:00 +00:00
Chris Bieneman ea02aa1585 Include time.h, and fix a Darwin warning
This is a little more cleanup from r300579.

llvm-svn: 300615
2017-04-18 22:11:13 +00:00
Chris Bieneman 399249a297 Fix Windows bot failure
timespec is not available on Windows, and we should use size_t instead of nfds_t.

llvm-svn: 300610
2017-04-18 21:47:50 +00:00
Chris Bieneman 09a88f3105 Fixing error on Android build (-Werror)
This is fallout from r300579.

llvm-svn: 300606
2017-04-18 21:35:26 +00:00
Chris Bieneman 1a4c748a48 Removing unused include
This is causing the Windows bot failures.

llvm-svn: 300605
2017-04-18 21:23:55 +00:00
Chris Bieneman 7879598d75 [CMake] Adding configure-time check for sigaction
Hopefully this will fix the netbsd bot that I broke...

llvm-svn: 300590
2017-04-18 20:49:09 +00:00
Chris Bieneman 38fdb72ca9 Writing multi-platform code is hard...
Fixing another error from r300579.

llvm-svn: 300589
2017-04-18 20:49:05 +00:00
Chris Bieneman 2515410cb4 Fix broken windows build.
This is not ideal, but it should get the bot going again. I'll need to revisit this if we want to get signal handling working on Windows.

llvm-svn: 300587
2017-04-18 20:37:05 +00:00
Chris Bieneman effa539495 Fixing bot failure caused by r300579
llvm-svn: 300582
2017-04-18 20:08:29 +00:00
Chris Bieneman d01a2fa38d Update DebugServer to support IPv6 over TCP
Summary: This patch adds IPv6 support to debugserver. It follows a similar pattern to the changes proposed for LLDB/Host except that the listen implementation is only with kqueue(2) because debugserver is only supported on Darwin.

Reviewers: jingham, jasonmolenda, clayborg

Reviewed By: clayborg

Subscribers: mgorny, lldb-commits

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

llvm-svn: 300580
2017-04-18 20:01:59 +00:00
Chris Bieneman 31e7c5e89f Update LLDB Host to support IPv6 over TCP
Summary:
This patch adds IPv6 support to LLDB/Host's TCP socket implementation. Supporting IPv6 involved a few significant changes to the implementation of the socket layers, and I have performed some significant code cleanup along the way.

This patch changes the Socket constructors for all types of sockets to not create sockets until first use. This is required for IPv6 support because the socket type will vary based on the address you are connecting to. This also has the benefit of removing code that could have errors from the Socket subclass constructors (which seems like a win to me).

The patch also slightly changes the API and behaviors of the Listen/Accept pattern. Previously both Listen and Accept calls took an address specified as a string. Now only listen does. This change was made because the Listen call can result in opening more than one socket. In order to support listening for both IPv4 and IPv6 connections we need to open one AF_INET socket and one AF_INET6 socket. During the listen call we construct a map of file descriptors to addrin structures which represent the allowable incoming connection address. This map removes the need for taking an address into the Accept call.

This does have a change in functionality. Previously you could Listen for connections based on one address, and Accept connections from a different address. This is no longer supported. I could not find anywhere in LLDB where we actually used the APIs in that way. The new API does still support AnyAddr for allowing incoming connections from any address.

The Listen implementation is implemented using kqueue on FreeBSD and Darwin, WSAPoll on Windows and poll(2) everywhere else.

Reviewers: zturner, clayborg

Subscribers: jasonmolenda, labath, lldb-commits, emaste

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

llvm-svn: 300579
2017-04-18 20:01:52 +00:00
Jim Ingham eb236735e5 Add back code to implement "frame var -a,-l,-g" filters.
r285226 dropped the code that did these checks.  I am pretty
sure that was inadvertent, so I added that back in and added
a test for it.

<rdar://problem/31661252>

llvm-svn: 300564
2017-04-18 16:52:16 +00:00
Kamil Rytarowski 36e23ecad0 Introduce FPR and Debug Registers/NetBSD/amd64 support
Summary:
This code offers Debug Registers (80386) model in LLDB/amd64.

This is initial support and has one issue that will be addressed later,
Debug Register trap (TRAP_DBREG) is registered as (TRAP_TRACE)
for unknown reason.  On the other hand this works good enough to
move on and leave this bug to be squashed later.

Improve the NativeProcessNetBSD::ReinitializeThreads() function,
stop setting inside it SetStoppedByExec(). This fixes incorrect
stop reason on attaching (SetStoppedBySignal(SIGSTOP)).

This commits also has no functional style improvements from
clang-format.

This code also ships with FXSAVE support on NetBSD.

Demo:

```
$ lldb ./watch                                                                                                                                      
(lldb) target create "./watch"
Current executable set to './watch' (x86_64).
(lldb) b main
Breakpoint 1: where = watch`main + 15 at watch.c:8, address = 0x000000000040087f
(lldb) r
Process 1573 launched: './watch' (x86_64)
Process 1573 stopped
* thread #1, stop reason = breakpoint 1.1
    frame #0: 0x000000000040087f watch`main(argc=1, argv=0x00007f7fffa12b88) at watch.c:8
   5    {
   6            int i, j, k;
   7    
-> 8            for (i = 0; i < 3; i++)
   9                    for (j = 0; j < 3; j++)
   10                           for (k = 0; k < 3; k++)
   11                                   printf("Hello world! i=%d j=%d k=%d\n", i, j, k);
(lldb) watch set var i
Watchpoint created: Watchpoint 1: addr = 0x7f7fffa12b4c size = 4 state = enabled type = w
    declare @ '/public/lldb_devel/watch.c:6'
    watchpoint spec = 'i'
    new value: 0
(lldb) c
Process 1573 resuming
Hello world! i=0 j=0 k=0
Hello world! i=0 j=0 k=1
Hello world! i=0 j=0 k=2
Hello world! i=0 j=1 k=0
Hello world! i=0 j=1 k=1
Hello world! i=0 j=1 k=2
Hello world! i=0 j=2 k=0
Hello world! i=0 j=2 k=1
Hello world! i=0 j=2 k=2
Process 1573 stopped
* thread #1, stop reason = trace
    frame #0: 0x00000000004008cc watch`main(argc=1, argv=0x00007f7fffa12b88) at watch.c:8
   5    {
   6            int i, j, k;
   7    
-> 8            for (i = 0; i < 3; i++)
   9                    for (j = 0; j < 3; j++)
   10                           for (k = 0; k < 3; k++)
   11                                   printf("Hello world! i=%d j=%d k=%d\n", i, j, k)
```

FPR (in another program using libm)

```
(lldb) register read --all
General Purpose Registers:
       rax = 0x000000000000001c
       rbx = 0x00007f7fff1d4fe0
       rcx = 0x000000000000000c
       rdx = 0x0000000000000002
       rdi = 0x0000746711d5b018  __sF + 152
       rsi = 0x0000000000000001
       rbp = 0x00007f7fff1d3d80
       rsp = 0x00007f7fff1d3d60
        r8 = 0x00007f7fff1d3470
        r9 = 0x0000000000000000
       r10 = 0x0000000000000001
       r11 = 0x0000000000000202
       r12 = 0x00007f7fff1d3da0
       r13 = 0x00007d8ad2d88500
       r14 = 0x0000000000000002
       r15 = 0x00007f7fffa627e0
       rip = 0x00000000004009e9  fpr`main + 217 at fpr.c:15
    rflags = 0x0000000000000202
        cs = 0x0000000000000047
        fs = 0x0000000000000000
        gs = 0x0000000000000000
        ss = 0x000000000000003f
        ds = 0x000000000000003f
        es = 0x000000000000003f
       eax = 0x0000001c
       ebx = 0xff1d4fe0
       ecx = 0x0000000c
       edx = 0x00000002
       edi = 0x11d5b018
       esi = 0x00000001
       ebp = 0xff1d3d80
       esp = 0xff1d3d60
       r8d = 0xff1d3470
       r9d = 0x00000000
      r10d = 0x00000001
      r11d = 0x00000202
      r12d = 0xff1d3da0
      r13d = 0xd2d88500
      r14d = 0x00000002
      r15d = 0xffa627e0
        ax = 0x001c
        bx = 0x4fe0
        cx = 0x000c
        dx = 0x0002
        di = 0xb018
        si = 0x0001
        bp = 0x3d80
        sp = 0x3d60
       r8w = 0x3470
       r9w = 0x0000
      r10w = 0x0001
      r11w = 0x0202
      r12w = 0x3da0
      r13w = 0x8500
      r14w = 0x0002
      r15w = 0x27e0
        ah = 0x00
        bh = 0x4f
        ch = 0x00
        dh = 0x00
        al = 0x1c
        bl = 0xe0
        cl = 0x0c
        dl = 0x02
       dil = 0x18
       sil = 0x01
       bpl = 0x80
       spl = 0x60
       r8l = 0x70
       r9l = 0x00
      r10l = 0x01
      r11l = 0x02
      r12l = 0xa0
      r13l = 0x00
      r14l = 0x02
      r15l = 0xe0

unknown:
     fctrl = 0x037f
     fstat = 0x0220
      ftag = 0x00
       fop = 0x0000
     fiseg = 0x11e1a52c
     fioff = 0x11e1a52c
     foseg = 0xff1d3d54
     fooff = 0xff1d3d54
     mxcsr = 0x00001fa0
  mxcsrmask = 0x0000ffff
       st0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
       st1 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
       st2 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
       st3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
       st4 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
       st5 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
       st6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
       st7 = {0xa5 0xdb 0x2d 0xbd 0x93 0xae 0xb9 0xfe 0xfe 0x3f}
       mm0 = 0x3fe9d13800000000
       mm1 = 0x3e0485fcce89c000
       mm2 = 0x3fefd735e0000000
       mm3 = 0x0000000000000000
       mm4 = 0x3fe0000000000000
       mm5 = 0x3fe00000005217f3
       mm6 = 0x0000000000000000
       mm7 = 0x3fefd735e0000000
      xmm0 = {0x00 0x00 0x00 0x00 0x38 0xd1 0xe9 0x3f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
      xmm1 = {0x00 0xc0 0x89 0xce 0xfc 0x85 0x04 0x3e 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
      xmm2 = {0x00 0x00 0x00 0xe0 0x35 0xd7 0xef 0x3f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
      xmm3 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
      xmm4 = {0x00 0x00 0x00 0x00 0x00 0x00 0xe0 0x3f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
      xmm5 = {0xf3 0x17 0x52 0x00 0x00 0x00 0xe0 0x3f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
      xmm6 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
      xmm7 = {0x00 0x00 0x00 0xe0 0x35 0xd7 0xef 0x3f 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
      xmm8 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
      xmm9 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
     xmm10 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
     xmm11 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
     xmm12 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
     xmm13 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
     xmm14 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
     xmm15 = {0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00}
       dr0 = 0x0000000000000000
       dr1 = 0x0000000000000000
       dr2 = 0x0000000000000000
       dr3 = 0x0000000000000000
       dr4 = 0x0000000000000000
       dr5 = 0x0000000000000000
       dr6 = 0x00000000ffff0ff0
       dr7 = 0x0000000000000400
22 registers were unavailable.
```

Sponsored by <The NetBSD Foundation>

Reviewers: labath, emaste, joerg, kettenis

Reviewed By: labath

Subscribers: #lldb

Tags: #lldb

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

llvm-svn: 300548
2017-04-18 12:53:35 +00:00
Jim Ingham 5cfe9294fe TestStaticVariables still fails on Linux.
llvm-svn: 300519
2017-04-18 00:44:14 +00:00
Jim Ingham 7c0d74aa2b This test is succeeding on macOS with clang.
llvm-svn: 300517
2017-04-18 00:20:59 +00:00
Jason Molenda 1781d6f732 Unify the common code in the ios, tvos, watchos platforms into a single
PlatformRemoveDarwinDevice class, subclassed to those three so they can 
provide their specific information.

<rdar://problem/30159764> 

llvm-svn: 300512
2017-04-17 22:52:20 +00:00
Davide Italiano 52ffb53909 [ClangASTContext] Placate `casts away qualifiers` warnings from GCC.
llvm-svn: 300476
2017-04-17 18:24:18 +00:00
Greg Clayton 84577092ba Don't ever reduce the timeout of a packet, only increase it.
Differential Revision: https://reviews.llvm.org/D32087

llvm-svn: 300455
2017-04-17 16:20:22 +00:00
Kuba Mracek 66785fdb25 ThreadSanitizer plugin: Support Swift access races and fix how external races are displayed.
llvm-svn: 300416
2017-04-16 04:02:45 +00:00
Zachary Turner 426d1379b0 Fix crash when completing in the current directory.
llvm-svn: 300386
2017-04-15 02:44:53 +00:00
Davide Italiano cf8a8294e5 [Interpreter] Make a static func a lambda and remove always_inline.
The attribute was fairly dubious as: a) we shouldn't tell the compiler
when to inline functions, b) GCC complains that the function may be
not always inlinable.

llvm-svn: 300377
2017-04-14 22:36:08 +00:00
Davide Italiano 49a28fdafb [ARM/Emulation] Remove an unneeded comparison and simplify. NFCI.
reg0 is always zero and comparison to an unsigned always yields
true.

llvm-svn: 300375
2017-04-14 22:27:28 +00:00
Chris Bieneman e0f17785f8 Fix bot breakage from r300372
Use #cmakedefine instead of #cmakedefine01 because the uses are ifndef instead of if.

llvm-svn: 300374
2017-04-14 22:20:36 +00:00
Davide Italiano 6462def06d [Process/Utility] Remove dead code. NFCI.
llvm-svn: 300373
2017-04-14 22:04:05 +00:00
Chris Bieneman b90bee044b [CMake] Support generating Config.h
Summary:
This patch removes the hand maintained config files in favor of auto-generating the config file. We will still need to maintain the defines for the Xcode builds on Mac, but all CMake builds use the generated header instead.

This will enable finer grained platform support tests and enable supporting LLDB on more platforms with less manual maintenance.

I have only tested this patch on Darwin, and any help testing it out on other platforms would be greatly appreciated. I've probably messed something up somewhere.

Reviewers: labath, zturner

Reviewed By: labath

Subscribers: krytarowski, emaste, srhines, lldb-commits, mgorny

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

llvm-svn: 300372
2017-04-14 22:03:45 +00:00
Greg Clayton 70a9f511c2 Increase the packet timeout for the jModulesInfo since it can take longer than the default 1 second timeout on some linux versions when many shared libraries are involved.
llvm-svn: 300342
2017-04-14 17:10:04 +00:00
Greg Clayton db1550ab66 Fixed to disassemble new packets and fixed the dumping of the 'x' packets.
llvm-svn: 300341
2017-04-14 17:05:21 +00:00
Jason Molenda 3f60829455 Don't use uuid_clear(), non-darwin platforms include
Utility/UuidCompatibility.h which gets you a definiton
of uuid_t but none of the functions that operate on it.

llvm-svn: 300162
2017-04-13 02:12:32 +00:00
Jason Molenda 9b7fcdcb57 Use two LC_NOTE load commands for identifying the main binary that
lldb should use when given a corefile.

This uses an LC_NOTE "main bin spec" or an LC_NOTE "kern ver str"
if they are present in a Mach-O core file.

Core files may have multiple different binaries -- different kernels,
or a mix of user process and kernel binaries -- and it can be
difficult for lldb to detect the correct one to use simply by looking
at the pages of memory.  These two new LC_NOTE load commands allow
for the correct binary to be recorded unambiguously.

<rdar://problem/20878266> 

llvm-svn: 300138
2017-04-12 23:33:30 +00:00
Chris Bieneman a4f532e0ac [NFC] Adding a new wrapper for getaddrinfo
Summary: This patch adds a new wrapper for getaddrinfo which returns a std::vector of SocketAddresses. While this patch doesn't add any uses of the new function, I have two separable patches that are dependent on this, so I put it in its own patch.

Reviewers: zturner

Reviewed By: zturner

Subscribers: lldb-commits

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

llvm-svn: 300112
2017-04-12 21:56:33 +00:00
Chris Bieneman efd065e6a0 Support Unit Testing debugserver
Summary:
This patch refactors the CMake build system's support for building debugserver to allow us to build the majority of debugserver's sources into the debugserverCommon library which can then be reused by unit tests.

The first unit test I've written tests debug server's ability to accept incoming connections from LLDB. The test forks the process, and one side creates a listening socket using debugserver's socket API, the other side creates a transmitting socket using LLDB's TCPSocket class.

I have no clue where to even start getting this connected into the LLDB Xcode project, so for now these tests are CMake-only.

Reviewers: zturner, labath, jasonmolenda

Subscribers: lldb-commits, mgorny

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

llvm-svn: 300111
2017-04-12 21:56:29 +00:00
Pavel Labath f0565cc84a Add libc++ category to the remaining libc++ data formatters
llvm-svn: 300054
2017-04-12 12:32:58 +00:00
Pavel Labath da7b15df70 Fix TestCppIncompleteTypes for android/clang
LDFLAGS contains some .a files. If it is specified before the relevant
object files, undefined symbol errors occur.

llvm-svn: 300048
2017-04-12 10:59:34 +00:00
Pavel Labath d3656a03ab Fix libc++ vector<bool> data formatter (bug #32553)
Summary:
The iteration list through the available data formatters was undefined,
which meant that the vector<bool> formatter kicked in only in cases
where it happened to be queried before the general vector formatter. To
fix this, I merge the two data formatter entries into one, and select
which implementation to use in the factory function.

Reviewers: jasonmolenda, tberghammer, EricWF

Subscribers: lldb-commits

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

llvm-svn: 300047
2017-04-12 10:59:24 +00:00
Pavel Labath 74207ad7ba Fix TestGuessLanguage for gcc
gcc emits DW_LANG_C89 even if we specify -std=c99 during compilation.
Since this isn't an lldb bug, but just the way the compiler happens to
be implemented, I teach the test to expect this situation correctly.

llvm-svn: 300046
2017-04-12 10:13:50 +00:00
Pavel Labath efe4e412ad Android.rules: setup correct objcopy path
This fixes a couple of tests when using android clang as a compiler.

llvm-svn: 300045
2017-04-12 10:13:47 +00:00
Jim Ingham bdbdd22937 Teach SBFrame how to guess its language.
<rdar://problem/31411646>

llvm-svn: 300012
2017-04-12 00:19:54 +00:00
Pavel Labath 0df645dda4 Add missing annotation to TestDataFormatterUnordered
llvm-svn: 299934
2017-04-11 12:26:33 +00:00
Pavel Labath f0a6d8ada3 Remove Plugins/Process/POSIX from include_directories
Summary:
The files there can always be referred to using their full path, which
is what most of the code has been doing already, so this makes the
situation more consistent. Also fix the the code in the FreeBSD plugin
to use the new paths.

Reviewers: eugene, emaste

Subscribers: lldb-commits, kettenis, mgorny, krytarowski

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

llvm-svn: 299933
2017-04-11 12:26:25 +00:00
Matt Arsenault 75696ffa25 Update for alloca construction changes
llvm-svn: 299898
2017-04-10 23:27:53 +00:00
Shoaib Meenai 96e541a7cf [lldb] Fix ninja URL
The old URL is a 404 now. Pointed out by Smirftsch1 on IRC.

llvm-svn: 299845
2017-04-10 15:41:15 +00:00
Jason Molenda 969230a702 Mark this test as XFAIL on all platforms, it's happening everywhere.
llvm.org/pr32553 and <rdar://problem/30646077> are tracking this.

llvm-svn: 299807
2017-04-07 23:20:22 +00:00
Kamil Rytarowski 426e864182 Correct environ parsing on NetBSD
Summary:
This replaces old code in Host::GetEnvironment for NetBSD
with the version from Linux. This makes parsing environment
variables correctly. It also fixes programs that depend on the
variables like curses(3) applications.

Long term this function should be moved to Process Plugin,
as currently env variables are not available with remote
debugging.

Other BSDs might want to catch up after this change.

Tested with NetBSD top(1).

Sponsored by <The NetBSD Foundation>

Reviewers: emaste, labath, joerg, kettenis

Reviewed By: emaste

Subscribers: #lldb

Tags: #lldb

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

llvm-svn: 299783
2017-04-07 16:45:36 +00:00
Ed Maste 70a26e93a9 Correct environ parsing on FreeBSD
Sync Host:GetEnvironment with Linux and Kamil Rytarowski's forthcoming
NetBSD change in review D31784.

llvm-svn: 299781
2017-04-07 16:40:25 +00:00
Eugene Zemtsov 5753710248 Add more tests for ExtractContextAndIdentifier
llvm-svn: 299729
2017-04-06 23:12:43 +00:00
Eugene Zemtsov a633ee6e4a New C++ function name parsing logic (Resubmit)
Current implementation of CPlusPlusLanguage::MethodName::Parse() doesn't
get anywhere close to covering full extent of possible function declarations.
It causes incorrect behavior in avoid-stepping and sometimes messes
printing of thread backtrace.

This change implements more methodical parsing logic based on clang
lexer and simple recursive parser.

Examples:
void std::vector<Class, std::allocator<Class>>::_M_emplace_back_aux<Class const&>(Class const&)
void (*&std::_Any_data::_M_access<void (*)()>())()

Previous version of this change (D31451) was rolled back due to an issue
with Objective-C selectors being incorrectly recognized as a C++ identifier.

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

llvm-svn: 299721
2017-04-06 22:36:02 +00:00
Zachary Turner 813de71329 Try to fix FreeBSD build after IWYU changes.
llvm-svn: 299719
2017-04-06 22:18:59 +00:00
Zachary Turner 720bd7af62 Fix build failure in unit test.
llvm-svn: 299718
2017-04-06 21:57:39 +00:00
Zachary Turner 2f3df6137a iwyu fixes for lldbCore.
This adjusts header file includes for headers and source files
in Core.  In doing so, one dependency cycle is eliminated
because all the includes from Core to that project were dead
includes anyway.  In places where some files in other projects
were only compiling due to a transitive include from another
header, fixups have been made so that those files also include
the header they need.  Tested on Windows and Linux, and plan
to address failures on OSX and FreeBSD after watching the
bots.

llvm-svn: 299714
2017-04-06 21:28:29 +00:00
Zachary Turner 8d4e2768be Try to fix FreeBSD build after iwyu changes.
llvm-svn: 299705
2017-04-06 20:51:22 +00:00
Tamas Berghammer 95776ad5b8 XFAIL TestDataFormatterLibcxxVBool on Linux & Android
The skipping logic for the test have been fixed recently but the test is
very flakey on the buildbot.

llvm-svn: 299677
2017-04-06 18:15:43 +00:00
Zachary Turner 4479ac15c9 iwyu fixes on lldbUtility.
This patch makes adjustments to header file includes in
lldbUtility based on recommendations by the iwyu tool
(include-what-you-use).  The goal here is to make sure that
all files include the exact set of headers which are needed
for that file only, to eliminate cases of dead includes (e.g.
someone deleted some code but forgot to delete the header
includes that that code necessitated), and to eliminate the
case where header includes are picked up transitively.

llvm-svn: 299676
2017-04-06 18:12:24 +00:00
Jason Molenda 30169d5ef2 Update unittests/Host/SocketTest.cpp to also use the new
one-socket API.

llvm-svn: 299613
2017-04-06 03:16:44 +00:00
Jason Molenda 3533cec58b Some old mach-o core files have an LC_IDENT load command
and there's a string in there that can be helpful in locating
the kernel binary.  Use it.
<rdar://problem/31444711> 

llvm-svn: 299612
2017-04-06 01:50:11 +00:00
Jim Ingham bef72b77fa getAsInteger is not a equivalent replacement for strtol
work around that fact for CommandObjectMemoryWrite.

<rdar://problem/31457148>

llvm-svn: 299609
2017-04-06 01:33:38 +00:00
Jason Molenda 90dce06f24 Change how UDP sockets are set up -- use the same one socket for
both sending and receiving information, instead of using one socket
to send and another to receive.  The two socket arrangement fails over
when a firewall is between the two systems.
<rdar://problem/31286757> 

llvm-svn: 299608
2017-04-06 01:21:44 +00:00
Pavel Labath 46f1d4a12c Annotate some more libc++ tests with the new category
This makes sure we are able to run them properly on android.

llvm-svn: 299588
2017-04-05 20:34:26 +00:00
Sean Callanan 894c147104 The darwin_log tests are very fragile and currently do not properly assess the state of that functionality.
I have put them all in their own category, and made that category disabled by default.

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

llvm-svn: 299587
2017-04-05 20:33:39 +00:00
Nitesh Jain d5be88ecf8 Fix a typo introduce in r299200.
llvm-svn: 299527
2017-04-05 09:31:43 +00:00
Jim Ingham 9645a6290a Reverting r299374 & r299402 due to testsuite failure.
This caused a failure in the test case:

  functionalities/breakpoint/objc/TestObjCBreakpoints.py

When we are parsing up names we stick interesting parts of the names
in various buckets, one of which is the ObjC selector bucket.  The new
C++ name parser must be interfering with this process somehow.

<rdar://problem/31439305>

llvm-svn: 299489
2017-04-05 00:08:21 +00:00
Jim Ingham 61cc47ad30 Tone down the "lldb types" log a bit.
Change the get shared class info function to only
dump its results to the inferior stdout when the
log is verbose.  This matches the lldb side of the
same process, which only logs what it found if the
log is on verbose.

llvm-svn: 299451
2017-04-04 17:48:21 +00:00