Commit Graph

22193 Commits

Author SHA1 Message Date
Raphael Isemann 4ab2ea9fc0 [lldb] Fix typo in ClangASTSource logging statement 2020-03-04 11:05:48 -08:00
Raphael Isemann e98ef0af2c [lldb] Fix several LLDB_LOGs with wrong indices in ClangASTSource.cpp 2020-03-04 10:32:50 -08:00
Raphael Isemann 0ab109d43d [lldb][NFC] Modernize logging UserExpression 2020-03-04 09:04:54 -08:00
Tatyana Krasnukha b1324e74da [lldb][NFC] Move local variables near to their usage 2020-03-04 16:56:51 +03:00
Tatyana Krasnukha 6c17cc531f [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to breakpoint
This prevents calling Breakpoint::shared_from_this of an object that is not owned by any shared_ptr.

Differential Revision: https://reviews.llvm.org/D74557
2020-03-04 16:56:50 +03:00
Pavel Labath 3245dd59b1 [lldb] Reduce duplication in CommandObjectDisassemble
This command had nearly identical code for the "then" and "else"
branches of the "if (m_options.num_instructions != 0)" condition.

This patch factors out the common parts of the two blocks to reduce
duplication.
2020-03-04 13:47:35 +01:00
Adrian Prantl a7fa8b022f Doxygenify CompilerType.h (NFC) 2020-03-03 13:43:25 -08:00
Alex Langford e566dd733d [lldb] Delete some commented out code in ClangASTSource.cpp 2020-03-03 13:17:21 -08:00
Stefan Stipanovic 13fd50cc26 Revert "Revert "[lldb/Docs] Mark both Python 3.6 and 3.8 as supported on Windows""
This reverts commit 78a734e279.
2020-03-03 20:43:16 +01:00
Stefan Stipanovic 78a734e279 Revert "[lldb/Docs] Mark both Python 3.6 and 3.8 as supported on Windows"
This reverts commit 3270ea9042.
2020-03-03 20:41:18 +01:00
Jonas Devlieghere 3270ea9042 [lldb/Docs] Mark both Python 3.6 and 3.8 as supported on Windows
Haibo told me he didn't have any issues with Python 3.8 and I was able
to confirm that. Even though we don't have bot running with 3.8, I think
it safe to mark it as supported in the docs.
2020-03-03 11:26:00 -08:00
Raphael Isemann 531515198e [lldb][NFC] Remove some commented out code in TypeSystemClang
Summary: I don't see why we want to keep that code around.

Reviewers: #lldb, JDevlieghere

Reviewed By: #lldb, JDevlieghere

Subscribers: davide

Differential Revision: https://reviews.llvm.org/D75496
2020-03-03 10:50:48 -08:00
Pavel Labath 573e077699 [lldb] Add detailed tests for the "disassemble" command
While we have some tests for this command already, they are very vague.
This is not surprising -- it's hard to make strict assertions about the
assembly if your input is a c++ source file. This means that the tests
can more-or-less only detect when the command breaks completely, and not
when there is a subtle change in meaning due to e.g. a code refactor --
which is something that I am getting ready to do.

This tests in this patch create binaries with well known data (via assembler
and yaml2obj). This means that we are able to make precise assertions
about the text that lldb is supposed to print. As some of the features
of this command are only available with a real process, I use a minidump
core file to create a sufficiently realistic process object.
2020-03-03 16:40:27 +01:00
Pavel Labath 1d6fa41f40 [lldb] Have Disassembler::ParseInstructions take a Target&
Instead of a ExecutionContext*. All it needs is the target so it can
read the memory.

This removes some defensive checks from the function. I've added
equivalent checks to the callers in cases where a non-null target
pointer was not guaranteed to be available.
2020-03-03 13:58:56 +01:00
Pavel Labath 221641be02 [lldb] Add lldbTarget -> llvmMC dependency
The ABI class uses llvm::MCRegisterInfo.
2020-03-03 13:10:44 +01:00
Unnar Freyr Erlendsson 6304368818 [lldb] Treat RangeDataVector as an augmented binary search tree
Summary:
Since RangeDataVector is assumed to always be sorted we can treat it as
an flattened BST and augment it with additional information about the
ranges belonging to each "subtree". By storing the maximum endpoint in
every subtree we can query for intervals in O(log n) time.

Reviewers: labath, teemperor

Reviewed By: labath

Subscribers: jarin, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74759
2020-03-03 11:28:16 +01:00
Pavel Labath 4deea65249 [lldb] Make sure we don't drop asynchronous output when sourcing files
Summary:
If a command from a sourced file produces asynchronous output, this
output often does not make its way to the user. This happens because the
asynchronous output machinery relies on the iohandler stack to ensure
the output does not interfere with the things the iohandler is doing.

However, if this happens near the end of the command stream then by the
time the asynchronous output is produced we may already have already
started tearing down the sourcing session. Specifically, we may already
pop the relevant iohandler, leaving the stack empty.

This patch makes sure this kind of output gets printed by adding a
fallback to IOHandlerStack::PrintAsync to print the output directly if
the stack is empty. This is safe because if we have no iohandlers then
there is nothing to synchronize.

Reviewers: JDevlieghere, clayborg

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75454
2020-03-03 11:18:41 +01:00
Hans Wennborg 916be8fd6a Revert abb00753 "build: reduce CMake handling for zlib" (PR44780)
and follow-ups:
a2ca1c2d "build: disable zlib by default on Windows"
2181bf40 "[CMake] Link against ZLIB::ZLIB"
1079c68a "Attempt to fix ZLIB CMake logic on Windows"

This changed the output of llvm-config --system-libs, and more
importantly it broke stand-alone builds. Instead of piling on more fix
attempts, let's revert this to reduce the risk of more breakages.
2020-03-03 11:03:09 +01:00
Fred Riss 138c7ac5b6 [lldb/GDBRemote] Fix obvious typo in error message.
It's unlikely that `errno` is the value the user wants to see in this
error message.
2020-03-02 17:53:39 -08:00
Fred Riss 20ce8affce [lldb/API] NFC: Reformat and simplify SBThread::GetStopDescription()
Summary:
This gets rid of some nesting and of the raw char* variable that caused
the memory management bug we hit recently.

This commit also removes the fallback code which should trigger when
the StopInfo provides no stop description. All currently implemented
StopInfos have a `GetDescription()` method that shouldn't return an
empty description.

Reviewers: JDevlieghere, labath, mib

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74157
2020-03-02 17:43:35 -08:00
Jonas Devlieghere 7ad30f4249 [lldb/Utility] Use emplace_back instead of push_back (NFC)
Use emplace_back to allow for in-place construction of the
BroadcastEventSpec instead of copying it.
2020-03-02 15:54:00 -08:00
Raphael Isemann b6b3fcdcb8 [lldb] Don't iterate over a std::set<Type*> in SymbolFileDWARF::GetTypes to make it deterministic
Summary:
Currently `SymbolFileDWARF::TypeSet` is a typedef to a `std::set<Type *>`.
In `SymbolFileDWARF::GetTypes` we iterate over a TypeSet variable when finding
types so that logic is non-deterministic as it depends on the actual pointer address values.

This patch changes the `TypeSet` to a `llvm::UniqueVector` which always iterates in
the order in which we inserted the types into the list.

Reviewers: JDevlieghere, aprantl

Reviewed By: JDevlieghere

Subscribers: mgrang, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75481
2020-03-02 15:03:45 -08:00
Davide Italiano eddf59ae71 [docs] Use 0 as version placeholder instead of a made up number.
While here, explain that this is not really used. Probably NFC.
2020-03-02 14:55:05 -08:00
Jonas Devlieghere c77fc00eec [lldb/Docs] Remove the version from the home page 2020-03-02 14:23:05 -08:00
Raphael Isemann 69d2b67556 [lldb] Remove checks behind LLDB_CONFIGURATION_DEBUG from TypeSystemClang
Summary:
This function is (supposed) to be a list of asserts that just do a generic sanity check
on declarations we return. Right now this function is hidden behind the
LLDB_CONFIGURATION_DEBUG macro which means it will *only* be run in
debug builds (but not Release+assert builds and so on).

As we have not a single CI running in Debug build, failures in VerifyDecl are hidden
from us until someone by accident executes the tests in Debug mode on their own machine.

This patch removes the `ifdef`'s for LLDB_CONFIGURATION_DEBUG and puts
the `getAccess()` call in `VerifyDecl` behind a `#ifndef NDEBUG` to make sure
that this function is just an empty function with internal linkage when NDEBUG
is defined (so compilers should just optimize away the calls to it).

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: shafik, abidh, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75330
2020-03-02 10:57:56 -08:00
Pavel Labath 7369ad38f8 [lldb] Use llvm MC as the source of dwarf/eh register numbers for X86 ABIs
x86_64 ABIs were converted with 07355c1c0. This does the same with i386.
2020-02-28 10:49:08 +01:00
Reid Kleckner e3a9b0f359 [Support] Remove byte swapping from MathExtras.h
MathExtras.h was just wrapping SwapByteOrder.h functionality, so have
the callers use it directly.  Use the MathExtras.h name (ByteSwap_NN) as
the standard naming, since it appears to be the most popular.
2020-02-27 17:23:48 -08:00
Reid Kleckner 4c2a6567bb Avoid ASTContext.h -> TargetInfo.h dep
This has been done before in 2008: ab13857072
But these things regress easily.
Move some things out of line.

Saves 316 includes + transitive stuff:
    316 -    ../clang/include/clang/Basic/TargetOptions.h
    316 -    ../clang/include/clang/Basic/TargetInfo.h
    316 -    ../clang/include/clang/Basic/TargetCXXABI.h
    316 -    ../clang/include/clang/Basic/OpenCLOptions.h
    316 -    ../clang/include/clang/Basic/OpenCLExtensions.def
    302 -    ../llvm/include/llvm/Target/TargetOptions.h
    302 -    ../llvm/include/llvm/Support/CodeGen.h
    302 -    ../llvm/include/llvm/MC/MCTargetOptions.h
    302 -    ../llvm/include/llvm/ADT/FloatingPointMode.h
    302 -    ../clang/include/clang/Basic/XRayInstr.h
    302 -    ../clang/include/clang/Basic/DebugInfoOptions.h
    302 -    ../clang/include/clang/Basic/CodeGenOptions.h
    302 -    ../clang/include/clang/Basic/CodeGenOptions.def
    257 -    ../llvm/include/llvm/Support/Regex.h
     79 -    ../llvm/include/llvm/ADT/SmallSet.h
     68 -    MSVCSTL/include/set
     66 -    ../llvm/include/llvm/ADT/SmallPtrSet.h
     62 -    ../llvm/include/llvm/ADT/StringSwitch.h
2020-02-27 14:35:00 -08:00
Reid Kleckner 86565c1309 Avoid SourceManager.h include in RawCommentList.h, add missing incs
SourceManager.h includes FileManager.h, which is expensive due to
dependencies on LLVM FS headers.

Remove dead BeforeThanCompare specialization.

Sink ASTContext::addComment to cpp file.

This reduces the time to compile a file that does nothing but include
ASTContext.h from ~3.4s to ~2.8s for me.

Saves these includes:
    219 -    ../clang/include/clang/Basic/SourceManager.h
    204 -    ../clang/include/clang/Basic/FileSystemOptions.h
    204 -    ../clang/include/clang/Basic/FileManager.h
    165 -    ../llvm/include/llvm/Support/VirtualFileSystem.h
    164 -    ../llvm/include/llvm/Support/SourceMgr.h
    164 -    ../llvm/include/llvm/Support/SMLoc.h
    161 -    ../llvm/include/llvm/Support/Path.h
    141 -    ../llvm/include/llvm/ADT/BitVector.h
    128 -    ../llvm/include/llvm/Support/MemoryBuffer.h
    124 -    ../llvm/include/llvm/Support/FileSystem.h
    124 -    ../llvm/include/llvm/Support/Chrono.h
    124 -    .../MSVCSTL/include/stack
    122 -    ../llvm/include/llvm-c/Types.h
    122 -    ../llvm/include/llvm/Support/NativeFormatting.h
    122 -    ../llvm/include/llvm/Support/FormatProviders.h
    122 -    ../llvm/include/llvm/Support/CBindingWrapping.h
    122 -    .../MSVCSTL/include/xtimec.h
    122 -    .../MSVCSTL/include/ratio
    122 -    .../MSVCSTL/include/chrono
    121 -    ../llvm/include/llvm/Support/FormatVariadicDetails.h
    118 -    ../llvm/include/llvm/Support/MD5.h
    109 -    .../MSVCSTL/include/deque
    105 -    ../llvm/include/llvm/Support/Host.h
    105 -    ../llvm/include/llvm/Support/Endian.h

Reviewed By: aaron.ballman, hans

Differential Revision: https://reviews.llvm.org/D75279
2020-02-27 13:49:40 -08:00
Jonas Devlieghere 04a91deebb [lldb/CMake] Use PYTHON_HOME as a hint to find Python 3.
http://lists.llvm.org/pipermail/lldb-dev/2020-February/015998.html

Differential revision: https://reviews.llvm.org/D75275
2020-02-27 13:17:49 -08:00
Paolo Severini 256e61699b [LLDB] Fix AddressSanitizer failure in MemoryCache
The lldb sanitizer bot is flagging a container-overflow error after we
introduced test TestWasm.py. MemoryCache::Read didn't behave correctly
in case of partial reads that can happen with object files whose size is
smaller that the cache size. It should return the actual number of bytes
read and not try to fill the buffer with random memory.
Module::GetMemoryObjectFile needs to be modified accordingly, to resize
its buffer to only the size that was read.

Differential Revision: https://reviews.llvm.org/D75200
2020-02-27 11:17:10 -08:00
Raphael Isemann 4bb3cb2bcb [lldb] Show the actual error when 'watchpoint set expression' failed
Currently we only show the user that the expression failed but not
what is actually wrong with it. This just dumps the error we get
back alongside the other output to the error stream.

This should also help with finding out with why sometimees the
TestWatchLocationWithWatchSet.py test fails here on the LLDB
incremental bot on Green Dragon.
2020-02-27 12:06:51 +01:00
Raphael Isemann 2affdcee61 [lldb][NFC] Fix several -Wdocumentation warnings
The GetOffset documentation was copied from the function above
so I completely deleted that one. The rest was just outdated
documentation that didn't keep up with renamed or changed
function parameters/return types.
2020-02-27 11:17:16 +01:00
Raphael Isemann 56b03c35dd [lldb] Skip TestWasm.py on sanitized builds until D75200 has landed 2020-02-27 10:45:42 +01:00
Davide Italiano 34ee941f6d [ObjectFileMachO] Fix a build error on embedded. 2020-02-26 14:31:48 -08:00
Reid Kleckner 34312ed24e Remove unneeded Compiler.h and DataTypes.h includes, NFC 2020-02-26 10:36:17 -08:00
Vedant Kumar 7822c8c03e [lldb/test] Skip running a test under ASan, it intentionally double-frees 2020-02-26 10:11:39 -08:00
Unnar Freyr Erlendsson 594130db0a Add unit tests for RangeDataVector::FindEntryIndexesThatContain
Summary: This adds unit tests for FindEntryIndexesThatContain, this is done in preparation for changing the logic of the function.

Reviewers: labath, teemperor

Reviewed By: labath

Subscribers: arphaman, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75180
2020-02-26 16:47:42 +01:00
Pavel Labath d4eca120ac [lldb/gdb-remote] Add support for the qOffsets packet
Summary:
This packet is necessary to make lldb work with the remote-gdb stub in
user mode qemu when running position-independent binaries. It reports
the relative position (load bias) of the loaded executable wrt. the
addresses in the file itself.

Lldb needs to know this information in order to correctly set the load
address of the executable. Normally, lldb would be able to find this out
on its own by following the breadcrumbs in the process auxiliary vector,
but we can't do this here because qemu does not support the
qXfer:auxv:read packet.

This patch does not implement full scope of the qOffsets packet (it only
supports packets with identical code, data and bss offsets), because it
is not fully clear how should the different offsets be handled and I am
not aware of a producer which would make use of this feature (qemu will
always
<https://github.com/qemu/qemu/blob/master/linux-user/elfload.c#L2436>
return the same value for code and data offsets). In fact, even gdb
ignores the offset for the bss sections, and uses the "data" offset
instead.  So, until the we need more of this packet, I think it's best
to stick to the simplest solution possible. This patch simply rejects
replies with non-uniform offsets.

Reviewers: clayborg, jasonmolenda

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74598
2020-02-26 10:18:58 +01:00
Jason Molenda 4b2b8b96db Re-land Unwind past an interrupt handler correctly on arm or at pc==0
Updated the patch to only fetch $pc on a Return Address-using
target only if we're in a trap frame *and* if there is a saved
location for $pc in the trap frame's unwind rules.  If not,
we fall back to fetching the Return Address register (eg $lr).

Original commit msg:

    Unwind past an interrupt handler correctly on arm or at pc==0

    Fix RegisterContextLLDB::InitializeNonZerothFrame so that it
    will fetch a FullUnwindPlan instead of falling back to the
    architectural default unwind plan -- GetFullUnwindPlan knows
    how to spot a jmp 0x0 that results in a fault, which may be
    the case when we see a trap handler on the stack.

    Fix RegisterContextLLDB::SavedLocationForRegister so that when
    the pc value is requested from a trap handler frame, where we
    have a complete register context available to us, don't provide
    the Return Address register (lr) instead of the pc.  We have
    an actual pc value here, and it's pointing to the instruction
    that faulted.

    Differential revision: https://reviews.llvm.org/D75007
    <rdar://problem/59416588>
2020-02-25 14:58:20 -08:00
Jim Ingham 3cd13c4624 Fix a race between lldb's packet timeout and the profile thread's usleep.
The debugserver profile thread used to suspend itself between samples with
a usleep.  When you detach or kill, MachProcess::Clear would delay replying
to the incoming packet until pthread_join of the profile thread returned.
If you are unlucky or the suspend delay is long, it could take longer than
the packet timeout for pthread_join to return.  Then you would get an error
about detach not succeeding from lldb - even though in fact the detach was
successful...

I replaced the usleep with PThreadEvents entity.  Then we just call a timed
WaitForEventBits, and when debugserver wants to stop the profile thread, it
can set the event bit, and the sleep will exit immediately.

Differential Revision: https://reviews.llvm.org/D75004
2020-02-25 11:17:08 -08:00
Ayke van Laethem ec1efe7113
[LLDB] Let DataExtractor deal with two-byte addresses
AVR usually uses two byte addresses. By making DataExtractor deal with
this, it is possible to load AVR binaries that don't have debug info
associated with them.

Differential Revision: https://reviews.llvm.org/D73969
2020-02-25 16:27:38 +01:00
Raphael Isemann bdb24faa2a [lldb][NFC] Move filling namespace map in ClangASTSource to own function 2020-02-25 13:59:21 +01:00
Raphael Isemann 93b6e19240 [lldb] Initialize NameSearchContext::m_namespace_map in constructor
This member is for some reason initialized in ClangASTSource::FindExternalVisibleDecls
so all other functions using this member dereference a nullptr unless we
call this function before that. Let's just initialize this in the constructor.

This should be NFC as the only side effect is that we don't reset the namespace map
when calling ClangASTSource::FindExternalVisibleDecls multiple times (and we never
call this function multiple times for one NameSearchContext from what I can see).
2020-02-25 13:20:54 +01:00
Raphael Isemann 2ad7b6fba0 [lldb][NFC] Make NameSearchContext::m_found members bools instead of bitfields
The size of NameSearchContext isn't important as we never store it and rarely
allocate more than a few. This way we also don't have to use the memset to
initialize these fields to zero.
2020-02-25 12:45:00 +01:00
Raphael Isemann defd0e24aa [lldb][NFC] Move NameSearchContext to own header/source files
The class is large enough to be in its own file. This patch also removes the cyclic
dependency between ClangASTSource <-> NameSearchContext.
2020-02-25 12:25:36 +01:00
Raphael Isemann fc0d11c904 [lldb][NFC] Modernize logging in ClangASTSource/ExpressionDeclMap 2020-02-25 12:08:09 +01:00
Raphael Isemann 05d174d301 [lldb][NFC] Move namespace lookup in ClangASTSource to own function.
Beside being cleaner we can probably reuse that logic elsewhere.
2020-02-25 10:27:47 +01:00
Pavel Labath eefbff0082 [lldb] s/CHECK-NEXT/CHECK-DAG in dwp-debug-types.s
These can come out nondeterministically for two reasons:
- sorting based on ConstStringified pointer values
- different relative speeds of the indexing threads

Making these nondeterministic without incurring performance penalties is
hard, so I just make the test expect them in any order (the order is not
important in this test anyway.
2020-02-25 10:04:09 +01:00
Raphael Isemann ea6b95dc2f [lldb][NFC] Make ArrayRef initialization more obvious in lldb-test.cpp
Seems like this code raised some alarm bells as it looks like an ArrayRef
to a temporary initializer list, but it's actually just calling the ArrayRef(T*, T*)
constructor. Let's clarify this and directly call the right ArrayRef constructor here.

Fixes rdar://problem/59176052
2020-02-25 09:48:17 +01:00
Raphael Isemann 55d4b0d7dd [lldb] Fix that a crashing test is marked as unsupported when it prints UNSUPPORTED before crashing
Summary:
I added an `abort()` call to some code and noticed that the test suite was still passing and it just marked my test as "UNSUPPORTED".

It seems the reason for that is that we expect failing tests to print "FAIL:" which doesn't happen when we crash. If we then also
have an unsupported because we skipped some debug information in the output, we just mark the test passing because it is unsupported
on the current platform.

This patch marks any test that has a non-zero exit code as failing even if it doesn't print "FAIL:" (e.g., because it crashed).

Reviewers: labath, JDevlieghere

Reviewed By: labath, JDevlieghere

Subscribers: aprantl, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75031
2020-02-25 08:46:37 +01:00
Pavel Labath c08a1c7071 [lldb] Mark ObjectFileBreakpad test inputs as non-text
These are technically text files, but the object file layer treats them
as binary, and the relevant tests verify the parsed contents byte for
byte. Git's crlf conversion can make those tests fail. Marking the files
as non-text disables that.
2020-02-25 08:29:41 +01:00
Jonas Devlieghere 35a0614535 [lldb/Utility] Fix unspecified behavior.
Order of evaluation of the operands of any C++ operator [...] is
unspecified. This patch fixes the issue in Stream::Indent by calling the
function consecutively.

On my Windows setup, TestSettings.py fails because the function prints
the value first, followed by the indentation.

Expected result:
  MY_FILE=this is a file name with spaces.txt

Actual result:
MY_FILE  =this is a file name with spaces.txt
2020-02-24 21:25:55 -08:00
Jason Molenda 4fdd2edbdb Revert "Unwind past an interrupt handler correctly on arm or at pc==0"
The aarcht64-ubuntu bot is showing a test failure in TestHandleAbort.py
with this patch.  Adding some logging to that file, it looks like
the saved register context above the trap handler does not have
save state for $pc, but it does have it for $lr on that platform.
I need to fall back to looking for $lr if the $pc cannot be retrieved.
I'll update the patch and re-commit once that's fixed.

This reverts commit edc4f4c9c9.
2020-02-24 19:03:22 -08:00
Jason Molenda d5a4fa0514 Revert "My prevous commit to RegisterContextLLDB is causing a test fail"
This reverts commit 082f1a3b15.
2020-02-24 19:03:22 -08:00
Jason Molenda 082f1a3b15 My prevous commit to RegisterContextLLDB is causing a test fail
on aarch64-ubuntu - collect a little information about what
is happening on this target before I revert my change; I don't
have access to this target.
2020-02-24 17:19:06 -08:00
Shoaib Meenai e34ddc09f4 [arcconfig] Delete subproject arcconfigs
From https://secure.phabricator.com/book/phabricator/article/arcanist_new_project/:

> An .arcconfig file is a JSON file which you check into your project's root.

I've done some experimentation, and it looks like the subproject
.arcconfigs just get ignored, as the documentation says. Given that
we're fully on the monorepo now, it's safe to remove them.

Differential Revision: https://reviews.llvm.org/D74996
2020-02-24 16:20:36 -08:00
Jason Molenda edc4f4c9c9 Unwind past an interrupt handler correctly on arm or at pc==0
Fix RegisterContextLLDB::InitializeNonZerothFrame so that it
will fetch a FullUnwindPlan instead of falling back to the
architectural default unwind plan -- GetFullUnwindPlan knows
how to spot a jmp 0x0 that results in a fault, which may be
the case when we see a trap handler on the stack.

Fix RegisterContextLLDB::SavedLocationForRegister so that when
the pc value is requested from a trap handler frame, where we
have a complete register context available to us, don't provide
the Return Address register (lr) instead of the pc.  We have
an actual pc value here, and it's pointing to the instruction
that faulted.

Differential revision: https://reviews.llvm.org/D75007
<rdar://problem/59416588>
2020-02-24 16:11:15 -08:00
Jonas Devlieghere 841be9854c [lldb] Color the line marker
Highlight the color marker similar to what we do for the column marker.
The default color matches the color of the current PC marker (->) in the
default disassembly format.

Differential revision: https://reviews.llvm.org/D75070
2020-02-24 15:40:31 -08:00
Med Ismail Bennani eefda18227 [lldb/Plugins] Move SBTarget::GetExtendedCrashInformation to SBProcess
This patch moves the SB API method GetExtendedCrashInformation from
SBTarget to SBProcess since it only makes sense to call this method on a
sane process which might not be the case on a SBTarget object.

It also addresses some feedbacks received after landing the first patch
for the 'crash-info' feature.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-02-24 23:37:04 +01:00
Jonas Devlieghere 7f9f027c62 [lldb/Test] Update TestDisassemblyFormat for new format 2020-02-24 14:08:16 -08:00
Jonas Devlieghere c4093db3da [lldb] Color the current PC marker
Differential revision: https://reviews.llvm.org/D75073
2020-02-24 12:51:01 -08:00
Jonas Devlieghere 77a2744fa5 [lldb/Debugger] Remove macros formerly used by property definitions
The DEFAULT_ were used in property definitions which have since been
moved to CoreProperties.td.
2020-02-24 12:48:31 -08:00
Pavel Labath c9c09ef836 [lldb/DWARF] Fix dwp search path in the separate-debug-file case
The convention is that the dwp file name is derived from the name of the
file holding the executable code, even if the linked portion of the
debug info is elsewhere (objcopy --only-keep-debug).
2020-02-24 17:01:15 +01:00
Raphael Isemann c131dfefe2 [lldb] Disable auto fix-its when evaluating expressions in the test suite
Summary:
Currently the test suite runs with enabled automatically applied Clang fix-its for expressions.
This is causing that sometimes incorrect expressions in tests are still evaluated even though they
are actually incorrect. Let's disable this feature in the test suite so that we know when expressions
are wrong and leave the fix-it testing to the dedicated tests for that feature.

Also updates the `lang/cpp/operators/` test as it seems Clang needs the `struct` keywords
before C and would otherwise fail without fixits.

Reviewers: jingham, JDevlieghere, shafik

Reviewed By: JDevlieghere, shafik

Subscribers: shafik, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74957
2020-02-24 09:31:11 +01:00
Pavel Labath be3b448c2e [lldb/test] simplify basic-elf.yaml
Explicit dynsym/dynstr sections were added in a6370d5 to compensate for
a yaml2obj change D74764. This test doesn't need those sections, so
instead I just delete the explicit section blocks, and also the
"DynamicSymbols" block, which triggers their implicit generation.
2020-02-24 09:02:18 +01:00
Pavel Labath 0f7cfb2543 [lldb/DWARF] Don't index dwp file multiple times
Summary:
When we added support for type units in dwo files, we changed the
"manual" dwarf index to index _all_ dwarf units in the dwo file instead
of just the split unit belonging to our skeleton unit. This was fine for
dwo files, as they contain only a single compile units and type units do
not have a split type unit which would point to them.

However, this does not work for dwp files because, these files do
contain multiple split compile units, and the current approach means
that each unit gets indexed multiple times (once for each split unit =>
n^2 complexity).

This patch teaches the manual dwarf index to treat dwp files specially.
Any type units in the dwp file added to the main list of compile units
and indexed with them in a single batch. Split compile units in dwp
files are still indexed as a part of their skeleton unit -- this is done
because we need the DW_AT_language attribute from the skeleton unit to
index them properly.

Handling of dwo files remains unchanged -- all units (type and skeleton)
are indexed when we reach the dwo file through the split unit.

Reviewers: clayborg, JDevlieghere, aprantl

Subscribers: arphaman, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74964
2020-02-24 08:50:51 +01:00
Raphael Isemann e657a1eb23 [lldb] Remove all the 'current_id' logging counters from the lookup code.
Summary:
We have a lot of code in our lookup code to pass around `current_id` counters which end up in our logs like this:
```
AOCTV::FT [234] Found XYZ
```

This patch removes all of this code because:
* I'm splitting up all humongous functions, so I need to write more and more boilerplate to pass around these ids.
* I never saw any similar counters in the LLDB/LLVM code base.
* They're essentially globals and the last thing we need in LLDB is even more global state.
* They're not really useful when readings logs. It doesn't help that there isn't just 1 or 2 counters, but 12 (!) unique counters. I always thought that if I see two identical counter values in those brackets it's the same lookup request, but it seems that's only true by accident (and you can't know which of the 12 counters is actually printed without reading the code). The only time I know I can trust the counters is when it's obvious from the log that it's the same counter like in the log below, but then why have the counters in the first place?

```
 LayoutRecordType[28] on (ASTContext*)0x00007FFA1C840200 'scratch ASTContext' for (RecordDecl*)0x00007FFA0AAE8CF0 [name = '__tree']
 LRT[28] returned:
 LRT[28]   Original = (RecordDecl*)%p
 LRT[28]   Size = %lld
 LRT[28]   Alignment = %lld
 LRT[28]   Fields:
 LRT[28]     (FieldDecl*)0x00007FFA1A13B1D0, Name = '__begin_node_', Offset = 0 bits
 LRT[28]     (FieldDecl*)0x00007FFA1C08FD30, Name = '__pair1_', Offset = 64 bits
 LRT[28]     (FieldDecl*)0x00007FFA1C061210, Name = '__pair3_', Offset = 128 bits
 LRT[28]   Bases:
```

Reviewers: labath, shafik, JDevlieghere

Reviewed By: labath, shafik, JDevlieghere

Subscribers: abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74951
2020-02-24 08:38:58 +01:00
Georgii Rymar a6370d5798 [lldb][test] - Update basic-elf.yaml to fix build bot.
D74764 (https://reviews.llvm.org/rG31f2ad9c368d47721508cbd0d120d626f9041715)
changed the behavior of the yaml2obj. Now it assigns virtual addresses
for allocatable sections.

SymbolFile/Breakpad/symtab.test started to fail after this change:
(http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/5520/steps/test/logs/stdio)

Command Output (stderr):
--
/home/worker/lldb-x86_64-debian/lldb-x86_64-debian/llvm-project/lldb/test/Shell/SymbolFile/Breakpad/symtab.test:6:10: error: CHECK: expected string not found in input
# CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 5:
         ^
<stdin>:15:1: note: scanning from here
Symtab, file = /home/worker/lldb-x86_64-debian/lldb-x86_64-debian/build/tools/lldb/test/SymbolFile/Breakpad/Output/symtab.out, num_symbols = 6:
^
<stdin>:15:99: note: possible intended match here
Symtab, file = /home/worker/lldb-x86_64-debian/lldb-x86_64-debian/build/tools/lldb/test/SymbolFile/Breakpad/Output/symtab.out, num_symbols = 6:

For now I've updated the basic-elf.yaml so that now it produce the same layout as before D74764.
Breakpad/symtab.test should be updated it seems.
2020-02-22 16:09:24 +03:00
Fangrui Song e29065a105 [lldb][test] Fix sh_flags and sh_entsize of .debug_str.dwo
sh_flags: SHF_MERGE | SHF_STRINGS | SHF_EXCLUDE
sh_entsize: 1

Incorrect sh_flags or sh_entsize is an error after the assembler change made by D73999.
2020-02-21 18:51:05 -08:00
Fangrui Song ebee131259 [lldb][test] Fix sh_type of .debug_cu_index and .debug_tu_index
They do not have the SHF_EXCLUDE flag.
After D73999, MC errors `changed section type for .debug_cu_index, expected: 0x0`
2020-02-21 17:38:39 -08:00
Haibo Huang 3ec3f62f0a Allow customized relative PYTHONHOME (Attemp 1)
Summary:
This is another attempt of 0bb90628b5.

The difference is that g_python_home is not declared as const. Since
some versions of python do not expect that.

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74998
2020-02-21 16:25:30 -08:00
Vedant Kumar 8a0f0e2656 [lldb/test] Tweak libcxx string test on Apple+ARM devices
On Apple platforms, is __arm__ isn't defined and we're not on Intel, we use an
alternate std::string layout. I.e., the libcxx string test fails on phones
because the hand-crafted "garbage" string structs are actually valid strings.

See:

```
  // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
  #if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) &&       \
       (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) ||                           \
      defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
  #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
  #endif
```

Disable inspection of the garbage structs on Apple+ARM devices.
2020-02-21 15:54:38 -08:00
Stella Stamenova 215a31115f Revert "Allow customized relative PYTHONHOME"
This reverts commit 0bb90628b5 since it is causing failures on the Windows LLDB buildbot:

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/14048
2020-02-21 14:57:00 -08:00
Med Ismail Bennani d7c403e640 [lldb/Plugins] Add ability to fetch crash information on crashed processes
Currently, in macOS, when a process crashes, lldb halts inside the
implementation disassembly without yielding any useful information.
The only way to get more information is to detach from the process, then wait
for ReportCrash to generate a report, find the report, then see what error
message was included in it. Instead of waiting for this to happen, lldb could
locate the error_string and make it available to the user.

This patch addresses this issue by enabling the user to fetch extended
crash information for crashed processes using `process status --verbose`.

Depending on the platform, this will try to gather different crash information
into an structured data dictionnary. This dictionnary is generic and extensible,
as it contains an array for each different type of crash information.

On Darwin Platforms, lldb will iterate over each of the target's images,
extract their `__crash_info` section and generated a StructuredData::Array
containing, in each entry, the module spec, its UUID, the crash messages
and the abort cause. The array will be inserted into the platform's
`m_extended_crash_info` dictionnary and `FetchExtendedCrashInformation` will
return its JSON representation like this:

```
{
  "crash-info annotations": [
    {
      "abort-cause": 0,
      "image": "/usr/lib/system/libsystem_malloc.dylib",
      "message": "main(76483,0x1000cedc0) malloc: *** error for object 0x1003040a0: pointer being freed was not allocated",
      "message2": "",
      "uuid": "5747D0C9-900D-3306-8D70-1E2EA4B7E821"
    },
    ...
  ],
  ...
}
```

This crash information can also be fetched using the SB API or lldb-rpc protocol
using SBTarget::GetExtendedCrashInformation().

rdar://37736535

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-02-21 22:44:36 +01:00
Med Ismail Bennani 1f04d1b706 [lldb/test] Move `platform process list` tests to its own directory (NFC)
Since the `platform process` commamnd has more tests now, this commits
separates each of the `platform process` subcommand's test in its own directory.

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-02-21 22:44:36 +01:00
Haibo Huang 0bb90628b5 Allow customized relative PYTHONHOME
Summary:
This change allows a hard coded relative PYTHONHOME setting. So that
python can easily be packaged together with lldb.

The change includes:
1. Extend LLDB_RELOCATABLE_PYTHON to all platforms. It defaults to ON
for platforms other than Windows, to keep the behavior compatible.
2. Allows to customize LLDB_PYTHON_HOME. But still defaults to
PYTHON_HOME.
3. LLDB_PYTHON_HOME can be a path relative to liblldb. If it is
relative, we will resolve it before send it to Py_DecodeLocale.

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74727
2020-02-21 12:49:10 -08:00
Matt Davis 07d2cdae11 [lldb/cmake] Enable more verbose find_package output.
Summary:
The purpose of this patch is to make identifying missing dependencies clearer to the user.
`find_package` will report if a package is not found, that output, combined with the exiting
status message, is clearer than not having the additional verbosity.

If the SWIG dependency is required {LLDB_ENABLE_PYTHON, LLDB_ENABLE_LUA}
and SWIG is not available, fail the configuration step.  Terminate the
configure early rather than later with a clear error message.

We could possibly modify:
`llvm-project/lldb/cmake/modules/FindPythonInterpAndLibs.cmake`
However, the patch here seems clear in my opinion.

Reviewers: aadsm, hhb, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: labath, jrm, mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74917
2020-02-21 10:37:02 -08:00
Ivan Hernandez c47e0e2d37 [lldb-vscode] Use libOption with tablegen to parse command line options.
This change will bring lldb-vscode in line with how several other llvm
tools process command line arguments and make it easier to add future
options.

Differential revision: https://reviews.llvm.org/D74798
2020-02-21 08:15:06 -08:00
Pavel Labath de8793b918 [lldb/DWARF] Add support for type units in dwp files
all that was needed was to teach lldb's DWARF context about the
debug_tu_index section.
2020-02-21 16:01:17 +01:00
Raphael Isemann 0e5ed1b262 [lldb][NFC] Split up ClangASTSource::FindExternalVisibleDecls
This function has two functions hidden inside it. Let's make
them proper functions.
2020-02-21 09:47:52 +01:00
Jonas Devlieghere 0d19b01622 [lldb/Test] Remove stale README in test/API
Now that the test live in the same directory the README is no longer
relevant.
2020-02-20 14:52:39 -08:00
Jonas Devlieghere 3ee2810827 [lldb/Plugin] Don't mark ProcessNetBSD as a plugin
ProcessNetBSD has no initializers so it's just a regular library and
shouldn't have the PLUGIN argument in add_lldb_library.
2020-02-20 14:35:49 -08:00
Jordan Rupprecht 0ffa6e1a7e [lldb] Fix version string when using LLDB_REVISION but not LLDB_REPOSITORY
Summary:
lldb's format string (line one) is:
`lldb version $clang_version ($lldb_repo revision $lldb_revision)`

When only using $lldb_revision and not $lldb_repo, this might look like:
`lldb version 11 ( revision 12345)`
which looks pretty ugly.

Aside: I'm not sure we really need all the different versions since we've moved to the monorepo layout -- I don't think anyone is using different llvm/clang/lldb revisions, are they? We could likely tidy this up further if we knew how people consumed the output of lldb --version.

Reviewers: labath, JDevlieghere, friss

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74859
2020-02-20 10:07:50 -08:00
Muhammad Omair Javaid af64b31959 Add target.xml support for qXfer request.
Summary:
Requesting registers one by one takes a while in our project.
We want to get rid of it by using target.xml.

Reviewers: jarin, labath, omjavaid

Reviewed By: labath, omjavaid

Subscribers: omjavaid, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74217
2020-02-20 23:03:54 +05:00
Djordje Todorovic 2f215cf36a Revert "Reland "[DebugInfo] Enable the debug entry values feature by default""
This reverts commit rGfaff707db82d.
A failure found on an ARM 2-stage buildbot.
The investigation is needed.
2020-02-20 14:41:39 +01:00
Konrad Kleine c7b7f76ae6 [lldb]: fix typo in lldb-gdb-remote.txt
Summary: The logic of the sentence made more sense when "with" is replaced with "without".

Reviewers: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74895
2020-02-20 14:30:12 +01:00
Pavel Labath 7b59ff2fa0 [lldb] Add boilerplate to recognize the .debug_tu_index section
It's just like debug_cu_index, only for type units.
2020-02-20 13:44:21 +01:00
Pavel Labath ddf60ba09f [lldb/DWARF] Always construct a DWARFDebugInfo object
Change the return value of SymbolFileDWARF::DebugInfo from a pointer to
a reference, and remove all null checks.

Previously, we were not constructing the DebugInfo object when the
debug_info section was empty. Now we always construct the object but
it will return an empty list of dwarf units (a thing which it already
supported).
2020-02-20 10:51:40 +01:00
Raphael Isemann fdea9a4ec9 [lldb] Remove license headers from all test source files
Summary:
Around a third of our test sources have LLVM license headers. This patch removes those headers from all test
sources and also fixes any tests that depended on the length of the license header.

The reasons for this are:

* A few tests verify line numbers and will start failing if the number of lines in the LLVM license header changes. Once I landed my patch for valid SourceLocations in debug info we will probably have even more tests that verify line numbers.
* No other LLVM project is putting license headers in its test files to my knowledge.
* They make the test sources much more verbose than they have to be. Several tests have longer license headers than the actual test source.

For the record, the following tests had their line numbers changed to pass with the removal of the license header:
    lldb-api :: functionalities/breakpoint/breakpoint_by_line_and_column/TestBreakpointByLineAndColumn.py
    lldb-shell :: Reproducer/TestGDBRemoteRepro.test
    lldb-shell :: Reproducer/TestMultipleTargets.test
    lldb-shell :: Reproducer/TestReuseDirectory.test
    lldb-shell :: ExecControl/StopHook/stop-hook-threads.test
    lldb-shell :: ExecControl/StopHook/stop-hook.test
    lldb-api :: lang/objc/exceptions/TestObjCExceptions.py

Reviewers: #lldb, espindola, JDevlieghere

Reviewed By: #lldb, JDevlieghere

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

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74839
2020-02-20 08:32:01 +01:00
Jonas Devlieghere 14fb31795a [lldb/Test] s/skipIfDarwinEmbedded/skipIfRemote/ in VSCode tests.
As pointed out on lldb-commits this skipIfRemote is the better fit for
the decorator.
2020-02-19 20:20:36 -08:00
Jonas Devlieghere 6990eaf1fe [lldb/Test] Skip VSCode test on embedded Darwin
These tests are not configured to run on the device.
2020-02-19 17:34:01 -08:00
Jonas Devlieghere df590f51b6 [lldb/Core] Remove locking in the PluginManager
Remove locking as all the plugin registration takes place from a single
thread. Addresses Pavel's feedback in D74816.
2020-02-19 10:04:05 -08:00
Raphael Isemann bb61021a8f [lldb][NFC] Remove giant do{...}while(false); in ClangASTSource::FindExternalVisibleDecls 2020-02-19 17:35:07 +01:00
Raphael Isemann 53eece04bd [lldb][NFC] Modernize test setup code in several lang/cpp tests
All these tests can just call lldbutil.run_to_source_breakpoint
instead of reimplementing it.
2020-02-19 15:07:26 +01:00
Raphael Isemann 1b2deb9ae0 [lldb] Remove Windows X-fail for TestCPPAuto and TestStepTarget
TestCPPAuto was only failing on windows due to the std::string
copying (which was not related at all to 'auto' functionality).

TestStepTarget is now also passing but that seems more that we
now have by accident the right behavior in Windows. I'll remove
the x-fail just to make the bot green again.
2020-02-19 15:05:36 +01:00
Raphael Isemann 3d7b591dca [lldb][NFC] Pointer to reference conversion for CompilerDeclContext params in ClangExpressionDeclMap.
Follow up for f9568a9549.
2020-02-19 14:45:23 +01:00
Pavel Labath 8131cb6e18 [lldb/DWARF] Add support for location lists in package files
The only thing needed was to account for the offset from the
debug_cu_index section when searching for the location list.

This patch also fixes a bug in the Module::ParseAllDebugSymbols
function, which meant that we would only parse the variables of the
first compile unit in the module. This function is only used from
lldb-test, so this does not fix any real issue, besides preventing me
from writing a test for this patch.
2020-02-19 14:33:58 +01:00
Raphael Isemann 10df88de21 [lldb] Remove some unnecessary includes from test sources 2020-02-19 14:12:45 +01:00
Raphael Isemann 4a9011dcda [lldb] Skip failing parts of TestCppConstructors that use 'new' on Windows 2020-02-19 13:21:51 +01:00