Commit Graph

24 Commits

Author SHA1 Message Date
Dimitar Vlahovski 36e21a3d56 Removing the new Minidump plugin
Tests are failing and build is failing on windows and darwin.
Will fix and commit it later
-------------------------------------------------------------

Revert "xfailing minidump tests again ... :("
This reverts commit 97eade002c9e43c1e0d11475a4888083a8965044.

Revert "Fixing new Minidump plugin tests"
This reverts commit 0dd93b3ab39c8288696001dd50b9a093b813b09c.

Revert "Add the new minidump files to the Xcode project."
This reverts commit 2f638a1d046b8a88e61e212220edc40aecd2ce44.

Revert "xfailing tests for Minidump plugin"
This reverts commit 99311c0b22338a83e6a00c4fbddfd3577914c003.

Revert "Adding a new Minidump post-mortem debugging plugin"
This reverts commit b09a7e4dae231663095a84dac4be3da00b03a021.

llvm-svn: 283352
2016-10-05 18:11:45 +00:00
Dimitar Vlahovski 8cabfb764d Adding a new Minidump post-mortem debugging plugin
Summary:
This plugin resembles the already existing Windows-only Minidump plugin.
The WinMinidumpPlugin uses the Windows API for parsing Minidumps
while this plugin is cross-platform because it includes a Minidump
parser (which is already commited)

It is able to produce a backtrace, to read the general puprose regiters,
inspect local variables, show image list, do memory reads, etc.

For now the only arch that this supports is x86 64 bit
This is because I have only written a register context for that arch.
Others will come in next CLs.

I copied the WinMinidump tests and adapted them a little bit for them to
work with the new plugin (and they pass)
I will add more tests, aiming for better code coverage.

There is still functionality to be added, see TODOs in code.

Reviewers: labath, zturner

Subscribers: beanz, mgorny, amccarth, lldb-commits, modocache

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

llvm-svn: 283259
2016-10-04 21:02:13 +00:00
Dimitar Vlahovski 4c31907dbf Adding a RegisterContextMinidump_x86_64 converter
Summary:
This is a register context converter from Minidump to Linux reg context.
This knows the layout of the register context in the Minidump file
(which is the same as in Windows FYI) and as a result emits a binary data
buffer that matches the Linux register context binary layout.
This way we can reuse the existing RegisterContextLinux_x86_64 and
RegisterContextCorePOSIX_x86_64 classes.

Reviewers: labath, zturner

Subscribers: beanz, mgorny, lldb-commits, amccarth

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

llvm-svn: 282529
2016-09-27 19:05:55 +00:00
Dimitar Vlahovski 1d2859ef6d MinidumpParsing: pid, modules, exceptions, strings
Summary:
Added parsing of the MiscInfo data stream.
The main member of it that we care about is the process_id
On Linux generated Minidump (from breakpad) we don't have
the MiscInfo, we have the /proc/$pid/status from where we can get the
pid.
Also parsing the module list - the list of all of the loaded
modules/shared libraries.
Parsing the exception stream.
Parsing MinidumpStrings.

I have unit tests for all of that.
Also added some tests using a Minidump generated from Windows tools (not
from breakpad)

Reviewers: labath, zturner

Subscribers: beanz, lldb-commits

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

llvm-svn: 281348
2016-09-13 15:54:38 +00:00
Todd Fiala fcdb1af655 async structured data packet handling improvements
This change does the following:
* Changes the signature for the continuation delegate method that handles
  async structured data from accepting an already-parsed structured data
  element to taking just the packet contents.
* Moves the conversion of the JSON-async: packet contents from
  GDBRemoteClientBase to the continuation delegate method.
* Adds a new unit test for verifying that the $JSON-asyc: packets get
  decoded and that the decoded packets get forwarded on to the delegate
  for further processing. Thanks to Pavel for making that whole section of
  code easily unit testable!
* Tightens up the packet verification on reception of a $JSON-async:
  packet contents. The code prior to this change is susceptible to a
  segfault if a packet is carefully crafted that starts with $J but
  has a total length shorter than the length of "$JSON-async:".

Reviewers: labath, clayborg, zturner

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

llvm-svn: 281121
2016-09-10 00:06:29 +00:00
Pavel Labath 6e5e49fbdf Fix new gdb-remote client unit test for windows
The behaviour of FileSpec differed between host OS versions. Hardcode the path
syntax to posix, as we don't care about that in this test.

llvm-svn: 281025
2016-09-09 09:49:54 +00:00
Pavel Labath 2f1fbaebe2 gdb-remote: Add jModulesInfo packet
Summary:
This adds the jModulesInfo packet, which is the equivalent of qModulesInfo, but it enables us to
query multiple modules at once. This makes a significant speed improvement in case the
application has many (over a hundred) modules, and the communication link has a non-negligible
latency. This functionality is accessed by ProcessGdbRemote::PrefetchModuleSpecs(), which does
the caching. GetModuleSpecs() is modified to first consult the cache before asking the remote
stub. PrefetchModuleSpecs is currently only called from POSIX-DYLD dynamic loader plugin, after
it reads the list of modules from the inferior memory, but other uses are possible.

