Commit Graph

1931 Commits

Author SHA1 Message Date
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
Pavel Labath 10c63835ad Fix windows build broken by r347846
The changed order of includes caused compile errors on MSVC due to
snprintf macro definition. snprintf should available since VS2015, and
the rest of the code seems to be able to use snprintf just fine without
this macro, so this removes it from the lldb driver as well.

llvm-svn: 347855
2018-11-29 11:53:12 +00:00
Pavel Labath 7b968969db Remove getopt includes from the driver
They are not needed now that we use LLVMOption for command-line parsing
thank you, Jonas).  This also allows us to avoid linking of lldbHost
into the driver which was breaking liblldb encapsulation.

(Technically, there is still a lldb/Host/windows/windows.h include which
is needed on windows, but this is a header-only wrapper for <windows.h>,
so it is not necessary to link lldbHost for that. But ideally, that
should go away too.)

llvm-svn: 347846
2018-11-29 10:45:41 +00:00
Jonas Devlieghere cef2af0f3c [driver] Fix --core/-c and add test
Because the optarg variable was shadowed we didn't notice we weren't
extracting the value from the option. This patch fixes that and renames
the variable to prevent this from happening in the future.

I also added two tests to check the error output for --core and --file
when the given value doesn't exist.

llvm-svn: 347821
2018-11-29 00:22:28 +00:00
Jonas Devlieghere b02baf0a7e [driver] Some NFC cleanup
This patch includes some small things I noticed while refactoring the
driver but didn't want to include in that patch.

llvm-svn: 347817
2018-11-28 22:39:17 +00:00
Jonas Devlieghere 68ed93d252 [Reproducers] Improve reproducer API and add unit tests.
When I landed the initial reproducer framework I knew there were some
things that needed improvement. Rather than bundling it with a patch
that adds more functionality I split it off into this patch. I also
think the API is stable enough to add unit testing, which is included in
this patch as well.

Other improvements include:

 - Refactor how we initialize the loader and generator.
 - Improve naming consistency: capture and replay seems the least ambiguous.
 - Index providers by name and make sure there's only one of each.
 - Add convenience methods for creating and accessing providers.

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

llvm-svn: 347716
2018-11-27 22:11:02 +00:00
Jonas Devlieghere 00eae5ea31 [Driver] Use libOption with tablegen.
This patch modifies the lldb driver to use libOption for option parsing.
It allows us to decouple option parsing from option processing which is
important when arguments affect initialization. This was previously not
possible because the debugger need to be initialized as some option
interpretation (like the scripting language etc) was handled by the
debugger, rather than in the driver.

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

llvm-svn: 347709
2018-11-27 21:00:32 +00:00
Davide Italiano 3bd249018c Revert "[CMake] Streamline code signing for debugserver and pass entitlements to extended llvm_codesign"
It breaks the lldb cmake bots.

llvm-svn: 347619
2018-11-27 00:25:49 +00:00
Stefan Granitz 6e6b4ac18e [CMake] Streamline code signing for debugserver and pass entitlements to extended llvm_codesign
Summary:
Use llvm_codesign to sign debugserver with entitlements.
Set global LLVM_CODESIGNING_IDENTITY from LLDB_CODESIGN_IDENTITY (if given).
Pass through ENTITLEMENTS from add_lldb_executable to add_llvm_executable.
Handle reconfigurations correctly.

We have a lot of cases, make them explicit:

(1) build and sign debugserver, if all conditions apply:
* LLDB_NO_DEBUGSERVER=OFF (default)
* On Darwin: LLDB_USE_SYSTEM_DEBUGSERVER=OFF (default)
* On Darwin: LLVM_CODESIGNING_IDENTITY == lldb_codesign

(2) use system debugserver, if on Darwin and any of:
* LLDB_USE_SYSTEM_DEBUGSERVER=ON and found on system (explicit case)
* LLVM_CODESIGNING_IDENTITY != lldb_codesign and found on system (fallback case)

(3) debugserver will not be available, in case of:
* LLDB_NO_DEBUGSERVER=ON
* On Darwin: LLVM_CODESIGNING_IDENTITY != lldb_codesign and not found on system

(4) error state, in case of:
* LLDB_USE_SYSTEM_DEBUGSERVER=ON and not found on system
* LLDB_USE_SYSTEM_DEBUGSERVER=ON and LLDB_NO_DEBUGSERVER=ON

Reviewers: xiaobai, beanz, vsk, JDevlieghere

Subscribers: mgorny, lldb-commits, llvm-commits

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

llvm-svn: 347305
2018-11-20 14:10:33 +00:00
Nathan Lanza a0d52cbdc9 Add a check whether or not a str is utf8 prior to emplacing
Summary:
Highlighing junk data on VSCode can send a query for evaluate which
fails. In particular cases on Windows, this the error message can end
up as a c-string of [-35,-35,-35,-35,...]. Attempting to emplace this
as the error message causes an assert failure.

Prior to emplacing the error message, confirm that it is valid UTF8 to
eliminate errors such as mentione above.

Reviewers: xiaobai, clayborg

Reviewed By: clayborg

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

llvm-svn: 346988
2018-11-15 19:49:57 +00:00
Jonas Devlieghere 9e046f02e3 Add GDB remote packet reproducer.
llvm-svn: 346780
2018-11-13 19:18:16 +00:00
Jonas Devlieghere ceff6644bb Remove header grouping comments.
This patch removes the comments grouping header includes. They were
added after running IWYU over the LLDB codebase. However they add little
value, are often outdates and burdensome to maintain.

llvm-svn: 346626
2018-11-11 23:17:06 +00:00
Jonas Devlieghere 672d2c1255 Remove comments after header includes.
This patch removes the comments following the header includes. They were
added after running IWYU over the LLDB codebase. However they add little
value, are often outdates and burdensome to maintain.

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

llvm-svn: 346625
2018-11-11 23:16:43 +00:00
Jason Molenda a9796ede39 Enable listening for EXC_RESOURCE events, and format mach
event as a thread stop reason if we receive one, using 
some macros to decode the payload.  

Patch originally written by Fred Riss, with a few small changes
by myself.

Writing a test for this is a little tricky because the 
mach exception data interpretation relies on header macros
or function calls - it may change over time and writing
a gdb_remote_client test for this would break as older 
encoding interpretation is changed.  I'll tak with Fred
about this more, but neither of us has been thrilled with
the kind of tests we could write for it.

<rdar://problem/13097323>, <rdar://problem/40144456> 

llvm-svn: 346571
2018-11-10 00:14:14 +00:00
Jason Molenda a1050973ed Remove llvm include from debugserver, change
LLVM_FALLTHROUGH's to [[clang::fallthrough]] -
debugserver is only ever compiled on darwin
systems with clang.

llvm-svn: 346553
2018-11-09 20:31:41 +00:00
Adrian Prantl 567906d8c7 Add missing include
llvm-svn: 346527
2018-11-09 17:58:05 +00:00
Adrian Prantl 69cf5571e3 Add missing include
llvm-svn: 346525
2018-11-09 17:44:20 +00:00
Adrian Prantl 96d37cf537 Annotate switch with LLVM_FALLTHROUGH
llvm-svn: 346519
2018-11-09 17:11:17 +00:00
Nathan Lanza 067cc509d0 Adjust some id bit shifts to fit inside 32 bit integers
Summary:
The DAP on vscode uses a JavaScript `number` for identifiers while the
Visual Studio version uses a C# `Int` for identifiers. lldb-vscode is
bit shifting identifiers 32 bits and then bitwise ORing another 32 bit
identifier into a 64 bit id to form a unique ID. Change this to
a a partitioning of the 32 bits that makes sense for the data types.

Reviewers: clayborg

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

llvm-svn: 346346
2018-11-07 19:27:36 +00:00
Nathan Lanza 5652cd3fe9 Remove working directory for debugserver code signing target
Summary:
LLVM puts output binaries in
`${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin`. This chunk of
code left out the `${CMAKE_CFG_INTDIR}`. Ultimately, the code signing target
does not need a working directory anyways, so it's safe to just remove it.

Reviewers: sas, xiaobai, beanz

Reviewed By: beanz

Subscribers: mgorny

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

llvm-svn: 346281
2018-11-06 23:54:52 +00:00
Nathan Lanza 8b73fa61d1 Adjust the comment section of CreateSource to account for lines longer than 60
Summary:
On rare occasions, the address, instruction and arguments of a line of
assembly in the CreateSource printout would reach > 60 characters. The
function would integer overflow and try to indent a line by `0xfff...`.

Change the calculated offset to be the maximum of 60 or
`line_strm.str().size()`

Reviewers: clayborg, xiaobai

Reviewed By: clayborg

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

llvm-svn: 346179
2018-11-05 22:55:30 +00:00
Nathan Lanza c61ee1bd04 Set stdout/stdin to binary mode on Windows
Summary:
A file opened in text mode on Windows will have `\n` automatically changed to `13,10` while Darwin and Linux leave it as `10`.

Set the file to binary mode to avoid this automatic conversion so that Darwin, Linux and Windows have equivalent treatment of `\r`.

Reviewers: clayborg, xiaobai

Reviewed By: clayborg

Subscribers: emaste, ki.stfu, mgorny, eraman, JDevlieghere, mgrang

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

llvm-svn: 346174
2018-11-05 22:25:00 +00:00
Jonas Devlieghere 454057da2a Remove OCaml debugger plugin
In January Davide sent an e-mail to the mailing list to suggest removing
unmaintained language plugins such as Go and Java. The plan was to have
some cool down period to allow users to speak up, however after that the
plugins were never actually removed.

This patch removes the OCaml debugger plugin.

The plugin can be added again in the future if it is mature enough both
in terms of testing and maintenance commitment.

Discussion on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2018-January/013171.html

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

