Commit Graph

1818 Commits

Author SHA1 Message Date
Jonas Devlieghere b453caf111 [lldb/Reproducers] Change the way we instrument void* arguments
The reproducer instrumentation cannot automatically serialize and
deserialize void* arguments. Currently we deal with this by explicitly
preventing these methods from being instrumented. This has the undesired
side effect of breaking replay when that method returns a value later
used by another SB API call.

The solution is to change our approach and instrument these methods.
Instead of using the DUMMY macro, we just make (de)serialization of the
void pointer a NOOP and always return a nullptr.
2020-02-04 19:05:13 -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
Hector Diaz 45e3f6660c Auto-completion bug fix for dot operator
Summary:
There was a bug on LLDB VSCode where there was the following behavior:

//Code

```
struct foo {
    int bar:
};
...
foo my_foo = {10};
```

Trying to auto-complete my_foo.b with my_foo.bar resulted instead with my_foo.my_foo.bar

This diff fixes this bug and adds some tests to check correct behavior.

It also fixes the same bug using the arrow operator (->) when user manually requests completions.
TODO: Fix bug where no recommended completions are automatically shown with arrow operator

{F11249959}

{F11249958}

Reviewers: wallace

Reviewed By: wallace

Subscribers: teemperor, labath, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D73506
2020-01-30 16:02:58 -08:00
Benjamin Kramer adcd026838 Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.

This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-28 23:25:25 +01:00
Jonas Devlieghere 96f3ea0d21 [lldb/debugserver] Implement hardware breakpoints for x86_64 and i386
This implements hardware breakpoints for x86_64 and i386 in debugserver.
It's based on Pedro's patch sent to lldb-commits [1] although most of it
is the same as the existing hardware watchpoint implementation.

[1] http://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20200113/060327.html

Differential revision: https://reviews.llvm.org/D72985
2020-01-24 15:07:31 -08:00
Jonas Devlieghere 9902c8e3c6 [lldb/debugserver] Unify the breakpoint/watchpoint interface (NFCI)
Unify the interface for enabling and disabling breakpoints with their
watchpoint counterpart. This allows both to go through
DoHardwareBreakpointAction.

Differential revision: https://reviews.llvm.org/D72981
2020-01-24 15:07:31 -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
Jason Molenda 1f45914b42 Embed a zero-length /dev/null in darwin-debug for the special section.
Fred suggested that instead of embedded CMakeLists.txt in the binary as
the contents of a special section, see if /dev/null would work.  It
does.
2020-01-22 15:50:33 -08: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
Jason Molenda 83a131b276 Fix an over-suspend bug with LaunchInNewTerminalWithAppleScript sessions
When launching an inferior in a new terminal window via AppleScript
and the darwin-debug helper program, we could often end up with the
inferior process having a too-high suspend count, and it would never
resume execution.

lldb tries to wait until darwin-debug has finished its work and has
launched the inferior (WaitForProcessToSIGSTOP) but this wasn't
working correctly - and cannot be made to work.

This patch removes WaitForProcessToSIGSTOP, adds a special tiny
segment to the darwin-debug executable so it can be identified as
that binary (ExecExtraSuspend), and adds code to debugserver to
detect this segment.  When debugserver sees this segment, it notes
that the next exec will be done with a launch-suspended flag.  When
the next exec happens, debugserver forces an extra task_resume when
we resume the inferior.

An alternative approach would be if lldb could detect when the
inferior has been launched by darwin-debug unambiguously; monitoring
when the unix socket between darwin-debug and lldb was closed would
have been a reasonable way to do this too.

<rdar://problem/29760580>

Differential Revision: https://reviews.llvm.org/D72963
2020-01-21 14:55:46 -08:00
Vedant Kumar 441aebc523 [debugserver] Delete stale code referencing ppc 2020-01-21 11:04:04 -08:00
Vedant Kumar 9aba2ced34 [debugserver] Delete macOS/PPC debug server implementation
macOS/PPC support was dropped in 10.6 (Snow Leopard).

Differential Revision: https://reviews.llvm.org/D69524
2020-01-21 10:59:38 -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
Jonas Devlieghere 2981eceec3 [debugserver] Share code between Enable/DisableHardwareWatchpoint (NFC)
This extract the common functionality of enabling and disabling hardware
watchpoints into a single function.

Differential revision: https://reviews.llvm.org/D72971
2020-01-18 11:36:56 -08:00
Vedant Kumar 510758dae2 debugserver: Pass -arch flags to mig invocation as needed
Specify -isysroot and any necessary -arch flags in the `mig` invocation
when CMAKE_OSX_ARCHITECTURES is set (needed for the bridgeOS build).
2020-01-17 13:11:54 -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
Paolo Severini 9b3254dbf9 [LLDB] Add SymbolVendorWasm plugin for WebAssembly debugging
Add plugin class SymbolVendorWasm, with the logic to manage debug symbols
for Wasm modules.

Reviewers: clayborg, labath, aprantl, sbc100, teemperor

