Commit Graph

17108 Commits

Author SHA1 Message Date
Pavel Labath f53288d596 Fix TestMixedDwarfBinary.py
As of yesterday, tests need to use self.getBuildArtifact() to get the
built executable.

llvm-svn: 323884
2018-01-31 16:23:24 +00:00
Davide Italiano 98f0021dd3 [lldb] Enable debugging of binaries with mixed (splitted/regular) dwarf
This recommits the patch, now that I verified that the bot instability
is due to something else. Sorry for the noise.

llvm-svn: 323879
2018-01-31 15:17:47 +00:00
Pavel Labath 73d8778437 Fix TestTargetSymbolsAddCommand makefile
We started passing the "all" target to make, which rendered the
"localall" trick in this Makefile inoperable.

I implement the strip step differently, and also reformat the Makefile.

llvm-svn: 323855
2018-01-31 09:14:12 +00:00
Davide Italiano 910f0a06c9 Revert "[lldb] Enable debugging of binaries with mixed (splitted/regular) dwarf"
It might have caused some instability on the bots.

llvm-svn: 323845
2018-01-31 04:13:37 +00:00
Alexander Shaposhnikov 2aea8f9787 [lldb] Enable debugging of binaries with mixed (splitted/regular) dwarf
Initialize the default value of SymbolFileDWARF uuid with 
the appropriately shifted DW_INVALID_OFFSET constant.
This change fixes the collision in the computation of DIE uid 
(inside DIERef::GetUID) and incorrect CompileUnit lookup
(because of the misleading cu_offset value).

Test plan: make check-lldb

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

llvm-svn: 323832
2018-01-30 23:45:20 +00:00
Adrian Prantl dbdda6a1e7 Enforce that NO_DEBUG_INFO_TESTCASEs build using buildDefault().
This is a prerequisite for building each test variant in its own subdirectory.

llvm-svn: 323830
2018-01-30 23:15:49 +00:00
Vedant Kumar e2fbd7035d XUnit Formatter: Handle UTF-8 decode errors on invalid XML
Strings which contain garbage data can trigger an exception in the XUnit
plugin at the UTF-8 decode step because the decode is strict. Use a lax
mode to avoid an exception.

See: https://ci.swift.org/job/oss-lldb-incremental-osx/780
llvm-svn: 323817
2018-01-30 21:16:42 +00:00
Vedant Kumar 61a29ded5d PR25934: Skip EventAPITestCase. It still SEGV's on Darwin.
See: https://ci.swift.org/job/swift-lldb-PR-osx/39

llvm.org/PR25934

llvm-svn: 323809
2018-01-30 19:49:05 +00:00
Adrian Prantl ee2d2bfbcd Add more diagnostics to help diagnose flaky test
llvm-svn: 323808
2018-01-30 19:40:09 +00:00
Jim Ingham 34b58a0ae4 Rewrite this test not to use pexpect.
llvm-svn: 323805
2018-01-30 18:43:31 +00:00
Adrian Prantl 5ec76fe720 Compile the LLDB tests out-of-tree.
This patch is the result of a discussion on lldb-dev, see
http://lists.llvm.org/pipermail/lldb-dev/2018-January/013111.html for
background.

For each test (should be eventually: each test configuration) a
separate build directory is created and we execute

  make VPATH=$srcdir/path/to/test -C $builddir/path/to/test -f $srcdir/path/to/test/Makefile -I $srcdir/path/to/test

In order to make this work all LLDB tests need to be updated to find
the executable in the test build directory, since CWD still points at
the test's source directory, which is a requirement for unittest2.

Although we have done extensive testing, I'm expecting that this first
attempt will break a few bots. Please DO NOT HESITATE TO REVERT this
patch in order to get the bots green again. We will likely have to
iterate on this some more.

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

llvm-svn: 323803
2018-01-30 18:29:16 +00:00
Adrian Prantl 43a68f1f03 Enforce that tests building with buildDefault set NO_DEBUG_INFO_TESTCASE
and fix resulting errors. This is a prerequisite for building each
test variant in its own build directory.

llvm-svn: 323789
2018-01-30 17:02:42 +00:00
Pavel Labath 26fa1f2be3 One more TestGDBRemoteClient/windows fix
We also need to be .EXE-aware when searching for the clang binary.

llvm-svn: 323763
2018-01-30 14:33:54 +00:00
Pavel Labath c561a6a920 Add LLDB_LOG_ERROR macro
Summary:
The difference between this and regular LLDB_LOG is that this one clears
the error object unconditionally.  This was inspired by the
ObjectFileELF bug (r322664), where the error object was being cleared
only if logging was enabled.

Reviewers: davide, zturner, jingham, clayborg

Subscribers: lldb-commits, emaste

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

llvm-svn: 323753
2018-01-30 12:19:34 +00:00
Pavel Labath 06f442c384 Fix TestGDBRemoteClient on windows
The logic was incorrect because on windows, we need to look for
yaml2obj.EXE. I implement the search in terms of
distutils.spawn.find_executable, which should handle the platform
differences for us.

llvm-svn: 323744
2018-01-30 10:41:46 +00:00
Pavel Labath af379085ef Skip TestWithModuleDebugging on i386 linux (pr36146)
It fails due to an assertion (if these are enabled).

llvm-svn: 323736
2018-01-30 09:39:22 +00:00
Vedant Kumar ba9838783a dotest: Apply --skip-categories to debug info categories
llvm-svn: 323723
2018-01-30 03:36:00 +00:00
Davide Italiano b0edeb90ab [test-suite] UNXfail several tests that now pass locally.
Another step towards enabling unexpected successes as failures
by default.

llvm-svn: 323707
2018-01-29 23:24:50 +00:00
Michal Gorny c061175fcd [Host] Respect LLVM_LIBDIR_SUFFIX when looking for LLDB plugins on Linux
Fix the Linux plugin lookup path to include appropriate libdir suffix
for the system. To accomplish this, store the value of
LLVM_LIBDIR_SUFFIX in lldb/Host/Config.h as LLDB_LIBDIR_SUFFIX,
and use this variable when defining the plugin path.

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

llvm-svn: 323673
2018-01-29 18:25:06 +00:00
Kirill Bobyrev de6fad6935 [lldb] Silence signed <-> unsigned integer comparison warning
`num_args` is unsigned integer, declared as below:

```
uint32_t num_args = arg_enum->getChildCount();
```

Comparison with the signed `arg_idx` produces a warning when compiled with
-Wsign-compare flag, this patch addresses this simple issue without affecting
any functionality.

Reviewers: davide, asmith
Subscribers: lldb-commits
Differential Revision: https://reviews.llvm.org/D42620

llvm-svn: 323645
2018-01-29 12:59:07 +00:00
Pavel Labath 02d4e50e9d Fix NetBsd build broken by r323637
llvm-svn: 323639
2018-01-29 11:10:21 +00:00
Pavel Labath 36e82208c7 Remove ObjectFile usage from HostLinux::GetProcessInfo
Summary:
The ObjectFile class was used to determine the architecture of a running
process by inspecting it's main executable. There were two issues with
this:
- it's in the wrong layer
- the call can be very expensive (it can end up computing the crc of the
  whole file).

Since the process is running on the host, ideally we would be able to
just query the data straight from the OS like darwin does, but there
doesn't seem to be a reasonable way to do that. So, this fixes the
layering issue by using the llvm object library to inspect the file.
Since we know the process is already running on the host, we just need
to peek at a few bytes of the elf header to determine whether it's 32-
or 64-bit (which should make this faster as well).

Pretty much the same logic was implemented in
NativeProcessProtocol::ResolveProcessArchitecture, so I delete this
logic and replace calls with GetProcessInfo.

Reviewers: eugene, krytarowski

Subscribers: mgorny, hintonda, lldb-commits

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

llvm-svn: 323637
2018-01-29 10:46:00 +00:00
Pavel Labath 1902ffd9a4 [lldb] Generic base for testing gdb-remote behavior
Summary:
Adds new utilities that make it easier to write test cases for lldb acting as a client over a gdb-remote connection.

- A GDBRemoteTestBase class that starts a mock GDB server and provides an easy way to check client packets
- A MockGDBServer that, via MockGDBServerResponder, can be made to issue server responses that test client behavior.
- Utility functions for handling common data encoding/decoding
- Utility functions for creating dummy targets from YAML files

----

Split from the review at https://reviews.llvm.org/D42145, which was a new feature that necessitated the new testing capabilities.

Reviewers: clayborg, labath

Reviewed By: clayborg, labath

Subscribers: hintonda, davide, jingham, krytarowski, mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D42195
Patch by Owen Shaw <llvm@owenpshaw.net>

llvm-svn: 323636
2018-01-29 10:02:40 +00:00
Jan Kratochvil 6492caab1d Remove unused class declarations
Simplification by removing excessive DWARFCompileUnit references for D40466 .

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

llvm-svn: 323586
2018-01-27 14:35:33 +00:00
Davide Italiano 643b2b9e26 [lldbtestsuite] Don't crash on `None` input for is_exe().
Now the function returns `False`, and the caller can take the
appropriate action (in this case, for --executable, reporting
that the file doesn't exist).

llvm-svn: 323566
2018-01-26 21:46:10 +00:00
Pavel Labath 61e07bb481 gmodules XFAIL two more tests that only fail for android (pr36109)
llvm-svn: 323537
2018-01-26 16:05:46 +00:00
Pavel Labath e8524e0ca2 Fix linux fallout from c++ gmodules enable
TestLibcxxListLoop - fails because the evil "define private public"
  trick does not work with gmodules. The purpose of the test is not to
  test debug info parsing so I just mark it as no_debug_info_testcase.
  In the long term it may be interesting to write a mock std::list which
  will allow us to test bad inputs to data formatters more easily.
TestGModules - seems to be a genuine bug. Filed pr36107 and xfailed.

llvm-svn: 323520
2018-01-26 11:40:59 +00:00
Vedant Kumar c2ca1261a2 [test] Fix a test that never compiled under -fmodules
This test #include's stdio.h, which, on at least two bots results in a
module import of MacTypes.h (due to weird SDK layering issues), which
causes the test to fail to compile.

Just don't #include stdio.h, as it's not needed for the test.

llvm-svn: 323467
2018-01-25 21:20:29 +00:00
Vedant Kumar 801362f067 Use test-specific module caches to avoid stale header conflicts
Stale global module caches cause problems for the bots. The modules
become invalid when clang headers are updated by version control, and
tests which use these modules fail to compile, e.g:

  fatal error: file '.../__stddef_max_align_t.h' has been modified since the module file '/var/.../Darwin.pcm' was built
  note: please rebuild precompiled header '/var/.../Darwin.pcm'

Eventually we should transition to having just a single module cache to speed
tests up. This patch should be just enough to fix the spurious bot failures due
to stale caches.

rdar://36479805, also related to llvm.org/PR36048

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

llvm-svn: 323450
2018-01-25 18:01:27 +00:00
Saleem Abdulrasool be86661c6f www: update lldb architecture doc
ArchSpec was moved from Core to Utility, so I modified the docs to
reflect that.

Patch by Alex Langford <apl@fb.com>!

llvm-svn: 323363
2018-01-24 19:00:08 +00:00
Pavel Labath d5a56e48b9 Remove unused includes from the Host module
llvm-svn: 323340
2018-01-24 16:40:22 +00:00
Aaron Smith ec40f818c6 [SymbolFilePDB] Fix null array access when parsing the type of a function without any arguments, i.e. 'int main()' and add support to test it
Summary:
- Fix a null array access bug. This happens when creating the lldb type for a function that has no argument.
- Implement SymbolFilePDB::ParseTypes method. Using `lldb-test symbols` will show all supported types in the target.
- Create lldb types for variadic function, PDBSymbolTypePointer, PDBSymbolTypeBuiltin
- The underlying builtin type for PDBSymbolTypeEnum is always `Int`, correct it with the very first enumerator's encoding if any. This is more accurate when the underlying type is not signed or another integer type.
- Fix a bug when the compiler type is not created based on PDB_BuiltinType. For example, basic type `long` is of same width as `int` in a 32-bit target, and the compiler type of former one will be represented by the one generated for latter if using the default method. Introduce a static function GetBuiltinTypeForPDBEncodingAndBitSize to correct this issue.
- Basic type `long double` and `double` have the same bit size in MSVC and there is no information in a PDB to distinguish them. The compiler type of the former one is represented by the latter's.
- There is no line information about typedef, enum etc in a PDB and the source and line information for them are not shown.
- There is no information about scoped enumeration. The compiler type is represented as an unscoped one.

Reviewers: zturner, lldb-commits

Reviewed By: zturner

Subscribers: majnemer, llvm-commits

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

llvm-svn: 323255
2018-01-23 20:35:19 +00:00
Adrian Prantl eac1c02d2a Move getBuildArtifact() from TestBase to Base and derive MiTestCaseBase from it
Thanks to Pavel Labath for pointing this out!

llvm-svn: 323219
2018-01-23 16:43:01 +00:00
Raphael Isemann b90f81ed82 Fix memory leaks in GoParser
Summary: The GoParser is leaking memory in the tests due to not freeing allocated nodes when encountering some parsing errors. With this patch all GoParser tests are passing with enabled memory sanitizers/ubsan.

Reviewers: labath, davide

Reviewed By: labath

Subscribers: lldb-commits

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

llvm-svn: 323197
2018-01-23 13:50:46 +00:00
Raphael Isemann acc48f3e1d Prevent unaligned memory read in parseMinidumpString
Summary:
It's possible to hit an unaligned memory read when reading `source_length` as the `data` array is only aligned with 2 bytes (it's actually a UTF16 array). This patch memcpy's `source_length` into a local variable to prevent this:

```
MinidumpTypes.cpp:49:23: runtime error: load of misaligned address 0x7f0f4792692a for type 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte alignment
```

Reviewers: dvlahovski, zturner, davide

Reviewed By: davide

Subscribers: davide, lldb-commits

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

llvm-svn: 323181
2018-01-23 08:04:27 +00:00
Lang Hames 48b32f4ced [lldb] Fix some C++ virtual method call bugs in LLDB expression evaluation by
building method override tables for CXXMethodDecls in 
DWARFASTParserClang::CompleteTypeFromDWARF.

C++ virtual method calls in LLDB expressions may fail if the override table for
the method being called is not correct as IRGen will produce references to the
wrong (or a missing) vtable entry.

This patch does not fix calls to virtual methods with covariant return types as
it mistakenly treats these as overloads, rather than overrides. This will be
addressed in a future patch.

Review: https://reviews.llvm.org/D41997

