Commit Graph

538 Commits

Author SHA1 Message Date
Michal Gorny f6e5594e81 [lldb] [unittest] Avoid mixing '127.0.0.1' and 'localhost'
Fix the tests not to use '127.0.0.1' and 'localhost' interchangeably.
More specifically, since tests bind specifically to 127.0.0.1, connect
to that address as well; using 'localhost' can resolve to IPv6 address
which can cause issues -- for example, if the matching port happens to
be used by some other process, the tests hang forever waiting for
the client to connect.

While technically the case of randomly selected IPv4 port being taken
on IPv6 loopback is not very likely, NetBSD happens to be suffering from
some weird kernel issue where connection to that port succeeds
nevertheless.  Until we can really figure out what goes wrong there,
this saves us from the tests hanging randomly.

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

llvm-svn: 353868
2019-02-12 18:09:00 +00:00
Pavel Labath 7f815a9a42 Have Stream::PutCStringAsRawHex8 take llvm::StringRef
This enables the function to be called with a StringRef without jumping
through any hoops. I rename the function to "PutStringAsRawHex8" to
honor the extended interface. I also remove ".c_str()" from any calls to
this function I could find.

llvm-svn: 353841
2019-02-12 14:28:55 +00:00
Jonas Devlieghere 70355ace3f Remove redundant ::get() for smart pointer. (NFC)
This commit removes redundant calls to smart pointer’s ::get() method.

https://clang.llvm.org/extra/clang-tidy/checks/readability-redundant-smartptr-get.html

llvm-svn: 353795
2019-02-12 03:47:39 +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
Pavel Labath 841bea933b Breakpad: auto-detect path style of file entries
Summary:
This adds support for auto-detection of path style to SymbolFileBreakpad
(similar to how r351328 did the same for DWARF). We guess each file
entry separately, as we have no idea which file came from which compile
units (and different compile units can have different path styles). The
breakpad generates should have already converted the paths to absolute
ones, so this guess should be reasonable accurate, but as always with
these kinds of things, it is hard to give guarantees about anything.

In an attempt to bring some unity to the path guessing logic, I move the
guessing logic from inside SymbolFileDWARF into the FileSpec class and
have both symbol files use it to implent their desired behavior.

Reviewers: clayborg, lemo, JDevlieghere

Subscribers: aprantl, markmentovai, lldb-commits

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

llvm-svn: 353702
2019-02-11 14:11:00 +00:00
Raphael Isemann d1307ec4cc Fix x86 return pattern detection
Summary: Replace 0xc9 (LEAVE) with 0xcb (RETF) in ret_pattern_p(). Also put 0xc3 first, since it is the most common form and will match first.

Reviewers: jasonmolenda

Reviewed By: jasonmolenda

Subscribers: labath, lldb-commits

Tags: #lldb

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

llvm-svn: 353643
2019-02-10 15:41:53 +00:00
Michal Gorny 01486b22bb [lldb] [unittests] Disable MainLoopTest::DetectsEOF on NetBSD
The NetBSD kernel currently does not support detecting closed slave pty
via kevent on master pty.  This causes the test to hang forever.
To avoid that, disable the test until the kernel is fixed.

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

llvm-svn: 353545
2019-02-08 18:56:11 +00:00
Aleksandr Urakov ee21a66a7b [NFC] Fix license headers after r352845
llvm-svn: 353503
2019-02-08 08:48:15 +00:00
Pavel Labath bae220ce9c Fix headers for files added in r353047
I started working on that patch before the headers were updated. Since
they were new files, I didn't get any conflicts during rebase.

llvm-svn: 353429
2019-02-07 17:16:25 +00:00
Pavel Labath a5d19759b2 Fix signed/unsigned mismatches in ProcessInfoTest.cpp
llvm-svn: 353420
2019-02-07 15:56:40 +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
Aleksandr Urakov 823c66b617 [x64] Process the B field of the REX prefix correctly for the PUSH and POP
instructions

Summary: This patch makes `x86AssemblyInspectionEngine` to process zero value of
the `B` field of the `REX` prefix in a correct way for `PUSH` and `POP`
instructions. MSVC sometimes emits `pushq %rbp` instruction as `0x40 0x55`, and
it was not parsed correctly before.

Reviewers: jasonmolenda, labath

Reviewed By: jasonmolenda, labath

Subscribers: abidh, lldb-commits

Tags: #lldb

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

llvm-svn: 353281
2019-02-06 08:48:30 +00:00
Jonas Devlieghere 3e30062acb [unittests] Fix warning
warning: comparison of integers of different signs: 'const int' and
'const unsigned long' [-Wsign-compare]