Reviewed By: labath

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72650
2020-01-16 09:36:17 -08:00
Jonas Devlieghere 066e817b42 [lldb/Reproducers] Add a flag to always generating a reproducer
Add a flag which always generates a reproducer when normally it would be
discarded. This is meant for testing purposes to capture a debugger
session without modification the session itself.
2020-01-15 19:45:54 -08:00
Vedant Kumar 1e89fb947e debugserver: Cut dependency on intrinsics_gen
debugserver does not depend on intrinsics_gen or on llvm.
2020-01-15 17:20:10 -08:00
Jonas Devlieghere 9efd57e3b7 [lldb/Tools] Remove lldb-mi.exports
lldb-mi was removed from the repo a while ago.
2020-01-15 16:50:17 -08:00
Paolo Severini 4bafceced6 [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging
Summary:
This is the first in a series of patches to enable LLDB debugging of
WebAssembly targets.

Current versions of Clang emit (partial) DWARF debug information in WebAssembly
modules and we can leverage this debug information to give LLDB the ability to
do source-level debugging of Wasm code that runs in a WebAssembly engine.

A way to do this could be to use the remote debugging functionalities provided
by LLDB via the GDB-remote protocol. Remote debugging can indeed be useful not
only to connect a debugger to a process running on a remote machine, but also to
connect the debugger to a managed VM or script engine that runs locally,
provided that the engine implements a GDB-remote stub that offers the ability to
access the engine runtime internal state.

To make this work, the GDB-remote protocol would need to be extended with a few
Wasm-specific custom query commands, used to access aspects of the Wasm engine
state (like the Wasm memory, Wasm local and global variables, and so on).
Furthermore, the DWARF format would need to be enriched with a few Wasm-specific
extensions, here detailed: https://yurydelendik.github.io/webassembly-dwarf.

This CL introduce classes **ObjectFileWasm**, a file plugin to represent a Wasm
module loaded in a debuggee process. It knows how to parse Wasm modules and
store the Code section and the DWARF-specific sections.

Reviewers: jasonmolenda, clayborg, labath

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71575
2020-01-15 16:25:35 -08:00
Alex Langford 6d57511e0b [lldb-server] Prefer target_include_directories
In the documentation of `include_directories`, it notes that
`target_include_directories` is preferred because it affects
specific targets intead of propagating include search paths
to the entire project.
2020-01-13 14:54:57 -08:00
Alex Langford 2bb154591f [lldb-server] Remove dead CMake code
No files in lldb-server are including a header from a plugin without the
whole path to the header relative to the lldb source directory. There is
no need to include the specific directories as a result.
2020-01-13 11:41:30 -08:00
Jason Molenda d44a074317 Save more descriptive error msg from FBS/BKS, relay it up to lldb.
When lldb requests an app launch through FrontBoard/BackBoard,
we get back an NSError object if there was a problem with an
integer error code and a descriptive text string.  debugserver
would log the descriptive text string to the console, but it
would only save the error code value, ask for the
much-less-specific name of that error code, and send that very
generic error word back to lldb.

This patch saves the longer description of the failure when
available, and sends that to lldb.  If unavailable, it falls
back to sending up the generic description of the error code
as it was doing before.

This only impacts the iOS on-device debugserver.

<rdar://problem/49953304>
2020-01-08 18:47:35 -08:00
Jason Molenda 5e2f4dc37b Rewrite comment about what watchpoints Aarch64 supports. 2020-01-07 16:13:23 -08:00
Raphael Isemann 65fdb34219 [lldb][NFC] Use static_cast instead of reinterpret_cast where possible
Summary: There are a few places in LLDB where we do a `reinterpret_cast` for conversions that we could also do with `static_cast`. This patch moves all this code to `static_cast`.

Reviewers: shafik, JDevlieghere, labath

Reviewed By: labath

Subscribers: arphaman, usaxena95, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D72161
2020-01-07 13:03:56 +01:00
Raphael Isemann f9f49d3594 [lldb][NFC] Return a reference from ClangASTContext::getASTContext and remove dead nullptr checks
ClangASTContext::getASTContext() currently returns a ptr but we have an assert there since a
while that the ASTContext is not a nullptr. This causes that we still have a lot of code
that is doing nullptr checks on the result of getASTContext() which is all unreachable code.

This patch changes the return value to a reference to make it clear this can't be a nullptr
and deletes all the nullptr checks.
2019-12-21 22:51:35 +01:00
Jonas Devlieghere 4e26cf2cfb [lldb/CMake] Rename LLDB_DISABLE_PYTHON to LLDB_ENABLE_PYTHON
This matches the naming scheme used by LLVM and all the other optional
dependencies in LLDB.

Differential revision: https://reviews.llvm.org/D71482
2019-12-13 13:41:11 -08:00
Jonas Devlieghere 3011d55f72 [lldb/Host] Use cmakedefine01 for LLDB_ENABLE_POSIX
Rename LLDB_DISABLE_POSIX to LLDB_ENABLE_POSIX and use cmakedefine01 for
consistency.
2019-12-13 10:00:59 -08:00
Serhiy Redko 6dad5e441d The field ‘totalFrames’ which is total number of frames available, is mandatory in StackTraces response for VSCode extension that implements DAP and declares capability 'supportsDelayedStackTraceLoading':
"The debug adapter supports the delayed loading of parts of the stack,
which requires that both the 'startFrame' and 'levels' arguments and the
'totalFrames' result of the 'StackTrace' request are supported."

Lack of this field makes VSCode incorrectly display stack traces information

D71034
2019-12-09 10:43:50 -08:00
Jason Molenda e11df58580 Upstream debugserver arm64e support.
The changes are minor; primarily debugserver needs to go through
accessor functions/macros when changing pc/fp/sp/lr, and debugserver
needs to clear any existing pointer auth bits from values in two
cases.  debugserver can fetch the number of bits used for addressing
from a sysctl, and will include that in the qHostInfo reply.  Update
qHostInfo documentation to document it.
2019-12-04 15:20:56 -08:00
Jonas Devlieghere 62827737ac [lldb/Reproducer] Add version check
To ensure a reproducer works correctly, the version of LLDB used for
capture and replay must match. Right now the reproducer already contains
the LLDB version. However, this is purely informative. LLDB will happily
replay a reproducer generated with a different version of LLDB, which
can cause subtle differences.

This patch adds a version check which compares the current LLDB version
with the one in the reproducer. If the version doesn't match, LLDB will
refuse to replay. It also adds an escape hatch to make it possible to
still replay the reproducer without having to mess with the recorded
version. This might prove useful when you know two versions of LLDB
match, even though the version string doesn't. This behavior is
triggered by passing a new flag -reproducer-skip-version-check to the
lldb driver.

Differential revision: https://reviews.llvm.org/D70934
2019-12-03 07:54:42 -08:00
Pavel Labath 38870af859 [lldb] Remove FileSpec->CompileUnit inheritance
Summary:
CompileUnit is a complicated class. Having it be implicitly convertible
to a FileSpec makes reasoning about it even harder.

This patch replaces the inheritance by a simple member and an accessor
function. This avoid the need for casting in places where one needed to
force a CompileUnit to be treated as a FileSpec, and does not add much
verbosity elsewhere.

It also fixes a bug where we were wrongly comparing CompileUnit& and a
CompileUnit*, which compiled due to a combination of this inheritance
and the FileSpec*->FileSpec implicit constructor.

Reviewers: teemperor, JDevlieghere, jdoerfert

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70827
2019-11-29 11:44:45 +01:00
Pavel Labath 12284e54b4 [lldb] fix a -Wcast-qual warning 2019-11-26 14:49:16 +01:00
Adrian Prantl c0eeea5d74 Register Objective-C property accessors with their property decls.
This is a correctness fix for the Clang DWARF parser that primarily
matters for swift-lldb's ability to import Clang types that were
reconstructed from DWARF into Swift.

rdar://problem/55025799

Differential Revision: https://reviews.llvm.org/D70580
2019-11-22 09:55:25 -08:00
Jonas Devlieghere 6c2e4e8801 [Driver] Fix newline at the end of help output
Print a regular newline at the end of the help output. The current
string literal seems to throw off shells.
2019-11-21 13:36:39 -08:00
Jonas Devlieghere b26d9e417d [Reproducer] Instruct users to replay reproducer
Improve the message printed when LLDB crashes by asking the user to
replay the reproducer before attaching it to a bugreport..

********************
Crash reproducer for lldb version 10.0.0 (git@github.com:llvm/llvm-project.git revision ...)
  clang revision ...
  llvm revision ...

Reproducer written to '/path/to/reproducer'

Before attaching the reproducer to a bug report:
 - Look at the directory to ensure you're willing to share its content.
 - Make sure the reproducer works by replaying the reproducer.

Replay the reproducer with the following command:
./bin/lldb -replay /path/to/reproducer
********************
2019-11-21 13:25:53 -08:00
Jonas Devlieghere bb775bee21 [Docs] Generate the LLDB man page with Sphinx
This patch replaces the existing out-of-date man page for lldb and
replaces it with an RST file from which sphinx generates the actual
troff file. This is similar to how man pages are generated for the rest
of the LLVM utilities.

The man page is generated by building the `docs-lldb-man` target.

Differential revision: https://reviews.llvm.org/D70514
2019-11-21 10:04:11 -08:00
Jonas Devlieghere b03374584d [Driver] Fix missing space in lldb --help output. 2019-11-20 13:49:22 -08:00
Jonas Devlieghere c8dfe90729 [Reproducer] Generate LLDB reproducer on crash
This patch hooks the reproducer infrastructure with the signal handlers.
When lldb crashes with reproducers capture enabled, it will now generate
the reproducer and print a short message the standard out. This doesn't
affect the pretty stack traces, which are still printed before.

This patch also introduces a new reproducer sub-command that
intentionally raises a given signal to test the reproducer signal
handling.

Currently the signal handler is doing too much work. Instead of copying
over files into the reproducers in the signal handler, we should
re-invoke ourselves with a special command line flag that looks at the
VFS mapping and performs the copy.

This is a NO-OP when reproducers are disabled.

Differential revision: https://reviews.llvm.org/D70474
2019-11-20 13:14:16 -08:00
Vedant Kumar af331cbe14 [debugserver] Set arch based on TARGET_TRIPLE
Use TARGET_TRIPLE instead of LLVM_DEFAULT_TARGET_TRIPLE, as the latter
isn't exported by LLVMConfig.cmake, which means arch detection fails if
lldb is built separately from llvm.
2019-11-20 12:12:47 -08:00
Jonas Devlieghere b117ec8be0 [LLDB] Fix formatting in the driver (NFC) 2019-11-19 10:23:56 -08:00
Vedant Kumar 4624e83ce7 [Signal] Allow llvm clients to opt into one-shot SIGPIPE handling
Allow clients of the llvm library to opt-in to one-shot SIGPIPE
handling, instead of forcing them to undo llvm's SIGPIPE handler
registration (which is brittle).

The current behavior is preserved for all llvm-derived tools (except
lldb) by means of a default-`true` flag in the InitLLVM constructor.

This prevents "IO error" crashes in long-lived processes (lldb is the
motivating example) which both a) load llvm as a dynamic library and b)
*really* need to ignore SIGPIPE.

