Commit Graph

19939 Commits

Author SHA1 Message Date
Michal Gorny
89a214eaf1 [lldb] [test/lldb-vscode] Use realpath to match vscode behavior
Compare the directory paths returned by lldb-vscode against realpaths
rather than apparent paths.  This matches lldb-vscode behavior
and therefore fixes test failures when one of the parent directories
of the source tree is a symlink.

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

llvm-svn: 367291
2019-07-30 07:47:22 +00:00
Michal Gorny
71e32aca46 [lldb] [test/lldb-vscode] Use os.path.dirname() [NFC]
Replace os.path.split()[0] with os.path.dirname().  Suggested by Pavel
Labath in D65432.

llvm-svn: 367290
2019-07-30 07:47:16 +00:00
Michal Gorny
f9108f76fa [lldb] [test] Mark newly running test XFAIL on NetBSD
The test was not previously run due to decorator bug (fixed in r366903).
It is not a regression and is probably related to the other failing
test, so just disable it.

llvm-svn: 367285
2019-07-30 06:12:03 +00:00
JF Bastien
268a83e39c [NFC] avoid AlignedCharArray in lldb
As discussed in D65249, don't use AlignedCharArray or std::aligned_storage. Just use alignas(X) char Buf[Size];. This will allow me to remove AlignedCharArray entirely, and works on the current minimum version of Visual Studio.

llvm-svn: 367275
2019-07-29 23:17:08 +00:00
Haibo Huang
79d117f27e [CMake] Move project() call to main CMake file
Summary:
The main CMake file don't have a project() call. In this case, cmake will run a dummy project(Project ) at the very beginning. Even before cmake_minimum_required. And a series of compiler detections will be triggered.

This is problematic if we depends on some policy to be set. E.g. CMP0056. try_compile will fail before we have a chance to do anything.

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

llvm-svn: 367273
2019-07-29 23:09:31 +00:00
Davide Italiano
9a5fbc8163 [Symbolication] Remove some dead code. Nothing exciting.
llvm-svn: 367262
2019-07-29 21:25:51 +00:00
Davide Italiano
f80c72be20 [Symbolication] Remove a duplicate assignment.
llvm-svn: 367261
2019-07-29 21:25:45 +00:00
Davide Italiano
acc626bc57 [Symbolication] Fix unicode compatibility between 2 and 3.
Triples are always ASCII for now, but we were handed out a
unicode object.

<rdar://problem/53592772>

llvm-svn: 367260
2019-07-29 21:25:37 +00:00
Jonas Devlieghere
96b44c77f8 [Reproducers] Pass FileCollector around as a shared_ptr (NFC)
Instead of passing the FileCollector around as a reference or raw
pointer, use a shared_ptr. This change's motivation is twofold. First it
adds compatibility for the newly added `FileCollectorFileSystem`.
Secondly, it addresses a lifetime issue we only see when LLDB is used
from Xcode, where a reference to the FileCollector outlives the
reproducer instance.

llvm-svn: 367258
2019-07-29 20:54:02 +00:00
Antonio Afonso
fce596160a Test load unloading of modules with libraries-svr4
Summary:
This doubles the 3 tests running right now on linux by also executing each test with libraries-svr4 enabled.
Not sure if there's a better way to do this as I had to copy/paste all the decorators as well...

Reviewers: labath, clayborg, xiaobai

Reviewed By: labath

Subscribers: srhines, lldb-commits

Tags: #lldb

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

llvm-svn: 367247
2019-07-29 18:12:55 +00:00
Jordan Rupprecht
6a253d378b [lldb] Qualify includes of Properties[Enum].inc files. NFC
Summary:
This is a bit more explicit, and makes it possible to build LLDB without
varying the -I lines per-directory.
(The latter is useful because many build systems only allow this to be
configured per-library, and LLDB is insufficiently layered to be split into
multiple libraries on stricter build systems).

(My comment on D65185 has some more context)

Reviewers: JDevlieghere, labath, chandlerc, jdoerfert

Reviewed By: labath

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

Patch by Sam McCall!

