Commit Graph

22069 Commits

Author SHA1 Message Date
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
Raphael Isemann b0060c3a78 [lldb] Make comparing RegisterInfo::[alt_]name's pointer value less footy-shooty
Comparing those two `const char *` values relies on the assumption that both
strings were created by a ConstString. Let's check that assumption with an
assert as otherwise this code silently does nothing and that's not great.
2020-02-19 13:19:41 +01:00
Djordje Todorovic faff707db8 Reland "[DebugInfo] Enable the debug entry values feature by default"
Differential Revision: https://reviews.llvm.org/D73534
2020-02-19 11:12:26 +01:00
Raphael Isemann a3093bfb3e [lldb] Let TestCppConstructors pass without fix-it intervention
This should use -> instead of '.', but the fix-it functionality of
the expression evaluator saved us here. Let's use the proper syntax
in the first place as we don't want to test fix-its here.
2020-02-19 11:02:10 +01:00
Raphael Isemann 3ed0ce458c [lldb] Put Host/common headers in a module
This directory escaped the modularization effort it seems. Just adding
this to the Host module along with the other common headers, which should
make this code less likely to break under modules and speed up compilation.
2020-02-19 10:47:46 +01:00
Raphael Isemann 785df61680 [lldb] Let TypeSystemClang::GetDisplayTypeName remove anonymous and inline namespaces.
Summary:
Currently when printing data types we include implicit scopes such as inline namespaces or anonymous namespaces.
This leads to command output like this (for `std::set<X>` with X being in an anonymous namespace):

```
(lldb) print my_set
(std::__1::set<(anonymous namespace)::X, std::__1::less<(anonymous namespace)::X>, std::__1::allocator<(anonymous namespace)::X> >) $0 = size=0 {}
```

This patch removes all the implicit scopes when printing type names in TypeSystemClang::GetDisplayTypeName
so that our output now looks like this:

```
(lldb) print my_set
(std::set<X, std::less<X>, std::allocator<X> >) $0 = size=0 {}
```

As previously GetDisplayTypeName and GetTypeName had the same output we actually often used the
two as if they are the same method (they were in fact using the same implementation), so this patch also
fixes the places where we actually want the display type name and not the actual type name.

Note that this doesn't touch the `GetTypeName` class that for example the data formatters use, so this patch
is only changes the way we display types to the user. The full type name can also still be found when passing
'-R' to see the raw output of a variable in case someone is somehow interested in that.

Partly fixes rdar://problem/59292534

Reviewers: shafik, jingham

Reviewed By: shafik

Subscribers: christof, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74478
2020-02-19 10:30:11 +01:00
Raphael Isemann b4608efc0b [lldb][NFC] Add a missing test case to TestCppConstructors.py 2020-02-19 10:24:59 +01:00
Raphael Isemann 2bab1738f3 [lldb] Make TestFormatters.py not rely on working constructor calls
All calls to operator new in this test fail for me with:
```
expression --show-types -- *(new foo(47))`
Error output:
error: Execution was interrupted, reason: internal c++ exception breakpoint(-6)..
The process has been returned to the state before expression evaluation.
```

As calling operator new isn't the idea of this test, this patch moves that
logic to the binary with some new_* utility functions and explicitly tests
this logic in the constructor test (where we can isolate the failures and
skip them on Linux).
2020-02-19 10:21:36 +01:00
Jonas Devlieghere 80b2e3cc53 [lldb/Core] Remove more duplicate code in PluginManager (NFCI)
The PluginManager contains a lot of duplicate code. I already removed a
bunch of it by introducing the templated PluginInstance class, and this
is the next step. The PluginInstances class combines the mutex and the
vector and implements the common operations.

To accommodate plugin instances with additional members it is possible
to access the underlying vector and mutex. The methods to query these
fields make use of that.

Differential revision: https://reviews.llvm.org/D74816
2020-02-18 23:58:29 -08:00
Jonas Devlieghere 7c4b70402c [lldb] Sort forward declarations in lldb-forward.h
Sort forward declarations alphabetically. Also remove the two LLVM
forward declares as they frankly don't belong here.
2020-02-18 20:22:52 -08:00
Jonas Devlieghere d7db094ef7 [lldb] Move ArchitectureCreateInstance into ldb-private-interfaces
There's no reason this should be the only one living in the
PluginManager itself.
2020-02-18 20:19:54 -08:00
Jonas Devlieghere e68205844d [lldb/Docs] Update the features matrix
Use YES/NO instead of OK, known issues instead of bugs and fix some
other small inconsistencies
2020-02-18 20:08:43 -08:00
Jonas Devlieghere ae73891164 [lldb/Docs] Update the Windows documentation
Update the build instructions for Windows with my recent experience.
2020-02-18 19:53:36 -08: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 bad1389f12 [lldb/Core] Remove dead Get*PluginCreateCallbackForPluginName (NFC)
The plugin manager had dedicated Get*PluginCreateCallbackForPluginName
methods for each type of plugin, and only a small subset of those were
used. This removes the dead duplicated code.
2020-02-18 17:36:26 -08:00
Jonas Devlieghere 7b76767dbc [lldb/Core] Remove blatant code duplication by using a template (NFC)
Remove a bunch of duplicate code by using a templated base class.
2020-02-18 17:19:47 -08:00
Davide Italiano 42cab985fd [TestTargetCommand] Remove another reference to a stale rdar.
The test passes, and the rdar is closed.
2020-02-18 13:39:37 -08:00
Davide Italiano 2560a93b70 [TestTargetCommand] `target var` without a process doesn't work on arm64e.
lldb needs to know about chains of authenticated relocations.

<rdar://problem/37773624>
2020-02-18 13:38:27 -08:00
Davide Italiano 3f5e0501b5 [TestGlobalVariables] Remove a reference to a stale rdar.
The bug has been fixed and the rdar is closed. No need to
clutter the test.
2020-02-18 13:31:14 -08:00
Davide Italiano 0159c21119 [TestGlobalVariables] `target var` without a process doesn't work on arm64e.
lldb needs to know about chains of authenticated relocations.

<rdar://problem/37773624>
2020-02-18 13:30:51 -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
Jan Kratochvil aa3e99dc85 [lldb] [nfc] Separate DIERef vs. user_id_t: GetForwardDeclClangTypeToDie()
Reasons are the same as for D74637.

Differential Revision: https://reviews.llvm.org/D74690
2020-02-18 18:09:39 +01:00
Djordje Todorovic 2bf44d11cb Revert "Reland "[DebugInfo] Enable the debug entry values feature by default""
This reverts commit rGa82d3e8a6e67.
2020-02-18 16:38:11 +01:00