As llvm signal handlers can be installed when calling into libclang
(say, via RemoveFileOnSignal), thereby overriding a previous SIG_IGN for
SIGPIPE, there is no clean way to opt-out of "exit-on-SIGPIPE" in the
current model.

Differential Revision: https://reviews.llvm.org/D70277
2019-11-18 10:27:27 -08:00
Alex Cameron 10b8514343 [lldb] Fix JSON parser to allow empty arrays
Summary:
Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=39405
```
alexc@kitty:~/work/wiredtiger/build_posix$ cat breakpoint.json
[{"Breakpoint" : {"BKPTOptions" : {"AutoContinue" : false,"ConditionText" : "","EnabledState" : true,"IgnoreCount" : 0,"OneShotState" : false},"BKPTResolver" : {"Options" : {"NameMask" : [56],"Offset" : 0,"SkipPrologue" : true,"SymbolNames" : ["__wt_btcur_search"]},"Type" : "SymbolName"},"Hardware" : false,"SearchFilter" : {"Options" : {},"Type" : "Unconstrained","Foo" : []}}}]
```
**Before**
```
(lldb) breakpoint read --file breakpoint.json
error: Invalid JSON from input file: /home/alexc/work/wiredtiger/build_posix/breakpoint.json.
```
**After**
```
(lldb) breakpoint read --file breakpoint.json
New breakpoints:
Breakpoint 1: where = libwiredtiger-3.2.2.so`__wt_btcur_search + 15 at bt_cursor.c:522:5, address = 0x00007ffff576ab2f
```

Reviewers: xbolva00, davide, labath

Reviewed By: davide, labath

Subscribers: mgorny, jingham, labath, davide, JDevlieghere, lldb-commits

Tags: #llvm, #lldb

Differential Revision: https://reviews.llvm.org/D68179
2019-11-18 15:12:55 +01:00
Walter Erquinigo 2c7c528d7a [lldb-vscode] support the completion request
Summary:
The DAP has a completion request that has been unimplemented. It allows showing autocompletion tokens inside the Debug Console.
I implemented it in a very simple fashion mimicking what the user would see when autocompleting an expression inside the CLI.
There are two cases: normal variables and commands. The latter occurs when a text is prepepended with ` in the Debug Console.
These two cases work well and have tests.

Reviewers: clayborg, aadsm

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D69873
2019-11-15 17:37:55 -08:00
Jonas Devlieghere 81104ea9ab [CMake] Configure the Info.plist so it contains a real version number.
Use CMake to configure the Info.plist file so that we have a real
version number in things like crash reporter.
2019-11-15 09:50:42 -08:00
Jonas Devlieghere fa6984a3de [LLDB] Don't install the pretty stack trace handler twice.
I noticed that currently we are printing LLVM's pretty stack trace
twice. The reason is that we're calling PrintStackTraceOnErrorSignal in
addition to InitLLVM, which besides some other useful things, also
register LLVM's pretty stack trace handler.

Differential revision: https://reviews.llvm.org/D70216
2019-11-13 17:35:58 -08:00
Jonas Devlieghere ad882774fe [LLDB] Fix a bunch of -Wdocumentation warnings 2019-11-13 12:28:10 -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
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
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
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
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
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
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 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
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
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
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
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
Martin Storsjo 807dbee366 [LLDB] [lldb-server] Use llvm::InitLLVM for doing unicode conversion of arguments for windows
This should allow lldb-server to operate on files with non-ascii
pathnames.

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

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

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

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

llvm-svn: 374526
2019-10-11 08:44:51 +00:00
Alex Langford 887707e29d [lldb-test] Remove unused header
llvm-svn: 374468
2019-10-10 22:43:03 +00:00
Jason Molenda d6e9e99cec Change debugserver to use the brk #0 for breakpoints.
debugserver had been using an instruction that would work
for armv7 or aarch64 processes, but we don't have armv7 code
running on arm64 devices any more so this is unnecessary.

