Commit Graph

1434 Commits

Author SHA1 Message Date
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