Commit Graph

21258 Commits

Author SHA1 Message Date
Jonas Devlieghere 6b44a41fef [lldb] Prevent Asan/SIP workaround from affecting Python in /usr/local/bin
The code that works around SIP was unintentionally being triggered for
/usr/local/bin/python as well. That caused trouble on GreenDragon where
we were swapping out a Python 3 executable with the system's Python 2
executable.
2019-11-08 09:08:27 -08:00
Adrian Prantl 454acae97c Adapt LLDB to clang API change in ObjCMethodDecl::create(). 2019-11-08 08:59:22 -08:00
Raphael Isemann cdc38c93fa [lldb] Skip parts of TestCallOverriddenMethod.py on Linux
The function call and the constructor call fail now several Linux
bots (Swift CI, my own bot and Stella's Debian system), so let's disable
the relevant test parts until we can figure out why it is failing.
2019-11-08 15:55:02 +01:00
Raphael Isemann 5a1bac4d1d [lldb] Make Target* a Target& in CommandObjectExpression::DoExecute REPL logic
Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70002
2019-11-08 12:28:49 +01:00
Raphael Isemann 79b3cce7f1 [lldb][NFC] Refactor some IsClangType checks in ClangASTContext
Summary:
All type in these functions need be valid and Clang types, so
we might as well replace these checks with IsClangType.

Also lets IsClangType explicitly check for validity instead of
assuming that the TypeSystem is a nullptr.

Subscribers: abidh, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70001
2019-11-08 12:03:28 +01:00
Jason Molenda 6602e1fb0e Reordering KextImageInfo::LoadImageUsingMemoryModule
so we only call ModulesDidLoad at the end of the method
after the new module has been added to the target and
the sections have all been adjusted to their actual
load addresses.  Solves a problem where an operating
system plugin in the kernel could be loaded multiple
times; the first before the binary had even been
added to the target.

<rdar://problem/50523558>
2019-11-07 19:34:09 -08:00
Fred Riss cbdd92be8a Modernize TestWeakSymbols Makefile 2019-11-07 14:53:52 -08:00
Jim Ingham f1539b9db3 BreakpointDummyOptionGroup was using g_breakpoint_modify_options rather than g_breakpoint_dummy_options
causing the -D option for breakpoint set command to be incorrectly parsed.

Patch by Martin Svensson.

Differential Revision: https://reviews.llvm.org/D69425
2019-11-07 14:25:04 -08:00
Jonas Devlieghere c62a9f180c [lldb] Improve assert in GDBRemoteCommunicationReplayServer
While investigating an issue where a different packet was sent during
replay I noticed how annoying it is that the existing assert doesn't
specify what packet is actually different. It's printed to the log, but
enabling logging has the potential to change LLDB's behavior. The same
is true when debugging LLDB while it's replaying the reproducer.

I replaced the assert with a printf of the unexpected packet followed by
a fatal_error wrapped in ifndef NDEBUG. The behavior is the same as the
previous assert, just with more/better context.
2019-11-07 12:43:59 -08:00
Adrian Prantl ff9d732887 crashlog.py: Improve regular expressions
This is yet another change to the regular expressions in crashlog.py
that fix a few edge cases, and attempt to improve the readability
quite a bit in the process. My last change to support spaces in
filenames introduced a bug that caused the version/archspec field to
be parsed as part of the image name.

For example, in "0x1111111 - 0x22222 +MyApp Pro arm64 <01234>", the
name of the image was recognized as "MyApp Pro arm64" instead of
"MyApp Pro" with a "version" of arm64.

The bugfix makes the space following an optional field mandatory
*inside* the optional group.

rdar://problem/56883435

Differential Revision: https://reviews.llvm.org/D69871
2019-11-07 10:52:06 -08:00
Jan Kratochvil 44f43461c0 [lldb] Comment typo fix 2019-11-07 17:48:25 +01:00
Raphael Isemann 87bc320b51 [lldb] Add -m option to 'target modules dump symtab' to disable demangling
Summary: This option was added downstream in swift-lldb. This upstreams this option as it seems useful and also adds the missing tests.

Reviewers: #lldb, kwk, labath

Reviewed By: kwk, labath

Subscribers: labath, kwk, abidh, JDevlieghere, lldb-commits

Tags: #lldb, #upstreaming_lldb_s_downstream_patches

Differential Revision: https://reviews.llvm.org/D69944
2019-11-07 15:47:01 +01:00
Guilherme Andrade b1b70f6761 [lldb-server] Add setting to force 'g' packet use
Following up on https://reviews.llvm.org/D62221, this change introduces
the settings plugin.process.gdb-remote.use-g-packet-for-reading.  When
they are on, 'g' packets are used for reading registers.

Using 'g' packets can improve performance by reducing the number of
packets exchanged between client and server when a large number of
registers needs to be fetched.

Differential revision: https://reviews.llvm.org/D62931
2019-11-07 10:48:54 +01:00
shafik e18f4db208 [LLDB] Adding caching to libc++ std::function formatter for lookups that require scanning symbols
Performance issues lead to the libc++ std::function formatter to be disabled.
This change is the first of two changes that should address the performance issues and allow us to enable the formatter again.
In some cases we end up scanning the symbol table for the callable wrapped by std::function for those cases we will now cache the results and used the cache in subsequent look-ups. This still leaves a large cost for the initial lookup which will be addressed in the next change.

Differential Revision: https://reviews.llvm.org/D67111
2019-11-06 16:02:56 -08:00
Jonas Devlieghere 703c97be24 [lldb] Mark ASan & TSan as test dependencies
Without asan and tsan as test dependencies, you might end up with a
clang that points to sanitizer runtime library that hasn't been build
yet.
2019-11-06 15:24:49 -08:00
Alex Langford a6b5daa701 [test] Fix apple_simulator_test decorator when simulators are unavailable
In the case where xcodebuild fails as you set up simulator tests, you
would fail because `feature` is never defined.
2019-11-06 15:14:01 -08:00
Jonas Devlieghere cfca0056f0 [lldb] Remove dead code from STLUtils.h 2019-11-06 15:06:29 -08:00
Fred Riss 8243918f43 Testuite: Support Asan test with remote testing
To do so, we need to register the sanitizer libraries with the target
so that they get uploaded before running. This patch adds a helper to
the test class to this effect.
2019-11-06 14:28:48 -08:00
shafik 83393d27af [LLDB] Fix handling for the clang name mangling extension for block invocations
Add support for clangs  mangling extension for block invocations.

Differential Revision: https://reviews.llvm.org/D69738
2019-11-06 14:20:00 -08:00
Haibo Huang 77a60f0df6 [lldb] Record framework build path and use it everywhere
This avoids config time dependencies on liblldb. And enables other refactoring.
2019-11-06 14:05:35 -08:00
Pavel Labath bcae3b04e8 lldb/docs: update the lldb-x86_64-debian bot url
It is on the "stable" master now.
2019-11-06 16:02:23 +01:00
Pavel Labath 58401612cd lldb: Skip reproducer+expression evaluation test on linux
It's flaky.
2019-11-06 15:48:00 +01:00
Benjamin Kramer eb12b3b8a3 Silence warning, PyMODINIT_FUNC already contains extern "C"
PythonReadline.h:22:12: warning: duplicate 'extern' declaration specifier [-Wduplicate-decl-specifier]
2019-11-06 12:27:11 +01:00
Alex Langford 40f3d1307c [TestMTCSimple] Disable the test if you don't have libMTC
If you are running on macOS and have the CommandLineTools installed of
Xcode, this test will fail because CommandLineTools doesn't ship with
libMainThreadChecker. Skip the test if you don't have it installed.
2019-11-05 14:11:26 -08:00
Haibo Huang 6a79e083a0 [lldb] Add a install target for lldb python on darwin
Summary: Similar to D68370 but for darwin framework build.

Reviewers: aadsm

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69834
2019-11-05 13:25:38 -08:00
Adrian Prantl 3ac6863efb [ValueObject] Upstream early exit from swift-lldb. (NFC) 2019-11-05 12:43:00 -08:00
Adrian Prantl de5417f81d [ValueObject] Upstream initialization from swift-lldb.
This is a non-Swift-specific change in swift-lldb that seems to be
useful for remote debugging. If does in fact turn out to be redundant
we can remove it from llvm.org and then it will disappear in
swift-lldb, too.
2019-11-05 12:36:14 -08:00
Jonas Devlieghere 2abcf44f4c [Reproducer] Add test case for expression evaluation 2019-11-05 12:33:21 -08:00
Fred Riss 42beb8ed79 TestBatchMode.py: add missing @skipIfRemote
All the tests in this file were already marked as skipped for remote tests
except for this one.
2019-11-05 12:22:59 -08:00
Fred Riss 270fe47aae testsuite: skipIfNoSBHeaders should skip when running remotely
The LLDB dylib/framework will not be available on the remote host, it makes
no sense to try to run those tests in a remote scenario.
2019-11-05 12:22:59 -08:00
Fred Riss 2ff545e76d Modernize add-dsym test Makefile 2019-11-05 12:22:59 -08:00
Adrian Prantl 3606b56784 ValueObject: Upstream early-exit from swift-lldb. (NFC) 2019-11-05 10:53:57 -08:00
Jonas Devlieghere a9970036d4 [lldb] Fix Python 3 incompatibility in API/lit.cfg.py
This code path is only taken on the sanitized bot, where it caused a
TypeError: "Can't mix strings and bytes in path components".
2019-11-05 10:13:01 -08:00
Michał Górny df3ae1eb29 [lldb] [Python] Build readline override module only on Linux
Restrict building the readline override to Linux only.  It both does not
build on *BSD systems, and is largely irrelevant since they default to
using libedit over readline anyway.  This restores the behavior
of the old readline override that also was built only on Linux.

Differential Revision: https://reviews.llvm.org/D69846
2019-11-05 17:07:59 +01:00
serge-sans-paille d590498829 [lldb] Fix readline/libedit compat patch for py2
This is a follow-up to https://reviews.llvm.org/D69793
2019-11-05 14:16:39 +01:00
Pavel Labath f71e35dc1f lldb/breakpad: add suppport for the "x86_64h" architecture 2019-11-05 11:41:20 +01:00
serge-sans-paille 9357b5d084 Revert and patch "[Python] Remove readline module"
Fix https://bugs.llvm.org/show_bug.cgi?id=43830 while avoiding polluting the
global Python namespace.

This both reverts r357277 to rebundle a version of Python's readline module
based on libedit.

However, this patch also provides two improvements over the previous
implementation:

1. use PyMem_RawMalloc instead of PyMem_Malloc, as expected by PyOS_Readline
   (prevents to segfault upon exit of interactive session)
2. patch the readline module upon embedded interpreter loading, instead of
   patching it globally, which should prevent any side effect on other
   modules/packages
3. only activate the patched module if libedit is actually linked in lldb

Differential Revision: https://reviews.llvm.org/D69793
2019-11-05 11:39:19 +01:00
Pavel Labath 4ecff91ed1 lldb/minidump: Add support for the alternate ARM64 constant 2019-11-05 11:26:06 +01:00
Pavel Labath 28cf9698ab MemoryRegion: Print "don't know" permission values as such
Summary:
The permissions in a memory region have ternary states (yes, no, don't
know), but the memory region command only prints in binary, treating
"don't know" as "yes", which is particularly confusing as for instance
the unwinder will treat an unknown value as "no".

This patch makes is so that we distinguish all three states when
printing the values, using "?" to indicate the lack of information. It
is implemented via a special argument to the format provider for the
OptionalBool enumeration.

Reviewers: clayborg, jingham

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D69106
2019-11-05 11:17:27 +01:00
Raphael Isemann db5074dc10 [lldb][NFC] Give some parameters in CommandInterpreter more descriptive names 2019-11-05 09:21:10 +01:00
Vedant Kumar 610f80f7ba [cmake] Add an option to skip stripping before install
The swift build system has support for cross-compiling, installing, and
generating symbols for lldb. As the swift symbol-generation step occurs
after installation, we need to disable stripping during the install.
2019-11-04 17:38:13 -08:00
Lawrence D'Anna adbf64ccc9 [LLDB][Python] remove ArgInfo::count
Summary:
This patch updates the last user of ArgInfo::count and deletes
it.   I also delete `GetNumInitArguments()` and `GetInitArgInfo()`.
Classess are callables and `GetArgInfo()` should work on them.

On python 3 it already works, of course. `inspect` is good.

On python 2 we have to add yet another special case.   But hey if
python 2 wasn't crufty we wouln't need python 3.

I also delete `is_bound_method` becuase it is unused.

This path is tested in `TestStepScripted.py`

Reviewers: labath, mgorny, JDevlieghere

Reviewed By: labath, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69742
2019-11-04 12:48:49 -08:00
Michał Górny 6eca4f4691 [lldb] [Process/NetBSD] Add register info for missing register sets
Add info for all register sets supported in NetBSD, particularly for all
registers 'expected' by LLDB.  This is necessary in order to fix
python_api/lldbutil/iter/TestRegistersIterator.py test that currently
fails due to missing names of register sets (None).

This copies fpreg descriptions from Linux, and combines Linux' AVX
and MPX registers into a single XState group, to fit NetBSD register
group design.  Technically, we do not support MPX registers
at the moment but gdb-remote insists on passing their errors anyway,
and if we do not include it in any group, they end up in a separate
anonymous group that breaks the test.

While at it, swap the enums for XState and DBRegs to match register set
ordering.

This also adds a few consts to the lldb-x86-register-enums.h to provide
more consistency between user registers and debug registers.

Differential Revision: https://reviews.llvm.org/D69667
2019-11-04 19:36:58 +01:00
Raphael Isemann bc728d5842 [lldb][NFC] Remove Ocaml from TypeSystem::LLVMCastKind
Ocaml support was removed.
2019-11-04 11:14:29 +01:00
Raphael Isemann 25b486ac4f [lldb][NFC] Remove unused ExpressionParser::Parse
Summary:
This function is only used internally by ClangExpressionParser. By putting it in the ExpressionParser class all languages
that implement ExpressionParser::Parse have to share the same signature (which forces us in downstream to add
swift-specific arguments to ExpressionParser::Parse which then propagate to ClangExpressionParser and so on).

Reviewers: davide

Subscribers: JDevlieghere, lldb-commits

Tags: #upstreaming_lldb_s_downstream_patches, #lldb

Differential Revision: https://reviews.llvm.org/D69710
2019-11-04 11:12:27 +01:00
Raphael Isemann 848007cfbc [lldb][NFC] Make test/python_api/module_section test smaller
Summary:
I don't see why this test needs to compile this rather complicated file for just testing module sections. This just removes all this code with a simple
"Hello world!" program which should be faster to compile

Reviewers: labath, davide, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: jfb, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69705
2019-11-04 09:25:01 +01:00
Raphael Isemann df12a75a19 [lldb] Also disable de-registration of EHFrames in IRExecutionUnit
Summary:
We disabled registration by providing an empty `registerEHFrames`, so we should also provide an empty `deregisterEHFrames`
in case that function relies on `registerEHFrames` being called before. Currently `deregisterEHFrames` is a no-op anyway
as it just iterates over the (empty( list of registered EHFrames and then clear the empty list.

Reviewers: davide, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: JDevlieghere, lldb-commits

Tags: #upstreaming_lldb_s_downstream_patches, #lldb

Differential Revision: https://reviews.llvm.org/D69713
2019-11-04 09:23:37 +01:00
Raphael Isemann ae10661a81 [lldb] Provide a getter for m_materializer_up in LLVMUserExpression instead of relying on it being accessible.
Summary:
Motivated by Swift using the materializer in a few places which requires us to add this getter ourselves.
We also need a setter, but let's keep this minimal to unblock the downstream reverts in Swift.

Reviewers: davide

Reviewed By: davide

Subscribers: abidh, JDevlieghere, lldb-commits

Tags: #upstreaming_lldb_s_downstream_patches, #lldb

Differential Revision: https://reviews.llvm.org/D69714
2019-11-04 09:05:24 +01:00
Raphael Isemann 80bf88d8bc [lldb] Add trailing dots to comments in Value.cpp
Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: JDevlieghere, lldb-commits

Tags: #upstreaming_lldb_s_downstream_patches, #lldb

Differential Revision: https://reviews.llvm.org/D69717
2019-11-04 08:35:56 +01:00
Luboš Luňák 79d8996d73 python path should be platform-dependent
Because one of the installed files is the _lldb.so symlink.

Differential Revision: https://reviews.llvm.org/D68910
2019-11-02 10:22:47 +01:00
Jim Ingham 81cc5d1c7d Don't assume that __cxa_current_exception_type exists.
Normally you shouldn't be able to have a process with an ItaniumABI plugin
that doesn't have this symbol.  But if the loader crashes before loading
libc++abi.dylib (on MacOS), then the symbol might not be present.  So we
should check before accessing the pointer.

There isn't a good way to write a test for this, but the change is obvious.
2019-11-01 17:20:31 -07:00
Martin Storsjö 1739c7c10c Reapply [LLDB] [test] Use %clang_cl instead of build.py in a few tests
This allows explicitly specifying the intended target architecture,
for tests that aren't supposed to be executed, and that don't
require MSVC headers or libraries to be available.

(These tests already implicitly assumed to be built for x86; one
didn't specify anything, assuming x86_64, while the other specified
--arch=32, which only picks the 32 bit variant of the default target
architecture).

Join two comment lines in disassembly.cpp, to keep row numbers
checked in the test unchanged.

This fixes running check-lldb on arm linux.

Previously when this was applied (in 95980409e6), it broke
macos buildbots, as they added "-isysroot <path>" to all %clang*
substitutions, and clang-cl didn't support that.

Reapplying it without further changes to this patch, after D69619
(9c73925226), because now, such extra parameters are added to
%clang_host*, but not to plain %clang_cl.

Differential Revision: https://reviews.llvm.org/D69031
2019-11-01 20:49:13 +02:00
Jason Molenda 54a873b158 Fix typeo in CPU_TYPE_ARM64_32 for older SDKs. 2019-10-31 14:13:57 -07:00
Alex Langford db542455dc [Symbol] Change ClangASTContext::GetCXXClassName return type
Summary:
Instead of filling out a std::string and returning a bool to indicate
success, returning a std::string directly and testing to see if it's
empty seems like a cleaner solution overall.

Differential Revision: https://reviews.llvm.org/D69641
2019-10-31 11:57:37 -07:00
Michał Górny 34f3c0fc44 [lldb] [test/API] Fix testcases symlink 2019-10-31 17:43:18 +01:00
Adrian Prantl aafe01fed4 Upstream diff from swift-lldb.
This is very likely untested, but it looks like an obviously correct change.
2019-10-31 09:25:36 -07:00
Pavel Labath 193a7bfb69 minidump: Create memory regions from the sections of loaded modules
Summary:
Not all minidumps contain information about memory permissions. However,
it is still important to know which regions of memory contain
potentially executable code. This is particularly important for
unwinding on win32, as the default unwind method there relies on
scanning the stack for things which "look like" code pointers.

This patch enables ProcessMinidump to reconstruct the likely permissions
of memory regions using the sections of loaded object files. It only
does this if we don't have a better source (memory info list stream, or
linux /proc/maps) for this information, and only if the information in
the object files does not conflict with the information in the minidump.

Theoretically that last bit could be improved, since the permissions
obtained from the MemoryList streams is also only a very rough guess,
but it did not seem worthwhile to complicate the implementation because
of that because there will generally be no overlap in practice as the
MemoryList will contain the stack contents and not any module data.

The patch adds a test checking that the module section permissions are
entered into the memory region list, and also a test which demonstrate
that now the unwinder is able to correctly find return addresses even in
minidumps without memory info list streams.

There's one TODO left in this patch, which is that the "memory region"
output does not give any indication about the "don't know" values of
memory region permissions (it just prints them as if they permission bit
was set). I address this in a follow up.

Reviewers: amccarth, clayborg

Subscribers: mgrang, lldb-commits

Differential Revision: https://reviews.llvm.org/D69105
2019-10-31 11:24:55 +01:00
Guilherme Andrade e46c6644db [lldb] Fix offset intersection bug between MPX and AVX registers
Summary:
This change increases the offset of MPX registers (by 128) so they
do not overlap with the offset associated with AVX registers. That was
causing MPX data in GDBRemoteRegisterContext::m_reg_data to get overwritten.

Reviewers: labath

Reviewed By: labath

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D68874
2019-10-31 10:58:17 +01:00
Pavel Labath 9c73925226 [lldb/lit] Introduce %clang_host substitutions
Summary:
This patch addresses an ambiguity in how our existing tests invoke the
compiler. Roughly two thirds of our current "shell" tests invoke the
compiler to build the executables for the host. However, there is also
a significant number of tests which don't build a host binary (because
they don't need to run it) and instead they hardcode a certain target.

We also have code which adds a bunch of default arguments to the %clang
substitutions. However, most of these arguments only really make sense
for the host compilation. So far, this has worked mostly ok, because the
arguments we were adding were not conflicting with the target-hardcoding
tests (though they did provoke an occasional "argument unused" warning).

However, this started to break down when we wanted to use
target-hardcoding clang-cl tests (D69031) because clang-cl has a
substantially different command line, and it was getting very confused
by some of the arguments we were adding on non-windows hosts.

This patch avoid this problem by creating separate %clang(xx,_cl)_host
substutitions, which are specifically meant to be used for compiling
host binaries. All funny host-specific options are moved there. To
ensure that the regular %clang substitutions are not used for compiling
host binaries (skipping the extra arguments) I employ a little
hac^H^H^Htrick -- I add an invalid --target argument to the %clang
substitution, which means that one has to use an explicit --target in
order for the compilation to succeed.

Reviewers: JDevlieghere, aprantl, mstorsjo, espindola

Subscribers: emaste, arichardson, MaskRay, jfb, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69619
2019-10-31 10:40:37 +01:00
Martin Storsjö 403cd574b6 [LLDB] [Windows] Fix Windows-specific race condition in LLDB for session lifetime
This can e.g. happen if the debugged executable exits before the initial
stop, e.g. if it fails to load dependent DLLs.

Add a virtual destructor to ProcessDebugger and let it clean up the
session, and make ProcessWindows::OnExitProcess call
ProcessDebugger::OnExitProcess for shared parts.

Fix suggestion by Adrian McCarthy.

Differential Revision: https://reviews.llvm.org/D69503
2019-10-31 11:26:20 +02:00
Martin Storsjö 3db1d138b1 [LLDB] [PECOFF] Fix error handling for executables that object::createBinary errors out on
llvm::object::createBinary returns an Expected<>, which requires
not only checking the object for success, but also requires consuming
the Error, if one was set.

Use LLDB_LOG_ERROR for this case, and change an existing similar log
statement to use it as well, to make sure the Error is consumed even
if the log channel is disabled.

Differential Revision: https://reviews.llvm.org/D69646
2019-10-31 11:26:21 +02:00
Martin Storsjö a42967f63c [LLDB] [Windows] Remove a TODO which probably won't be implemented
Contrary to WoW64 on x86_64, there's no struct similar to WOW64_CONTEXT
defined, for storing and handling the CPU state of an ARM32 process
from an ARM64 process. Thus, making an ARM64 lldb-server able to
control ARM32 processes seems infeasible at the moment.

(The normal CONTEXT struct has a different layout on each architecture.
In addition to this, a WOW64_CONTEXT struct always is defined, that
can store the CPU state of an x86_32 process, to allow handling it from
an x86_64 process. But there's no similar universally available struct
for ARM32.)
2019-10-31 11:26:06 +02:00
Martin Storsjö 7e1a307641 [LLDB] [PECOFF] Don't crash in ReadImageDataByRVA for addresses out of range
This can happen e.g. when unwinding doesn't work perfectly.

Differential Revision: https://reviews.llvm.org/D69502
2019-10-31 11:26:06 +02:00
Jim Ingham 29d5e275f2 Only ask once if we have no commands. NFC. 2019-10-30 18:04:03 -07:00
Adrian Prantl a925974bf1 Run clang-format on lldb/source/Commands (NFC)
These files had a lot of whitespace errors in them which was a
constant source of merge conflicts downstream.
2019-10-30 16:03:00 -07:00
Saleem Abdulrasool 5e029c4cfd DebugServer: be more lenient about the target triple
When building standalone, `LLVM_DEFAULT_TARGET_TRIPLE` may be undefined.
Matching against an empty string does not work as desired in CMake, so,
fallback to the old behaviour, defaulting `LLDB_DEBUGSERVER_ARCH` to
`CMAKE_OSX_ARCHITECTURES`.
2019-10-30 12:08:29 -07:00
Lawrence D'Anna fb01c01bf3 [LLDB][Python] warning fix for LLDBSwigPythonBreakpointCallbackFunction
This is a quick followup to this commit:

https://reviews.llvm.org/rGa69bbe02a2352271e8b14542073f177e24c499c1

In that, I #pragma-squelch this warning in `ScriptInterpreterPython.cpp`
but we get the same warning in `PythonTestSuite.cpp`.

This patch squelches the same warning in the same way as the
reviweed commit.   I'm submitting it without review under the
"obviously correct" rule.

At least if this is incorrect the main commit was also incorrect.

By the way, as far as I can tell, these functions are extern "C" because
SWIG does that to everything, not because they particularly need to be.
2019-10-30 09:47:27 -07:00
Lawrence D'Anna 3071ebf7b3 [LLDB][PythonFile] fix dangerous borrow semantics on python2
Summary:
It is inherently unsafe to allow a python program to manipulate borrowed
memory from a python object's destructor.     It would be nice to
flush a borrowed file when python is finished with it, but it's not safe
to do on python 2.

Python 3 does not suffer from this issue.

Reviewers: labath, mgorny

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69532
2019-10-30 09:46:51 -07:00
Pavel Labath 83a55c6a57 minidump: Rename some architecture constants
The architecture enum contains two kinds of contstants: the "official" ones
defined by Microsoft, and unofficial constants added by breakpad to cover the
architectures not described by the first ones.

Up until now, there was no big need to differentiate between the two. However,
now that Microsoft has defined
https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-system_info
a constant for ARM64, we have a name clash.

This patch renames all breakpad-defined constants with to include the prefix
"BP_". This frees up the name "ARM64", which I'll re-introduce with the new
"official" value in a follow-up patch.

Reviewers: amccarth, clayborg

Subscribers: lldb-commits, llvm-commits

Differential Revision: https://reviews.llvm.org/D69285
2019-10-30 14:46:00 +01:00
Pavel Labath 2d1a0dfe4c lldb-vscode: Add a forgotten cast to void
"git push" works even with a dirty working tree. :/
2019-10-30 14:27:55 +01:00
SquallATF 2dbcfad35d [lldb-vscod] fix build with NDEBUG on windows
Summary: _setmode in assert will not run when build with NDEBUG

Reviewers: mstorsjo, labath, amccarth

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69612
2019-10-30 14:20:22 +01:00
Pavel Labath f1e0ae3420 COFF: Set section permissions
Summary:
This enables us to reason about whether a given address can be
executable, for instance during unwinding.

Reviewers: amccarth, mstorsjo

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D69102
2019-10-30 14:13:21 +01:00
Michał Górny 02f4cfecf6 [lldb] [test] Mark TestCustomShell XFAIL on *bsd as well
All *BSD targets do not implement ShellExpandArguments, so mark
the test appropriately.
2019-10-30 13:26:13 +01:00
Jonas Devlieghere 44bac3ed52 [lldbsuite] Remove unused test_event files
These files don't appear to be used anywhere and the corresponding tests
are not run.
2019-10-29 16:56:59 -07:00
Jonas Devlieghere 9f989559ba [lldbsuite] Remove the DumpFormatter
This formatter is never used or referenced.
2019-10-29 16:56:59 -07:00
Jonas Devlieghere 8a82000e48 [lldbsuite] Remove pre_kill_hook package
This package was only used by dosep.py which has since been removed.
2019-10-29 16:56:59 -07:00
Jonas Devlieghere 5cc2e0651f [lldbsuite] Remove unused support files
To the best of my understanding these files or their content is nowhere
referenced.
2019-10-29 16:56:59 -07:00
Lawrence D'Anna a69bbe02a2 [LLDB][breakpoints] ArgInfo::count -> ArgInfo::max_positional_args
Summary:
Move breakpoints from the old, bad ArgInfo::count to the new, better
ArgInfo::max_positional_args.   Soon ArgInfo::count will be no more.

It looks like this functionality is already well tested by
`TestBreakpointCommandsFromPython.py`, so there's no need to write
additional tests for it.

Reviewers: labath, jingham, JDevlieghere

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69468
2019-10-29 15:03:02 -07:00
Davide Italiano d46c65592e [ValueObjectDisplay] Generalize the description of an option. 2019-10-29 13:05:56 -07:00
shafik e6581783f7 [LLDB] Fix for windows bots broken by unsupported tests 2019-10-29 11:33:11 -07:00
Lawrence D'Anna 6a93a12a8d [LLDB][Python] fix another fflush issue on NetBSD
Summary:
Here's another instance where we were calling fflush on an input
stream, which is illegal on NetBSD.

Reviewers: labath, mgorny

Reviewed By: mgorny

Subscribers: krytarowski, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69488
2019-10-29 09:41:22 -07:00
Saleem Abdulrasool e56ba3743b build: make standalone builds work again
Apple's greendragon bot uses a standalone build of lldb which would
fail to build after a recent change to LLVM as it relied on LLVM setting
global flags for its build.  Attempt to repair the standalone build for
greendragon bot.
2019-10-29 08:24:10 -07:00
Saleem Abdulrasool 55eec2ba96 build: workaround stale caches (NFC)
`LLVM_DEFAULT_TARGET_TRIPLE` is a cached variable, which means that it
may actually be unset.  Furthermore, in standalone builds, the variable
may be fully undefined.  Apply the regular expression over the empty
string in such a case.  This should improve the state of the green
dragon bot.
2019-10-29 08:20:58 -07:00
Raphael Isemann 3011c7eb31 [lldb][NFC] Make LLVMUserExpression::DoExecute return early
The giant if-else isn't conforming to LLVM code style.
2019-10-29 15:38:35 +01:00
Martin Storsjö 4394b5bee6 [LLDB] [PECOFF] Use FindSectionByID to associate symbols to sections
The virtual container/header section caused the section list to be
offset by one, but by using FindSectionByID, the layout of the
section list shouldn't matter.

Differential Revision: https://reviews.llvm.org/D69366
2019-10-29 14:48:35 +02:00
Haibo Huang 99046b873f [lldb] move package generation from python to cmake
Summary: This is the last part. And we can remove the python script.

Subscribers: lldb-commits, mgorny

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69019
2019-10-28 16:54:55 -07:00
Jim Ingham 651b5e725e Modernize TestThreadStepOut.py
This test was timing out on the swift CI bots.  I didn't see any obvious reason
for that, and the test hasn't had problems on greendragon.  OTOH, it was a bit
oddly written, and needed modernizing, so I did that.

Differential Revision: https://reviews.llvm.org/D69453
2019-10-28 16:15:09 -07:00
Vedant Kumar 82d3ba87d0 [debugserver] Detect arch from LLVM_DEFAULT_TARGET_TRIPLE
The debugserver build needs to conditionally include files depending on the
target architecture.

Switch on the architecture specified by LLVM_DEFAULT_TARGET_TRIPLE, as
the llvm and swift build systems use this variable to identify the
target (the latter, indirectly, through LLVM_HOST_TRIPLE).

It would be possible to switch on CMAKE_OSX_ARCHITECTURES, but the swift
build does not provide it, preferring instead to pass arch-specific
CFLAGS etc explicitly. Switching on LLVM_HOST_TRIPLE is also an option,
but it breaks down when cross-compiling.

Differential Revision: https://reviews.llvm.org/D69523
2019-10-28 15:34:39 -07:00
Jonas Devlieghere 5ae881f96f [Docs] Repurpose 'sources' page as 'contributing'.
The page describing how to get the sources was more about contributing
to LLDB than getting the actual source. This patch moves some things
around and repurposes this page as a contributing to LLDB landing page.
2019-10-28 15:03:05 -07:00
shafik de2c7cab71 Add support for DW_AT_export_symbols for anonymous structs
Summary:
We add support for DW_AT_export_symbols to detect anonymous struct on top of the heuristics implemented in D66175
This should allow us to differentiate anonymous structs and unnamed structs.
We also fix TestTypeList.py which was incorrectly detecting an unnamed struct as an anonymous struct.

Differential Revision: https://reviews.llvm.org/D68961
2019-10-28 14:26:54 -07:00
Jonas Devlieghere f8a92af893 [LLDB] Remove incorrect dotest.py invocation
The invocation shown by dotest.py to re-run a single test is misleading:
it ranges from missing arguments (best case scenario) to being totally
wrong (worst case scenario).

In the past I've tried to get it right, but given the dotest
architecture this is harder than it looks. Furthermore, we have pretty
good documentation on the website [1] for most use cases.

This patch removes the rerun invocation.

[1] https://lldb.llvm.org/resources/test.html
2019-10-28 13:24:07 -07:00
Jonas Devlieghere da2a4c234d [Docs] Update source code link to Github 2019-10-28 11:14:59 -07:00
Jonas Devlieghere 6336317e0a [Docs] Disable Python docs when LLDB_DISABLE_PYTHON is set
This leads to a configuration error because we're trying to get a
property that doesn't exist:

get_target_property() called with non-existent target "swig_wrapper"
2019-10-28 09:53:58 -07:00
Lawrence D'Anna 40b0fa7ef2 [LLDB][formatters] ArgInfo::count -> ArgInfo::max_positional_args
Summary:
Move breakpoints from the old, bad ArgInfo::count to the new, better
ArgInfo::max_positional_args.   Soon ArgInfo::count will be no more.

This functionality is tested in `TestFormatters.py`, `TestDataFormatterSynthVal.py`,
`TestDataFormatterSynthType.py`.

You may notice that the old code was passing 0 arguments when count was 1, and passing
1 argument when count is 2.

This is no longer necessary because max_positional_args counts the self pointer
correctly.

Reviewers: labath, jingham, JDevlieghere

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69469
2019-10-27 16:01:46 -07:00
Luboš Luňák 9231e44344 fix lldb build with -DLLVM_ENABLE_MODULES=On (missing #include)
The error message says to add the #include.
2019-10-26 15:34:45 +02:00
Shu-Chun Weng 5e30780855 Correct size_t format specifier
Differential Revision: https://reviews.llvm.org/D69455
2019-10-26 10:38:06 +02:00
Adrian McCarthy 5a3c657f3e Fix after 738af7a624
Default implementation of a new virtual method wasn't returning a value.
2019-10-25 15:57:52 -07:00
Jonas Devlieghere 10b5cd8ed5 [LLDB] Fix inline variable only used in assertion. (NFC)
This prevents unused variable warning/error in -DNDEBUG builds. The
variable was introduced in 5934cd11ea.

Patch by: Shu-Chun Weng

Differential revision: https://reviews.llvm.org/D69451
2019-10-25 15:47:17 -07:00
Pavel Labath 7c603a41e2 lldb/minidump: Refactor memory region computation code
The goal of this refactor is to enable ProcessMinidump to take into
account the loaded modules and their sections when computing the
permissions of various ranges of memory, as discussed in D66638.

This patch moves some of the responsibility for computing the ranges
from MinidumpParser into ProcessMinidump. MinidumpParser still does the
parsing, but ProcessMinidump becomes responsible for answering the
actual queries about memory ranges. This will enable it (in a follow-up
patch) to augment the information obtained from the parser with data
obtained from actual object files.

The changes in the actual code are fairly straight-forward and just
involve moving code around. MinidumpParser::GetMemoryRegions is renamed
to BuildMemoryRegions to emphasize that it does no caching. The only new
thing is the additional bool flag returned from this function. This
indicates whether the returned regions describe all memory mapped into
the target process. Data obtained from /proc/maps and the MemoryInfoList
stream is considered to be exhaustive. Data obtained from Memory(64)List
is not. This will be used to determine whether we need to augment the
data or not.

This reshuffle means that it is no longer possible/easy to test some of
this code via unit tests, as constructing a ProcessMinidump instance is
hard. Instead, I update the unit tests to only test the parsing of the
actual data, and test the answering of queries through a lit test using
the "memory region" command. The patch also includes some tweaks to the
MemoryRegion class to make the unit tests easier to write.

Reviewers: amccarth, clayborg

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D69035
2019-10-25 22:33:32 +00:00
Pavel Labath 73a7a55c0e lldb/COFF: Create a separate "section" for the file header
In an attempt to ensure that every part of the module's memory image is
accounted for, D56537 created a special "container section" spanning the
entire image. While that seemed reasonable at the time (and it still
mostly does), it did create a problem of what to put as the "file size"
of the section, because the image is not continuous on disk, as we
generally assume (which is why I put zero there). Additionally, this
arrangement makes it unclear what kind of permissions should be assigned
to that section (which is what my next patch does).

To get around these, this patch partially reverts D56537, and goes back
to top-level sections. Instead, what I do is create a new "section" for
the object file header, which is also being loaded into memory, though
its not considered to be a section in the strictest sense. This makes it
possible to correctly assign file size section, and we can later assign
permissions to it as well.

Reviewers: amccarth, mstorsjo

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D69100
2019-10-25 22:11:53 +00:00
Jim Ingham 738af7a624 Add the ability to pass extra args to a Python breakpoint callback.
For example, it is pretty easy to write a breakpoint command that implements "stop when my caller is Foo", and
    it is pretty easy to write a breakpoint command that implements "stop when my caller is Bar". But there's no
    way to write a generic "stop when my caller is..." function, and then specify the caller when you add the
    command to a breakpoint.

    With this patch, you can pass this data in a SBStructuredData dictionary. That will get stored in
    the PythonCommandBaton for the breakpoint, and passed to the implementation function (if it has the right
    signature) when the breakpoint is hit. Then in lldb, you can say:

    (lldb) break com add -F caller_is -k caller_name -v Foo

    More generally this will allow us to write reusable Python breakpoint commands.

    Differential Revision: https://reviews.llvm.org/D68671
2019-10-25 14:05:07 -07:00
Vedant Kumar 0877dd14e4 [Driver] Force llvm to install its handlers before lldb's
Install llvm's signal handlers up front to prevent lldb's handlers from being
ignored. This is (hopefully) a stopgap workaround.

When lldb invokes an llvm API that installs signal handlers (e.g.
llvm::sys::RemoveFileOnSignal, possibly via a compiler embedded within lldb),
lldb's signal handlers are overriden if llvm is installing its handlers for the
first time.

To work around llvm's behavior, force it to install its handlers up front, and
*then* install lldb's handlers. In practice this is used to prevent lldb test
processes from exiting due to IO_ERR when SIGPIPE is received.

Note that when llvm installs its handlers, it 1) records the old handlers it
replaces and 2) re-installs the old handlers when its new handler is invoked.
That means that a signal not explicitly handled by lldb can fall back to being
handled by llvm's handler the first time it is received, and then by the
default handler the second time it is received.

Differential Revision: https://reviews.llvm.org/D69403
2019-10-25 11:19:10 -07:00
Vedant Kumar 72105b9dcd Fix compilation error in ObjectFileMachO::ParseSymtab 2019-10-25 11:16:51 -07:00
Pavel Labath 96601ec28b ValueObject: Fix a crash related to children address type computation
Summary:
This patch fixes a crash encountered when debugging optimized code. If some
variable has been completely optimized out, but it's value is nonetheless known,
the compiler can replace it with a DWARF expression computing its value. The
evaluating these expressions results in a eValueTypeHostAddress Value object, as
it's contents are computed into an lldb buffer. However, any value that is
obtained by dereferencing pointers in this object should no longer have the
"host" address type.

Lldb had code to account for this, but it was only present in the
ValueObjectVariable class. This wasn't enough when the object being described
was a struct, as then the object holding the actual pointer was a
ValueObjectChild. This caused lldb to dereference the contained pointer in the
context of the host process and crash.

Though I am not an expert on ValueObjects, it seems to me that this children
address type logic should apply to all types of objects (and indeed, applying
applying the same logic to ValueObjectChild fixes the crash). Therefore, I move
this code to the base class, and arrange it to be run everytime the value is
updated.

The test case is a reduced and simplified version of the original debug info
triggering the crash. Originally we were dealing with a local variable, but as
these require a running process to display, I changed it to use a global one
instead.

Reviewers: jingham, clayborg

Subscribers: aprantl, lldb-commits

Differential Revision: https://reviews.llvm.org/D69273
2019-10-25 17:49:06 +00:00
Jonas Devlieghere 5934cd11ea [TableGen] Add asserts to make sure default values match property type
This adds a few asserts to the property TableGen backend to prevent
mismatches between property types and their default values. This
would've prevented a copy-paste mistake we discovered downstream.
2019-10-25 10:18:38 -07:00
Michał Górny a6712889f5 [lldb] [Host/netbsd] Set Arg0 for 'platform process list -v'
Differential Revision: https://reviews.llvm.org/D69400
2019-10-25 09:41:12 +02:00
Jonas Devlieghere 33fca97880 [CMake] Move LLDB_TEST_BUILD_DIRECTORY into test/CMakeLists.txt
The LLDB_TEST_BUILD_DIRECTORY variable only matters to the different
test suites. Therefore they belong in test/CMakeLists.txt rather than
the top-level CMakeLists.txt.
2019-10-24 14:47:07 -07:00
Jonas Devlieghere fd025c094b [CMake] Move test dependency tracking into test/CMakeLists.txt
As the name suggests, the LLDB test dependencies only matter to the
different test suites. Therefore they belong in test/CMakeLists.txt
rather than the top-level CMakeLists.txt.
2019-10-24 14:47:07 -07:00
Jonas Devlieghere 220cce1e72 [CMake] Don't set LLDB_TEST_* in the top-level CMakeLists
All these variables only affect the API tests. Therefore they belong in
test/API/CMakeLists.txt rather than the top-level CMakeLists.txt.
2019-10-24 14:47:07 -07:00
Jonas Devlieghere d52b36e354 [CMake] Remove unused variable LLDB_TEST_CXX_COMPILER
CMake allows you to set a custom CXX compiler for the API test suite.
However, this variable is never used, because dotest uses the same
compiler to build C and CXX sources.

I'm not sure if this variable was added with the intention of supporting
a different compiler or if this is just a remnant of old functionality.
Given that this hasn't been working for a while, I assume it's safe to
remove.

Differential revision: https://reviews.llvm.org/D69401
2019-10-24 14:47:07 -07:00
Vedant Kumar d0bd3fc88b Revert "Disable exit-on-SIGPIPE in lldb"
This reverts commit 32ce14e55e.

In post-commit review, Pavel pointed out that there's a simpler way to
ignore SIGPIPE in lldb that doesn't rely on llvm's handlers.
2019-10-24 13:19:49 -07:00
Michal Gorny 267cc3292e [lldb] [Python] Do not attempt to flush() a read-only fd
Summary:
When creating a FileSP object, do not flush() the underlying file unless
it is open for writing.  Attempting to flush() a read-only fd results
in EBADF on NetBSD.

Reviewers: lawrence_danna, labath, krytarowski

Reviewed By: lawrence_danna, labath

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D69320
2019-10-24 11:29:00 -07:00
Jonas Devlieghere 0c798aa448 [CMake] Split logic across test suite subdirectories (NFC)
The top-level CMake file in the test directory can be simplified by
moving relevant configuration options into the corresponding
subdirectories. Doing so makes it easier to understand what CMake
options are needed by the different test suites.

Differential revision: https://reviews.llvm.org/D69394
2019-10-24 10:58:22 -07:00
Raphael Isemann d01fd2f35a [lldb] Add nodebug attribute to import-std-module/sysroot test
Summary:
So far we rely on the default argument and the fact that we don't call this
inline function in our actual `main.cpp` to make sure that this function can only
be called if LLDB loads this header as a C++ module. This patch just adds
the nodebug attribute as yet another measure to make sure LLDB can't call this
function without the standard module loaded. Note that the test is already
requiring clang for the sysroot setup, so its fine that this is a Clang specific attribute.

Reviewers: friss, labath

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D68861
2019-10-23 09:26:57 -07:00
Mirko Brkusanin 4b63ca1379 [Mips] Use appropriate private label prefix based on Mips ABI
MipsMCAsmInfo was using '$' prefix for Mips32 and '.L' for Mips64
regardless of -target-abi option. By passing MCTargetOptions to MCAsmInfo
we can find out Mips ABI and pick appropriate prefix.

Tags: #llvm, #clang, #lldb

Differential Revision: https://reviews.llvm.org/D66795
2019-10-23 12:24:35 +02:00
Jonas Devlieghere 0bff9bd26e [lldb] Adjust for the new class_rw_t layout.
The field holding the "ro" will now be a union. If the low bit is set,
then it isn't an ro and it needs to be dereferenced once more to get to
it. If the low bit isn't set, then it is a proper class_ro_t

No dedicated test is needed as this code path will trigger when running
the existing Objective-C tests under a current version of the runtime.
2019-10-22 10:22:06 -07:00
Lawrence D'Anna d602e0d0ca fix PythonDataObjectsTest.TestExceptions on windows
Looks like on windows googlemock regexes treat newlines differently
from on darwin.    This patch fixes the regex in this test so it
will work on both.

Fixes: https://reviews.llvm.org/D69214
llvm-svn: 375477
2019-10-22 04:00:37 +00:00
Lawrence D'Anna 04edd1893c remove multi-argument form of PythonObject::Reset()
Summary:
With this patch, only the no-argument form of `Reset()` remains in
PythonDataObjects.   It also deletes PythonExceptionState in favor of
PythonException, because the only call-site of PythonExceptionState was
also using Reset, so I cleaned up both while I was there.

Reviewers: JDevlieghere, clayborg, labath, jingham

Reviewed By: labath

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 375475
2019-10-22 02:32:37 +00:00
Adrian Prantl e57fe85a59 whitespace cleanup
llvm-svn: 375465
2019-10-21 22:48:27 +00:00
Adrian Prantl 667c2eb08b Factor out common test functionality into a helper class. (NFC)
llvm-svn: 375464
2019-10-21 22:46:53 +00:00
Jonas Devlieghere 3434472ed7 XFAIL TestLocalVariables.py on Windows
This test has been failing for a while on the Windows bot.

https://bugs.llvm.org/show_bug.cgi?id=43752

llvm-svn: 375459
2019-10-21 22:16:28 +00:00
Adrian Prantl ed870cce67 Found more timeouts to unify.
llvm-svn: 375454
2019-10-21 20:50:45 +00:00
Adrian Prantl 5827a82a58 Unify timeouts in gdbserver tests and ensure they are larger if ASAN is enabled.
llvm-svn: 375431
2019-10-21 17:19:42 +00:00
Raphael Isemann 7a79e10a82 [lldb] Add test for executing static initializers in expression command
llvm-svn: 375422
2019-10-21 16:07:45 +00:00
Konrad Kleine 9129a281cd [lldb] drop .symtab removal in minidebuginfo tests
Summary:
After D69041, we no longer have to manually remove the .symtab section
once yaml2obj was run.

Reviewers: espindola, alexshap

Subscribers: emaste, arichardson, MaskRay, lldb-commits

Tags: #lldb

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

llvm-svn: 375415
2019-10-21 14:11:21 +00:00
Martin Storsjo a59444a356 [LLDB] [Windows] Initial support for ARM register contexts
Differential Revision: https://reviews.llvm.org/D69226

llvm-svn: 375392
2019-10-21 08:02:34 +00:00
Lawrence D'Anna 722b618924 eliminate nontrivial Reset(...) from TypedPythonObject
Summary:
This deletes `Reset(...)`, except for the no-argument form `Reset()`
from `TypedPythonObject`, and therefore from `PythonString`, `PythonList`,
etc.

It updates the various callers to use assignment, `As<>`, `Take<>`,
and `Retain<>`, as appropriate.

followon to https://reviews.llvm.org/D69080

Reviewers: JDevlieghere, clayborg, labath, jingham

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 375350
2019-10-19 18:43:49 +00:00
Lawrence D'Anna bdcad0aca0 convert LLDBSwigPythonCallTypeScript to ArgInfo::max_positional_args
Summary:
This patch converts another user of ArgInfo::count over to
use ArgInfo::max_positional_args instead.   I also add a test
to make sure both documented signatures for python type formatters
work.

Reviewers: JDevlieghere, clayborg, labath, jingham

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 375334
2019-10-19 07:05:39 +00:00
Lawrence D'Anna 2386537c24 [LLDB] bugfix: command script add -f doesn't work for some callables
Summary:
When users define a debugger command from python, they provide a callable
object.   Because the signature of the function has been extended, LLDB
needs to inspect the number of parameters the callable can take.

The rule it was using to decide was weird, apparently not tested, and
giving wrong results for some kinds of python callables.

This patch replaces the weird rule with a simple one: if the callable can
take 5 arguments, it gets the 5 argument version of the signature.
Otherwise it gets the old 4 argument version.

It also adds tests with a bunch of different kinds of python callables
with both 4 and 5 arguments.

Reviewers: JDevlieghere, clayborg, labath, jingham

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 375333
2019-10-19 07:05:33 +00:00
Reid Kleckner 90c64a3456 Move endian constant from Host.h to SwapByteOrder.h, prune include
Works on this dependency chain:
  ArrayRef.h ->
  Hashing.h -> --CUT--
  Host.h ->
  StringMap.h / StringRef.h

ArrayRef is very popular, but Host.h is rarely needed. Move the
IsBigEndianHost constant to SwapByteOrder.h. Clients of that header are
more likely to need it.

llvm-svn: 375316
2019-10-19 00:48:11 +00:00
Adrian Prantl 0904f92401 Skip (more) PExpect tests under ASAN, I can't get them to work reliably.
llvm-svn: 375312
2019-10-19 00:30:30 +00:00
Jonas Devlieghere 06a2beae92 [Reproducer] XFAIL TestWorkingDir on Windows
I'm having a hard time reproducing this and it's failing on the Windows
bot. Temporarily X-failing this test while I continue to try building
LLDB on Windows.

llvm-svn: 375294
2019-10-18 22:16:15 +00:00
Jonas Devlieghere 64b7d95568 [Reproducer] Improve reproducer help (NFC)
Provide a little more detail for the reproducer command.

llvm-svn: 375292
2019-10-18 21:47:31 +00:00
Vedant Kumar 32ce14e55e Disable exit-on-SIGPIPE in lldb
Occasionally, during test teardown, LLDB writes to a closed pipe.
Sometimes the communication is inherently unreliable, so LLDB tries to
avoid being killed due to SIGPIPE (it calls `signal(SIGPIPE, SIG_IGN)`).
However, LLVM's default SIGPIPE behavior overrides LLDB's, causing it to
exit with IO_ERR.

Opt LLDB out of the default SIGPIPE behavior. I expect that this will
resolve some LLDB test suite flakiness (tests randomly failing with
IO_ERR) that we've seen since r344372.

rdar://55750240

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

llvm-svn: 375288
2019-10-18 21:05:30 +00:00
Raphael Isemann 5c28d49314 [lldb][NFC] Remove wrong tests in TestCallOverriddenMethod
We call these tests in the second test function where they are
x-failed on Windows. I forgot to remove the tests from the first
test function (which is not x-failed on Windows) when extracting these
calls into their own test function, so the test is still failing on Windows.

llvm-svn: 375271
2019-10-18 19:18:41 +00:00
Jonas Devlieghere ded44e220f [Reproducer] Use ::rtrim() to remove trailing control characters.
Pavel correctly pointed out that removing all control characters from
the working directory is overkill. It should be sufficient to just strip
the last ones.

llvm-svn: 375259
2019-10-18 17:11:48 +00:00
Joseph Tremoulet 77460d3888 ProcessMinidump: Suppress reporting stop for signal '0'
Summary:
The minidump exception stream can report an exception record with
signal 0.  If we try to create a stop reason with signal zero, processing
of the stop event won't find anything, and the debugger will hang.
So, simply early-out of RefreshStateAfterStop in this case.

Also set the UnixSignals object in DoLoadCore as is done for
ProcessElfCore.

Reviewers: labath, clayborg, jfb

Reviewed By: labath, clayborg

Subscribers: dexonsmith, lldb-commits

Tags: #lldb

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

llvm-svn: 375244
2019-10-18 15:02:16 +00:00
Joseph Tremoulet d094d97d02 LLDB: Use LLVM's type for minidump ExceptionStream [NFC]
Summary: The types defined for it in LLDB are now redundant with core types.

Reviewers: labath, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 375243
2019-10-18 14:59:10 +00:00
Joseph Tremoulet a50272f826 Update MinidumpYAML to use minidump::Exception for exception stream
Reviewers: labath, jhenderson, clayborg, MaskRay, grimar

Reviewed By: grimar

Subscribers: lldb-commits, grimar, MaskRay, hiraditya, llvm-commits

Tags: #llvm, #lldb

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

llvm-svn: 375242
2019-10-18 14:56:19 +00:00
Pavel Labath ea8b8fdf90 Add REQUIRES: x86 to more tests which need the x86 llvm target built
llvm-svn: 375234
2019-10-18 13:49:40 +00:00
Pavel Labath 0c30491774 SystemInitializerCommon fix compilation on linux
C++ defines two overloads of std::iscntrl. One in <cctype> and one in
<locale>. On linux we seem to include both which makes the std::erase_if
call ambiguous.

Wrap std::iscntrl call in a lambda to ensure regular overload
resolution.

llvm-svn: 375221
2019-10-18 11:47:23 +00:00
Raphael Isemann b31c624156 [lldb][NFC] Fix typo in DWARFASTParserClang.cpp
llvm-svn: 375187
2019-10-17 23:11:32 +00:00
Lawrence D'Anna 03819d1c80 eliminate one form of PythonObject::Reset()
Summary:
I'd like to eliminate all forms of Reset() and all public constructors
on these objects, so the only way to make them is with Take<> and Retain<>
and the only way to copy or move them is with actual c++ copy, move, or
assignment.

This is a simple place to start.

Reviewers: JDevlieghere, clayborg, labath, jingham

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 375182
2019-10-17 22:22:09 +00:00
Lawrence D'Anna c86a6acaee clean up the implementation of PythonCallable::GetNumArguments
Summary:
The current implementation of PythonCallable::GetNumArguments
is not exception safe, has weird semantics, and is just plain
incorrect for some kinds of functions.

Python 3.3 introduces inspect.signature, which lets us easily
query for function signatures in a sane and documented way.

This patch leaves the old implementation in place for < 3.3,
but uses inspect.signature for modern pythons.   It also leaves
the old weird semantics in place, but with FIXMEs grousing about
it.   We should update the callers and fix the semantics in a
subsequent patch.    It also adds some tests.

Reviewers: JDevlieghere, clayborg, labath, jingham

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 375181
2019-10-17 22:22:06 +00:00
Sterling Augustine bbbc873f83 (NFC) Delete variable made unused by llvm-svn: 375160
Reviewers: aprantl

Subscribers: llvm-commits

Tags: #llvm

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

llvm-svn: 375174
2019-10-17 21:40:12 +00:00
Raphael Isemann 69b3363a53 [lldb] X-fail tests that use constructors in expressions on Windows
These tests were testing a bug related to constructors. It seems that
on Windows the expression command can't construct objects (or at least,
call their constructor explicitly which is required for the tests), so
this is just x-failing them until Windows actually supports constructor calls.

