Commit Graph

19114 Commits

Author SHA1 Message Date
Pavel Labath dfaafbcf4c Breakpad: Refine record classification code
Previously we would classify all STACK records into a single bucket.
This is not really helpful, because there are three distinct types of
records beginning with the token "STACK" (STACK CFI INIT, STACK CFI,
STACK WIN). To be consistent with how we're treating other records, we
should classify these as three different record types.

It also implements the logic to put "STACK CFI INIT" and "STACK CFI"
records into the same "section" of the breakpad file, as they are meant
to be read together (similar to how FUNC and LINE records are treated).

The code which performs actual parsing of these records will come in a
separate patch.

llvm-svn: 357691
2019-04-04 13:23:25 +00:00
Pavel Labath e090389c4a modify-python-lldb.py: (Re)move __len__ and __iter__ support
Summary:
This patch moves the modify-python-lldb code for adding new functions to
the SBModule class into the SBModule interface file. As this is the last
class using this functionality, I also remove all support for this kind
of modifications from modify-python-lldb.py.

Reviewers: amccarth, clayborg, jingham

Subscribers: zturner, lldb-commits

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

llvm-svn: 357680
2019-04-04 10:13:59 +00:00
Jan Kratochvil d0157b3b07 Add dropped ManualDWARFIndex assert()
D47253 dropped this assertion.

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

llvm-svn: 357678
2019-04-04 09:24:02 +00:00
Reid Kleckner e10d00419a [codeview] Remove Type member from CVRecord
Summary:
Now CVType and CVSymbol are effectively type-safe wrappers around
ArrayRef<uint8_t>. Make the kind() accessor load it from the
RecordPrefix, which is the same for types and symbols.

Reviewers: zturner, aganea

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 357658
2019-04-04 00:28:48 +00:00
Stella Stamenova e51c12430f Un-xfail one of the TestMiniDumpUUID tests on Windows
The test is passing on Windows and the windows bot is failing because of the unexpected pass

llvm-svn: 357641
2019-04-03 21:57:41 +00:00
Jonas Devlieghere 306809f292 [Reproducers] Capture return values of functions returning by ptr/ref
For some reason I had convinced myself that functions returning by
pointer or reference do not require recording their result. However,
after further considering I don't see how that could work, at least not
with the current implementation. Interestingly enough, the reproducer
instrumentation already (mostly) accounts for this, though the
lldb-instr tool did not.

This patch adds the missing macros and updates the lldb-instr tool.

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

llvm-svn: 357639
2019-04-03 21:31:22 +00:00
Jorge Gorbe Moya 060bf99f49 Re-enable most lldb-vscode tests on Linux.
Summary:
After https://reviews.llvm.org/D59828 and https://reviews.llvm.org/D59849,
I believe the problems with these tests hanging have been solved.

I tried enabling all of them on my machine, and got two failures:

- One of them was spawning a child process that lives for 5 seconds, waited
  for 5 seconds to attach to the child, and failed because the child wasn't
  there.

- The other one was a legit failure because shell expansion of arguments doesn't
  work on Linux.

This tests enables all lldb-vscode tests on Linux except for "launch process
with shell expansion of args" (which doesn't work), and fixes the other broken
test by reducing the time it waits before attaching to its child process.

Reviewers: zturner, clayborg

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 357633
2019-04-03 20:43:20 +00:00
Adrian McCarthy ffa857c7a6 Fix and simplify PrepareCommandsForSourcing
Spotted some problems in the Driver's PrepareCommandsForSourcing while
helping a colleague track another problem.

1. One error case was not handled because there was no else clause.
Fixed by switching to llvm's early-out style instead of nested
`if (succes) { } else { }` cases.  This keeps error handling close
to the actual error.