Partially fixes <rdar://problem/14205774>

llvm-svn: 323163
2018-01-22 23:53:56 +00:00
Raphael Isemann 5a3cf664ef Fix memory leak in TestClangASTContext.TestRecordHasFields
Summary: We can't use unique_ptr's here because we use those variables as `out` parameters to some functions. Discovered by the memory sanitizer.

Subscribers: lldb-commits

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

llvm-svn: 323138
2018-01-22 18:56:33 +00:00
Raphael Isemann 57f9b363c1 Fix uninitialized variable in GoParser
Summary:
`m_last_tok` isn't initialized anywhere before it's used the first time (most likely in the `GoParser::Rule::error` method), which causes most of the GoParser tests to fail with sanitizers enabled with errors like this:

```
GoParser.cpp:52:21: runtime error: load of value <random value>, which is not a valid value for type 'GoLexer::TokenType'
UndefinedBehaviorSanitizer: undefined-behavior GoParser.cpp:52:21
```

Reviewers: ribrdb, davide, labath

Reviewed By: labath

Subscribers: labath, lldb-commits

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

llvm-svn: 323119
2018-01-22 14:32:43 +00:00
Pavel Labath 11d0b29446 Revert "[SymbolFilePDB] Fix null array access when parsing the type of a function without any arguments, i.e. 'int main()' and add support to test it"
This reverts commit r322995, as it breaks
lldb-Unit::SymbolFilePDBTests.TestTypedefs
<http://lab.llvm.org:8011/builders/lldb-windows7-android/builds/7715>.

llvm-svn: 323102
2018-01-22 11:51:56 +00:00
Pavel Labath 6a92e99b64 Add SysV Abi for PPC64le
Summary:
This patch implements the ABI Plugin for PPC64le. It was based on the
ABI for PPC64. It also enables LLDB to evaluate expressions using JIT.

Reviewers: labath, clayborg, jhibbits, davide

Reviewed By: labath, clayborg, jhibbits, davide

Subscribers: davide, JDevlieghere, chmeee, emaste, jhibbits, hfinkel, lldb-commits, nemanjai, luporl, lbianc, mgorny, anajuliapc, kbarton

Differential Revision: https://reviews.llvm.org/D41702
Patch by Alexandre Yukio Yamashita <alexandre.yamashita@eldorado.org.br>

llvm-svn: 323100
2018-01-22 11:27:43 +00:00
Pavel Labath 717937d586 Fix TestTargetSymbolsAddCommand [getBuildArtifact refactor]
llvm-svn: 323086
2018-01-22 09:55:30 +00:00
Raphael Isemann 8f52340766 Fix memory leaks in MinidumpParserTest
Summary: We never delete the allocated RegisterContext objects, causing those tests to fail with enabled memory sanitizer.

Reviewers: dvlahovski, zturner

Reviewed By: zturner

Subscribers: zturner, lldb-commits

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

llvm-svn: 323085
2018-01-22 09:48:40 +00:00
Raphael Isemann 1784388567 Fix use after free in DiskFilesOrDirectories
Summary:
We copy the local variable `Resolved` into `Storage` to keep it around. However, we then still let the `SearchDir` ref point to `Resolved` which then is used to access the already freed memory later on. With this patch we point to `Storage` which doesn't get deleted after the current scope exits.

Discovered by memory sanitizer in the CompletionTest.DirCompletionUsername test.

Reviewers: zturner

Subscribers: lldb-commits

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

llvm-svn: 323082
2018-01-22 09:17:16 +00:00
Raphael Isemann 0b16ef7814 Fix unrepresentable float value in ScalarTest
Summary: float can't represent the given value in the literal, so we get this UB error: `runtime error: 1.23457e+48 is outside the range of representable values of type 'float'`. The test seems to not rely on this specific value, so let's just choose a smaller one that can be represented.

Reviewers: uweigand

Subscribers: lldb-commits

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

llvm-svn: 323081
2018-01-22 08:11:29 +00:00
Raphael Isemann bb3c570633 Fix memory leaks in TestArm64InstEmulation
Summary: We never delete the created instances, so those test fail with the memory sanitizer.

Reviewers: jasonmolenda

Reviewed By: jasonmolenda

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

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

llvm-svn: 323076
2018-01-22 07:22:13 +00:00
Raphael Isemann fbdf0b9315 Make loop counter unsigned in SymbolFilePDB::GetCompileUnitIndex
Summary: This fixes a clang warning.

Reviewers: zturner

Reviewed By: zturner

Subscribers: zturner, lldb-commits

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

llvm-svn: 323075
2018-01-22 06:56:09 +00:00
Jan Kratochvil 79834a1fce Clean up #include "DWARFCompileUnit.h"
Clean up needless+missing #include "DWARFCompileUnit.h" for split of
DWARFCompileUnit to DWARFUnit as discussed in D40466.

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

llvm-svn: 323069
2018-01-21 18:03:17 +00:00
Raphael Isemann e07688898b [modules] Fix missing includes/typo in LLDB's includes. [NFC]
Summary:
This patch adds missing includes to the LLDB headers inside `include/` as a first step of building LLDB's source with C++ modules. It also fixes this single `stds::` typo.

Some quick map why some non-obvious includes were necessary:
* lldb/lldb-defines.h for LLDB_INVALID_ADDRESS
* lldb/lldb-types.h for addr_t
* lldb/lldb-defines.h for DISALLOW_COPY_AND_ASSIG
* lldb/DataFormatters/TypeSynthetic.h for SyntheticChildrenFrontEnd

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: zturner, lldb-commits

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

llvm-svn: 323064
2018-01-21 09:54:19 +00:00
Adrian Prantl 595048f3ec Wrap all references to build artifacts in the LLDB testsuite (NFC)
in TestBase::getBuildArtifact(). This NFC commit is in preparation for
https://reviews.llvm.org/D42281 (compile the LLDB tests out-of-tree).

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

llvm-svn: 323007
2018-01-19 23:24:35 +00:00
Aaron Smith 563799b3a6 [SymbolFilePDB] Fix null array access when parsing the type of a function without any arguments, i.e. 'int main()' and add support to test it
Summary:
- Fix a null array access bug. This happens when creating the lldb type for a function that has no argument.
- Implement SymbolFilePDB::ParseTypes method. Using `lldb-test symbols` will show all supported types in the target.
- Create lldb types for variadic function, PDBSymbolTypePointer, PDBSymbolTypeBuiltin
- The underlying builtin type for PDBSymbolTypeEnum is always `Int`, correct it with the very first enumerator's encoding if any. This is more accurate when the underlying type is not signed or another integer type.
- Fix a bug when the compiler type is not created based on PDB_BuiltinType. For example, basic type `long` is of same width as `int` in a 32-bit target, and the compiler type of former one will be represented by the one generated for latter if using the default method. Introduce a static function GetBuiltinTypeForPDBEncodingAndBitSize to correct this issue.
- Basic type `long double` and `double` have the same bit size in MSVC and there is no information in a PDB to distinguish them. The compiler type of the former one is represented by the latter's.
- There is no line informaton about typedef, enum etc in a PDB and the source and line information for them are not shown.
- There is no information about scoped enumeration. The compiler type is represented as an unscoped one.

Reviewers: zturner, lldb-commits, davide, asmith

Reviewed By: zturner, asmith

Subscribers: llvm-commits, davide

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

llvm-svn: 322995
2018-01-19 21:55:44 +00:00
Pavel Labath 91f14e69b8 Remove Platform references from the Host module
Summary:
These were used by Host::LaunchProcess to "resolve" the executable it
was about to launch. The only parts of Platform::ResolveExecutable, which
seem to be relevant here are the FileSpec::ResolvePath and
ResolveExecutableLocation calls.

The rest (most) of that function deals with selecting an architecture
out of a fat binary and making sure we are able to create a Module with that
slice. These are reasonable actions when selecting a binary to debug,
but not for a generic process launching framework (it's technically even
wrong because we should be able to launch a binary with execute
permissions only, but trying to parse such file will obviously fail).

I remove the platform call by inlining the relevant FileSpec calls and
ignoring the rest of the Platform::ResolveExecutable code.  The
architecture found by the slice-searching code is being ignored already
anyway, as we use the one specified in the LaunchInfo, so the only
effect of this should be a different error message in case the
executable does not contain the requested architecture -- before we
would get an error message from the Platform class, but now we will get
an error from the actual posix_spawn syscall (this is only relevant on
mac, as it's the only target supporting fat binaries).

Launching targets for debugging should not be affected as here the
executable is pre-resolved at the point when the Target is created.

Reviewers: jingham, clayborg

Subscribers: lldb-commits, emaste

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

llvm-svn: 322935
2018-01-19 11:10:54 +00:00
Pavel Labath 8872d703ad Fix logging test on windows
Refactor in r322653 broke the logging test on windows because MSVC uses
a fully qualified name as the value of __FUNCTION__, which is not what
we were expecting. I'm changing the code to use the more portable
__func__, which behaves the same as on clang/gcc.

The standard still says that the value of __func__ is implementation
defined, so if we run into problems with this test again we may just
need to drop it.

llvm-svn: 322834
2018-01-18 11:15:50 +00:00
Vedant Kumar 3c3345be1b [CMake] Make check-lldb work with LLDB_CODESIGN_IDENTITY=''
On Darwin, if a test machine isn't set up for code-signing (see
docs/code-signing.txt), running check-lldb should use the system
debugserver instead of the unsigned one built in-tree. This makes it
possible to run lldb's test suite without having code-signing set up,
which is really convenient.

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

llvm-svn: 322803
2018-01-18 01:16:30 +00:00
Vedant Kumar 75d7ee6af5 A third attempt to mark TestRdar12408181.py as skipped
Due to an unfortunate difference between the open source test harness
and our internal harness, applying two @skip... decorators to this test
works in the internal build but not in the open source build.

I've tried another approach to skipping this test and tested it out with
the open source harness. Hopefully this sticks!

rdar://36417163

llvm-svn: 322756
2018-01-17 20:54:39 +00:00
Vedant Kumar d122baec22 Try again to mark TestRdar12408181.py as skipped
rdar://36417163

llvm-svn: 322740
2018-01-17 19:25:12 +00:00
Vedant Kumar cc9fd4b661 Skip a flaky test (TestRdar12408181.py)
This test frequently times out on our bots. While we're investigating
the issue, mark the test as skipped so the builds aren't impacted as
much.

rdar://36417163

llvm-svn: 322728
2018-01-17 18:53:42 +00:00
Pavel Labath 555130c3f6 [lldb][PPC64] Fixed long double variables dump
Summary:
LLDB's DumpDataExtractor was not prepared to handle PowerPC's long double type: PPCDoubleDouble.

As it is somewhat special, treating it as other regular float types resulted in getting wrong information about it.
In this particular case, llvm::APFloat::getSizeInBits(PPCDoubleDouble) was returning 0.

This caused the TestSetValues.py test to fail, because lldb would abort on an assertion failure on APInt(), because of the invalid size.

Since in the PPC case the value of item_byte_size was correct and the
getSizeInBits call was only added to support x87DoubleExtended
semantics, this restricts the usage of getSizeInBits to the x87
semantics.

Reviewers: labath, clayborg

Reviewed By: labath

Subscribers: llvm-commits, anajuliapc, alexandreyy, lbianc, lldb-commits

Differential Revision: https://reviews.llvm.org/D42083
Author: Leandro Lupori <leandro.lupori@gmail.com>

llvm-svn: 322666
2018-01-17 15:11:20 +00:00
Pavel Labath b424de390e Fix assertion in ObjectFileELF
In D40616 I (mistakenly) assumed that logging an llvm::Error would clear
it. This of course is only true if logging is actually enabled.

This fixes the assertion by manually clearing the error, but it raises
the point of whether we need a special error-clearing logging primitive.

llvm-svn: 322664
2018-01-17 14:40:25 +00:00
Pavel Labath 243ea5b5fe Simplify some LogTest tests
This removes boilerplate for setting up a log channel and capturing the
output from some of the tests. I do this by moving the setup code into a
test fixture and adding a logAndTakeOutput utility function to log some
string and then retrieve it from the log.

I also use some googlemock goodies to simplify a couple of assertions.

llvm-svn: 322653
2018-01-17 13:46:06 +00:00
Jason Molenda 0af609d17c Remove the hardcoded macos deployment targets altogether
from the xcode project files.  We'll build for the current
OS only, by default.  

llvm-svn: 322603
2018-01-17 00:22:27 +00:00
Pavel Labath dbda285178 One more attempt to fix NetBSD build
llvm-svn: 322477
2018-01-15 11:50:05 +00:00
Pavel Labath e831bb3cd9 Fix NetBSD build for llvm r322475
llvm-svn: 322476
2018-01-15 11:32:43 +00:00
Pavel Labath cc2ba02817 Fix HostInfoBase::ComputeSharedLibraryDirectory comment
The comment seems to indicate that this function would return the "bin"
directory on linux. I've verified that this is not the case, so I'm
updating the comment to match.

llvm-svn: 322472
2018-01-15 09:56:00 +00:00
Aaron Smith 10a02577ea [lldb] Add support to cache a PDB's global scope and fix a bug in getting the source file name for a compiland
Summary:
This commit is a combination of the following changes:
    
- Cache PDB's global scope (executable) in SymbolFilePDB  

- Change naming of `cu` to `compiland` which is PDB specific   

- Change ParseCompileUnitForSymIndex to ParseCompileUnitForUID.
   Prefer using a common name `UID` instead of PDB's `System Index`
   Adding one more argument `index` to this method, which is used to
   specify the index of the compile unit in a cached compile unit array
    
- Add GetPDBCompilandByUID method to simply code
    
- Fix a bug in getting the source file name for a PDB compiland.
   For some reason, PDBSymbolCompiland::getSourceFileName() could
   return an empty name, so if that is true, we have to walk through all
   source files of this compiland and determine the right source file
   used to generate this compiland based on language indicated.
    
   The previous implementation called PDBSession::findOneSourceFile 
   method to get its name for the compiland. This is not accurate since
   the `one source file` found could be a header other than source file.

Reviewers: zturner, lldb-commits

Reviewed By: zturner

Subscribers: llvm-commits

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

llvm-svn: 322433
2018-01-13 06:58:18 +00:00
Jason Molenda 9f0115fe1c We have two sources for path remapping information that we get out
of a dSYM per-uuid plist that may be present (dsymutil does not
create this plist, it is only added after the fact by additional
tools) -- either the DBGBuildSourcePath + DBGSourcePath pair of
k-v entries which give us the build-time and debug-time remapping,
or the newer DBGSourcePathRemapping dictionary which may give us
multiple remappings.

