Commit Graph

22600 Commits

Author SHA1 Message Date
Martin Storsjö 613d866374 [lldb] Remove a redundant semicolon, fixing GCC warnings. NFC. 2020-04-29 21:00:43 +03:00
Pavel Labath 2cf69684fb [lldb/DWARF] Fix a split-dwarf crash while parsing compile units
The cause of this crash is relatively simple -- we are using a
SymbolFileDWARFDwo to parse a (skeleton) dwarf unit. This cause the
CompileUnit to be created with the wrong ID, which later triggers an
assertion in SymbolFile::SetCompileUnitAtIndex. The fix is also simple
-- ensure we use the right symbol file for parsing.

However, a fairly elaborate setup is needed trigger this bug, because
ParseCompileUnit is normally called very early on (and with the right
symbol file object) during the process of accessing a compile unit.
The only way this can be triggered is if the DWARF unit is
"accidentally" pulled into scope during expression evaluation
This can happen if the "this" object used for the context of an
expression is in a namespace, and that namespace is also present in
other compile units

The included test recreates this setup.
2020-04-29 16:21:11 +02:00
Jonas Devlieghere bb7bde5bba Revert "[lldb/Platform] Return a std::string from GetSDKPath"
This reverts commit b14c37a29a.
2020-04-29 01:26:24 -07:00
Muhammad Omair Javaid e35dbb3c88 Fix LLDB elf core dump register access for ARM/AArch64
Summary:
This patch adds support to access AArch64 FP SIMD core dump registers and adds a test case to verify registers.

This patches fixes a bug where doing "register read --all" causes lldb to crash.

Reviewers: labath

Reviewed By: labath

Subscribers: kristof.beyls, danielkiss, lldb-commits

Differential Revision: https://reviews.llvm.org/D77793
2020-04-29 09:24:39 +05:00
Saleem Abdulrasool 7c8fa95395 lldb: use the newer `find_package` if available
Now that the rest of LLVM prefers python3 over python2, the LLDB path
should follow suite.  Add a fallback path to python2 for non-Windows
targets.
2020-04-29 03:54:33 +00:00
Muhammad Omair Javaid 9f8b4472fb Extend max register size to accommodate AArch64 SVE vector regs
Summary: This patch increases maximum register size to 256 bytes to accommodate AArch64 SVE registers maximum possible size of 256 bytes.

Reviewers: labath, jankratochvil, rengolin

Reviewed By: labath

Subscribers: tschuett, kristof.beyls, danielkiss, lldb-commits

Differential Revision: https://reviews.llvm.org/D77044
2020-04-29 07:51:30 +05:00
Jonas Devlieghere 6e693386af [lldb/Host] Pass a StringRef to the FileSpec ctor
The FileSpec constructor takes a StringRef so there's no point in going
through a C string.
2020-04-28 19:21:58 -07:00
Jonas Devlieghere 75c3d6f49c [lldb/Platform] Synchronize access to SDK String Map.
The SwiftASTContext queries this function in parallel and requires
synchronization.
2020-04-28 19:21:58 -07:00
Jonas Devlieghere b14c37a29a [lldb/Platform] Return a std::string from GetSDKPath
Nothing guarantees that the objects in the StringMap remains at the same
address when the StringMap grows. Therefore we shouldn't return a
reference into the StringMap but return a copy of the string instead.
2020-04-28 19:21:58 -07:00
Walter Erquinigo 83725822c5 [lldb-vscode] Add an option for loading core files
Summary:
Currently loading core files on lldb-vscode is broken because there's a check in the attach workflow that asserts that the PID is valid, which of course fails for this case.
Hence, I'm adding a "coreFile" argument for the attach request, which does the work correctly.

I don't know how to test it effectively so that it runs on the buildbots and the debugger can in fact makes sense of it. Anyway, the change has been relatively simple.

Reviewers: labath, clayborg

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78839
2020-04-28 13:03:02 -07:00
Pavel Labath f07f2cee9b [lldb/unittest] Adjust CheckIPSupport function to avoid double-consume of llvm::Error
The problem caught by clang-tidy and reported by Tobias Bosch.
2020-04-28 13:35:07 +02:00
Pavel Labath 5cee8ddcc7 [lldb-vscode] A couple of small style fixes
to make the code conform to llvm style better:
- avoid use of auto where the type is not obivous
- avoid StringRef::data where it is not needed

No functional change intended.
2020-04-28 13:35:07 +02:00
Craig Topper a58b62b4a2 [IR] Replace all uses of CallBase::getCalledValue() with getCalledOperand().
This method has been commented as deprecated for a while. Remove
it and replace all uses with the equivalent getCalledOperand().

I also made a few cleanups in here. For example, to removes use
of getElementType on a pointer when we could just use getFunctionType
from the call.

Differential Revision: https://reviews.llvm.org/D78882
2020-04-27 22:17:03 -07:00
Eric Christopher 4d40d66402 Fix up a clang-tidy nit about using empty rather than size == 0. 2020-04-27 15:22:44 -07:00
Med Ismail Bennani 8f5beb4c4b
[lldb/Dataformatter] Add support for CoreFoundation Dictionaries and Sets.
This patch improves data formatting for CoreFoundation containers:
CFDictionary and CFSet.

These data formatters make the containers and their children appear in Xcode's
variables view (and on the command line) without having to expand the
data structure.

Previous implementation only supported showing the container's element count.

```
(lldb) frame var dict
(__NSCFDictionary *) dict = 0x00000001004062b0 2 key/value pairs

(lldb) frame var set
(__NSCFSet *) set = 0x0000000100406330 2 elements
```
Now the variable can be dereferenced to dispaly the container's children:

