Commit Graph

1818 Commits

Author SHA1 Message Date
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
Jonas Devlieghere c18740976e Mark private unimplemented functions as deleted
Applies modernize-use-equals-delete to the LLDB code base and removes
the now redundant comments.

llvm-svn: 360751
2019-05-15 05:31:14 +00:00
Saleem Abdulrasool 1362905e8c lldb-server: rename `llgs::terminate` (NFC)
`terminate` overlaps with a C function on Windows:

```
D:\a\1\s\lldb\tools\lldb-server\lldb-server.cpp(45,13):  warning: 'terminate' redeclared without 'dllimport' attribute: 'dllexport' attribute added [-Winconsistent-dllimport]
static void terminate() { g_debugger_lifetime->Terminate(); }
            ^
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\corecrt_terminate.h(29,48):  note: previous declaration is here
    _ACRTIMP __declspec(noreturn) void __cdecl terminate() throw();
                                               ^
D:\a\1\s\lldb\tools\lldb-server\lldb-server.cpp(45,61):  warning: function declared 'noreturn' should not return [-Winvalid-noreturn]
static void terminate() { g_debugger_lifetime->Terminate(); }
                                                            ^
```

Rename the function to `terminate_debugger` to avoid the errant match.

llvm-svn: 360693
2019-05-14 17:07:36 +00:00
Fangrui Song efe8e7e36d typedef enum -> enum
Reviewed By: labath

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

llvm-svn: 360654
2019-05-14 08:55:50 +00:00
Jonas Devlieghere 1d8b2a0661 [CMake] Reinstate LLDB_CAN_USE_LLDB_SERVER
We cannot manipulate the LLDB_TOOL_LLDB_SERVER_BUILD directly from
LLDBConfig.cmake because this would set the variable before the option
is defined in AddLLVM.cmake. Instead, we need to use the
LLDB_CAN_USE_LLDB_SERVER variable to conditionally add the lldb-server
subdirectory. This should ensure the variable doesn't get cleared.

llvm-svn: 360631
2019-05-13 22:55:11 +00:00
Jonas Devlieghere aeeeb37e37 [CMake] Simplify lldb-server handling
We can piggyback off the existing add_lldb_tool_subdirectory to decide
whether or not lldb-server should be built.

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

llvm-svn: 360621
2019-05-13 21:25:02 +00:00
Fangrui Song b0e54cbcdf Fix file names in file headers. NFC
llvm-svn: 360554
2019-05-13 04:42:32 +00:00
Jonas Devlieghere 7ffd963834 [Driver] Add command line option to allow loading local lldbinit file.
This patch adds a command line flag that allows lldb to load local
lldbinit files.

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

llvm-svn: 360172
2019-05-07 16:57:17 +00:00
Jonas Devlieghere 2edcad7b59 [Driver] Change the way we deal with local lldbinit files.
Currently we have special handling for local lldbinit files in the
driver. At the same time, we have an SB API named
`SourceInitFileInCurrentWorkingDirectory` that does the same thing.

This patch removes the special handling from the driver and uses the API
instead. In addition to the obvious advantages of having one canonical
way of doing things and removing code duplication, this change also
means that the code path is the same for global and local lldb init
files.

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

llvm-svn: 360077
2019-05-06 20:45:31 +00:00
Greg Clayton 8a7779209d Include inlined functions when figuring out a contiguous address range
Checking this in for Antonio Afonso:

This diff changes the function LineEntry::GetSameLineContiguousAddressRange so that it also includes function calls that were inlined at the same line of code.

My motivation is to decrease the step over time of lines that heavly rely on inlined functions. I have multiple examples in the code base I work that makes a step over stop 20 or mote times internally. This can easly had up to step overs that take >500ms which I was able to lower to 25ms with this new strategy.

The reason the current code is not extending the address range beyond an inlined function is because when we resolve the symbol at the next address of the line entry we will get the entry line corresponding to where the original code for the inline function lives, making us barely extend the range. This then will end up on a step over having to stop multiple times everytime there's an inlined function.

To check if the range is an inlined function at that line I also get the block associated with the next address and check if there is a parent block with a call site at the line we're trying to extend.

To check this I created a new function in Block called GetContainingInlinedBlockWithCallSite that does exactly that. I also added a new function to Declaration for convinence of checking file/line named CompareFileAndLine.

To avoid potential issues when extending an address range I added an Extend function that extends the range by the AddressRange given as an argument. This function returns true to indicate sucess when the rage was agumented, false otherwise (e.g.: the ranges are not connected). The reason I do is to make sure that we're not just blindly extending complete_line_range by whatever GetByteSize() we got. If for some reason the ranges are not connected or overlap, or even 0, this could be an issue.

I also added a unit tests for this change and include the instructions on the test itself on how to generate the yaml file I use for testing.


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

llvm-svn: 360071
2019-05-06 20:01:21 +00:00
Saleem Abdulrasool e24d8c55d5 Initialization: move InstructionEmulation to full initialization
The debug server does not need to use the instruction emulation. This
helps reduce the size of the final lldb-server binary by another ~100K
(~1% savings).

llvm-svn: 360067
2019-05-06 19:38:24 +00:00
Jonas Devlieghere c1e2c5340b Make lldb-mi optional and change how we deal with missing tools in lit
We don't need the variables in lit, we can use the capabilities to check
if the utility exists.

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

llvm-svn: 359926
2019-05-03 20:33:58 +00:00
Raphael Isemann 1756630dfa C.128 override, virtual keyword handling
Summary:
According to [C128] "Virtual functions should specify exactly one
of `virtual`, `override`, or `final`", I've added override where a
virtual function is overriden but the explicit `override` keyword
was missing. Whenever both `virtual` and `override` were specified,
I removed `virtual`. As C.128 puts it:

> [...] writing more than one of these three is both redundant and
> a potential source of errors.

I anticipate a discussion about whether or not to add `override` to
destructors but I went for it because of an example in [ISOCPP1000].
Let me repeat the comment for you here:

Consider this code:

```
    struct Base {
      virtual ~Base(){}
    };

    struct SubClass : Base {
      ~SubClass() {
        std::cout << "It works!\n";
      }
    };

    int main() {
      std::unique_ptr<Base> ptr = std::make_unique<SubClass>();
    }
```

If for some odd reason somebody removes the `virtual` keyword from the
`Base` struct, the code will no longer print `It works!`. So adding
`override` to destructors actively protects us from accidentally
breaking our code at runtime.

[C128]: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c128-virtual-functions-should-specify-exactly-one-of-virtual-override-or-final
[ISOCPP1000]: https://github.com/isocpp/CppCoreGuidelines/issues/1000#issuecomment-476951555