llvm-svn: 367241
2019-07-29 17:22:10 +00:00
Jonas Devlieghere
a8ea595509 [lldb] Also include the array definition in Properties.inc
Right now our Properties.inc only generates the initializer for the
options list but not the array declaration boilerplate around it. As the
array definition is identical for all arrays, we might as well also let
the Properties.inc generate it alongside the initializers.

Unfortunately we cannot do the same for enums, as there's this magic
ePropertyExperimental, which needs to come at the end to be interpreted
correctly. Hopefully we can get rid of this in the future and do the
same for the property enums.

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

llvm-svn: 367238
2019-07-29 16:41:30 +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
Pavel Labath
c2409baa66 SymbolVendor: Make SectionAddressesChanged a passthrough
Summary:
This moves the implementation of the function into the SymbolFile class,
making it possible to excise the SymbolVendor passthrough functions in
follow-up patches.

Reviewers: clayborg, jingham, JDevlieghere

Subscribers: lldb-commits

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

llvm-svn: 367231
2019-07-29 15:53:36 +00:00
Michal Gorny
e0ab4c8ee4 [lldb] [test] Mark three new tests XFAIL on NetBSD
llvm-svn: 367228
2019-07-29 14:32:40 +00:00
Raphael Isemann
4e44c77ab3 [lldb][NFC] Split emitting and parsing in LLDBOptionDefEmitter
Splitting the different logic is cleaner and we it will be easier
to implement the enum emitting (which otherwise would have to
reimplement the Record parsing).

llvm-svn: 367207
2019-07-29 08:22:41 +00:00
Raphael Isemann
822c58704b [lldb][NFC] Remove DiagnosticManager::CopyDiagnostics
The Diagnostic class in LLDB is suppossed to be inherited from,
so just copying the diagnostics like this is wrong. The function
is also unused, so lets just get rid of it instead of creating
some cloning facility for it.

llvm-svn: 367201
2019-07-29 07:37:17 +00:00
Raphael Isemann
bd68a052f2 [lldb] Also include the array definition in CommandOptions.inc
Summary:
Right now our CommandOptions.inc only generates the initializer for the options list but
not the array declaration boilerplate around it. As the array definition is identical for all arrays,
we might as well also let the CommandOptions.inc generate it alongside the initializers.

This patch will also allow us to generate additional declarations related to that option list in
the future (e.g. a enum class representing the specific options which would make our
handling code less prone).

This patch also fixes a few option tables that didn't follow our naming style.

Reviewers: JDevlieghere

Reviewed By: JDevlieghere

Subscribers: abidh, lldb-commits

Tags: #lldb

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

llvm-svn: 367186
2019-07-28 06:24:07 +00:00
Jonas Devlieghere
fe4b12b4de [CMake] Print the correct variables
This didn't get updated after we decided to set PYTHON_MAJOR_VERSION and
PYTHON_MINOR_VERSION in find_python_libs_windows, instead of parsing the
variables ourselves.

llvm-svn: 367153
2019-07-26 20:58:10 +00:00
Jonas Devlieghere
d4044aad66 [TableGen] Fix stale include paths
This worked locally because the include files were not regenerated, but
fails when performing a clean build.

llvm-svn: 367152
2019-07-26 20:55:07 +00:00
Jonas Devlieghere
01f277e2db [TableGen] Move core properties into a separate file (NFC)
With the plugins having their own tablgen file, it makes sense to split
off the core properties as well.

llvm-svn: 367140
2019-07-26 18:14:12 +00:00
Jonas Devlieghere
463a48e416 [TableGen] Move target properties into a separate file (NFC)
With the plugins having their own tablgen file, it makes sense to split
off the target properties as well.

llvm-svn: 367139
2019-07-26 18:14:08 +00:00
Jonas Devlieghere
7070a0b02a [TableGen] Move interpreter properties into a separate file (NFC)
With the plugins having their own tablgen file, it makes sense to split
off the interpreter properties as well.

llvm-svn: 367138
2019-07-26 18:14:04 +00:00
Jim Ingham
be4a78af46 Document that LLDB_LOG macros use the format_providers.
Differential Revision: https://reviews.llvm.org/D65293