```
(lldb) frame var *dict
(__NSCFDictionary) *dict = {
  [0] = {
    key = 0x0000000100004050 @"123"
    value = 0x0000000100004090 @"456"
  }
  [1] = {
    key = 0x0000000100004030 @"abc"
    value = 0x0000000100004070 @"def"
  }
}

(lldb) frame var *set
(__NSCFSet) *set = {
  [0] = 0x0000000100004050 @"123"
  [1] = 0x0000000100004030 @"abc"
}
```

rdar://39882287

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2020-04-27 22:10:11 +02:00
Pavel Labath 58435f69cb [lldb] Fix windows build break from 18e96a31 2020-04-27 19:22:44 +02:00
Pavel Labath 18e96a31fe [lldb/unittests] Skip IPv6 test on systems which don't have IPv6 configured
Sadly IPv6 is still not present anywhere. The test was attempting to
detect&skip such hosts, but the way it did that (essentially, by calling
getaddrinfo) meant that it only detected hosts which have IPv6 support
completely compiled out. It did not do anything about hosts which have
it compiled in, but lack runtime configuration even for the ::1 loopback
address.

This patch changes the detection logic to use a new method. It does it
by attempting to bind a socket to the appropriate loopback address. That
should ensure the hosts loopback interface is fully set up. In an effort
to avoid silently skipping the test on too many hosts, the test is
fairly strict about the kind of error it expects in these cases -- it
will only skip the test when receiving EADDRNOTAVAIL. If we find other
error codes that can be reasonably returned in these situations, we can
add more of them.

The (small) change in TCPSocket.cpp is to ensure that the code correctly
propagates the error received from the OS.
2020-04-27 17:33:20 +02:00
Raphael Isemann ff5264f0c6 [lldb][cmake] Move the remove_module_flags call to the right place in debugserver's CMakeLists
This code should always be executed, not just when building the debugserver
on its own. Fixes the modules build when building LLVM+LLDB together.
2020-04-27 16:04:19 +02:00
Pavel Labath 9671f6e8d5 [lldb] Remove NativeProcessDarwin
this is dead and non-functional code that hasn't been touched (modulo
refactors) since it was checked in (as an "NFC, with no review and
tests) in 2016.

Anyone interested in adding darwin support to lldb-server can look this
up in git history.
2020-04-27 15:26:57 +02:00
Raphael Isemann d00eaa082b [lldb] Adjust TestExec code to be closer to real world code
Summary:
For some reason the TestExec test on the macOS bots randomly fails with this error:
```
output: * thread #2, stop reason = EXC_BAD_ACCESS (code=1, address=0x108e66000)
  * frame #0: 0x0000000108e66000
[...]
  File "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/exec/TestExec.py", line 25, in test_hitting_exec
    self.do_test(False)
  File "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/exec/TestExec.py", line 113, in do_test
    "Stopped at breakpoint in exec'ed process.")
AssertionError: False is not True : Stopped at breakpoint in exec'ed process.
Config=x86_64-/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang-11
```

I don't know why the test program is failing and I couldn't reproduce this problem on my own.
This patch is a stab in the dark that just tries to make the test code more similar to code which
we would expect in a user program to make whatever part of macOS happy that is currently
not liking our code.