llvm-svn: 375173
2019-10-17 21:27:26 +00:00
Jonas Devlieghere a0f6c6434c [test] Add a .clang-format file for the shell test.
The API tests have a .clang-format file that disables formatting
altogether. While this is needed for some tests, it also leads to
inconsistency between test files. The shell tests suffer from a similar
problem: a test with a source-file extension (.c, .cpp) will get
formatted, potentially breaking up lines and leading to invalid RUN
commands.

Rather than completely disabling formatting here, I propose to not
enforce a line limit instead. That way tests will be consistent, but you
can still have long run commands (as is not uncommon in LLVM either) and
use breakpoints with patters that extend beyond 80 cols.

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

llvm-svn: 375172
2019-10-17 21:23:35 +00:00
Adrian Prantl 3ebbda0f08 Adapt Windows test to API change.
llvm-svn: 375170
2019-10-17 20:51:55 +00:00
Martin Storsjo 54017d0f52 Revert "[LLDB] [test] Use %clang_cl instead of build.py in a few tests"
This reverts SVN r375156, as it seems to have broken tests when run
on macOS: http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/2706/console

llvm-svn: 375163
2019-10-17 20:14:19 +00:00
Adrian Prantl 1ad655e255 Modernize the rest of the Find.* API (NFC)
This patch removes the size_t return value and the append parameter
from the remainder of the Find.* functions in LLDB's internal API. As
in the previous patches, this is motivated by the fact that these
parameters aren't really used, and in the case of the append parameter
were frequently implemented incorrectly.

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