This decreases the attach time to an android application by about 40%.

Reviewers: clayborg

Subscribers: tberghammer, lldb-commits, danalbert

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

llvm-svn: 280919
2016-09-08 10:07:04 +00:00
Pavel Labath 46031e6fec Fix unittest compilation on windows
After the reformat, the unittests do not compile due to missing due to redefinition errors
between PosixApi.h and ucrt/direct.h. This is a bit of a shot in the dark, as I have not tested
it on windows, but I am restoring the original include order, so it should hopefully fix it.

llvm-svn: 280793
2016-09-07 08:46:50 +00:00
Kate Stone b9c1b51e45 *** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style.  This kind of mass change has
*** two obvious implications:

Firstly, merging this particular commit into a downstream fork may be a huge
effort.  Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit.  The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):

    find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
    find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;

The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.

Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit.  There are alternatives available that will attempt
to look through this change and find the appropriate prior commit.  YMMV.

llvm-svn: 280751
2016-09-06 20:57:50 +00:00
Dimitar Vlahovski 2e50d8edc6 Minidump parsing
Summary:
This is a Minidump parsing code.
There are still some more structures/data streams that need to be added.
The aim ot this is to be used in the implementation of
a minidump debugging plugin that works on all platforms/architectures.
Currently we have a windows-only plugin that uses the WinAPI to parse
the dump files.
Also added unittests for the current functionality.

Reviewers: labath, amccarth

Subscribers: tberghammer, danalbert, srhines, lldb-commits, dschuff

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

llvm-svn: 280356
2016-09-01 11:29:53 +00:00
Pavel Labath 5c95ee4dd8 Revert "gdb-remote: Make the sequence mutex non-recursive"
This reverts commit r279725 as it breaks "dynamic register size" feature of mips.

llvm-svn: 280088
2016-08-30 13:56:11 +00:00
Zachary Turner 26709df81d Convert some functions to use StringRef instead of c_str, len
This started as an effort to change StringExtractor to store a
StringRef internally instead of a std::string.  I got that working
locally with just 1 test failure which I was unable to figure out the
cause of.  But it was also a massive changelist due to a trickle
down effect of changes.

So I'm starting over, using what I learned from the first time to
tackle smaller, more isolated changes hopefully leading up to
a full conversion by the end.

At first the changes (such as in this CL) will seem mostly
a matter of preference and pointless otherwise.  However, there
are some places in my larger CL where using StringRef turned 20+
lines of code into 2, drastically simplifying logic.  Hopefully
once these go in they will illustrate some of the benefits of
thinking in terms of StringRef.

llvm-svn: 279917
2016-08-27 15:52:29 +00:00
Pavel Labath 0faf37333c gdb-remote: Make the sequence mutex non-recursive
Summary:
This is a preparatory commit for D22914, where I'd like to replace this mutex by an R/W lock
(which is also not recursive). This required a couple of changes:
- The only caller of Read/WriteRegister, GDBRemoteRegisterContext class, was already acquiring
  the mutex, so these functions do not need to. All functions which now do not take a lock, take
  an lock argument instead, to remind the caller of this fact.
- GetThreadSuffixSupported() was being called from locked and unlocked contexts (including
  contexts where the process was running, and the call would fail if it did not have the result
  cached). I have split this into two functions, one which computes the thread suffix support and
  caches it (this one always takes the lock), and another, which returns the cached value (and
  never needs to take the lock). This feels quite natural as ProcessGdbRemote was already
  pre-caching this value at the start.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 279725