I'm changing the order that we process these & add them to the
list of source remappings.  If the DBGSourcePathRemapping dict
is present, it should be the first entries we will try.

<rdar://problem/36481989> 

llvm-svn: 322418
2018-01-12 22:42:45 +00:00
Jim Ingham 5ec7cd7227 Fix Breakpoint::RemoveInvalidLocations to fix the exec testcase.
RemoveInvalidLocations was clearing out the m_locations in the
breakpoint by hand, and it wasn't also clearing the locations from
the address->location map, which confused us when we went to update
breakpoint locations.  

I also made Breakpoint::ModulesChanged check the Location's Section
to make sure it hadn't been deleted.  This shouldn't strictly be necessary,
but if the DynamicLoaderPlugin doesn't do it's job right (I'm looking at
you new Darwin DynamicLoader...) then it can end up leaving stale locations
on rerun.  It doesn't hurt to clean them up here as a backstop.

<rdar://problem/36134350>

llvm-svn: 322348
2018-01-12 03:03:23 +00:00
Jim Ingham 8157e8ee8c Fix the Makefile - this version should work on the bot
llvm-svn: 322341
2018-01-12 01:30:33 +00:00
Vedant Kumar 3ffbbeabbc Skip TestFunctionTemplateParameterPack.py, which unexpectedly asserts (PR35920)
This test stresses expression evaluation support for template functions.
Currently the support is rudimentary, and running this test causes assertion
failures in clang. This test cannot be XFAIL'ed because the test harness
treats assertion failures as unexpected events. For now, the test must be
skipped.

llvm-svn: 322340
2018-01-12 01:23:52 +00:00
Jason Molenda c4dd04c5c3 When parsing the target.xml register file, if no architecture has
been specified yet (either by the user, or by one of the lldb
extensions like qHostInfo or qProcessInfo), and the target.xml
includes a <architecture> tag specifying x86_64, set the architecture
appropriately.

I'm not sure what we can expect to see in the <architecture> tag, so
I'm only doing this for x86_64 right now where I've seen "i386:x86_64"
used.  I've seen a target.xml from a jtag board that sends just "arm"
because it doesn't know more specifically what type of board it is
connected to...  

<rdar://problem/29908970> 

llvm-svn: 322339
2018-01-12 01:16:13 +00:00
Jim Ingham e38b018df4 Print the SBDebugger.CreateTarget error message.
This is failing on the bot but not locally.  Maybe
the error message will tell us why.

llvm-svn: 322338
2018-01-12 01:12:45 +00:00
Jim Ingham f4b0884718 Fix the same thinko in another place...
Thanks Jason.

llvm-svn: 322329
2018-01-11 23:52:50 +00:00
Jim Ingham 7581337382 Fix a tiny thinko in this test and re-add.
target.IsValid() not target...

llvm-svn: 322328
2018-01-11 23:31:29 +00:00
Davide Italiano 4bec480f71 [testsuite] Remove a broken test which tried to find App in bundles.
That never really worked, and the change associated isn't yet
committed, so, let's try to make the bots green for now.

llvm-svn: 322322
2018-01-11 22:38:57 +00:00
Pavel Labath b6ac2d9694 Make the bundle folders in the find-app-in-bundle test non-empty
git will not create empty folders, which makes this test fail if the repo is
checked out with git.

llvm-svn: 322271
2018-01-11 12:21:58 +00:00
Tatyana Krasnukha 6c2c08f3a1 Check existence of each required component during construction of LLVMCDisassembler.
Summary:
Actually, fix two issues:

  # remove repeat creation of reg_info, use m_reg_info_ap  for createMCAsmInfo instead;

  # remove possibility to dereference nullptr during createMCAsmInfo invocation, that could lead to undefined behavior.

Placed checking of a component right after its creation to simplify the code and avoid same issues later.

Reviewers: zturner, clayborg, jingham, jasonmolenda, labath

Reviewed By: clayborg, labath

Subscribers: labath, lldb-commits

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

llvm-svn: 322270
2018-01-11 12:06:22 +00:00
Eugene Zemtsov b7386d9943 Advanced guessing of rendezvous breakpoint (resubmit)
When rendezvous structure is not initialized we need to set up
rendezvous breakpoint anyway. In this case the code will locate
dynamic loader (interpreter) and look for known function names.

This is r322209, but with fixed VDSO loading fixed.

Bug: https://bugs.llvm.org/show_bug.cgi?id=25806
Differential Revision: https://reviews.llvm.org/D41533

llvm-svn: 322251
2018-01-11 03:46:35 +00:00
Jim Ingham e8db13da0a Running this on other systems won't work because I don't
know how to specifically build a MachO binary on other systems.

llvm-svn: 322239
2018-01-10 23:32:43 +00:00
Jason Molenda 8049b4db55 Remove Environment.h, test-dwarf.cpp, test-dwarf.exe
from being listed as a part of the desktop or 
desktop/desktop_no_xpc Targets - they should not be
a part of any target.  Having them listed as a part of
desktop target results in them being added to the 
Copy Files build phase for desktop and I'm guessing
they'd end up in the manpage directory or something.

llvm-svn: 322237
2018-01-10 23:11:29 +00:00
Jim Ingham 1f74a24ac0 Runs the part of the test that just finds the binary on all systems.
That should work everywhere. Then only try actually running on macosx.

llvm-svn: 322235
2018-01-10 23:06:34 +00:00
Jim Ingham d657eb6551 Add a test for finding a binary in an app package.
llvm-svn: 322232
2018-01-10 22:52:42 +00:00
Eugene Zemtsov 5c84e4b001 Revert "Advanced guessing of rendezvous breakpoint"
This reverts commit r322209, because it broke
TestNoreturnUnwind,TestInferiorAssert and TestNumThreads on i386.

llvm-svn: 322229
2018-01-10 22:25:33 +00:00
Eugene Zemtsov 4c3ea8029e Advanced guessing of rendezvous breakpoint
When rendezvous structure is not initialized we need to set up
rendezvous breakpoint anyway. In this case the code will locate
dynamic loader (interpreter) and look for known function names.

Bug: https://bugs.llvm.org/show_bug.cgi?id=25806
Differential Revision: https://reviews.llvm.org/D41533

llvm-svn: 322209
2018-01-10 19:04:36 +00:00
Davide Italiano 90d96aa107 [XCodebuild] Catch up with recent changes (Environment.cpp).
llvm-svn: 322208
2018-01-10 18:53:00 +00:00
Pavel Labath 7da84753a3 Handle O reply packets during qRcmd
Summary:
Gdb servers like openocd may send many $O reply packets for the client to output during a qRcmd command sequence.  Currently, lldb interprets the first O packet as an unexpected response.  Besides generating no output, this causes lldb to get out of sync with future commands because it continues reading O packets from the first command as response to subsequent commands.

This patch handles any O packets during an qRcmd, treating the first non-O packet as the true response.

Preliminary discussion at http://lists.llvm.org/pipermail/lldb-dev/2018-January/013078.html

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: labath, lldb-commits

Differential Revision: https://reviews.llvm.org/D41745
Patch by Owen Shaw <llvm@owenpshaw.net>

llvm-svn: 322190
2018-01-10 14:39:08 +00:00
Pavel Labath e71429d1d8 Add empty() function to the Environment class
Needed to make the previous Freebsd fix work.

llvm-svn: 322188
2018-01-10 14:17:40 +00:00
Pavel Labath 75c6de0be2 Another attempt to fix FreeBsd build
the previous fix did not work because of different const qualifications
on the envp pointer.

This should resolve that (and remove a couple of const_casts in the
process).

llvm-svn: 322187
2018-01-10 13:53:40 +00:00
Tim Northover 400c7b3c7a Fix Xcode build for r322174
llvm-svn: 322183
2018-01-10 13:32:01 +00:00
Pavel Labath 3ff377a927 Fix windows and freebsd builds for r322174 (Environment)
llvm-svn: 322176
2018-01-10 12:25:48 +00:00
Pavel Labath 62930e57eb Add Utility/Environment class for handling... environments
Summary:
There was some confusion in the code about how to represent process
environment. Most of the code (ab)used the Args class for this purpose,
but some of it used a more basic StringList class instead. In either
case, the fact that the underlying abstraction did not provide primitive
operations for the typical environment operations meant that even a
simple operation like checking for an environment variable value was
several lines of code.

This patch adds a separate Environment class, which is essentialy a
llvm::StringMap<std::string> in disguise. To standard StringMap
functionality, it adds a couple of new functions, which are specific to
the environment use case:
- (most important) envp conversion for passing into execve() and likes.
  Instead of trying to maintain a constantly up-to-date envp view, it
  provides a function which creates a envp view on demand, with the
  expectation that this will be called as the very last thing before
  handing the value to the system function.
- insert(StringRef KeyEqValue) - splits KeyEqValue into (key, value)
  pair and inserts it into the environment map.
- compose(value_type KeyValue) - takes a map entry and converts in back
  into "KEY=VALUE" representation.

With this interface most of the environment-manipulating code becomes
one-liners. The only tricky part was maintaining compatibility in
SBLaunchInfo, which expects that the environment entries are accessible
by index and that the returned const char* is backed by the launch info
object (random access into maps is hard and the map stores the entry in
a deconstructed form, so we cannot just return a .c_str() value). To
solve this, I have the SBLaunchInfo convert the environment into the
"envp" form, and use it to answer the environment queries. Extra code is
added to make sure the envp version is always in sync.

(This also improves the layering situation as Args was in the Interpreter module
whereas Environment is in Utility.)

Reviewers: zturner, davide, jingham, clayborg

Subscribers: emaste, lldb-commits, mgorny

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

llvm-svn: 322174
2018-01-10 11:57:31 +00:00
Pavel Labath 698d63a61a [dotest] Remove crashinfo hook
Summary:
This used to be important when all tests were run in a single process,
but that has no longer been the case for a while. Furthermore, this hook fails
to build on new mac versions for several people, and it's not clear
whether fixing it is worth the effort.

Reviewers: jingham, clayborg, davide

Subscribers: lldb-commits

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

llvm-svn: 322167
2018-01-10 10:18:47 +00:00
Jason Molenda 6b7daba64a This change updates the deployment target for lldb and debugserver
(built with Xcode) from 10.9 to 10.11.  It also enables the use of
libcompression in debugserver by default (these API are only present
in macOS 10.11 and newer -- 10.11 was released c. Sep 2015).

I don't know if we have people / bots building lldb on older mac
releases; if this turns out to be a problem I will revert the change.
There are some parts of lldb (e.g. debugserer's ability to report
the OS version #) that only work with 10.10 and this changes the
behavior of lldb (whether the older or newer dyld interfaces are
used) so there is some importance to updating the min required
version.

llvm-svn: 322128
2018-01-09 22:17:10 +00:00
Michal Gorny c5e0b63e56 [test] Fix tests to use more portable LLVM_ENABLE_ZLIB
The HAVE_LIBZ variable is not exported by LLVM, and therefore is not
available in stand-alone builds of other tools. Use LLVM_ENABLE_ZLIB
which is the name under which the effective value is exported.

Additional, use llvm_canonicalize_cmake_booleans() to make sure that
a correct (Python-safe) boolean value is passed down to lit.

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

llvm-svn: 322081
2018-01-09 14:44:04 +00:00
Pavel Labath 03ed2249a6 TestConflictingSymbols: simplify test by using run_break_set_by_source_regexp
follow-up to r321271 based on post-commit feedback by Jim Ingham.

llvm-svn: 322075
2018-01-09 13:22:22 +00:00
Jim Ingham 9c7ba8e047 Cut and paste error - I wasn't actually running both tests...
llvm-svn: 322054
2018-01-09 03:03:20 +00:00
Michal Gorny 15a86ef5af [test] Use full PATH lookup for tools
Use full PATH when looking up test tools rather than just llvm tools
directory. r320813 has added a lookup for 'lldb-test' which is part
of LLDB tools rather than LLVM, and therefore is not present
in llvm_tools_dir before LLDB is installed.

While technically we could introduce separate per-directory lookup
logic, there is no real reason not to use the PATH formed earlier here,
and this is what other tools are doing.

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

llvm-svn: 321932
2018-01-06 10:20:25 +00:00
Davide Italiano 08e52bc801 [ArchSpec] Add a unittest to complement the change in r321856.
<rdar://problem/35778442>

llvm-svn: 321879
2018-01-05 18:00:44 +00:00
Davide Italiano c910aa67b3 [ArchSpec] Don't consider Unknown MachO64 as invalid.
Even without a proper arch we can access line tables, etc..

<rdar://problem/35778442>

llvm-svn: 321856
2018-01-05 02:50:24 +00:00
Davide Italiano 45925d77d6 [IRExecutionUnit] Remove broken/dead code.
llvm-svn: 321833
2018-01-04 23:37:18 +00:00
Adrian Prantl dce4a9aa59 Look for external types in all clang modules imported by the current symbol file.
This fixes a bug in -gmodules DWARF handling when debugging without a .dSYM bundle
that was particularly noticable when debugging LLVM itself.

Debugging without clang modules and DWO handling should be unaffected by this patch.

<rdar://problem/32436209>

llvm-svn: 321802
2018-01-04 16:42:05 +00:00
Davide Italiano 0d0f1ff719 [Core/Debugger] Remove some code that doesn't compile anymore.
llvm-svn: 321654
2018-01-02 16:27:01 +00:00
Davide Italiano 29e1856966 [MacOSX-Kernel] Remove broken KDP_IMAGEPATH support.
llvm-svn: 321652
2018-01-02 16:24:30 +00:00
Davide Italiano aae267d7f2 [ARM64] Remove unused function. NFCI.
llvm-svn: 321651
2018-01-02 16:22:09 +00:00
Aaron Smith 5a81bb73ad Remove duplicate declaration from D41550; NFC
llvm-svn: 321514
2017-12-28 07:48:10 +00:00
Aaron Smith 364cbfe964 Update failing PDB unit tests that are searching for symbols by regex
Summary: D41086 fixed an exception in FindTypes()/FindTypesByRegex() and caused two lldb unit test to fail. This change updates the unit tests to pass again.

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

Reviewed By: asmith

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

llvm-svn: 321511
2017-12-28 06:29:59 +00:00
Pavel Labath deb45f2043 debugserver: Propagate environment in launch-mode (pr35671)
Summary:
Make sure we propagate environment when starting debugserver with a pre-loaded
inferior. AFAIK, RNBRunLoopLaunchInferior is only called in pre-loaded inferior
scenario, so we can just pick up the debugserver environment instead of trying
to construct an envp from the (empty) context.

This makes debugserver pass an test added for an equivalent lldb-server fix.

Reviewers: jasonmolenda, clayborg

Subscribers: JDevlieghere, lldb-commits

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

llvm-svn: 321355
2017-12-22 11:09:21 +00:00
Pavel Labath b8318155eb Enable TestReadMemCString on non-darwin targets
The test works fine on linux, and I believe other targets should not
have an issue with as well. If they do, we can start blacklisting
instead of whitelisting.

The idea of using "-1" as the value of the pointer on non-apple targets
backfired, as it fails the "address != LLDB_INVALID_ADDRESS" test (-1 is
the value of LLDB_INVALID_ADDRESS).  However, it should be safe to use
0x100 for other targets as well. The first page of memory is generally
kept unreadable to catch null pointer dereferences.

llvm-svn: 321353
2017-12-22 10:26:59 +00:00
Aaron Smith 86e9434db9 [lldb] Stop searching for a symbol in a pdb by regex
Summary:
It was possible when searching for a symbol by regex in a pdb that an invalid regex would cause an exception on Windows. This updates the code to avoid throwing an exception.

When fixing the exception it was decided there is no reason to search for a symbol in a pdb by regex. To support this, SymbolFilePDB::FindTypes() now only searches for types by name and no longer calls FindTypesByRegEx().

Reviewers: zturner, lldb-commits

Reviewed By: zturner

Subscribers: clayborg

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

llvm-svn: 321344
2017-12-22 05:26:50 +00:00
Jason Molenda 16b386de15 Change SBProcess::ReadCStringFromMemory() back to returning
an empty Python string object when it reads a 0-length 
string out of memory (and a successful SBError object).

<rdar://problem/26186692> 

llvm-svn: 321338
2017-12-22 03:27:02 +00:00
Jason Molenda a22e923106 Change the default Aarch64 ISA to be v8.2 to correctly decode newer
instructions (e.g. on the new iphones).
<rdar://problem/30585124> 

llvm-svn: 321328
2017-12-22 00:16:04 +00:00
Aaron Smith 1f8552abf3 Enable more abilities in SymbolFilePDB
Summary:
1) Finding symbols through --symfile
2) More abilities: Functions, Blocks, GlobalVariables, LocalVariables, VariableTypes