llvm-svn: 375160
2019-10-17 19:56:40 +00:00
Martin Storsjo 95980409e6 [LLDB] [test] Use %clang_cl instead of build.py in a few tests
This allows explicitly specifying the intended target architecture,
for tests that aren't supposed to be executed, and that don't
require MSVC headers or libraries to be available.

(These tests already implicitly assumed to be built for x86; one
didn't specify anything, assuming x86_64, while the other specified
--arch=32, which only picks the 32 bit variant of the default target
architecture).

Join two comment lines in disassembly.cpp, to keep row numbers
checked in the test unchanged.

This fixes running check-lldb on arm linux.

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

llvm-svn: 375156
2019-10-17 19:22:50 +00:00
Raphael Isemann 6237c9fe6c [lldb] Don't emit artificial constructor declarations as global functions
Summary:
When we have a artificial constructor DIE, we currently create from that a global function with the name of that class.
That ends up causing a bunch of funny errors such as "must use 'struct' tag to refer to type 'Foo' in this scope" when
doing `Foo f`. Also causes that constructing a class via `Foo()` actually just calls that global function.

The fix is that when we have an artificial method decl, we always treat it as handled even if we don't create a CXXMethodDecl
for it (which we never do for artificial methods at the moment).

Fixes rdar://55757491 and probably some other radars.

Reviewers: aprantl, vsk, shafik

Reviewed By: aprantl

Subscribers: jingham, shafik, labath, JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 375151
2019-10-17 18:16:50 +00:00
Jonas Devlieghere 2b7899b730 [Reproducer] Surface error if setting the cwd fails
Make sure that we surface an error if setting the current working
directory fails during replay.