The actual changes are:
* We pass in argv[0] that is describing otherprog path instead of the current argv[0].
* We pass in a non-null envp (which anyway doesn't seem to be allowed on macOS man page).

Reviewers: labath, JDevlieghere

Reviewed By: labath

Subscribers: abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D75241
2020-04-27 14:57:12 +02:00
Aleksandr Urakov 84c398d375 [lldb][TypeSystemClang] Desugar an elaborated type before checking if it's a typedef or getting a typedefed type
Summary:
Sometimes a result variable of some expression can be presented as an elaborated
type. In this case the methods `IsTypedefType()` and `GetTypedefedType()` of
`SBType` didn't work. This patch fixes that.

I didn't find the test for these API methods, so I added a basic test for this
too.

Reviewers: aprantl, teemperor, labath, leonid.mashinskiy

Reviewed By: teemperor

Subscribers: labath, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78697
2020-04-27 11:08:19 +03:00
Raphael Isemann b58af8d254 [lldb] Improve error message when --func-regex parameter for the breakpoint command is invalid
Summary:
Currently the breakpoint command is prompting the user to file a bug report if the provided regex is invalid:
```
(lldb) rbreak *foo
error: Function name regular expression could not be compiled: "Inconvertible error value. An error has occurred that could not be converted to a known std::error_code. Please file a bug. repetition-operator operand invalid"
```

The reason is simply that we are using the wrong StringError constructor (the one with the error code as the first parameter
is also printing the string version of the error code, and the inconvertible error code is just an invalid place holder code with
that description). Switching the StringError constructor parameters will only print the error message we get from the regex
engine when we convert the error into a string.

I checked the rest of the code base and I couldn't find the same issue anywhere else.

Fixes rdar://62233561

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D78808
2020-04-27 09:55:06 +02:00
Adrian Prantl a0919ac080 Invert an #ifdef in XcodeSDKModuleTests.cpp and actually make the test work. 2020-04-24 18:39:40 -07:00
Adrian Prantl 06e4f69b22 Add a getter to retrieve the XcodeSDK from Module and unit-test it. (NFC)
This API is used by swift-lldb.

(Recommit with missing file git-added)
2020-04-24 17:00:34 -07:00
Adrian Prantl af015c1a33 Revert "Add a getter to retrieve the XcodeSDK from Module and unit-test it. (NFC)"
This reverts commit 345df863ce.

(Forgot to git-add the new file)
2020-04-24 16:59:48 -07:00
Adrian Prantl 345df863ce Add a getter to retrieve the XcodeSDK from Module and unit-test it. (NFC)
This API is used by swift-lldb.
2020-04-24 16:51:54 -07:00
Eric Christopher 6a9edce257 Fix a dangling-gsl warning and avoid transitively including string. 2020-04-24 16:03:17 -07:00
Adrian Prantl d8fb631d13 Relax testcase. The Clang module debug info may return additional
attributes such as __unsafe_unretained that is not present in DWARF.
2020-04-24 15:50:26 -07:00
Adrian Prantl b9c7e276bd Disable path-sensitive test on Windows. 2020-04-24 15:21:54 -07:00
Adrian Prantl 79feafa514 Add an internal bit to the XcodeSDK class.
For developing the OS itself there exists an "internal" variant of
each SDK. This patch adds support for these SDK directories to the
XcodeSDK class.

Differential Revision: https://reviews.llvm.org/D78675
2020-04-24 12:55:53 -07:00
Jonas Devlieghere 0d671dbca9 [lldb/Driver] Remove level of indentation (NFC)
Use an early return for when we couldn't create a pipe to source the
commands.
2020-04-24 12:50:53 -07:00
Adrian Prantl 304ba5d4c6 Delete cargo-cult code that doesn't affect the testsuite. 2020-04-24 11:54:52 -07:00
Adrian Prantl ef423a3ba5 Add Objective-C property accessors loaded from Clang module DWARF to lookup
This patch fixes a bug when synthesizing an ObjC property from
-gmodules debug info. Because the method declaration that is injected
via the non-modular property implementation is not added to the
ObjCInterfaceDecl's lookup pointer, a second copy of the accessor
would be generated when processing the ObjCPropertyDecl. This can be
avoided by finding the existing method decl in
ClangExternalASTSourceCallbacks::FindExternalVisibleDeclsByName() and
adding it to the LookupPtr.

Differential Revision: https://reviews.llvm.org/D78333
2020-04-24 11:10:50 -07:00
Jonas Devlieghere 1fcd234ac5 [lldb/Core] Don't crash in GetSoftwareBreakpointTrapOpcode for unknown triples
This patch ensures we don't crash in GetSoftwareBreakpointTrapOpcode for
not-yet-supported architectures but rather continue with degraded
behavior.

I found the issue in the context of an invalid ArchSpec, which should be
handled further up the chain. In this patch I've also added an assert to
cover that, so we can still catch those issues.

Differential revision: https://reviews.llvm.org/D78588
2020-04-24 09:10:41 -07:00
Mircea Trofin 5948dafc69 [lldb][NFC][CallSite] Remove CallSite use
Reviewers: dblaikie, craig.topper

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78791
2020-04-23 22:24:23 -07:00
shafik def7c7f602 [ASTImporter] Fix handling of not defined FromRecord in ImportContext(...)
In ImportContext(…) we may call into CompleteDecl(…) which if FromRecrord is not
defined will start the definition of a ToRecord but from what I can tell at least
one of the paths though here don't ensure we complete the definition.
For a RecordDecl this can be problematic since this means we won’t import base
classes and we won’t have any of the methods or types we inherit from these bases.

Differential Revision: https://reviews.llvm.org/D78000
2020-04-23 15:18:48 -07:00
Puyan Lotfi 9721fbf85b [NFC] Refactoring PropertyAttributeKind for ObjCPropertyDecl and ObjCDeclSpec.
This is a code clean up of the PropertyAttributeKind and
ObjCPropertyAttributeKind enums in ObjCPropertyDecl and ObjCDeclSpec that are
exactly identical. This non-functional change consolidates these enums
into one. The changes are to many files across clang (and comments in LLVM) so
that everything refers to the new consolidated enum in DeclObjCCommon.h.

2nd Landing Attempt...

Differential Revision: https://reviews.llvm.org/D77233
2020-04-23 17:21:25 -04:00
Raphael Isemann c2fec2fb17 [lldb] Make RNBSocketTest compile again after socket modernization
Commit c9e6b7010c changed the API but didn't update this
macOS-specific test.
2020-04-23 17:00:02 +02:00
Pavel Labath 9321255b88 [lldb/Core] Avoid more Communication::Disconnect races
Calling Disconnect while the read thread is running is racy because the
thread can also call Disconnect.  This is a follow-up to b424b0bf, which
reorders other occurences of Disconnect/StopReadThread I can find, and also
adds an assertion to guard against new occurences being introduced.
2020-04-23 16:36:21 +02:00
Pavel Labath 7cfa74fc69 [lldb/DWARF] Trust CU DW_AT_low/high_pc information when building address tables
Summary:
The code in DWARFCompileUnit::BuildAddressRangeTable tries hard to avoid
relying on DW_AT_low/high_pc for compile unit range information, and
this logic is a big cause of llvm/lldb divergence in the lowest layers
of dwarf parsing code.

The implicit assumption in that code is that this information (as opposed to
DW_AT_ranges) is unreliable. However, I have not been able to verify
that assumption. It is definitely not true for all present-day
compilers (gcc, clang, icc), and it was also not the case for the
historic compilers that I have been able to get a hold of (thanks Matt
Godbolt).

All compiler included in my research either produced correct
DW_AT_ranges or .debug_aranges entries, or they produced no DW_AT_hi/lo
pc at all. The detailed findings are:
- gcc >= 4.4: produces DW_AT_ranges and .debug_aranges
- 4.1 <= gcc < 4.4: no DW_AT_ranges, no DW_AT_high_pc, .debug_aranges
  present. The upper version range here is uncertain as godbolt.org does
  not have intermediate versions.
- gcc < 4.1: no versions on godbolt.org
- clang >= 3.5: produces DW_AT_ranges, and (optionally) .debug_aranges
- 3.4 <= clang < 3.5: no DW_AT_ranges, no DW_AT_high_pc, .debug_aranges
  present.
- clang <= 3.3: no DW_AT_ranges, no DW_AT_high_pc, no .debug_aranges
- icc >= 16.0.1: produces DW_AT_ranges
- icc < 16.0.1: no functional versions on godbolt.org (some are present
  but fail to compile)

Based on this analysis, I believe it is safe to start trusting
DW_AT_low/high_pc information in dwarf as well as remove the code for
manually reconstructing range information by traversing the DIE
structure, and just keep the line table fallback. The only compilers
where this will change behavior are pre-3.4 clangs, which are almost 7
years old now. However, the functionality should remain unchanged
because we will be able to reconstruct this information from the line
table, which seems to be needed for some line-tables-only scenarios
anyway (haven't researched this too much, but at least some compilers
seem to emit DW_AT_ranges even in these situations).

In addition, benchmarks showed that for these compilers computing the
ranges via line tables is noticably faster than doing so via the DIE
tree.

Other advantages include simplifying the code base, removing some
untested code (the only test changes are recent tests with overly
reduced synthetic dwarf), and increasing llvm convergence.

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78489
2020-04-23 16:12:41 +02:00
Pavel Labath f512b978b0 [lldb/Utility] Improve error_code->Status conversion
Both entities have the notion of error "namespaces". Map the errno
namespace correctly.
2020-04-23 16:12:41 +02:00
Pavel Labath c9e6b7010c [lldb/Host] Modernize some socket functions
return Expected<Socket> instead of a Status object plus a Socket*&
argument.
2020-04-23 14:20:26 +02:00
Raphael Isemann e327ea4a82 [lldb] Fix typo in breakpoint set -r description 2020-04-23 12:06:27 +02:00
Jonas Devlieghere b424b0bf73 [lldb/Target] Avoid race between Communication::Disconnect calls.
Avoid a race between the Disconnect call in `Communication::ReadThread`
and the one in `Process::ShouldBroadcastEvent` by reordering the calls
to Disconnect and StopReadThread in `Process::ShouldBroadcastEvent`.

In D77295 Pavel suggested that that might explain the broken pipe I was
seeing. Indeed, changing the order resolved the issue.
2020-04-22 16:56:42 -07:00
Muhammad Omair Javaid 478619cf9a Revert "get rid of PythonInteger::GetInteger()"
This reverts commit 7375212172.

This causes multiple test failures on LLDB AArch64 Linux buildbot.
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/3695

Differential Revision: https://reviews.llvm.org/D78462
2020-04-23 04:38:32 +05:00
Jonas Devlieghere e57361c055 [lldb/Host] Remove TaskPool and replace its uses with llvm::ThreadPool
Remove LLDB's TaskPool and replace its uses with LLVM's ThreadPool.

Differential revision: https://reviews.llvm.org/D78337
2020-04-22 09:17:49 -07:00
Christopher Tetreault 2dea3f1298 [SVE] Add new VectorType subclasses
Summary:
Introduce new types for fixed width and scalable vectors.

Does not remove getNumElements yet so as to not break code during transition
period.

Reviewers: deadalnix, efriedma, sdesmalen, craig.topper, huntergr

Reviewed By: sdesmalen

Subscribers: jholewinski, arsenm, jvesely, nhaehnle, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, liufengdb, kerbowa, Joonsoo, grosul1, frgossen, lldb-commits, tschuett, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm, #lldb

Differential Revision: https://reviews.llvm.org/D77587
2020-04-22 08:59:01 -07:00
Jan Kratochvil d482fe2add [nfc] [lldb] DWARF callbacks: DIERef -> DWARFDIE
Pavel Labath wrote in D73206:
The internal representation of DebugNames and Apple indexes is fixed by
the relevant (pseudo-)standards, so we can't really change it. The
question is how to efficiently (and cleanly) convert from the internal
representation to some common thing. The conversion from AppleIndex to
DIERef is trivial (which is not surprising as it was the first and the
overall design was optimized for that). With debug_names, the situation
gets more tricky. The internal representation of debug_names uses
CU-relative DIE offsets, but DIERef wants an absolute offset. That means
the index has to do more work to produce the common representation. And
it needs to do that for all results, even though a lot of the index
users are really interested only in a single entry. With the switch to
user_id_t, _all_ indexes would have to do some extra work to encode it,
only for their users to have to immediately decode it back. Having
a iterator/callback based api would allow us to minimize the impact of
that, as it would only need to happen for the entries that are really
used. And /I think/ we could make it interface returns DWARFDies
directly, and each index converts to that using the most direct approach
available.

Jan Kratochvil:
It also makes all the callers shorter as they no longer need to fetch
DWARFDIE from DIERef (and handling if not found by ReportInvalidDIERef)
but the callers are already served DWARFDIE which they need.
In some cases the DWARFDIE had to be fetched both by callee (DWARFIndex
implementation) and caller.

Differential Revision: https://reviews.llvm.org/D77970
2020-04-22 17:11:50 +02:00
Raphael Isemann a53874b7e4 [lldb] Fix modules build by adding missing include
This header is using FileSpec so we should at least include the forward header.
2020-04-22 09:14:09 +02:00
Lawrence D'Anna 7375212172 get rid of PythonInteger::GetInteger()
Summary:
One small step in my long running quest to improve python exception handling in
LLDB.  Replace GetInteger() which just returns an int with As<long long> and
friends, which return Expected types that can track python exceptions

Reviewers: labath, jasonmolenda, JDevlieghere, vadimcn

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78462
2020-04-21 16:55:51 -07:00
Jonas Devlieghere b707cf096d [lldb/Test] Add decorator to the right method 2020-04-21 15:05:32 -07:00
Jonas Devlieghere 1e566f6b47 [lldb/Test] Add skipIfReproducer for tests that diverge during replay
Add the skipIfReproducer decorator to the remaining tests that fail to
replay because the GDB remote packets diverge during replay. This is
*not* expected and should be fixed, but figuring out exactly what caused
the divergence has proven pretty difficult to track down.

I've marked these tests as skipped for now so we can get clean results
and detect new regressions. I have no evidence to believe that these
failures have the same root cause, so I've not assigned them a PR.
2020-04-21 14:42:14 -07:00
Jonas Devlieghere 400b6f2bc5 [lldb/Test] Add skipIfReproducer for tests that are not expected to work
Some tests are not expected to work with reproducers, for example tests
that completely circumvent the reproducers (i.e. using the side_effects
Python module) or that rely on changes to the file system.
2020-04-21 14:42:14 -07:00
Jonas Devlieghere 116c2da4b2 [lldb/Scripts] proc.returncode is set in proc.communicate
Make sure proc.returncode has been assigned before we compare it to 0.
2020-04-21 11:30:15 -07:00
Jonas Devlieghere 2de52422ac [lldb/Test] Decode stdout and stderr in case it contains Unicode.
Lit's to_string will just return the string when it's a `str` instance,
which in Python 2 can still contain UTF-8 characters.

Differential revision: https://reviews.llvm.org/D76955
2020-04-21 08:32:30 -07:00
Jonas Devlieghere e687aa8282 [lldb/Reproducers] Fix passive replay for (char*, size_t) functions.
Several SB API functions return strings using (char*, size_t) output
arguments. During capture, we serialize an empty string for the char*
because the memory can be uninitialized.

During active replay, we have custom replay redirects that ensure that
we don't override the buffer from which we're reading, but rather write
to a buffer on the heap with the given length. This is sufficient for
the active reproducer use case, where we only care about the side
effects of the API calls, not the values actually returned.

This approach does not not work for passive replay because here we
ignore all the incoming arguments, and re-execute the current function
with the arguments deserialized from the reproducer. This means that
these function will update the deserialized copy of the arguments,
rather than whatever was passed in by the SWIG wrapper.

To solve this problem, this patch extends the reproducer instrumentation
to handle this special case for passive replay. We nog ignore the
replayer in the registry and the incoming char pointer, and instead
reinvoke the current method on the deserialized class, and populate the
output argument.

Differential revision: https://reviews.llvm.org/D77759
2020-04-20 13:26:11 -07:00
Jonas Devlieghere e128d53895 [lldb/Test] Don't friend std::make_unique
This wasn't a great idea to begin with, as you can't really rely on the
implementation, but since it also doesn't work with MSVC I've just made
the ctors public.
2020-04-20 11:48:52 -07:00
Jonas Devlieghere 950a8aa165 [lldb/Reproducers] Support new replay mode: passive replay
Support passive replay as proposed in the RFC [1] on lldb-dev and
described in more detail on the lldb website [2].

This patch extends the LLDB_RECORD macros to re-invoke the current
function with arguments deserialized from the reproducer. This relies on
the function being called in the exact same order as during replay. It
uses the same mechanism to toggle the API boundary as during recording,
which guarantees that only boundary crossing calls are replayed.

Another major change is that before this patch we could ignore the
result of an API call, because we only cared about the observable
behavior. Now we need to be able to return the replayed result to the
SWIG bindings.

We reuse a lot of the recording infrastructure, which can be a little
confusing. We kept the existing naming to limit the amount of churn, but
might revisit that in a future patch.

[1] http://lists.llvm.org/pipermail/lldb-dev/2020-April/016100.html
[2] https://lldb.llvm.org/resources/reproducers.html

Differential revision: https://reviews.llvm.org/D77602
2020-04-20 09:41:40 -07:00
Jonas Devlieghere 4cfb71adba [lldb/Scripts] Add verbose and failure only mode to replay script.
Add two modes to the reproducer replay script that make debugging a
little easier. Verbose mode prints stdout and stderr, regardless of
whether replay was successful. When --failure-only is passed, output is
limited to tests that failed to replay.
2020-04-20 09:03:48 -07:00
Emre Kultursay 865996ddf6 [lldb] Remove m_last_file_sp from SourceManager
Summary:
...and replace it with m_last_file_spec instead.

When Source Cache is enabled, the value stored in m_last_file_sp is
already in the Source Cache, and caching it again in SourceManager
brings no extra benefit. All we need is to "remember" the last used
file, and FileSpec can serve the same purpose.

When Source Cache is disabled, the user explicitly requested no caching
of source files, and therefore, m_last_file_sp should NOT be used.

Bug: llvm.org/PR45310

Depends on D76805.

Reviewers: labath, jingham

Reviewed By: jingham

Subscribers: labath, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76806
2020-04-20 16:27:19 +02:00
Emre Kultursay 1f820fa4fe [lldb] Fix SourceManager::SourceFileCache insertion
Summary:
Lookup and subsequent insert was done using uninitialized
FileSpec object, which caused the cache to be a no-op.

Bug: llvm.org/PR45310

Depends on D76804.

Reviewers: labath, JDevlieghere

Reviewed By: labath

Subscribers: mgorny, jingham, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76805
2020-04-20 16:25:54 +02:00
Emre Kultursay acae69d08c [lldb] Add new LLDB setting: use-source-cache
Summary:
LLDB memory-maps large source files, and at the same time, caches
all source files in the Source Cache.

On Windows, memory-mapped source files are not writeable, causing
bad user experience in IDEs (such as errors when saving edited files).
IDEs should have the ability to disable the Source Cache at LLDB
startup, so that users can edit source files while debugging.

Bug: llvm.org/PR45310

Reviewers: labath, JDevlieghere, jingham

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D76804
2020-04-20 16:24:25 +02:00
Pavel Labath 9cd9f3f1b8 [lldb] Fix gcc warnings in TypeCategory.cpp
The cleanup in 3e3701f8a0 left these variable unused.
2020-04-20 16:12:51 +02:00
Yuri Per 6afa5c407c [lldb] Prefer executable files from sysroot over files from local filesystem
Summary:
In D49685 sysroot behaviour was partially fixed. But files from local filesystem with same path still has priority over files from sysroot.

This patch fixes it by removing fallback to local filesystem from RemoteAwarePlatform::GetModuleSpec(). It is not actually required because higher level code do such fallback itself. See, for example, resolver in Platform::GetSharedModule().

Reviewers: labath, clayborg, EugeneBi

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77529
2020-04-20 16:12:51 +02:00
Jan Kratochvil 239093f30c [lldb] [testsuite] Fix a regression of TestCppScope.py
This is a regression since:
  [lldb][NFC] Modernize lang/cpp/scope test
  acb0b99c8e
  rGacb0b99c8e4f

  File "/home/jkratoch/redhat/llvm-monorepo/lldb/test/API/lang/cpp/scope/TestCppScope.py", line 19, in test
    self.assertEqual(global_var_names, expected_var_names)
  AssertionError: Lists differ: ['C::a', 'A::a', 'B::a', '::a'... != ['A::a', 'B::a', 'C::a', '::a'...
  First differing element 0:
  C::a
  A::a
  - ['C::a', 'A::a', 'B::a', '::a']
  + ['A::a', 'B::a', 'C::a', '::a']

ManualDWARFIndex using NameToDIE does not sort alphabetically:
    // This is only for uniqueness, not lexicographical ordering, so we can
    // just compare pointers.
    return uintptr_t(lhs.GetCString()) < uintptr_t(rhs.GetCString());
2020-04-18 10:46:32 +02:00
Jan Kratochvil eef9cb1628 [lldb] [testsuite] Fix TestFixIts.py on Linux
Since D77214 there is a testsuite regression for TestFixIts.py
on Fedora 31 x86_64.
    File "/home/jkratoch/redhat/llvm-monorepo/lldb/test/API/commands/expression/fixits/TestFixIts.py", line 148, in test_with_target
      self.assertEquals(value.GetError().GetCString(), "error: No value")
  AssertionError: 'error: error: Multiple internal symbols found for \'d\'\nid = {0x00000d2a}, ran [truncated]... != 'error: No value'

That is because Fedora glibc incl. libm.so contains also ELF debug
symbols and there exists a 'd' symbol:
  (gdb) p d
  $1 = {i = {0, 1076887552}, d = 16}
  (gdb) p &d
  $2 = (const number *) 0x7ffff78e8bc0 <d>
  (gdb) info sym 0x7ffff78e8bc0
  d in section .rodata of /lib64/libm.so.6

  $ nm /lib64/libm.so.6 |grep ' d$'
  00000000000bfbc0 r d
  00000000000caa20 r d
  00000000000caa20 r d
  00000000000caa20 r d

  glibc-build$ for i in `find -name "*.o"`;do nm 2>/dev/null $i|grep ' d$' && echo $i;done
  0000000000000080 r d
  ./math/s_atan-fma4.o
  0000000000000080 r d
  ./math/s_atan-avx.o
  0000000000000080 r d
  ./math/s_atan.o
2020-04-18 08:32:12 +02:00
Adrian Prantl 681466f5e6 Allow lldb-test to combine -find with -dump-clang-ast
This patch threads an lldb::DescriptionLevel through the typesystem to
allow dumping the full Clang AST (level=verbose) of any lldb::Type in
addition to the human-readable source description (default
level=full). This type dumping interface is currently not exposed
through the SBAPI.

The application is to let lldb-test dump the clang AST of search
results. I need this to test lazy type completion of clang types in
subsequent patches.

Differential Revision: https://reviews.llvm.org/D78329
2020-04-17 11:01:20 -07:00
Erich Keane 5f0903e9be Reland Implement _ExtInt as an extended int type specifier.
I fixed the LLDB issue, so re-applying the patch.

This reverts commit a4b88c0449.
2020-04-17 10:45:48 -07:00
Jonas Devlieghere 9eaf0abebf Revert "[lldb/Utility] Provide a stringify_append overload for function pointers."
Temporarily reverts commit d10386e177
because it breaks the Windows build. MSVC complains about an ambiguous
call to an overloaded function.
2020-04-16 17:52:09 -07:00
Davide Italiano ce7790044f [DWARF] Rename a function and comment it for clarity.
Pointed out by Adrian.
2020-04-16 15:37:09 -07:00
Jonas Devlieghere d10386e177 [lldb/Utility] Provide a stringify_append overload for function pointers.
Converting a function pointer to an object pointer is illegal as nothing
requires it to be in the same address space. Add an overload for
function pointers so we don't convert do this illegal conversion, and
simply print out "function pointer".
2020-04-16 15:35:51 -07:00
Jason Molenda 7fa342bd2a Remove attach-failed-due-to-SIP checks which were not working
The SIP debugserver was calling in attach_failed_due_to_sip
haven't worked for a while; remove them.  To check this
properly we'd need debugsever to call out to codesign(1) to
inspect the entitlements, or the equivalant API,
and I'm not interested in adding that at this point.  SIP
is has been the default on macOS for a couple of releases
and it's expected behavior now.

<rdar://problem/59198052>
2020-04-16 15:22:14 -07:00
Jonas Devlieghere 9f6a308457 [lldb/Utility] Fix a bug in stringify_append for printing addresses.
The recent change in the API macros revealed that we were not printing
the pointer address for a bunch of methods, but rather the address of
the pointer. It's something I had already noticed while looking at some
reproducer traces, but hadn't made it to the top of my list yet. This
fixes the issue by providing a more specific overload.
2020-04-16 14:03:55 -07:00
Davide Italiano 1fae85a853 [DWARF] Add instructions to regenerate this test, if needed. 2020-04-16 13:31:32 -07:00
Davide Italiano 8cac6d1875 [Shell] Remove incorrectly cargo-culted UNSUPPORTED.
Let's see if this sticks on the bots.
2020-04-16 13:22:46 -07:00
Jonas Devlieghere 3a6b60fa62 [lldb/Docs] Add some more info about the test suite structure
Expand on the structure of the LLDB test suite. So far this information
has been mostly "tribal knowledge". By writing it down I hope to make it
easier to understand our test suite for anyone that's new to the
project.
2020-04-16 10:17:59 -07:00
Jonas Devlieghere a3237f861c [lldb/Reproducers] Simplify LLDB_RECORD macros
Redefine the LLDB_RECORD macros in terms of a common uber-macro to
reduce code duplication across them.

Differential revision: https://reviews.llvm.org/D78141
2020-04-16 09:55:28 -07:00
Pavel Labath d5c26f871b [lldb/unittests] Better error messages when creating sockets fails
We get failures in SocketTestUtilities on the pre-merge bots. This
might give us a clue as to what's wrong.
2020-04-16 11:59:37 +02:00
Walter Erquinigo acfee72a05 Another attempt of D77452 - da0e91fee6
[intel-pt] Improve the way the test determines whether to run

- Now I'm creating a default value for the new test parameter
- I fixed a small mistake in the skipping logic of the test

... I forgot to clear the cmake cache when testing my diff
2020-04-15 17:52:36 -07:00
Walter Erquinigo f17a85cf36 Revert "[intel-pt] Improve the way the test determines whether to run"
This reverts commit da0e91fee6.

There's a failure in
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/8584
caused by a missing python object.
2020-04-15 16:35:29 -07:00
Walter Erquinigo da0e91fee6 [intel-pt] Improve the way the test determines whether to run
Summary:
@labath raised a concern on the way I was skipping this test. I think that was
fair and I found a better way.
Now I'm skipping if the CMAKE flag LLDB_BUILD_INTEL_PT is false.
I added an enabled_plugins entry in the dotest configuration, which gets
set by lit or lldb-dotest. The only available plugin right now is
'intel-pt', but I imagine it will be useful in the future for other
kinds of plugins that get determined at configuration time. I didn't
want to add a new argument option --enable-intel-pt or something or the
sort, as it wouldn't be useful for other cases.

Reviewers: labath, clayborg

Subscribers: lldb-commits, labath

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77452
2020-04-15 16:03:31 -07:00
Jan Kratochvil 5e04b5f2fa [nfc] [lldb] Introduce DWARF callbacks (fixed-up)
As requested by @labath in https://reviews.llvm.org/D73206#1949516
providing DWARF index callbacks refactorization.

It is a re-landing of the patch with a regression fix the previous
commit had.

Differential Revision: https://reviews.llvm.org/D77327
2020-04-15 23:40:54 +02:00
Jonas Devlieghere 1349ca4359 [lldb/Docs] Split testing in running and debugging
Separate running the tests from debugging the test. This is preparatory
for a new section coming soon.
2020-04-15 13:48:58 -07:00
Jonas Devlieghere 7ce1a93efd [lldb/Scripts] Add script to replay multiple reproducers
Script to replay reproducers in parallel using the command line driver.
This is used for active replay (stage 1 as described in the RFC on
lldb-dev [1]).

[1] http://lists.llvm.org/pipermail/lldb-dev/2020-April/016100.html

Differential revision: https://reviews.llvm.org/D77608
2020-04-15 10:55:41 -07:00
Jan Kratochvil 9289f34390 Revert "[nfc] [lldb] Introduce DWARF callbacks"
This reverts commit bd47c470d1.

It broke Green Dragon, reason is unknown to me so far:
  http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/15323/consoleFull

Differential Revision: https://reviews.llvm.org/D77327
2020-04-15 15:12:59 +02:00
Pavel Labath ff18a6acea [lldb] Fix -Wparentheses in ThreadPlanStack.cpp 2020-04-15 12:47:57 +02:00
Jan Kratochvil bd47c470d1 [nfc] [lldb] Introduce DWARF callbacks
As requested by @labath in https://reviews.llvm.org/D73206#1949516
providing DWARF index callbacks refactorization.

Differential Revision: https://reviews.llvm.org/D77327
2020-04-15 10:37:38 +02:00
Raphael Isemann 3e3701f8a0 [lldb][NFC] Remove FormatterChoiceCriterion
Summary:
The formatters code has a lot of 'reason' or 'why' values that we keep or-ing FormatterChoiceCriterion
enum values into. These values are only read by a single log statement and don't have any functional
purpose. It also seems the implementation is not finished (for example, display names and type
names don't have any dedicated enum values). Also everything is of course not tested or documented.

Let's just remove all of this.

Reviewers: labath, JDevlieghere, jingham, davide, vsk

Reviewed By: labath, vsk

Subscribers: JDevlieghere

Differential Revision: https://reviews.llvm.org/D77968
2020-04-15 09:47:15 +02:00
Jason Molenda 1cd92e480c Bug where insn-based unwind plans on arm64 could be wrong
Fix a bug where UnwindAssemblyInstEmulation would confuse which
register is used to compute the Canonical Frame Address after it
had branched over a mid-function epilogue (where the CFA reg changes
from $fp to $sp in the process of epiloguing).  Reinstate the
correct CFA register after we forward the unwind rule for branch
targets.  The failure mode was that UnwindAssemblyInstEmulation
would think CFA was set in terms of $sp after one of these epilogues,
and if it sees modifications to $sp after the branch target, it would
change the CFA offset in the unwind rule -- even though the CFA is
defined in terms of $fp and the $sp changes are irrelevant to correct
calculation.

<rdar://problem/60300528>

Differential Revision: https://reviews.llvm.org/D78077
2020-04-14 16:57:25 -07:00
Adrian Prantl 81aba6cd72 Initiallize property getters as being property accessors (NFC)
This is a no-op because it is set later on unconditionally again, but
it's far less confusing this way and consistent with how the setters
are initialized.
2020-04-14 15:56:17 -07:00
Jonas Devlieghere ca99a70237 [lldb/Test] s/lldb-repo/lldb-repro/ (NFC) 2020-04-14 14:51:41 -07:00
Jonas Devlieghere cc220d4031 [lldb/Test] Use RAII for reproducer instrumentation data in unittest.
Use a RAII object to manage the lifetime of the reproducer
instrumentation data.
2020-04-14 14:46:39 -07:00
David Blaikie 208a11ab3a Reapply "llvm-dwarfdump: Report errors when failing to parse loclist/debug_loc entries""
Originally committed as 416fa7720e
Reverted (due to buildbot failure - breaking lldb) in 7a45aeacf3.

I still can't seem to build lldb locally, but Pavel Labath has kindly
provided a potential fix to preserve the old behavior in lldb by
registering a simple recoverable error handler there that prints to the
desired stream in lldb, rather than stderr.
2020-04-14 14:44:32 -07:00
Walter Erquinigo cea112f422 [lldb] Fix a typo in a test name
Summary:
Removing the Test prefix from the file name and its usages. The standard is using only Test as a suffix.
This was correctly pointed out in https://reviews.llvm.org/D77444.

Reviewers: labath, clayborg

Subscribers: mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77878
2020-04-14 12:18:58 -07:00
Isuru Fernando 664fda72ea Fix setting Python3_ROOT_DIR on Windows
Summary:
Previously the value of Python3_ROOT_DIR was set to the string
"PYTHON_HOME" instead of the value of the variable named
PYTHON_HOME. This commit fixes that as CMake expects
a path as the value of Python3_ROOT_DIR

Reviewers: #lldb, JDevlieghere, teemperor

Reviewed By: #lldb, JDevlieghere, teemperor

Subscribers: teemperor, JDevlieghere, mgorny, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D77842
2020-04-14 12:50:54 -05:00
Jonas Devlieghere ba10840eeb [lldb/Reproducers] Make static methods go through the invoke wrapper.
They don't actually have to, but it makes it easier to unify the
corresponding code and macros. NFC.
2020-04-14 10:22:04 -07:00
Jonas Devlieghere fc41013893 [lldb/Reproducers] Capture reproducers from the API test suite.
Make it possible to capture reproducers from the API test suite. Given
the symmetry between capture and replay, this patch also adds the
necessary code for replay. For now this is a NO-OP until the
corresponding reproducer instrumentation changes land.

For more info please refer to the RFC on lldb-dev:
http://lists.llvm.org/pipermail/lldb-dev/2020-April/016100.html

Differential revision: https://reviews.llvm.org/D77588
2020-04-14 09:24:23 -07:00
Jonas Devlieghere c5a3991895 [lldb/Docs] Document active and passive replay.
Document reproducer replay and its two modes.

Differential revision: https://reviews.llvm.org/D77771
2020-04-14 08:40:26 -07:00
Med Ismail Bennani f0be92ebcd [lldb/test] Fix TestLoadUnload
Summary:
[lldb/test] Fix TestLoadUnload failure introduced in e0dbd02513

It seems that `env_cmd_string` is declared and used few lines under this
self.runCmd expression. I guess this is some left-over from an older
version.

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>

Reviewers: labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D78094
2020-04-14 13:53:51 +02:00
Muhammad Omair Javaid 01cfe88a17 [LLDB] Remove xfail aarch64-linux from test_step_over_load*
test_step_over_load_with_svr4 and test_step_over_load now pass on
aarch64 linux.

Fixed by change-id: e0dbd02513

Differential Revision: https://reviews.llvm.org/D77662
2020-04-14 16:21:06 +05:00