Reviewers: teemperor, JDevlieghere, davide, shafik

Reviewed By: teemperor

Subscribers: kwk, arphaman, kadircet, lldb-commits

Tags: #lldb

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

llvm-svn: 359868
2019-05-03 10:03:28 +00:00
Saleem Abdulrasool bd689b9c6b gdb-remote: reduce some inclusion of Target/Process.h
Reduce the inclusion of Target/Process.h to help isolate why Process is being
preserved during the build of `lldb-server`.

llvm-svn: 359811
2019-05-02 18:15:03 +00:00
Saleem Abdulrasool dc476df585 lldb-server: remove link against lldbInterpreter
This dependency is unused. Remove the extraneous link.

llvm-svn: 359738
2019-05-01 23:06:45 +00:00
Alex Langford 4e7104bd63 [lldb-server] Remove lldb-server's dependency on Core
No need to directly link against Core, as lldb-server doesn't directly
use it.

llvm-svn: 359730
2019-05-01 21:41:40 +00:00
Jonas Devlieghere de3d12f954 [Driver] Remove unused functions (NFC)
Remove unused from the driver class. I noticed a bunch of small thing
while doing this that didn't warrant separate commits, so I've lumped
them together into this patch.

llvm-svn: 359355
2019-04-26 22:54:39 +00:00
Davide Italiano b2930b8631 [tools] Only build lldb-test when needed.
llvm-svn: 358533
2019-04-16 21:56:07 +00:00
Davide Italiano 6df6895d90 [tools] Make vscode and lldb-instr optional.
Summary:
Saves some build times, and they're not part of the usual
developer workflow.

Reviewers: JDevlieghere, friss

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 358528
2019-04-16 21:15:28 +00:00
Frederic Riss b47d356093 [debugserver] Relax the codesigning identity check
In an effort to help new LLDB developers, we added checks and messaging around
the selection of your codesigning identity on macOS. While helpful, it is not
actually correct. It's perfectly valid to codesign with an identity that is
not named lldb_codesign. Currently this fails the build.

This patch keeps a warning that informs developers how to setup lldb_codesign
and how to pass it to cmake, but it allows the build to proceed with a
different identity.

llvm-svn: 358525
2019-04-16 20:54:42 +00:00
Jonas Devlieghere 8b3af63b89 [NFC] Remove ASCII lines from comments
A lot of comments in LLDB are surrounded by an ASCII line to delimit the
begging and end of the comment.

Its use is not really consistent across the code base, sometimes the
lines are longer, sometimes they are shorter and sometimes they are
omitted. Furthermore, it looks kind of weird with the 80 column limit,
where the comment actually extends past the line, but not by much.
Furthermore, when /// is used for Doxygen comments, it looks
particularly odd. And when // is used, it incorrectly gives the
impression that it's actually a Doxygen comment.

I assume these lines were added to improve distinguishing between
comments and code. However, given that todays editors and IDEs do a
great job at highlighting comments, I think it's worth to drop this for
the sake of consistency. The alternative is fixing all the
inconsistencies, which would create a lot more churn.

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

llvm-svn: 358135
2019-04-10 20:48:55 +00:00
Pavel Labath fbe91ffb7b Fix signed-unsigned comparison warning in Driver.cpp
llvm-svn: 357893
2019-04-08 09:17:56 +00:00
Jonas Devlieghere 306809f292 [Reproducers] Capture return values of functions returning by ptr/ref
For some reason I had convinced myself that functions returning by
pointer or reference do not require recording their result. However,
after further considering I don't see how that could work, at least not
with the current implementation. Interestingly enough, the reproducer
instrumentation already (mostly) accounts for this, though the
lldb-instr tool did not.

This patch adds the missing macros and updates the lldb-instr tool.

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

llvm-svn: 357639
2019-04-03 21:31:22 +00:00
Adrian McCarthy ffa857c7a6 Fix and simplify PrepareCommandsForSourcing
Spotted some problems in the Driver's PrepareCommandsForSourcing while
helping a colleague track another problem.

1. One error case was not handled because there was no else clause.
Fixed by switching to llvm's early-out style instead of nested
`if (succes) { } else { }` cases.  This keeps error handling close
to the actual error.

2. One call-site failed to call the clean-up function.  I solved this
by simplifying the API.  PrepareCommandsForSourcing no longer requires
the caller to provide a buffer for the pipe's file descriptors and to
call a separate clean-up function later.  PrepareCommandsForSourcing
now ensures the file descriptors are handled before returning.
(The read end of the pipe is held open by the returned FILE * as
before.)

I also eliminated an unnecessary local, shorted the lifetime of another,
and tried to improve the comments.

I wrapped the call to open the pipe to get the `#ifdef`s out of the
mainline.  I replaced the `close`/`_close` calls with a platform-neutral
helper from `llvm::sys` for the same reason.  Per discussion on the
review, I'm leaving the `fdopen` call to use the spelling that Windows
has officially deprecated because it still works it avoids more `#ifdef`s.

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

llvm-svn: 357626
2019-04-03 19:49:14 +00:00
Aaron Smith 41a7950cfb [lldb-server] Use llgs namespace to avoid conflicts with Win32 API
llvm-svn: 357496
2019-04-02 17:10:12 +00:00
Jonas Devlieghere f8819bd510 [Platform] Remove Kalimba Platform
This patch removes the Kalimba platform. For more information please
refer to the corresponding thread on the mailing list.

http://lists.llvm.org/pipermail/lldb-dev/2019-March/014921.html

llvm-svn: 357086
2019-03-27 16:23:50 +00:00
Adrian Prantl 040f94cc7e Update the lldb driver to support the -O and -S options when passing --repl
At the moment when --repl is passed to lldb it silently ignores any
commands passed via the options below:

--one-line-before-file <command>
                     Tells the debugger to execute this one-line lldb command before any file provided on the command line has been loaded.
--one-line <command>
                     Tells the debugger to execute this one-line lldb command after any file provided on the command line has been loaded.
--source-before-file <file>
                     Tells the debugger to read in and execute the lldb commands in the given file, before any file has been loaded.
--source <file>
                     Tells the debugger to read in and execute the lldb commands in the given file, after any file has been loaded.
-O <value>           Alias for --one-line-before-file
-o <value>           Alias for --one-line
-S <value>           Alias for --source-before-file
-s <value>           Alias for --source

The -O and -S options are quite useful when writing tests for the REPL
though, e.g. to change settings prior to entering REPL mode. This
patch updates the driver to still respect the commands supplied via -O
and -S when passing --repl instead of silently ignoring them. As -s
and -o don't really make sense in REPL mode, commands supplied via
those options are still ignored, but the driver now emits a warning to
make that clear to the user.