llvm-svn: 375146
2019-10-17 17:58:44 +00:00
Walter Erquinigo e19dfa6745 Disable TestProcessList on windows
Summary: `platform process list -v` on windows doesn't show all the process arguments, making this test useless for that platform

Reviewers: stella.stamenova

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 375144
2019-10-17 17:53:44 +00:00
Adrian Prantl d06a2f3ad6 Fix an inverted condition in test.
llvm-svn: 375127
2019-10-17 15:41:17 +00:00
Tatyana Krasnukha 92e498d58c [ARC] Add SystemV ABI
Differential Revision: https://reviews.llvm.org/D55724

llvm-svn: 375123
2019-10-17 15:18:03 +00:00
Tatyana Krasnukha faf6b2543e [ARC] Basic support in gdb-remote process plugin
Differential Revision: https://reviews.llvm.org/D55718

llvm-svn: 375122
2019-10-17 15:16:21 +00:00
Lawrence D'Anna 0f783599a4 delete SWIG typemaps for FILE*
Summary:
The SWIG typemaps for FILE* are no longer used, so
this patch deletes them.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 375073
2019-10-17 01:35:22 +00:00
Fangrui Song 56ee31964f SBCommandReturnObject: change LLDB_RECORD_METHOD(..., FILE *, ...) to use LLDB_RECORD_DUMMY
POSIX says FILE is a typedef to a structure containing information about
a file. The structure is unspecified, i.e. it may be an incomplete type, as is the case on musl
(`struct _IO_FILE` is an implementation detail that is not exposed).

`LLDB_RECORD_METHOD(..., (FILE *), ...)` transitively uses sizeof(FILE)
and requires the structure to be complete.  Change it to
LLDB_RECORD_DUMMY to fix the build failure on musl (regression of
D57475).

Reviewed By: JDevlieghere, labath, lawrence_danna

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

llvm-svn: 375072
2019-10-17 01:28:07 +00:00
Jonas Devlieghere eb1bbcec08 [CMake] Make it possible to set the RPATH in add_lldb_exectable.
Make it possible to pass a build and install RPATH to
add_lldb_executable instead of having to call lldb_setup_rpaths after
the fact.

This fixes a real issue where setting an install RPATH with
lldb_setup_rpaths would only affect the symroot installation component.
Given that lldb_setup_rpaths sets a target property I would expect this
to be orthogonal to installation components. Regardless, it makes sense
to integrate this functionality in add_lldb_exectable.

llvm-svn: 375068
2019-10-17 00:50:39 +00:00
Jonas Devlieghere f80f15e38a [Reproducer] Set the working directory in the VFS
Now that the VFS knows how to deal with virtual working directories, we
can set the current working directory to the one we recorded during
reproducer capture. This ensures that relative paths are resolved
correctly during replay.

llvm-svn: 375064
2019-10-17 00:24:37 +00:00
Raphael Isemann 755420c085 Revert "make ConstString allocate memory in non-tiny chunks"
As discussed in https://reviews.llvm.org/D68549, the actual issue
here seems to be that the BumpPtrAllocator is growing far too slow
because of the 256 different StringPools used as the backend for ConstString.
At the same time the original patch made ConstString allocate memory in
256MiB slabs for the same reason, meaning that the RSS usage of LLDB increased
by a few hundred MiB for all users without bringing any noticeable speedup
for most of them.

llvm-svn: 375062
2019-10-17 00:02:32 +00:00
Jonas Devlieghere f4f120125e [Reproducer] Support dumping the reproducer CWD
Add support for dumping the current working directory with
`reproducer dump -p cwd`.

llvm-svn: 375061
2019-10-17 00:02:00 +00:00
Jonas Devlieghere b2575da9aa [Reproducer] Add LoadBuffer<> helper (NFC)
Introduce a helper method named LoadBuffer in the Loader to abstract
reading a reproducer file from disk.

llvm-svn: 375060
2019-10-17 00:01:57 +00:00
Jonas Devlieghere 27ef81cd48 [Reproducer] Capture the debugger's working directory
This patch extends the reproducer to capture the debugger's current
working directory. This information will be used later to set the
current working directory of the VFS.

llvm-svn: 375059
2019-10-17 00:01:53 +00:00
Martin Storsjo 13993a6f86 [LLDB] Use the llvm microsoft demangler instead of the windows dbghelp api. NFCI.
Differential Revision: https://reviews.llvm.org/D68134

llvm-svn: 375034
2019-10-16 19:39:56 +00:00
Jason Molenda 7dd7a36075 Add arm64_32 support to lldb, an ILP32 codegen
that runs on arm64 ISA targets, specifically 
Apple watches.


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

llvm-svn: 375032
2019-10-16 19:14:49 +00:00
Walter Erquinigo 48a50ee034 [android/process list] support showing process arguments
Summary:
The qfProcessInfo and qsProcessInfo packets currently don't set the processes' arguments, however the platform process list -v command tries to print it.
In this diff I'm adding the arguments as part of the packet, and now the command shows the arguments just like on mac.

On Mac:

507    1      wallace    1876110778 wallace    1876110778 x86_64-apple-macosx      /usr/libexec/secd
503    1      wallace    1876110778 wallace    1876110778 x86_64-apple-macosx      /usr/libexec/secinitd
501    1      wallace    1876110778 wallace    1876110778 x86_64-apple-macosx      /usr/libexec/languageassetd --firstLogin
497    1      wallace    1876110778 wallace    1876110778 x86_64-apple-macosx      /usr/libexec/trustd --agent
496    1      wallace    1876110778 wallace    1876110778 x86_64-apple-macosx      /usr/libexec/lsd
494    1      wallace    1876110778 wallace    1876110778 x86_64-apple-macosx      /System/Library/Frameworks/CoreTelephony.framework/Support/CommCenter -L
491    1      wallace    1876110778 wallace    1876110778 x86_64-apple-macosx      /usr/sbin/distnoted agent
489    1      wallace    1876110778 wallace    1876110778 x86_64-apple-macosx      /usr/libexec/UserEventAgent (Aqua)
484    1      wallace    1876110778 wallace    1876110778 x86_64-apple-macosx      /usr/sbin/cfprefsd agent
483    1      wallace    1876110778 wallace    1876110778 x86_64-apple-macosx      /System/Library/Frameworks/LocalAuthentication.framework/Support/coreauthd
On android:

1561   1016   root       0                     0          aarch64-unknown-linux-android  /system/bin/ip6tables-restore--noflush -w -v
1805   982    1000       1000                  1000                                      android:drmService
1811   982    10189      10189                 10189                                     com.qualcomm.embms:remote
1999   1      1000       1000                  1000       aarch64-unknown-linux-android  /system/bin/tlc_serverCCM
2332   982    10038      10038                 10038                                     com.android.systemui
2378   983    1053       1053                  1053                                      webview_zygote
2448   982    5013       5013                  5013                                      com.sec.location.nsflp2
2465   982    10027      10027                 10027                                     com.google.android.gms.persistent

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

llvm-svn: 375029
2019-10-16 18:47:05 +00:00
Haibo Huang 1d4a40751f [lldb] move more things from python to cmake
Summary: Move the copy of six.py, lldb.py and macosx/heap

Reviewers: labath

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 375024
2019-10-16 18:00:21 +00:00
Lawrence D'Anna b07823f3e2 update ScriptInterpreterPython to use File, not FILE*
Summary:
ScriptInterpreterPython needs to save and restore sys.stdout and
friends when LLDB runs a python script.

It currently does this using FILE*, which is not optimal.  If
whatever was in sys.stdout can not be represented as a FILE*, then
it will not be restored correctly when the script is finished.

It also means that if the debugger's own output stream is not
representable as a file, ScriptInterpreterPython will not be able
to redirect python's  output correctly.

This patch updates ScriptInterpreterPython to represent files with
lldb_private::File, and to represent whatever the user had in
sys.stdout as simply a PythonObject.

This will make lldb interoperate better with other scripts or programs
that need to manipulate sys.stdout.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374964
2019-10-16 01:58:15 +00:00
Haibo Huang 208e9c01fc [lldb] Creates _liblldb symlink from cmake
Summary:
This is another attempt of D67993.

This change removed hard coded relative paths. This way we can generate correct result when get_python_lib() returns a different path, or LLDB_PYTHON_RELATIVE_PATH is specified directly.

By moving things out of python, we are also able to correctly process more cross compile situations. E.g. .pyd vs .so for Windows.

Subscribers: lldb-commits, mgorny

Tags: #lldb

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

llvm-svn: 374953
2019-10-15 21:58:45 +00:00
Lawrence D'Anna 30cf609548 remove FILE* usage from SBStream.i
Summary:
This patch removes FILE* and replaces it with SBFile and FileSP the
SWIG interface for `SBStream.i`.   And this is the last one.   With
this change, nothing in the python API will can access a FILE* method
on the C++ side.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374924
2019-10-15 17:41:40 +00:00
Lawrence D'Anna d3bd5b3d71 eliminate virtual methods from PythonDataObjects
Summary:
This patch eliminates a bunch of boilerplate from
PythonDataObjects, as well as the use of virtual methods.
In my opinion it also makes the Reset logic a lot more
clear and easy to follow.   The price is yet another
template.   I think it's worth it.

Reviewers: JDevlieghere, jasonmolenda, labath, zturner

Reviewed By: JDevlieghere, labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374916
2019-10-15 17:12:49 +00:00
Lawrence D'Anna 311dbb1bd7 convert SBDebugger::***FileHandle() wrappers to native files.
Summary:
This patch converts the swig wrappers for SetInputFileHandle() and friends
to emulate the old behavior using SetInputFile().

This will clear the way for deleting the FILE* typemaps altogether.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: mehdi_amini, dexonsmith, lldb-commits

Tags: #lldb

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

llvm-svn: 374912
2019-10-15 16:59:20 +00:00
Lawrence D'Anna d9b553ec99 SBFile::GetFile: convert SBFile back into python native files.
Summary:
This makes SBFile::GetFile public and adds a SWIG typemap to convert
the result back into a python native file.

If the underlying File itself came from a python file, it is returned
identically.   Otherwise a new python file object is created using
the file descriptor.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374911
2019-10-15 16:46:27 +00:00
Adrian Prantl b459be1025 Increase gdbremote_testcase timeouts when running under ASAN.
llvm-svn: 374906
2019-10-15 15:46:17 +00:00
Adrian Prantl 263eb36869 Skip PExpect tests under ASAN, I can't get them to work reliably.
llvm-svn: 374905
2019-10-15 15:38:49 +00:00
Aleksandr Urakov 86d0f8b148 [Windows][NFC] Fix tests after r374528.
Differential Revision: https://reviews.llvm.org/D67347

llvm-svn: 374888
2019-10-15 13:52:27 +00:00
Martin Storsjo 674d55438d [LLDB] [PECOFF] Use a "pc" vendor name in aarch64 triples
This matches all other architectures listed in the same file.

This fixes debugging aarch64 executables with lldb-server, which
otherwise fails, with log messages like these:

Target::SetArchitecture changing architecture to aarch64 (aarch64-pc-windows-msvc)
Target::SetArchitecture Trying to select executable file architecture aarch64 (aarch64-pc-windows-msvc)

ArchSpec::SetArchitecture sets the vendor to llvm::Triple::PC
for any coff/win32 combination, and if this doesn't match the triple
set by the PECOFF module, things doesn't seem to work with when
using lldb-server.

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

llvm-svn: 374867
2019-10-15 08:32:46 +00:00
Martin Storsjo b1f6ba2a2e [LLDB] [Windows] Initial support for ARM64 register contexts
Differential Revision: https://reviews.llvm.org/D67954

llvm-svn: 374866
2019-10-15 08:31:52 +00:00
Pavel Labath 8d49995795 Fix TestDisassemble_VST1_64
- use a full triple instead of just the architecture (makes the test
  pass on non-apple hosts)
- skip the test if the ARM llvm target is not built

llvm-svn: 374863
2019-10-15 07:20:01 +00:00
Walter Erquinigo d04855f820 [lldb-server/android] Show more processes by relaxing some checks
By default `platform process list` only shows the processes of the current user that lldb-server can parse.
There are several problems:
- apk programs don't have an executable file. They instead use a package name as identifier. We should show them instead.
- each apk also runs under a different user. That's how android works
- because of the user permission, some files like /proc/<pid>/{environ,exe} can't be read.

This results in a very small process list.

This is a local run on my machine
```
(lldb) platform process list
2 matching processes were found on "remote-android"
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
23291  3177              aarch64-unknown-linux-android sh
23301  23291            aarch64-unknown-linux-android lldb-server
```
However, I have 700 processes running at this time.

By implementing a few fallbacks for android, I've expanded this list to 202, filtering out kernel processes, which would presumably appear in this list if the device was rooted.

```
(lldb) platform process list
202 matching processes were found on "remote-android"
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
...
12647  3208              aarch64-unknown-linux-android sh
12649  12647             aarch64-unknown-linux-android lldb-server
12653  982                                        com.samsung.faceservice
13185  982                                        com.samsung.vvm
15899  982                                        com.samsung.android.spay
16220  982                                        com.sec.spp.push
17126  982                                        com.sec.spp.push:RemoteDlcProcess
19772  983                                        com.android.chrome
20209  982                                        com.samsung.cmh:CMH
20380  982                                        com.google.android.inputmethod.latin
20879  982                                        com.samsung.android.oneconnect:Receiver
21212  983                                        com.tencent.mm
24459  1                 aarch64-unknown-linux-android wpa_supplicant
25974  982                                        com.samsung.android.contacts
26293  982                                        com.samsung.android.messaging
28714  982                                        com.samsung.android.dialer
31605  982                                        com.samsung.android.MtpApplication
32256  982                                        com.bezobidny
```

Something to notice is that the architecture is unkonwn for all apks. And that's fine, because run-as would be required to gather this information and that would make this entire functionality massively slow.

There are still several improvements to make here, like displaying actual user names, which I'll try to do in a following diff.

Note: Regarding overall apk debugging support from lldb. I'm planning on having lldb spawn lldb-server by itself with the correct user, so that everything works well. The initial lldb-server used for connecting to the remote platform can be reused for such purpose. Furthermore, eventually lldb could also launch that initial lldb-server on its own.

Differential Revision: D68289

llvm-svn: 374853
2019-10-15 00:00:05 +00:00
Walter Erquinigo 1473b9f205 Revert "fix"
This reverts commit d8af64c9a0228301f6fd0e1c841e4abe0b6f4801.

llvm-svn: 374852
2019-10-14 23:56:54 +00:00
Walter Erquinigo ed57fb7665 fix
llvm-svn: 374846
2019-10-14 23:32:46 +00:00
Lawrence D'Anna 9efbc564ba build fix for SBInstruction.
oops!  I cherry-picked  rL374820 thinking it was completely
independent of D68737, but it wasn't.  It makes an incidental
use of SBFile::GetFile, which is introduced there, so I broke the
build.

The docs say you can commit without review for "obvious".   I think
this qualifies.   If this kind of fix isn't considered obvious, let
me know and I'll revert instead.

Fixes: rL374820
llvm-svn: 374825
2019-10-14 21:51:02 +00:00
Lawrence D'Anna e7a9115680 remove FILE* bindings from SBInstruction.
Summary:
This patch replaces the FILE* python bindings for SBInstruction and
SBInstructionList and replaces them with the new, safe SBFile and FileSP
bindings.

I also re-enable `Test_Disassemble_VST1_64`, because now we can use
the file bindings as an additional test of the disassembler, and we
can use the disassembler test as a test of the file bindings.

The bugs referred to in the comments appear to have been fixed.   The
radar is closed now and the bugzilla bug does not reproduce with the
instructions given.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374820
2019-10-14 20:59:57 +00:00
Lawrence D'Anna 62c9fe4273 uint32_t options -> File::OpenOptions options
Summary:
This patch re-types everywhere that passes a File::OpenOptions
as a uint32_t so it actually uses File::OpenOptions.

It also converts some OpenOptions related functions that fail
by returning 0 or NULL into llvm::Expected

split off from https://reviews.llvm.org/D68737

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374817
2019-10-14 20:15:34 +00:00
Lawrence D'Anna 322f12afc3 remove FILE* usage from ReportEventState() and HandleProcessEvent()
Summary:
This patch adds FileSP and SBFile versions of the API methods
ReportEventState and  HandleProcessEvent.   It points the SWIG
wrappers at these instead of the ones that use FILE* streams.

Reviewers: JDevlieghere, jasonmolenda, labath, jingham

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374816
2019-10-14 20:15:28 +00:00
Lawrence D'Anna d5768e3d0e Fix test breakage caused by r374424
Summary:
The build directory name is based on the test method name, so having
two test methods with the same name in the same test file is a
problem, even if they're in different test classes.

On linux and darwin this conflict can go unnoticed, but windows
has different filesystem semantics and it will fail when one
process tries to delete files still held open by another.

The problem is fixed just by changing the name of one of the test
methods.

Reviewers: JDevlieghere, jasonmolenda, labath, stella.stamenova

Reviewed By: stella.stamenova

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374803
2019-10-14 18:53:27 +00:00
Pavel Labath 458680ac78 minidump: Use yaml for memory info tests
Also, delete some minidump binary files that are no longer used in any
test.

llvm-svn: 374776
2019-10-14 14:16:39 +00:00
Pavel Labath 5a8db84964 DWARFExpression: Fix/add support for (v4) debug_loc base address selection entries
The DWARFExpression is parsing the location lists in about five places.
Of those, only one actually had proper support for base address
selection entries.

Since r374600, llvm has started to produce location expressions with
base address selection entries more aggresively, which caused some tests
to fail.

This patch adds support for these entries to the places which had it
missing, fixing the failing tests. It also adds a targeted test for the
two of the three fixes, which should continue testing this functionality
even if the llvm output changes. I am not aware of a way to write a
targeted test for the third fix (DWARFExpression::Evaluate).

llvm-svn: 374769
2019-10-14 12:49:06 +00:00
Walter Erquinigo af1d27e301 [platform process list] add a flag for showing the processes of all users
Summary:
For context: https://reviews.llvm.org/D68293

We need a way to show all the processes on android regardless of the user id.
When you run `platform process list`, you only see the processes with the same user as the user that launched lldb-server. However, it's quite useful to see all the processes, though, and it will lay a foundation for full apk debugging support from lldb.

Before:
```
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
3234   1                 aarch64-unknown-linux-android adbd
8034   3234              aarch64-unknown-linux-android sh
9096   3234              aarch64-unknown-linux-android sh
9098   9096              aarch64-unknown-linux-android lldb-server
(lldb) ^D
```

Now:
```
(lldb) platform process list -x
205 matching processes were found on "remote-android"
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
1      0                                          init
524    1                                          init
525    1                                          init
531    1                                          ueventd
568    1                                          logd
569    1                 aarch64-unknown-linux-android servicemanager
570    1                 aarch64-unknown-linux-android hwservicemanager
571    1                 aarch64-unknown-linux-android vndservicemanager
577    1                 aarch64-unknown-linux-android qseecomd
580    577               aarch64-unknown-linux-android qseecomd
...
23816  979                                        com.android.providers.calendar
24600  979                                        com.verizon.mips.services
27888  979                                        com.hualai
28043  2378                                       com.android.chrome:sandboxed_process0
31449  979                                        com.att.shm
31779  979                                        com.samsung.android.authfw
31846  979                                        com.samsung.android.server.iris
32014  979                                        com.samsung.android.MtpApplication
32045  979                                        com.samsung.InputEventApp
```

Reviewers: labath,xiaobai,aadsm,clayborg

Subscribers:

> llvm-svn: 374584