llvm-svn: 346159
2018-11-05 19:34:03 +00:00
Jonas Devlieghere 0b8c5c9e13 Remove Java debugger plugin
In January Davide sent an e-mail to the mailing list to suggest removing
unmaintained language plugins such as Go and Java. The plan was to have
some cool down period to allow users to speak up, however after that the
plugins were never actually removed.

This patch removes the Java debugger plugin.

The plugin can be added again in the future if it is mature enough both
in terms of testing and maintenance commitment.

Discussion on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2018-January/013171.html

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

llvm-svn: 346158
2018-11-05 19:34:02 +00:00
Jonas Devlieghere 77198bc79b Remove Go debugger plugin
In January Davide sent an e-mail to the mailing list to suggest removing
unmaintained language plugins such as Go and Java. The plan was to have
some cool down period to allow users to speak up, however after that the
plugins were never actually removed.

This patch removes the Go debugger plugin.

The plugin can be added again in the future if it is mature enough both
in terms of testing and maintenance commitment.

Discussion on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2018-January/013171.html

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

llvm-svn: 346157
2018-11-05 19:33:59 +00:00
Jonas Devlieghere 8f3be7a32b [FileSystem] Move path resolution logic out of FileSpec
This patch removes the logic for resolving paths out of FileSpec and
updates call sites to rely on the FileSystem class instead.

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

llvm-svn: 345890
2018-11-01 21:05:36 +00:00
Reid Kleckner 4dc0b1ac60 Fix clang -Wimplicit-fallthrough warnings across llvm, NFC
This patch should not introduce any behavior changes. It consists of
mostly one of two changes:
1. Replacing fall through comments with the LLVM_FALLTHROUGH macro
2. Inserting 'break' before falling through into a case block consisting
   of only 'break'.

We were already using this warning with GCC, but its warning behaves
slightly differently. In this patch, the following differences are
relevant:
1. GCC recognizes comments that say "fall through" as annotations, clang
   doesn't
2. GCC doesn't warn on "case N: foo(); default: break;", clang does
3. GCC doesn't warn when the case contains a switch, but falls through
   the outer case.

I will enable the warning separately in a follow-up patch so that it can
be cleanly reverted if necessary.

Reviewers: alexfh, rsmith, lattner, rtrieu, EricWF, bollu

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

llvm-svn: 345882
2018-11-01 19:54:45 +00:00
Marc-Andre Laperle d8e14a5901 [lldb-mi] Implement -gdb-set breakpoint pending on/off
Summary:
This allows creating pending breakpoint automatically when a location is not found.
This is used by some front-ends instead of doing "-break-insert -f" every time.

See also https://sourceware.org/gdb/onlinedocs/gdb/Set-Breaks.html

Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>

Subscribers: MaskRay, llvm-commits, lldb-commits, ki.stfu

Tags: #lldb

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

llvm-svn: 345563
2018-10-30 03:10:41 +00:00
Jason Molenda 9fd917ba3d Remove an early-return from Driver::ParseArgs that
was added as a part of D52604 / r343348.  If the
lldb driver is run without any arguments, .lldbinit 
file reading was not enabled.

<rdar://problem/45570242> 

llvm-svn: 345422
2018-10-26 19:40:18 +00:00
Bruce Mitchener 173946dca6 Fix typos.
Reviewers: lldb-commits

Subscribers: srhines, ki.stfu

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

llvm-svn: 343825
2018-10-04 22:33:39 +00:00
Tatyana Krasnukha c06db02748 [Driver] Remove unused declarations and "include" directives
llvm-svn: 343357
2018-09-28 19:58:03 +00:00
Tatyana Krasnukha 5ce9dc614d Clean-up usage of OptionDefinition arrays
Differential Revision: https://reviews.llvm.org/D52604

llvm-svn: 343348
2018-09-28 17:58:16 +00:00
Jonas Devlieghere f9a07e9f8d [NFC] Turn "load dependent files" boolean into an enum
This is an NFC commit to refactor the "load dependent files" parameter
from a boolean to an enum value. We want to be able to specify a
default, in which case we decide whether or not to load the dependent
files based on whether the target is an executable or not (i.e. a
dylib).

This is a dependency for D51934.

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

llvm-svn: 342633
2018-09-20 09:09:05 +00:00
Alex Langford fde4cda9f7 Fix lldb-vscode README.md
Summary: The readme was missing "-" characters to enable links

Patch by Nathan Lanza <nathan@lanza.io>

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

llvm-svn: 342266
2018-09-14 19:41:20 +00:00
Aleksandr Urakov 709426b33a [PDB] Restore AST from PDB symbols
Summary:
This patch adds an implementation of retrieving of declarations and declaration
contexts based on PDB symbols.

PDB has different type symbols for const-qualified types, and this
implementation ensures that only one declaration was created for both const
and non-const types, but creates different compiler types for them.

The implementation also processes the case when there are two symbols
corresponding to a variable. It's possible e.g. for class static variables,
they has one global symbol and one symbol belonging to a class.

PDB has no info about namespaces, so this implementation parses the full symbol
name and tries to figure out if the symbol belongs to namespace or not,
and then creates nested namespaces if necessary.

Reviewers: asmith, zturner, labath

Reviewed By: asmith

Subscribers: aleksandr.urakov, teemperor, lldb-commits, stella.stamenova

Tags: #lldb

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

llvm-svn: 341782
2018-09-10 08:08:43 +00:00
Jason Molenda b0d33e9b3c Re-instate a bit of code that was commented out in r188246 which
reads an ObjectFileMachO's string table in one chunk.  Originally
this was commented out because binaries in the system's shared cache
all share a mega-string table and so reading the entire mega-strtab
for each binary was a performance problem.

In the reinstated code, I add a check that the binary we're reading
from memory is not in the shared cache (there isn't a constant in
<mach-o/loader.h> for this bit yet; we hardcode the value in one
other place in ObjectFileMachO alread).  For binaries that we're
reading out of memory that are NOT in the shared cache, reading 
the string table in one chunk is a big performance improvement.

Also have debugserver send up the flags value for binaries in its
response to the jGetLoadedDynamicLibrariesInfos request.

NFC.

<rdar://problem/33604496> 

llvm-svn: 341511
2018-09-06 00:55:27 +00:00
Aleksandr Urakov 398f81b3b4 [PDB] Resolve a symbol context block info correctly
Summary:
This patch allows to resolve a symbol context block info even if a function
info was not requested. Also it adds the correct resolving of nested blocks
(the previous implementation used function blocks instead of them).

Reviewers: zturner, asmith, labath

Reviewed By: asmith

Subscribers: lldb-commits, stella.stamenova

Tags: #lldb

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

llvm-svn: 340901
2018-08-29 07:26:11 +00:00
Jason Molenda f04833f9ee Remove unnecessary entitlement in debugserver for iOS.
<rdar://problem/43631901> 

llvm-svn: 340877
2018-08-28 22:28:34 +00:00
Alex Langford 520201babb [cmake] Add option to skip building lldb-server
Summary:
There is currently a way to skip the debugserver build. See how the CMake
variables SKIP_DEBUGSERVER and LLDB_CODESIGN_IDENTITY are used if you're
interested in that.

This allows us to skip building lldb-server as well. There is another
debug server called ds2 that can be used with LLDB. If you choose to use
ds2, this flag is very useful because it can cut down the build time of LLDB.

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

llvm-svn: 340560
2018-08-23 18:05:45 +00:00
Greg Clayton ada3f77e44 Update the Core file loading instructions so they keep the process stopped after attaching to a core file.
llvm-svn: 339954
2018-08-16 22:13:01 +00:00
Reid Kleckner 8b5e6991d2 Fix lldb-vscode build on Windows
Include PosixAPI.h to get a PATH_MAX definition and replace CreateEvent
with CreateEventObject to avoid conflicts with the windows.h definition
of CreateEvent to CreateEventW.

llvm-svn: 339920
2018-08-16 18:24:59 +00:00
Greg Clayton 2f5cf8511a Add a new tool named "lldb-vscode" that implements the Visual Studio Code Debug Adaptor Protocol
This patch adds a new lldb-vscode tool that speaks the Microsoft Visual Studio Code debug adaptor protocol. It has full unit tests that test all packets.

This tool can be easily packaged up into a native extension and used with Visual Studio Code, and it can also be used by Nuclide

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

llvm-svn: 339911
2018-08-16 17:59:38 +00:00
Alexander Polyakov 65bd2f6c85 [lldb-mi] Re-implement target-select command
Now target-select uses SB API instead of HandleCommand.

This patch has been reviewed along with the r339175.

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

llvm-svn: 339178
2018-08-07 20:45:46 +00:00
Alexander Polyakov 57e6dd7222 [lldb-mi] Re-implement MI HandleProcessEventStateSuspended.
Summary: Now this function uses SB API instead of HandleCommand.

Reviewers: aprantl, clayborg, labath

Reviewed By: aprantl

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 339160
2018-08-07 17:55:26 +00:00
Alexander Polyakov 19150571c5 Fix windows build after r337689
Added missing header.

llvm-svn: 337692
2018-07-23 14:10:30 +00:00
Alexander Polyakov e2183d508a [lldb-mi] Re-implement data-info-line command.
Summary: Now data-info-line command uses SB API instead of HandleCommand.

Reviewers: aprantl, clayborg, jingham

Reviewed By: aprantl

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 337689
2018-07-23 13:02:41 +00:00
Alex Langford 97ba3b64dd Invert dependency between lldb-framework and lldb-suite
Summary:
Currently, if you build lldb-framework the entire framework doesn't
actually build. In order to build the entire framework, you need to actually
build lldb-suite. This abstraction doesn't feel quite right because
lldb-framework truly does depend on lldb-suite (liblldb + related tools).

In this change I want to invert their dependency. This will mean that lldb and
finish_swig will depend on lldb-framework in a framework build, and lldb-suite
otherwise. Instead of adding conditional logic everywhere to handle this, I
introduce LLDB_SUITE_TARGET to handle it.

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