<rdar://problem/56133118>

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

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 374238
2019-10-09 21:50:49 +00:00
Davide Italiano 2b371fbedd [debugserver] Include the correct header.
<rdar://problem/55916729>

llvm-svn: 373957
2019-10-07 20:35:22 +00:00
Davide Italiano 68d01d9429 [debugserver] Don't link against Cocoa, it's not needed.
<rdar://problem/55916729>

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

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

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

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

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

Reviewers: JDevlieghere, labath

Reviewed By: labath

Subscribers: mgorny, abidh, lldb-commits

Tags: #lldb

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

llvm-svn: 373723
2019-10-04 09:52:26 +00:00
Jonas Devlieghere e09adb400b [JSON] Use LLVM's library for argdumper
This patch replaces the LLDB's JSON implementation with the one from
LLVM in argdumper.

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

llvm-svn: 373361
2019-10-01 17:41:55 +00:00
Adrian Prantl d4d428ef92 Remove unused "append" parameter from FindTypes API
I noticed that SymbolFileDWARFDebugMap::FindTypes was implementing it
incorrectly (passing append=false in a for-loop to recursive calls to
FindTypes would yield only the very last set of results), but instead
of fixing it, removing it seemed like an even better option.

rdar://problem/54412692

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

llvm-svn: 373224
2019-09-30 16:42:28 +00:00
Jonas Devlieghere 0b1b3c6068 [debugserver] Add --version/-V command line option to debugserver.
When not running under a TTY the output is buffered and not flushed
before debugserver exits which makes it impossible to parse the version
string. This adds a -V/--version command that just prints the version to
stdout and exits with an exit code zero.

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

llvm-svn: 373127
2019-09-27 21:26:44 +00:00
Alex Langford 7dfb095b88 [lldb-vscode] correctly handle multiple sourceMap entries
Summary:
`lldb-vscode` concatenates a string of sourceMap entries
specified in the config, but fails to put a space between
each entry, which causes the settings command to fail.
This patch adds a space between each mapping.

Patch by Richard Howell

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

llvm-svn: 373016
2019-09-26 21:18:37 +00:00
Pavel Labath e8f0613185 SystemInitializer: Define macros for experimental targets too
llvm-svn: 372998
2019-09-26 17:15:18 +00:00
Pavel Labath 8865ebb509 SystemInitializer: Use Targets.def to selectively initialize ABI plugins
This avoids having to define additional macros in the cmake file, and
and also makes the logic in the cpp files more compact. It is also
easily extendible to other plugin types (instruction emulation?) that
should only be initialized if the corresponding llvm target is built.

Thanks to Ilya Birukov for pointing me to this file.

llvm-svn: 372952
2019-09-26 09:47:32 +00:00
Pavel Labath d0b44dbefd Have ABI plugins vend llvm MCRegisterInfo data
Summary:
I was recently surprised to learn that there is a total of 2 (two) users
of the register info definitions contained in the ABI plugins. Yet, the
defitions themselves span nearly 10kLOC.
The two users are:
 - dwarf expression pretty printer
 - the mechanism for augmenting the register info definitions obtained
   over gdb-remote protocol (AugmentRegisterInfoViaABI)

Both of these uses need the DWARF an EH register numbers, which is
information that is already available in LLVM. This patch makes it
possible to do so.

It adds a GetMCRegisterInfo method to the ABI class, which every class
is expected to implement. Normally, it should be sufficient to obtain
the definitions from the appropriate llvm::Target object (for which I
provide a utility function), but the subclasses are free to construct it
in any way they deem fit.

We should be able to always get the MCRegisterInfo object from llvm,
with one important exception: if the relevant llvm target was disabled
at compile time. To handle this, I add a mechanism to disable the
compilation of ABI plugins based on the value of LLVM_TARGETS_TO_BUILD
cmake setting. This ensures all our existing are able to create their
MCRegisterInfo objects.

The new MCRegisterInfo api is not used yet, but the intention is to make
use of it in follow-up patches.

Reviewers: jasonmolenda, aprantl, JDevlieghere, tatyana-krasnukha

Subscribers: wuzish, nemanjai, mgorny, kbarton, atanasyan, lldb-commits

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

llvm-svn: 372862
2019-09-25 13:03:04 +00:00
Jonas Devlieghere cb4cda2d45 [CMake] Copy over the system debugserver when using LLDB_USE_SYSTEM_DEBUGSERVER
r366433 broke support for the system debugserver. Although the change
was well-intended, it (presumably) unintentionally removed the logic to
copy over the debugserver. As a result, even with
LLDB_USE_SYSTEM_DEBUGSERVER enabled, we ended up building, signing and
using the just-built debugserver.

This patch partially recovers the old behavior: when
LLDB_USE_SYSTEM_DEBUGSERVER is set we don't build debugserver and just
copy over the system one.

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

llvm-svn: 372786
2019-09-24 22:39:04 +00:00
Martin Storsjo c98bb8658e [LLDB] Rework a MinGW build fix from D65691
That change didn't contain any explanation for this bit. There shouldn't
be any need for a check for MinGW ifdefs here, as long as the include
uses lowercase windows.h (as is used consistently elsewhere in
the llvm projects).

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

llvm-svn: 372656
2019-09-23 20:43:11 +00:00
Martin Storsjo 33d29a60a2 [LLDB] Avoid a warning about an unused static variable
The variable is unused on windows.

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

llvm-svn: 372589
2019-09-23 12:03:21 +00:00
Martin Storsjo 5534a67500 [LLDB] Cast -1 (as invalid socket) to the socket type before comparing
This silences warnings about comparison of integers between unsigned
long long (which is what the Windows SOCKET type is) and signed int
when building in MinGW mode.

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

llvm-svn: 372486
2019-09-21 19:10:15 +00:00
Jonas Devlieghere 3cabfb344b Fix warning: lambda capture 'temp_file_path' is not used
llvm-svn: 372044
2019-09-16 22:55:49 +00:00
Tim Shen 573863ea18 [LLDB] Add missing breaks for switch statement
llvm-svn: 371902
2019-09-13 22:00:03 +00:00
Jan Korous f69c91780f [Support] Add overload writeFileAtomically(std::function Writer)
Differential Revision: https://reviews.llvm.org/D67424

llvm-svn: 371890
2019-09-13 20:08:27 +00:00
Jim Ingham 6ca76ceb63 Fix a thinko in handling the QSetLogging packet.
The comparison against LOG_MEMORY shortcut all the LOG_MEMORY_*
log channels.  It has to come last.

llvm-svn: 371560
2019-09-10 21:58:22 +00:00
Jonas Devlieghere e0ea8d87eb [Utility] Replace `lldb_private::CleanUp` by `llvm::scope_exit`
This removes the CleanUp class and replaces its usages with llvm's
ScopeExit, which has similar semantics.

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