llvm-svn: 367132
2019-07-26 17:25:20 +00:00
Jonas Devlieghere
81dab368bf [CMake] Fix find_python_libs_windows
Exporting PYTHON_INCLUDE_DIR to the Python scope somehow got lost in my
last change. Add it back again. This should fix the Windows bot!

llvm-svn: 367127
2019-07-26 16:32:49 +00:00
Jonas Devlieghere
ac4a5c15fe [CMake] Print Python version on Windows
Trying to figure out what's causing the Windows bot to fail.

llvm-svn: 367125
2019-07-26 16:15:19 +00:00
Jonas Devlieghere
447ef83068 [CMake] Loosen Python version check and ignore patch version
Some versions of macOS report a different patch version for the system
provided interpreter and libraries.

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

llvm-svn: 367115
2019-07-26 14:26:33 +00:00
Raphael Isemann
623950db50 [lldb][NFC] Remove eDiagnosticOriginGo
This enum value is unused as we removed Go support.

llvm-svn: 367110
2019-07-26 14:00:13 +00:00
Pavel Labath
d67b550df5 DWARF: Improve type safety or range lists parsing
Delete the abstract GetOffset function, which is only defined for
rnglists entries. Instead fix up entries which refer to the range list
classes so that one can statically know that he is dealing with the
rnglists section and call the function that way.

llvm-svn: 367106
2019-07-26 13:15:28 +00:00
Raphael Isemann
0ab0bb91aa [lldb] Don't dynamically allocate the posix option validator.
We dynamically allocate the option validator which means we
can't mark this list of OptionDefinitions as constexpr. It's also
more complicated than necessary.

llvm-svn: 367102
2019-07-26 11:46:21 +00:00
Pavel Labath
fcdceab7e1 Fix some "control reaches end of non-void function" warnings
llvm-svn: 367095
2019-07-26 09:38:23 +00:00
Fangrui Song
20db94b7b3 ObjectFileELF: Use llvm::JamCRC to refactor CRC32 computation
Reviewed By: labath

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

llvm-svn: 367090
2019-07-26 08:33:36 +00:00
Pavel Labath
84a6856928 SymbolVendor: Move Symtab construction into the SymbolFile
Summary:
Instead of having SymbolVendor coordinate Symtab construction between
Symbol and Object files, make the SymbolVendor function a passthrough,
and put all of the logic into the SymbolFile.

Reviewers: clayborg, JDevlieghere, jingham, espindola

Subscribers: emaste, mgorny, arichardson, MaskRay, lldb-commits

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

llvm-svn: 367086
2019-07-26 07:03:28 +00:00
Jonas Devlieghere
5620e7530f [dotest] Remove dead code
Remove some dead code that I ran into when preparing D65311.

llvm-svn: 367079
2019-07-26 01:58:18 +00:00
Jonas Devlieghere
32211fda29 [Tests] Split inferior crashing tests
We noticed that TestInferiorCrashing.py and TestRecursiveInferior.py are
the second and third slowest tests in the test suite. Splitting them up
allows lit to schedule them more effectively.

llvm-svn: 367077
2019-07-26 01:00:40 +00:00
Jonas Devlieghere
a5db339cda [CMake] Add TableGen dependency to lldbInterpreter.
lldbInterpreter depends on LLDBPropertiesGen and LLDBPropertiesEnumGen.

llvm-svn: 367073
2019-07-25 22:56:59 +00:00
Jonas Devlieghere
29af3b4e67 [Docs] Remove reproducers from the project page.
Jim pointed out that this was still open on the website.