llvm-svn: 353196
2019-02-05 18:46:37 +00:00
Jonas Devlieghere 494fd8f84f [Reproducers] Instrumentation Framework: Serialization
This is the is serialization/deserialization part of the reproducer
instrumentation framework.

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/D57714

llvm-svn: 353195
2019-02-05 18:46:36 +00:00
Pavel Labath eef758e949 Move FileAction, ProcessInfo and ProcessLaunchInfo from Target to Host
Summary:
These classes describe the details of the process we are about to
launch, and so they are naturally used by the launching code in the Host
module. Previously they were present in Target because that is the most
important (but by far not the only) user of the launching code.

Since the launching code has other customers, must of which do not care
about Targets, it makes sense to move these classes to the Host layer,
next to the launching code.

This move reduces the number of times that Target is included from host
to 8 (it used to be 14).

Reviewers: zturner, clayborg, jingham, davide, teemperor

Subscribers: emaste, mgorny, lldb-commits

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

llvm-svn: 353047
2019-02-04 14:28:08 +00:00
Aleksandr Urakov 758657e565 [PDB] Fix location retrieval for function local variables and arguments that are
stored relative to VFRAME

Summary:
This patch makes LLDB able to retrieve proper values for function arguments and
local variables stored in PDB relative to VFRAME register.

Patch contains retrieval of corresponding FPO table entries from PDB and a
generic translator from FPO programs to DWARF expressions to get correct VFRAME
value.

Patch also improves variables-locations.test and makes this test passable on
x86.

Patch By: leonid.mashinsky

Reviewers: zturner, asmith, stella.stamenova, aleksandr.urakov

Reviewed By: zturner

Subscribers: arphaman, labath, mgorny, aprantl, JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 352845
2019-02-01 10:01:18 +00:00
Jonas Devlieghere 043ff33362 [unittest] Fix scalar unit test.
The test was using ASSERT_EQ instead of ASSERT_STREQ which meant we were
comparing string addresses instead of the actual string. This caused the
test to fail with with the sanitizers enabled.

llvm-svn: 352780
2019-01-31 18:48:17 +00:00
Davide Italiano 51d46bd4d2 [Scalar] Implement support for 512-bit values.
(useful, e.g. when reading 512-bits registers, a-la AVX-512).

<rdar://problem/46886288>

llvm-svn: 352639
2019-01-30 18:05:36 +00:00
Jonas Devlieghere 7d2192ca7b [test] Use correct macro in FileCollectorTest.cpp
This test was supposed to be skipped on Windows but was using the wrong
macro name.

llvm-svn: 352556
2019-01-29 22:53:47 +00:00
Jonas Devlieghere 46575176e9 [Reproducers] Add file provider
This patch adds the file provider which is responsible for capturing
files used by LLDB.

When capturing a reproducer, we use a file collector that is very
similar to the one used in clang. For every file that we touch, we add
an entry with a mapping from its virtual to its real path. When we
decide to generate a reproducer we copy over the files and their
permission into to reproducer folder.

When replaying a reproducer, we load the VFS mapping and instantiate a
RedirectingFileSystem. The latter will transparently use the files
available in the reproducer.

I've tested this on two macOS machines with an artificial example.
Still, it is very likely that I missed some places where we (still) use
native file system calls. I'm hoping to flesh those out while testing
with more advanced examples. However, I will fix those things in
separate patches.

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

llvm-svn: 352538
2019-01-29 20:36:38 +00:00
Pavel Labath b1f28579ac BreakpadRecords: Add parsing code for FILE and LINE records
The two records aren't used by anything yet, but this part can be
separated out easily, so I am comitting it separately to simplify
reviews of the followup patch.

llvm-svn: 352507
2019-01-29 15:39:27 +00:00
Jim Ingham f3ecbfc164 Add UUID::SetFromOptionalStringRef, use it in DynamicLoaderDarwin
We use UUID::fromOptionalData to read UUID's from the Mach-O files, so UUID's
of all 0's are invalid UUID's.
We also get uuid's from debugserver, which need to match the file UUID's.  So
we need an API that treats "000000000" as invalid as well.  Added that and use it.

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

llvm-svn: 352122
2019-01-24 22:43:44 +00:00
Davide Italiano 7fca260dc8 [Scalar] Clarify the constructor from APInt and document through a test.
I want to add 512-bits support but I first want to make sure I'm
not breaking anything obvious. This is the first of a series of commit
adding tests. The first oddity found is that Scalar from APInt(s)
always constructed signed. Maybe at some point we want to revisit
this, but at least now we have a test to document how the API behaves.