llvm-svn: 371474
2019-09-10 00:20:50 +00:00
Adrian Prantl 2461061168 Upstream macCatalyst support in debugserver and the macOS dynamic loader
plugin.

Unfortunately the test is currently XFAILed because of missing changes
to the clang driver.

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

llvm-svn: 370931
2019-09-04 17:23:15 +00:00
Frederic Riss cc5b509b9e Workaround TestConcurrentMany* flakiness in a more pricipled way
The flakiness on our local machines seems to come for a race in the kernel
between task_suspend and the creation of the Mach exceptions for the threads
that hit breakpoints. The debugserver code is written with the assumption
that the kernel will be able to provide us with all the exceptions for a
given task once task_suspend returns. On machines with higher core counts,
this seems not to be the case. The first batch of exceptions we get after
task_suspend does not contain exceptions for all the threads that have hit
a breakpoint, thus they get misreprorted in the first stop packet.

Adding a 1ms timeout to the call that retrieves the batch of exceptions
seems to workaround the issue reliably on our machines, and it shoulnd't
impact standard debugging scenarios too much (a stop will incur an additional
1ms delay). We'll be talking to the kernel team to figure out the right
contract for those APIs.

This patch also reverts part of Jonas' previous workaround for the
issue (r370785).

llvm-svn: 370916
2019-09-04 16:13:12 +00:00
Jonas Devlieghere a0a2ca67fe [Driver] Remove duplicate option parsing (NFC)
We were checking OPT_no_use_colors three times, twice to disable colors
and once to enable debug mode. This simplifies things and now the option
is only checked once.

llvm-svn: 370814
2019-09-03 20:18:19 +00:00
Jason Molenda fe64323fd5 Send error message on failed attach from debugerserver.
Instead of using a magic return error code from debugserver to
indicate that an attach failed because of SIP being enabled in
RNBRemote::HandlePacket_v, use the extended error reporting that
Pavel added to lldb/lldb-server in https://reviews.llvm.org/D45573


<rdar://problem/39398385> 

llvm-svn: 369990
2019-08-27 00:08:27 +00:00
Adrian Prantl aa97a89d83 Extend FindTypes with CompilerContext to allow filtering by language.
This patch is also motivated by the Swift branch and is effectively NFC for the single-TypeSystem llvm.org branch.

In multi-language projects it is extremely common to have, e.g., a
Clang type and a similarly-named rendition of that same type in
another language. When searching for a type It is much cheaper to pass
a set of supported languages to the SymbolFile than having it
materialize every result and then rejecting the materialized types
that have the wrong language.

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

<rdar://problem/54471165>

This reapplies r369690 with a previously missing constructor for LanguageSet.

llvm-svn: 369710
2019-08-22 21:45:58 +00:00
Adrian Prantl b041602e3f Revert Extend FindTypes with CompilerContext to allow filtering by language.
This reverts r369690 (git commit aa3a564efa)

llvm-svn: 369702
2019-08-22 20:41:16 +00:00
Adrian Prantl aa3a564efa Extend FindTypes with CompilerContext to allow filtering by language.
This patch is also motivated by the Swift branch and is effectively NFC for the single-TypeSystem llvm.org branch.

In multi-language projects it is extremely common to have, e.g., a
Clang type and a similarly-named rendition of that same type in
another language. When searching for a type It is much cheaper to pass
a set of supported languages to the SymbolFile than having it
materialize every result and then rejecting the materialized types
that have the wrong language.

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

<rdar://problem/54471165>

llvm-svn: 369690
2019-08-22 19:24:55 +00:00
Adrian Prantl 9a0f124f26 Remove redundant curly braces.
llvm-svn: 369670
2019-08-22 16:58:56 +00:00
Jonas Devlieghere 83ee8d4463 [debugserver] Switch back to std::once_flag
We cannot use llvm::once_flag in debugserver because doesn't link
against llvm.

llvm-svn: 369621
2019-08-22 03:48:19 +00:00
Davide Italiano 0a8e634b3b [lldb] Replace std::once_flag with llvm::once_flag.
Summary:
The former seems like it's not working on some platforms.
All the other uses use `llvm::`, so, let's change for consistency.

Reviewers: jasonmolenda, friss

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 369618
2019-08-22 03:12:49 +00:00
Adrian Prantl 330ae19a1a Generalize FindTypes with CompilerContext to support fuzzy lookup
This patch generalizes the FindTypes with CompilerContext interface to
support looking up a type of unknown kind by name, as well as looking
up a type inside an unspecified submodule. These features are
motivated by the Swift branch, but are fully tested via unit tests and
lldb-test on llvm.org.  Specifically, this patch adds an AnyModule and
an AnyType CompilerContext kind.

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

rdar://problem/54471165

llvm-svn: 369555
2019-08-21 18:06:56 +00:00
Jonas Devlieghere d35b42f20a [NFC] Return llvm::StringRef from StringExtractor::GetStringRef.
This patch removes the two variant of StringExtractor::GetStringRef that
return (non-)const references to std::string. The non-const one was
being abused to reinitialize the StringExtractor and its uses are
replaced by calls to the copy asignment operator. The const variant was
refactored to return an actual llvm::StringRef.

llvm-svn: 369493
2019-08-21 04:55:56 +00:00
Jonas Devlieghere 7483005c59 [NFC] Remove unused function GetHexWithFixedSize
The implementation of this function was obviously incorrect, as the
result variable was never used. This led me to check if it was actually
used anywhere, which came back negative.

llvm-svn: 369492
2019-08-21 04:55:53 +00:00
Adrian Prantl 260aa0f0f3 Make the FindTypes(std::vector<CompilerContext>, ...) API testable in lldb-test
This adds a -compiler-context=<...> option to lldb-test that trakes a
comma-separated string that is a list of kind/name pairs and
translates it into a std::vector<CompilerContext>, a CompilerContext
being a pair of context-kind and name.

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

<rdar://problem/54471165>

llvm-svn: 369407
2019-08-20 16:44:25 +00:00
Alex Langford 3b4ce731fb [lldb-vscode] add `launchCommands` to handle launch specific commands
Summary:
This can help `lldb-vscode` handle launch commands associate with remote platform
attach request have field `attachCommands` to handle attach specific commands
add a corresponding one for launch request
if no launch command is provided, create a new target and launch; otherwise, execute the launch command

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

Patch by Wanyi Ye <kusmour@gmail.com>

llvm-svn: 369296
2019-08-19 20:17:27 +00:00
Jonas Devlieghere a8f3ae7c9c [LLDB] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

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

llvm-svn: 368933
2019-08-14 22:19:23 +00:00
Aaron Smith 8664998046 Add missing NativeProcessFactory for lldb-server on Windows
llvm-svn: 368872
2019-08-14 16:39:41 +00:00
Aaron Smith 216944ee03 Enable lldb-server on Windows
Summary:
This commit contains three small changes to enable lldb-server on Windows.