2. One call-site failed to call the clean-up function.  I solved this
by simplifying the API.  PrepareCommandsForSourcing no longer requires
the caller to provide a buffer for the pipe's file descriptors and to
call a separate clean-up function later.  PrepareCommandsForSourcing
now ensures the file descriptors are handled before returning.
(The read end of the pipe is held open by the returned FILE * as
before.)

I also eliminated an unnecessary local, shorted the lifetime of another,
and tried to improve the comments.

I wrapped the call to open the pipe to get the `#ifdef`s out of the
mainline.  I replaced the `close`/`_close` calls with a platform-neutral
helper from `llvm::sys` for the same reason.  Per discussion on the
review, I'm leaving the `fdopen` call to use the spelling that Windows
has officially deprecated because it still works it avoids more `#ifdef`s.

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

llvm-svn: 357626
2019-04-03 19:49:14 +00:00
Greg Clayton bbc428e93a Attempt #2 to get this patch working. I will watch the build bots carefully today.
Allow partial UUID matching in Minidump core file plug-in

Breakpad had bugs in earlier versions where it would take a 20 byte ELF build ID and put it into the minidump file as a 16 byte PDB70 UUID with an age of zero. This would make it impossible to do postmortem debugging with one of these older minidump files.

This fix allows partial matching of UUIDs. To do this we first try and match with the full UUID value, and then fall back to removing the original directory path from the module specification and we remove the UUID requirement, and then manually do the matching ourselves. This allows scripts to find symbols files using a symbol server, place them all in a directory, use the "setting set target.exec-search-paths" setting to specify the directory, and then load the core file. The Target::GetSharedModule() can then find the correct file without doing any other matching and load it.

Tests were added to cover a partial UUID match where the breakpad file has a 16 byte UUID and the actual file on disk has a 20 byte UUID, both where the first 16 bytes match, and don't match.

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

llvm-svn: 357603
2019-04-03 16:30:44 +00:00
George Rimar ed3eaf477c [LLDB] - Update the test cases after yaml2obj change.
https://reviews.llvm.org/D60122 (r357595) changed the
symbols description format in yaml2obj.

This change updates the LLDB tests.

llvm-svn: 357600
2019-04-03 15:28:35 +00:00
Pavel Labath 4da5a1dbab modify-python-lldb.py: clean up __iter__ and __len__ support
Summary:
Instead of modifying the swig-generated code, just add the appropriate
methods to the interface files in order to get the swig to do the
generation for us.

This is a straight-forward move from the python script to the interface
files. The single class which has nontrivial handling in the script
(SBModule) has been left for a separate patch.

For the cases where I did not find any tests exercising the
iteration/length methods (i.e., no tests failed after I stopped emitting
them), I tried to add basic tests for that functionality.

Reviewers: zturner, jingham, amccarth

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 357572
2019-04-03 11:48:38 +00:00
Jonas Devlieghere cad96c498c [lit] Use 10 minute timeout by default.
Lit has the ability to set a timeout for individual tests. This patch
enables that functionality with a default of 10 minutes.

Currently we rely on the bots to kill the whole test suite. However this
doesn't tell us which test caused the timeout. Furthermore, when running
the test suite during development, I have to manually kill the tests
that time out to get the lit output at then end. This fixes both
inconveniences.

llvm-svn: 357555
2019-04-03 01:26:41 +00:00
Jonas Devlieghere 6ed7a95c9e [lldb-dotest] Print dotest.py invocation.
In order to debug a failing python test, you need to debug Python
instead of the wrapper. For a while I've been adding and removing this,
but I think it could be useful for everyone.

llvm-svn: 357554
2019-04-03 01:26:38 +00:00
Jason Molenda aa107ca3a5 Avoid macro redefinition error if HAVE_LIBCOMPRESSION
is already defined.

llvm-svn: 357553
2019-04-03 01:16:54 +00:00
Adrian Prantl 1b5310c2df Revert r357504, r357491, r357482 because of bot breakage.
See discussion in https://reviews.llvm.org/D60001.