llvm-svn: 374631
2019-10-12 02:36:16 +00:00
Walter Erquinigo 0f22955899 Revert "[platform process list] add a flag for showing the processes of all users"
This reverts commit f670a5edfc70066872e1795d650ed6e1ac62b6a8.

llvm-svn: 374630
2019-10-12 02:31:22 +00:00
Walter Erquinigo d334b78f25 [platform process list] add a flag for showing the processes of all users
Summary:
For context: https://reviews.llvm.org/D68293

We need a way to show all the processes on android regardless of the user id.
When you run `platform process list`, you only see the processes with the same user as the user that launched lldb-server. However, it's quite useful to see all the processes, though, and it will lay a foundation for full apk debugging support from lldb.

Before:
```
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
3234   1                 aarch64-unknown-linux-android adbd
8034   3234              aarch64-unknown-linux-android sh
9096   3234              aarch64-unknown-linux-android sh
9098   9096              aarch64-unknown-linux-android lldb-server
(lldb) ^D
```

Now:
```
(lldb) platform process list -x
205 matching processes were found on "remote-android"
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
1      0                                          init
524    1                                          init
525    1                                          init
531    1                                          ueventd
568    1                                          logd
569    1                 aarch64-unknown-linux-android servicemanager
570    1                 aarch64-unknown-linux-android hwservicemanager
571    1                 aarch64-unknown-linux-android vndservicemanager
577    1                 aarch64-unknown-linux-android qseecomd
580    577               aarch64-unknown-linux-android qseecomd
...
23816  979                                        com.android.providers.calendar
24600  979                                        com.verizon.mips.services
27888  979                                        com.hualai
28043  2378                                       com.android.chrome:sandboxed_process0
31449  979                                        com.att.shm
31779  979                                        com.samsung.android.authfw
31846  979                                        com.samsung.android.server.iris
32014  979                                        com.samsung.android.MtpApplication
32045  979                                        com.samsung.InputEventApp
```

Reviewers: labath,xiaobai,aadsm,clayborg

Subscribers:

> llvm-svn: 374584

llvm-svn: 374626
2019-10-12 02:08:35 +00:00
Walter Erquinigo 892482eb9c Revert "[platform process list] add a flag for showing the processes of all users"
This reverts commit 90d0de4999354a5223f08ad714222b0a5dca3cad.

llvm-svn: 374625
2019-10-12 02:01:33 +00:00
Walter Erquinigo e031bdfefa [platform process list] add a flag for showing the processes of all users
Summary:
For context: https://reviews.llvm.org/D68293

We need a way to show all the processes on android regardless of the user id.
When you run `platform process list`, you only see the processes with the same user as the user that launched lldb-server. However, it's quite useful to see all the processes, though, and it will lay a foundation for full apk debugging support from lldb.

Before:
```
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
3234   1                 aarch64-unknown-linux-android adbd
8034   3234              aarch64-unknown-linux-android sh
9096   3234              aarch64-unknown-linux-android sh
9098   9096              aarch64-unknown-linux-android lldb-server
(lldb) ^D
```

Now:
```
(lldb) platform process list -x
205 matching processes were found on "remote-android"
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
1      0                                          init
524    1                                          init
525    1                                          init
531    1                                          ueventd
568    1                                          logd
569    1                 aarch64-unknown-linux-android servicemanager
570    1                 aarch64-unknown-linux-android hwservicemanager
571    1                 aarch64-unknown-linux-android vndservicemanager
577    1                 aarch64-unknown-linux-android qseecomd
580    577               aarch64-unknown-linux-android qseecomd
...
23816  979                                        com.android.providers.calendar
24600  979                                        com.verizon.mips.services
27888  979                                        com.hualai
28043  2378                                       com.android.chrome:sandboxed_process0
31449  979                                        com.att.shm
31779  979                                        com.samsung.android.authfw
31846  979                                        com.samsung.android.server.iris
32014  979                                        com.samsung.android.MtpApplication
32045  979                                        com.samsung.InputEventApp
```

Reviewers: labath,xiaobai,aadsm,clayborg

Subscribers:

> llvm-svn: 374584

llvm-svn: 374622
2019-10-12 01:33:21 +00:00
Walter Erquinigo 16194bf8bf Revert "[platform process list] add a flag for showing the processes of all users"
This reverts commit 08781f4c53a177662c029d3da9c407ba65ae6747.

llvm-svn: 374621
2019-10-12 01:08:50 +00:00
Walter Erquinigo 914f38295e [platform process list] add a flag for showing the processes of all users
Summary:
For context: https://reviews.llvm.org/D68293

We need a way to show all the processes on android regardless of the user id.
When you run `platform process list`, you only see the processes with the same user as the user that launched lldb-server. However, it's quite useful to see all the processes, though, and it will lay a foundation for full apk debugging support from lldb.

Before:
```
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
3234   1                 aarch64-unknown-linux-android adbd
8034   3234              aarch64-unknown-linux-android sh
9096   3234              aarch64-unknown-linux-android sh
9098   9096              aarch64-unknown-linux-android lldb-server
(lldb) ^D
```

Now:
```
(lldb) platform process list -x
205 matching processes were found on "remote-android"
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
1      0                                          init
524    1                                          init
525    1                                          init
531    1                                          ueventd
568    1                                          logd
569    1                 aarch64-unknown-linux-android servicemanager
570    1                 aarch64-unknown-linux-android hwservicemanager
571    1                 aarch64-unknown-linux-android vndservicemanager
577    1                 aarch64-unknown-linux-android qseecomd
580    577               aarch64-unknown-linux-android qseecomd
...
23816  979                                        com.android.providers.calendar
24600  979                                        com.verizon.mips.services
27888  979                                        com.hualai
28043  2378                                       com.android.chrome:sandboxed_process0
31449  979                                        com.att.shm
31779  979                                        com.samsung.android.authfw
31846  979                                        com.samsung.android.server.iris
32014  979                                        com.samsung.android.MtpApplication
32045  979                                        com.samsung.InputEventApp
```

Reviewers: labath,xiaobai,aadsm,clayborg

Subscribers:

> llvm-svn: 374584

llvm-svn: 374620
2019-10-12 00:44:50 +00:00
Adrian Prantl b15c886ba5 Temporarily Revert [platform process list] add a flag for showing the processes of all users
as it breaks the bots.

This reverts r374609 (git commit 696d3cf8ad)

llvm-svn: 374616
2019-10-12 00:03:40 +00:00
Walter Erquinigo 696d3cf8ad [platform process list] add a flag for showing the processes of all users
Summary:
For context: https://reviews.llvm.org/D68293

We need a way to show all the processes on android regardless of the user id.
When you run `platform process list`, you only see the processes with the same user as the user that launched lldb-server. However, it's quite useful to see all the processes, though, and it will lay a foundation for full apk debugging support from lldb.

Before:
```
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
3234   1                 aarch64-unknown-linux-android adbd
8034   3234              aarch64-unknown-linux-android sh
9096   3234              aarch64-unknown-linux-android sh
9098   9096              aarch64-unknown-linux-android lldb-server
(lldb) ^D
```

Now:
```
(lldb) platform process list -x
205 matching processes were found on "remote-android"
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
1      0                                          init
524    1                                          init
525    1                                          init
531    1                                          ueventd
568    1                                          logd
569    1                 aarch64-unknown-linux-android servicemanager
570    1                 aarch64-unknown-linux-android hwservicemanager
571    1                 aarch64-unknown-linux-android vndservicemanager
577    1                 aarch64-unknown-linux-android qseecomd
580    577               aarch64-unknown-linux-android qseecomd
...
23816  979                                        com.android.providers.calendar
24600  979                                        com.verizon.mips.services
27888  979                                        com.hualai
28043  2378                                       com.android.chrome:sandboxed_process0
31449  979                                        com.att.shm
31779  979                                        com.samsung.android.authfw
31846  979                                        com.samsung.android.server.iris
32014  979                                        com.samsung.android.MtpApplication
32045  979                                        com.samsung.InputEventApp
```

Reviewers: labath,xiaobai,aadsm,clayborg

Subscribers:

> llvm-svn: 374584

llvm-svn: 374609
2019-10-11 23:10:34 +00:00
Walter Erquinigo 6fcf068160 Revert "[platform process list] add a flag for showing the processes of all users"
Summary:
This reverts commit e4ac611cd787f3f0e727a394e96fb1a5c3b19ccb.

There's a failure according to http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/2538/testReport/junit/lldb-api/functionalities_gdb_remote_client/TestPlatformClient_py/

Reviewers: labath, aadsm, clayborg

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374603
2019-10-11 21:58:49 +00:00
Adrian Prantl f30ae71739 Set GNUC version in the LLDB expression parser.
This adapts LLDB for https://reviews.llvm.org/D68055.

Darwin's libC headers expect the GNUC macro to be set.

llvm-svn: 374591
2019-10-11 20:27:51 +00:00
Alex Langford 03fbde6d84 [NativePDB] Remove unused references to ClangASTImporter
llvm-svn: 374587
2019-10-11 20:12:29 +00:00
Adrian Prantl 886099974e Add -fgnuc-version to ClangModuleCompilationOptions on Darwin.
This adapts LLDB for https://reviews.llvm.org/D68055.

Darwin's libC headers expect the GNUC macro to be set.

llvm-svn: 374585
2019-10-11 19:54:09 +00:00
Walter Erquinigo 089a334c39 [platform process list] add a flag for showing the processes of all users
Summary:
For context: https://reviews.llvm.org/D68293

We need a way to show all the processes on android regardless of the user id.
When you run `platform process list`, you only see the processes with the same user as the user that launched lldb-server. However, it's quite useful to see all the processes, though, and it will lay a foundation for full apk debugging support from lldb.

Before:
```
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
3234   1                 aarch64-unknown-linux-android adbd
8034   3234              aarch64-unknown-linux-android sh
9096   3234              aarch64-unknown-linux-android sh
9098   9096              aarch64-unknown-linux-android lldb-server
(lldb) ^D
```

Now:
```
(lldb) platform process list -x
205 matching processes were found on "remote-android"
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
1      0                                          init
524    1                                          init
525    1                                          init
531    1                                          ueventd
568    1                                          logd
569    1                 aarch64-unknown-linux-android servicemanager
570    1                 aarch64-unknown-linux-android hwservicemanager
571    1                 aarch64-unknown-linux-android vndservicemanager
577    1                 aarch64-unknown-linux-android qseecomd
580    577               aarch64-unknown-linux-android qseecomd
...
23816  979                                        com.android.providers.calendar
24600  979                                        com.verizon.mips.services
27888  979                                        com.hualai
28043  2378                                       com.android.chrome:sandboxed_process0
31449  979                                        com.att.shm
31779  979                                        com.samsung.android.authfw
31846  979                                        com.samsung.android.server.iris
32014  979                                        com.samsung.android.MtpApplication
32045  979                                        com.samsung.InputEventApp
```

Reviewers: labath,xiaobai,aadsm,clayborg

Subscribers:

llvm-svn: 374584
2019-10-11 19:41:12 +00:00
Lubos Lunak e2ca7cb504 make ConstString allocate memory in non-tiny chunks
BumpPtrAllocator allocates in 4KiB chunks, which with any larger
project is going to result in a large number of allocations.
Increasing allocation size this way can save 10%-20% of symbol
load time for a huge C++ project with correctly built debuginfo.

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

llvm-svn: 374583
2019-10-11 19:34:39 +00:00
Haibo Huang 6aacd96875 [lldb] Fix python packages install path
Reviewers: mgorny

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374577
2019-10-11 17:44:14 +00:00
Lawrence D'Anna b3faa01ff9 IOHandler: fall back on File::Read if a FILE* isn't available.
Summary:
IOHandler needs to read lines of input from a lldb::File.
The way it currently does this using, FILE*, which is something
we want to avoid now.   I'd prefer to just replace the FILE* code
with calls to File::Read, but it contains an awkward and
delicate workaround specific to ctrl-C handling on windows, and
it's not clear if or how that workaround would translate to
lldb::File.

So in this patch, we use use the FILE* if it's available, and only
fall back on File::Read if that's the only option.

I think this is a reasonable approach here for two reasons.  First
is that interactive terminal support is the one area where FILE*
can't be avoided.   We need them for libedit and curses anyway,
and using them here as well is consistent with that pattern.

The second reason is that the comments express a hope that the
underlying windows bug that's being worked around will be fixed one
day, so hopefully when that happens, that whole path can be deleted.

Reviewers: JDevlieghere, jasonmolenda, labath, lanza

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374576
2019-10-11 17:43:32 +00:00
Raphael Isemann 766a0cb1e0 [lldb] Mark import-std-module/empty-module as libc++ test
Same as with the import-std-module/sysroot test before.

llvm-svn: 374574
2019-10-11 17:34:44 +00:00
Raphael Isemann 81018c85b9 [lldb] Add import-std-module/sysroot to the libc++ test category.
We essentially test libc++ in a sysroot here so let's make sure
that we actually only run this test on platforms where libc++
testing is enabled.

llvm-svn: 374572
2019-10-11 17:17:58 +00:00
Shafik Yaghmour 5f46982b45 [lldb-test] Modify lldb-test to print out ASTs from symbol file
Summary:
Currently when invoking lldb-test symbols -dump-ast it parses all the debug symbols and calls print(...) on the TranslationUnitDecl.
While useful the TranslationUnitDecl::print(...) method gives us a higher level view then the dump from ASTDumper which is what we get when we invoke dump() on a specific AST node.
The main motivation for this change is allow us to verify that the AST nodes we create when we parse DWARF. For example in order to verify we are correctly using DIFlagExportSymbols added by D66667

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

llvm-svn: 374570
2019-10-11 16:36:20 +00:00
Kadir Cetinkaya cb5324c462 [lldb] Insert break to avoid unannotated fall-through
llvm-svn: 374545
2019-10-11 12:33:47 +00:00
Martin Storsjo 807dbee366 [LLDB] [lldb-server] Use llvm::InitLLVM for doing unicode conversion of arguments for windows
This should allow lldb-server to operate on files with non-ascii
pathnames.

I tried looking around in lldb/tools, and this seemed like the only
other tool (other than the main lldb driver itself) that would be
used (implicitly) by an end user (which could be working in
non-ascii paths).

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

llvm-svn: 374537
2019-10-11 11:47:07 +00:00
Pavel Labath 2c24b928c3 minidump: Use llvm memory info list parser
llvm-svn: 374532
2019-10-11 11:23:40 +00:00
Pavel Labath a8b18baa0f ProcessInstanceInfoMatch: Don't match processes with no name if a name match was requested, take 2
Summary:
The previous attempt at making nameless process not match when searching for a
given name failed because the macos implementation was depending on this detail
in its partial matching strategy. Doing partial matching to avoid expensive
lookups is a perfectly valid thing to do, the way it was implemented seems
somewhat unexpected.

This patch implements it differently by providing special
methods in the ProcessInstanceInfoMatch which match only a subset of fields,
and changes mac host code to use those instead.

Then, it re-applies r373925 to get make the ProcessInstanceInfoMatch with a
name *not* match a nameless process.

Reviewers: JDevlieghere, teemperor, jingham

Subscribers: wallace, lldb-commits

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

llvm-svn: 374529
2019-10-11 10:56:54 +00:00
Aleksandr Urakov 30c2441a32 [Windows] Use information from the PE32 exceptions directory to construct unwind plans
This patch adds an implementation of unwinding using PE EH info. It allows to
get almost ideal call stacks on 64-bit Windows systems (except some epilogue
cases, but I believe that they can be fixed with unwind plan disassembly
augmentation in the future).

To achieve the goal the CallFrameInfo abstraction was made. It is based on the
DWARFCallFrameInfo class interface with a few changes to make it less
DWARF-specific.

To implement the new interface for PECOFF object files the class PECallFrameInfo
was written. It uses the next helper classes:

- UnwindCodesIterator helps to iterate through UnwindCode structures (and
  processes chained infos transparently);
- EHProgramBuilder with the use of UnwindCodesIterator constructs EHProgram;
- EHProgram is, by fact, a vector of EHInstructions. It creates an abstraction
  over the low-level unwind codes and simplifies work with them. It contains
  only the information that is relevant to unwinding in the unified form. Also
  the required unwind codes are read from the object file only once with it;
- EHProgramRange allows to take a range of EHProgram and to build an unwind row
  for it.

So, PECallFrameInfo builds the EHProgram with EHProgramBuilder, takes the ranges
corresponding to every offset in prologue and builds the rows of the resulted
unwind plan. The resulted plan covers the whole range of the function except the
epilogue.

Reviewers: jasonmolenda, asmith, amccarth, clayborg, JDevlieghere, stella.stamenova, labath, espindola

Reviewed By: jasonmolenda

Subscribers: leonid.mashinskiy, emaste, mgorny, aprantl, arichardson, MaskRay, lldb-commits, llvm-commits

Tags: #lldb

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

llvm-svn: 374528
2019-10-11 09:03:29 +00:00
Martin Storsjo 4778f40f78 [LLDB] [Driver] Use llvm::InitLLVM to do unicode argument conversion on Windows
This avoids the currently MSVC specific codepath of using the
wchar entry point and converting that to utf8.

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

llvm-svn: 374526
2019-10-11 08:44:51 +00:00
Raphael Isemann 423c2e98e4 [lldb] Fix crash in CxxModuleHandler when std module is empty
We currently don't handle the error in the Expected we get
when searching for an equal local DeclContext. Usually this can't
happen as this would require that we have a STL container and
we can find libc++'s std module, but when we load the module in
the expression parser the module doesn't even contain the 'std'
namespace. The only way I see to test this is by having a fake
'std' module that requires a special define to actually provide
its contents, while it will just be empty (that is, it doesn't
even contain the 'std' namespace) without that define. LLDB currently
doesn't know about that define in the expression parser, so it
will load the wrong 'empty' module which should trigger this error.

Also removed the 'auto' for that variable as the function name
doesn't make it obvious that this is an expected and not just
a optional/ptr (which is how this slipped in from the start).

llvm-svn: 374525
2019-10-11 08:42:22 +00:00
Haibo Huang 7b9900dff3 Clean up format in cmake file
Summary: Makes the indent consistent to other part of the file.

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 374483
2019-10-11 00:12:20 +00:00
Alex Langford 887707e29d [lldb-test] Remove unused header
llvm-svn: 374468
2019-10-10 22:43:03 +00:00
Jonas Devlieghere 6cff8648cc [Make] Remove spurious line break
This test is disabled upstream and therefore this went unnoticed.

llvm-svn: 374462
2019-10-10 21:49:25 +00:00
Jonas Devlieghere b9e518d3c6 [test] Reduce inconsistency between lit configuration files.
Add the Python extension to the configuration files in the API directory
to match the other test suites.

llvm-svn: 374461
2019-10-10 21:49:22 +00:00
Frederic Riss 58417b3390 TestMTCSimple: Make Makefile portable.
r374262 left out the Makefile changes needed to cross compile this test.

llvm-svn: 374451
2019-10-10 21:21:16 +00:00
Dimitry Andric a42942e0ec Fix process launch failure on FreeBSD after r365761
Summary:
After rLLDB365761, and with `LLVM_ENABLE_ABI_BREAKING_CHECKS` enabled,
launching any process on FreeBSD crashes lldb with:

```
Expected<T> must be checked before access or destruction.
Expected<T> value was in success state. (Note: Expected<T> values in success mode must still be checked prior to being destroyed).
```

This is because `m_operation_thread` and `m_monitor_thread` were wrapped
in `llvm::Expected<>`, but this requires the objects to be correctly
initialized before accessing them.