Patch by Nathan Hawes!

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

llvm-svn: 356911
2019-03-25 15:38:18 +00:00
Hafiz Abid Qadeer de9d736495 Fix a broken comment line. NFC.
Just checking that commit access is working after licensing changes.

llvm-svn: 356876
2019-03-25 09:41:49 +00:00
Michal Gorny 2819136f0a [lldb] Add missing EINTR handling
Differential Revision: https://reviews.llvm.org/D59606

llvm-svn: 356703
2019-03-21 19:35:55 +00:00
Jason Molenda 9d760a0a76 Change the logging on ptrace(PT_KILL) in MachProcess::Kill to log
if LOG_PROCESS is enabled or if there was an error making that call.

<rdar://problem/49036508> 

llvm-svn: 356626
2019-03-20 22:59:16 +00:00
Jorge Gorbe Moya 717b1c804b [lldb-vscode] Fix dangling pointer in request_evaluate.
SBError::GetCString() returns a pointer to a string owned by the SBError
object. The code here was calling GetCString on a temporary and using
the returned pointer after the temporary was destroyed.

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

llvm-svn: 356227
2019-03-15 01:46:50 +00:00
Jorge Gorbe Moya d383a342aa [lldb-vscode] Don't try to launch an invalid program.
If an invalid program is specified, lldb-vscode will send back a
response with "success" = false, but then will continue executing the
rest of request_launch(), try to launch the program anyway and try to
send another response (possibly using the `response` object after it was
moved).

This change adds a return statement so we stop executing the handler
after producing the first failing response.

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

llvm-svn: 356110
2019-03-13 23:50:35 +00:00
Jonas Devlieghere 13ecae2f9a [Reproducers] Support capturing a reproducer without an explicit path.
Tablegen doesn't support options that are both flags and take values as
an argument. I noticed this when doing the tablegen rewrite, but forgot
that that affected the reproducer --capture flag.

This patch makes --capture a flag and adds --capture-path to specify a
path for the reproducer. In reality I expect this to be mostly used for
testing, but it could be useful nonetheless.

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

llvm-svn: 355936
2019-03-12 16:44:18 +00:00
Adrian Prantl f05b42e960 Bring Doxygen comment syntax in sync with LLVM coding style.
This changes '@' prefix to '\'.

llvm-svn: 355841
2019-03-11 17:09:29 +00:00
Jonas Devlieghere 3b0a54e138 [lldb-instr] Support LLDB_RECORD_DUMMY
Extend lldb-instr to insert LLDB_RECORD_DUMMY macros for currently
unsupported signatures (void and function pointers).

llvm-svn: 355710
2019-03-08 18:33:40 +00:00
Jonas Devlieghere fee5576f7c [lldb-vscode] Fix warning
I changed the variable to an unsigned to get rid of a signed and
unsigned compare without realizing the value could be negative. This
fixes the assert instead.

llvm-svn: 355708
2019-03-08 17:36:54 +00:00
Zachary Turner 7e89b3cc17 [lldb-vscode] Report an error if an invalid program is specified.
Previously if an invalid program was specified, there was a bug
which, when we attempted to launch the program, would report that
the operation succeeded, causing LLDB to then hang while waiting
indefinitely to receive some events from the process.

After this patch, when an invalid program is specified, we immediately
return to vs code with an error message that indicates that the
program can not be found.

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

llvm-svn: 355656
2019-03-08 00:11:27 +00:00
Jonas Devlieghere 8d359c147d Make bytes_read an unsigned
llvm-svn: 355651
2019-03-07 22:59:55 +00:00
Jonas Devlieghere 4e7301ecf2 Remove unused function
llvm-svn: 355650
2019-03-07 22:58:39 +00:00
Zachary Turner 29e8754172 [lldb-vscode] Support running in server mode on Windows.
Windows can't use standard i/o system calls such as read and write
to work with sockets, it instead needs to use the specific send
and recv calls.  This complicates matters for the debug adapter,
since it needs to be able to work in both server mode where it
communicates over a socket, as well as non-server mode where it
communicates via stdin and stdout.  To abstract this out, I've
introduced a class IOStream which hides all these details and
exposes a read/write interface that does the right on each
platform.

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

llvm-svn: 355637
2019-03-07 21:23:21 +00:00
Zachary Turner 3229000f63 [lldb-vscode] Correctly propagate errors back to VS Code.
llvm-svn: 355557
2019-03-06 22:30:06 +00:00
Frederic Riss fcda044d22 [debugserver] Fix IsUserReady thread filtering
Summary:
In 2010 (r118866), filtering code was added to debugserver to avoid reporting threads
that were "not ready to be displayed to the user". This code inspects the thread's
state and discards threads marked 'uninterruptible'. Turns out, this state is pretty
common and not only a characterisitic of 'user-readiness'. This filtering was tracked
down as the source of the flakiness of TestQueues and TestConcurrent* with the symptom
of missing threads.

We discussed with the kernel team and there should be no need for us to filter the
restult of task_threads(). Everything that is returned from there can be examined.
So I went on and tried to remove the filtering completely. This produces other test
failures, where we were reporting more theads than expected. Always threads that had
been terminated, but weren't removed from the task bookkeeping structures yet. Those
threads always had a PC of 0.

This patch changes the heuristic to make the filtering a little less strict and only
rejects threads that are 'uninteruptible' *and* have a PC of 0. This has proven to be
solid in my testing.

Reviewers: jasonmolenda, clayborg, jingham

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 355555
2019-03-06 21:56:14 +00:00
Jan Kratochvil 94b1ff72f5 Sanity check --max-gdbserver-port
In mail
	[lldb-dev] Remote debugging a docker process
	https://lists.llvm.org/pipermail/lldb-dev/2019-March/014795.html
user was confused by --min-gdbserver-port and --max-gdbserver-port options
being ignored. I think there is even a bug that --max-gdbserver-port is upper
exclusive limit (and not upper inclusive limit appropriate for max).

At least this patch should catch such mistake by an error message. The question
is whether --max-gdbserver-port should not be changed to really be max and not
max+1 but that would break backward compatibility.

Now the mail example does produce:
	error: --min-gdbserver-port (5001) is not lower than --max-gdbserver-port (5001)

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

llvm-svn: 355554
2019-03-06 21:52:19 +00:00
Jonas Devlieghere 2e3e65fb62 [Reproducers] Enable replay from SBRepro.
Now that the LLDB instrumentation macros are in place, we should use
that to test reproducer replay.

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

llvm-svn: 355470
2019-03-06 01:49:57 +00:00
Jason Molenda 7cdaf1e06b Update com.apple.diagnosticd.diagnostic entitlement
name to the newer com.apple.private.logging.diagnostic.