Revert Clean up windows build bot.
This reverts r357504 (git commit 380c2420ec)
Revert Fix buildbot where paths were not matching up.
This reverts r357491 (git commit 5050586860)
Revert Allow partial UUID matching in Minidump core file plug-in
This reverts r357482 (git commit 838bba9c34)

llvm-svn: 357534
2019-04-02 22:03:22 +00:00
Zachary Turner a31347f17d [NativePDB] Don't fail on import modules.
A recent patch to LLD started emitting information about import modules.
These are represented as compile units in the PDB, but with no
additional debug info.  This was confusing the native pdb reader, who
expected that the debug info stream be present.

This should fix failing tests on the Windows bots.

llvm-svn: 357513
2019-04-02 19:39:45 +00:00
Jonas Devlieghere 1c5250abaa [Reproducers] Print warning when generating the reproducer.
Encourage users to look at the directory so they know what data they'd
be sharing by uploading the reproducer.

llvm-svn: 357507
2019-04-02 18:23:16 +00:00
Greg Clayton 380c2420ec Clean up windows build bot.
llvm-svn: 357504
2019-04-02 17:50:08 +00:00
Aaron Smith 41a7950cfb [lldb-server] Use llgs namespace to avoid conflicts with Win32 API
llvm-svn: 357496
2019-04-02 17:10:12 +00:00
Aaron Smith b622809b2d Fix typo; NFC
llvm-svn: 357495
2019-04-02 17:02:21 +00:00
Greg Clayton 5050586860 Fix buildbot where paths were not matching up.
llvm-svn: 357491
2019-04-02 16:36:34 +00:00
Greg Clayton 838bba9c34 Allow partial UUID matching in Minidump core file plug-in
Breakpad had bugs in earlier versions where it would take a 20 byte ELF build ID and put it into the minidump file as a 16 byte PDB70 UUID with an age of zero. This would make it impossible to do postmortem debugging with one of these older minidump files.

This fix allows partial matching of UUIDs. To do this we first try and match with the full UUID value, and then fall back to removing the original directory path from the module specification and we remove the UUID requirement, and then manually do the matching ourselves. This allows scripts to find symbols files using a symbol server, place them all in a directory, use the "setting set target.exec-search-paths" setting to specify the directory, and then load the core file. The Target::GetSharedModule() can then find the correct file without doing any other matching and load it.

Tests were added to cover a partial UUID match where the breakpad file has a 16 byte UUID and the actual file on disk has a 20 byte UUID, both where the first 16 bytes match, and don't match.

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

llvm-svn: 357482
2019-04-02 15:40:54 +00:00
Pavel Labath 4bc0500635 Make operator==s consistent between c++ and python APIs
Summary:
modify-python-lldb.py had code to insert python equality operators to
some classes. Some of those classes already had c++ equality operators,
and some didn't.

This makes the situation more consistent, by removing all equality
handilng from modify-python-lldb. Instead, I add c++ operators to
classes where they were missing, and expose them in the swig interface
files so that they are available to python too.

The only tricky case was the SBAddress class, which had an operator==
defined as a free function, which is not handled by swig. This function
cannot be removed without breaking ABI, and we cannot add an extra
operator== member, as that would make equality comparisons ambiguous.
For this class, I define a python __eq__ function by hand and have it
delegate to the operator!=, which I have defined as a member function.

This isn't fully NFC, as the semantics of some equality functions in
python changes slightly, but I believe it changes for the better (e.g.,
previously SBBreakpoint.__eq__ would consider two breakpoints with the
same ID as equal, even if they belonged to different targets; now they
are only equal if they belong to the same target).

Reviewers: jingham, clayborg, zturner

Subscribers: jdoerfert, JDevlieghere, lldb-commits

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

