Commit Graph

21196 Commits

Author SHA1 Message Date
Adrian Prantl 78586775f7 Rename ParseTypeFromDWO to ParseTypeFromClangModule (NFC)
Because that is what this function really does. The old name is
misleading.
2019-11-13 13:37:43 -08:00
Jonas Devlieghere ad882774fe [LLDB] Fix a bunch of -Wdocumentation warnings 2019-11-13 12:28:10 -08:00
Jonas Devlieghere 7ba28644a1 [Reproducer] Discard reproducer directory if not generated.
If lldb was run in capture mode, but no reproducer was generated, make
sure we clean up the reproducer directory.
2019-11-12 20:16:33 -08:00
Muhammad Omair Javaid 9b95835698 [LLDB] Add core definition for armv8l and armv7l
This patch adds core definitions in lldb ArchSpecs for armv8l and armv7l cores.

This was needed because on Linux running on 32-bit Arm v8 we are returned
armv8l in case we are running 32-bit sysroot on 64bit kernel. In case of 32-bit
kernel and 32-bit sysroot running on arm v8 hardware we are returned armv7l.
This is quite common when we run 32 bit arm using docker container.

Signed-off-by: Muhammad Omair Javaid <omair.javaid@linaro.org>

Differential Revision: https://reviews.llvm.org/D69904
2019-11-13 05:40:09 +05:00
Jonas Devlieghere 056c319769 [LLDB] Only set FRAMEWORK when we're actually building a framework. 2019-11-12 15:42:07 -08:00
Jonas Devlieghere 34ca6e1fbe [LLDB] Remove debug message in AddLLDB.cmake 2019-11-12 15:33:03 -08:00
Jonas Devlieghere a247bd1f27 [LLDB] Fix/silence CMake developer warning for LLDB framework.
This fixes the following warning for developers:

  Target 'liblldb' was changed to a FRAMEWORK sometime after install().  This
  may result in the wrong install DESTINATION.  Set the FRAMEWORK property
  earlier.

The solution is to pass the FRAMEWORK flag to add_lldb_library and set
the target property before install(). For now liblldb is the only
customer.
2019-11-12 14:17:19 -08:00
Jonas Devlieghere fbb228c7d2 [LLDB] Always remove debugserver from LLVM_DISTRIBUTION_COMPONENTS
Centralize the logic to remove debugserver from
LLVM_DISTRIBUTION_COMPONENTS when LLDB_USE_SYSTEM_DEBUGSERVER is
enabled. Now this happens regardless of whether the tests are enabled.
2019-11-12 12:58:26 -08:00
shafik 91e94a7015 [LLDB][Formatters] Re-enable std::function formatter with fixes to improve non-cached lookup performance
Performance issues lead to the libc++ std::function formatter to be disabled. We addressed some of those performance issues by adding caching see D67111
This PR fixes the first lookup performance by not using FindSymbolsMatchingRegExAndType(...) and instead finding the compilation unit the std::function wrapped callable should be in and then searching for the callable directly in the CU.

Differential Revision: https://reviews.llvm.org/D69913
2019-11-12 11:30:18 -08:00
Davide Italiano 96915495f9 [ObjectFileMachO] Fix the build for __arm64__.
Catch up with an API change.
2019-11-12 11:10:36 -08:00
Adrian Prantl 3b73dcdc96 Performance: Add a set of visited SymbolFiles to the other FindFiles variant.
This is basically the same bug as in r260434.

SymbolFileDWARF::FindTypes has exponential worst-case when digging
through dependency DAG of .pcm files because each object file and .pcm
file may depend on an already-visited .pcm file, which may again have
dependencies. Fixed here by carrying a set of already visited
SymbolFiles around.

rdar://problem/56993424

Differential Revision: https://reviews.llvm.org/D70106
2019-11-12 09:38:37 -08:00
Muhammad Omair Javaid a6c40f56ae Revert "Fix lookup of symbols at the same address with no size vs. size"
This reverts commit 3f594ed168.