To fix the crashes, use `llvm::Optional<>` for the members (as indicated
by labath), and use local variables to store the return values of
`LaunchThread` and `StartMonitoringChildProcess`.  Then, only assign to
the member variables after checking if the return values indicated
success.

Reviewers: devnexen, emaste, MaskRay, mgorny

Reviewed By: devnexen

Subscribers: jfb, labath, krytarowski, lldb-commits

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

llvm-svn: 374444
2019-10-10 20:26:59 +00:00
Jonas Devlieghere 0a186d0f64 [test] Add timeout to API tests.
Before the reorganiziation, the API tests were inheriting the timeout
from the top-level lit file. Now that this is no longer the case, the
lldb-api test suite needs to set its own timeout.

llvm-svn: 374435
2019-10-10 19:51:50 +00:00
Jonas Devlieghere 7cc1fac8c9 [test] Cleanup top-level lit.cfg.py
llvm-svn: 374434
2019-10-10 19:51:47 +00:00
Jonas Devlieghere ff5640caea [Docs] Update testing documentaton
Update the test documentation after the directory reorganization.

llvm-svn: 374430
2019-10-10 19:35:20 +00:00
Lawrence D'Anna ab1cd65f19 update TestRunCommandInterpreterAPI to use SBFile
Summary:
If you look at what this test is doing, it's actually quite
mysterious why it works at all.   It sets the input file
inside a "with open".   As soon as the with block ends,
that file will be closed.   And yet somehow LLDB reads
commands from it anyway.    What's actually happening is that
the file descriptor gets dup'd when something inside LLDB
calls File::GetStream().   I think it's fair to say that
what this test is doing is illegal and it has no right
to expect it to work.

This patch updates the test with two cases.  One uses
the SBFile api, and actually transfers ownership of
the original file descriptor to the debugger.   The other
just uses the old FILE* API, but in a sane way.

I also set NO_DEBUG_INFO_TESTCASE, because this test doesn't
use any debug info and doesn't need to run three times.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: aprantl, lldb-commits

Tags: #lldb

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

llvm-svn: 374424
2019-10-10 19:24:07 +00:00
Lawrence D'Anna c040b30ffc update SBDebugger::SetInputFile() etc to work on native Files
Summary:
This patch adds FileSP versions of SetInputFile(),
SetOutputFile, and SetErrorFile().   SWIG will convert native
python file objects into FileSP.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: clayborg, lldb-commits

Tags: #lldb

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

llvm-svn: 374422
2019-10-10 19:10:59 +00:00
Lawrence D'Anna 4faec5e01a TestFileHandle.py: fix for Python 3.6
Summary:
Python 3.6 stringifies exceptions as `ExceptionClass("foo",)` instead
of `ExceptionClass("foo")`.   This patch makes the test assertions a
little more flexible so the test passes anyway.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374417
2019-10-10 18:38:23 +00:00
Adrian Prantl e9529a942a Remove merge marker :-)
llvm-svn: 374414
2019-10-10 18:30:47 +00:00
Jim Ingham b895f778e2 Die, TABS, die, die, die, die...
Not sure how tabs got into this file, but they don't belong there.

llvm-svn: 374412
2019-10-10 18:19:27 +00:00
Adrian Prantl 6a07b99c90 Remove CC autodetection from Makefile.rules
Auto-detecting CC in Makefile.rules is no longer useful. Ever since
out-of-tree builds we are better off just running lldb-dotest which
sets it directly. This also makes it harder to accidentally unset CC
in a Makefile.

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

llvm-svn: 374402
2019-10-10 17:59:18 +00:00
Adrian Prantl 418893d8f2 Speed up accelerator table lookups
When debugging a large program like clang and doing "frame variable
*this", the ValueObject pretty printer is doing hundreds of scoped
FindTypes lookups. The ones that take longest are the ones where the
DWARFDeclContext ends in something like ::Iterator which produces many
false positives that need to be filtered out *after* extracting the
DIEs. This patch demonstrates a way to filter out false positives at
the accerator table lookup step.

With this patch
  lldb clang-10 -o "b EmitFunctionStart" -o r -o "f 2" -o "fr v *this" -b -- ...
goes (in user time) from 5.6s -> 4.8s
or (in wall clock) from 6.9s -> 6.0s.

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

llvm-svn: 374401
2019-10-10 17:59:15 +00:00
Jim Ingham 47b33dcc0d Implement serializing scripted breakpoints and their extra args.
Differential Revision: https://reviews.llvm.org/D68750

llvm-svn: 374394
2019-10-10 17:44:50 +00:00
Jonas Devlieghere 27c23653ae [test] Use a different module cache for Shell and API tests.
Before the test reorganization, everything was part of a single test
suite with a single module cache. Now that things are properly separated
this is no longer the case. Only the shell tests inherited the logic to
properly configure and wipe the module caches. This patch adds that
logic back for the API tests. While doing so, I noticed that we were
configuring a Clang module cache in CMake, but weren't actually using it
from dotest.py. I included a fix for that in this patch as well.

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

llvm-svn: 374386
2019-10-10 17:27:09 +00:00
Jonas Devlieghere 2d2cf936ac [test] Pass DSYMUTIL and SDKROOT as part of the Make invocation.
Pass the DSYMUTIL and SDKROOT variables on the command line instead of
the environment. This makes it easier to reproduce the make invocation
during development.

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

llvm-svn: 374385
2019-10-10 17:27:06 +00:00
Jonas Devlieghere 5c5184be74 [test] Trim the symbtab test case (NFC)
We don't actually need the section content for this tests.

llvm-svn: 374382
2019-10-10 17:12:57 +00:00
Adrian Prantl a8419b1f27 Increase timeout in pexpect to lower chances of tests failing under ASAN.
If this doesn't actually work, I'll revert the change and just disable
the remaining thee pexpect tests under asan.

llvm-svn: 374375
2019-10-10 16:16:49 +00:00
Adrian Prantl cba575e8ff Increase timeout in gdbclientutils.py to decrease chance of test failing under ASAN.
llvm-svn: 374371
2019-10-10 15:59:17 +00:00
Pavel Labath 390accea83 unwind-via-stack-win.yaml: update for changes in yaml format
llvm-svn: 374353
2019-10-10 14:01:59 +00:00
Raphael Isemann ffe170c6e2 [lldb] Fix minidebuginfo-set-and-hit-breakpoint.test
This was failing for me because of this error:
llvm-objcopy: error: 'build/tools/lldb/test/ObjectFile/ELF/Output/minidebuginfo-set-and-hit-breakpoint.test.tmp.mini_debuginfo': section '.dynsym' cannot be removed because it is referenced by the section '.hash'

Patch by Konrad Kleine!

llvm-svn: 374352
2019-10-10 14:00:32 +00:00
Raphael Isemann ccd54a1349 [lldb] Add log output for the support files we pass to the CppModuleConfiguration
CppModuleConfiguration is the most likely point of failure when we have weird
setups where we fail to load a C++ module. With this logging it should be easier
to figure out why we can't find a valid configuration as the configuration only
depends on the list of file paths.

llvm-svn: 374350
2019-10-10 13:43:37 +00:00
Pavel Labath 5070322332 Fix the unwinding plan augmentation from x86 assembly
Unwind plan augmentation should compute the plan row at offset x from
the instruction before offset x, but currently we compute it from the
instruction at offset x. Note that this behavior is a regression
introduced when moving the x86 assembly inspection engine to its own
file
(1c9858b298 (diff-375a2be066db6f34bb9a71442c9b71fcL913));
the original version handled this properly by copying the previous
instruction out before advancing the instruction pointer.

The relevant bug with more info is here: https://bugs.llvm.org/show_bug.cgi?id=43561

Differential Revision: https://reviews.llvm.org/D68454
Patch by Jaroslav Sevcik <jarin@google.com>.

llvm-svn: 374342
2019-10-10 13:23:09 +00:00
Pavel Labath c8c71e6f76 Fix some dangling else warnings
EXPECT_EQ contains an if-else statement. It also contains some magic to
suppress the dangling else warnings, but it seems that some new
compilers can see through that...

llvm-svn: 374341
2019-10-10 13:23:02 +00:00
Raphael Isemann f5b2b76008 [lldb] Make sure import-std-module/sysroot actually passes for the right reasons
This test was previously passing because myabs was actually emitted into the
debug information and we called that. The test itself was broken as it didn't
use the libc++ directory structure (the /v1/ directory was just called /include/).

This patch gives myabs a default argument which we can't get from debug information
and inlines the function to make sure we can't call it from LLDB without loading
the C++ module.

llvm-svn: 374335
2019-10-10 12:57:14 +00:00
Pavel Labath 342b1b2e9b File: Handle more cases in GetOptionsFromMode
The "b" (binary) flag is meaningless most of the time, but the relevant
standars allow it. The standards permit one to spell it both as "r+b"
and "rb+", so handle both cases.

This fixes TestFileHandle.test_binary_inout with python2.

llvm-svn: 374331
2019-10-10 12:40:27 +00:00
Aleksandr Urakov 0891366571 [Windows] Introduce a switch for the `lldb-server` mode on Windows
Summary:
This patch introduces a switch, based on the environment variable
`LLDB_USE_LLDB_SERVER`, to determine whether to use the `ProcessWindows` plugin
(the old way) or the `lldb-server` way for debugging on Windows.

Reviewers: labath, amccarth, asmith, stella.stamenova

Reviewed By: labath, amccarth

Subscribers: mstorsjo, abidh, JDevlieghere, lldb-commits, leonid.mashinskiy

Tags: #lldb

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

llvm-svn: 374325
2019-10-10 12:21:04 +00:00
Pavel Labath 44506cd7f2 TestFileHandle.py: relax exception type checks
the exceptions returned differ between swig4 (TypeError) and swig<=3
(NotImplementedError). Just check for the base Exception class instead.

Theoretically we could switch on the swig version and expect the precise
type directly, but checking the exact type does not seem that important.

Thanks to Raphael for helping me figure this out.

llvm-svn: 374322
2019-10-10 12:07:30 +00:00
Raphael Isemann 95e264fc8a [lldb][NFC] Remove strange bool parameter from Searcher::SearchCallback
Summary:
The SearchCallback has a bool parameter that we always set to false, we never use in any callback implementation and that also changes its name
from one file to the other (either `containing` and `complete`). It was added in the original LLDB check in, so there isn't any history what
this was supposed to be, so let's just remove it.

Reviewers: jingham, JDevlieghere, labath

Reviewed By: jingham, labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374313
2019-10-10 11:26:51 +00:00
Raphael Isemann 067bb1f546 [lldb] Fix out of bounds read in DataExtractor::GetCStr and add unit test that function.
Summary:
The `if (*cstr_end == '\0')` in the previous code checked if the previous loop terminated because it
found a null terminator or because it reached the end of the data. However, in the case that we hit
the end of the data before finding a null terminator, `cstr_end` points behind the last byte in our
data and `*cstr_end` reads the memory behind the array (which may be uninitialised)

This patch just rewrites that function use `std::find` and adds the relevant unit tests.

Reviewers: labath

Reviewed By: labath

Subscribers: abidh, JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 374311
2019-10-10 11:15:38 +00:00
Raphael Isemann 186f1c58c5 [lldb][NFC] Use llvm::all_of instead of std::all_of in CppModuleConfiguration
llvm-svn: 374307
2019-10-10 10:56:12 +00:00
Pavel Labath c92a75fec0 s/@expectedFailure/@expectedFailureAll in TestFileHandle
The test isn't using @expectedFailure correctly, which causes weird
errors, at least with python2, at least with linux. Possibly that
function shouldn't even be public as it's main use is as a backed for
other decorators.

llvm-svn: 374299
2019-10-10 09:52:32 +00:00
Raphael Isemann 7c47b4a113 [lldb][NFC] Use unique_ptr in DiagnosticManager to express ownership
llvm-svn: 374289
2019-10-10 08:30:10 +00:00
Jason Molenda d6e9e99cec Change debugserver to use the brk #0 for breakpoints.
debugserver had been using an instruction that would work
for armv7 or aarch64 processes, but we don't have armv7 code
running on arm64 devices any more so this is unnecessary.

<rdar://problem/56133118>

llvm-svn: 374264
2019-10-10 00:12:05 +00:00
Frederic Riss 80b080723f TestMTCSimple.py: allow the test to run on Darwin embedded platforms
The test needed some updates to run using a different UI toolkit
and with a different libMTC, but it should run fine on a device.

llvm-svn: 374262
2019-10-09 23:52:31 +00:00
Frederic Riss adc5043fa2 TestIndirectSymbols: Modernize the Makefile
This old test used a completely hand-rolled Makefile. Modernize so that
it's able to cross-compile. And XFAIL the test as it fails on embedded
targets...

llvm-svn: 374256
2019-10-09 22:47:28 +00:00
Frederic Riss 0e891bcf79 Makefile.rules: add missing CODESIGN call
When building an executable and a shared library at the same time (yes,
Makefile.rules is setup to do this!) the executable was not codesigned.

llvm-svn: 374251
2019-10-09 22:35:56 +00:00
Haibo Huang 1a50941771 [lldb] Put site-packages into a sub dir of CMAKE_CFG_INTDIR
Summary: Fixes issue like D68719

Reviewers: tatyana-krasnukha

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 374250
2019-10-09 22:34:55 +00:00
Greg Clayton dc9276b7d7 Set eRegisterKindEHFrame register numbers for 32 bit ARM register contexts in minidumps
Stack unwinding was sometimes failing when trying to unwind stacks in 32 bit ARM. I discovered this was because the EH frame register numbers were not set. This patch fixes this issue and adds a unit test to verify this doesn't regress.

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

llvm-svn: 374246
2019-10-09 22:16:12 +00:00
Jonas Devlieghere f204914fee [CMake] Use the correct lit.cfg.py
llvm-svn: 374244
2019-10-09 22:09:57 +00:00
Greg Clayton 0156be59b4 Fix a crasher due to an assert when two files have the same UUID but different paths.
Summary: The PlaceholderObjectFile has an assert in SetLoadAddress that fires if "m_base == value" is not true. To avoid this, we create check that the base address matches, and if it doesn't we clear the module that was found using the UUID so that we create a new PlaceholderObjectFile. Added a test to cover this issue.

Reviewers: labath, aadsm, dvlahovski

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374242
2019-10-09 22:03:15 +00:00
Lawrence D'Anna 5da2bc22ba remove a smattering of isolated, unnecessary uses of FILE*
Summary:
There a a few call sites that use FILE* which are easy to
fix without disrupting anything else.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: JDevlieghere, labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374239
2019-10-09 21:50:52 +00:00
Lawrence D'Anna 9eb1371923 SBFile support in SBCommandReturnObject
Summary:
This patch add SBFile interfaces to SBCommandReturnObject, and
removes the internal callers of its FILE* interfaces.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374238
2019-10-09 21:50:49 +00:00
Lawrence D'Anna b24022cd72 SBFile: add a bunch of tests that should eventually work.
Summary:
It's really annoying and confusing to have to keep referring
back to earlier versions of this SBFile work to find the
tests that need to be added for each patch, and not duplicate
them with new tests.

This patch just imports all my tests.   A bunch of them don't
work yet, so they are marked to be skipped.   They'll be
unmarked as I fix them.

One of these tests will actually trip an assert in the SWIG
code now instead of just failing, so I'm fixing that here too.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: JDevlieghere, labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374237
2019-10-09 21:50:46 +00:00
Jonas Devlieghere 865cd0932f [Reproducer] Add convenience methods IsCapturing and IsReplaying.
Add convenience methods to the Reproducer class for when you don't need
access to the generator and the loader.

llvm-svn: 374236
2019-10-09 21:47:49 +00:00
Frederic Riss ffb26d9c78 TestHelloWorld: Make compatible with remote testing
The synchronization token handling was not remote-friendly.

llvm-svn: 374234
2019-10-09 21:41:02 +00:00
Cameron Desrochers 745e57c593 [LLDB] Fix for regression of test 'TestDataFormatterInvalidStdUniquePtr.py' introduced in r374195
Differential Revision: https://reviews.llvm.org/D68641

llvm-svn: 374231
2019-10-09 21:15:48 +00:00
Jonas Devlieghere 988ad41948 [LLDB] Remove standalone build dep on llvm-strip
When building standalone, since llvm-strip is a symlink, it is created
using add_custom_command/add_custom_target which cannot be exported, and
thus cannot be depended on by lldb.

Patch by: Gwen Mittertreiner

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

llvm-svn: 374229
2019-10-09 21:06:03 +00:00
Jim Ingham c0da1282fc Revert "[lldb] Calculate relative path for symbol links"
This reverts commit 958091c209.