<rdar://problem/47183116> 

llvm-svn: 355170
2019-03-01 03:34:51 +00:00
Tatyana Krasnukha a20bd2735e [lldb-mi] Return source line number in proper format
Line number is a decimal number and is printed as such, however for some
reason it was prefixed with '0x', thus turning printed value invalid.

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

llvm-svn: 354804
2019-02-25 18:32:46 +00:00
Tatyana Krasnukha 96585d11fb [lldb-mi] Fix conversion warning for 64-bit build
llvm-svn: 354803
2019-02-25 18:23:44 +00:00
Tatyana Krasnukha 2a4c1f3e5b [lldb-mi] Check raw pointers before passing them to std::string ctor/assignment
Differential Revision: https://reviews.llvm.org/D55653

llvm-svn: 354798
2019-02-25 16:40:11 +00:00
Jonas Devlieghere 936c62422f [Reproducers] Initialize reproducers before initializing the debugger.
As per the discussion on the mailing list:
http://lists.llvm.org/pipermail/lldb-commits/Week-of-Mon-20190218/048007.html

This commit implements option (3):

> Go back to initializing the reproducer before the rest of the debugger.
> The method wouldn't be instrumented and guarantee no other SB methods are
> called or SB objects are constructed. The initialization then becomes part
> of the replay.

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

llvm-svn: 354631
2019-02-21 22:26:16 +00:00
Jonas Devlieghere b7c22314c3 [lldb-instr] Group RECORD macros
Group LLDB_RECORD macros per input file.

llvm-svn: 354423
2019-02-20 01:49:10 +00:00
Jonas Devlieghere ee04d4d840 [lldb-instr] Don't print REGISTER macro when RECORD is already present
Currently we'd always print the LLDB_REGISTER macro, even if the
LLDB_RECORD macro was already present. This patches changes that to make
it easier to incrementally update the macros.

Note that it's still possible for the RECORD and REGISTER macros to get
out of sync.

llvm-svn: 354400
2019-02-19 23:13:29 +00:00
Jonas Devlieghere 091b925284 [lldb-instr] Wrap returns of struct/classes in LLDB_RECORD_RESULT
The instrumentation framework requires return values of custom classes
and structs to be wrapped in the LLDB_RECORD_RESULT macro.

llvm-svn: 354301
2019-02-19 01:04:31 +00:00
Jason Molenda 461c416878 One more fix while I'm looking at this - remove the
unused IsSBProcess method, and have IsFBSProcess
return false if we don't have API that we can use to
make that determination, so we'll try other API
if we can.

llvm-svn: 354289
2019-02-18 22:18:11 +00:00
Jason Molenda 870c0a648b Ah, misunderstood Jonas' feedback - fix this so we'll
do the right thing when both API are available.  We
want to try both of them if the first one fails.

llvm-svn: 354288
2019-02-18 22:13:34 +00:00
Jason Molenda 5044316d16 Clean up an unused variable warning when building this for
mac native.

llvm-svn: 354287
2019-02-18 22:10:23 +00:00
Jason Molenda 3bf883eac9 Add some unconditional logging on the failure points when attaching
to a process so we'll always get messages in the console logs.  

Also make the "is frontboard process" / "is backboard process"
determination lazy, specifically take it out of the
MachProcess::AttachForDebug codepath when we are attaching to a
process, to simplify attaching.

<rdar://problem/47982516> 
<rdar://problem/48060134> 

llvm-svn: 354181
2019-02-15 22:39:30 +00:00
Michal Gorny 2d874e5356 [lldb] [lldb-server] Catch and report errors from main loop
Catch the possible error from lldb-gdbserver's main loop, and report
it verbosely.  Currently, if the loop fails the server exits normally,
rendering the problem indistinguishable from regular termination.

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

llvm-svn: 354030
2019-02-14 13:52:37 +00:00
Jonas Devlieghere d5b440369d Replace 'ap' with 'up' suffix in variable names. (NFC)
The `ap` suffix is a remnant of lldb's former use of auto pointers,
before they got deprecated. Although all their uses were replaced by
unique pointers, some variables still carried the suffix.

In r353795 I removed another auto_ptr remnant, namely redundant calls to
::get for unique_pointers. Jim justly noted that this is a good
opportunity to clean up the variable names as well.

I went over all the changes to ensure my find-and-replace didn't have
any undesired side-effects. I hope I didn't miss any, but if you end up
at this commit doing a git blame on a weirdly named variable, please
know that the change was unintentional.

llvm-svn: 353912
2019-02-13 06:25:41 +00:00
Jonas Devlieghere 1ca9dd8507 [lldb-instr] Pass PCHContainerOperations to ClangTool
On a local modules build this would cause an error.

> fatal error: no handler registered for module format 'obj'
> LLVM ERROR: unknown module format

Interestingly enough, this didn't trigger on the GreenDragon CMake bot,
which is configured with modules.

llvm-svn: 353869
2019-02-12 18:19:34 +00:00
Jonas Devlieghere 796ac80b86 Use std::make_shared in LLDB (NFC)
Unlike std::make_unique, which is only available since C++14,
std::make_shared is available since C++11. Not only is std::make_shared
a lot more readable compared to ::reset(new), it also performs a single
heap allocation for the object and control block.

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

llvm-svn: 353764
2019-02-11 23:13:08 +00:00
Michal Gorny f68b6cbae2 [lldb] [lldb-instr] Add missing linkage to clang libraries
Fix build errors against shared clang by adding all the libraries used
in the code.

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

llvm-svn: 353680
2019-02-11 10:02:26 +00:00
Adrian Prantl 238ce2128c Silence fallthrough warnings in debugserver.
llvm-svn: 353468
2019-02-07 21:22:38 +00:00
Pavel Labath 76016ba1ca Fix some warnings introduced in r353324 (ReproducerInstrumentation patch)
GetIndexForObjectImpl generated a bunch of "conversion casts away
constness warnings". Change the function to use "const void *" (and
static_cast, while I'm at it), to avoid this.

Driver.cpp: unused variable "replay" (this was actually caused by a
subsequent partial revert of this patch). I just finish the revert by
removing the variable completely.

llvm-svn: 353405
2019-02-07 13:51:38 +00:00
Jonas Devlieghere 9a7356a60f [Driver] Don't try to replay reproducer in the driver.
Because the macros for the SBReproducers have not been committed yet,
the driver should not attempt to replay a reproducer this way.