This change has cause LLDB expression evaluation to fail on Arm Linux.

Differential Revision: https://reviews.llvm.org/D63540
2019-11-12 19:02:17 +05:00
Pavel Labath 6aa60b0514 [lldb] Fix more -Wdeprecated-copy warnings
This warning triggers when a class defines a copy constructor but not a
copy-assignment operator (which then gets auto-generated by the
compiler). Fix the warning by deleting the other operator too, as the
default implementation works just fine.
2019-11-12 14:39:47 +01:00
Pavel Labath 1dfb1a85e7 [lldb] Fix some warnings in the python plugin 2019-11-12 14:39:34 +01:00
Michał Górny 77cc246412 [lldb] [Process/NetBSD] Use PT_STOP to stop the process [NFCI]
Differential Revision: https://reviews.llvm.org/D70060
2019-11-12 12:35:02 +01:00
Tatyana Krasnukha 3130a88137 [lldb][test] Macros in expressions require DWARF 5 2019-11-12 13:58:06 +03:00
Raphael Isemann ec4c96d685 [lldb][NFC] Simplify a return in ThreadPlanStepInRange::DefaultShouldStopHereCallback
We know should_stop_here is false here, so we might as well return false directly.
2019-11-12 10:58:54 +01:00
Raphael Isemann 874b6495b5 [lldb] Add missing include to ObjCLanguage.cpp to fix build 2019-11-12 10:21:49 +01:00
Raphael Isemann 52f3a2faf9 [lldb][NFC] Move LLVM RTTI implementation from enum to static ID variable
Summary:
swift-lldb currently has to patch the ExpressionKind enum to add support for Swift expressions. If we implement LLVM's RTTI
with a static ID variable instead of a centralised enum we can drop that patch.

Reviewers: labath, davide

Reviewed By: labath

Subscribers: JDevlieghere, lldb-commits

Tags: #upstreaming_lldb_s_downstream_patches, #lldb

Differential Revision: https://reviews.llvm.org/D70070
2019-11-12 10:04:32 +01:00
Raphael Isemann 6cc853b416 [lldb][NFC] Remove unused CompilerType::IsPossibleCPlusPlusDynamicType
Reviewers: davide, xiaobai

Reviewed By: davide, xiaobai

Subscribers: davide, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70074
2019-11-12 10:02:59 +01:00
Raphael Isemann bd7d9a85b8 [lldb] Check if we actually have a Clang type in ObjCLanguage::GetPossibleFormattersMatches
We call IsPossibleDynamicType but we also need to check if this is a Clang type,
otherwise other languages with dynamic types (like Swift) might end up being interpreted
as potential Obj-C dynamic types.
2019-11-12 09:59:04 +01:00
António Afonso 31ea714e9a Add rpath to liblldb so vendors can ship their own python framework (or others)
Summary:
I want to be able to specify which python framework to use for lldb in macos. With python2.7 we could just rely on the MacOS one but python3.7 is not shipped with the OS.
An alternative is to use the one shipped with Xcode but that could be path dependent or maybe the user doesn't have Xcode installed at all.
A definite solution is to just ship a python framework with lldb. To make this possible I added "@loader_path/../../../" to the rpath so it points to the same directory as the LLDB.framework, this way we can just drop any frameworks there.

Reviewers: hhb, sgraenitz, xiaobai, smeenai, beanz, labath

Reviewed By: labath

