Commit Graph

132 Commits

Author SHA1 Message Date
Jonas Devlieghere e089b5e9e1 [lldb] Call os_log_fault on lldb_assert
Call `os_log_fault` when an lldb assert fails. We piggyback off
`LLVM_SUPPORT_XCODE_SIGNPOSTS`, which also depends on `os_log`, to avoid
having to introduce another CMake check and corresponding define.

This patch also adds a small test using lldb-test that verifies we abort
with a "regular" assertion when asserts are enabled.

Differential revision: https://reviews.llvm.org/D98987
2021-03-19 14:23:50 -07:00
Pavel Labath 004a264f8c [lldb] Fix shared library directory computation on windows
Our code for locating the shared library directory works via dladdr (or
the windows equivalent) to locate the path of an address known to reside
in liblldb. This works great for C++ programs, but there's a catch.

When (lib)lldb is used from python (like in our test suite), this dladdr
call will return a path to the _lldb.so (or such) file in the python
directory. To compensate for this, we have code which attempts to
resolve this symlink, to ensure we get the canonical location. However,
here's the second catch.

On windows, this file is not a symlink (but a copy), so this logic
fails. Since most of our other paths are derived from the liblldb
location, all of these paths will be wrong, when running the test suite.
One effect of this was the failure to find lldb-server in D96202.

To fix this issue, I add some windows-specific code to locate the
liblldb directory. Since it cannot rely on symlinks, it works by
manually walking the directory tree -- essentially doing the opposite of
what we do when computing the python directory.

To avoid python leaking back into the host code, I implement this with
the help of a callback which can be passed to HostInfo::Initialize in
order to assist with the directory location. The callback lives inside
the python plugin.

I also strenghten the existing path test to ensure the returned path is
the right one.

Differential Revision: https://reviews.llvm.org/D96779
2021-02-18 15:37:52 +01:00
Jonas Devlieghere 5c1c8443eb [lldb] Abstract scoped timer logic behind LLDB_SCOPED_TIMER (NFC)
This patch introduces a LLDB_SCOPED_TIMER macro to hide the needlessly
repetitive creation of scoped timers in LLDB. It's similar to the
LLDB_LOG(F) macro.

Differential revision: https://reviews.llvm.org/D93663
2020-12-22 09:10:27 -08:00
Jonas Devlieghere d6f5e08199 [lldb] Kill the inferior instead of detaching during test suite runs
Kill (rather than detach) form the inferior if debugserver loses its
connection to lldb to prevent zombie processes.

Differential revision: https://reviews.llvm.org/D92908
2020-12-09 18:40:06 -08:00
Jonas Devlieghere 75966ee241 [lldb] Get rid of helper CMake variables for Python
This patch is a big sed to rename the following variables:

  s/PYTHON_LIBRARIES/Python3_LIBRARIES/g
  s/PYTHON_INCLUDE_DIRS/Python3_INCLUDE_DIRS/g
  s/PYTHON_EXECUTABLE/Python3_EXECUTABLE/g
  s/PYTHON_RPATH/Python3_RPATH/g

I've also renamed the CMake module to better express its purpose and for
consistency with FindLuaAndSwig.

Differential revision: https://reviews.llvm.org/D85976
2020-08-17 08:47:52 -07:00
Jonas Devlieghere 61afdf0ab4 [lldb] Enable inheriting TCC permissions in lldb-test
Like the rest of the test suite, also set the target.inherit-tcc option
to true in lldb-test.
2020-08-11 11:37:14 -07:00
Jonas Devlieghere de019b88dd [lldb/Interpreter] Support color in CommandReturnObject
Color the error: and warning: part of the CommandReturnObject output,
similar to how an error is printed from the driver when colors are
enabled.

Differential revision: https://reviews.llvm.org/D81058
2020-06-09 10:45:45 -07:00
Jonas Devlieghere e6a404fbe7 [lldb/CMake] Set both the BUILD and INSTALL RPATH on macOS (2/2)
This is also needed for lldb-test.
2020-05-29 12:22:51 -07:00
Jonas Devlieghere 21afeddfb2 [lldb/CMake] Use INSTALL_RPATH for tools and BUILD_RPATH for unittests.
It seems like only the unittests are building with
BUILD_WITH_INSTALL_RPATH set to OFF. Of course when I did my last change
I only ran check-lldb-unit. Not sure why this difference exists, why
would you even install the unittest?