llvm-svn: 353362
2019-02-07 01:49:07 +00:00
Jonas Devlieghere 58947cf854 [Reproducers] SBReproducer framework: Capture & Replay
This is part two of the reproducer instrumentation framework. It
contains the code to capture and replay function calls. The main user of
this framework will be the SB API layer.

For all the details refer to the RFC on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2019-January/014530.html

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

llvm-svn: 353324
2019-02-06 18:57:42 +00:00
Jonas Devlieghere edff5f4b21 [Reproducers] lldb-instr: tool to generate instrumentation macros.
This patch introduces a new tool called 'lldb-instr'. It automates the
workflow of inserting LLDB_RECORD and LLDB_REGSITER macros for
instrumentation.

Because the tool won't be part of the build process, I didn't want to
over-complicate it. SB_RECORD macros are inserted in place, while
SB_REGISTER macros are printed to stdout, and have to be manually copied
into the Registry's constructor. Additionally, the utility makes no
attempt to properly format the inserted macros. Please use clang-format
to format the changes after running the tool.

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

llvm-svn: 353271
2019-02-06 04:33:14 +00:00
Stefan Granitz 61db81d8d0 [CMake] Add code signing for lldb-server on iOS
llvm-svn: 352388
2019-01-28 16:57:23 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Alex Langford cb1c467edb [CMake] Prevent lldbDebugserverCommon from building if you disable debugserver builds
Summary:
The flags `LLDB_USE_SYSTEM_DEBUGSERVER` and `LLDB_NO_DEBUGSERVER` were
introduced to the debugserver build. If one of these two flags are set, then we
do not build and sign debugserver. However I noticed that we were still building
the lldbDebugserverCommon and lldbDebugserverCommon_NonUI libraries regardless
of whether or not these flags were set. I don't believe we should be building
these libraries unless we are building and signing debugserver.

Reviewers: sgraenitz, davide, JDevlieghere, beanz, vsk, aprantl, labath

Subscribers: mgorny, jfb, lldb-commits

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

llvm-svn: 351496
2019-01-17 23:14:04 +00:00
Alex Langford f510bc7972 [lldb-mi] Remove use of dialog box
Summary:
This really is only implemented on Windows, and it requires us to pull
in User32. This was only useful when debugging on lldb-mi on Windows, and there
doesn't seem to be a good reason why using a dialog box is better than what
exists for other platforms.

Reviewers: zturner, jingham, compnerd

Subscribers: ki.stfu

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

llvm-svn: 351276
2019-01-16 00:09:50 +00:00
Alex Langford 76cb3089de [debugserver][CMake] Remove commented out line
This has been commented out since rL300111
(commit d742d081f3a1e7412cc609765139ba32d597ac15). Looks like it was
committed as a commented out line, so I'm removing it.

llvm-svn: 351263
2019-01-15 22:27:59 +00:00
Zachary Turner 576495e67b [SymbolFile] Remove SymbolContext parameter from FindTypes.
This parameter was only ever used with the Module set, and
since a SymbolFile is tied to a module, the parameter turns
out to be entirely unnecessary.  Furthermore, it doesn't make
a lot of sense to ask a caller to ask SymbolFile which is tied
to Module X to find types for Module Y, but that possibility
was open with the previous interface.  By removing this
parameter from the API, it makes it harder to use incorrectly
as well as easier for an implementor to understand what it
needs to do.

llvm-svn: 351133
2019-01-14 22:41:21 +00:00
Zachary Turner c0a246afbe [SymbolFile] Remove the SymbolContext parameter from FindNamespace.
Every callsite was passing an empty SymbolContext, so this parameter
had no effect.  Inside the DWARF implementation of this function,
however, there was one codepath that checked members of the
SymbolContext.  Since no call-sites actually ever used this
functionality, it was essentially dead code, so I've deleted this
code path as well.

llvm-svn: 351132
2019-01-14 22:41:00 +00:00
Pavel Labath 1cf23e1a37 Introduce SymbolFileBreakpad and use it to fill symtab
Summary:
This commit adds the glue code necessary to integrate the
SymbolFileBreakpad into the plugin system. Most of the methods are
stubbed out. The only method implemented method is AddSymbols, which
parses the PUBLIC "section" of the breakpad "object file", and fills out
the Module's symtab.

To enable testing this, I've made two additional changes:
- dump Symtab from the SymbolVendor class. The symtab was already being
  dumped as a part of the object file dump, but that happened before
  symbol vendor kicked in, so it did not reflect any symbols added
  there.
- add ability to explicitly specify the external symbol file in
  lldb-test (so that the object file could be linked with the breakpad
  symbol file). To make things simpler, I've changed lldb-test from
  consuming multiple inputs (and dumping their symbols) to having it
  just process a single file per invocation. This was not a problem
  since everyone was using it that way already.

Reviewers: clayborg, zturner, lemo, markmentovai, amccarth

Subscribers: mgorny, lldb-commits

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