Subscribers: beanz, labath, mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69931
2019-11-11 19:23:10 -08:00
Jonas Devlieghere 0b8dfb5762 [lldb] Re-enable VSCode tests
The VSCode tests were all disabled on macOS because the implementation
had some issues that resulted in flakiness on Darwin. It seems most of
these issues have been addressed. I've re-enabled all the tests that
consistently passed locally.
2019-11-11 15:59:54 -08:00
Jonas Devlieghere 0cf86da174 [Reproducer] Quit the debugger after generating a reproducer
Currently nothing prevents you from continuing your debug session after
generating the reproducer. This can cause the reproducer to end up in an
inconsistent state. Most of the time this doesn't matter, but I want to
prevent this from causing bugs in the future.
2019-11-11 14:29:53 -08:00
Adrian Prantl 646d927175 Replace tabs with spaces. (NFC) 2019-11-11 12:22:55 -08:00
Adrian Prantl da83e96273 Fix a regression in macOS-style path remapping.
When we switched to the LLVM .debug_line parser, the .dSYM-style path
remapping logic stopped working for relative paths because of how
RemapSourceFile silently fails for relative paths. This patch both
makes the code more readable and fixes this particular bug.

One interesting thing I learned is that Module::RemapSourceFile() is a
macOS-only code path that operates on on the lldb::Module level and is
completely separate from target.source-map, which operates on a
per-Target level.

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

rdar://problem/56924558
2019-11-11 12:21:38 -08:00
Adrian Prantl d24bce57c3 Add a testcase for .dSYM path remapping dictionaries.
rdar://problem/56924558
2019-11-11 12:21:38 -08:00
Pavel Labath a14eb8f47d lldb: Fix some -Wdeprecated-copy warnings
gcc-9 started warning when a class defined a copy constructor without a
copy assignment operator (or vice-versa).

This fixes those warnings by deleting the other special member too
(after verifying it doesn't do anything non-trivial).
2019-11-11 17:55:49 +01:00
Pavel Labath 135a493f34 Fix TestNoGPacketSupported on linux
The mock server pretends the process stopped with signal 17, which is
SIGCHLD on linux. This causes lldb to resume to process, utterly
confusing the test. Lldb probably shouldn't resume in this case, but for
now this issue can be fixed by changing the signal number to 2, which is
SIGINT just about anywhere.
2019-11-11 17:29:48 +01:00
Michał Górny e2f0b243aa [lldb] [test] Fix typo in TestSendSignal 2019-11-11 11:01:42 +01:00
Michał Górny 36937ec7fb [lldb] [test] Mark TestSendSignal XFAIL on NetBSD 2019-11-11 10:54:36 +01:00
Michał Górny 0ac296322f [lldb] [test] Un-XFAIL tests that work on NetBSD 9 2019-11-09 19:40:31 +01:00
Jason Molenda 60ab30ebce Temporarily change the default for use-g-packet-for-reading to false,
until we can automatically fall back to p/P if g/G are not supported;
it looks like there is a bug in debugserver's g/G packets taht needs
to be fixed, or debugserver should stop supporting g/G until that bug
is fixed.  But we need lldb to be able to fall back to p/P correctly
for that to be a viable workaround.
2019-11-08 18:21:57 -08:00
Jonas Devlieghere 441a78533e Revert "Add a testcase for .dSYM path remapping dictionaries."
This reverts commit 2bbc4fdd8f.
2019-11-08 18:16:44 -08:00
Jason Molenda 1478f36f27 Test case to verify that lldb falls back to p/P if g is unsupported
and that lldb uses the expedited register values in the ? packet
aka stop packet (T11 etc) and does not re-fetch them with the p packet.

This test is currently failing from the "[lldb-server] Add setting to
force 'g' packet use" commit; I'm marking it as @expectedFailureAll
until we can get this fixed.
2019-11-08 15:57:54 -08:00
Adrian Prantl 2bbc4fdd8f Add a testcase for .dSYM path remapping dictionaries.
rdar://problem/56924558
2019-11-08 14:07:35 -08:00
Adrian Prantl 8204d9ff7e Properly propagate is_variadic.
This fixes a copy&paste error made when adapting to new clang API
which was promptly caught by the bots.
2019-11-08 09:53:51 -08:00
Jonas Devlieghere 4d0e07f786 [lldb] Make Asan/SIP workaround work for Python 3
Make the check generic instead of hard-coding the path to Python 2. This
also fixes the print-syntax to be compatible with both versions.
2019-11-08 09:19:56 -08:00
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