For the LLDB framework we do need different build and install RPATHs.
Currently that logic lives downstream. I plan to upstream that in the
near future. For now I'm just trying to make it possible to run the
test.
2020-04-30 13:20:06 -07:00
Jonas Devlieghere 8539588783 [lldb/CMake] Set the PYTHON_RPATH for the unit tests
The API and Python script interpreter unit tests also link against
Python and therefore need to set the RPATH when applicable.
2020-04-30 11:05:50 -07:00
Jonas Devlieghere ae6d2ff633 [lldb] fix RPATH when linking against Python3.framework
The install name for the Python 3 framework in Xcode is relative to
the framework's location and not the dylib itself.

  @rpath/Python3.framework/Versions/3.x/Python3

This means that we need to compute the path to the Python3.framework
and use that as the RPATH instead of the usual dylib's directory.
2020-04-30 10:42:03 -07:00
Adrian Prantl 681466f5e6 Allow lldb-test to combine -find with -dump-clang-ast
This patch threads an lldb::DescriptionLevel through the typesystem to
allow dumping the full Clang AST (level=verbose) of any lldb::Type in
addition to the human-readable source description (default
level=full). This type dumping interface is currently not exposed
through the SBAPI.

The application is to let lldb-test dump the clang AST of search
results. I need this to test lazy type completion of clang types in
subsequent patches.

Differential Revision: https://reviews.llvm.org/D78329
2020-04-17 11:01:20 -07:00
Kazuaki Ishizaki e9264b746b [lldb] NFC: Fix trivial typo in comments, documents, and messages
Differential Revision: https://reviews.llvm.org/D77460
2020-04-07 01:06:16 +09: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
Jonas Devlieghere 80c3ea4e63 Re-land "[lldb/CMake] Auto-generate the Initialize and Terminate calls for plugin"
This patch changes the way we initialize and terminate the plugins in
the system initializer. It uses an approach similar to LLVM's
TARGETS_TO_BUILD with a def file that enumerates the plugins.

Previous attempts to land this failed on the Windows bot because there's
a dependency between the different process plugins. Apparently
ProcessWindowsCommon needs to be initialized after all other process
plugins but before ProcessGDBRemote.

Differential revision: https://reviews.llvm.org/D73067
2020-02-18 19:16:07 -08:00
Jonas Devlieghere ebf9a99bbd [lldb/Plugin] Reject WASM and Hexagon in DynamicLoaderStatic
The WASM and Hexagon plugin check the ArchType rather than the OSType,
so explicitly reject those in the DynamicLoaderStatic.

Differential revision: https://reviews.llvm.org/D74780
2020-02-18 13:29:34 -08:00
Jonas Devlieghere 2d146aa2a2 [lldb/Plugin] Generate LLDB_PLUGIN_DECLARE with CMake
Generate the LLDB_PLUGIN_DECLARE macros with CMake and a def file. I'm
landing D73067 in pieces so I can bisect what exactly is breaking the
Windows bot.
2020-02-18 11:29:56 -08:00
Jonas Devlieghere 884a58948b [lldb/Plugin] Unconditionally initialize DynamicLoaderDarwinKernel
Other plugins depend on DynamicLoaderDarwinKernel and which means we
cannot conditionally enable/build this plugin based on the target
platform. This means that it will be past of the list of plugins
initialized once that's autogenerated.
2020-02-18 10:32:06 -08:00
Raphael Isemann f9568a9549 [lldb][NFC] Make all CompilerDeclContext parameters references instead of pointers
Summary:
All of our lookup APIs either use `CompilerDeclContext &` or `CompilerDeclContext *` semi-randomly it seems.
This leads to us constantly converting between those two types (and doing nullptr checks when going from
pointer to reference). It also leads to the confusing situation where we have two possible ways to express
that we don't have a CompilerDeclContex: either a nullptr or an invalid CompilerDeclContext (aka a default
constructed CompilerDeclContext).