llvm-svn: 357463
2019-04-02 10:18:46 +00:00
Pavel Labath c5cefa2caf Fix flakyness in TestCommandScriptImmediateOutput
I'm not sure why this surfaced at this particular point, but
TestCommandScriptImmediateOutput (a pexpect test) had a synchronization
issue, where the (lldb) promts it was expecting were getting out of
sync. This happened for two reasons:
- it did not expect the initial (lldb) prompt we print at startup
- launchArgs() returned None, which resulted in an extra "target create
  None" command being issued to lldb (and an extra unhandled prompt
  being printed).

Resolving these two issues seems to fix (or at least, improve) the test.

llvm-svn: 357459
2019-04-02 09:45:40 +00:00
Pavel Labath 821263faa5 Fix llvm_unreachable in TestWriteMemory
The test was hitting llvm_unreachable in
Platform::GetSoftwareBreakpointTrapOpcode because it could not figure
out the architecture of the process. Since that is not the purpose of
the test, I change the test to use an explicit
CreateTargetWithFileAndTargetTriple command to specify it.

llvm-svn: 357456
2019-04-02 08:56:22 +00:00
Pavel Labath 1c4ee16012 PDBFPO: Refactor register reference resolution
Summary:
This refactors moves the register name->number resolution out of the
FPOProgramNodeRegisterRef class. Instead I create a special
FPOProgramNodeSymbol class, which holds unresolved symbols, and move the
resolution into the ResolveRegisterRefs visitor.

The background here is that I'd like to use this code for Breakpad
unwind info, which uses similar syntax to describe unwind info. For
example, a simple breakpad unwind program might look like:
    .cfa: $esp 8 + $ebp: .cfa 8 - ^

To be able to do this, I need to be able to customize register
resolving, as that is presently hardcoded to use codeview register
names, but breakpad supports a lot more architectures with different
register names. Moving the resolution into a separate class will allow
each user to use a different resolution logic.

Reviewers: aleksandr.urakov, zturner, amccarth

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 357455
2019-04-02 08:44:24 +00:00
Pavel Labath 155bc16e7f Simplify TestGdbRemoteRegisterState
While reviewing D56233 it became clear to me that this test can be
simplified. There's no need for a start-stop cycle in the inferior -- we
can start fiddling with its registers as soon as it is launched.

llvm-svn: 357451
2019-04-02 07:47:38 +00:00
Jonas Devlieghere dd245c4f8f [CMake] Only the Python scirpt interpreter should link against Python.
This patch removes spurious links against Python.

llvm-svn: 357431
2019-04-01 22:03:04 +00:00
Jonas Devlieghere 533fe617ac [Process] Use early returns in Process::WriteMemory (NFC)
I found the code of Process::WriteMemory particularly hard to follow
when reviewing Ismail's change in D60022. This simplifies the code and
hopefully prevents similar oversights in the future.

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

llvm-svn: 357428
2019-04-01 20:39:03 +00:00
Jorge Gorbe Moya 4665aca8ca [lldb-vscode] Add logic to handle EOF when reading from lldb-vscode stdout.
Summary:
This change prevents the lldb-vscode test harness from hanging up waiting for
new messages when the lldb-vscode subprocess crashes.

Now, when an EOF from the subprocess pipe is detected we enqueue a `None` packet
in the received packets list. Then, during the message processing loop, we can
use this `None` packet to tell apart the case where lldb-vscode has terminated
unexpectedly from the normal situation where no pending messages means blocking
and waiting for more data.

I believe this should be enough to fix the issues with these tests hanging on
multiple platforms. Once this lands, I'll prepare and test a separate change
removing the @skipIfLinux annotations.

Reviewers: clayborg, zturner

Subscribers: lldb-commits

Tags: #lldb

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

llvm-svn: 357426
2019-04-01 20:37:22 +00:00
Jonas Devlieghere c791a20b42 [API] Add SBReproducer to LLDB.h
llvm-svn: 357424
2019-04-01 19:56:15 +00:00
Med Ismail Bennani 62bcf73683 [Process] Fix WriteMemory return value
Summary:
In case of a breakpoint site overlapping with the destination address,
the WriteMemory method reported an incorrect memory size.