- Add lldb-server for Windows to the build
- Disable pty redirection on Windows for the initial lldb-server bring up
- Add a support to get the parent pid for a process on Windows
- Ifdef some signals which aren't supported on Windows

Thanks to Hui Huang for the help with this patch!

Reviewers: labath

Reviewed By: labath

Subscribers: JDevlieghere, compnerd, Hui, amccarth, xiaobai, srhines, mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 368774
2019-08-13 23:50:54 +00:00
Stefan Granitz f241001793 [lldb][CMake] Workaround debugserver code-signing issue in generated Xcode project
Summary:
Explicitly code-sign the LLDB.framework copy of debugserver in the build-tree. This is necessary, because the Xcode-specific logic in `llvm_codesign` [1] has the side-effect that Xcode code-signs after post-build steps (here: after copying debugserver over into the framework). The special case for Xcode was necessary to avoid double-signing errors in the past (see D55116 and D55816).

[1] https://github.com/llvm/llvm-project/blob/36fb93982f0e/llvm/cmake/modules/AddLLVM.cmake#L1676

Reviewers: jingham, davide, JDevlieghere, teemperor

Reviewed By: JDevlieghere

Subscribers: beanz, mgorny, lldb-commits, #lldb

Tags: #lldb

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

llvm-svn: 368151
2019-08-07 11:02:04 +00:00
Haibo Huang c6551bf013 Detect HAVE_SYS_TYPES_H in lldb
Summary:
After rL368069 I noticed that HAVE_SYS_TYPES_H is not defined in
Platform.h, or anywhere else in lldb. This change fixes that.

Reviewers: labath

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 368125
2019-08-07 06:15:01 +00:00
Jason Molenda 6cebeafac3 Upstream a few small Apple changes to debugserver - arm64_32, Catalyst
Adrian's changes to support Catalyst processes and my
changes to support debugserver running on an arm64_32
device (Apple Watch Series 4, which uses an IPL32 model
on arm64 cpus).

llvm-svn: 368118
2019-08-07 02:06:06 +00:00
Haibo Huang a63417fe6c Various build fixes for lldb on MinGW
Subscribers: mstorsjo, lldb-commits

Tags: #lldb

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

llvm-svn: 368069
2019-08-06 18:20:43 +00:00
Pavel Labath 465eae3669 SymbolVendor: Remove passthrough methods
After the recent refactorings the SymbolVendor passthrough no longer
serve any purpose. This patch removes those methods, and updates all
callsites to go to the symbol file directly -- in most cases that just
means calling GetSymbolFile()->foo() instead of
GetSymbolVendor()->foo().

llvm-svn: 368001
2019-08-06 09:12:42 +00:00
Fangrui Song d9b948b6eb Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFC
F_{None,Text,Append} are kept for compatibility since r334221.

llvm-svn: 367800
2019-08-05 05:43:48 +00:00
Alex Langford 0e252e38ef [Symbol] Use llvm::Expected when getting TypeSystems
Summary:
This commit achieves the following:
- Functions used to return a `TypeSystem *` return an
  `llvm::Expected<TypeSystem *>` now. This means that the result of a call
  is always checked, forcing clients to move more carefully.
- `TypeSystemMap::GetTypeSystemForLanguage` will either return an Error or a
  non-null pointer to a TypeSystem.

Reviewers: JDevlieghere, davide, compnerd

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 367360
2019-07-30 22:12:34 +00:00
Jan Kratochvil 2b38951799 [lldb] Increase testsuite packet-timeout 5secs -> 1min
rL357954 did increase `packet-timeout` 1sec -> 5secs. Which is IMO about the
maximum timeout reasonable for regular use. But for testsuite I think the
timeout should be higher as the testsuite runs in parallel and it can be run
even on slow hosts and with other load (moreover if it runs on some slow arch).

I have chosen 60 secs, that should be enough hopefully.  Larger value could
make debugging with hanging `lldb-server` annoying.

This patch was based on this testsuite timeout:
http://lab.llvm.org:8014/builders/lldb-x86_64-fedora/builds/546/steps/test/logs/stdio
	FAIL: test_connect (TestGDBRemoteClient.TestGDBRemoteClient)
	   Test connecting to a remote gdb server
	----------------------------------------------------------------------
	Traceback (most recent call last):
	  File "/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteClient.py", line 13, in test_connect
	    process = self.connect(target)
	  File "/home/jkratoch/slave-lldb-x86_64-fedora/lldb-x86_64-fedora/llvm/tools/lldb/packages/Python/lldbsuite/test/functionalities/gdb_remote_client/gdbclientutils.py", line 480, in connect
	    self.assertTrue(error.Success(), error.description)
	AssertionError: False is not True : failed to get reply to handshake packet

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

llvm-svn: 367234
2019-07-29 16:10:16 +00:00
Fangrui Song 5b406d7058 cli-wrapper-mpxtable.cpp: fix file header
llvm-svn: 366983
2019-07-25 05:15:50 +00:00
Jonas Devlieghere 63e5fb76ec [Logging] Replace Log::Printf with LLDB_LOG macro (NFC)
This patch replaces explicit calls to log::Printf with the new LLDB_LOGF
macro. The macro is similar to LLDB_LOG but supports printf-style format
strings, instead of formatv-style format strings.

So instead of writing:

  if (log)
    log->Printf("%s\n", str);

You'd write:

  LLDB_LOG(log, "%s\n", str);

This change was done mechanically with the command below. I replaced the
spurious if-checks with vim, since I know how to do multi-line
replacements with it.

  find . -type f -name '*.cpp' -exec \
  sed -i '' -E 's/log->Printf\(/LLDB_LOGF\(log, /g' "{}" +

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

llvm-svn: 366936
2019-07-24 17:56:10 +00:00
Stefan Granitz e8bffd3ff0 [lldb] Configure debugserver_vers.c from CMake
llvm-svn: 366932
2019-07-24 17:28:24 +00:00
Pavel Labath e0119909a6 SymbolVendor: Move compile unit handling into the SymbolFile class
Summary:
SymbolFile classes are responsible for creating CompileUnit instances
and they already need to have a notion of the id<->CompileUnit mapping
(because of APIs like ParseCompileUnitAtIndex). However, the
SymbolVendor has remained as the thing responsible for caching created
units (which the SymbolFiles were calling via convoluted constructs like
"m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(...)").

This patch moves the responsibility of caching the units into the
SymbolFile class. It does this by moving the implementation of
SymbolVendor::{GetNumCompileUnits,GetCompileUnitAtIndex} into the
equivalent SymbolFile functions. The SymbolVendor functions become just
a passthrough much like the rest of SymbolVendor.