2016-08-25 08:34:57 +00:00
Pavel Labath b42b48e051 Remove the last manually constructed packet from gdb-remote register context + small refactor
Summary:
The tricky part here was that the exisiting implementation of WriteAllRegisters was expecting
hex-encoded data (as that was what the first implementation I replaced was using, but here we had
binary data to begin with. I thought the read/write register functions would be more useful if
they handled the hex-encoding themselves (all the other client functions provide the responses in
a more-or-less digested form). The read functions return a DataBuffer, so they can allocate as
much memory as they need to, while the write functions functions take an llvm::ArrayRef, as that
can be constructed from pretty much anything.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 279232
2016-08-19 12:31:49 +00:00
Todd Fiala 49178e5efe fix broken gdb-remote gtest
This change adds the Process/gdb-remote gtests to the Xcode
build.  It also adds a virtual method impl to the continuation
delegate that I added with the StructuredDataPlugin change.

llvm-svn: 279203
2016-08-19 04:38:44 +00:00
Pavel Labath 27402d2a12 Move QSyncThreadState packet generation to the gdb-remote client
llvm-svn: 279057
2016-08-18 12:32:41 +00:00
Pavel Labath 4b6f9591d3 gdb-remote: Centralize thread specific packet handling
Summary:
Before this, each function had a copy of the code which handled appending of the thread suffix to
the packet (or using $Hg instead). I have moved that code into a single function and made
everyone else use that. The function takes the partial packet as a StreamString rvalue reference,
to avoid a copy and to remind the users that the packet will have undeterminate contents after
the call.

This also fixes the incorrect formatting of the QRestoreRegisterState packet in case thread
suffix is not supported.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 279040
2016-08-18 08:30:03 +00:00
Pavel Labath 8e8e5061b8 Fix unittests on windows after r278915
Apparently clang will happily capture a const variable in a lambda without it being specified in
the capture clause. MSVC does not like that.

llvm-svn: 278925
2016-08-17 12:00:19 +00:00
Pavel Labath 3cc2f11f90 Fix unittest compilation error in r278915
llvm-svn: 278918
2016-08-17 09:17:08 +00:00
Pavel Labath 56d7262b69 Move packet construction from GDBRemoteRegisterContext go the communication class
Summary:
When saving/restoring registers the GDBRemoteRegisterContext class was manually constructing
the register save/restore packets. This creates appropriate helper functions in
GDBRemoteCommunicationClient, and switches the class to use those. It also removes what a
duplicate packet send in some of those functions, a thing that I can only attribute to a bad
merge artefact.

I also add a test framework for testing gdb-remote client functionality and add tests for the new
functions I introduced. I'd like to be able to test the register context changes in isolation as
well, but currently there doesn't seem to be a way to reasonably construct a standalone register
context object, so we'll have to rely on the end-to-end tests to verify that.

Reviewers: clayborg

Subscribers: lldb-commits

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

llvm-svn: 278915
2016-08-17 08:53:31 +00:00
Pavel Labath 5a123c4e37 Remove GetThreadSuffixSupported from GDBRemoteCommunication **base** class
Despite its comment, the function is only used in the Client class, and its presence was merely
complicating mock implementation in unit tests.

llvm-svn: 278785
2016-08-16 09:36:29 +00:00
Pavel Labath 8c1b6bd7d2 Reapply "Rewrite gdb-remote's SendContinuePacketAndWaitForResponse"
Resumbitting the commit after fixing the following problems:
- broken unit tests on windows: incorrect gtest usage on my part (TEST vs. TEST_F)
- the new code did not correctly handle the case where we went to interrupt the process, but it
  stopped due to a different reason - the interrupt request would remain queued and would
  interfere with the following "continue". I also added a unit test for this case.

This reapplies r277156 and r277139.

llvm-svn: 278118
2016-08-09 12:04:46 +00:00
Pavel Labath 4cb699260c Revert "Rewrite gdb-remote's SendContinuePacketAndWaitForResponse"
This reverts commit r277139, because:
- broken unittest on windows (likely typo on my part)
- seems to break TestCallThatRestart (needs investigation)

llvm-svn: 277154
2016-07-29 15:41:52 +00:00
Pavel Labath e768c4b858 Rewrite gdb-remote's SendContinuePacketAndWaitForResponse
SendContinuePacketAndWaitForResponse was huge function with very complex interactions with
several other functions (SendAsyncSignal, SendInterrupt, SendPacket). This meant that making any
changes to how packet sending functions and threads interact was very difficult and error-prone.

This change does not add any functionality yet, it merely paves the way for future changes. In a
follow-up, I plan to add the ability to have multiple query packets in flight (i.e.,
request,request,response,response instead of the usual request,response sequences) and use that
to speed up qModuleInfo packet processing.

Here, I introduce two special kinds of locks: ContinueLock, which is used by the continue thread,
and Lock, which is used by everyone else. ContinueLock (atomically) sends a continue packet, and
blocks any other async threads from accessing the connection. Other threads create an instance of
the Lock object when they want to access the connection. This object, while in scope prevents the
continue from being send. Optionally, it can also interrupt the process to gain access to the
connection for async processing.

Most of the syncrhonization logic is encapsulated within these two classes. Some of it still
had to bleed over into the SendContinuePacketAndWaitForResponse, but the function is still much
more manageable than before -- partly because of most of the work is done in the ContinueLock
class, and partly because I have factored out a lot of the packet processing code separate
functions (this also makes the functionality more easily testable). Most importantly, there is
none of syncrhonization code in the async thread users -- as far as they are concerned, they just
need to declare a Lock object, and they are good to go (SendPacketAndWaitForResponse is now a
very thin wrapper around the NoLock version of the function, whereas previously it had over 100
lines of synchronization code).  This will make my follow up changes there easy.

I have written a number of unit tests for the new code and I have ran the test suite on linux and
osx with no regressions.

Subscribers: tberghammer

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

llvm-svn: 277139
2016-07-29 13:10:02 +00:00