This commit incorrectly sets the _lldb.so symlink (at least it does when
building in Stefans' two build directory mode, where you build llvm with
cmake/ninja and lldb with cmake/Xcode, using a cmake generated project.

The _lldb.so link is SUPPOSED to point to:

bin/LLDB.framework/Versions/A/LLDB

but instead it points to

bin/LLDB

which is where LLDB was staged to before constructing the framework.  This
causes all sorts of problems when we then build the lldb driver into bin -
remember that MacOS is a case-preserving but case insensitive filesystem -
so when we later go to dlopen _lldb.so, we dlopen the main executable instead.

llvm-svn: 374226
2019-10-09 20:56:43 +00:00
Lawrence D'Anna 21b8a8ae27 allow arbitrary python streams to be converted to SBFile
Summary:
This patch adds SWIG typemaps that can convert arbitrary python
file objects into lldb_private::File.

A SBFile may be initialized from a python file using the
constructor.   There are also alternate, tagged constructors
that allow python files to be borrowed, and for the caller
to control whether or not the python I/O methods will be
called even when a file descriptor is available.I

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: zturner, amccarth, lldb-commits

Tags: #lldb

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

llvm-svn: 374225
2019-10-09 20:56:17 +00:00
Frederic Riss 868b47fcbe Skip Apple simulator test for all remote testing scenarios.
The test makes no sense to run remotely, period. The architecture of
the target is not the discriminant here.

llvm-svn: 374217
2019-10-09 20:39:04 +00:00
Jonas Devlieghere d61ef7c46d [CMake] Fix add_lldb_test_dependency
This function would ignore all but the first argument. Now it correctly
adds every dependency by iterating over its arguments.

llvm-svn: 374216
2019-10-09 20:36:29 +00:00
Jonas Devlieghere be1c290226 [utils] Update lldb-dotest for new test layout
The path to dotest.py changed after the test directory reorganization.

llvm-svn: 374215
2019-10-09 20:30:54 +00:00
Vedant Kumar c7cfa7c34e [test] Skip entry value test when clang < 10.0.0
clang-9 emitted the wrong opcode for entry values on Darwin.

rdar://56119661

llvm-svn: 374212
2019-10-09 20:21:33 +00:00
Jonas Devlieghere 87aa9c9e4d Re-land "[test] Split LLDB tests into API, Shell & Unit"
The original patch got reverted because it broke `check-lldb` on a clean
build. This fixes that.

llvm-svn: 374201
2019-10-09 19:22:02 +00:00
Lawrence D'Anna 609010d063 protect libedit and LLDB gui from receiving null FILE* streams
Summary:
We now have valid files that will return NULL from GetStream().
libedit and the LLDB gui are the only places left that need FILE*
streams.  Both are doing curses-like user interaction that only
make sense with a real terminal anyway, so there is no need to convert
them off of their use of FILE*.   But we should check for null streams
before enabling these features.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: JDevlieghere, labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374197
2019-10-09 18:43:03 +00:00
Cameron Desrochers 89386daa95 [LLDB] Fix for synthetic children memory leak
The lifetime of a ValueObject and all its derivative ValueObjects (children, clones, etc.) is managed by a ClusterManager. These objects are only destroyed when every shared pointer to any of the managed objects in the cluster is destroyed. This means that no object in the cluster can store a shared pointer to another object in the cluster without creating a memory leak of the entire cluster. However, some of the synthetic children front-end implementations do exactly this; this patch fixes that.

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

llvm-svn: 374195
2019-10-09 18:27:33 +00:00
Antonio Afonso 70aa6fb6e3 Update breakpad lit test to be independent of the unnamed symbol number
llvm-svn: 374192
2019-10-09 18:02:59 +00:00
Adrian Prantl 0115c10328 Revert [test] Split LLDB tests into API, Shell & Unit
as it appears to have broken check-lldb.

This reverts r374184 (git commit 22314179f0)

llvm-svn: 374187
2019-10-09 17:35:43 +00:00
Adrian Prantl f98606f177 Remove obsolete parameter.
llvm-svn: 374185
2019-10-09 16:55:27 +00:00
Jonas Devlieghere 22314179f0 [test] Split LLDB tests into API, Shell & Unit
LLDB has three major testing strategies: unit tests, tests that exercise
the SB API though dotest.py and what we currently call lit tests. The
later is rather confusing as we're now using lit as the driver for all
three types of tests. As most of this grew organically, the directory
structure in the LLDB repository doesn't really make this clear.

The 'lit' tests are part of the root and among these tests there's a
Unit and Suite folder for the unit and dotest-tests. This layout makes
it impossible to run just the lit tests.

This patch changes the directory layout to match the 3 testing
strategies, each with their own directory and their own configuration
file. This means there are now 3 directories under lit with 3
corresponding targets:

 - API (check-lldb-api): Test exercising the SB API.
 - Shell (check-lldb-shell): Test exercising command line utilities.
 - Unit (check-lldb-unit): Unit tests.

Finally, there's still the `check-lldb` target that runs all three test
suites.

Finally, this also renames the lit folder to `test` to match the LLVM
repository layout.

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

llvm-svn: 374184
2019-10-09 16:38:47 +00:00
Adrian Prantl 939411c1aa Remove the is_mangled flag from Mangled and Symbol
Testing whether a name is mangled or not is extremely cheap and can be
done by looking at the first two characters. Mangled knows how to do
it. On the flip side, many call sites that currently pass in an
is_mangled determination do not know how to correctly do it (for
example, they leave out Swift mangling prefixes).

This patch removes this entry point and just forced Mangled to
determine the mangledness of a string itself.

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

llvm-svn: 374180
2019-10-09 16:22:14 +00:00
Hans Wennborg 1e1e3ba252 Unify the two CRC implementations
David added the JamCRC implementation in r246590. More recently, Eugene
added a CRC-32 implementation in r357901, which falls back to zlib's
crc32 function if present.

These checksums are essentially the same, so having multiple
implementations seems unnecessary. This replaces the CRC-32
implementation with the simpler one from JamCRC, and implements the
JamCRC interface in terms of CRC-32 since this means it can use zlib's
implementation when available, saving a few bytes and potentially making
it faster.

JamCRC took an ArrayRef<char> argument, and CRC-32 took a StringRef.
This patch changes it to ArrayRef<uint8_t> which I think is the best
choice, and simplifies a few of the callers nicely.

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

llvm-svn: 374148
2019-10-09 09:06:30 +00:00
Raphael Isemann 4e969da33e [lldb] Don't crash when the ASTImporter produces diagnostics but instead log them.
When playing with the C++ module prototype I noticed I can get LLDB to crash
by making a result type that depends on __make_integer_seq (a BuiltinTemplate)
which is not supported by the ASTImporter yet. This causes the ASTImporter to emit
a diagnostic when copying the type to the ScratchASTContext. As deporting the result
type is done after we are done parsing and the Clang's diagnostic engine asserts that
it can only be used during parsing, it crashes LLDB while trying to render the diagnostic
in the HandleDiagnostic method of ClangDiagnosticManagerAdapter.

This patch just moves the HandleDiagnostic call to Clang behind our check that we still
have a DiagnosticManager (which we remove after parsing) which prevents the assert
from firing. We also shouldn't ignore such diagnostics, so I added a log statement for
them.

There doesn't seem to way to test this as these diagnostic only happen when we copy
a node that's not supported by the ASTImporter which should never happen once
we can copy everything with the ASTImporter, so every test case we add here will
eventually become invalid.

(Note that most of this diff is just whitespace changes as we now use an early exit
instead of a huge 'if' block).

llvm-svn: 374145
2019-10-09 08:30:06 +00:00
Antonio Afonso ad6690afa3 Explicitly set entry point arch when it's thumb [Second Try]
Summary:
This is a redo of D68069 because I reverted it due to some concerns that were now addressed along with the new comments that @labath added.

I found a case where the main android binary (app_process32) had thumb code at its entry point but no entry in the symbol table indicating this. This made lldb set a 4 byte breakpoint at that address (we default to arm code) instead of a 2 byte one (like we should for thumb).
The big deal with this is that the expression evaluator uses the entry point as a way to know when a JITed expression has finished executing by putting a breakpoint there. Because of this, evaluating expressions on certain android devices (Google Pixel something) made the process crash.
This was fixed by checking this specific situation when we parse the symbol table and add an artificial symbol for this 2 byte range and indicating that it's arm thumb.

I created 2 unit tests for this, one to check that now we know that the entry point is arm thumb, and the other to make sure we didn't change the behaviour for arm code.

I also run the following on the command line with the `app_process32` where I found the issue:
**Before:**
```
(lldb) dis -s 0x1640 -e 0x1644
app_process32[0x1640]: .long  0xf0004668                ; unknown opcode
```
**After:**
```
(lldb) dis -s 0x1640 -e 0x1644
app_process32`:
app_process32[0x1640] <+0>: mov    r0, sp
app_process32[0x1642]:      andeq  r0, r0, r0
```

Reviewers: clayborg, labath, wallace, espindola

Reviewed By: labath

Subscribers: labath, lldb-commits, MaskRay, kristof.beyls, arichardson, emaste, srhines

Tags: #lldb

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

llvm-svn: 374132
2019-10-08 23:44:49 +00:00
Adrian Prantl 35b63a435c Revert Trust the arange accelerator tables in dSYMs
This reverts r374117 (git commit 6399db2f6f)
while inspecting bot breakage.

llvm-svn: 374121
2019-10-08 21:34:22 +00:00
Adrian Prantl 6399db2f6f Trust the arange accelerator tables in dSYMs
When ingesting aranges from a dSYM it makes sense to always trust the
contents of the accelerator table since it always comes from
dsymutil. According to Instruments, skipping the decoding of all CU
DIEs to get at the DW_AT_ranges attribute removes ~3.5 seconds from
setting a breakpoint by file/line when debugging clang with a
dSYM. Interestingly on the wall clock the speedup is less noticeable,
but still present.

rdar://problem/56057688

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

llvm-svn: 374117
2019-10-08 21:14:36 +00:00
Vedant Kumar 4805c817c3 StopInfo/Mach: Delete PPC support
LLDB appears to have at least partial support for PPC, but PPC on Mach
isn't a thing AFAIK.

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

llvm-svn: 374114
2019-10-08 20:47:44 +00:00
Frederic Riss b56e3a1723 Add test coverage to printing of enums and fix display of unsigned values
TestCPP11EnumTypes.py should have covered all our bases when it comes
to typed enums, but it missed the regression introduced in r374066.
The reason it didn't catch it is somewhat funny: the test was copied
over from another test that recompiled a source file with a different
base type every time, but neither the test source nor the python code
was adapted for testing enums. As a result, this test was just running
8 times the exact same checks on the exact same binary.

This commit fixes the coverage and addresses the issue revealed by
the new tests.

llvm-svn: 374108
2019-10-08 19:52:01 +00:00
Vedant Kumar 07c5f2a9b0 StopInfo/Mach: Use early-exits, reflow messy comments, NFCI
llvm-svn: 374106
2019-10-08 19:40:13 +00:00
Jonas Devlieghere b328dcbf85 [Reproducer] Don't isntrument methods that get called from the signal handler.
LLDB's signal handlers call SBDebugger methods, which themselves try to
be really careful about not doing anything non-signal safe. The
Reproducer record macro is not careful though, and does unsafe things
which potentially caused LLDB to crash. Given that these methods are not
particularly interesting I've swapped the RECORD macros with DUMMY ones,
so that we still register the API boundary but don't do anything
non-signal safe.

Thanks Jim for figuring this one out!

llvm-svn: 374104
2019-10-08 19:17:42 +00:00
Alex Langford 28fcc033c8 [CMake] Fix building without python on Windows
Summary: find_python_libs_windows might set LLDB_DISABLE_PYTHON to ON.
Unfortunately we do not re-check this variable before using variables filled in
by find_python_libs_windows, leading to a failed configuration.

llvm-svn: 374100
2019-10-08 18:38:46 +00:00
Adrian Prantl 065d34dbe1 Reflow/fix doxygen comments.
llvm-svn: 374096
2019-10-08 18:04:49 +00:00
Frederic Riss 5d415b706f Fix sign extension handling in DumpEnumValue
When an enumerator has an unsigned type and its high bit set, the
code introduced in r374067 would fail to match it due to a sign
extension snafu. This commit fixes this aspec of the code and should
fix the bots.

I think it's not a complete fix though, I'll add more test coverage
and additional tweaks in a follow-up commit.

llvm-svn: 374095
2019-10-08 17:59:02 +00:00
Lawrence D'Anna 085328eeee exception handling in PythonDataObjects.
Summary:
Python APIs nearly all can return an exception.   They do this
by returning NULL, or -1, or some such value and setting
the exception state with PyErr_Set*().   Exceptions must be
handled before further python API functions are called.   Failure
to do so will result in asserts on debug builds of python.
It will also sometimes, but not usually result in crashes of
release builds.

Nearly everything in PythonDataObjects.h needs to be updated
to account for this.   This patch doesn't fix everything,
but it does introduce some new methods using Expected<>
return types that are safe to use.

split off from https://reviews.llvm.org/D68188

Reviewers: JDevlieghere, jasonmolenda, labath, zturner

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374094
2019-10-08 17:56:18 +00:00
Adrian Prantl 8db229e287 ObjectFileMachO: Replace std::map with llvm::DenseMap (NFC)
This makes parsing the symbol table of clang marginally faster. (Hashtable versus tree).

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

llvm-svn: 374084
2019-10-08 16:59:24 +00:00
Adrian Prantl ea63775054 Replace regex match with rfind (NFCish)
This change is mostly performance-neutral since our regex engine is
fast, but it's IMHO slightly more readable.  Also, matching matching
parenthesis is not a great match for regular expressions.

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

llvm-svn: 374082
2019-10-08 16:29:39 +00:00
Adrian Prantl 917b8df0e5 Replace static const StringRef with StringRef (NFC)
Differential Revision: https://reviews.llvm.org/D68597

llvm-svn: 374081
2019-10-08 16:29:36 +00:00
Adrian Prantl bde5a6a45a Remove constructor and unused method (NFC).
Differential Revision: https://reviews.llvm.org/D68595

llvm-svn: 374080
2019-10-08 16:29:33 +00:00
Shafik Yaghmour 02376077be Revert "[platform process list] add a flag for showing the processes of all users"
This reverts commit 080f35fb875f52c924ee37ed4d56a51fe7056afa.

 Conflicts:
	packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestPlatformClient.py

llvm-svn: 374077
2019-10-08 16:24:28 +00:00
Frederic Riss 3fb4e49a68 [Testsuite] Get rid of most of the recursive shared library Makefiles
Most of the secondary Makefiles we have are just a couple variable
definitions and then an include of Makefile.rules. This patch removes
most of the secondary Makefiles and replaces them with a direct
invocation of Makefile.rules in the main Makefile. The specificities
of each sub-build are listed right there on the recursive $(MAKE)
call. All the variables that matter are being passed automagically by
make as they have been passed on the command line. The only things you
need to specify are the variables customizating the Makefile.rules
logic for each image.

This patch also removes most of the clean logic from those Makefiles
and from Makefile.rules. The clean rule is not required anymore now
that we run the testsuite in a separate build directory that is wiped
with each run. The patch leaves a very crude version of clean in
Makefile.rules which removes everything inside of $(BUILDDIR). It does
this only when the $(BUILDDIR) looks like a sub-directory of our
standard testsuite build directory to be extra safe.

Reviewers: aprantl, labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374076
2019-10-08 16:23:28 +00:00
Konrad Kleine 6d7fb29914 [lldb] Avoid resource leak
Summary:
Before the pointer variable `args_dict` was assigned the result of an
allocation with `new` and then `args_dict` is passed to
`GetValueForKeyAsDictionary` which immediatly and unconditionally
assigns `args_dict` to `nullptr`:

```
    bool GetValueForKeyAsDictionary(llvm::StringRef key,
                                    Dictionary *&result) const {
      result = nullptr;
```

This caused a memory leak which was found in my coverity scan instance
under CID 224753: https://scan.coverity.com/projects/kwk-llvm-project.

Reviewers: jankratochvil, teemperor

Reviewed By: teemperor

Subscribers: teemperor, lldb-commits

Tags: #lldb

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

llvm-svn: 374071
2019-10-08 15:56:02 +00:00
Konrad Kleine 8970d88b65 Simplify LZMA decoding by using ArrayRef::take_back
Summary: Follow-up for D66791#inline-616303

Reviewers: labath

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374069
2019-10-08 15:43:29 +00:00
Frederic Riss 41ff39605e Add pretty printing of Clang "bitfield" enums
Summary:
Using enumerators as flags is standard practice. This patch adds
support to LLDB to display such enum values symbolically, eg:

(E) e1 = A | B

If enumerators don't cover the whole value, the remaining bits are
displayed as hexadecimal:

(E) e4 = A | 0x10

Detecting whether an enum is used as a bitfield or not is
complicated. This patch implements a heuristic that assumes that such
enumerators will either have only 1 bit set or will be a combination
of previous values.

This patch doesn't change the way we currently display enums which the
above heuristic would not consider as bitfields.

Reviewers: jingham, labath

Subscribers: lldb-commits

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

llvm-svn: 374067
2019-10-08 15:35:59 +00:00
Frederic Riss d6470fb01a Extract and simplify DumpEnumValue
llvm-svn: 374066
2019-10-08 15:35:58 +00:00
Pavel Labath 9a44ab7763 Tweak minidebuginfo-set-and-hit-breakpoint.test
On my system, llvm-objcopy was refusing to remove the .dynsym section
because it was still referenced from .rela.plt. Remove that section too,
and clarify that this is needed only because llvm-objcopy
--only-keep-debug does not work (does not set the sections to
SHT_NOBITS). Also, ensure that the test is not creating temporary files
in the source tree.

llvm-svn: 374046
2019-10-08 13:51:05 +00:00
Pavel Labath c41294705b Revert "[lldb-server/android] Show more processes and package name when necessary"
This reverts r373758 because it causes several to test to be flaky (=
failing ~90% of the time) on linux.

llvm-svn: 374030
2019-10-08 09:05:31 +00:00
Pavel Labath 07932b1088 Fix a -Wpedantic warning
namespace-closing '}' don't need ';'.

llvm-svn: 374029
2019-10-08 09:05:25 +00:00
Jonas Devlieghere e21399b02e Revert "ProcessInstanceInfoMatch: Don't match processes with no name if a name match was requested"
This breaks TestProcessAttach and TestHelloWorld on Darwin.

llvm-svn: 374008
2019-10-08 01:16:59 +00:00
Lawrence D'Anna 68491f5072 test fix: TestLoadUsingPaths should use realpath
Summary:
TestLoadUsingPaths will fail if the build directory has
symlinks in its path, because the real paths reported by
the debugger won't match the symlink-laden paths it's expecting.

This can be solved just by using os.path.realpath on the base
path for the test.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374007
2019-10-08 01:16:29 +00:00
Antonio Afonso ffc67f9251 Fixing missing lldb-scripts rename from D68370
llvm-svn: 374005
2019-10-08 01:10:03 +00:00
Jonas Devlieghere ce3314cf28 [CMake] Add two more uses of add_lldb_test_dependency
llvm-svn: 374000
2019-10-08 00:44:54 +00:00
Haibo Huang 0016b450be [lldb] Reverts part of 61f471a
Seems I wrongly merged an old patch.

Reverts the change related to python dir for windows.

FileSpec should always contain normalized path. I.e. using '/' even in
windows.

llvm-svn: 373998
2019-10-08 00:33:26 +00:00
Lawrence D'Anna 5d10e417e9 DWIMy filterspecs for dotest.py
Summary:
dotest.py currently requires a filterspec to be of the
form `TestCase.test_method`.   This patch makes it more
flexible, so you can pass `TestModule.TestCase.test_method`
or `TestModule.TestCase` or `TestCase.test_method` or just
`test_method`.

This makes it more convenient to just copy a test name
out of the terminal after running a bunch of tests and use
it as a filterspec.

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: JDevlieghere

Subscribers: jingham, lldb-commits

Tags: #lldb

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

llvm-svn: 373997
2019-10-08 00:26:53 +00:00
Jonas Devlieghere 37cf39df20 [CMake] Track test dependencies with add_lldb_test_dependency
I often use `ninja lldb-test-deps` to build all the test dependencies
before running a subset of the tests with `lit --filter`. This
functionality seems to break relatively often because test dependencies
are tracked in an ad-hoc way acrooss cmake files. This patch adds a
helper function `add_lldb_test_dependency` to unify test dependency
tracking by adding dependencies to lldb-test-deps.

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

llvm-svn: 373996
2019-10-08 00:21:34 +00:00
Jonas Devlieghere 6f23e5f6d5 [CMake] Remove stale comment
llvm-svn: 373995
2019-10-08 00:14:02 +00:00
Jonas Devlieghere 4bddca306a [MachO] Fix symbol merging during symtab parsing.
The symtab parser in ObjectFileMachO has logic to coalesce debug (STAB)
and non-debug symbols, based on the address and the symbol name for
static (STSYM) and global symbols (GSYM) respectively. It makes the
assumption that the debug variant is always encountered first. Rather
than creating a second entry in the symbol table for the non-debug
symbol, the latter gets merged into the existing debug symbol.

This breaks when the linker emits the non-debug symbol first. We'd end
up with two entries in the symbol table, each containing part of the
information LLDB relies on. Indeed, commenting out the merging logic
breaks the test suite spectacularly.

This patch solves that problem by always parsing the debug symbols
first. This guarantees that the assumption for merging holds.

I'm not particularly happy with  adding a lambda, but after numerous
attempts this is the best solution I could come up with. The symtab
parsing logic is pretty complex in that it touches a lot of things. I've
experienced first hand that it's very easy to break things. I believe
this approach strikes a balance between fixing the issue while limiting
the risk of regressions.

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

llvm-svn: 373994
2019-10-08 00:13:59 +00:00
Haibo Huang 61f471a705 [lldb] Unifying lldb python path
Based on mgorny@'s D67890

There are 3 places where python site-package path is calculated
independently:

1. finishSwigPythonLLDB.py where files are written to site-packages.

2. lldb/scripts/CMakeLists.txt where site-packages are installed.

3. ScriptInterpreterPython.cpp where site-packages are added to
PYTHONPATH.

This change creates the path once and use it everywhere. So that they
will not go out of sync.

Also it provides a chance for cross compiling users to specify the right
path for site-packages.

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 373991
2019-10-07 23:49:01 +00:00
Alex Langford f4c7345b88 [Symbol] Remove unused method ClangASTContext::GetObjCClassName
llvm-svn: 373990
2019-10-07 23:43:33 +00:00
Davide Italiano 33f054a316 [CMake] We only want to copy the headers for macOS.
<rdar://problem/55916729>

llvm-svn: 373970
2019-10-07 21:38:30 +00:00
Adrian Prantl 69a3b21a5c Mark constructor as default and remove implementation (NFC)
llvm-svn: 373968
2019-10-07 21:23:19 +00:00
Davide Italiano 2b371fbedd [debugserver] Include the correct header.
<rdar://problem/55916729>

llvm-svn: 373957
2019-10-07 20:35:22 +00:00
Jonas Devlieghere 4db091754b [test] Rename `Modules` to `ObjectFile` (NFC)
llvm-svn: 373955
2019-10-07 20:31:28 +00:00
Jonas Devlieghere 369407fc52 [MachO] Shuffle some things around in ParseSymtab (NFC)
llvm-svn: 373954
2019-10-07 20:31:22 +00:00
Walter Erquinigo 8b6dcc1d8c [gdb-remote] process properly effective uid
Summary:
Someone wrote SetEffectiveSetEffectiveGroupID instead of SetEffectiveUserID.

After this fix, the android process list can show user names, e.g.

```
PID    PARENT USER       GROUP      EFF USER   EFF GROUP  TRIPLE                               ARGUMENTS
====== ====== ========== ========== ========== ========== ============================== ============================
529    1      root       0          root       0                                         /sbin/ueventd
```
Reviewers: labath,clayborg,aadsm,xiaobai

Subscribers:

llvm-svn: 373953
2019-10-07 20:26:49 +00:00
Walter Erquinigo 6e1a0cf46b [platform process list] add a flag for showing the processes of all users
Summary:
For context: https://reviews.llvm.org/D68293

We need a way to show all the processes on android regardless of the user id.
When you run `platform process list`, you only see the processes with the same user as the user that launched lldb-server. However, it's quite useful to see all the processes, though, and it will lay a foundation for full apk debugging support from lldb.

Before:
```
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
3234   1                 aarch64-unknown-linux-android adbd
8034   3234              aarch64-unknown-linux-android sh
9096   3234              aarch64-unknown-linux-android sh
9098   9096              aarch64-unknown-linux-android lldb-server
(lldb) ^D
```

Now:
```
(lldb) platform process list -x
205 matching processes were found on "remote-android"
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
1      0                                          init
524    1                                          init
525    1                                          init
531    1                                          ueventd
568    1                                          logd
569    1                 aarch64-unknown-linux-android servicemanager
570    1                 aarch64-unknown-linux-android hwservicemanager
571    1                 aarch64-unknown-linux-android vndservicemanager
577    1                 aarch64-unknown-linux-android qseecomd
580    577               aarch64-unknown-linux-android qseecomd
...
23816  979                                        com.android.providers.calendar
24600  979                                        com.verizon.mips.services
27888  979                                        com.hualai
28043  2378                                       com.android.chrome:sandboxed_process0
31449  979                                        com.att.shm
31779  979                                        com.samsung.android.authfw
31846  979                                        com.samsung.android.server.iris
32014  979                                        com.samsung.android.MtpApplication
32045  979                                        com.samsung.InputEventApp
```

Reviewers: labath,xiaobai,aadsm,clayborg

Subscribers:

llvm-svn: 373931
2019-10-07 17:49:32 +00:00
Vedant Kumar 40a1853c49 [DWARFASTParserClang] Factor out structure-like type parsing, NFC
Split out the logic to parse structure-like types into a separate
function, in an attempt to reduce the complexity of ParseTypeFromDWARF.

Inspired by discussion in https://reviews.llvm.org/D68130.

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

llvm-svn: 373927
2019-10-07 17:22:53 +00:00
Vedant Kumar fccfe2c04a [DWARFASTParserClang] Delete commented-out typedef, NFC
(& group together all the protected members & typedefs)

llvm-svn: 373926
2019-10-07 17:22:50 +00:00
Pavel Labath f7bd5bffed ProcessInstanceInfoMatch: Don't match processes with no name if a name match was requested
Since D68289, a couple of tests on linux started being extremely flaky.
All of them were doing name-based attaching and were failing because
they couldn't find an unambiguous process to attach to.

The patch above changed the process finding logic, so that failure to
find a process name does not constitute an error. This meant that a lot
more transient processes showed up in the process list during the test
suite run. Previously, these processes would not appear as they would be
gone by the time we went to read their executable name, arguments, etc.

Now, this alone should not cause an issue were it not for the fact that
we were considering a process with no name as if it matched by default
(even if we were explicitly searching for a process with a specified
name). This meant that any of the "transient" processes with no name
would make the name match ambiguous. That clearly seems like a bug to me
so I fix that.

llvm-svn: 373925
2019-10-07 17:17:53 +00:00
Konrad Kleine 2c082b4827 [lldb][ELF] Read symbols from .gnu_debugdata sect.
Summary:
If the .symtab section is stripped from the binary it might be that
there's a .gnu_debugdata section which contains a smaller .symtab in
order to provide enough information to create a backtrace with function
names or to set and hit a breakpoint on a function name.

This change looks for a .gnu_debugdata section in the ELF object file.
The .gnu_debugdata section contains a xz-compressed ELF file with a
.symtab section inside. Symbols from that compressed .symtab section
are merged with the main object file's .dynsym symbols (if any).
In addition we always load the .dynsym even if there's a .symtab
section.

For example, the Fedora and RHEL operating systems strip their binaries
but keep a .gnu_debugdata section. While gdb already can read this
section, LLDB until this patch couldn't. To test this patch on a
Fedora or RHEL operating system, try to set a breakpoint on the "help"
symbol in the "zip" binary. Before this patch, only GDB can set this
breakpoint; now LLDB also can do so without installing extra debug
symbols:

    lldb /usr/bin/zip -b -o "b help" -o "r" -o "bt" -- -h

The above line runs LLDB in batch mode and on the "/usr/bin/zip -h"
target:

    (lldb) target create "/usr/bin/zip"
    Current executable set to '/usr/bin/zip' (x86_64).
    (lldb) settings set -- target.run-args  "-h"

Before the program starts, we set a breakpoint on the "help" symbol:

    (lldb) b help
    Breakpoint 1: where = zip`help, address = 0x00000000004093b0

Once the program is run and has hit the breakpoint we ask for a
backtrace:

    (lldb) r
    Process 10073 stopped
    * thread #1, name = 'zip', stop reason = breakpoint 1.1
        frame #0: 0x00000000004093b0 zip`help
    zip`help:
    ->  0x4093b0 <+0>:  pushq  %r12
        0x4093b2 <+2>:  movq   0x2af5f(%rip), %rsi       ;  + 4056
        0x4093b9 <+9>:  movl   $0x1, %edi
        0x4093be <+14>: xorl   %eax, %eax

    Process 10073 launched: '/usr/bin/zip' (x86_64)
    (lldb) bt
    * thread #1, name = 'zip', stop reason = breakpoint 1.1
      * frame #0: 0x00000000004093b0 zip`help
        frame #1: 0x0000000000403970 zip`main + 3248
        frame #2: 0x00007ffff7d8bf33 libc.so.6`__libc_start_main + 243
        frame #3: 0x0000000000408cee zip`_start + 46

In order to support the .gnu_debugdata section, one has to have LZMA
development headers installed. The CMake section, that controls this
part looks for the LZMA headers and enables .gnu_debugdata support by
default if they are found; otherwise or if explicitly requested, the
minidebuginfo support is disabled.

GDB supports the "mini debuginfo" section .gnu_debugdata since v7.6
(2013).

Reviewers: espindola, labath, jankratochvil, alexshap

Reviewed By: labath

Subscribers: rnkovacs, wuzish, shafik, emaste, mgorny, arichardson, hiraditya, MaskRay, lldb-commits

Tags: #lldb, #llvm

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

llvm-svn: 373891
2019-10-07 10:32:16 +00:00
Sylvestre Ledru 68f58a75a7 Do not install lit-cpuid
Summary:
AFAIK, lit-cpuid is used by the tests. 
Installing it causes LLVMExports*.cmake files to depend
on this program.
It causes some serious packaging issues as it would means
that llvm-dev depends on lldb.

See:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=941082
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=941306

See also https://bugs.llvm.org/show_bug.cgi?id=43035
for a similar issue caused by
https://reviews.llvm.org/D56606

Reviewers: mgorny

Reviewed By: mgorny

Subscribers: delcypher, lldb-commits

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

llvm-svn: 373819
2019-10-05 08:22:40 +00:00
Jonas Devlieghere 4e5d9e120b [MachO] Reduce indentation further in ParseSymtab (NFC)
llvm-svn: 373810
2019-10-04 23:09:55 +00:00
Jonas Devlieghere cd5cd7d14c [test] Run TestLaunchWithShellExpand with /bin/sh on POSIX.
Now that we do shell expansion on POSIX with the user's shel, this test
can potentially fail. This should ensure that we always use /bin/sh.

llvm-svn: 373804
2019-10-04 22:21:35 +00:00
Jonas Devlieghere 5042882698 [MachO] Move nlist parsing into helper function (NFC)
llvm-svn: 373803
2019-10-04 22:21:32 +00:00
Davide Italiano 68d01d9429 [debugserver] Don't link against Cocoa, it's not needed.
<rdar://problem/55916729>

llvm-svn: 373795
2019-10-04 21:51:35 +00:00
Jason Molenda 984d08c680 Expand on the qfProcessInfo documentation, add examples from
lldb-gdb-remote.txt and text explaining the no-criteria mode.

llvm-svn: 373789
2019-10-04 21:01:52 +00:00
Jan Kratochvil 4c7b842185 [lldb] [testsuite] Mark TestSBCommandReturnObject as failing on Windows
Filed:
	testsuite: TestSBCommandReturnObject: object has no attribute 'dylibPath'
	https://bugs.llvm.org/show_bug.cgi?id=43570

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/9530/steps/test/logs/stdio

AttributeError: 'TestSBCommandReturnObject' object has no attribute 'dylibPath'

Fix crash on SBCommandReturnObject & assignment
https://reviews.llvm.org/D67589
  env = {self.dylibPath: self.getLLDBLibraryEnvVal()}

I do not know how to link with liblldb on Windows so marking it as failing on
Windows.

llvm-svn: 373787
2019-10-04 20:49:44 +00:00
Jonas Devlieghere 2a711814b0 [Host] Return status directly from RunShellCommand
Thanks for catching this, Pavel!

llvm-svn: 373783
2019-10-04 19:54:45 +00:00
Jonas Devlieghere e973fc0056 [MachO] Add early returns to save some indentation.
This file really suffered from the Great Reformat. I'm adding a few
early returns to give the deeply nested code some more breathing room.

llvm-svn: 373778
2019-10-04 19:37:59 +00:00
Jonas Devlieghere 845292cba3 [MachO] Reformat before making changes to this file (NFC)
llvm-svn: 373777
2019-10-04 19:37:52 +00:00
Jonas Devlieghere a8c04469e5 [Host] Don't discard return value from RunShellCommand
The recent change to expand arguments with the user's shell sometimes
caused a timeout and the error was not propagated.

llvm-svn: 373776
2019-10-04 19:37:46 +00:00
Jan Kratochvil 4112b47335 [lldb] Fix crash on SBCommandReturnObject & assignment
I was writing an SB API client and it was crashing on:
	bool DoExecute(SBDebugger dbg, char **command, SBCommandReturnObject &result) {
	  result = subcommand(dbg, "help");

That is because SBCommandReturnObject &result gets initialized inside LLDB by:
	bool DoExecute(Args &command, CommandReturnObject &result) override {
	  // std::unique_ptr gets initialized here from `&result`!!!
	  SBCommandReturnObject sb_return(&result);
	  DoExecute(...);
	  sb_return.Release();

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

llvm-svn: 373775
2019-10-04 19:32:57 +00:00
Antonio Afonso f6bedd81cc Componentize lldb/scripts to use with LLVM_DISTRIBUTION_COMPONENTS
Summary:
I'd like to install lldb using the install-distribution target with LLVM_DISTRIBUTION_COMPONENTS but this is currently not possible as the lldb/scripts do not provide any component we can use and install the python scripts.
For this effect I created an lldb-python-scripts target and added the install-lldb-python-scripts llvm install target.

I tested with:
cmake ... -DLLVM_ENABLE_PROJECTS="clang;lldb" -DLLVM_DISTRIBUTION_COMPONENTS="lldb;liblldb;lldb-python-scripts" ...
DESTDIR=... ninja install-distribution

Then checked with bin/lldb -x -o 'script import lldb'

Reviewers: labath, xiaobai, clayborg, lanza

Subscribers: mgorny, lldb-commits, smeenai, wallace

Tags: #lldb

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

llvm-svn: 373768
2019-10-04 18:10:42 +00:00
Walter Erquinigo 9819b9d35f [process info] Remove assert in DoGetGroupName
Summary:
Disabling this assert prevents lldb-server from crashing, which prevents it from finding the user and group names of a given process list.

Before this change, the process list didn't contain names:

```
PID    PARENT USER       GROUP      EFF USER   EFF GROUP  TRIPLE                               ARGUMENTS
====== ====== ========== ========== ========== ========== ============================== ============================
27585  982    10098      10098      10098      10098                                     com.LogiaGroup.LogiaDeck
27623  982    10098      10098      10098      10098                                     com.digitalturbine.ignite.suspend.DataUsageRecorderService
28024  982    10199      10199      10199      10199                                     com.google.vr.vrcore
28061  983    10353      10353      10353      10353                                     com.instagram.android:videoplayer
28121  982    10045      10045      10045      10045                                     com.sec.spp.push
28325  982    10247      10247      10247      10247                                     com.facebook.orca
28714  982    10367      10367      10367      10367                                     com.samsung.android.dialer
29867  3208   2000       2000       2000       2000       aarch64-unknown-linux-android  /system/bin/sh-c /data/local/tmp/lldb-server platform --listen *:5557 --server --log-file /data/local/tmp/logs --log-channels gdb-remote all --log-channels lldb all
```

After this change, the list looks much better

```
PID    PARENT USER       GROUP      EFF USER   EFF GROUP  TRIPLE                               ARGUMENTS
====== ====== ========== ========== ========== ========== ============================== ============================
24459  1      wifi       1010       wifi       1010       aarch64-unknown-linux-android  /vendor/bin/hw/wpa_supplicant-O/data/vendor/wifi/wpa/sockets -puse_p2p_group_interface=1 -g@android:wpa_wlan0
25098  982    u0_a42     10042      u0_a42     10042                                     com.samsung.android.messaging
25442  982    u0_a65     10065      u0_a65     10065                                     com.samsung.android.mobileservice
25974  982    u0_a9      10009      u0_a9      10009                                     com.samsung.android.contacts
26377  982    radio      1001       radio      1001                                      com.samsung.android.incallui
26390  983    u0_a26     10026      u0_a26     10026                                     com.samsung.android.game.gametools
26876  983    u0_a306    10306      u0_a306    10306                                     com.tencent.mm:push
```

Reviewers: clayborg,aadsm,xiaobai,labath

Subscribers:

llvm-svn: 373760
2019-10-04 16:56:23 +00:00
Walter Erquinigo 856383555b [lldb-server/android] Show more processes and package name when necessary
Summary:
By default `platform process list` only shows the processes of the current user that lldb-server can parse.
There are several problems:
- apk programs don't have an executable file. They instead use a package name as identifier.
- each apk also runs under a different user. That's how android works
- because of the user permission, some files like /proc/<pid>/{environ,exe} can't be read.

This results in a very small process list.

This is a local run on my machine
```
(lldb) platform process list
2 matching processes were found on "remote-android"
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
23291  3177              aarch64-unknown-linux-android sh
23301  23291            aarch64-unknown-linux-android lldb-server
```
However, I have 700 processes running at this time.

By implementing a few fallbacks for android, I've expanded this list to 202, filtering out kernel processes, which would presumably appear in this list if the device was rooted.

```
(lldb) platform process list
202 matching processes were found on "remote-android"
PID    PARENT USER       TRIPLE                   NAME
====== ====== ========== ======================== ============================
...
12647  3208              aarch64-unknown-linux-android sh
12649  12647             aarch64-unknown-linux-android lldb-server
12653  982                                        com.samsung.faceservice
13185  982                                        com.samsung.vvm
15899  982                                        com.samsung.android.spay
16220  982                                        com.sec.spp.push
17126  982                                        com.sec.spp.push:RemoteDlcProcess
19772  983                                        com.android.chrome
20209  982                                        com.samsung.cmh:CMH
20380  982                                        com.google.android.inputmethod.latin
20879  982                                        com.samsung.android.oneconnect:Receiver
21212  983                                        com.tencent.mm
24459  1                 aarch64-unknown-linux-android wpa_supplicant
25974  982                                        com.samsung.android.contacts
26293  982                                        com.samsung.android.messaging
28714  982                                        com.samsung.android.dialer
31605  982                                        com.samsung.android.MtpApplication
32256  982                                        com.bezobidny
```

Something to notice is that the architecture is unkonwn for all apks. And that's fine, because run-as would be required to gather this information and that would make this entire functionality massively slow.

There are still several improvements to make here, like displaying actual user names, which I'll try to do in a following diff.

Note: Regarding overall apk debugging support from lldb. I'm planning on having lldb spawn lldb-server by itself with the correct user, so that everything works well. The initial lldb-server used for connecting to the remote platform can be reused for such purpose. Furthermore, eventually lldb could also launch that initial lldb-server on its own.

Reviewers: clayborg, aadsm, labath, xiaobai

Subscribers: srhines, krytarowski, kristof.beyls, lldb-commits

Tags: #lldb

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

llvm-svn: 373758
2019-10-04 16:35:59 +00:00
Michal Gorny 9735739be7 [lldb] [cmake] Support linking against clang-cpp dylib
Link against clang-cpp dylib rather than split libs when
CLANG_LINK_CLANG_DYLIB is enabled.

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

llvm-svn: 373734
2019-10-04 12:03:03 +00:00
Raphael Isemann baf769d322 [lldb] Get the TargetAPI lock in SBProcess::IsInstrumentationRuntimePresent
Summary:
We should get the TargetAPI lock here to prevent the process of being destroyed while we are in the function. Thanks Jim for explaining what's going on.

Fixes rdar://54424754

Reviewers: jingham

Reviewed By: jingham

Subscribers: JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 373725
2019-10-04 09:54:58 +00:00
Raphael Isemann 91ad5398d1 [lldb] Fix that 'ninja clean' breaks the build by deleting debugserver_vers.c
Summary:
We mark debugserver_vers.c as a generated file in CMake. This means that when we run `ninja clean` we end up deleting that file,
but any following `ninja` invocation will fail due to the file missing. The file can't be generated as `ninja` doesn't know it has to
rerun CMake to create the file. Turns out that marking the output of configure_file as generated is wrong as explained in this bug report:
https://gitlab.kitware.com/cmake/cmake/issues/18032

This patch just removes that property. The only side effect of this seems to be that this file maybe shows up in your IDE when
opening our CMake project, but that seems like a small sacrifice.

This patch can be quickly tested by running `ninja clean ; ninja lldbDebugserverCommon`. Before this patch the build will fail
due to debugserver_vers.c missing.

Reviewers: JDevlieghere, labath

Reviewed By: labath

Subscribers: mgorny, abidh, lldb-commits

Tags: #lldb

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

llvm-svn: 373723
2019-10-04 09:52:26 +00:00
Sam McCall f6a2086d52 [lldb] Fix -Wreorder-ctor in r373673
llvm-svn: 373721
2019-10-04 09:41:43 +00:00