The original implementations of SymbolFile::GetNumCompileUnits is moved
to "CalculateNumCompileUnits", and are made protected, as the "Get"
function is the external api of the class.
SymbolFile::ParseCompileUnitAtIndex is made protected for the same
reason.

This is the first step in removing the SymbolVendor indirection, as
proposed in
<http://lists.llvm.org/pipermail/lldb-dev/2019-June/015071.html>. After
removing all interesting logic from the SymbolVendor class, I'll proceed
with removing the indirection itself.

Reviewers: clayborg, jingham, JDevlieghere

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 366791
2019-07-23 09:24:02 +00:00
Jonas Devlieghere 63b921f01d Remove Xcode project remnants
llvm-svn: 366745
2019-07-22 21:51:04 +00:00
Stefan Granitz fc0d766511 [CMake] Align debugserver with lldb-server on Darwin
Summary: Make debugserver a tool like lldb-server, so it can be included/excluded via `LLDB_TOOL_DEBUGSERVER_BUILD`. This replaces the old `LLDB_NO_DEBUGSERVER` flag. Doing the same for darwin-debug while I am here.

Reviewers: xiaobai, JDevlieghere, davide

Reviewed By: xiaobai, JDevlieghere

Subscribers: mgorny, lldb-commits, #lldb

Tags: #lldb

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

llvm-svn: 366631
2019-07-20 11:18:31 +00:00
Stefan Granitz f44d7c3f9f [NFC] Remove indent after r366433
llvm-svn: 366560
2019-07-19 10:20:35 +00:00
Jonas Devlieghere 37fed66402 [LLDB] Remove lldb-mi
As discussed on the mailing list [1], this patch removes the lldb-mi
tool and its tests from the LLDB repository. We moved lldb-mi into a
separate repository on GitHub [2] for downstream users or maintainers to
build and package.

[1] http://lists.llvm.org/pipermail/lldb-dev/2019-July/015103.html
[2] https://github.com/lldb-tools/lldb-mi

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

llvm-svn: 366465
2019-07-18 17:06:06 +00:00
Stefan Granitz 0c4948455d [CMake] Always build debugserver on Darwin and allow tests to use the system's one
Summary:
We can always build debugserver, but we can't always sign it to be useable for testing. `LLDB_USE_SYSTEM_DEBUGSERVER` should only tell whether or not the system debugserver should be used for testing.
The old behavior complicated the logic around debugserver a lot. The new logic sorts out most of it.

Please note that this patch is in early stage and needs some more testing. It should not affect platfroms other than Darwin. It builds on Davide's approach to validate the code-signing identity at configuration time.

What do you think?

Reviewers: xiaobai, JDevlieghere, davide, compnerd, friss, labath, mgorny, jasonmolenda

Reviewed By: JDevlieghere

Subscribers: lldb-commits, #lldb

Tags: #lldb

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

llvm-svn: 366433
2019-07-18 13:30:37 +00:00
Jan Kratochvil d0ac1888aa [lldb] Handle EOF from `lldb-vscode`
Sometimes (when running lldb-vscode under strace) I get:

read(0, "", 16)                         = 0
read(0, "", 16)                         = 0
read(0, "", 16)                         = 0
...

With this patch testcases finish properly even with strace:

read(0, "", 16)                         = 0
futex(0x1346508, FUTEX_WAKE_PRIVATE, 2147483647) = 0
stat("", 0x7ffe8f2634c8)                = -1 ENOENT (No such file or directory)
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=9124, si_uid=1001, si_status=SIGINT, si_utime=1, si_stime=0} ---
close(4)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

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

llvm-svn: 366187
2019-07-16 06:34:44 +00:00
Nathan Lanza 320d6795b2 [windows] re-call signal in sigint_handler for Windows
Summary:
Windows requires re-setting the signal handler each time it is used
and thus ctrl-c was not behaving properly on Windows

Reviewers: jfb

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

llvm-svn: 365868
2019-07-12 04:43:46 +00:00
Jonas Devlieghere f4af9a9d80 Add convenience methods to convert LLDB to LLVM data structures.
This patch adds two convenience methods named GetAsLLVM to the LLDB
counterparts of the DWARF DataExtractor and the DWARF context. The
DWARFContext, once created, is cached for future usage.

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

llvm-svn: 365819
2019-07-11 20:26:53 +00:00
Stefan Granitz 110f97632e [CMake] `install-distribution` for LLDB on Darwin
Summary:
There's a number of requirements for installing LLDB on macOS that are untypical for LLVM projects: use special install-prefix for LLDB.framework, ship headers and tools as framework resources, patch RPATHs, externalize debug-info to dSYM's and strip binaries with `-ST`. For some of it we could use `llvm_externalize_debuginfo()` in the past and just add special cases. However, this complicates the code for all projects and comes with the major drawback, that it adds all these actions at build-time, i.e. dSYM creation and stripping take a lot of time and don't make sense at build-time.

LLVM's distribution mechanism (https://llvm.org/docs/BuildingADistribution.html) appears to be the natural candidate to install LLDB. Based on D64399 (enable in standalone builds), this patch integrates framework installation with the distribution mechanism and adds custom stripping flags and dSYM creation at install-time. Unlike the abandoned D61952, it leaves build-tree binaries untouched, so there's no side-effects on testing. Potential install-order issues must be handled externally.

Please let me know what you think, while I run a few more tests and add remarks+documentation.

Reviewers: xiaobai, compnerd, JDevlieghere, davide, labath, mgorny

Reviewed By: xiaobai, JDevlieghere

Subscribers: lldb-commits, #lldb

Tags: #lldb

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

llvm-svn: 365617
2019-07-10 11:09:29 +00:00
Jonas Devlieghere a5ede3182b Remove install-headers
After discussing this internally, it is my understanding this was used
for building LLDB internally at Apple, and is no longer used or
necessary.

llvm-svn: 365392
2019-07-08 21:53:22 +00:00
Jonas Devlieghere cbdf794872 Remove lldb-perf
As discussed offline, this tool is no longer used or maintained, and
doesn't provide the right abstraction for performance tracking in lldb.

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

llvm-svn: 365391
2019-07-08 21:38:34 +00:00
Davide Italiano 97017a8ef9 [CMake] Check that a certificate for lldb is present at build time.
Reviewers: JDevlieghere, sgraenitz, aprantl, friss

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 364334
2019-06-25 17:13:24 +00:00
Jan Kratochvil 8c82c41262 [lldb] [test] Extend D55859 symbols.enable-external-lookup=false for more testcases
D55859 <https://reviews.llvm.org/D55859> has no effect for some of the
testcases so this patch extends it even for (all?) other testcases known to me.
LLDB was failing when LLDB prints errors reading system debug infos
(`*-debuginfo.rpm`, DWZ-optimized) which should never happen as LLDB testcases
should not be affected by system debug infos.