llvm-svn: 367066
2019-07-25 22:22:43 +00:00
Jonas Devlieghere
7296fac558 [Tablegen] Fix issues caused by incorrect escaping.
The printEscapedString would escape newlines by their ASCII values
instead of prefixing them with a `\`. Remove the escaping logic and
escape the strings in the definition file.

llvm-svn: 367065
2019-07-25 22:17:08 +00:00
Jim Ingham
2b6afdf710 Mention adding predicates to settings in the projects page.
llvm-svn: 367059
2019-07-25 21:37:57 +00:00
Jonas Devlieghere
971f9ca612 Let tablegen generate property definitions
Property definitions are currently defined in a PropertyDefinition array
and have a corresponding enum to index in this array. Unfortunately this
is quite error prone. Indeed, just today we found an incorrect merge
where a discrepancy between the order of the enum values and their
definition caused the test suite to fail spectacularly.

Tablegen can streamline the process of generating the property
definition table while at the same time guaranteeing that the enums stay
in sync. That's exactly what this patch does. It adds a new tablegen
file for the properties, building on top of the infrastructure that
Raphael added recently for the command options. It also introduces two
new tablegen backends: one for the property definitions and one for
their corresponding enums.

It might be worth mentioning that I generated most of the tablegen
definitions from the existing property definitions, by adding a dump
method to the struct. This seems both more efficient and less error
prone that copying everything over by hand. Only Enum properties needed
manual fixup for the EnumValues and DefaultEnumValue fields.

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

llvm-svn: 367058
2019-07-25 21:36:37 +00:00
Jim Ingham
d16a034c7c Remove a project that was completed.
llvm-svn: 367057
2019-07-25 21:29:29 +00:00
Jonas Devlieghere
2fa67f442a [dotest] Set environment variables after potentialy clearing others.
Dotest contains code to clear DYLD_LIBRARY_PATH for the inferior to not
propagate sanitized builds. However, it's possible that we want to
inject a different library path with `--inferior-env`. To make that work
correctly, we need to do that *after* clearing DYLD_LIBRARY_PATH.

llvm-svn: 367054
2019-07-25 20:54:41 +00:00
Antonio Afonso
9294c87282 [LLDB] Find debugserver in Command Line Tools as well
Summary:
This might be an edge case in regular use but if you're shipping an lldb version with no debugserver lldb will try to use the System one.
However, lldb only knows how to find the Xcode one and not the Command Line Tools one. This diff fixes that.

We try to find debugserver with `PlatformDarwin::LocateExecutable("debugserver")`, we call `xcode-select -p` to get the path and then assume this path is of Xcode.

The changes I did are:
* Change `PlatformDarwin::LocateExecutable` to also add the Command Line Tools directory to the list of paths to search for debugserver.
* Created a new function to find the Command Line Tools directory named `GetCommandLineToolsLibraryPath`.
* Refactored the code that calls `xcode-select -p` into its own function `GetXcodeSelectPath()`. There were 2 identical pieces of code for this so I reduced it to one and used this function everywhere instead.
* I also changed `PlatformDarwin::GetSDKDirectoryForModules` to use the `SDKs` directory that exists in the Command Line Tools installation.

I'm not sure how to create tests for this. PlatformDarwinTest is really limited and I couldn't find how to mock Filesystem::Instance() so I could create a virtual file system.

Reviewers: clayborg, JDevlieghere

Reviewed By: clayborg, JDevlieghere

Subscribers: jasonmolenda, lldb-commits

Tags: #lldb

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

llvm-svn: 367052
2019-07-25 20:53:00 +00:00
Michal Gorny
e1c159e86a [lldb] [Process/NetBSD] Report stopped process on SIGSTOP
Mark the process as stopped when SIGSTOP arrives.  This is necessary
for lldb-server to generate correct response to 'process interrupt',
and therefore to prevent the whole stack crashing when process
is stopped.

Thanks to Pavel Labath for the tip.

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

llvm-svn: 367047
2019-07-25 20:27:40 +00:00
Antonio Afonso
d668260f1a Correctly use GetLoadedModuleList to take advantage of libraries-svr4
Summary:
Here's a replacement for D62504. I thought I could use LoadModules to implement this but in reality I can't because there are at few issues with it:
* The LoadModules assumes that the list returned by GetLoadedModuleList is comprehensive in the sense that reflects all the mapped segments, however, this is not true, for instance VDSO entry is not there since it's loaded manually by LoadVDSO using GetMemoryRegionInfo and it doesn't represent a specific shared object in disk. Because of this LoadModules will unload the VDSO module.
* The loader (interpreter) module might have also been loaded using GetMemoryRegionInfo, this is true when we launch the process and the rendezvous structure is not yet available (done through LoadInterpreterModule()). The problem here is that this entry will point to the same file name as the one found in /proc/pid/maps, however, when we read the same module from the r_debug.link_map structure it might be under a different name. This is true at least on CentOS where the loader is a symlink. Because of this LoadModules will unload and load the module in a way where the rendezvous breakpoint is unresolved but not resolved again (because we add the new module first and remove the old one after).

The symlink issue might be fixable by first unloading the old and loading the news (but sounds super brittle), however, I'm not sure how to fix the VDSO issue.
Since I can't trust it I'm just going to use GetLoadedModuleList directly with the same logic that we use today for when we read the linked list in lldb. The only safe thing to do here is to only calculate differences between different snapshots of the svr4 packet itself. This will also cut the dependency this plugin has from LoadModules.

I separated the 2 logics into 2 different functions (remote and not remote) because I don't like mixing 2 different logics in the same function with if/else's. Two different functions makes it easier to reason with I believe. However, I did abstract away the logic that decides if we should take a snapshot or add/remove modules so both functions could reuse it.

The other difference between the two is that on the UpdateSOEntriesFromRemote I take the snapshot only once when state = Consistent because I didn't find a good reason to always update that, as we already got the list from state = Add | Remove. I probably should use the same logic on UpdateSOEntries though I don't see a reason not to since it's really using the same data, just read in different places. Any thoughts here?

It might also be worthwhile to add a test to make sure we don't unload modules that were not actually "unloaded" like the vdso. I haven't done this yet though.
This diff is also missing the option for svr4 like proposed in https://reviews.llvm.org/D62503#1564296, I'll start working on this but wanted to have this up first.

Reviewers: labath, jankratochvil, clayborg, xiaobai

Reviewed By: labath

Subscribers: srhines, JDevlieghere, lldb-commits

Tags: #lldb

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

llvm-svn: 367020
2019-07-25 14:28:21 +00:00
Raphael Isemann
ec67e73430 [lldb] Tablegenify expr/frame/log/register/memory
llvm-svn: 367009
2019-07-25 11:22:46 +00:00
Stefan Granitz
c8916258d5 [lldb][CMake] Fix framework-enabled build detail for Xcode
If debugserver or any other framework tool gets built first, its post-build copy operation was using 'Resources' as the file name instead of the destination directory. It was not a problem with Ninja, because here the framework structure was alreaady created at configuration time. With this fix, both generators are happy.

llvm-svn: 367005
2019-07-25 10:47:49 +00:00
Fangrui Song
2e959415d7 SymbolFile: Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off builds after D65089/r366791
llvm-svn: 367001
2019-07-25 09:56:45 +00:00
Pavel Labath
f46e8974de SymbolVendor: Remove the type list member
Summary:
Similarly to the compile unit lists, the list of types can also be
managed by the symbol file itself.

Since the only purpose of this list seems to be to maintain an owning
reference to all the types a symbol file has created (items are only
ever added to the list, never retrieved), I remove the passthrough
functions in SymbolVendor and Module. I also tighten the interface of
the function (return a reference instead of a pointer, make it protected
instead of public).

Reviewers: clayborg, JDevlieghere, jingham

Subscribers: lldb-commits

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

llvm-svn: 366994
2019-07-25 08:22:05 +00:00
Pavel Labath
ee74c9e5fd LLGS: fix tracking execve on linux
Summary:
Due to a logic error, lldb-server ended up asserting/crashing every time
the debugged process attempted an execve(). This fixes the error, and
extends TestExec to work on other platforms too. The "extension"
consists of avoiding non-standard posix_spawn extensions and using the
classic execve() call, which should be available on any platform that
actually supports re-execing. I change the test decorator from
@skipUnlessDarwin to @skipIfWindows.

Reviewers: clayborg, jasonmolenda

Subscribers: lldb-commits

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

llvm-svn: 366985
2019-07-25 06:38:33 +00:00