llvm-svn: 350924
2019-01-11 11:17:51 +00:00
Pavel Labath 976af43ba9 Implement ObjectFileELF::GetBaseAddress
Summary:
The concept of a base address was already present in the implementation
(it's needed for computing section load addresses properly), but it was
never exposed through this function. This fixes that.

llvm-svn: 350804
2019-01-10 09:32:31 +00:00
Aaron Smith e55850be23 [lldb-server] Add unnamed pipe support to PipeWindows
Summary:
This adds unnamed pipe support in PipeWindows to support communication between a debug server and child process.
Modify PipeWindows::CreateNew to support the creation of an unnamed pipe.
Rename the previous method that created a named pipe to PipeWindows::CreateNewNamed.

Reviewers: zturner, llvm-commits

Reviewed By: zturner

Subscribers: Hui, labath, lldb-commits

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

llvm-svn: 350784
2019-01-10 00:46:09 +00:00
Zachary Turner c68925aba3 Change lldb-test to use ParseAllDebugSymbols.
ParseDeclsForContext was originally created to serve the very specific
case where the context is a function block. It was never intended to be
used for arbitrary DeclContexts, however due to the generic name, the
DWARF and PDB plugins implemented it in this way "just in case". Then,
lldb-test came along and decided to use it in that way.

Related to this, there are a set of functions in the SymbolFile class
interface whose requirements and expectations are not documented. For
example, if you call ParseCompileUnitFunctions, there's an inherent
requirement that you create entries in the underlying clang AST for
these functions as well as their signature types, because in order to
create an lldb_private::Function object, you have to pass it a
CompilerType for the parameter representing the signature.

On the other hand, there is no similar requirement (either inherent or
documented) if one were to call ParseDeclsForContext. Specifically, if
one calls ParseDeclsForContext, and some variable declarations, types,
and other things are added to the clang AST, is it necessary to create
lldb::Variable, lldb::Type, etc objects representing them? Nobody knows.
There is, however, an accidental requirement, because since all of the
plugins implemented this just in case, lldb-test came along and used
ParsedDeclsForContext, and then wrote check lines that depended on this.

When I went to try and implemented the NativePDB reader, I did not
adhere to this (in fact, from a layering perspective I went out of my
way to avoid it), and as a result the existing DIA PDB tests don't work
when the native PDB reader is enabled, because they expect that calling
ParseDeclsForContext will modify the *module's* view of symbols, and not
just the internal AST.

All of this confusion, however, can be avoided if we simply stick to
using ParseDeclsForContext for its original intended use case (blocks),
and use a different function (ParseAllDebugSymbols) for its intended use
case which is, unsuprisingly, to parse all the debug symbols (which is
all lldb-test really wanted to do anyway).

In the future, I would like to change ParseDeclsForContext to
ParseDeclsForFunctionBlock, then delete all of the dead code inside that
handles other types of DeclContexts (and probably even assert if the
DeclContext is anything other than a block).

A few PDB tests needed to be fixed up as a result of this, and this also
exposed a couple of bugs in the DIA PDB reader (doesn't matter much
since it should be going away soon, but worth mentioning) where the
appropriate AST entries weren't being created always.

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

llvm-svn: 350764
2019-01-09 21:20:44 +00:00
Jonas Devlieghere 243d0415c6 [CMakeLists] Sort tools/CMakeLists.txt
llvm-svn: 350682
2019-01-09 00:31:30 +00:00
Jonas Devlieghere e6366a85b5 [Driver] Some more cleanup. NFC
llvm-svn: 350446
2019-01-05 00:01:04 +00:00
Stefan Granitz 5d005a856d [CMake] Revised RPATH handling
Summary:
If we build LLDB.framework, dependant tools need appropriate RPATHs in both locations, the build-tree (for testing) and the install-tree (for deployment). Luckily, CMake can handle it for us: https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling.

* In the build-tree, tools use the absolute path to the framework's actual output location.
* In the install-tree, tools get a list of RPATHs to look for the framework when deployed.

`LLDB_FRAMEWORK_INSTALL_DIR` is added to the `CMAKE_INSTALL_PREFIX` to change the relative location of LLDB.framework in the install-tree.
If it is not empty, it will be added as an additional RPATH to all dependant tools (so they are functional in the install-tree).
If it is empty, LLDB.framework goes to the root and tools will not be functional in the directory structure of the LLVM install-tree.
For historical reasons `LLDB_FRAMEWORK_INSTALL_DIR` defaults to "Library/Frameworks".

Reviewers: xiaobai, JDevlieghere, aprantl, clayborg

Reviewed By: JDevlieghere

Subscribers: ki.stfu, mgorny, lldb-commits, #lldb

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

llvm-svn: 350392
2019-01-04 12:46:57 +00:00
Stefan Granitz f126ce6881 [CMake] Revised LLDB.framework builds
Summary:
Add features to LLDB CMake builds that have so far only been available in Xcode. Clean up a few inconveniences and prepare further improvements.

Options:
* `LLDB_FRAMEWORK_BUILD_DIR` determines target directory (in build-tree)
* `LLDB_FRAMEWORK_INSTALL_DIR` **only** determines target directory in install-tree
* `LLVM_EXTERNALIZE_DEBUGINFO` allows externalized debug info (dSYM on Darwin, emitted to `bin`)
* `LLDB_FRAMEWORK_TOOLS` determines which executables will be copied to the framework's Resources (dropped symlinking, removed INCLUDE_IN_SUITE, removed dummy targets)

Other changes:
* clean up `add_lldb_executable()`
* include `LLDBFramework.cmake` from `source/API/CMakeLists.txt`
* use `*.plist.in` files, which are typical for CMake and independent from Xcode
* add clang headers to the framework bundle

Reviewers: xiaobai, JDevlieghere, aprantl, davide, beanz, stella.stamenova, clayborg, labath

Reviewed By: aprantl

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

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

llvm-svn: 350391
2019-01-04 12:46:50 +00:00
Stefan Granitz d0dc161f62 [CMake] Move debugserver options to separate debugserverConfig.cmake
Summary:
One place for debugserver options, analog to LLDBConfig for LLDB options (see D55317). It was discussed in earlier reviews already, e.g. D55013.

Reviewers: JDevlieghere, aprantl, xiaobai

Reviewed By: aprantl, xiaobai

Subscribers: mgorny, lldb-commits, #lldb

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

llvm-svn: 350390
2019-01-04 12:46:38 +00:00
Stefan Granitz 90aeb4c8d9 [CMake] Streamline code signing for debugserver #2
Summary:
Major fixes after D54476 (use Diff1 as base for comparison to see only recent changes):
* In standalone builds target directory for debugserver must be LLDB's bin, not LLVM's bin
* Default identity for code signing must not force-override LLVM_CODESIGNING_IDENTITY globally

We have a lot of cases, make them explicit:

* ID used for code signing (debugserver and in tests):
** `LLDB_CODESIGN_IDENTITY` if set explicitly, or otherwise
** `LLVM_CODESIGNING_IDENTITY` if set explicitly, or otherwise
** `lldb_codesign` as the default

* On Darwin we have a debugserver target that:

* On other systems, the debugserver target is not defined, which is equivalent to **[3A]**

Common configurations on Darwin:
* **[1A]** `cmake -GNinja ../llvm` builds debugserver from source and signs with `lldb_codesign`, no code signing for other binaries (prints status: //lldb debugserver: /path/to/bin/debugserver//)
* **[1A]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- -DLLDB_CODESIGN_IDENTITY=lldb_codesign ../llvm` builds debugserver from source and signs with `lldb_codesign`, ad-hoc code signing for other binaries (prints status: //lldb debugserver: /path/to/bin/debugserver//)
* **[2A]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- -DLLDB_USE_SYSTEM_DEBUGSERVER=ON ../llvm` copies debugserver from system, ad-hoc code signing for other binaries (prints status: //Copy system debugserver from: /path/to/system/debugserver//)
* **[2B]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- ../llvm` same, but prints additional warning: //Cannot code sign debugserver with identity '-'. Will fall back to system's debugserver. Pass -DLLDB_CODESIGN_IDENTITY=lldb_codesign to override the LLVM value for debugserver.//
* **[3A]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- -DLLDB_NO_DEBUGSERVER=ON ../llvm` debugserver not available (prints status: //lldb debugserver will not be available)//

Reviewers: JDevlieghere, beanz, davide, vsk, aprantl, labath

Reviewed By: JDevlieghere, labath

Subscribers: mgorny, #lldb, lldb-commits

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

llvm-svn: 350388
2019-01-04 12:46:30 +00:00
Jonas Devlieghere 9eba99ba66 [Driver] Remove unused imports
Removes some unneeded includes from the driver.

llvm-svn: 350267
2019-01-02 22:38:16 +00:00
Pavel Labath a352ed208b lldb-test ir-memory-map: Use IntervalMap::contains
Summary:
Simplify the code by using the contains implementation in IntervalMap.

There is a slight change of behavior here: We now treat an allocation of
size 0, as if it was size 1. This guarantees that the returned addresses
will be unique, whereas previously we would allow the allocation
function to return the same zero-sized region multiple times, as long as
it is not null, and not in the middle of an existing interval (but the
situation when we were placing an larger interval over a zero-sized one
was not detected).

I think this behavior makes more sense, as that is pretty much the same
guarantee as offered by malloc (except that is permitted to also return
nullptr).

Reviewers: vsk

Subscribers: lldb-commits

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

llvm-svn: 350087
2018-12-27 09:32:04 +00:00
Jonas Devlieghere 8d20cfdfc6 [NFC] Replace `compare` with (in)equality operator where applicable.
Using compare is verbose, bug prone and potentially inefficient (because
of early termination). Replace relevant call sites with the (in)equality
operator.

llvm-svn: 349972
2018-12-21 22:46:10 +00:00
Jason Molenda 681f6c2f55 Un-conditionalize use of libcompression. debugserver only builds
on Darwin systems and libcompression has been in the OS for over
three years. 

Remove use of / linking to zlib.  We'll always have libcompression
available now.

Create a scratch buffer via compression_encode_scratch_buffer_size()
and use it in calls to compression_encode_buffer() to avoid 
compression_encode_buffer having to malloc & free a scratch buffer
on each call.  

Tested by forcing compression to be enabled on macos native (normally
only enabled on iOS et al devices), running the testsuite.

<rdar://problem/41601084>

llvm-svn: 349553
2018-12-18 22:21:48 +00:00
Pavel Labath 0d38e4fd2c ELF: Don't create sections for section header index 0
Summary:
The first section header does not define a real section. Instead it is
used for various elf extensions. This patch skips creation of a section
for index 0.

This has one furtunate side-effect, in that it allows us to use the section
header index as the Section ID (where 0 is also invalid). This way, we
can get rid of a lot of spurious +1s in the ObjectFileELF code.

Reviewers: clayborg, krytarowski, joerg, espindola

Subscribers: emaste, lldb-commits, arichardson

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

llvm-svn: 349498
2018-12-18 15:56:45 +00:00
Jonas Devlieghere 7e89627728 [Driver] Fix --repl argument.
The --repl option was incorrectly defined as "Separate" (option and
value separated by a space). This resulted in the option not being
picked up when no value was specified.

This patch fixes the driver so that `--repl` is recognized again. I
split the option into two:

 - A flag: `--repl` and `-r` which take no arguments.
 - A joined option: `--repl=<flags>` and `-r=<flags>` that forward its
   values to the repl.

This should match the driver's old behavior.

llvm-svn: 349371
2018-12-17 18:11:48 +00:00
Pavel Labath d211d1a59c lldb-test: Improve newline handling
Summary:
Previously lldb-test's LinePrinter would output the indentation spaces
even on completely empty lines. This is not nice, as trailing spaces get
flagged as errors in some tools/editors, and it prevents FileCheck's
CHECK-EMPTY from working.

Equally annoying was the fact that the LinePrinter did not terminate
it's output with a newline (instead it would leave the unterminated hanging
indent from the last NewLine() command), which meant that the shell prompt
following the lldb-test command came out wrong.

This fixes both issues by changing how newlines are handled. NewLine(),
which was ending the previous line ('\n') *and* begging the next line by
printing the indent, is now "demoted" to just printing literal "\n".
Instead, lines are now delimited via a helper Line object, which makes
sure the line is indented and terminated in an RAII fashion. The typical
usage would be:
Printer.line() << "This text will be indented and terminated";
If one needs to do more work than it will fit into a single statement,
one can also assign the result of the line() function to a local
variable. The line will then be terminated when that object goes out of
scope.

Reviewers: zturner

Subscribers: lldb-commits

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

llvm-svn: 349269
2018-12-15 13:49:25 +00:00
Pavel Labath 62a8254f29 ELF: more section creation cleanup
Summary:
This patch attempts to move as much code as possible out of the
CreateSections function to make room for future improvements there. Some
of this may be slightly over-engineered (VMAddressProvider), but I
wanted to keep the logic of this function very simple, because once I
start taking segment headers into acount (as discussed in D55356), the
function is going to grow significantly.

While in there, I also added tests for various bits of functionality.

This should be NFC, except that I changed the order of hac^H^Heuristicks
for determining section type slightly. Previously, name-based deduction
(.symtab -> symtab) would take precedence over type-based (SHT_SYMTAB ->
symtab) one. In fact we would assert if we ran into a .text section with
type SHT_SYMTAB. Though unlikely to matter in practice, this order
seemed wrong to me, so I have inverted it.

Reviewers: clayborg, krytarowski, espindola

Subscribers: emaste, arichardson, lldb-commits

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

llvm-svn: 349268
2018-12-15 13:45:38 +00:00
Jonas Devlieghere a6682a413d Simplify Boolean expressions
This patch simplifies boolean expressions acorss LLDB. It was generated
using clang-tidy with the following command:

run-clang-tidy.py -checks='-*,readability-simplify-boolean-expr' -format -fix $PWD

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

llvm-svn: 349215
2018-12-15 00:15:33 +00:00
Pavel Labath ef8683abec ELF: Clean up section type computation
Move code into a separate function, and replace the if-else chain with
llvm::StringSwitch.

A slight behavioral change is that now I use the section flags
(SHF_TLS) instead of the section name to set the thread-specific
property. There is no explanation in the original commit introducing
this (r153537) as to why that was done this way, but the new behavior
should be more correct.

llvm-svn: 348936
2018-12-12 15:46:18 +00:00
Pavel Labath 280d2e8179 lldb-test: Add ability to dump subsections
Previously, lldb-test would only print top-level sections. However, in
lldb, sections can contain other sections. This teaches lldb-test to
print nested sections too.

llvm-svn: 348924
2018-12-12 12:35:25 +00:00
Jonas Devlieghere fb3e58920d [Driver] Simplify OptionData. NFC
Hopefully this makes the option data easier to understand and maintain.

 - Group the member variables.
 - Do the initialization in the header as it's less error prone.
 - Rename the Clean method. It was called only once and was
   re-initializing some but not all (?) members. The only useful thing it
   does is dealing with the local lldbinit file so keep that and make the
   name reflect that.

llvm-svn: 348894
2018-12-11 20:19:53 +00:00
Pavel Labath 1f6b247717 Re-commit "Introduce ObjectFileBreakpad"
This re-commits r348592, which was reverted due to a failing test on
macos.

The issue was that I was passing a null pointer for the
"CreateMemoryInstance" callback when registering ObjectFileBreakpad,
which caused crashes when attemping to load modules from memory. The
correct thing to do is to pass a callback which always returns a null
pointer (as breakpad files are never loaded in inferior memory).

It turns out that there is only one test which exercises this code path,
and it's mac-only, so I've create a new test which should run everywhere
(except windows, as one cannot delete an executable which is being run).
Unfortunately, this test still fails on linux for other reasons, but at
least it gives us something to aim for.

The original commit message was:
This patch adds the scaffolding necessary for lldb to recognise symbol
files generated by breakpad. These (textual) files contain just enough
information to be able to produce a backtrace from a crash
dump. This information includes:
- UUID, architecture and name of the module
- line tables
- list of symbols
- unwind information

A minimal breakpad file could look like this:
MODULE Linux x86_64 0000000024B5D199F0F766FFFFFF5DC30 a.out
INFO CODE_ID 00000000B52499D1F0F766FFFFFF5DC3
FILE 0 /tmp/a.c
FUNC 1010 10 0 _start
1010 4 4 0
1014 5 5 0
1019 5 6 0
101e 2 7 0
PUBLIC 1010 0 _start
STACK CFI INIT 1010 10 .cfa: $rsp 8 + .ra: .cfa -8 + ^
STACK CFI 1011 $rbp: .cfa -16 + ^ .cfa: $rsp 16 +
STACK CFI 1014 .cfa: $rbp 16 +

Even though this data would normally be considered "symbol" information,
in the current lldb infrastructure it is assumed every SymbolFile object
is backed by an ObjectFile instance. So, in order to better interoperate
with the rest of the code (particularly symbol vendors).

In this patch I just parse the breakpad header, which is enough to
populate the UUID and architecture fields of the ObjectFile interface.
The rough plan for followup patches is to expose the individual parts of
the breakpad file as ObjectFile "sections", which can then be used by
other parts of the codebase (SymbolFileBreakpad ?) to vend the necessary
information.

Reviewers: clayborg, zturner, lemo, amccarth

Subscribers: mgorny, fedor.sergeev, markmentovai, lldb-commits

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

llvm-svn: 348773
2018-12-10 17:16:38 +00:00
Shafik Yaghmour 48c7b4f0b6 Revert "Introduce ObjectFileBreakpad"
This reverts commit 5e056e624cc57bb22a4c29a70b522783c6242293.

Reverting because this lldb cmake bot: http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/13712/

llvm-svn: 348629
2018-12-07 18:59:00 +00:00
Pavel Labath d6e6e232ec Introduce ObjectFileBreakpad
Summary:
This patch adds the scaffolding necessary for lldb to recognise symbol
files generated by breakpad. These (textual) files contain just enough
information to be able to produce a backtrace from a crash
dump. This information includes:
- UUID, architecture and name of the module
- line tables
- list of symbols
- unwind information

A minimal breakpad file could look like this:
MODULE Linux x86_64 0000000024B5D199F0F766FFFFFF5DC30 a.out
INFO CODE_ID 00000000B52499D1F0F766FFFFFF5DC3
FILE 0 /tmp/a.c
FUNC 1010 10 0 _start
1010 4 4 0
1014 5 5 0
1019 5 6 0
101e 2 7 0
PUBLIC 1010 0 _start
STACK CFI INIT 1010 10 .cfa: $rsp 8 + .ra: .cfa -8 + ^
STACK CFI 1011 $rbp: .cfa -16 + ^ .cfa: $rsp 16 +
STACK CFI 1014 .cfa: $rbp 16 +

Even though this data would normally be considered "symbol" information,
in the current lldb infrastructure it is assumed every SymbolFile object
is backed by an ObjectFile instance. So, in order to better interoperate
with the rest of the code (particularly symbol vendors).

In this patch I just parse the breakpad header, which is enough to
populate the UUID and architecture fields of the ObjectFile interface.
The rough plan for followup patches is to expose the individual parts of
the breakpad file as ObjectFile "sections", which can then be used by
other parts of the codebase (SymbolFileBreakpad ?) to vend the necessary
information.

Reviewers: clayborg, zturner, lemo, amccarth

Subscribers: mgorny, fedor.sergeev, markmentovai, lldb-commits

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

llvm-svn: 348592
2018-12-07 14:20:27 +00:00
Aaron Smith 037ed1befd [pecoff] Implement ObjectFilePECOFF::GetDependedModules()
Summary:
This parses entries in pecoff import tables for imported DLLs and
is intended as the first step to allow LLDB to load a PE's shared
modules when creating a target on the LLDB console. 


Reviewers: rnk, zturner, aleksandr.urakov, lldb-commits, labath, asmith

Reviewed By: labath, asmith

Subscribers: labath, lemo, clayborg, Hui, mgorny, mgrang, teemperor

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

llvm-svn: 348527
2018-12-06 21:36:39 +00:00
Jonas Devlieghere 15eacd741f [Reproducers] Change how reproducers are initialized.
This patch changes the way the reproducer is initialized. Rather than
making changes at run time we now do everything at initialization time.
To make this happen we had to introduce initializer options and their SB
variant. This allows us to tell the initializer that we're running in
reproducer capture/replay mode.

Because of this change we also had to alter our testing strategy. We
cannot reinitialize LLDB when using the dotest infrastructure. Instead
we use lit and invoke two instances of the driver.

Another consequence is that we can no longer enable capture or replay
through commands. This was bound to go away form the beginning, but I
had something in mind where you could enable/disable specific providers.
However this seems like it adds very little value right now so the
corresponding commands were removed.

Finally this change also means you now have to control this through the
driver, for which I replaced --reproducer with --capture and --replay to
differentiate between the two modes.

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

llvm-svn: 348152
2018-12-03 17:28:29 +00:00
Stefan Granitz 10c1116c09 [CMake] Fix standalone build for debugserver on macOS
Summary:
Quick-fix to avoid CMake config issue:
```
CMake Error at /path/to/lldb/cmake/modules/AddLLDB.cmake:116 (add_dependencies):
  Cannot add target-level dependencies to non-existent target "lldb-suite".
```

Reviewers: xiaobai, beanz

Subscribers: mgorny, lldb-commits

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

llvm-svn: 347869
2018-11-29 14:51:49 +00:00