Instead of returning the right amount of bytes written, it falls through
the scope and returned 0.

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

Reviewers: jasonmolenda, friss, jingham

Subscribers: JDevlieghere, davide, lldb-commits, #lldb

Tags: #lldb

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

llvm-svn: 357420
2019-04-01 19:08:47 +00:00
Michal Gorny d8519f4a7d [lldb] [Process/elf-core] Support aarch64 NetBSD core dumps
Include support for NetBSD core dumps from evbarm/aarch64 system,
and matching test cases for them.

Based on earlier work by Kamil Rytarowski.

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

llvm-svn: 357399
2019-04-01 15:08:24 +00:00
Pavel Labath 38a8241321 [Linux/x86] Fix writing of non-gpr registers on newer processors
Summary:
We're using ptrace(PTRACE_SETREGSET, NT_X86_XSTATE) to write all non-gpt
registers on x86 linux. Unfortunately, this method has a quirk, where
the kernel rejects all attempts to write to this area if one supplies a
buffer which is smaller than the area size (even though the kernel will
happily accept partial reads from it).

This means that if the CPU supports some new registers/extensions that
we don't know about (in my case it was the PKRU extension), we will fail
to write *any* non-gpr registers, even those that we know about.

Since this is a situation that's likely to appear again and again, I add
code to NativeRegisterContextLinux_x86_64 to detect the runtime size of
the area, and allocate an appropriate buffer. This does not mean that we
will start automatically supporting all new extensions, but it does mean
that the new extensions will not prevent the old ones from working.

This fixes tests attempting to write to non-gpr registers on new intel
processors (cca Kaby Lake Refresh).

Reviewers: jankratochvil, davezarzycki

Subscribers: lldb-commits

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

llvm-svn: 357376
2019-04-01 08:11:46 +00:00
David Zarzycki 916709e0be [CMake] Add missing test dep
lit/SymbolFile/NativePDB/globals-bss.cpp needs llvm-readobj

llvm-svn: 357336
2019-03-30 00:00:19 +00:00
Jonas Devlieghere 6f8251fb38 [ScriptInterpreterPython] Fix the unit test after refactor
llvm-svn: 357313
2019-03-29 20:56:52 +00:00
Jonas Devlieghere 63dd5d2518 [Python] Remove Python include from ScriptInterpreterPython.h
This patch limits the scope of the python header to the implementation
of the python script interpreter plugin. ScriptInterpreterPython is now
an abstract interface that doesn't expose any Python specific types, and
is implemented by the ScriptInterpreterPythonImpl.

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

llvm-svn: 357307
2019-03-29 20:17:20 +00:00
Jonas Devlieghere 05f1dd9362 [ScriptInterpreterPython] Remove unused field (NFC)
The m_lldb_module was initialized but not used.

llvm-svn: 357292
2019-03-29 17:58:07 +00:00
Jonas Devlieghere 4d63d8cf75 [CMake] Move link dependencies where they are used.
The utility library shouldn't depend on curses, libedit or python. Move
curses to core, libedit to host and python to the python plugin.

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

llvm-svn: 357287
2019-03-29 17:47:26 +00:00
Jonas Devlieghere ae1cc995e3 [Cmake] Unify python variables
FindPythonInterp and FindPythonLibs do two things, they set some
variables (PYTHON_LIBRARIES, PYTHON_INCLUDE_DIRS) and update the cached
variables (PYTHON_LIBRARY, PYTHON_INCLUDE_DIR) which are also used to
specify a custom python installation.

I believe the canonical way to do this is to use the PYTHON_LIBRARIES
and PYTHON_INCLUDE_DIRS variables instead of the cached ones. However,
since the cached variables are accessible from the cache and GUI, this
is a lot less confusing when you're trying to debug why a variable did
or didn't get the value you expected. Furthermore, as far as I can tell,
the implementation uses the cached variables to set their LIBRARIES/DIRS
counterparts. This is also the reason this works today even though we
mix-and-match.

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