`lldb/packages/Python/lldbsuite/test/api/multithreaded/driver.cpp.template` is
using only SB API which does not expose `ModuleList` so I had to call
`HandleCommand()` there.

`lldb-test.cpp` could also use `HandleCommand` and then there would be no need
for `ModuleListProperties::SetEnableExternalLookup()` but I think it is cleaner
with API and not on based on text commands.

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

llvm-svn: 363567
2019-06-17 14:46:17 +00:00
Stefan Granitz a866d3b2ee [CMake] Two extra FOLDER properties for debugserver
llvm-svn: 363171
2019-06-12 14:46:30 +00:00
Adrian McCarthy 4447d15aef Fix lit tests on Windows related to CR+LF
Problem discovered in the breakpoint lit test, but probably exists in others.
lldb-test splits lines on LF.  Input files that are CR+LF separated (as is
common on Windows) then resulted in commands being sent to LLDB that ended
in CR, which confused the command interpreter.

This could be fixed at different levels:

1.  Treat '\r' like a tab or space in the argument splitter.
2.  Fix the line splitters (plural) in lldb-test.
3.  Normalize the test files to LF only.

If we did only 3, I'd expect similar problems to recur, so this patch does
1 and 2.  I may also do 3 in a separate patch later, but that's tricky
because I believe we have some input files that MUST use CR+LF.

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

llvm-svn: 362844
2019-06-07 21:13:30 +00:00
Stefan Granitz 72e05d0aa4 [CMake] Remove lldb-server from LLDB.framework
Summary: The LLDB test suite doesn't need lldb-server in the framework bundle anymore.

Reviewers: JDevlieghere, jasonmolenda, xiaobai

Reviewed By: JDevlieghere

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 361947
2019-05-29 11:28:11 +00:00
Stefan Granitz 5dc9036746 [CMake] LLDB.framework tools handling
Summary:
Modify the way LLDB.framework tools are collected. This allows for better fine-tuning of the install behavior downstream. Each target calls `lldb_add_to_framework()` individually. When entering the function, the target exists and we can tweak its very own post-build and install steps. This was not possible with the old `LLDB_FRAMEWORK_TOOLS` approach.

No function change otherwise.
This is a reduced follow-up from the proposal in D61952.

Reviewers: xiaobai, compnerd, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: clayborg, friss, ki.stfu, mgorny, lldb-commits, labath, #lldb

Tags: #lldb

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

llvm-svn: 361946
2019-05-29 11:26:06 +00:00
Alexandre Ganea cf950b46c8 Fix 'warning: format specifies type 'int' but the argument has type 'MIuint' (aka 'unsigned long long') [-Wformat]' with Clang 8.0
llvm-svn: 361861
2019-05-28 18:36:11 +00:00
Stefan Granitz a3388e5f9e [CMake] Folder structure for generated Xcode project to cover more targets
llvm-svn: 361799
2019-05-28 09:29:05 +00:00
Jonas Devlieghere 09ad8c8f73 Fix integer literals which are cast to bool
This change replaces built-in types that are implicitly converted to
booleans.

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

llvm-svn: 361580
2019-05-24 00:44:33 +00:00
J. Ryan Stinnett b4cb7d8045 [NFC] Add blank line (test commit)
llvm-svn: 361555
2019-05-23 21:13:50 +00:00
Konrad Kleine 248a13057a [lldb] NFC modernize codebase with modernize-use-nullptr
Summary:
NFC = [[ https://llvm.org/docs/Lexicon.html#nfc | Non functional change ]]

This commit is the result of modernizing the LLDB codebase by using
`nullptr` instread of `0` or `NULL`. See
https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html
for more information.

This is the command I ran and I to fix and format the code base:

```
run-clang-tidy.py \
	-header-filter='.*' \
	-checks='-*,modernize-use-nullptr' \
	-fix ~/dev/llvm-project/lldb/.* \
	-format \
	-style LLVM \
	-p ~/llvm-builds/debug-ninja-gcc
```

NOTE: There were also changes to `llvm/utils/unittest` but I did not
include them because I felt that maybe this library shall be updated in
isolation somehow.

NOTE: I know this is a rather large commit but it is a nobrainer in most
parts.

Reviewers: martong, espindola, shafik, #lldb, JDevlieghere

Reviewed By: JDevlieghere

Subscribers: arsenm, jvesely, nhaehnle, hiraditya, JDevlieghere, teemperor, rnkovacs, emaste, kubamracek, nemanjai, ki.stfu, javed.absar, arichardson, kbarton, jrtc27, MaskRay, atanasyan, dexonsmith, arphaman, jfb, jsji, jdoerfert, lldb-commits, llvm-commits

Tags: #lldb, #llvm

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

llvm-svn: 361484
2019-05-23 11:14:47 +00:00
Jorge Gorbe Moya 33dbab8271 [lldb] Fix use-of-uninitialized-value in Driver
The driver passes by reference an uninitialized num_errors variable to
RunCommandInterpreter. This should be fine, as it's supposed to be
an output argument, but the reproducer instrumentation reads it in order
to record the value of all the arguments to the function.

This change fixes it by initializing num_errors to 0 before calling
RunCommandInterpreter.

llvm-svn: 361444
2019-05-22 23:37:48 +00:00
Fangrui Song 1d846e1a4d Delete unnecessary copy ctors
llvm-svn: 361358
2019-05-22 08:38:23 +00:00
Tatyana Krasnukha e0cc56e038 [lldb-mi] Include full path in the -data-disassemble response
Differential Revision: https://reviews.llvm.org/D59015

Patch by Anton Kolesov <Anton.Kolesov@synopsys.com>

llvm-svn: 361255
2019-05-21 13:22:46 +00:00
Saleem Abdulrasool a5401e48dd lldb-server: LLGS: support 32-bit on 64-bit hosts
Enable the ARM emulation support on AArch64 which can execute ARM32
code. Similarly, handle MIPS 32 on 64.

llvm-svn: 361210
2019-05-21 01:25:48 +00:00
Stefan Granitz dcc477e38c [CMake] Inline info plist in lldb driver
llvm-svn: 361068
2019-05-17 19:19:34 +00:00
Fangrui Song 71a44224e5 Delete unnecessary copy ctors/copy assignment operators
It's the simplest and gives the cleanest semantics.

llvm-svn: 360762
2019-05-15 11:23:54 +00:00
Jonas Devlieghere 4c1d6ee83d Replace assert with static_assert here applicable.
Replaces assert() with static_assert() if the condition is can be
evaluated at compile time.

llvm-svn: 360753
2019-05-15 05:39:41 +00:00