This moves all APIs to use references and gets rid of all the nullptr checks and conversions.

Reviewers: labath, mib, shafik

Reviewed By: labath, shafik

Subscribers: shafik, arphaman, abidh, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74607
2020-02-18 08:58:36 +01:00
Jonas Devlieghere cdc514e4c6 [lldb] Update header guards to be consistent and compliant with LLVM (NFC)
LLDB has a few different styles of header guards and they're not very
consistent because things get moved around or copy/pasted. This patch
unifies the header guards across LLDB and converts everything to match
LLVM's style.

Differential revision: https://reviews.llvm.org/D74743
2020-02-17 23:15:40 -08:00
Jonas Devlieghere aa2ae6af81 [lldb/Plugins] Add missing initialize/terminate calls
Add missing initialize and terminate calls for DynamicLoaderHexagonDYLD
and ObjectFileJIT.
2020-02-17 21:28:16 -08:00
Jonas Devlieghere ccad194861 [lldb/Plugins] Rename initializers to match their plugin name.
Use LLDB_PLUGIN_DEFINE_ADV to make the name of the generated initializer
match the name of the plugin. This is a step towards generating the
initializers with a def file. I'm landing this change in pieces so I can
narrow down what exactly breaks the Windows bot.
2020-02-17 20:07:53 -08:00
Jonas Devlieghere bcde387f46 [lldb/Plugins] Initialize all ABI plugins by their plugin name 2020-02-17 19:55:43 -08:00
Jonas Devlieghere 50c9cd9526 Revert "[lldb/CMake] Auto-generate the Initialize and Terminate calls for plugin"
This is still failing spectacularly on the Windows bot and I still have
no clue what's going on.
2020-02-17 19:04:50 -08:00
Jonas Devlieghere 9b12dc98fd Re-land "[lldb/CMake] Auto-generate the Initialize and Terminate calls for plugin"
This patch changes the way we initialize and terminate the plugins in
the system initializer. It uses an approach similar to LLVM's
TARGETS_TO_BUILD with a def file that enumerates the plugins.

The previously landed patch got reverted because it was lacking:

 (1) A plugin definition for the Objective-C language runtime,
 (2) The dependency between the Static and WASM dynamic loader,
 (3) Explicit initialization of ScriptInterpreterNone for lldb-test.

All issues have been addressed in this patch.

Differential revision: https://reviews.llvm.org/D73067
2020-02-17 14:43:05 -08:00
Jonas Devlieghere 058cb1b47f Revert "[lldb/CMake] Auto-generate the Initialize and Terminate calls for plugin"
This temporarily reverts commit 7d6da329de
because it's causing test failures on the bots.
2020-02-17 12:34:21 -08:00
Jonas Devlieghere 7d6da329de [lldb/CMake] Auto-generate the Initialize and Terminate calls for plugin
This patch changes the way we initialize and terminate the plugins in
the system initializer. It uses an approach similar to LLVM's
TARGETS_TO_BUILD with a def file that enumerates the plugins.