<rdar://problem/46886288>

llvm-svn: 352103
2019-01-24 20:55:12 +00:00
Pavel Labath 06bb373559 breakpad: Add FUNC records to the symtab
This patch extends SymbolFileBreakpad::AddSymbols to include the symbols
from the FUNC records too. These symbols come from the debug info and
have a size associated with them, so they are given preference in case
there is a PUBLIC record for the same address.

To achieve this, I first pre-process the symbols into a temporary
DenseMap, and then insert the uniqued symbols into the module's symtab.

Reviewers: clayborg, lemo, zturner

Reviewed By: clayborg

Subscribers: lldb-commits

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

llvm-svn: 351781
2019-01-22 04:56:31 +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
Pavel Labath 2cf5486ce4 Breakpad: Extract parsing code into a separate file
Summary:
This centralizes parsing of breakpad records, which was previously
spread out over ObjectFileBreakpad and SymbolFileBreakpad.

For each record type X there is a separate breakpad::XRecord class, and
an associated parse function. The classes just store the information in
the breakpad records in a more accessible form. It is up to the users to
determine what to do with that data.

This separation also made it possible to write some targeted tests for
the parsing code, which was previously unaccessible, so I write a couple
of those too.

Reviewers: clayborg, lemo, zturner

Reviewed By: clayborg

Subscribers: mgorny, fedor.sergeev, lldb-commits

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

llvm-svn: 351541
2019-01-18 10:37:04 +00:00
Jonas Devlieghere 17f277d754 [Reproducers] Fix reproducers unittest.
Fix fallout from r351501 in the reproducer unittest.

llvm-svn: 351524
2019-01-18 07:17:05 +00:00
Alex Langford 9299d589ec [CMake] Only test debugserver if platform can use debugserver
In commit svn r351496 I changed this condition from
`if(LLDB_CAN_USE_DEBUGSERVER)` to `if(NOT SKIP_TEST_DEBUGSERVER)`.
This causes debugserver tests to run on windows, which shouldn't happen.
SKIP_TEST_DEBUGSERVER is set either by the user (it shouldn't be set on
windows builds) or in the debugserver CMake logic (which doesn't get
included when building on windows). Therefore, I changed the condition
to be `if(LLDB_CAN_USE_DEBUGSERVER AND NOT SKIP_TEST_DEBUGSERVER)`.

llvm-svn: 351498
2019-01-18 00:05:25 +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
Pavel Labath 2a32a69c53 TestClangASTContext: Rewrite an if-else chain into a switch
This avoids the "ambiguous else" warning, which comes from within the
EXPECT_TRUE macro.

llvm-svn: 351331
2019-01-16 12:43:01 +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
Davide Italiano ff92a1a7cf [Scalar] Simplify comparison operators and add coverage.
llvm-svn: 350428
2019-01-04 19:23:52 +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
Pavel Labath 0611642f3a RangeMap.h: merge RangeDataArray and RangeDataVector
Summary:
The main difference between the classes was supposed to be the fact that
one is backed by llvm::SmallVector, and the other by std::vector.
However, over the years, they have accumulated various other differences
too.

This essentially removes the std::vector version, as that is pretty much
identical to llvm::SmallVector<T, 0>, and combines their interfaces. It
does not attempt to do a more significant refactoring, even though there
is still a lot of duplication in this file, as it is hard to tell which
quirk of some API is depended on by somebody (and, a previous, more
ambitious attempt at this in D16769 has failed).

I also add some tests, including one which demonstrates one of the
quirks/bugs of the API I have noticed in the process.

Reviewers: clayborg, teemperor, tberghammer

Subscribers: mgorny, JDevlieghere, lldb-commits

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

llvm-svn: 350380
2019-01-04 07:14:17 +00:00
Pavel Labath f760f5aef4 Simplify ObjectFile::GetArchitecture
Summary:
instead of returning the architecture through by-ref argument and a
boolean value indicating success, we can just return the ArchSpec
directly. Since the ArchSpec already has an invalid state, it can be
used to denote the failure without the additional bool.

Reviewers: clayborg, zturner, espindola

Subscribers: emaste, arichardson, JDevlieghere, lldb-commits

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

llvm-svn: 350291
2019-01-03 10:37:19 +00:00
Pavel Labath 52b7e863d1 NativeProcessProtocolTest: fix -Winconsistent-missing-override warning
The warning comes from the fact that the MOCK_METHOD macros don't use the
override keyword internally. This makes us not use it in the manually overriden
methods either, to be consistent.