llvm-svn: 337311
2018-07-17 18:28:51 +00:00
Jonas Devlieghere 2ad6e0a696 Move pretty stack trace printer into driver.
We used to have a pretty stack trace printer in SystemInitializerCommon.
This was disabled on Apple because we didn't want the library to be
setting signal handlers, as this was causing issues when loaded into
Xcode. However, I think it's useful to have this for the LLDB driver, so
I moved it up to use the PrettyStackTraceProgram in the driver's main.

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

llvm-svn: 337261
2018-07-17 10:04:19 +00:00
Raphael Isemann c094d23f6f Allow specifying an exit code for the 'quit' command
Summary:
This patch adds the possibility to specify an exit code when calling quit.
We accept any int, even though it depends on the user what happens if the int is
out of the range of what the operating system supports as exit codes.

Fixes rdar://problem/38452312

Reviewers: davide, jingham, clayborg

Reviewed By: jingham

Subscribers: clayborg, jingham, lldb-commits

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

llvm-svn: 336824
2018-07-11 17:18:01 +00:00
Tatyana Krasnukha 2bdcf581c1 Fix build on Windows with SDK build version >= 17134.
Platform.h doesn't define signal() and SIGINT since commit r263858. Code was compiled successfully because signal.h didn't have "ifndef" include guard in previous versions of Windows SDK. Now it does.

llvm-svn: 336483
2018-07-07 14:58:13 +00:00
Alexander Polyakov 67cdc92d43 Ammend "Fix MSVC2015 compilation failure after r336206 patch".
llvm-svn: 336235
2018-07-03 22:51:01 +00:00
Alexander Polyakov 83e3ec5413 Fix MSVC2015 compilation failure after r336206 patch.
Added missing headers.

llvm-svn: 336212
2018-07-03 16:07:30 +00:00
Alexander Polyakov 8c670ec73f [lldb-mi] Re-implement symbol-list-lines command.
Summary: Now this command uses SB API instead of HandleCommand.

Reviewers: aprantl, clayborg

Reviewed By: aprantl, clayborg

Subscribers: ki.stfu, eraman, lldb-commits

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

llvm-svn: 336206
2018-07-03 15:40:20 +00:00
Alexander Polyakov fc018b071b [lldb-mi] Re-implement a few MI commands.
Summary: This patch updates exec-next-instruction, exec-step-instruction,
exec-finish, exec-interrupt commands to use SB API instead of HandleCommand.

Reviewers: aprantl, clayborg

Reviewed By: aprantl

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 336155
2018-07-02 23:54:06 +00:00
Alexander Polyakov 4bbb820e22 [lldb-mi] Clean up and update a few MI commands.
Summary:
This patch updates a few MI commands using a new way of
handling an errors in lldb-mi and removes unnecessary
m_lldbResult variables.

Reviewers: aprantl, clayborg, labath

Reviewed By: aprantl, clayborg

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 336009
2018-06-29 19:58:31 +00:00
Pavel Labath 62a7f80af7 Add a test for reading lld-generated build-ids
Summary:
This test makes sure we are able to read the shorter build-ids which are
generated by lld.

To make this work, I've extended lldb-test to print the UUID of the
loaded object file. I've renamed the lldb-test subcommand from
"module-sections" to "object-file" to reflect the fact it prints more
than just the sections.

I've also added the module Architecture to the output, so we could avoid
printing the entire symbol file information just to get the ArchSpec
details in the lc_version_min test (which was also the only test in it's
folder not using the module-sections command).

Reviewers: aprantl, zturner

Subscribers: lldb-commits

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

llvm-svn: 335967
2018-06-29 12:15:54 +00:00
Pavel Labath 9ea80d259f Retrieve a function PDB symbol correctly from nested blocks
Summary:
This patch fixes a problem with retrieving a function symbol by an
address in a nested block. In the current implementation of
ResolveSymbolContext function it retrieves a symbol with
PDB_SymType::None and then checks if found symbol's tag equals to
PDB_SymType::Function. So, if nested block's symbol was found,
ResolveSymbolContext does not resolve a function.

Reviewers: asmith, labath, zturner

Reviewed By: asmith, labath

Differential Revision: https://reviews.llvm.org/D47939
Patch by Aleksandr Urakov <aleksandr.urakov@jetbrains.com>

llvm-svn: 335822
2018-06-28 10:03:42 +00:00
Alexander Polyakov 32447ff5b9 Fix windows build for r335541.
I didn't include <functional> header and used std::function.

llvm-svn: 335552
2018-06-25 23:29:52 +00:00
Alexander Polyakov 9bca7483a5 Implement new methods for handling an error in MI commands.
Summary:
The new methods take SBError object and call handler,
specified by user, depending on SBError status.

Reviewers: aprantl, clayborg, labath

Reviewed By: aprantl, clayborg

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 335541
2018-06-25 22:01:44 +00:00
Alex Langford 27510c18ad Introduce lldb-framework CMake target and centralize its logic
Summary:
In this patch I aim to do the following:

1) Create an lldb-framework target that acts as the target that handles generating LLDB.framework. Previously, liblldb acted as the target for generating the framework in addition to generating the actual lldb library. This made the target feel overloaded.
2) Centralize framework generation as much as it makes sense to do so.
3) Create a target lldb-suite, which depends on every tool and library that makes liblldb fully functional. One result of having this target is it makes tracking dependencies much clearer.

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

llvm-svn: 334968
2018-06-18 18:27:16 +00:00
Jason Molenda 94405ddb95 Sort the files in the PBXBuildFile and PBXFileReference sections
of debugserver's xcode project file to reduce automerger issues
with the github swift repository of lldb where the order of these
entries has drifted significantly over the years.

llvm-svn: 334873
2018-06-15 23:32:37 +00:00
Alexander Polyakov 56d9aa26ab Revert "[lldb-mi] Add overload method for setting an error"
Summary: This reverts commit r334245 because it duplicates
functionality of Status::AsCString used in SBError.

Reviewers: aprantl, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits, ki.stfu

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

llvm-svn: 334860
2018-06-15 20:20:39 +00:00
Frederic Riss 9745a0adb2 Add support for PLATFORM_*SIMULATOR
The toolchain in Xcode 10 uses a new LC_BUILD_VERSION entry to identify
simulator binaries. Add support for reading those to debugserver.

The exisitng test testing that code is currently failling when run
with Xcode 10, no need for a new test.

llvm-svn: 334784
2018-06-15 02:50:45 +00:00
Frederic Riss 2153c42358 Add an entitlement to debugserver
On macOS 10.14, debugserver needs to have an entitlement do be
allowed to debug processes. Adding this to both the Xcode and
cmake build system. This shouldn't have any impact on previous
OSs.

llvm-svn: 334772
2018-06-14 21:17:59 +00:00
Jonas Devlieghere 937348cd13 [FileSpec] Make style argument mandatory for SetFile. NFC
SetFile has an optional style argument which defaulted to the native
style. This patch makes that argument mandatory so clients of the
FileSpec class are forced to think about the correct syntax.

At the same time this introduces a (protected) convenience method to
update the file from within the FileSpec class that keeps the current
style.

These two changes together prevent a potential pitfall where the style
might be forgotten, leading to the path being updated and the style
unintentionally being changed to the host style.

llvm-svn: 334663
2018-06-13 22:08:14 +00:00
Raphael Isemann cfbb354457 Added modulemap for lldb-mi
Summary: This patch allows building a C++ module for the lldb-mi headers.

Reviewers: bruno, aprantl

Reviewed By: aprantl

Subscribers: lldb-commits, ki.stfu

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

llvm-svn: 334549
2018-06-12 21:22:52 +00:00
Pavel Labath 38d9ff7a8a Fix build error introduced in r334498
Some gcc versions (circa 4.9) do not accept initializing Expected
objects containing a reference to a function from a function.

Change the Expected object to contain function pointers to work around
this.

llvm-svn: 334501
2018-06-12 13:26:43 +00:00
Pavel Labath e6954cb2a1 lldb-test symbols: Add -file argument and the ability to dump global variables in a file
The motivation for this is to be able to Dwarf index ability to look up
variables within a given compilation unit. It also fits in with the
patch in progress at D47939, which will add the ability to look up
funtions using file+line pairs.

The verification of which lldb-test options can be used together was
getting a bit unwieldy, so I moved the logic out into a separate
function.

llvm-svn: 334498
2018-06-12 12:57:36 +00:00
Alexander Polyakov 4a60320a20 [lldb-mi] Re-implement MI -exec-step command.
Summary: Now -exec-step uses SB API instead of HandleCommand hack.

Reviewers: aprantl, clayborg, labath, stella.stamenova

Reviewed By: aprantl

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 334364
2018-06-10 14:58:29 +00:00
Alexander Polyakov 44a060f8d6 [lldb, lldb-mi] Re-implement MI -exec-continue command.
Summary: Now -exec-continue command uses SB API to resume target's process.

Reviewers: aprantl, clayborg, labath

Reviewed By: clayborg

Subscribers: apolyakov, labath, ki.stfu, llvm-commits, lldb-commits

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

llvm-svn: 334350
2018-06-09 15:11:37 +00:00
Alex Langford 9391061fd7 Delete some dead code
llvm-svn: 334320
2018-06-08 21:13:26 +00:00
Aaron Smith 010edd37f8 PDB support of function-level linking and splitted functions
Summary:
The patch adds support of splitted functions (when MSVC is used with PGO) and function-level linking feature.

SymbolFilePDB::ParseCompileUnitLineTable function relies on fact that ranges of compiled source files in the binary are continuous and don't intersect each other. The function creates LineSequence for each file and inserts it into LineTable, and implementation of last one relies on continuity of the sequence. But it's not always true when function-level linking enabled, e.g. in added input test file test-pdb-function-level-linking.exe there is xstring's std__basic_string_char_std__char_traits_char__std__allocator_char_____max_size (.00454820) between test-pdb-function-level-linking.cpp's foo (.00454770) and main (.004548F0).