Differential revision: https://reviews.llvm.org/D73067
2020-02-17 09:07:00 -08:00
Paolo Severini c1121908aa [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging
Add a dynamic loader plug-in class for WebAssembly modules.

Differential Revision: https://reviews.llvm.org/D72751
2020-02-17 12:42:23 +01:00
Jonas Devlieghere f10e2df7bc [lldb/Plugins] Have one initializer per ABI plugin
After the recent change that grouped some of the ABI plugins together,
those plugins ended up with multiple initializers per plugin. This is
incompatible with my proposed approach of generating the initializers
dynamically, which is why I've grouped them together in a new entry
point.

Differential revision: https://reviews.llvm.org/D74451
2020-02-13 21:49:38 -08:00
Jonas Devlieghere 6e30fd05c9 [lldb/Plugins] Move DynamicLoaderMacOS into DynamicLoaderMacOSXDYLD (NFCI)
Move the logic for initialization and termination for DynamicLoaderMacOS
into DynamicLoaderMacOSXDYLD so that there's one initializer for the
DynamicLoaderMacOSXDYLD plugin.
2020-02-12 13:44:20 -08:00
Jonas Devlieghere 654086cbf5 [lldb/Plugins] Move SymbolFileDWARFDebugMap into SymbolFileDWARF (NFCI)
Move the logic for initialization and termination for
SymbolFileDWARFDebugMap into SymbolFileDWARF so that there's one
initializer for the SymbolFileDWARF plugin.
2020-02-12 11:30:17 -08:00
Martin Storsjö 7002128ca9 [LLDB] Fix GCC warnings about extra semicolons. NFC. 2020-02-12 13:40:33 +02:00
Jonas Devlieghere 2d3ecade38 [lldb/Plugins] Move PlatformRemoteiOS into PlatformMacOSX (NFCI)
Move the logic for initialization and termination for PlatformRemoteiOS
into PlatformMacOSX, like we did for the other Darwin platforms in
a731c6ba94.
2020-02-11 15:54:36 -08:00
Jonas Devlieghere 3e70a91963 [lldb/Plugin] Use LLDB_PLUGIN_DECLARE to forward declare plugin initializers
Apparently Linux and Windows have the exact opposite behavior when it
comes to inline declarations of external functions. On Linux they're
considered to be part of the lldb_private namespace, while on Windows
they're considered to be part of the top level namespace. Somehow on
macOS, it doesn't really matter and both are fine...

At this point I don't know what to do, so I'm just adding the
LLDB_PLUGIN_DECLARE macros again as originally proposed in D74245.
2020-02-07 18:02:21 -08:00
Jonas Devlieghere fbb4d1e43d [lldb/Plugins] Use external functions to (de)initialize plugins
This is a step towards making the initialize and terminate calls be
generated by CMake, which in turn is towards making it possible to
disable plugins at configuration time.

Differential revision: https://reviews.llvm.org/D74245
2020-02-07 15:28:27 -08:00
Pavel Labath e21b39a86d [lldb] Group ABI plugins
Summary:
There's a fair amount of code duplication between the different ABI plugins for
the same architecture (e.g. ABIMacOSX_arm & ABISysV_arm). Deduplicating this
code is not very easy at the moment because there is no good place where to put
the common code.

Instead of creating more plugins, this patch reduces their number by grouping
similar plugins into a single folder/plugin. This makes it easy to extract
common code to a (e.g.) base class, which can then live in the same folder.

The grouping is done based on the underlying llvm target for that architecture,
because the plugins already require this for their operation.

Reviewers: JDevlieghere, jasonmolenda, jfb

Subscribers: sdardis, nemanjai, mgorny, kristof.beyls, fedor.sergeev, kbarton, jrtc27, atanasyan, jsji, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74138
2020-02-07 09:51:38 -08:00
Pavel Labath 40efa65de8 Revert "[LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging"
This patch has a couple of outstanding issues. The test is not python3
compatible, and it also seems to fail with python2 (at least under some
circumstances) due to an overambitious assertion.

This reverts the patch as well as subsequent fixup attempts:
014ea93376,
f5f70d1c8f.
4697e701b8.
5c15e8e682.
3ec28da6d6.
2020-02-05 16:22:19 -08:00
Derek Schuff f5f70d1c8f Add missing directory from 3ec28da6
Also revert 4697e701b8, restoring the original patch from
https://reviews.llvm.org/D72751
2020-02-05 15:49:48 -08:00
Jonas Devlieghere 4697e701b8 Partially revert "[LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging"
This temporarily and partially reverts 3ec28da6d6 because it's missing
a directory.
2020-02-05 15:32:54 -08:00
Paolo Severini 3ec28da6d6 [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging
Add a dynamic loader plug-in class for WebAssembly modules.

Differential Revision: https://reviews.llvm.org/D72751
2020-02-05 14:49:36 -08:00
Alex Langford 8be30215fe [lldb] Move clang-based files out of Symbol
Summary:
This change represents the move of ClangASTImporter, ClangASTMetadata,
ClangExternalASTSourceCallbacks, ClangUtil, CxxModuleHandler, and
TypeSystemClang from lldbSource to lldbPluginExpressionParserClang.h

This explicitly removes knowledge of clang internals from lldbSymbol,
moving towards a more generic core implementation of lldb.

Reviewers: JDevlieghere, davide, aprantl, teemperor, clayborg, labath, jingham, shafik

Subscribers: emaste, mgorny, arphaman, jfb, usaxena95, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D73661
2020-01-31 12:20:10 -08:00
Raphael Isemann 6e3b0cc2fb [lldb][NFC] Rename ClangASTContext to TypeSystemClang
Summary:
This commit renames ClangASTContext to TypeSystemClang to better reflect what this class is actually supposed to do
(implement the TypeSystem interface for Clang). It also gets rid of the very confusing situation that we have both a
`clang::ASTContext` and a `ClangASTContext` in clang (which sometimes causes Clang people to think I'm fiddling
with Clang's ASTContext when I'm actually just doing LLDB work).

I also have plans to potentially have multiple clang::ASTContext instances associated with one ClangASTContext so
the ASTContext naming will then become even more confusing to people.

Reviewers: #lldb, aprantl, shafik, clayborg, labath, JDevlieghere, davide, espindola, jdoerfert, xiaobai

Reviewed By: clayborg, labath, xiaobai

Subscribers: wuzish, emaste, nemanjai, mgorny, kbarton, MaskRay, arphaman, jfb, usaxena95, jingham, xiaobai, abidh, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72684
2020-01-23 10:09:14 +01:00
Jonas Devlieghere 1d1ebb9e59 [lldb/Initializers] Move all ObjC initializers into AppleObjCRuntime
AppleObjCRuntime is the main entry point to the plugin with the same
name. This is part of a greater refactoring to auto generate the
initializers. NFC.

Differential revision: https://reviews.llvm.org/D73121
2020-01-21 22:24:32 -08:00
Jonas Devlieghere be9604247e [lldb/Plugin] Move DisassemblerLLVMC for consistency with plugin (NFC)
Rename the DisassemblerLLVMC directory from llvm to LLVMC to match the
plugin name.
2020-01-21 15:17:29 -08:00
Jonas Devlieghere fc1e855112 [lldb/Plugin] Rename MainThreadCheckerRuntime for consistency with plugin (NFC)
Renames MainThreadCheckerRuntime to
InstrumentationRuntimeMainThreadChecker to be consistent with the
directory structure and plugin name.
2020-01-21 15:02:41 -08:00
Jonas Devlieghere 623c3c4cf9 [lldb/Plugin] Rename UBSanRuntime for consistency with plugin (NFC)
Renames UBSanRuntime to InstrumentationRuntimeUBSan to be consistent
with the directory structure and plugin name.
2020-01-21 15:02:41 -08:00
Jonas Devlieghere 7745990dd9 [lldb/Plugin] Rename TSanRuntime for consistency with plugin (NFC)
Renames TSanRuntime to InstrumentationRuntimeTSan to be
consistent with the directory structure and plugin name.
2020-01-21 15:02:41 -08:00
Jonas Devlieghere 0feedebf4f [lldb/Plugin] Rename AddressSanitizerRuntime for consistency with plugin (NFC)
Renames AddressSanitizerRuntime to InstrumentationRuntimeASan to be
consistent with the directory structure and plugin name.
2020-01-21 15:02:41 -08:00
Jonas Devlieghere cf263807a6 [lldb/tools] Update lldb-test's system initializer
After a731c6ba94 the initializer only has to call the PlatformMacOSX
to initialize all the macOS platforms.
2020-01-21 09:58:35 -08:00
Raphael Isemann c3ab790c8f [lldb][NFC] Resynchronize Init/Terminate calls in SystemInitializerFull/Test.cpp files.
These files should do the more or less the same initialize/terminate calls in the
same order. This just reverts all the differences that have piled up over time
in the SystemInitializerTest that people keep forgetting about.
2020-01-17 11:34:59 +01:00