Reviewers: zturner, lldb-commits

Reviewed By: zturner

Subscribers: clayborg

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

llvm-svn: 321327
2017-12-22 00:04:36 +00:00
Adrian Prantl 559d2c98a8 Bring clang options in error messages up to date.
llvm-svn: 321322
2017-12-21 23:04:51 +00:00
Pavel Labath 71ff9fa65f Make one more test redhat-compatible
This test was also using "a" in an expression.

llvm-svn: 321277
2017-12-21 15:52:59 +00:00
Pavel Labath 3db29a1b3e Work around test failures on red-hat linux
Two tests were failing because the debugger was picking up multiply
defined internal symbols from the system libraries. This is a bug, as
there should be no ambiguity because the tests are defining variables
with should shadow these symbols, but lldb is not smart enough to figure
that out.

I work around the issue by renaming the variables in these tests, and in
exchange I create a self-contained test which reproduces the issue
without depending on the system libraries.

This increases the predictability of our test suite.

llvm-svn: 321271
2017-12-21 14:40:03 +00:00
Pavel Labath 50251fc715 Make sure DataBufferLLVM contents are writable
Summary:
We sometimes need to write to the object file we've mapped into memory,
generally to apply relocations to debug info sections. We've had that
ability before, but with the introduction of DataBufferLLVM, we have
lost it, as the underlying llvm class (MemoryBuffer) only supports
read-only mappings.

This switches DataBufferLLVM to use the new llvm::WritableMemoryBuffer
class as a back-end, as this one guarantees to return a writable buffer.

This removes the need for the "Private" flag to the DataBufferLLVM
creation functions, as it was really used to mean "writable". The LLVM
function also does not have the NullTerminate flag, so I've modified our
clients to not require this feature and removed that flag as well.

Reviewers: zturner, clayborg, jingham

Subscribers: emaste, aprantl, arichardson, krytarowski, lldb-commits

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

llvm-svn: 321255
2017-12-21 10:54:30 +00:00
Adrian Prantl 7e13aef428 Replace an accidentally added "break" with an LLVM_FALLTHROUGH.
Thanks to Greg Clayton for catchting this!

llvm-svn: 321123
2017-12-19 23:16:38 +00:00
Adrian Prantl a01e024ad7 Fix a couple of warnings (NFC)
llvm-svn: 321120
2017-12-19 22:54:37 +00:00
Adrian Prantl 3519a27635 Temporarily XFAIL test/functionalities/exec while investiagting bot breakage.
When building with cmake on green gragon or on ci.swift.org, this test fails.

rdar://problem/36134350

llvm-svn: 321095
2017-12-19 18:21:28 +00:00
Jason Molenda b1e350f71f Tweak to the debugserver entitlements setup in the xcode project
file.  For macos builds specifically, use the macosx entitlements
files; for all other builds, use the ios etc entitlements.

llvm-svn: 321051
2017-12-19 01:41:47 +00:00
Dimitry Andric e4f5d01033 Fix more inconsistent line endings. NFC.
llvm-svn: 321016
2017-12-18 19:46:56 +00:00
Pavel Labath 8c92c899c6 Fix regression in jModulesInfo packet handling
The recent UUID cleanups exposed a bug in the parsing code for the
jModulesInfo response, which was passing wrong value for the second
argument to UUID::SetFromStringRef (it passed the length of the string,
whereas the correct value should be the number of decoded bytes we
expect to receive).

This was not picked up by tests, because they test with 16-byte uuids,
for which the function happens to do the right thing even if the length
does not match (if the length does not match, the function does not
update m_num_uuid_bytes member, but that member is already 16 to begin
with).

I fix that and add a test with 20-byte uuid to catch if this regresses.
I have also added more safeguards into the parsing code to fail if we
cannot parse the entire uuid field we recieve. While testing the latter
part, I noticed that the "negative" jModulesInfo tests were succeeding
because we were sending malformed json (and not because the json
contents was invalid), so I make those tests a bit more robuts as well.

llvm-svn: 320985
2017-12-18 14:31:44 +00:00
Pavel Labath 11e5917d2a llgs: Propagate the environment when launching the inferior from command line
Summary:
We were failing to propagate the environment when lldb-server was
started with a pre-loaded process
(e.g.: lldb-server gdbserver -- inferior --inferior_args)

This patch makes sure the environment is propagated. Instead of adding a
new GDBRemoteCommunicationServerLLGS::SetLaunchEnvironment function to
complement SetLaunchArgs and SetLaunchFlags, I replace these with a
more generic SetLaunchInfo, which can be used to set any launch-related
property.

The accompanying test also verifies that the server correctly terminates
the connection after sending the exit packet (specifically, that it does
not send the exit packet twice).

Reviewers: clayborg, eugene

Subscribers: lldb-commits, mgorny

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

llvm-svn: 320984
2017-12-18 14:31:39 +00:00
Pavel Labath 45fda904d9 Fix FreeBSD build broken by r320966
llvm-svn: 320969
2017-12-18 11:05:28 +00:00
Pavel Labath 9b95b32323 Add LLVMObject dependency to our ObjectFileELF plugin
llvm-svn: 320967
2017-12-18 10:51:03 +00:00
Pavel Labath a0e3c6f6f5 Reduce x86 register context boilerplate.
Summary:
The x86 FPR struct was defined as a struct containing a union between
two members: XSAVE and FXSAVE. This patch makes FPR a union directly to
remove one layer of indirection when trying to access the members.

The initial layout of these two structs is identical, which is
recognised by the fact that XSAVE has FXSAVE as its first member, so we
also considered removing one more layer and leave FPR identical to XSAVE
struct, but stopped short of doing that, as the FPR may be used to store
different layouts in the future (e.g., ones generated by the FSAVE
instruction).

Reviewers: clayborg, krytarowski

Subscribers: emaste, lldb-commits

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

llvm-svn: 320966
2017-12-18 10:50:59 +00:00
Pavel Labath d8b3c1a135 NPL: Clean up handling of inferior exit
Summary:
lldb-server was sending the "exit" packet (W??) twice. This happened
because it was handling both the pre-exit (PTRACE_EVENT_EXIT) and
post-exit (WIFEXITED) as exit events. We had some code which was trying
to detect when we've already sent the exit packet, but this stopped
working quite a while ago.

This never really caused any problems in practice because the client
automatically closes the connection after receiving the first packet, so
the only effect of this was some warning messages about extra packets
from the lldb-server test suite, which were ignored because they didn't
fail the test.

The new test suite will be stricter about this, so I fix this issue
ignoring the first event. I think this is the correct behavior, as the
inferior is not really dead at that point, so it's premature to send the
exit packet.

There isn't an actual test yet which would verify the exit behavior, but
in my next patch I will add a test which will also test this
functionality.

Reviewers: eugene

Subscribers: lldb-commits

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

llvm-svn: 320961
2017-12-18 09:44:29 +00:00
Davide Italiano 5cc82f24ff [testsuite] Un-XFAIL the global variables tests.
<rdar://problem/28725399>

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

llvm-svn: 320952
2017-12-17 18:58:27 +00:00
Davide Italiano 864a6edf8b [CMake] darwin-debug is an hard dependency for tests on macOS.
Fixes a few failured on the testsuite with CMake.

llvm-svn: 320891
2017-12-15 23:27:10 +00:00
Davide Italiano 8539edb0f3 [MacOSX/Queues] Relax an overly aggressive assertion in a test.
"Default" is a valid QoS for a thread on older versions of macOS,
like the one installed in the bot.
Thanks to Jason Molenda for helping me figuring out the problem.

<rdar://problem/28346273>