To fix the problem this patch renews the sequence on each address gap.

Reviewers: asmith, zturner

Reviewed By: asmith

Subscribers: aleksandr.urakov, labath, mgorny, lldb-commits

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

llvm-svn: 334260
2018-06-08 02:45:25 +00:00
Alexander Polyakov f0f5175518 [lldb-mi] Add overloaded method for setting an error.
Reviewers: aprantl, clayborg

Reviewed By: clayborg

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 334245
2018-06-07 23:03:49 +00:00
Alexander Polyakov 2b08ca76df [lldb-mi] Re-implement MI -exec-next command.
Summary: Now -exec-next command uses SB API for stepping over.

Reviewers: aprantl, clayborg, stella.stamenova, labath

Reviewed By: aprantl, clayborg, labath

Subscribers: labath, ki.stfu, lldb-commits

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

llvm-svn: 334215
2018-06-07 19:09:01 +00:00
Vedant Kumar c418b5cc25 [IRMemoryMap] Use labels in the "malloc" and "free" lldb-test commands
Change the syntax of the malloc and free commands in lldb-test's
ir-memory-map subcommand to:

  <malloc> ::= <label> = malloc <size> <alignment>

  <free> ::= free <label>

This should make it easier to read and extend tests in the future, e.g
to test IRMemoryMap::WriteMemory or double-free behavior.

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

llvm-svn: 333930
2018-06-04 17:11:15 +00:00
Alexander Polyakov cc92f5038e [lldb, lldm-mi] Fix hanging of -exec-run command.
Summary: -exec-run command hanged in case of invalid or dummy target.

Reviewers: aprantl, stella.stamenova

Reviewed By: aprantl

Subscribers: ki.stfu, llvm-commits, lldb-commits

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

llvm-svn: 333844
2018-06-03 15:15:23 +00:00
Alexander Polyakov 2c5a424150 Test commit. Fix typo in comment.
llvm-svn: 333837
2018-06-03 12:41:00 +00:00
Vedant Kumar cc5a6163a4 [IRMemoryMap] Test interleaved Mallocs and Frees
This adds a new command to the ir-memory-map tester:

  free <allocation-index>

The argument to free is an index which identifies which live allocation
to free. Index 0 identifies the first live allocation in the address
space, index 1 identifies the second, etc. where the allocations are
sorted in increasing order.

For illustrative purposes, assume malloc returns monotonically
increasing addresses. Here are some examples of how free would work:

Example 1
---------

malloc 16 1
malloc 32 1
free 1      //< Free the 32-byte allocation.
free 0      //< Next, free the 16-byte allocation.

Example 2
---------

malloc 16 1
malloc 32 1
free 0      //< Free the 16-byte allocation.
free 0      //< Next, free the 32-byte allocation.

llvm-svn: 333700
2018-05-31 22:09:01 +00:00
Vedant Kumar 7e4c84a78c [lldb-test] Make logging available to all subcommands
llvm-svn: 333699
2018-05-31 22:09:00 +00:00
Vedant Kumar f616b9db7d [IRMemoryMap] Test host-side allocations
r333583 introduced testing for IRMemoryMap's process-side allocations
(eAllocationPolicyProcessOnly). This adds support for the host-side
variety (eAllocationPolicyHostOnly).

llvm-svn: 333698
2018-05-31 22:09:00 +00:00
Pavel Labath 34cda14b09 Remove append parameter to FindGlobalVariables
Summary:
As discussed in https://bugs.llvm.org/show_bug.cgi?id=37317,
FindGlobalVariables does not properly handle the case where
append=false.  As this doesn't seem to be used in the tree, this patch
removes the parameter entirely.

Reviewers: clayborg, jingham, labath

Reviewed By: clayborg

Subscribers: aprantl, lldb-commits, kubamracek, JDevlieghere

Differential Revision: https://reviews.llvm.org/D46885
Patch by Tom Tromey <ttromey@mozilla.com>.

llvm-svn: 333639
2018-05-31 09:46:26 +00:00
Vedant Kumar f3b6d2930d [lldb-test] ir-memory-map: Avoid accessing a bad iterator
Do not access Probe.start() when Probe is at the end of the interval
map.

llvm-svn: 333585
2018-05-30 19:46:47 +00:00
Vedant Kumar c1cd826248 [lldb-test] Add a testing harness for the JIT's IRMemoryMap
This teaches lldb-test how to launch a process, set up an IRMemoryMap,
and issue memory allocations in the target process through the map. This
makes it possible to test IRMemoryMap in a targeted way.

This has uncovered two bugs so far. The first bug is that Malloc
performs an adjustment on the pointer returned from AllocateMemory (for
alignment purposes) which ultimately allows overlapping memory regions
to be created. The second bug is that after most of the address space on
the host side is exhausted, Malloc may return the same address multiple
times. These bugs (and hopefully more!) can be uncovered and tested for
with targeted lldb-test commands.

At an even higher level, the motivation for addressing these bugs is
that they can lead to strange user-visible failures (e.g, variables
assume the wrong value during expression evaluation, or the debugger
crashes). See my third comment on this swift-lldb PR for an example:

https://github.com/apple/swift-lldb/pull/652