llvm-svn: 357282
2019-03-29 17:35:42 +00:00
Jonas Devlieghere 903a9c74f0 [Python] Remove readline module
Todd added this empty readline module to workaround an issue with an old
version of Python on Ubuntu in 2014 (18841). In the meantime, libedit
seems to have fixed the underlying issue, and indeed, I wasn't able to
reproduce this.

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

llvm-svn: 357277
2019-03-29 17:12:08 +00:00
Jim Ingham cdd4892f12 Use the multi-lockable form of std::lock for operator=
For = operators for lists that have mutexes, we were either
just taking the locks sequentially or hand-rolling a trick
to try to avoid lock inversion.  Use the std::lock mechanism
for this instead.

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

llvm-svn: 357276
2019-03-29 17:07:30 +00:00
Adrian Prantl 515d1306ff Don't abort() in lldb_assert and document why.
rdar://problem/49356014

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

llvm-svn: 357268
2019-03-29 16:12:27 +00:00
Shafik Yaghmour a1f1ff8896 Fix for regression test, since we rely on the formatter for std::vector in the test we need a libc++ category.
See differential https://reviews.llvm.org/D59847 for initial change that this fixes

llvm-svn: 357210
2019-03-28 20:25:57 +00:00
Jim Ingham 43aaafc0e1 Fix the swig typemap for "uint32_t *versions, uint32_t num_versions".
It was making a list of a certain size but not always filling in that
many elements, which would lead to a crash iterating over the list.

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

llvm-svn: 357207
2019-03-28 19:25:54 +00:00
Jonas Devlieghere c712bac78b [NFC] find_first_of/find_last_of -> find/rfind for single char.
For a single char argument, find_first_of is equal to find and
find_last_of is equal to rfind. While playing around with the plugin
stuff this caused an export failure because it always got inlined except
once, which resulted in an undefined symbol.

llvm-svn: 357198
2019-03-28 18:10:14 +00:00
Shafik Yaghmour 0f71a25e98 Regression test to ensure that we handling importing of std::vector of enums correctly
Summary:
https://reviews.llvm.org/D59845 added a fix for the IsStructuralMatch(...) specialization for EnumDecl this test should pass once this fix is committed.

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

llvm-svn: 357188
2019-03-28 17:22:13 +00:00
Jim Ingham 1432b9780b Copy the breakpoint site owner's collection so we can drop
the collection lock before we iterate over the owners calling ShouldStop.

BreakpointSite::ShouldStop can do a lot of work, and might by chance hit the same breakpoint
site again on another thread.  So instead of holding the site's owners lock
while iterating over them calling ShouldStop, I make a local copy of the list, drop the lock 
and then iterate over the copy calling BreakpointLocation::ShouldStop.

It's actually quite difficult to make this cause problems because usually all the
action happens on the private state thread, and the lock is recursive.

I have a report where some code hit the ASAN error breakpoint, went to 
compile the ASAN error gathering expression, in the course of compiling
that we went to fetch the ObjC runtime data, but the state of the program
was such that the ObjC runtime grubbing function triggered an ASAN error and 
we were executing that function on another thread.  

I couldn't figure out a way to reproduce that situation in a test.  But this is an 
NFC change anyway, it just makes the locking strategy more narrowly focused.

<rdar://problem/49074093>

llvm-svn: 357141
2019-03-28 01:51:33 +00:00
Davide Italiano 8ff45859c2 [Process] Reorder declarations and document ReadMemoryFromInferior.
llvm-svn: 357136
2019-03-28 00:07:33 +00:00
Davide Italiano 454e9428db [ObjectFileMachO] Remove another debugging aid.
Pointed out by Jason.

llvm-svn: 357135
2019-03-28 00:07:20 +00:00