Commit Graph

18750 Commits

Author SHA1 Message Date
Pavel Labath 95e29763d4 Revert "minidump: Add ability to attach (breakpad) symbol files to placeholder modules"
This reverts r354263, because it uncovered a problem in handling of the
minidumps with conflicting UUIDs. If a minidump contains two files with
the same UUID, we will not create to placeholder modules for them, but
instead reuse the first one for the second instance. This creates a
problem because these modules have their load address hardcoded in them
(and I've added an assert to verify that).

Technically this is not a problem with this patch, as the same issue
existed in the previous implementation, but it did not have the assert
which would diagnose that. Nonetheless, I am reverting this until I
figure out what's the best course of action in this situation.

llvm-svn: 354324
2019-02-19 13:52:31 +00:00
Pavel Labath 499611a20f Fix vscode tests for python3
encode/decode the data before sending it over the socket. Since (AFAICT)
the vscode protocol (unlike the gdb-remote one) is fully textual, using
the utf8 codec here is appropriate.

llvm-svn: 354308
2019-02-19 08:25:25 +00:00
Pavel Labath eebf32fad6 [gui] Simplify SourceFileWindowDelegate::WindowDelegateDraw
instead of printf-ing into a buffer, and them using that buffer as a
format string, simply use the appropriate indirect format string.

This also fixes a -Wformat-truncation warning with gcc.

llvm-svn: 354307
2019-02-19 08:12:41 +00:00
Jonas Devlieghere cd2e6c75f6 [lldb-instr] Test that we ignore existing macros.
Although the functionality was already present, it wasn't tested.

llvm-svn: 354303
2019-02-19 01:20:49 +00:00
Jonas Devlieghere 091b925284 [lldb-instr] Wrap returns of struct/classes in LLDB_RECORD_RESULT
The instrumentation framework requires return values of custom classes
and structs to be wrapped in the LLDB_RECORD_RESULT macro.

llvm-svn: 354301
2019-02-19 01:04:31 +00:00
Jonas Devlieghere 292a533085 Disable TestModuleCXX.test on Windows
Importing cxx modules doesn't seem to work on Windows:

error: a.out :: Class 'tagARRAYDESC' has a member 'tdescElem' of type
  'tagTYPEDESC' which does not have a complete definition.
error: a.out :: Class 'tagPARAMDESCEX' has a member 'varDefaultValue' of type
  'tagVARIANT' which does not have a complete definition.
llvm-svn: 354300
2019-02-19 00:08:10 +00:00
Davide Italiano 05709acba4 [lldbtest] Fix some code to be compatible between py2 and py3.
llvm-svn: 354297
2019-02-18 23:18:14 +00:00
Jonas Devlieghere d1511a4bc7 [lldb-instr] Add constructor and move test into lit/tools
The test had an implicit constructor for the Foo struct. Also, as the
instrumentation doesn't have to be reproducer specific, I moved the
tests into the lit/tools directory.

llvm-svn: 354294
2019-02-18 22:59:52 +00:00
Jason Molenda 461c416878 One more fix while I'm looking at this - remove the
unused IsSBProcess method, and have IsFBSProcess
return false if we don't have API that we can use to
make that determination, so we'll try other API
if we can.

llvm-svn: 354289
2019-02-18 22:18:11 +00:00
Jason Molenda 870c0a648b Ah, misunderstood Jonas' feedback - fix this so we'll
do the right thing when both API are available.  We
want to try both of them if the first one fails.

llvm-svn: 354288
2019-02-18 22:13:34 +00:00
Jason Molenda 5044316d16 Clean up an unused variable warning when building this for
mac native.

llvm-svn: 354287
2019-02-18 22:10:23 +00:00
Davide Italiano 9144aa38ed [Python3] Fix TestObjCMethods.py to work with py2 and 3.
llvm-svn: 354286
2019-02-18 21:53:02 +00:00
Jonas Devlieghere 9764b65c82 [Reproducers] Make clang use lldb's VFS.
In r353906 we hooked up clang and lldb's reproducer infrastructure to
capture files used by clang. This patch adds the necessary logic to have
clang reuse the files from lldb's reproducer during replay.

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

llvm-svn: 354283
2019-02-18 20:31:18 +00:00
Pavel Labath 9d800a135a Un-XFAIL TestLinuxCore for windows
It turns out all that was needed to get this test passing was to fix the
python3 incompatibility.

llvm-svn: 354278
2019-02-18 16:05:26 +00:00
Pavel Labath 81b02590d8 Fix TestLinuxCore for python3
- dictionaries don't have iteritems()
- division returns floats

llvm-svn: 354273
2019-02-18 15:04:33 +00:00
Pavel Labath 515e7cdec0 minidump: Add ability to attach (breakpad) symbol files to placeholder modules
This re-commits r353677, which was reverted due to test failures on the
windows bot. The issue there was that ObjectFilePECOFF vended its base
address through the incorrect interface. SymbolFilePDB depended on that,
which lead to assertion failures when SymbolFilePDB was attempting to
use the placeholder object files as a base. This has been fixed in
r354258

It also fixes one small problem in the original patch. The issue was that the
Module class would attempt to overwrite the object file we created in
CreateModuleFromObjectFile if the file corresponding to the placeholder object
file happened to exist (but we have already disqualified it due to UUID
mismatch. The fix is simple -- we set the m_did_load_objfile flag to properly
record the fact that we have already created an object file for the module.

The original commit message was:

The reason this wasn't working was that ProcessMinidump was creating odd
object-file-less modules, and SymbolFileBreakpad required the module to
have an associated object file because it needed to get its base
address.

This fixes that by introducing a PlaceholderObjectFile to serve as a
dummy object file. The general idea for this is taken from D55142, but
I've reworked it a bit to avoid the need for the PlaceholderModule
class. Now that we have an object file, our modules are sufficiently
similar to regular modules that we can use the regular Module class
almost out of the box -- the only thing I needed to tweak was the
Module::CreateModuleFromObjectFile functon to set the module's FileSpec
in addition to it's architecture. This wasn't needed for ObjectFileJIT
(the other user of CreateModuleFromObjectFile), but it shouldn't hurt it
either, and the change seems like a straightforward extension of this
function.

Reviewers: clayborg, lemo, amccarth

Subscribers: lldb-commits

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

llvm-svn: 354263
2019-02-18 11:55:01 +00:00
Pavel Labath d1304bba34 PECOFF: Implement GetBaseAddress
COFF files are modelled in lldb as having one big container section
spanning the entire module image, with the actual sections being
subsections of that. In this model, the base address is simply the
address of the first byte of that section.

This also removes the hack where ObjectFilePECOFF was using the
m_file_offset field to communicate this information. Using file offset
for this purpose is completely wrong, as that is supposed to indicate
where is this ObjectFile located in the file on disk. This field is only
meaningful for fat binaries, and should normally be 0.

Both PDB plugins have been updated to use GetBaseAddress instead of
GetFileOffset.

llvm-svn: 354258
2019-02-18 11:06:57 +00:00
Pavel Labath 9d723b8296 Return better error message from GDBRemoteCommunication::ConnectLocally
llvm-svn: 354256
2019-02-18 10:36:23 +00:00
Pavel Labath 105f949149 Set cmake policy CMP0075 to NEW
Summary:
The policy is about cmake_include_files ignoring
CMAKE_REQUIRED_LIBRARIES in the OLD behavior. Llvm already sets this
policy to NEW, but that is overridden by our cmake_minimum_required
command.

This makes our cmake policy setup consistent with the llvm build files
and avoids a warning when using newer versions of cmake.

Reviewers: sgraenitz, xiaobai

Subscribers: mgorny, lldb-commits

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

llvm-svn: 354251
2019-02-18 10:09:29 +00:00
Jan Kratochvil b9d7984b2d Remove unused extern declaration as removed by D32167
llvm-svn: 354225
2019-02-17 17:12:37 +00:00
Tatyana Krasnukha b81d715cd2 Add PythonBoolean type to the PythonDataObjects
Differential Revision: https://reviews.llvm.org/D57817

llvm-svn: 354206
2019-02-16 18:39:14 +00:00
Davide Italiano 40046bc843 [testsuite] Skip this test correctly also on macOS.
llvm-svn: 354204
2019-02-16 17:16:53 +00:00
Raphael Isemann 913f07af6e Fix TestDataFormatterLibcxxListLoop.py test
Summary:
The compilation of the TestDataFormatterLibcxxListLoop.py currently fails with this error:

```
functionalities/data-formatter/data-formatter-stl/libcxx/list/loop/main.cpp:19:24: error: no member named '__value_' in 'std::__1::__list_node_base<int, void *>'
    assert(third_elem->__value_ == 3);
           ~~~~~~~~~~  ^
```

It seems the internal structure of list has changed with the 3.8 release. This patch makes the test compile with the current libc++ and with the previous libc++.

Reviewers: shafik, zturner, labath

Reviewed By: labath

Subscribers: christof, jdoerfert, lldb-commits

Tags: #lldb

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

llvm-svn: 354202
2019-02-16 12:13:30 +00:00
Richard Smith 81086e2a65 Temporarily disable test:
test/lang/cpp/class-template-parameter-pack/TestClassTemplateParameterPack.py

It fails on Mac OS; apparently a VarDecl 'void *&C' is implicitly
declared there, making the class template name C ambiguous.

llvm-svn: 354185
2019-02-16 00:13:26 +00:00
Jason Molenda 3bf883eac9 Add some unconditional logging on the failure points when attaching
to a process so we'll always get messages in the console logs.  

Also make the "is frontboard process" / "is backboard process"
determination lazy, specifically take it out of the
MachProcess::AttachForDebug codepath when we are attaching to a
process, to simplify attaching.

<rdar://problem/47982516> 
<rdar://problem/48060134> 

llvm-svn: 354181
2019-02-15 22:39:30 +00:00
Davide Italiano 1c29801615 Revert "Don't include UnixSignals.h from Host."
It broke the modules green dragon buildbot.

llvm-svn: 354177
2019-02-15 21:55:29 +00:00
Richard Smith 35b007e9a9 Fix AST generated for a class template to connect the class inside a
class template back to the template.

Previously, when the ASTImporter imported the class, it didn't know that
it was the pattern of a class template, so made the class a name lookup
result for the name of the template, resulting in ambiguity errors when
naming the template.

Due to a clang bug (fixed in r354091, reverted and soon to be
re-committed), ambiguity errors between a template and a non-template
were previously not diagnosed. Once r354091 is re-committed, this will
be covered by existing lldb tests.

llvm-svn: 354173
2019-02-15 21:48:09 +00:00
Stella Stamenova a2d9fdf5b6 [win] Resolve the module only if there isn't one already
Summary:
This commit modifies the OnLoadModule method to resolve the module
unless we already have one

Change by Hui Huang to fix the failing LLDB tests on Windows

Reviewers: labath, asmith

Subscribers: abidh, lldb-commits

Tags: #lldb

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

llvm-svn: 354172
2019-02-15 21:40:59 +00:00
Zachary Turner 63c300cfc1 Don't include UnixSignals.h from Host.
Host had a function to get the UnixSignals instance corresponding
to the current host architecture.  This means that Host had to
include a file from Target.  To break this dependency, just make
this a static function directly in UnixSignals.  We already have
the function UnixSignals::Create(ArchSpec) anyway, so we just
need to have UnixSignals::CreateForHost() which determines which
value to pass for the ArchSpec.

The goal here is to eventually break the Host->Target->Host
circular dependency.

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

llvm-svn: 354168
2019-02-15 20:43:56 +00:00
Jorge Gorbe Moya da0487f3f2 Disable stop-hook-threads.test on Linux
ExecControl/StopHook/stop-hook-threads.test is flaky on Linux (it's
consistently failing on my machine, but doesn't fail on a co-worker's).
I'm seeing the following assertion failure:

```
CommandObject.cpp:145: bool lldb_private::CommandObject::CheckRequirements(lldb_private::CommandReturnObject&): Assertion `m_exe_ctx.GetTargetPtr() == NULL' failed.
```

Interestingly, this doesn't happen when typing the same commands in
interactive mode. The cause seems to be that, in synchronous execution
mode continue waits until the process stops again, and that includes
running any stop-hooks for that later stop, so we end with a stack trace
like this (lots of frames omitted for clarity):

```
abort()
CommandObject::CheckRequirements() <-- this is again the same instance of CommandObjectProcessContinue, fails assertion because the previous continue command hasn't finished.
Target::RunStopHooks()
CommandObjectProcessContinue::DoExecute()
Target::RunStopHooks()
```

In general, it seems like using process control commands inside
stop-hooks does not have very well defined semantics. You don't even
need multiple threads to make that assertion fail, you can build

```
int main() {
  printf("1\n");  // break1
  printf("2\n");  // break2
}
```

and then on lldb

```
target stop-hook add -o continue
break set -f stop-hook-simple.cpp -p "break1"
break set -f stop-hook-simple.cpp -p "break2"
run
```

In this case it's even worse because the presence of multiple threads
makes it prone to race conditions. In some tests I ran with a simpler
version of this test case, I was hitting either the previous assertion
failure or the following issue:

1. Two threads reach a breakpoint
2. First stop-hook does a process continue
3. Threads end
4. Second stop-hook runs, complains about process not existing.

This change disables the test on Linux. It's already marked as XFAIL on
Windows, so maybe we should just delete it until it's clear what should
be the expected behavior in these cases. Or maybe try to come up with a
way to write a similar multithreaded test without calling continue from
a stop hook, I don't know.

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

llvm-svn: 354149
2019-02-15 17:54:00 +00:00
Stefan Granitz 42a9da7b35 Fix potential UB when target_file directory is null
Summary: As seen in a crash report, the C-string returned for the directory component of `target_file` can null. It should not be assigned to `std::string` directly as this is undefined behavior.

Reviewers: jingham

Reviewed By: jingham

Subscribers: jdoerfert, lldb-commits, #lldb

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

llvm-svn: 354145
2019-02-15 16:42:29 +00:00
Pavel Labath 4f85014dff Remove alignment from struct XSAVE altogether
I reduced the alignment of this struct in r342029 to avoid compiler
warnings about under-aligned allocations, but it turns out that this
still causes problems with some compilers (see r353778). As I hinted in
r342029, I don't believe any special aligment is necessary here (the
only reason for that would be if we used some aligned SSE instructions to
access this buffer, but I don't see any reason why we should do that),
so here I go all the way, and remove the alignment requirements (except
the ones naturally imposed by basic types) altogether.

llvm-svn: 354125
2019-02-15 12:20:23 +00:00
Michal Gorny 53eabaab3f [lldb] [MainLoop] Add kevent() EINTR handling
Add missing EINTR handling for kevent() calls.  If the call is
interrupted, return from Poll() as if zero events were returned and let
the polling resume on next iteration.  This fixes test flakiness
on NetBSD.

Includes a test case suggested by Pavel Labath on D42206.

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

llvm-svn: 354122
2019-02-15 12:13:02 +00:00
Pavel Labath 5f54fe2332 Fix the gdb-client test suite for python3
This applies the same fix that was done in r354106 to the lldb-server
test: bitcasting the string to a bytes object before sending it over a
socket. Since the gdb-remote protocol occasionally contains binary data,
and it does not assign any particular encoding to them, this is the
right thing to do here.

llvm-svn: 354114
2019-02-15 10:47:34 +00:00
Pavel Labath 0ed2d16063 Sort files in source/Host/CMakeLists.txt
llvm-svn: 354112
2019-02-15 10:06:21 +00:00
Pavel Labath 0af864b4b2 Fix lldb-server test suite for python3
Summary:
This patch finishes the python3-ification of the lldb-server test suite.
It reverts the partial attempt in r352709 to encode/decode the string
via utf8 before writing to the socket. This wasn't enough because the
gdb-remote protocol can sometimes (but not very often) carry binary
data, and the utf8 codec chokes on that. Instead I add utility functions
to the "seven" module for performing "identity" transformations on the
byte data. This basically drills back the hole in the python type system
that the string/bytes distinction was supposed to plug. That is not
ideal, but was the best solution of the alternatives I could come up
with. The options I considered were:
- make use of the type system to add type safety to the test suite: This
  required making a lot of changes to the test suite, since most of the
  strings would now become byte objects instead, and it was not even
  fully clear to me where to draw the line. One extreme solution would
  be to just use byte objects everywhere, as the protocol doesn't
  support non-ascii characters anyway. However, this appeared to be:
  a) weird, because most of the protocol actually deals with strings,
     but we would have to prefix everything with 'b'
  b) clunky, because the handling of the bytes objects is sufficiently
     different in PY2 and PY3 (e.g. b'a'[0] is a string in PY2, but an
     int in PY3).
- using the latin1 codec (which gives an identity transformation for the
  first 256 code points of unicode) instead of the custom
  bytes_to_string functions. This almost could work, but it was still
  slightly different between python 2 and 3, because in PY2 in would
  return a unicode object, which would then cause problems when
  combined with regular strings if it contained 8-bit chars.

With this in mind, I think the best solution for the time being is to
just coerce everything into the string type as early as possible, and
have things proceed indentically on both python versions. Once we stop
supporting python3, we can revisit the idea of using bytes objects more
prevasively.

Reviewers: davide, zturner, serge-sans-paille

Subscribers: lldb-commits

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

llvm-svn: 354106
2019-02-15 07:47:06 +00:00
Pavel Labath b302bd2324 Use sys.executable in lldb-dotest
Without that, dotest.py would be executed with the default python
interpreter, which may not be the same one that lldb is built with.

This still requires the user do know which python interpreter to use
when running lldb-dotest, but now he is at least able to choose it, if
he knows which one to use.

llvm-svn: 354105
2019-02-15 07:41:17 +00:00
Pavel Labath 8d6b60c14c Embed swig version into lldb.py in a different way
Summary:
Instead of doing string chopping on the resulting python file, get swig
to output the version for us. The two things which make slightly
non-trivial are:
- in order to get swig to expand SWIG_VERSION for us, we cannot use
  %pythoncode directly, but we have to go through an intermediate macro.
- SWIG_VERSION is a hex number, but it's components are supposed to be
  interpreted decimally, so there is a bit of integer magic needed to
  get the right number to come out.

I've tested that this approach works both with the latest (3.0.12) and
oldest (1.3.40) supported swig.

Reviewers: zturner, jingham, serge-sans-paille

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 354104
2019-02-15 07:41:12 +00:00
Pavel Labath 8c02e778ff Remove redundant semicolon after namespace-closing '}'
llvm-svn: 354103
2019-02-15 07:33:37 +00:00
Aaron Smith 96b821071f Fix for build bot problem from last change
llvm-svn: 354100
2019-02-15 06:13:59 +00:00
Aaron Smith eb6671e7c8 Implement GetLoadAddress for the Windows process plugin
Summary:
When a process is loaded, update its sections with the load address to resolve any created breakpoints. For the remote debugging case, the debugged process is launched remotely so GetLoadAddress is intended to pass the load address from remote to LLDB (client).


Reviewers: zturner, llvm-commits, clayborg, labath

Reviewed By: labath

Subscribers: mgorny, sas, Hui, clayborg, labath, lldb-commits

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

llvm-svn: 354099
2019-02-15 04:32:50 +00:00
Michal Gorny 257fcd9b17 [lldb] [MainLoop] Remove redundant termination clause (NFCI)
Remove the redundant termination clause from within the loop.  Since
the check is done at the end of the loop, it's entirely redundant
to the 'while' condition.  If termination was requested, the latter
will become false and the 'while' loop will terminate, resulting
in the 'return' statement below the loop being executed (which is
equivalent to the one used inside 'if').

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

llvm-svn: 354050
2019-02-14 18:51:21 +00:00
Adrian Prantl 8400eb3279 Add explicit language specifier to test.
llvm-svn: 354048
2019-02-14 18:49:14 +00:00
Frederic Riss b3a4649a6a [dotest] Fix compiler version number comparison
dotest's version comparision function is just a lexicographical compare
of the version strings. This is obviously wrong. This patch implements
the comparison using distutils.version.LooseVersion as suggested by
Zachary.

Reviewers: zturner, labath, serge-sans-paille

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 354047
2019-02-14 18:48:05 +00:00
Jonas Devlieghere ff04b3d4d7 [ExpressionParser] Reuse the FileManager from the compiler instance.
I was looking at the ClangExpressionParser and noticed that we have a
FileManager owned by the expression parser and later ask the compiler
instance to create a new FileManager, owned by the clang CI. Looking at
the code I don't see a good reason for having two instances. This patch
removes the one owned by LLDB.

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

llvm-svn: 354041
2019-02-14 18:05:43 +00:00
Raphael Isemann a2a6acf3f0 Don't source local .lldbinit in the test suite
Summary:
As suggested by Pavel, we shouldn't let our tests parse the local .lldbinit to prevent random test failures
due to changed settings.

Fixes Minidump/Windows/Sigsegv/sigsegv.test (and probably others too).

Reviewers: labath, serge-sans-paille

Reviewed By: labath

Subscribers: abidh, lldb-commits, zturner

Tags: #lldb

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

llvm-svn: 354038
2019-02-14 17:39:19 +00:00
Stefan Granitz db85fdd115 [CMake] Fix RPATH handling for LLDB.framework
Summary:
Generator expressions are not supported in the `BUILD_RPATH` target property.
`BUILD_RPATH` is only supported in 3.8+ https://cliutils.gitlab.io/modern-cmake/chapters/intro/newcmake.html
`LLDB_FRAMEWORK_INSTALL_DIR` should not overwrite, but rather add an install RPATH (and it should be the first)

Reviewers: xiaobai, lanza

Reviewed By: xiaobai

Subscribers: mgorny

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

llvm-svn: 354037
2019-02-14 17:34:39 +00:00
Pavel Labath 66d88326ab Move UnwindTable from ObjectFile to Module
Summary:
This is a preparatory step to enable adding extra unwind strategies by
symbol file plugins. This has been discussed on the lldb-dev mailing
list: <http://lists.llvm.org/pipermail/lldb-dev/2019-February/014703.html>.

Reviewers: jasonmolenda, clayborg, espindola

Subscribers: lemo, emaste, lldb-commits, arichardson

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

llvm-svn: 354033
2019-02-14 14:40:10 +00:00
Michal Gorny 2d874e5356 [lldb] [lldb-server] Catch and report errors from main loop
Catch the possible error from lldb-gdbserver's main loop, and report
it verbosely.  Currently, if the loop fails the server exits normally,
rendering the problem indistinguishable from regular termination.

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

llvm-svn: 354030
2019-02-14 13:52:37 +00:00
Michal Gorny c23f82c026 [lldb] [MainLoop] Report errno for failed kevent()
Modify the kevent() error reporting to use errno rather than returning
the return value.  At least on FreeBSD and NetBSD, kevent() always
returns -1 in case of error, and the actual error is returned via errno.

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

llvm-svn: 354029
2019-02-14 13:52:31 +00:00