I hope lldb-test is the right place to add this testing harness. Setting
up a gtest-style unit test proved too cumbersome (you need to recreate
or mock way too much debugger state), as did writing end-to-end tests
(it's hard to write a test that actually hits a buggy path).

With lldb-test, it's easy to read/generate the test input and parse the
test output. I'll attach a simple "fuzz" tester which generates failing
test cases to the Phab review. Here's an example:

```
Command: malloc(size=1024, alignment=32)
Malloc: address = 0xca000
Command: malloc(size=64, alignment=16)
Malloc: address = 0xca400
Command: malloc(size=1024, alignment=16)
Malloc: address = 0xca440
Command: malloc(size=16, alignment=8)
Malloc: address = 0xca840
Command: malloc(size=2048, alignment=16)
Malloc: address = 0xcb000
Command: malloc(size=64, alignment=32)
Malloc: address = 0xca860
Command: malloc(size=1024, alignment=16)
Malloc: address = 0xca890
Malloc error: overlapping allocation detected, previous allocation at [0xca860, 0xca8a0)
```

{F6288839}

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

llvm-svn: 333583
2018-05-30 19:39:10 +00:00
Bruce Mitchener 4ebdee0a59 Typo fixes.
Reviewers: javed.absar

Subscribers: ki.stfu, JDevlieghere, lldb-commits

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

llvm-svn: 333399
2018-05-29 09:10:46 +00:00
Raphael Isemann 02d4ff4498 Add missing includes to some LLDB headers.
Summary: When compiling with modules, these missing includes cause the build to fail (as the header can't be compiled into a module).

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 333345
2018-05-26 14:59:14 +00:00
Raphael Isemann 81cc13258a Don't include headers from inside a namespace in MIUtilSingletonHelper.h
Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 333343
2018-05-26 14:39:35 +00:00
Adrian Prantl 512ccd7e6f [lldb-mi] Add possibility to set breakpoints without selecting a target.
Now it's possible to set breakpoints before selecting a target, they
will be set to the dummy target and then copied to an each added one.

Patch by Alexander Polyakov!

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

llvm-svn: 333205
2018-05-24 16:45:59 +00:00
Pavel Labath 5dd5833bd1 Fix windows/mac builds broken by r333182.
I should've known that something was wrong when only one of my plugins
was prefixed by the lldb_private namespace.

llvm-svn: 333183
2018-05-24 13:12:07 +00:00
Pavel Labath fa3fa5b90e Move ObjectFile initialization out of SystemInitializerCommon
Summary:
For lldb-server, it is sufficient to parse only the native object file
format for its target OS (no other file can be loaded into a running
process). This moves the object file initialization code into specific
initializer classes: lldb-test and liblldb get all object files;
lldb-server gets only one of them. For this to work, I've needed to
create a special SystemInitializer for use in lldb-server, instead of it
calling directly into the common one.

This reduces the size of lldb-server by about 2%, which is not
earth-shattering, but it's an easy win, and it helps.

Reviewers: zturner, clayborg

Subscribers: mgorny, lldb-commits

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

llvm-svn: 333182
2018-05-24 12:44:18 +00:00
Adrian Prantl 4672849ead Add a --synchronous option to lldb-mi to facilitate reliable testing.
Patch by Alexander Polyakov!

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

llvm-svn: 333140
2018-05-23 23:33:50 +00:00
Jonas Devlieghere 52721286b2 [CMake] Unify and relayer testing
This patch restructures part of LLDB's testing configuration:

1. I moved the test dependencies up the chain so every dotest dependency
   becomes a lit dependency as well. It wouldn't make sense for dotest to
   have other dependencies when it's being run by lit. Lit on the other
   hand can still specify extra dependencies.

2. I replaced as much generator expressions with variables as possible.
   This is consistent with the rest of LLVM and doesn't break generators
   that support multiple targets (MSVC, Xcode). This wasn't a problem
   before, but now we need to expand the dotest arguments in the lit
   configuration and there's only one test suite even with multiple
   targets.

3. I moved lldb-dotest into it's own directory under utils since there's
   no need anymore for it to located under `test/`.

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

llvm-svn: 331463
2018-05-03 16:54:10 +00:00
Pavel Labath 90b0a53499 lldb-test symbols: Add ability to do name-based lookup
Summary:
lldb-test already had the ability to dump all symbol information in a
module. This is interesting, but it can be too verbose, and it also does
not use the same APIs that lldb uses to query symbol information. The
last part is interesting to me now, because I am about to add DWARF v5
debug_names support, which needs to implement these APIs.

This patch adds a set of arguments to lldb-test, which modify it's
behavior from dumping all symbols to dumping only the requested
information:
- --find={function,namespace,type,variable} - search for the given
  kind of objects.

- --name - the name to search for.

- --regex - whether to treat the "name" as a regular expression. This is
  not available for all lookup types (we do not have the required APIs
  for namespaces and types).

- --context - specifies the context, which can be used to restrict the
  search. This argument takes a variable name (which must be defined and
  be unique), and we then use the context that this variable is defined
  in as the search context.

- --function-flags={auto,full,base,method,selector} - a set of flags to
  further restrict the search for function symbols.

Together, these flags and their combinations cover the main SymbolFile
entry points which I will need to modify for the accelerator table
support, and so I plan to do most of the regression testing this way.
(I've also found this a useful tool for exploration of what the given
APIs are supposed to do.)

I add a couple of tests to demonstrate the usage of the usage of the
various options, and also an xfailed test which demonstrates a bug I
found while playing with this. The only requirement for these tests is
the presence of lld -- the should run on any platform which is able to
build lldb.

These tests use c++ code as input, but this isn't a requirement. It is also
possible to use IR, assembly or json to create the test module.

Reviewers: davide, zturner, asmith, JDevlieghere, clayborg, alexshap

Subscribers: mgorny, aprantl, lldb-commits

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

llvm-svn: 331447
2018-05-03 10:57:16 +00:00
Adrian Prantl 6e9f77126b Silence compiler warning.
llvm-svn: 331375
2018-05-02 17:11:43 +00:00
Adrian Prantl d8f460e864 Enable AUTOBRIEF in doxygen configuration.
This brings the LLDB configuration closer to LLVM's and removes visual
clutter in the source code by removing the @brief commands from
comments.

This patch also reflows the paragraphs in all doxygen comments.

See also https://reviews.llvm.org/D46290.

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

llvm-svn: 331373
2018-05-02 16:55:16 +00:00
Jan Kratochvil e4777a9df5 Support reading section ".gnu_debugaltlink"
Differential revision: https://reviews.llvm.org/D40468

llvm-svn: 331148
2018-04-29 19:47:48 +00:00
Frederic Riss 60b94c296e [debugserver] Fix the G packet handling.
Of course r331004 needed a counterpart on the write side.

llvm-svn: 331073
2018-04-27 19:59:42 +00:00
Frederic Riss 34ec0bfb5e [debugserver] Fix handling of the 'g' packet
LLDB doesn't use this packet so we never hit this, but it looks like
some other projects talk to debugserver and are hitting an assert
(https://github.com/derekparker/delve/issues/1015).

We had an off by 1 in the accounting of the FPU structure sizes.
I added a test that basically just check that 'g' doesn't return
an error (currently it assert in debug builds). I didn't make
it an lldb-server test because it looks like lldb-server doesn't
implement the g packet.

llvm-svn: 331004
2018-04-27 00:09:04 +00:00
Frederic Riss 05e8bc85e6 [debugserver] Return 'ios' instead of 'iphoneos' for the ostype.
When I merged the 2 codepaths that return an OS type, I hade
checked that the places accepting 'iphoneos' would also accept
'ios', but then I got it backwards and return 'iphoneos'.

We use this value to build triples, and there 'iphoneos' is
invalid.

This also makes the test slightly simpler.

llvm-svn: 330877
2018-04-25 22:12:12 +00:00
Pavel Labath 145d95c964 Move Args.cpp from Interpreter to Utility
Summary:
The Args class is used in plenty of places besides the command
interpreter (e.g., anything requiring an argc+argv combo, such as when
launching a process), so it needs to be in a lower layer. Now that the
class has no external dependencies, it can be moved down to the Utility
module.

This removes the last (direct) dependency from the Host module to
Interpreter, so I remove the Interpreter module from Host's dependency
list.

Reviewers: zturner, jingham, davide

Subscribers: mgorny, lldb-commits

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

llvm-svn: 330200
2018-04-17 18:53:35 +00:00
Davide Italiano e185dcf13d Revert "[debugserver] Remove dead function call. NFCI."
This reverts commit r330066 as it was wrong and the call was
not dead. Thanks to Fred for pointing this out.

llvm-svn: 330071
2018-04-13 21:26:32 +00:00
Davide Italiano 0bd55b187e [debugserver] Remove dead function call. NFCI.
llvm-svn: 330066
2018-04-13 20:47:25 +00:00
Frederic Riss cd90f878d4 [debugserver] Fix LC_BUILD_VERSION load command handling.
Summary:
In one of the 2 places the LC_BUILD_VERSION load command is handled, there
is a bug preventing us from actually handling them (the address where to
read the load command was not updated). This patch factors reading the
deployment target load commands into a helper and adds testing for the 2
code paths calling the helper.

The testing is a little bit complicated because the only times those load
commands matter is when debugging a simulator process. I added a new
decorator to check that a specific SDK is available. The actual testing was
fairly easy once I knew how to run a simulated process.

Reviewers: jasonmolenda, labath

Subscribers: lldb-commits

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

llvm-svn: 329374
2018-04-06 04:28:12 +00:00
Frederic Riss fa37026db3 Prevent double release of mach ports
Summary:
When a MIG routine returns KERN_FAILURE, the demux function will release any OOL resources like ports. In this case, task_port and thread_port will be released twice, potentially resulting in use after free of the ports.

I don't think we can test this in any useful way
rdar://problem/37331387

Reviewers: jasonmolenda

Subscribers: lldb-commits

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

llvm-svn: 328761
2018-03-29 03:49:41 +00:00
Jason Molenda 49b30d5ad5 Add the same new entitlement from r326399 to
the macos entitlement list.
<rdar://problem/38887712> 

llvm-svn: 328591
2018-03-26 23:13:17 +00:00
Jason Molenda f92817ab23 Rename remotectl_com.apple.internal.xpc.remote.debugserver.plist
to com.apple.internal.xpc.remote.debugserver.plist, not sure where
that remotectl_ prefix came from.

<rdar://problem/36751222> 

llvm-svn: 327922
2018-03-19 23:07:31 +00:00
Jason Molenda 695b211ce6 I didn't see that SocketAddress.cpp was already being pulled
in to debugserver; my re-addition resulted in duplicated
symbols.  Remove my added SocketAddress.cpp, and change the
original one to also be included for the debugserver-mini target.

llvm-svn: 327918
2018-03-19 22:55:19 +00:00
Jason Molenda cd063214b0 Add the ios-mini target to the top-level xcodeproj, which builds
the debugserver-mini target in debugserver.  Add a new plist
which needs to be installed for debugserver-mini.
<rdar://problem/36751222> 

llvm-svn: 327915
2018-03-19 22:04:45 +00:00
Vedant Kumar 51bc20527b [cmake] Copy system debugserver from the right place when only CommandLineTools
are installed

Instead of building debugserver when building lldb, I'd rather pass
LLDB_CODESIGN_IDENTITY="" to cmake and use the one already on my system.
However, on one of my machines I only have the CommandLineTools installed, and
so the hardcoded path to the system debugserver does not work for me.
Additionally, we should verify the LLDB framework exists on the machine before
trying to set the path to debugserver. This allows us to warn the user at
configure time that a system debugserver can't be found if they choose not to
build it themselves.

Patch by Alex Langford!

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

llvm-svn: 327691
2018-03-16 03:31:16 +00:00
Jim Ingham 08581263dc Re-add change for https://reviews.llvm.org/D42582 with added directories.
llvm-svn: 327331
2018-03-12 21:17:04 +00:00
Vedant Kumar d1faa56f3d Revert "Improve prologue handling to support functions with multiple entry points."
This reverts commit r327318. It breaks the Xcode and CMake Darwin
builders:

clang: error: no such file or directory:
'.../source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp'
clang: error: no input files

More details are in https://reviews.llvm.org/D42582.

llvm-svn: 327327
2018-03-12 20:35:33 +00:00
Jim Ingham 467b50057a Improve prologue handling to support functions with multiple entry points.
https://reviews.llvm.org/D42582

Patch from Leandro Lupori.

llvm-svn: 327318
2018-03-12 19:21:59 +00:00
Jason Molenda 250524f7ed I added CFLAGS etc to one part of the project file I should not have.
llvm-svn: 327097
2018-03-09 01:43:18 +00:00
Jason Molenda 4b7ea1f33c More cleanups of debugserver project file and the libpmenergy/libpmsample
stuff.  Activate it when an internal SDK is selected.  Update the name of
the LDFLAGS to match the rest of the settings.  Update the default arch for 
ios builds.

llvm-svn: 327095
2018-03-09 01:37:37 +00:00
Jason Molenda fc7321197e Remove unneeded per-arch sdk specifications from debugserver xcode project file.
llvm-svn: 327088
2018-03-09 00:32:56 +00:00
Jason Molenda c13a14ac26 Remove the explicit dependency on libpmenergy and libpmsample.
llvm-svn: 327087
2018-03-09 00:28:51 +00:00
Jason Molenda a608510b13 Fixed two more sdk inconsistencies with the pmenergy stuff.
llvm-svn: 327085
2018-03-09 00:23:29 +00:00
Jason Molenda 917f5b9944 Three little cleanups in the debugserver xcode project file.
1. Link against libpmenergy and pmsample unconditionally.  It is available on 
macOS 10.10 ("Yosemite") and newer.  We're already linking against libcompression
unconditionally which is only available on macOS 10.11 & newer.

2. Change a few "sdk=macosx.internal"'s to sdk=macosx.

3. Clean up a few places where libcompression was being enabled inconsistently.


Note: the -DLLDB_ENERGY define is only set when building against the macosx.internal
SDK; it includes a header file that is not public.  We link against the dylibs
unconditionally for simplicity.

llvm-svn: 327084
2018-03-09 00:17:22 +00:00
Jason Molenda 702895989a the thread id is easier to read in base16.
llvm-svn: 326849
2018-03-06 23:33:02 +00:00
Pavel Labath 96979ceecb Rewrite TestTargetSymbolsBuildidCase to be more focused
Summary:
The test was failing in remote debugging scenario with windows as a host
as cmd.exe is not able to parse the complicated shell commands in the
Makefile.

The test seemed like a perfect candidate for a more focused testing
approach, so I have rewritten in on top of lldb-test's module-sections
functionality. The slight gotcha there was that the
Module::GetSectionList does not include the sections from the symbol
file until someone manually calls Module::GetSymbolVendor. Normally,
this is not an issue, because someone will have initialized the symbol
vendor by the time anyone starts looking at the sections. However, when
all one this is dump the section list, we run into this problem.

I've tried making this behavior more automatic, but it turns out it's
not that easy, so for now, I just manually initialize the Symbol Vendor
before dumping out the sections in lldb-test.

Reviewers: jankratochvil

Subscribers: lldb-commits

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

llvm-svn: 326805
2018-03-06 15:56:20 +00:00
Jason Molenda a1bd9508e0 Upstreaming avx512 register support in debugserver. These changes
were originally written by Chris Bieneman, they've undergone a
number of changes since then.

Also including the debugserver bridgeos support, another arm
environment that runs Darwin akin to ios.  These codepaths are
activated when running in a bridgeos environment which we're not
set up to test today.

There's additional (small) lldb changes to handle bridgeos binaries
that still need to be merged up.

Tested on a darwin system with avx512 hardware and without.

<rdar://problem/36424951> 

llvm-svn: 326756
2018-03-06 00:27:41 +00:00
Jason Molenda f50299fb87 Add another entitlement that we need for debugserver.
<rdar://problem/29855293> 

llvm-svn: 326399
2018-03-01 01:04:07 +00:00
Han Ming Ong 4142369204 Add ability to collect memory limit.
Reviewer: Jason Molenda

<rdar://problem/37686560>

llvm-svn: 326374
2018-02-28 22:18:45 +00:00
Pavel Labath a535a7a2a0 [LLDB] Initial version of PPC64 InstEmulation
Summary: Supports common prologue/epilogue instructions.

Reviewers: clayborg, labath

Reviewed By: clayborg, labath

Subscribers: davide, anajuliapc, alexandreyy, lbianc, nemanjai, mgorny, kbarton

Differential Revision: https://reviews.llvm.org/D43345
Author: Leandro Lupori <leandro.lupori@gmail.com>

llvm-svn: 326224
2018-02-27 18:42:46 +00:00
Han Ming Ong 28efd27fe2 Removed accidentally committed code from previous commit.
llvm-svn: 326214
2018-02-27 18:02:15 +00:00
Han Ming Ong 83d178de9f Got rid of weak imports of libpenergy and libpsample because we are already requiring a modern macOS (at least 10.11)
Reviewer: Jason Molenda
llvm-svn: 326213
2018-02-27 17:53:38 +00:00
Pavel Labath 7c94582f90 Add "lldb-test breakpoint" command and convert the case-sensitivity test to use it
Summary:
The command takes two input arguments: a module to use as a debug target
and a file containing a list of commands. The command will execute each
of the breakpoint commands in the file and dump the breakpoint state
after each one.

The commands are expected to be breakpoint set/remove/etc. commands, but
I explicitly allow any lldb command here, so you can do things like
change setting which impact breakpoint resolution, etc. There is also a
"-persistent" flag, which causes lldb-test to *not* automatically clear
the breakpoint list after each command. Right now I don't use it, but
the idea behind it was that it could be used to test more complex
combinations of breakpoint commands (set+modify, set+disable, etc.).

Right now the command prints out only the basic breakpoint state, but
more information can be easily added there.  To enable easy matching of
the "at least one breakpoint location found" state, the command
explicitly prints out the string "At least one breakpoint location.".

To enable testing of breakpoints set with an absolute paths, I add the
ability to perform rudimentary substitutions on the commands: right now
the string %p is replaced by the directory which contains the command
file (so, under normal circumstances, this will perform the same
substitution as lit would do for %p).

I use this command to rewrite the TestBreakpointCaseSensitivity test --
the test was checking about a dozen breakpoint commands, but it was
launching a new process for each one, so it took about 90 seconds to
run. The new test takes about 0.3 seconds for me, which is approximately
a 300x speedup.

Reviewers: davide, zturner, jingham

Subscribers: luporl, lldb-commits

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

llvm-svn: 326112
2018-02-26 18:50:16 +00:00
Vedant Kumar d4e2dabbbb Delete dead code in MachVMMemory.cpp, NFC
This addresses a compiler warning.

llvm-svn: 326002
2018-02-24 00:17:05 +00:00
Vedant Kumar f6769ae176 [unittests] Disable lldb-server tests if an external debug server is in use
The lldb-server unit tests don't test the right thing when the debug
server in use is copied from somewhere else. This can lead to spurious
test failures.

Disable these unit tests when an external debug server is in use.

Fixes llvm.org/PR36494.

llvm-svn: 326001
2018-02-24 00:17:04 +00:00
Don Hinton b308571916 Add DEBUGSERVER_PATH to the cache so it'll be available for tests.
This fixed a problem caused by r325442.

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

llvm-svn: 325452
2018-02-17 23:06:15 +00:00
Don Hinton d8a6b90e83 [cmake] Fix LLDB_CODESIGN_IDENTITY logic.
Summary:
Consolidate LLDB_CODESIGN_IDENTITY logic in one place and use
SKIP_DEBUGSERVER, which can be set independently, to control
codesigning targets.

Currently, running cmake the first time in a clean directory, without
passing -DLLDB_CODESIGN_IDENTITY='', fails.  However, subsequent runs
succeed.  That's because LLDB_CODESIGN_IDENTITY gets added to the
CACHE after the initial test.  To fix that, the default value must be
set before it's tested.

Here's the error produced on the first run:

CMake Error at tools/lldb/tools/debugserver/source/CMakeLists.txt:215 (add_custom_command):
  No TARGET 'debugserver' has been created in this directory.

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

llvm-svn: 325442
2018-02-17 19:17:21 +00:00
Vedant Kumar 361b5e1169 [cmake] Darwin: Copy in the system debugserver if needed
This makes the built debugger functional on Darwin when compiling
without code signing (as documented in docs/code-signing.txt).

llvm-svn: 325068
2018-02-13 23:05:46 +00:00
Jason Molenda 35eb6c856a Turn off the deprecated ALWAYS_SEARCH_USER_PATHS feature
in debugserver.  This is already set this way in the lldb
project files but not in debugserver.  Updating for
consistency.

llvm-svn: 324158
2018-02-03 00:37:46 +00:00
Han Ming Ong 017edbddeb Make use of physical footprint as memory measurement.
Remove obsolete measurements.

This check in requires at least 10.11

Reviewed: Jason Molenda, Jim Ingham

<rdar://problem/37047106> Xcode Memory gauge should show the jetsam ledger footprint rather than anonymous

llvm-svn: 324013
2018-02-01 21:46:40 +00:00
Jason Molenda 0af609d17c Remove the hardcoded macos deployment targets altogether
from the xcode project files.  We'll build for the current
OS only, by default.  

llvm-svn: 322603
2018-01-17 00:22:27 +00:00
Jason Molenda c4dd04c5c3 When parsing the target.xml register file, if no architecture has
been specified yet (either by the user, or by one of the lldb
extensions like qHostInfo or qProcessInfo), and the target.xml
includes a <architecture> tag specifying x86_64, set the architecture
appropriately.

I'm not sure what we can expect to see in the <architecture> tag, so
I'm only doing this for x86_64 right now where I've seen "i386:x86_64"
used.  I've seen a target.xml from a jtag board that sends just "arm"
because it doesn't know more specifically what type of board it is
connected to...  

<rdar://problem/29908970> 

llvm-svn: 322339
2018-01-12 01:16:13 +00:00
Pavel Labath 62930e57eb Add Utility/Environment class for handling... environments
Summary:
There was some confusion in the code about how to represent process
environment. Most of the code (ab)used the Args class for this purpose,
but some of it used a more basic StringList class instead. In either
case, the fact that the underlying abstraction did not provide primitive
operations for the typical environment operations meant that even a
simple operation like checking for an environment variable value was
several lines of code.

This patch adds a separate Environment class, which is essentialy a
llvm::StringMap<std::string> in disguise. To standard StringMap
functionality, it adds a couple of new functions, which are specific to
the environment use case:
- (most important) envp conversion for passing into execve() and likes.
  Instead of trying to maintain a constantly up-to-date envp view, it
  provides a function which creates a envp view on demand, with the
  expectation that this will be called as the very last thing before
  handing the value to the system function.
- insert(StringRef KeyEqValue) - splits KeyEqValue into (key, value)
  pair and inserts it into the environment map.
- compose(value_type KeyValue) - takes a map entry and converts in back
  into "KEY=VALUE" representation.

With this interface most of the environment-manipulating code becomes
one-liners. The only tricky part was maintaining compatibility in
SBLaunchInfo, which expects that the environment entries are accessible
by index and that the returned const char* is backed by the launch info
object (random access into maps is hard and the map stores the entry in
a deconstructed form, so we cannot just return a .c_str() value). To
solve this, I have the SBLaunchInfo convert the environment into the
"envp" form, and use it to answer the environment queries. Extra code is
added to make sure the envp version is always in sync.

(This also improves the layering situation as Args was in the Interpreter module
whereas Environment is in Utility.)

Reviewers: zturner, davide, jingham, clayborg

Subscribers: emaste, lldb-commits, mgorny

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

llvm-svn: 322174
2018-01-10 11:57:31 +00:00
Jason Molenda 6b7daba64a This change updates the deployment target for lldb and debugserver
(built with Xcode) from 10.9 to 10.11.  It also enables the use of
libcompression in debugserver by default (these API are only present
in macOS 10.11 and newer -- 10.11 was released c. Sep 2015).

I don't know if we have people / bots building lldb on older mac
releases; if this turns out to be a problem I will revert the change.
There are some parts of lldb (e.g. debugserer's ability to report
the OS version #) that only work with 10.10 and this changes the
behavior of lldb (whether the older or newer dyld interfaces are
used) so there is some importance to updating the min required
version.

llvm-svn: 322128
2018-01-09 22:17:10 +00:00
Pavel Labath deb45f2043 debugserver: Propagate environment in launch-mode (pr35671)
Summary:
Make sure we propagate environment when starting debugserver with a pre-loaded
inferior. AFAIK, RNBRunLoopLaunchInferior is only called in pre-loaded inferior
scenario, so we can just pick up the debugserver environment instead of trying
to construct an envp from the (empty) context.

This makes debugserver pass an test added for an equivalent lldb-server fix.

Reviewers: jasonmolenda, clayborg

Subscribers: JDevlieghere, lldb-commits

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

llvm-svn: 321355
2017-12-22 11:09:21 +00:00
Adrian Prantl 7e13aef428 Replace an accidentally added "break" with an LLVM_FALLTHROUGH.
Thanks to Greg Clayton for catchting this!

llvm-svn: 321123
2017-12-19 23:16:38 +00:00
Adrian Prantl a01e024ad7 Fix a couple of warnings (NFC)
llvm-svn: 321120
2017-12-19 22:54:37 +00:00
Jason Molenda b1e350f71f Tweak to the debugserver entitlements setup in the xcode project
file.  For macos builds specifically, use the macosx entitlements
files; for all other builds, use the ios etc entitlements.

llvm-svn: 321051
2017-12-19 01:41:47 +00:00
Pavel Labath 11e5917d2a llgs: Propagate the environment when launching the inferior from command line
Summary:
We were failing to propagate the environment when lldb-server was
started with a pre-loaded process
(e.g.: lldb-server gdbserver -- inferior --inferior_args)

This patch makes sure the environment is propagated. Instead of adding a
new GDBRemoteCommunicationServerLLGS::SetLaunchEnvironment function to
complement SetLaunchArgs and SetLaunchFlags, I replace these with a
more generic SetLaunchInfo, which can be used to set any launch-related
property.

The accompanying test also verifies that the server correctly terminates
the connection after sending the exit packet (specifically, that it does
not send the exit packet twice).

Reviewers: clayborg, eugene

Subscribers: lldb-commits, mgorny

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

llvm-svn: 320984
2017-12-18 14:31:39 +00:00
Pavel Labath e2867bc4a0 ObjectFileELF: Add support for compressed sections
Summary:
We use the llvm decompressor to decompress SHF_COMPRESSED sections. This enables
us to read data from debug info sections, which are sometimes compressed,
particuarly in the split-dwarf case.  This functionality is only available if
llvm is compiled with zlib support.

Reviewers: clayborg, zturner

Subscribers: emaste, mgorny, aprantl, lldb-commits

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

llvm-svn: 320813
2017-12-15 14:23:58 +00:00
Jason Molenda aae5b69079 Change uses of strncpy in debugserver to strlcpy
for better safety.

<rdar://problem/32906923> 

llvm-svn: 320242
2017-12-09 03:37:09 +00:00
Vedant Kumar 9c36859b33 [MachException] Avoid alignment UB, NFC
Fix alignment UB in some Mach exception-handling logic.

This lets us build lldb and debugserver with UBSan in trapping mode, and
get further along in the testing process before a trap is encountered.

rdar://35923991

llvm-svn: 320127
2017-12-08 01:09:40 +00:00
Vedant Kumar b773e488c9 Remove extant references to g_message_mutex, NFC
Thanks to Jim Ingham for providing the explanation!

llvm-svn: 320126
2017-12-08 01:09:39 +00:00
Shoaib Meenai 5e8d5ccfe7 [lldb] Use PRIVATE in target_link_libraries
This is a follow-up to r319840. I guess none of the systems I'd tested
on before had LLDB_SYSTEM_LIBS set, which is why I didn't see any local
errors, but I'm surprised none of the bots caught it either.

llvm-svn: 319953
2017-12-06 20:53:03 +00:00
Vedant Kumar 50048ac65e Fix the -Wunused-function warning properly (MachProcess.mm)
r319938 was not NFC, because it got the preprocessor guard wrong. Check
WITH_FBS and WITH_BKS before defining SplitEventData.

llvm-svn: 319943
2017-12-06 19:27:20 +00:00
Vedant Kumar eacb0929e8 Fix an -Wunused-function warning, NFC
llvm-svn: 319938
2017-12-06 19:21:11 +00:00
Vedant Kumar 07d956149b Fix misc -Wcast-qual warnings, NFC
llvm-svn: 319937
2017-12-06 19:21:11 +00:00
Vedant Kumar 606908aab5 Remove no-op function pointer null checks, NFC
Null-checking functions which aren't marked weak_import is a no-op
(the compiler rewrites the check to 'true'), regardless of whether a
library providing its definition is weak-linked. If the deployment
target is greater than the minimum requirement, the availability markup
on APIs does not lower to weak_import.

Remove no-op null checks to clean up the code and silence warnings.

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

llvm-svn: 319936
2017-12-06 19:21:10 +00:00
Zachary Turner a6d5464cfe Add a symbols subcommand to lldb-test.
Differential Revision: https://reviews.llvm.org/D40745

llvm-svn: 319599
2017-12-02 00:15:29 +00:00
Vedant Kumar 02de50fdc4 Fix warnings in JSON.cpp, NFC
These asserts are no-ops, and are supplanted by -Wcovered-switch.

llvm-svn: 319596
2017-12-01 23:29:04 +00:00
Vedant Kumar 01e86df684 Fix warnings in DNBDataRef.cpp, NFC
llvm-svn: 319595
2017-12-01 23:24:12 +00:00
Zachary Turner 888a428292 Add lldb-test.
This is basically a proof-of-concept and starting point for having a
testing-centric tool in LLDB.  I'm sure this leaves a lot of room to be
desired, but this at least allows us to have something to build on.

Right now there is only one command, the `module-sections` command, and I
created this command not because it was particularly special, but
because it addressed an immediate use case and was extremely simple.

Run the tool as `lldb-test module-sections <path-to-object>`.

Feel free to add testing related stuff to your heart's content after
this goes in.  Implementing the commands themselves takes some work, but
once they're there they can be reused without writing any code and
result in very easy to use and maintain tests.

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

llvm-svn: 319504
2017-12-01 00:52:51 +00:00
Jim Ingham e28a93deff Recognize another magic token sent in the LaunchInfo's EventData.
<rdar://problem/32505028>

llvm-svn: 318496
2017-11-17 01:22:34 +00:00
Pavel Labath f753bfeeec Fix LLVM_LINK_LLVM_DYLIB build (pr35053)
Summary:
r316368 broke this build when it introduced a reference to a pthread
function to the Utility module. This caused cmake to generate an
incorrect link line (wrong order of libs) because it did not see the
dependency from Utility to the system libraries. Instead these libraries
were being manually added to each final target.

This changes moves the dependency management from the individual targets
to the lldbUtility module, which is consistent with how llvm does it.
The final targets will pick up these libraries as they will be a part of
the link interface of the module.

Technically, some of these dependencies could go into the host module,
as that's where most of the os-specific code is, but I did not try to
investigate which ones.

Reviewers: zturner, sylvestre.ledru

Subscribers: lldb-commits, mgorny

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

llvm-svn: 316997
2017-10-31 13:23:19 +00:00
Ted Woodward 2ecfd62938 Remove default case from switch.
Add case to handle new event lldb::eBreakpointEventTypeAutoContinueChanged.

llvm-svn: 315496
2017-10-11 19:38:35 +00:00
Davide Italiano 54fcf82454 [lldb-mi] Fix a thinko in my previous commit.
Hopefully this should unbreak the Android buildbot.

llvm-svn: 314606
2017-09-30 21:52:31 +00:00
Davide Italiano d4e450aca2 [lldb-mi] Add a default case to placate GCC with -Werror.
llvm-svn: 314604
2017-09-30 21:30:41 +00:00
Stephane Sezer 2ca6c3da63 Add a few missing newlines in lldb-server messages
Reviewers: fjricci, clayborg

Subscribers: lldb-commits

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

llvm-svn: 314455
2017-09-28 19:49:00 +00:00
Eugene Zemtsov 3015341d45 Use socketpair on all Unix platforms
Using TCP sockets is insecure against local attackers, and possibly
against remote attackers too (some vulnerabilities may allow tricking a
browser to make a request to localhost). Use socketpair (which is immune
to such attacks) on all Unix platforms.

Patch by Demi Marie Obenour < demiobenour@gmail.com >

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

llvm-svn: 314127
2017-09-25 17:41:16 +00:00
Adrian McCarthy 6c84ffbf5f Fix the SIGINT handlers
1. Fix a data race (g_interrupt_sent flag usage was not thread safe, signals
can be handled on arbitrary threads)

2. exit() is not signal-safe, replaced it with the signal-safe equivalent
_exit()

(This differs from the patch on Phabrictor because I had to add
`#include <atomic>` to get the definition of `std::atomic_flag`.)

patch by lemo

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

llvm-svn: 313785
2017-09-20 18:09:39 +00:00
Chris Bieneman 5226a2a6de [CMake] Need to set WITH_LOCKDOWN on debugserver target
Turns out WITH_LOCKDOWN define changes the struct layout and constructor implementation for RNBSocket which is used in debugserver.cpp, so we need to make sure this is consistent.

In the future we should change WITH_LOCKDOWN to be configured in a generated header, but for now we can just set it correctly.

<rdar://problem/33900552>

llvm-svn: 312666
2017-09-06 20:15:43 +00:00
Ted Woodward 91635e0cef lldb-mi: -var-update can hang when traversing complex types with pointers
Summary:
-var-update calls CMICmdCmdVarUpdate::ExamineSBValueForChange to check if a varObj has been updated. It checks that the varObj is updated, then recurses on all of its children. If a child is a pointer pointing back to a parent node, this will result in an infinite loop, and lldb-mi hanging.

The problem is exposed by packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py, but this test is skipped everywhere.

This patch changes ExamineSBValueForChange to not traverse children of varObjs that are pointers.

Reviewers: ki.stfu, zturner, clayborg, abidh

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 312270
2017-08-31 19:22:33 +00:00
Jason Molenda 9ff294f039 Change the ftag x87 register from being 8-bits wide to 16-bits wide
to match the changes Saleem Abdulrasool committed in r311579.  Fixes
a testsuite failure now that the testsuite expects a 16 bit return
value for thsi reg.

llvm-svn: 311627
2017-08-24 03:22:08 +00:00
Bruce Mitchener 416bc3d70a lldb-argdumper doesn't need lldbCore.
Summary: lldb-argdumper only needs lldbUtility to successfully build and link.

Reviewers: beanz, zturner, labath

Subscribers: mgorny, lldb-commits

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

llvm-svn: 311399
2017-08-21 22:54:49 +00:00
Lang Hames ccfc80ccc7 Fix typo in variable name.
llvm-svn: 310984
2017-08-16 01:50:32 +00:00
Chris Bieneman a944dd109b [CMake] Fixing an error in STREQUAL usage.
llvm-svn: 310955
2017-08-15 20:56:04 +00:00
Chris Bieneman 30f044b72c [CMake] Disable code sign entitlements when using lldb_codesign
Turns out self-signed certificates and entitlements don't always play well together...

llvm-svn: 310936
2017-08-15 17:42:20 +00:00
Abhishek Aggarwal 95bd95c075 Checking in files accidentally missed in later diffs of revision r310261
-- 2 files were missing in this commit which should have been there.
    These files were submitted initially for review and were reviewed.
    However, while updating the revision with newer diffs, I accidentally
    forgot to include them in newer diffs. So commiting now.
    

llvm-svn: 310341
2017-08-08 09:25:50 +00:00
Abhishek Aggarwal a8af18ac1d Fixed build failure for revision r310261
-- Was failing for Linux

llvm-svn: 310270
2017-08-07 17:15:26 +00:00
Abhishek Aggarwal 96bea51234 Fixed build failure for revision r310261
-- Build was failing for freebsd

llvm-svn: 310266
2017-08-07 15:53:30 +00:00
Abhishek Aggarwal 307db0f897 Tool for using Intel(R) Processor Trace hardware feature
Summary:
1. Provide single library for all Intel specific hardware features instead
    of individual libraries for each feature
2. Added Intel(R) Processor Trace hardware feature in this single library.
    Details about the tool implementing this feature is as follows:

     Tool developed on top of LLDB to provide its users the execution
     trace of the debugged inferiors. Tool's API are exposed as C++ object
     oriented interface in a shared library. API are designed especially to be
     easily integrable with IDEs providing LLDB as an application debugger.
     Entire API is also available as Python functions through a script bridging
     interface allowing development of python modules.

     This patch also provides a CLI wrapper to use the Tool through LLDB's command
     line. Highlights of the Tool and the wrapper are given below:

  ******************************
  Intel(R) Processor Trace Tool:
  ******************************
       - Provides execution trace of the debugged application
       - Uses Intel(R) Processor Trace hardware feature (already implemented inside LLDB)
         for this purpose
           -- Collects trace packets generated by this feature from LLDB, decodes and
              post-processes them
           -- Constructs the execution trace of the application
           -- Presents execution trace as a list of assembly instructions
       - Provides 4 APIs (exposed as C++ object oriented interface)
           -- start trace with configuration options for a thread/process,
           -- stop trace for a thread/process,
           -- get the execution flow (assembly instructions) for a thread,
           -- get trace specific information for a thread
       - Easily integrable into IDEs providing LLDB as application debugger
       - Entire API available as Python functions through script bridging interface
           -- Allows developing python apps on top of Tool
       - README_TOOL.txt provides more details about the Tool, its dependencies, building
         steps and API usage
       - Tool ready to use through LLDB's command line
           -- CLI wrapper has been developed on top of the Tool for this purpose

  *********************************
  CLI wrapper: cli-wrapper-pt.cpp
  *********************************
       - Provides 4 commands (syntax similar to LLDB's CLI commands):
           -- processor-trace start
           -- processor-trace stop
           -- processor-trace show-trace-options
           -- processor-trace show-instr-log
       - README_CLI.txt provides more details about commands and their options

Signed-off-by: Abhishek Aggarwal <abhishek.a.aggarwal@intel.com>

Reviewers: clayborg, jingham, lldb-commits, labath

Reviewed By: clayborg

Subscribers: ravitheja, emaste, krytarowski, mgorny

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

llvm-svn: 310261
2017-08-07 15:26:11 +00:00
Chris Bieneman 6678e39aa4 [CMake] debugserver-nonui doesn't go in the framework
Small change to correct the install path of the nonui debugserver.

llvm-svn: 309428
2017-07-28 20:27:37 +00:00
Chris Bieneman b311741011 [CMake] libcompression is optional not required for debugserver
Fix a quick bug from r309395.

llvm-svn: 309396
2017-07-28 15:44:16 +00:00
Chris Bieneman 8c01cc54eb [CMake] Add checks for libcompression
This enables libcompression when available in the CMake build system.

llvm-svn: 309395
2017-07-28 15:39:51 +00:00
Chris Bieneman 09736e314c [CMake] Build debugserver & debugserver_nonui
When building for iOS we build two variants of debugserver. One which supports UI functionality like Springboard for launching applications, and one which does not.

This patch adds support for building debugserver with and without UI support libraries being available.

llvm-svn: 309026
2017-07-25 20:31:53 +00:00
Chris Bieneman 712fe007cd [CMake] Add debugserver entitlements
When consigning debugserver we should also include the entitlements file on the code sign command.

llvm-svn: 309020
2017-07-25 20:29:28 +00:00
Chris Bieneman f396708f4c [CMake] Refactor debugserver build system
This refactoring changes two significant things about how the debugserver build system works:

(1) debugserver will include all appropriate architecture support, so we can now build arm or ppc debugservers
(2) debugserver can be built by itself, so you don't have to configure all of LLDB in order to generate debugserver.

llvm-svn: 308377
2017-07-18 21:15:27 +00:00
Pavel Labath b6dbe9a99c Clean up lldb-types.h
Summary:
It defined a couple of types (condition_t) which we don't use anymore,
as we have c++11 goodies now. I remove these definitions.

Also it unnecessarily included a couple of headers which weren't
necessary for it's operation. I remove these, and place the includes in
the relevant files (usually .cpp, usually in Host code) which use them.
This allows us to reduce namespace pollution in most of the lldb files
which don't need the OS-specific definitions.

Reviewers: zturner, jingham

Subscribers: ki.stfu, lldb-commits

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

llvm-svn: 308304
2017-07-18 13:14:01 +00:00
Pavel Labath 82abefa4b1 Remove shared pointer from NativeProcessProtocol
Summary:
The usage of shared_from_this forces us to separate construction and
initialization phases, because shared_from_this() is not available in
the constructor (or destructor). The shared semantics are not necessary,
as we always have a clear owner of the native process class
(GDBRemoteCommunicationServerLLDB object). Even if we need shared
semantics in the future (which I think we should strongly avoid),
reverting this will not be necessary -- the owners can still easily
store the native process object in a shared pointer if they really want
to -- this just prevents the knowledge of that from leaking into the
class implementation.

After this a NativeThread object will hold a reference to the parent
process (instead of a weak_ptr) -- having a process instance always
available allows us to simplify some logic in this class (some of it was
already simplified because we were asserting that the process is
available, but this makes it obvious).

Reviewers: krytarowski, eugene, zturner

Subscribers: lldb-commits

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

llvm-svn: 308282
2017-07-18 09:24:48 +00:00
Chris Bieneman 7dc58b238d Fix debugserver accepting remote connections
While adding IPv6 support to debugserver I broke handling wildcard addresses and fully qualified address filtering. This patch resolves that bug and adds a test for matching the address "*".

<rdar://problem/32947613>

llvm-svn: 307957
2017-07-13 20:58:13 +00:00
Pavel Labath 96e600fcf5 Add a NativeProcessProtocol Factory class
Summary:
This replaces the static functions used for creating
NativeProcessProtocol instances with a factory pattern, and modernizes
the interface of the new class in the process -- I use llvm::Expected
instead of the Status+value combo. I also move some of the common code
(like the Delegate registration into the base class). The new
arrangement has multiple benefits:
- it removes the NativeProcess*** dependency from Process/gdb-remote
  (which for example means that liblldb no longer pulls in this code).
- it enables unit testing of the GDBRemoteCommunicationServerLLGS class
  (by providing a mock Native Process).
- serves as another example on how to use the llvm::Expected class (I
  couldn't get rid of the Initialize-type functions completely here
  because of the use of shared_from_this, but that's the next thing on
  my list here)

Tests still pass on Linux and I've made sure NetBSD compiles after this.

Reviewers: zturner, eugene, krytarowski

Subscribers: srhines, lldb-commits, mgorny

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

llvm-svn: 307390
2017-07-07 11:02:19 +00:00
Pavel Labath 21fb07b715 Fix a copy-paste error in r307161
llvm-svn: 307253
2017-07-06 11:43:25 +00:00
Pavel Labath ef7aff507b Fix assorted compiler warnings (mismatched signedness and printf specifiers)
llvm-svn: 307161
2017-07-05 14:54:46 +00:00
Tim Hammerquist 0a94072e4d Fix some type-based warnings
llvm-svn: 306765
2017-06-29 23:33:40 +00:00
Jason Molenda d2d4c8db45 Update default cpu subtype for armv7 processes to armv7k, the most
likely cpu subtype at this point.

llvm-svn: 306752
2017-06-29 22:50:53 +00:00