llvm-svn: 320883
2017-12-15 22:22:51 +00:00
Pavel Labath 93a582c00a llgs-tests: Add support for "exit" stop-reply packets
Summary:
This makes StopReply class abstract, so that we can represent different
types of stop replies such as StopReplyStop and StopReplyExit (there
should also be a StopReplySignal, but I don't need that right now so I
haven't implemented it yet).

This prepares the ground for a new test I'm writing.

Reviewers: eugene, zturner

Subscribers: lldb-commits

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

llvm-svn: 320820
2017-12-15 15:19:45 +00:00
Pavel Labath 4c2eb8b244 Fix 32-bit builds broken by 320813
cast to size_t to avoid narrowing error.

llvm-svn: 320816
2017-12-15 14:39:12 +00:00
Pavel Labath e2867bc4a0 ObjectFileELF: Add support for compressed sections
Summary:
We use the llvm decompressor to decompress SHF_COMPRESSED sections. This enables
us to read data from debug info sections, which are sometimes compressed,
particuarly in the split-dwarf case.  This functionality is only available if
llvm is compiled with zlib support.

Reviewers: clayborg, zturner

Subscribers: emaste, mgorny, aprantl, lldb-commits

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

llvm-svn: 320813
2017-12-15 14:23:58 +00:00
Pavel Labath 671d3e6318 llgs-tests: Make addition of new tests easier
Summary:
Adding a new test would require one to duplicate a significant part of
the existing test that we have. This attempts to reduce that by moving
some part of that code to the test fixture. The StandardStartupTest
fixture automatically starts up the server and connects it to the
client. I also add a more low-level TestBase fixture, which allows one
to start up the client and server in a custom way (I am going to need
this for the test I am writing).

Reviewers: eugene, zturner

Subscribers: lldb-commits, mgorny

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

llvm-svn: 320809
2017-12-15 13:56:22 +00:00
Davide Italiano 89419f88bc [ExpressionParser] Fix evaluation failures due to mismatch in C++ versions.
Clang recently switched to C++14 (with GNU extensions) as the default
dialect, but LLDB didn't catch up. This causes failures as LLDB still
evaluates ObjectiveC expressions as Objective C++ using C++98 as standard.

There are things not available in C++98, including, e.g. nullptr.
In some cases Objective-C `nil` is defined as `nullptr` so this causes
an evaluation failure. Switch the default to overcome this issue
(actually, currently lldb evaluates both C++11 and C++14 as C++11,
but that seems a larger change and definitely could be re-evaluated
in the future).

No test as this is currently failing on the LLDB bots after the clang
switch (so, de facto, there's a test already for it).

This is a recommit, with a thinko fixed (the code was previously
placed incorrectly).

<rdar://problem/36011995>

llvm-svn: 320778
2017-12-15 00:50:43 +00:00
Davide Italiano 75dfd9a525 [ExpressionParser] Rollback C++98 as the standard for evaluating.
Some ubuntu bots are failing with this patch in, let me unblock
while I investigate.

llvm-svn: 320769
2017-12-15 00:00:17 +00:00
Davide Italiano d416b0b903 [ExpressionParser] Fix evaluation failures due to mismatch in C++ versions.
Clang recently switched to C++14 (with GNU extensions) as the default
dialect, but LLDB didn't catch up. This causes failures as LLDB still
evaluates ObjectiveC expressions as Objective C++ using C++98 as standard.

There are things not available in C++98, including, e.g. nullptr.
In some cases Objective-C `nil` is defined as `nullptr` so this causes
an evaluation failure. Switch the default to overcome this issue
(actually, currently lldb evaluates both C++11 and C++14 as C++11,
but that seems a larger change and definitely could be re-evaluated
in the future).

No test as this is currently failing on the LLDB bots after the clang
switch (so, de facto, there's a test already for it).

<rdar://problem/36011995>

llvm-svn: 320761
2017-12-14 23:11:15 +00:00
Davide Italiano f550ed1abd [ClangASTContext] Remove dead stuff found fixing something else.
llvm-svn: 320759
2017-12-14 23:03:35 +00:00
Pavel Labath f1208e7aef ObjectFile: remove ReadSectionData/MemoryMapSectionData mutual recursion
Summary:
These two functions were calling each other, while handling different
branches of the if(IsInMemory()). This had a reason at some point in the
past, but right now it's just confusing.

I resolve this by removing the MemoryMapSectionData function and
inlining the !IsInMemory branch into ReadSectionData. There isn't
anything mmap-related in this function anyway, as the decision whether
to mmap is handled at a higher level.

This is a preparatory step to make ObjectFileELF be able to decompress
compressed sections (I want to make sure that all calls reading section
data are routed through a single piece of code).

Reviewers: clayborg

Subscribers: emaste, JDevlieghere, lldb-commits

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

llvm-svn: 320705
2017-12-14 14:56:45 +00:00
Pavel Labath 8630d3871d Remove stderr message from GDBRemoteCommunicationServerLLGS
A similar error message is printed again in lldb-gdbserver.cpp, so the
user will see the message twice. Also, this is generic library code, we
shouldn't really be using stderr here.

llvm-svn: 320704
2017-12-14 14:56:29 +00:00
Davide Italiano b32f389c91 [IRExecutionUnit] Initialize uninititialized member variable.
Found by the ubsan build.

<rdar://problem/31106358>

llvm-svn: 320541
2017-12-13 01:41:17 +00:00
Davide Italiano 64c2760ecb [DataEncoder] Replace buggy versions of write functions.
This fixes a previously introduced thinko, now that I have
a better idea of what's going on :)

<rdar://problem/35941757>

llvm-svn: 320540
2017-12-13 01:41:16 +00:00
Petr Hosek eb8301413a [lldb] Set component when invoking add_llvm_install_targets
This is needed to ensure that the distribution and install-distribution
targets work properly.

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

llvm-svn: 320537
2017-12-13 01:14:27 +00:00
Vedant Kumar c8e1c0945a Add an #include to appease an older clang, NFC
Add in a missing #include that AppleClang-900 complains about when
building with -DLLVM_ENABLE_MODULES.

llvm-svn: 320522
2017-12-12 20:19:40 +00:00
Vedant Kumar 08ff404308 Avoid module import in a textual header, NFC
This unbreaks the lldb modules build (-DLLVM_ENABLE_MODULES=On).

llvm-svn: 320456
2017-12-12 03:27:13 +00:00
Davide Italiano 074f858da7 [TestModulesInlineFunctions] This test now passes.
Remove yet another spurious unexpected success.
Ack'ed by Jim Ingham.

Fixes PR25743.

llvm-svn: 320454
2017-12-12 02:52:01 +00:00
Davide Italiano 4b13d8bdf3 [TestCppScope] This test now passes on Darwin.
I tested on x86-64 and Jason on embedded architectures.
This cleans up another couple of reported unexpected successes.

<rdar://problem/28623427>

llvm-svn: 320452
2017-12-12 02:32:49 +00:00
Davide Italiano e8d85eaaa7 [testsuite] Remove even more testing vestiges.
With this one, the number of unexpected successes for the LLDB
test suite when building with clang ToT goes down to 18.

llvm-svn: 320450
2017-12-12 02:10:23 +00:00
Davide Italiano ee710e1d00 Rollback [Testsuite] Rename this file from *m -> *mm.
After discussing this with Jim and Jason, I think my commit was
actually sweeping the issue under the carpet rather than fixing it.
I'll take a closer look between tonight and tomorrow.

llvm-svn: 320447
2017-12-12 01:21:43 +00:00
Davide Italiano 53cff5161c [testsuite] Remove testing failures vestiges.
Some tests are failing on macOS when building with the in-tree
clang, and this is because they're conditional on the version released.
Apple releases using a different versioning number, but as these are
conditional on clang < 7, they fail for clang ToT (which is 6.0).
As a general solution, we actually need either a mapping between
Apple internal release version and public ones.

That said, I discussed this with Fred , and Apple Clang 6.0 seems
to be old enough that we can remove this altogether (which means I
can delay implementing the general purpose solution for a bit).

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

llvm-svn: 320444
2017-12-12 01:14:11 +00:00
Shoaib Meenai ac75523108 [lldb] Switch to add_llvm_install_targets
This adds the install-*-stripped targets to LLDB, which are required for
the install-distribution-stripped option. We also need to create some
install-*-stripped targets manually, which are modeled after their
corresponding install-* targets.

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

llvm-svn: 320443
2017-12-12 00:47:07 +00:00
Davide Italiano ecff6ac373 [test-suite] Un'XFAIL a test that's not failing anymore.
This is the first of a series of commits aiming to improve
overall LLDB's hygiene. Feel free to shout at me in case
I break something.

<rdar://problem/30915340>

llvm-svn: 320425
2017-12-11 21:52:02 +00:00
Davide Italiano 9b8649c88d [Testsuite] Rename this file from *m -> *mm.
Should hopefully bring the bots back.

<rdar://problem/35976115>

llvm-svn: 320422
2017-12-11 21:21:53 +00:00
Pavel Labath e0b61e3c9a dotest.py: Correctly annotate lldbinline tests with debug info categories
This enables one to run all dwo tests with dotest.py --category dwo, or
skip them with --skip-category.

llvm-svn: 320377
2017-12-11 15:28:21 +00:00
Pavel Labath c58a80ff47 Add a StringList constructor to Args class
Host::GetEnvironment returns a StringList, but the interface for
launching a process takes Args. The fact that we use two classes for
representing an environment is not ideal, but for now we should at least
have an easy way to convert between the two.

llvm-svn: 320366
2017-12-11 14:22:30 +00:00
Pavel Labath 293d6c39d3 Fix osx build broken in r320346
llvm-svn: 320349
2017-12-11 11:12:22 +00:00
Pavel Labath 07d6f881e7 Move PseudoTerminal to the lldb_private namespace
lldb_utility doesn't make sense, as it is no longer even living in the
"utility" module.

llvm-svn: 320346
2017-12-11 10:09:14 +00:00
Pavel Labath 390b487994 MainLoop: avoid infinite loop when pty slave gets closed
Summary:
For ptys (at least on Linux), the end-of-file (closing of the slave FD)
is signalled by the POLLHUP flag. We were ignoring this flag, which
meant that when this happened, we would spin in a loop, continuously
calling poll(2) and not making any progress.

This makes sure we treat POLLHUP as a read event (reading will return
0), and we call the registered callback when it happens. This is the
behavior our clients expect (and is consistent with how select(2)
works).

Reviewers: eugene, beanz

Subscribers: lldb-commits

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

llvm-svn: 320345
2017-12-11 09:33:18 +00:00
Davide Italiano 226aab7cdb Revert "[DataEncoder] Replace buggy versions of write functions."
The commit exposes a bunch of failures in the LLDB testsuite that
I need to analyze more carefully. Reverting for now.

llvm-svn: 320341
2017-12-11 05:09:35 +00:00
Davide Italiano dd6d037284 [DarwinLog] Remove other dead code. Found while reading this file.
llvm-svn: 320338
2017-12-10 23:49:23 +00:00
Davide Italiano 1209c4b4e7 [MachException] Garbage collect unused and dead code.
llvm-svn: 320337
2017-12-10 23:33:33 +00:00
Davide Italiano d752d6b4be [DataEncoder] Replace buggy versions of write functions.
They cause an ubsan error when ran through the testsuite (store
to misaligned address is UB). This commit kills two birds with
one stone, as we also remove some code while fixing it.

<rdar://problem/35941757>

llvm-svn: 320335
2017-12-10 22:54:07 +00:00
Jason Molenda aae5b69079 Change uses of strncpy in debugserver to strlcpy
for better safety.

<rdar://problem/32906923> 

llvm-svn: 320242
2017-12-09 03:37:09 +00:00
Jason Molenda 1bfb9f1c0f Change the ordering that we search for kexts and kernels on the local
computer.  When doing kernel debugging, lldb scrapes around a few 
well-known locations to find kexts and kernels.  It builds up two
lists - kexts and kernels with dSYM, and kexts and kernels without dSYMs.
After both lists have failed to provide a file, then we'll call out
to things like the DebugSymbols framework to find a kext/kernel.

This meant that when you had a kext/kernel on the local computer that
did not have debug information, lldb wouldn't consult DebugSymbols etc
once it'd locked on to one of these no-debug-info binaries on the local
computer.

Reorder this so we give DebugSymbols etc a shot at finding a debug-info
file before we use any of the no-debug-info binaries that were found on
the system.

<rdar://problem/34434440> 

llvm-svn: 320241
2017-12-09 03:28:15 +00:00
Jason Molenda 6e78b6bd8e Update PlatformDarwin::GetDeveloperDir to handle the two
most common cases where the Xcode.app bundle puts lldb -
either as a default part of the bundle, or in a toolchain
subdirectory, so the platform subclasses can find files
relative to this directory.

Dropped support for handling the case where the lldb
framework was in /Library/PrivateFrameworks.  I think
this was intended to handle the case where lldb is installed
in / (outside the Xcode.app bundle) - but in that case, we
can look in the raw directory file paths to find anything.

<rdar://problem/35285622> 

llvm-svn: 320240
2017-12-09 03:06:19 +00:00
Vedant Kumar 9c36859b33 [MachException] Avoid alignment UB, NFC
Fix alignment UB in some Mach exception-handling logic.

This lets us build lldb and debugserver with UBSan in trapping mode, and
get further along in the testing process before a trap is encountered.

rdar://35923991

llvm-svn: 320127
2017-12-08 01:09:40 +00:00
Vedant Kumar b773e488c9 Remove extant references to g_message_mutex, NFC
Thanks to Jim Ingham for providing the explanation!

llvm-svn: 320126
2017-12-08 01:09:39 +00:00
Jim Ingham 6c96486962 These tests don't depend on debug info format.
Mark them as such.

llvm-svn: 320077
2017-12-07 19:44:09 +00:00
Vedant Kumar 9df6e0a5ea Disable warnings related to anonymous types in the ObjC plugin
This part of lldb make use of anonymous structs and unions. The usage is
idiomatic and doesn't deserve a warning. Logic in the NSDictionary and NSSet
plugins use anonymous structs in a manner consistent with the relevant Apple
frameworks.

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

llvm-svn: 320071
2017-12-07 18:57:09 +00:00
Davide Italiano e2564051be [SBBreakpointOptionCommon] Give this class an explicit destructor.
llvm-svn: 320067
2017-12-07 18:06:06 +00:00
Davide Italiano c218ee58ac [SBBreakpoint] Outline some functions to prevent to be exported.
They're hidden, so all they cause is a linker warning.

ld: warning: cannot export hidden symbol
lldb::SBBreakpointNameImpl::operator==(lldb::SBBreakpointNameImpl const&) from
tools/lldb/source/API/CMakeFiles/liblldb.dir/SBBreakpointName.cpp.o

llvm-svn: 320066
2017-12-07 18:06:06 +00:00
Davide Italiano e1407c2c13 [Target] Remove commented out code. Found by inspection. NFCI.
llvm-svn: 320060
2017-12-07 17:05:56 +00:00
Pavel Labath 62ef18562b Variable: Fix usage of uninitialised value
Summary:
Variable::GetValuesForVariableExpressionPath was passing an
uninitialised value for the final_task_on_target argument. On my
compiler/optimization level combo, the final_task_on_target happened to
contain "dereference" in some circumstances, which produced hilarious
results. The same is true for other arguments to the
GetValueForExpressionPath call.

The correct behavior here seems to be to just omit the arguments
altogether and let the default behavior take place.

Reviewers: jingham

Subscribers: mehdi_amini, lldb-commits

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

llvm-svn: 320021
2017-12-07 10:38:22 +00:00
Shoaib Meenai 5e8d5ccfe7 [lldb] Use PRIVATE in target_link_libraries
This is a follow-up to r319840. I guess none of the systems I'd tested
on before had LLDB_SYSTEM_LIBS set, which is why I didn't see any local
errors, but I'm surprised none of the bots caught it either.

llvm-svn: 319953
2017-12-06 20:53:03 +00:00
Vedant Kumar 50048ac65e Fix the -Wunused-function warning properly (MachProcess.mm)
r319938 was not NFC, because it got the preprocessor guard wrong. Check
WITH_FBS and WITH_BKS before defining SplitEventData.

llvm-svn: 319943
2017-12-06 19:27:20 +00:00
Vedant Kumar 94d788fa78 Fix const-correctness in RegisterContext methods, NFC
A few methods in RegisterContext classes accept const objects which are
cast to a non-const thread_state_t. Drop const-ness more explicitly
where we mean to do so. This fixes a slew of warnings.

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

llvm-svn: 319939
2017-12-06 19:21:12 +00:00
Vedant Kumar eacb0929e8 Fix an -Wunused-function warning, NFC
llvm-svn: 319938
2017-12-06 19:21:11 +00:00
Vedant Kumar 07d956149b Fix misc -Wcast-qual warnings, NFC
llvm-svn: 319937
2017-12-06 19:21:11 +00:00
Vedant Kumar 606908aab5 Remove no-op function pointer null checks, NFC
Null-checking functions which aren't marked weak_import is a no-op
(the compiler rewrites the check to 'true'), regardless of whether a
library providing its definition is weak-linked. If the deployment
target is greater than the minimum requirement, the availability markup
on APIs does not lower to weak_import.

Remove no-op null checks to clean up the code and silence warnings.

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

llvm-svn: 319936
2017-12-06 19:21:10 +00:00
Vedant Kumar 8465c38b1e Use a static_cast instead of a C cast, NFC
Pointed out by Davide Italiano in post-commit review.

llvm-svn: 319935
2017-12-06 19:21:09 +00:00
Vedant Kumar a73324b0a9 [MappedHash] Fix alignment violations
This fixes a few alignment problems pointed out by UBSan, and is
otherwise NFC.

llvm-svn: 319934
2017-12-06 19:21:08 +00:00
Fangrui Song c09bce1146 Do not use default arguments of DataLayout::getPointer*. NFC
Summary: There are "FIXME"s in include/llvm/IR/DataLayout.h to remove the default arguments.

Reviewers: zturner, clayborg

Reviewed By: zturner

Subscribers: bjope

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

llvm-svn: 319869
2017-12-06 01:32:06 +00:00
Shoaib Meenai d806af3499 [CMake] Use PRIVATE in target_link_libraries for executables
We currently use target_link_libraries without an explicit scope
specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
Dependencies added in this way apply to both the target and its
dependencies, i.e. they become part of the executable's link interface
and are transitive.

Transitive dependencies generally don't make sense for executables,
since you wouldn't normally be linking against an executable. This also
causes issues for generating install export files when using
LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
library dependencies, which are currently added as interface
dependencies. If clang is in the distribution components but the LLVM
libraries it depends on aren't (which is a perfectly legitimate use case
if the LLVM libraries are being built static and there are therefore no
run-time dependencies on them), CMake will complain about the LLVM
libraries not being in export set when attempting to generate the
install export file for clang. This is reasonable behavior on CMake's
part, and the right thing is for LLVM's build system to explicitly use
PRIVATE dependencies for executables.

Unfortunately, CMake doesn't allow you to mix and match the keyword and
non-keyword target_link_libraries signatures for a single target; i.e.,
if a single call to target_link_libraries for a particular target uses
one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
also be updated to use those keywords. This means we must do this change
in a single shot. I also fully expect to have missed some instances; I
tested by enabling all the projects in the monorepo (except dragonegg),
and configuring both with and without shared libraries, on both Darwin
and Linux, but I'm planning to rely on the buildbots for other
configurations (since it should be pretty easy to fix those).

Even after this change, we still have a lot of target_link_libraries
calls that don't specify a scope keyword, mostly for shared libraries.
I'm thinking about addressing those in a follow-up, but that's a
separate change IMO.

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

llvm-svn: 319840
2017-12-05 21:49:56 +00:00
Davide Italiano f363fd8d30 [Darwin] Delete dead code. NFCI.
llvm-svn: 319832
2017-12-05 20:55:36 +00:00
Jim Ingham ba205c1b76 Add target.process.stop-on-exec setting, and obey it.
Also add a test.  There should also be control for this
in ProcessLaunchInfo and a "target launch" flag, but at least
this will allow you to control it somehow.

<rdar://problem/35842137>

llvm-svn: 319731
2017-12-05 02:50:45 +00:00
Jim Ingham 45816d6b91 Clean up stop hook output in case a hook restarts.
I was warning about the fact that this will abort
further stop hooks, but didn't check that there WAS
a further stop hook.  Also the warning was missing a
newline.

llvm-svn: 319730
2017-12-05 02:34:05 +00:00
Aaron Ballman 05b618e31f Switch from C++1z to C++17; corresponds to r319688 in Clang.
llvm-svn: 319694
2017-12-04 20:46:43 +00:00
Pavel Labath fd9a526a30 Makefile.rules: compile all tests with -fno-limit-debug-info
Summary:
This flag is on by default for darwin and freebsd, but off for linux.
Without it, clang will sometimes not emit debug info for types like
std::string. Whether it does this, and which tests will fail because of
that depends on the linux distro and c++ library version.

A bunch of tests were already setting these flags manually, but here
instead I take a whole sale approach and enable this flag for all tests.
Any test which does not want to have this flag (right now we have one
such test) can turn it off explicitly via
CFLAGS_EXTRAS+=$(LIMIT_DEBUG_INFO_FLAGS)

This fixes a bunch of data formatter tests on red-hat.

Reviewers: davide, jankratochvil

Subscribers: emaste, aprantl, krytarowski, JDevlieghere, lldb-commits

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

llvm-svn: 319653
2017-12-04 13:31:56 +00:00
Zachary Turner a6d5464cfe Add a symbols subcommand to lldb-test.
Differential Revision: https://reviews.llvm.org/D40745

llvm-svn: 319599
2017-12-02 00:15:29 +00:00
Jim Ingham 2f1cb7ed82 Don't use llvm::EnablePrettyStackTrace on macOS.
LLDB.framework gets loaded into Xcode and other 
frameworks, and this is inserting a signal handler into
the process even when lldb isn't used.  I have a bunch
of reports of this SignalHandler blowing out the stack,
which renders crash reports for the crash useless.

And in any case libraries really shouldn't be installing
signal handlers.

I only turned this off for APPLE platforms, I'll let
the maintainers of other platforms decide what policy
they want to have w.r.t. this.

llvm-svn: 319598
2017-12-02 00:11:18 +00:00
Vedant Kumar 1541c37cb9 Fix warning in DynamicLoaderDarwinKernel.cpp, NFC
llvm-svn: 319597
2017-12-01 23:53:01 +00:00
Vedant Kumar 02de50fdc4 Fix warnings in JSON.cpp, NFC
These asserts are no-ops, and are supplanted by -Wcovered-switch.

llvm-svn: 319596
2017-12-01 23:29:04 +00:00
Vedant Kumar 01e86df684 Fix warnings in DNBDataRef.cpp, NFC
llvm-svn: 319595
2017-12-01 23:24:12 +00:00
Jan Kratochvil 4f39b294aa Prevent vain lldb::user_id_t 0xffffffff lookups
I have found LLDB commonly looks up lldb::user_id_t 0xffffffff failing to find
its DIE. One would rather expect LLDB_INVALID_UID == 0xffffffffffffffff in such
case.

DWARFASTParserClang.cpp:495
492             type_sp.reset(
493                 new Type(die.GetID(), dwarf, type_name_const_str, byte_size, NULL,
494                          DIERef(encoding_uid).GetUID(dwarf), encoding_data_type,
495                          &decl, clang_type, resolve_state));
encoding_uid = (DWARFFormValue) {m_cu = 0x0, m_form = 0, m_value = {value = {uval = 0, sval = 0, cstr = 0x0}, data = 0x0}}
-> DIERef::DIERef(const DWARFFormValue &form_value = {m_cu = 0x0, m_form = 0, m_value = {value = {uval = 0, sval = 0, cstr = 0x0}, data = 0x0}})
-> (DIERef) {cu_offset = 0xffffffff, die_offset = 0xffffffff}
-> lldb::user_id_t DIERef::GetUID(SymbolFileDWARF *dwarf = 0x61d00000b480) const
-> Type::Type(lldb::user_id_t encoding_uid = 0xffffffff)
But 0xffffffff !=
#define LLDB_INVALID_UID UINT64_MAX

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

llvm-svn: 319580
2017-12-01 20:14:09 +00:00
Pavel Labath 11edb4eeef Kill struct IOVEC
struct iovec is used as an interface to system (posix) api's. As such,
we shouldn't be using it in os-independent code, and we shouldn't be
defining our own iovec replacements.

Fortunately, its usage was not very widespread, so the removal was very
easy -- I simply moved a couple declarations into os-specific code.

llvm-svn: 319536
2017-12-01 12:05:00 +00:00
Jim Ingham 4e29eed498 ClangASTContext::ParseClassTemplateDecl doesn't always succeed.
When it does, it returns a NULL ClassTemplateDecl.  Don't use 
it if it is NULL...

<rdar://problem/35672107>

llvm-svn: 319516
2017-12-01 03:41:30 +00:00
Zachary Turner 888a428292 Add lldb-test.
This is basically a proof-of-concept and starting point for having a
testing-centric tool in LLDB.  I'm sure this leaves a lot of room to be
desired, but this at least allows us to have something to build on.

Right now there is only one command, the `module-sections` command, and I
created this command not because it was particularly special, but
because it addressed an immediate use case and was extremely simple.

Run the tool as `lldb-test module-sections <path-to-object>`.

Feel free to add testing related stuff to your heart's content after
this goes in.  Implementing the commands themselves takes some work, but
once they're there they can be reused without writing any code and
result in very easy to use and maintain tests.

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

llvm-svn: 319504
2017-12-01 00:52:51 +00:00
Jason Molenda c187147572 We had a situation where a kext was inlined into the kernel,
but still listed in the kernel's kext table with the kernel
binary UUID.  This resulted in the kernel text section being
loaded at the kext address and problems ensuing.  Instead,
if there is a kext with the same UUID as the kernel, lldb
should skip over it.

<rdar://problem/35757689> 

llvm-svn: 319500
2017-11-30 23:31:18 +00:00
Alexander Shaposhnikov 03c17a0c87 [lldb] A few minor fixes in TaskPool
1. Move TaskPool into the namespace lldb_private.
2. Add missing std::move in TaskPoolImpl::Worker.
3. std:🧵:hardware_concurrency may return 0,
handle this case correctly.

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

Test plan: make check-all

llvm-svn: 319492
2017-11-30 22:56:11 +00:00
Jim Ingham 0b7c822f84 Fix this test so that the breakpoints you set are
unambiguously on one bit of code.  On macOS these
lines mapped to two distinct locations, and that
was artificially throwing off the test.

llvm-svn: 319472
2017-11-30 20:43:00 +00:00
Jim Ingham 27f55dda1d Remove a long out-of-date comment.
llvm-svn: 319454
2017-11-30 18:35:35 +00:00
Pavel Labath 6b75fab1fb Add a test case for open bug 35480
The test is about failing to hit breakpoints in global constructors in
shared libraries.

llvm-svn: 319443
2017-11-30 15:39:57 +00:00
Pavel Labath f59056ff93 Fix assertion in ClangASTContext
Summary:
llvm::APSInt(0) asserts because it creates an int with bit-width 0 and
not (as I thought) a value 0.

Theoretically it should be sufficient to change this to APSInt(1), as
the intention there was that the value of the first argument should be
ignored if the type is invalid, but that would look dodgy.

Instead, I use llvm::Optional to denote an invalid value and use a
special struct instead of a std::pair, to reduce typing and increase
clarity.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 319414
2017-11-30 10:16:54 +00:00
Jan Kratochvil bc3205e7bf refactor: Simplify loop with DWARFCompileUnit::Extract
Forgotten small simplification in D40212.

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

llvm-svn: 319402
2017-11-30 05:49:02 +00:00
Jim Ingham a5d07a79e4 Fix the gtest target for the move of ArchSpecTest.cpp from Core to Utility.
<rdar://problem/35562389>

llvm-svn: 319389
2017-11-30 00:23:42 +00:00
Jan Kratochvil ca9c2b290c refactor: Unify+simplify DWARFCompileUnit ctor+Clear() into in-class initializers + Extract()
It has no functionality effect.

I was concerned about the worse performance of DWARFDebugInfo::Parse this way
of allocating+destroying a CU for each iteration but I see it is now used only
by DWARFDebugInfo::Dump so that is no longer a problem.

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

llvm-svn: 319359
2017-11-29 21:13:11 +00:00
Jim Ingham 4e0b043009 Add elf-core/RegisterUtilities.{cpp,h} to the project file.
llvm-svn: 319226
2017-11-28 21:11:15 +00:00
Greg Clayton 7547aca722 Update remote debugging page with many more details.
llvm-svn: 319213
2017-11-28 20:04:43 +00:00
Stephane Sezer 5011298958 Simplify UUID constructors
Summary: This remove a small amount of duplicated code.

Reviewers: clayborg, zturner, davide

Subscribers: lldb-commits

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

llvm-svn: 319191
2017-11-28 17:50:31 +00:00
Pavel Labath bc8cc867a1 elf-core: Convert remaining register context to use register set maps
In https://reviews.llvm.org/D39681, we started using a map instead
passing a long list of register sets to the ppc64le register context.
However, existing register contexts were still using the old method.

This converts the remaining register contexts to use this approach.
While doing that, I've had to modify the approach a bit:
- the general purpose register set is still kept as a separate field,
because this one is always present, and it's parsing is somewhat
different than that of other register sets.
- since the same register sets have different IDs on different operating
systems, but we use the same register context class to represent
different register sets, I've needed to add a layer of indirection to
translate os-specific constants (e.g. NETBSD::NT_AMD64_FPREGS) into more
generic terms (e.g. floating point register set).

While slightly more complicated, this setup allows for better separation
of concerns. The parsing code in ProcessElfCore can focus on parsing
OS-specific core file notes, and can completely ignore
architecture-specific register sets (by just storing any unrecognised
notes in a map). These notes will then be passed on to the
architecture-specific register context, which can just deal with
architecture specifics, because the OS-specific note types are hidden in
a register set description map.

This way, adding an register set, which is already supported on other
OSes, to a new OS, should in most cases be as simple as adding a new
entry into the register set description map.

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

llvm-svn: 319162
2017-11-28 11:10:23 +00:00
Pavel Labath d2cfe0e597 Fix floating point register write on new x86 linux kernels
Summary:
New linux kernels (on systems that support the XSAVES instruction) will
not update the inferior registers unless the corresponding flag in the
XSAVE header is set. Normally this flag will be set in our image of the
XSAVE area (since we obtained it from the kernel), but if the inferior
has never used the corresponding register set, the respective flag can
be clear.

This fixes the issue by making sure we explicitly set the flags
corresponding to the registers we modify. I don't try to precisely match
the flags to set on each write, as the rules could get quite complicated
-- I use a simpler over-approximation instead.

This was already caught by test_fp_register_write, but that was only
because the code that ran before main() did not use some of the register
sets. Since nothing in this test relies on being stopped in main(), I
modify the test to stop at the entry point instead, so we can be sure
the inferior did not have a chance to access these registers.

Reviewers: clayborg, valentinagiusti

Subscribers: lldb-commits

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

llvm-svn: 319161
2017-11-28 10:56:54 +00:00
Stephane Sezer b108dbcc91 Remove some duplicated code in UUID.cpp
Summary: Formatting needs to be done only once. Ran check-lldb and nothing changes.

Reviewers: clayborg, davide

Reviewed By: clayborg, davide

Subscribers: zturner, davide, lldb-commits

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

llvm-svn: 319132
2017-11-28 01:26:07 +00:00
Stephane Sezer 2072552360 Mark UUID::GetByteSize() const
Summary:
This method doesn't modify anything in the object it's called on so we
can mark it const to make it usable in a const context.

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 319095
2017-11-27 21:16:37 +00:00
Pavel Labath 11479d1bab Remove custom TimePoint-formatting code
This was a temporary thing, until llvm has proper support for formatting
time. That time has come, so we can remove the relevant code. There
should be no change in the format of the time.

llvm-svn: 319048
2017-11-27 17:06:42 +00:00
Pavel Labath daa3c97e5a dotest: Mark more android targets as chatty
New android ndk linker started adding more flags to the produced
binaries, which causes older dynamic linkers display warnings to stderr
about unsupported flags. This interferes with our stderr tests.

Extend the hasChattyStderr function to catch these targets as well.

llvm-svn: 319028
2017-11-27 13:47:14 +00:00
Jan Kratochvil 639e799c98 Due to changes for DWZ I would need to update those such as renaming it to
SetFileOffset.

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

llvm-svn: 318981
2017-11-25 17:16:56 +00:00
Pavel Labath cef4119cdf elf-core: Split up parsing code into os-specific functions
Summary:
We've had a single function responsible for splitting a core segment
into notes, and parsing the notes themselves, bearing in mind variations
between 4 supported OS types. This commit splits that code into 5
pieces:
- (os-independent) code for splitting a segment into individual notes
- per-os function for parsing the notes into thread information

Reviewers: clayborg, krytarowski, emaste, alexandreyy, kettenis

Subscribers: lldb-commits

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

llvm-svn: 318903
2017-11-23 10:50:34 +00:00
Stephane Sezer fd3ffabfc3 Run clang-format on source/Host/common/Symbols.cpp
I saw a bunch of style errors so this fixes them.

llvm-svn: 318886
2017-11-22 23:56:32 +00:00
Tatyana Krasnukha 70cf4dd735 Remove extra minuses from command option
Reviewers: labath, abidh, clayborg, ki.stfu

Reviewed By: labath, abidh, clayborg, ki.stfu

Subscribers: clayborg, ki.stfu, lldb-commits

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

llvm-svn: 318846
2017-11-22 17:07:43 +00:00
Tatyana Krasnukha 6be1e3da1e Remove unused variable.
llvm-svn: 318833
2017-11-22 13:35:04 +00:00
Tatyana Krasnukha d40f357219 Test commit. Fix typo in comment.
llvm-svn: 318832
2017-11-22 13:03:02 +00:00
Craig Topper dc5050c4f5 [Expression parser] Remove logging of field that is no longer in clang's TargetOptions struct.
The Reciprocals field was moved to CodeGenOptions. I don't think lldb was really using this field so I'm just removing the mention.

llvm-svn: 318664
2017-11-20 17:24:47 +00:00
Jan Kratochvil 0f45abdef7 Remove 2 unused methods DWARFDebugInfo::Find and their FindCallbackString
Differential revision: https://reviews.llvm.org/D40216

llvm-svn: 318631
2017-11-19 19:04:24 +00:00
Jan Kratochvil d7ff94f035 Add comments to DWARFCompileUnit length fields/methods
Differential revision: https://reviews.llvm.org/D40211

llvm-svn: 318626
2017-11-19 14:35:07 +00:00
Davide Italiano e77c8425e1 [ABI] Remove dead code that was copy-pasted all around. NFCI.
llvm-svn: 318580
2017-11-18 00:54:31 +00:00
Davide Italiano 389dbb715c [Module] Throw away some more commented code. NFCI.
llvm-svn: 318579
2017-11-18 00:52:29 +00:00
Davide Italiano 2078234697 [ABI/SysV] Remove more dead code. NFCI.
llvm-svn: 318577
2017-11-18 00:35:27 +00:00
Davide Italiano f5b0135c6b [Core] Garbage collect dead code untouched in years. NFCI.
This sketching can be resurrected if anybody needs it, although
I doubt is relevant these days.

llvm-svn: 318576
2017-11-18 00:34:09 +00:00
Alexander Shaposhnikov f413c7852e [lldb] Ensure that dwo/dwp are not double-indexed
DWO/DWP should not be indexed directly.
Instead, the corresponding base file should be used.
This diff adds an assert to DWARFCompileUnit::Index
and adjusts the methods 
SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE,
SymbolFileDWARF::GetObjCMethodDIEOffsets accordingly.

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

llvm-svn: 318554
2017-11-17 20:50:54 +00:00
Eugene Zemtsov 11c0aab755 Fix LLDB build.
It was broken by r318489.

llvm-svn: 318504
2017-11-17 03:28:58 +00:00
Jason Molenda 5584cc48c7 Update xcode project file to build new ppc64le files.
llvm-svn: 318500
2017-11-17 01:55:50 +00:00
Jim Ingham e28a93deff Recognize another magic token sent in the LaunchInfo's EventData.
<rdar://problem/32505028>

llvm-svn: 318496
2017-11-17 01:22:34 +00:00
Jim Ingham 9347b68629 "source list -a" was calling DisplaySourceLinesWithNumbers incorrectly.
The parameters were just passed in the wrong order.

<rdar://problem/35150446>

llvm-svn: 318495
2017-11-17 01:19:59 +00:00
Greg Clayton 84a7333a61 Fixed up to use a class for the commands, renamed the commands and added a way to just dump the compile unit full paths and optionally their support files with the new "dump-files"command.
llvm-svn: 318424
2017-11-16 17:14:48 +00:00
Pavel Labath fd2c8d6572 Implement core dump debugging for PPC64le
Summary: Implement core dump debugging for PPC64le.

Reviewers: labath

Reviewed By: labath

Subscribers: JDevlieghere, krytarowski, clayborg, labath, lbianc, nemanjai, gut, anajuliapc, mgorny, kbarton, lldb-commits

Differential Revision: https://reviews.llvm.org/D39681
Patch by Alexandre Yukio Yamashita <alexandre.yamashita@eldorado.org.br>

llvm-svn: 318399
2017-11-16 13:38:57 +00:00
Jason Molenda 4f34614beb Fix alignment of arm64 fpu register context structure
so it has the same padding as the kernel's definition
which is written in terms of uint128_t.  Original patch
by Ryan Mansfield.

<rdar://problem/35468499> 

llvm-svn: 318357
2017-11-16 00:50:29 +00:00
Davide Italiano c12c0c5467 [POSIX] Replace assert with llvm_unreachable(). NFCI.
llvm-svn: 318348
2017-11-15 23:39:41 +00:00
Jason Molenda fd6647ecb6 Roll back r318260 because it is causing the windows bot to
break.  The alignas(__uint128_t) is not recognized with MSVC
it looks like.  Zachary, is there a similar type on windows?
I suppose I can go with alignas(16) here but I'd prefer to
specify the type alignment that I want & let the ABI dictate
how much padding is required.

llvm-svn: 318262
2017-11-15 03:41:47 +00:00
Jason Molenda 1f88f4c3bc Two small fixes to handle arm64 fpu register contexts in
a Mach-O file load command correctly, patch by Ryan
Mansfield.

<rdar://problem/35468499> 

llvm-svn: 318260
2017-11-15 03:18:24 +00:00
Jason Molenda 5882359128 Update xcode project file to track ArchSpec.cpp
move and LibCxxBitset.cpp addition.

llvm-svn: 318218
2017-11-14 23:15:35 +00:00
Don Hinton f031e48f45 Add check for self-assignment. NFC
Differential Revision: https://reviews.llvm.org/D39578

llvm-svn: 318164
2017-11-14 18:19:41 +00:00
Pavel Labath 5269875ef9 Add a data formatter for libc++ std::bitset
Reviewers: jingham, EricWF

Subscribers: mgorny, lldb-commits

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

llvm-svn: 318145
2017-11-14 11:15:03 +00:00
Stephane Sezer aaa41ae08e Reformat a comment. NFC.
llvm-svn: 318079
2017-11-13 20:13:25 +00:00
Pavel Labath 2da1b5970c Fix netbsd, freebsd and osx builds for ArchSpec move
llvm-svn: 318052
2017-11-13 16:47:37 +00:00
Pavel Labath 5f19b90783 Move ArchSpec to the Utility module
The rationale here is that ArchSpec is used throughout the codebase,
including in places which should not depend on the rest of the code in
the Core module.

This commit touches many files, but most of it is just renaming of
 #include lines. In a couple of cases, I removed the #include ArchSpec
line altogether, as the file was not using it. In one or two places,
this necessitated adding other #includes like lldb-private-defines.h.

llvm-svn: 318048
2017-11-13 16:16:33 +00:00
Pavel Labath 4ebb64b95f Remove last Host usage from ArchSpec
Summary:
In D39387, I was quick to jump to conclusion that ArchSpec has no
external dependencies. It turns there still was one call to
HostInfo::GetArchitecture left -- for implementing the "systemArch32"
architecture and friends.

Since GetAugmentedArchSpec is the place we handle these "incomplete"
triples that don't specify os or vendor and "systemArch" looks very much
like an incomplete triple, I move its handling there.

After this ArchSpec *really* does not have external dependencies, and
I'll move it to the Utility module as a follow-up.

Reviewers: zturner, clayborg, jingham

Subscribers: lldb-commits

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

llvm-svn: 318046
2017-11-13 15:57:20 +00:00
Pavel Labath 769b21eaf2 CompilerType: Add ability to retrieve an integral template argument
Summary:
Despite it's name, GetTemplateArgument was only really working for Type
template arguments. This adds the ability to retrieve integral arguments
as well (which I've needed for the std::bitset data formatter).

I've done this by splitting the function into three pieces. The idea is
that one first calls GetTemplateArgumentKind (first function) to
determine the what kind of a parameter this is. Based on that, one can
then use specialized functions to retrieve the correct value. Currently,
I only implement two of these: GetTypeTemplateArgument and
GetIntegralTemplateArgument.

Reviewers: jingham, clayborg

Subscribers: lldb-commits

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

llvm-svn: 318040
2017-11-13 14:26:21 +00:00
Pavel Labath d739636ccf Revert "[lldb] Use OrcMCJITReplacement rather than MCJIT as the underlying JIT for LLDB"
This commit really did not introduce any functional changes (for most
people) but it turns out it's not for the reason we thought it was.

The reason wasn't that Orc is a perfect drop-in replacement for MCJIT,
but it was because we were never using Orc in the first place, as it was
not initialized.

Orc's initialization relies on a global constructor in the LLVMOrcJIT.a.
Since this archive does not expose any symbols referenced from other
object files, it does not get linked into liblldb when linking against
llvm components statically. However, in an LLVM_LINK_LLVM_DYLIB=On
build, LLVMOrcJit.a is linked into libLLVM.so using --whole-archive, so
the global constructor does end up firing.

The result of using Orc jit is pr34194, where lldb fails to evaluate
even very simple expressions. This bug can be reproduced in
non-LLVM_LINK_LLVM_DYLIB builds by making sure Orc jit is linked into
liblldb, for example by #including
llvm/ExecutionEngine/OrcMCJITReplacement.h in IRExecutionUnit.cpp (and
adding OrcJIT as a dependency to the relevant CMakeLists.txt file). The
bug reproduces (at least) on linux and osx.

The root cause of the bug seems to be related to relocation processing.
It seems Orc processes relocations earlier than the system it is
replacing. This means the relocation processing happens before we have
had a chance to remap section load addresses to reflect their address in
the target process memory, so they end up pointing to locations in the
lldb's address space instead.

I am not sure whether this is a bug in Orc jit, or in how we are using
it from lldb, but in any case it is preventing us from using Orc right
now. Reverting this fixes LLVM_LINK_LLVM_DYLIB build, and makes it clear
that we are in fact *not* using Orc, and we never really were.

This reverts commit r279327.

llvm-svn: 318039
2017-11-13 14:03:17 +00:00
Greg Clayton 61eaf8f163 Added a way to dump the full paths to all source files in a module that has debug info.
llvm-svn: 317945
2017-11-10 22:39:07 +00:00
Alexander Shaposhnikov 7fd4a2c477 [lldb] Remove unused method declaration
FindCompleteObjCDefinitionType is not used anywhere and there is no implementation of it, only a declaration.

Test plan: make check-lldb

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

llvm-svn: 317919
2017-11-10 19:40:53 +00:00
Pavel Labath d37349f380 Clean up NativeRegisterContext
Summary:
This commit removes the concrete_frame_idx member from
NativeRegisterContext and related functions, which was always set to
zero and never used.

I also change the native thread class to store a NativeRegisterContext
as a unique_ptr (documenting the ownership) and make sure it is always
initialized (most of the code was already blindly dereferencing the
register context pointer, assuming it would always be present -- this
makes its treatment consistent).

Reviewers: eugene, clayborg, krytarowski

Subscribers: aemerson, sdardis, nemanjai, javed.absar, arichardson, kristof.beyls, kbarton, uweigand, alexandreyy, lldb-commits

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

llvm-svn: 317881
2017-11-10 11:05:49 +00:00
Pavel Labath 1ebc85f86f llgs-tests: Replace the "log+return false" pattern with llvm::Error
Summary:
These tests used to log the error message and return plain bool mainly
because at the time they we written, we did not have a nice way to
assert on llvm::Error values. That is no longer true, so replace this
pattern with a more idiomatic approach.

As a part of this patch, I also move the formatting of
GDBRemoteCommunication::PacketResult values out of the test code, as
that can be useful elsewhere.

Reviewers: zturner, eugene

Subscribers: mgorny, lldb-commits

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

llvm-svn: 317795
2017-11-09 15:45:09 +00:00
Pavel Labath 0ccb256dae Add a unit test for ClangASTContext template arguments handling
I am planning to make changes to this piece of code, so I wrote this
test to add more coverage to it first.

llvm-svn: 317792
2017-11-09 15:06:31 +00:00
Pavel Labath 578a425890 Simplify NativeProcessProtocol::GetArchitecture/GetByteOrder
Summary:
These functions used to return bool to signify whether they were able to
retrieve the data. This is redundant because the ArchSpec and ByteOrder
already have their own "invalid" states, *and* because both of the
current implementations (linux, netbsd) can always provide a valid
result.

This allows us to simplify bits of the code handling these values.

Reviewers: eugene, krytarowski

Subscribers: javed.absar, lldb-commits

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

llvm-svn: 317779
2017-11-09 10:43:16 +00:00
Pavel Labath d9f6f5f44d Xfail TestConcurrentTwoWatchpointsOneSignal on arm
r317561 exposed an interesting bug (pr35228) in handling of simultaneous
watchpoint hits. Disabling the test until we can get that fixed.

llvm-svn: 317683
2017-11-08 11:51:49 +00:00
Pavel Labath d2aab749d1 Log: delimit thread name in log message
The thread name was not followed by a space, which meant it was glued to
the log message. I also align the name as we do that with other log
fields. I align it to 16 chars instead of llvm::max_thread_name(), as
that can be 64 on darwin, which is rather long. If anybody feels
differently about that, we can change it.

llvm-svn: 317679
2017-11-08 10:48:54 +00:00
Pavel Labath 042c752691 Make TestTopLevelExprs more robust in face of linker GC
Summary:
This test was failing in various configurations on linux in a fairly
unpredictible way. The success depended on whether the c++ abi library
was linked in statically or not and how well was the linker able to
strip parts of it. This introduces additional code to the "dummmy" test
executable, which ensures that all parts of the library needed to
evaluate the expressions are always present.

Reviewers: clayborg

Subscribers: srhines, tatyana-krasnukha, davide, lldb-commits

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

llvm-svn: 317678
2017-11-08 10:48:50 +00:00
Pavel Labath 4c0461f8ce Update tuple/list/deque data formatters to work with newest libc++
Summary:
A couple of members of these data structures have been renamed in recent
months. This makes sure they still work with the latest libc++ version.

Reviewers: jingham, EricWF

Subscribers: lldb-commits

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

llvm-svn: 317624
2017-11-07 22:17:29 +00:00
Tamas Berghammer cf6bf4c4ba Fix an issue in r317563 causing a clang assert
llvm-svn: 317574
2017-11-07 13:43:55 +00:00
Tamas Berghammer 5976583a30 Support scoped enums in the DWARF AST parser
Subscribers: JDevlieghere

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

llvm-svn: 317563
2017-11-07 10:39:22 +00:00
Pavel Labath 888cc5d50b test: Clean up finalize_build_dictionary
We only support API>=16 now, so we don't need to check the API level of
the android device.

llvm-svn: 317562
2017-11-07 10:36:42 +00:00
Pavel Labath 881fe8ecb2 "Fix" concurrent events test for arm
Summary:
The test incremented an atomic varible to trigger the watchpoint event.
On arm64 this compiled to a ldaxr/stlxr loop, with the watchpoint being
triggered in the middle of the loop. Hitting the watchpoint resets the
exclusive monitor, and forces the process to loop one more time, hitting
the watchpoint again, etc.

While it would be nice if the debugger was able to resume from this
situation, this is not trivial, and is not what this test is about.
Therefore, I propose to change this to a simple store to a normal
variable (which should still trip the watchpoint everywhere, but without
atomic loops) and file a bug to investigate the possibilities of
handling the watchpoints in atomic loops in a more reasonable way.

Reviewers: clayborg

Subscribers: aemerson, kristof.beyls, lldb-commits

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

llvm-svn: 317561
2017-11-07 10:36:36 +00:00
Stephane Sezer d20106b5ec Disable tests in lang/c/shared_lib on Windows
Summary: These fail because `-fPIC` is not supported on Windows.

Reviewers: zturner, jingham, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 317529
2017-11-07 00:14:40 +00:00
Stephane Sezer 972d513a5c Add a dependency from check-lldb on lld
Summary:
This is required when using the in-tree clang for building tests,
because -fuse-ld=lld is used by default.

Subscribers: mgorny

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

llvm-svn: 317501
2017-11-06 19:25:33 +00:00
Pavel Labath a68e048233 Extend android xfail in TestTopLevelExprs
The test fails on API level 19 as well. I'm going to assume that it
fails on every API level below 23.

llvm-svn: 317474
2017-11-06 12:34:27 +00:00
Tamas Berghammer 7cb7df2bbf Improve the posix core file triple detection
Summary:
Posix core files sometime don't contain enough information to correctly
detect the OS. If that is the case we should use the OS from the target
instead as it will contain usable information in more cases and if the
target and the core contain different OS-es then we are already in a
pretty bad state so moving from an unknown OS to a known (but possibly
incorrect) OS will do no harm.

We already had similar code in place for MIPS. This change tries to make
it more generic by using ArchSpec::MergeFrom and extends it to all
architectures but some MIPS specific issue prevent us from getting rid
of special casing MIPS.

Reviewers: clayborg, nitesh.jain

Subscribers: aemerson, sdardis, arichardson, kristof.beyls, lldb-commits

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

llvm-svn: 317411
2017-11-04 18:25:51 +00:00
Pavel Labath a964012cd2 Remove ProcessGdbRemote::m_flags
The member is completely unused. Discussed on lldb-dev.

llvm-svn: 317377
2017-11-03 22:12:50 +00:00
Pavel Labath e6a661053d Add float/vector registers for ppc64le
Summary: Add read and write functions for VSX, VMX and float registers and fix watchpoint size

Reviewers: clayborg

Reviewed By: clayborg

Subscribers: eugene, labath, clayborg, nemanjai, kbarton, JDevlieghere, anajuliapc, gut, lbianc, lldb-commits

Differential Revision: https://reviews.llvm.org/D39487
Patch by: Alexandre Yukio Yamashita <alexandre.yamashita@eldorado.org.br>

llvm-svn: 317329
2017-11-03 15:22:36 +00:00
Don Hinton a6a2910e3d Add type to FileSpec::PathSyntax enum.
Summary:
Add type to FileSpec::PathSyntax enum to decrease size for
FileSpec on systems with 32 bit pointers.

Thanks to @zturner for pointing this out.

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

llvm-svn: 317327
2017-11-03 14:59:36 +00:00
Pavel Labath 6cf1aa5f5f Xfail test_stack_info_in_minidump test
The test has been failing since we enabled the i386 ABI plugin on
windows. See pr35193 for details.

llvm-svn: 317326
2017-11-03 14:42:37 +00:00
Pavel Labath 09bdfb32ef Fix classifications on two concurrent event tests
I have classified one as a watchpoint test even though it wasn't and
vice versa. Fix that.

llvm-svn: 317319
2017-11-03 12:13:22 +00:00
Pavel Labath 64b6e5af13 Remove getCategories mechanism of specifying test categories
Summary:
This mechanism was mostly redundant with the file-based .categories
mechanism, and it was interfering with it, as any test which implemented
a getCategories method would not inherit the filesystem categories.

This patch removes it. The existing categories are preserved either by
adding a .categories file, or using the @add_test_categories decorator.

Reviewers: jingham, clayborg, zturner

Subscribers: lldb-commits

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

llvm-svn: 317277
2017-11-02 22:13:09 +00:00
Pavel Labath 03304427a9 Remove android watchpoint xfails
Now that the wathpoint tests have their own category, we can easily skip
them on devices which don't have watchpoint support. Therefore, we don't
need an android xfail on each of these tests.

llvm-svn: 317276
2017-11-02 22:12:55 +00:00
Pavel Labath eac00c3be6 Fix some warnings found by ToT clang
These fall into two categories:
- unused variables
- (uint8_t *)NULL + X -- changed to reinterpret_cast(X)

llvm-svn: 317270
2017-11-02 21:35:26 +00:00
Stephane Sezer 7a0c218bae Run clang-format on lldb.cpp
llvm-svn: 317219
2017-11-02 16:56:52 +00:00
Stephane Sezer b55c8b1f16 Use LLVM version string
Summary:
macOS builds of LLDB use the bundle version from
`tools/driver/lldb-Info.plist`. That file hasn't been updated since the 4.0
release so the version we print provides no value. I also think that even if it
were up to date, that number has no meaning and displaying the version from the
LLVM tree is more valuable.

I know that Apple folks have some form of override for the clang version to
match the Xcode version, so it'd make sense for them to do the same for LLDB.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 317218
2017-11-02 16:56:19 +00:00
Jason Molenda 2350272187 Revert r317182 for https://reviews.llvm.org/D39128
we're still failing on android.  I'll ask Larry to 
ask Pavel for any tips he might be able to give.

llvm-svn: 317183
2017-11-02 03:17:07 +00:00
Jason Molenda edc2def4a6 Commit Lawrence D'Anna's patch to change
SetOututFileHandle to work with IOBase.

I did make one change after checking with Larry --
I renamed SBDebugger::Flush to FlushDebuggerOutputHandles
and added a short docstring to the .i file to make it
a little clearer under which context programs may need
to use this API.

Differential Revision: https://reviews.llvm.org/D39128
<rdar://problem/34870417> 

llvm-svn: 317182
2017-11-02 02:43:27 +00:00
Jason Molenda 9e27b70a07 Ahhhh roll back that commit, I didn't see that Lawrence had filed
a separate phabracator with the revised change.  This was his
first atttempt which broke on the bots the second time too.

llvm-svn: 317181
2017-11-02 02:33:59 +00:00
Jason Molenda c139a402b2 Commit Lawrence D'Anna's patch to change
SetOututFileHandle to work with IOBase.

I did make one change after checking with Larry --
I renamed SBDebugger::Flush to FlushDebuggerOutputHandles
and added a short docstring to the .i file to make it
a little clearer under which context programs may need
to use this API.

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

llvm-svn: 317180
2017-11-02 02:02:56 +00:00
Davide Italiano 43252d5390 [Core] Comparison for unsigned >= 0 is redundant. NFCI.
llvm-svn: 317145
2017-11-01 23:49:23 +00:00
Davide Italiano 014ef593aa [XML] Simplify lambda removing unused capture. NFCI.
llvm-svn: 317144
2017-11-01 23:48:07 +00:00
Davide Italiano 8e353b90c7 [Interpreter] Remove unused variable usage. NFCI.
llvm-svn: 317143
2017-11-01 23:46:21 +00:00
Pavel Labath cf82cc3d54 dotest: consistently call finalize_build_dictionary in debug info variants
dwarf&dwo versions were doing it, but gmodules and dsym weren't. All
this function does right now is pass OS=Android to make when targeting
android. This enables us to run dotest without manually passing --env
OS=Android.

llvm-svn: 317130
2017-11-01 22:01:03 +00:00
Jason Molenda 813c5f21dd add LibCxxTuple.cpp, LibCxxQueue.cpp to xcode project file.
llvm-svn: 317129
2017-11-01 21:55:35 +00:00
Pavel Labath e0d51846f2 Add data formatter for libc++ std::queue
Summary:
std::queue is just a fancy wrapper around another container, so all we
need to do is to delegate to the it.

Reviewers: jingham, EricWF

Subscribers: srhines, mgorny, lldb-commits, eugene

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

llvm-svn: 317099
2017-11-01 15:52:08 +00:00
Pavel Labath 333739d0e2 Add data formatter for libc++ std::tuple
Reviewers: jingham, EricWF

Subscribers: srhines, eugene, lldb-commits, mgorny

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

llvm-svn: 317095
2017-11-01 15:19:52 +00:00
Pavel Labath b38c02047a Remove uint32_t assignment operator from Status
Summary:
It is not presently used, and it's quite dangerous to use -- it assumes the
integer is an osx kern_return_t, but very few of the integers we have lying
around are mach kernel error codes. The error can still be used to a
mach error using a slightly longer (but more explicit) syntax.

Reviewers: jingham

Subscribers: lldb-commits

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

llvm-svn: 317093
2017-11-01 15:00:58 +00:00
Jason Molenda 6418bff2f3 Remove Sean Callanan from the CODE_OWNERS, he won't have time
to participate in lldb going forward.  Jim Ingham is adopting
the areas he was responsible for.

llvm-svn: 317067
2017-11-01 01:38:42 +00:00
Jim Ingham dccb1db1af Modernize the example cmdtemplate.py.
This version relies on a newer and more convenient way
to use a class to implement a command.  It has been in place
since early 2015, so it should be pretty safe to use.

llvm-svn: 317043
2017-10-31 22:38:24 +00:00
Pavel Labath 22e71a030e Add a "watchpoint" test category and annotate tests appropriately
Most of the watchpoint tests are organized into subtrees, so we can use the
file-based .categories approach to annotate them. The exception are the
concurrent_events tests, which needed to be annotated on a per-test basis.

The motivation behind this is to provide an easy way to disable watchpoint
tests on systems where the watchpoint functionality is not present/unreliable.

llvm-svn: 317004
2017-10-31 15:27:19 +00:00
Pavel Labath f753bfeeec Fix LLVM_LINK_LLVM_DYLIB build (pr35053)
Summary:
r316368 broke this build when it introduced a reference to a pthread
function to the Utility module. This caused cmake to generate an
incorrect link line (wrong order of libs) because it did not see the
dependency from Utility to the system libraries. Instead these libraries
were being manually added to each final target.

This changes moves the dependency management from the individual targets
to the lldbUtility module, which is consistent with how llvm does it.
The final targets will pick up these libraries as they will be a part of
the link interface of the module.

Technically, some of these dependencies could go into the host module,
as that's where most of the os-specific code is, but I did not try to
investigate which ones.

Reviewers: zturner, sylvestre.ledru

Subscribers: lldb-commits, mgorny

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

llvm-svn: 316997
2017-10-31 13:23:19 +00:00
Pavel Labath aee3e26c72 Increase AdbClient read timeout
The previous value was not sufficient for Pixel 2 phones. One would have
hoped that the newer phones are faster, but that does not seem to be the
case here.

llvm-svn: 316993
2017-10-31 12:27:46 +00:00
Pavel Labath 89ac0c7d32 Add data formatter for libc++'s forward_list
Summary:
This adds a data formatter for the implementation of forward_list in
libc++. I've refactored the existing std::list data formatter a bit to
enable more sharing of code (mainly the loop detection stuff).

Reviewers: jingham, EricWF

Subscribers: srhines, eugene, lldb-commits

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

llvm-svn: 316992
2017-10-31 12:27:43 +00:00
Pavel Labath e443564291 Fix mac build broken in r316987
Forgot one occurence of ArchSpec::SetTriple in mac-specific code.

llvm-svn: 316990
2017-10-31 11:48:33 +00:00
Pavel Labath 7263f1bda6 Invert ArchSpec<->Platform dependency
Summary:
ArchSpec::SetTriple was taking a Platform as an argument, and used it to
fill in missing pieces of the specified triple. I invert the dependency
by moving this code to other classes. For this purpose, I've created
three new functions.
- HostInfo::GetAugmentedArchSpec: fills in the triple using the host
  platform (this used to be implemented by passing a null platform
  pointer). By putting this code in the Host module, we can provide a
  way to anyone who does not have a platform instance (lldb-server) an
  easy way to get Host data.
- Platform::GetAugmentedArchSpec: if you have a platform instance, you
  can call this to let it fill in the triple.
- static Platform::GetAugmentedArchSpec: implements the "if platform ==
  0 then use_host() else use_platform()" part.

Reviewers: zturner, jingham, clayborg

Subscribers: mgorny, javed.absar, lldb-commits

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

llvm-svn: 316987
2017-10-31 10:56:03 +00:00
Pavel Labath 7344790005 Android.rules: build with "unified android headers"
Unified headers will be the only way to build applications in NDK r16,
and it also works with NDK r15.

This also bumps the minimum supported android version to 16.

llvm-svn: 316985
2017-10-31 10:33:03 +00:00
Pavel Labath 64325c51ad Split makefile for TestTopLevelExprs
this test was using a single makefile to build two executables. This
setup, although not supported by Makefile.rules, happened to
work in most configurations, except when building with the android ndk
r16.

Here I move the building of the second executable to a separate
makefile, which is the solution other tests use for multiple targets.

llvm-svn: 316982
2017-10-31 10:01:30 +00:00
Jim Ingham 205e5f656b Remove a stray space.
llvm-svn: 316954
2017-10-30 20:44:45 +00:00
Pavel Labath f93591b0be Fix windows build broken in r316915
I accidentally left a linux-specific include in generic code.

llvm-svn: 316919
2017-10-30 16:21:18 +00:00
Pavel Labath 3703310834 MainLoop: work around an android libc bug
Versions of android before kitkat implemented pselect non-atomically,
which caused flakyness, as we were relying on it atomically setting the
signal mask to implement waiting for signals.

This patch implements a direct call to the the pselect kernel syscall,
which does not suffer from this problem. The code itself is not very
pretty, but fortunately the uglyness is contained in the
android version of the MainLoop::RunImpl::Poll function.

llvm-svn: 316915
2017-10-30 16:00:13 +00:00
Davide Italiano 4ab13cda81 [CMake] Build clang as dependency when using in-tree clang for tests.
Discussed with Zachary Turner and Pavel Labath on lldb-dev.
Let's hope this doesn't break anything :)

llvm-svn: 316800
2017-10-27 21:22:57 +00:00