llvm-svn: 350209
2019-01-02 10:37:38 +00:00
Pavel Labath 2da15e4dc8 Fix signed-unsigned comparisons in MinidumpParserTest
llvm-svn: 350122
2018-12-28 13:34:50 +00:00
Pavel Labath 9352f4706a Fix assertion failure in NativeProcessProtocolTest
The assertion fired (with a debug visual studio STL) because we tried to
dereference the end of a vector (although it was only to take its
address again and form an end iterator). Rewrite this logic to avoid the
questionable code.

llvm-svn: 350091
2018-12-27 13:45:55 +00:00
Davide Italiano b429637168 [Scalar] Simplify as Jonas suggested. NFCI.
llvm-svn: 349971
2018-12-21 22:45:07 +00:00
Davide Italiano 18a0ce9813 [Scalar] Implement operator!= using operator==.
Summary: Adding some test coverage while I'm around.

Reviewers: JDevlieghere, aprantl, zturner, clayborg, jingham

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

llvm-svn: 349970
2018-12-21 22:42:00 +00:00
Pavel Labath 56279cf24f Fix the "dangerous use of tempnam" warning in Host/SocketTest.cpp
instead, create a unique temporary directory, and place the socket file
there.

llvm-svn: 349495
2018-12-18 15:33:50 +00:00
Greg Clayton 48a28c1665 Add "dump" command as a custom "process plugin" subcommand when ProcessMinidump is used.
Each process plug-in can create its own custom commands. I figured it would be nice to be able to dump things from the minidump file from the lldb command line, so I added the start of the some custom commands.

Currently you can dump:

minidump stream directory
all linux specifc streams, most of which are strings
each linux stream individually if desired, or all with --linux
The idea is we can expand the command set to dump more things, search for data in the core file, and much more. This patch gets us started.

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

llvm-svn: 349429
2018-12-18 00:50:11 +00:00
Greg Clayton baaf2cc7ba Add missing .dmp files to test inputs.
llvm-svn: 349183
2018-12-14 19:38:08 +00:00
Greg Clayton 026e1bf56a Cache memory regions in ProcessMinidump and use the linux maps as the source of the information if available
Breakpad creates minidump files that sometimes have:
- linux maps textual content
- no MemoryInfoList

Right now unless the file has a MemoryInfoList we get no region information.

This patch:

- reads and caches the memory region info one time and sorts it for easy subsequent access
- get the region info from the best source in this order:
  - linux maps info (if available)
  - MemoryInfoList (if available)
  - MemoryList or Memory64List
- returns memory region info for the gaps between regions (before the first and after the last)

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

llvm-svn: 349182
2018-12-14 19:36:01 +00:00
Pavel Labath 181b823b04 Move Broadcaster+Listener+Event combo from Core into Utility
Summary:
These are general purpose "utility" classes, whose functionality is not
debugger-specific in any way. As such, I believe they belong in the
Utility module.

This doesn't break any particular dependency (yet), but it reduces the
number of Core dependencies across the board.

Reviewers: zturner, jingham, teemperor, clayborg

Subscribers: mgorny, lldb-commits

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

llvm-svn: 349157
2018-12-14 15:59:49 +00:00
Pavel Labath eed7b2eeca Fix minidump unit test failures from r349062
This commit added new test inputs, but it did not add them to the cmake
files. This caused the test to fail at runtime.

While in there, I also sorted the list of minidump test inputs.

llvm-svn: 349154
2018-12-14 14:41:04 +00:00
Greg Clayton e55979b1e2 Fix MinidumpParser::GetFilteredModuleList() and test it
The MinidumpParser::GetFilteredModuleList() code was attempting to iterate through the entire module list and if it found more than one entry for a given module name, it wanted to pick the MinidumpModule with the lowest address. A bug existed where it wasn't doing that due to "exists" variable being inverted. "exists" was set to true if it was inserted, not if it existed. Furthermore, the order of the modules would be modified by sorting all modules from low address to high address (using MinidumpModule::base_of_image). This fix also maintains the original order which means your executable is at index 0 as intended instead of some random shared library.

Tests were added to ensure this functionality doesn't regress.

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

llvm-svn: 349062
2018-12-13 17:24:30 +00:00
Adrian Prantl 96f6963708 Add another ArchSpec unit test.
llvm-svn: 348502
2018-12-06 17:11:45 +00:00
Adrian Prantl 7b8a03751c Add a unit test for ArchSpec matching to document how it behaves (and test it).
llvm-svn: 348440
2018-12-06 00:43:55 +00:00