Commit Graph

1115 Commits

Author SHA1 Message Date
Stephane Sezer 15d810fa29 Always transmit SIGPROF back to the inferior.
Summary:
SIGPROF is used for profiling processes (with google-perftools for
instance), which results in the inferior receiving a SIGPROF from the
kernel every few milliseconds. Instead of stopping the debugging session
and notifying the user of this, we should just pass the signal and keep
running.

This follows the behavior we have in UnixSignals.cpp.

Test Plan: Run LLDB on linux with a binary using google-perftools, see that execution gets interrupted all the time because we receive SIGPROF. Apply the patch, everything works fine.

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D5953

llvm-svn: 221011
2014-10-31 22:37:24 +00:00
Shawn Best 396f80a1ea commit on behalf of Oleksiy Vyalov Fix junk content handling within GDBRemoteCOmmunication::CheckForPacket 1. Avoid removing of an extra symbol from m_bytes. 2. iterate over m_bytes until useful content is found. Differential Revision: http://reviews.llvm.org/D6042
llvm-svn: 220983
2014-10-31 18:18:23 +00:00
Justin Hibbits 6256a0ea8f First cut of PowerPC(64) support in LLDB.
Summary:
This adds preliminary support for PowerPC/PowerPC64, for FreeBSD.  There are
some issues still:

 * Breakpoints don't work well on powerpc64.
 * Shared libraries don't yet get loaded for a 32-bit process on powerpc64 host.
 * Backtraces don't work.  This is due to PowerPC ABI using a backchain pointer
   in memory, instead of a dedicated frame pointer register for the backchain.
 * Breakpoints on functions without debug info may not work correctly for 32-bit
   powerpc.

Reviewers: emaste, tfiala, jingham, clayborg

Reviewed By: clayborg

Subscribers: emaste, lldb-commits

Differential Revision: http://reviews.llvm.org/D5988

llvm-svn: 220944
2014-10-31 02:34:28 +00:00
Greg Clayton c3eefa39cc Get the correct process architecture in ProcessKDP::DidAttach().
<rdar://problem/18806212>

llvm-svn: 220938
2014-10-31 00:06:52 +00:00
Zachary Turner 047a070f7c Make ProcessWindows just use Host::LaunchProcess.
llvm-svn: 220574
2014-10-24 17:51:56 +00:00
Jason Molenda 84843ed536 A << operation would be undefined for a bit-selecting
function because of a '1u' making it a 32-bit value
when it really needed to be a 64-bit value.  Trivial to fix
once I figured out what was going on.
clang static analzyer fixit.

llvm-svn: 220022
2014-10-17 01:52:30 +00:00
Jason Molenda 270c52c8dc Be more consistent about null checks for the Process and ABI
in GetFullUnwindPlanForFrame() - the code was mostly checking
that we had an active Process and ABI but not always.
clang static analyzer fixit.

llvm-svn: 219772
2014-10-15 03:11:37 +00:00
Zachary Turner 172d37d3b9 Create a process launcher abstraction.
This implements Host::LaunchProcess for windows, and in doing so
does some minor refactor to move towards a more modular process
launching design.

The original motivation for this is that launching processes on
windows needs some very windows specific code, which would live
most appropriately in source/Host/windows somewhere.  However,
there is already some common code that all platforms use when
launching a process before delegating to the platform specific
stuff, which lives in source/Host/common/Host.cpp which would
be nice to reuse without duplicating.

This commonality has been abstracted into MonitoringProcessLauncher,
a class which abstracts out the notion of launching a process using
an arbitrary algorithm, and then monitoring it for state changes.

The windows specific launching code lives in ProcessLauncherWindows,
and the posix specific launching code lives in ProcessLauncherPosix.
When launching a process MonitoringProcessLauncher is created, and
then an appropriate delegate launcher is created and given to the
MonitoringProcessLauncher.

Reviewed by: Greg Clayton
Differential Revision: http://reviews.llvm.org/D5781

llvm-svn: 219731
2014-10-14 21:55:08 +00:00
Todd Fiala 75f47c3a5d llgs: fixes to PTY/gdb-remote inferior stdout/stderr handling, logging addtions.
With this change, both local-process llgs and remote-target llgs stdout/stderr
handling from inferior work correctly.

Several log lines have been added around PTY and stdout/stderr redirection
logic on the lldb client side.

Regarding remote llgs execution, see the following:

With these changes, remote llgs with $O now works properly:

$ lldb
(lldb) platform select remote-linux
(lldb) target create ~/some/inferior/exe
(lldb) gdb-remote {some-target}:{port}
(lldb) run

The sequence above will correctly redirect stdout/stderr over gdb-remote $O,
as is needed for remote debugging.  That sequence assumes there is a lldb-gdbserver
exe running on the target with {some-host}:{port}.

You can replace the gdb-remote command with a '(lldb) platform connect
connect://{target-ip}:{target-port}'.  If you do this and have a
lldb-platform running on the remote end, it will go ahead and launch
llgs for lldb for each target instance that is run/attached.

For local debugging with llgs, the following sequence also works, and
uses local PTYs instead to avoid $O and extra gdb-remote messages:

$ lldb
(lldb) settings set platform.plugin.linux.use-llgs true
(lldb) target create ~/some/inferior/exe
(lldb) run

The above will run the inferior using llgs on the local host, and
will use PTYs rather than $O redirection.

This change also removes the logging that happened after the fork but
before the exec when llgs is launching a new inferior process.  Some
aspect of the file handling during that portion of code would not do
the right thing with log handling.  We might want to go back later
and have that communicate over a pipe from the child to parent to pass
along any messages that previously were logged in that section of code.

llvm-svn: 219578
2014-10-11 21:42:09 +00:00
Todd Fiala 348fb385d5 Enable local llgs debugging on Linux when the use-llgs-for-local setting is enabled.
See http://reviews.llvm.org/D5695 for details.

This change does the following:

Enable lldb-gdbserver (llgs) usage for local-process Linux debugging.
To turn on local llgs debugging support, which is disabled by default, enable this setting:

(lldb) settings set platform.plugin.linux.use-llgs-for-local true
Adds a stream-based Dump() function to FileAction.
Pushes some platform methods that Linux (and FreeBSD) will want to share with MacOSX from PlatformDarwin into PlatformPOSIX.

Reviewed by Greg Clayton.

llvm-svn: 219457
2014-10-10 00:09:16 +00:00
Todd Fiala 7aafc4a5ff thread state coordinator: fixed bug in thread running state book-keeping.
Adds a test to verify that a thread resume request marks the thread as running
after doing the resume callback.  This test fails without the corresponding
ThreadStateCoordinator.cpp change.

Fixes the code where that state was not maintained.

llvm-svn: 219412
2014-10-09 17:00:55 +00:00
Todd Fiala 616b827ad0 Added a bit of logging around GDBRemoteCommunicationClient::SendGDBStoppointTypePacket.
llvm-svn: 219374
2014-10-09 00:55:04 +00:00
Jason Molenda a410679ed6 When we detect a stack unwind loop, before we abort
the backtrace, try falling back to the architecture default
unwind plan and see if we can backtrace a little further.
<rdar://problem/18556719> 

llvm-svn: 219247
2014-10-07 22:55:13 +00:00
Zachary Turner 93a66fc13a Move ConnectionFileDescriptor to platform-specific Host directory.
As part of getting ConnectionFileDescriptor working on Windows,
there is going to be alot of platform specific work to be done.
As a result, the implementation is moving into Host.  This patch
performs the code move and fixes up call-sites appropriately.

Reviewed by: Greg Clayton
Differential Revision: http://reviews.llvm.org/D5548

llvm-svn: 219143
2014-10-06 21:22:36 +00:00
Todd Fiala b72209102f thread state coordinator: add tests and impl to error on creation/death issues.
Added tests and impl to make sure the following errors are reported:
* Notifying a created thread that we are already tracking.
* Notifying a thread death for a thread we don't know about.

llvm-svn: 218900
2014-10-02 19:44:32 +00:00
Todd Fiala 325111bcc6 thread state coordinator: added simpler deferred stop notification method.
Now that ThreadStateCoordinator errors out on threads in unexpected states,
it has enough information to know which threads need stop requests fired
when we want to do a deferred callback on a thread's behalf.  This change
adds a new method, CallAfterRunningThreadsStop(...), which no longer
takes a set of thread ids that require stop requests.  It's much harder
to misuse this method and (with newer error logic) it's harder to
correctly use the original method.  Expect the original method that takes
the set of thread ids to stop to disappear in the near future.

Adds several tests for CallAfterRunningThreadsStop().

llvm-svn: 218897
2014-10-02 19:03:06 +00:00
Todd Fiala 404e370892 thread state coordinator: requesting resume now signals error appropriately.
Added tests to verify that the coordinator signals an error if
the given thread to resume is unknown, and if the thread is through to
be running already.

Modified resume handling code to match tests.

llvm-svn: 218872
2014-10-02 14:41:15 +00:00
Eric Christopher 78b833bb53 Remove unused variable.
llvm-svn: 218844
2014-10-02 00:52:57 +00:00
Todd Fiala ebcf42cdec thread state coordinator: added error callbacks, cleaned up tests.
ThreadStateCoordinator changes:
* Most commands that run in the queue now take an error handler that
  will be called with an error string if an error occurs during processing.
  Errors generally stop the operation in progress.  The errors are checked
  at time of execution.  This is intended to help flush out ptrace/waitpid/state management
  issues as quickly as possible.

* Threads now must be known to the coordinator before stops can be reported,
  resumes can be requested, thread deaths can be reported, or deferred stop
  notifications can be made.  Failure to know the thread will cause the coordinator
  to call the error callback for the event being processed.  Threads are introduced
  to the system by the NotifyThreadCreate method.
  
* The NotifyThreadCreate method now takes the initial state of the thread being
  introduces to the system.  We no longer just assume the thread is running.
  
The test cases were cleaned up, too:
* A gtest test fixture is now used, which allows creating less verbose helper
  methods that setup common pieces of callback code for some method invocations.
  Net result: the tests are simpler to read and shorter to write.

llvm-svn: 218833
2014-10-01 21:40:45 +00:00
Todd Fiala e825f44761 thread state coordinator: replaced shortened type name Func suffix with Function.
ThreadIDFunc => ThreadIDFunction
LogFunc      => LogIDFunction

We try to avoid abbreviations/shortened names.  Adjusted function parameter names
as well to replace _func with _function.

llvm-svn: 218773
2014-10-01 16:08:20 +00:00
Todd Fiala 241ce99503 Minor tweak to Ed's FreeBSD fix.
Fall back to including the Linux version if not on __FreeBSD__.  Also covers
__ANDROID__ case.

llvm-svn: 218770
2014-10-01 15:10:37 +00:00
Ed Maste 81f59a09f2 Add a bandaid to fix the FreeBSD build
r218568 added an explicit #include of the Linux ProcessMonitor.h to
POSIXThread.cpp, rather than including just "ProcessMonitor.h" and
relying on the build infrastructure for the appropriate paths.

For now add #ifdefs in the source to use the FreeBSD or Linux header
as appropriate; a cleaner fix (and perhaps some refactoring of the
POSIX classes) should still be done later.

llvm-svn: 218762
2014-10-01 12:56:39 +00:00
Zachary Turner 25cbf5aac6 Fix FreeBSD build.
llvm-svn: 218685
2014-09-30 16:56:56 +00:00
Todd Fiala f8d929dc82 thread state coordinator: add test to be explicit about resume behavior in presence of deferred stop notification still pending.
There is a state transition that seems potentially buggy that I am capturing and
logging here, and including an explicit test to demonstrate expected behavior.  See new test
for detailed description.  Added logging around this area since, if we hit it, we
may have a usage bug, or a new state transition we really need to investigate.

This is around this scenario:
Thread C deferred stop notification awaiting thread A and thread B to stop.
Thread A stops.
Thread A requests resume.
Thread B stops.

Here we will explicitly signal the deferred stop notification after thread B
stops even though thread A is now resumed.  Copious logging happens here.

llvm-svn: 218683
2014-09-30 16:56:28 +00:00
Jim Ingham 2bdbfd50d2 This checkin is the first step in making the lldb thread stepping mechanism more accessible from
the user level.  It adds the ability to invent new stepping modes implemented by python classes,
and to view the current thread plan stack and to some extent alter it.

I haven't gotten to documentation or tests yet.  But this should not cause any behavior changes
if you don't use it, so its safe to check it in now and work on it incrementally.

llvm-svn: 218642
2014-09-29 23:17:18 +00:00
Todd Fiala e2109e7323 thread state coordinator: added a thread resume request and related tests.
The thread resume block is executed in the normal flow of thread
state queued event processing.  The tests verify that it is executed
when we track the thread to be stopped and skipped when we track
it to already be running.

llvm-svn: 218638
2014-09-29 22:57:05 +00:00
Todd Fiala 424723b281 thread state coordinator: add exec reset support, remove empty virtual destructors.
Also added a test for the reset handling.  The reset/state clearing happens
as a processed queue event.  The only diff vs. standard processing is that
the exec clears the queue before queueing the activity to clear internal state.
i.e. once we get an exec, we really stop doing any other queue-based activity.

llvm-svn: 218629
2014-09-29 21:45:21 +00:00
Matthew Gardiner e598d7b01d Included cstdarg for compilation of va_start and va_end.
llvm-svn: 218594
2014-09-29 07:12:47 +00:00
Todd Fiala 55a02a7478 thread state coordinator: added new thread support.
A new thread arriving while a pending signal notification
is outstanding will (1) add the new thread to the list of
stops expected before the deferred signal notification is
fired, (2) send a stop request for the new thread, and
(3) track the new thread as currently running.

llvm-svn: 218578
2014-09-28 06:50:47 +00:00
Todd Fiala cacde7df6d Enable llgs to build against experimental Android AOSP lldb/llvm/clang/compiler-rt repos.
See http://reviews.llvm.org/D5495 for more details.

These are changes that are part of an effort to support building llgs, within the AOSP source tree, using the Android.mk
build system, when using the llvm/clang/lldb git repos from AOSP replaced with the experimental ones currently in
github.com/tfiala/aosp-{llvm,clang,lldb,compiler-rt}.

llvm-svn: 218568
2014-09-27 16:54:22 +00:00
Todd Fiala ef5dbf55c8 thread state coordinator: added thread death support and more tests.
Tested two pending stops before notification, where one of the pending stop
requirements was already known to be stopped.

Tested pending thread stop before notification, then reporting thread with
pending stop died and verifies pending notification is made.

llvm-svn: 218559
2014-09-27 01:58:13 +00:00
Todd Fiala 9dd7334d69 thread state coordinator: added test for notify after two pending thread stops.
Glad I did - caught a bug where the auto variable was not a reference
to a set and instead was a copy.  I need to review rules on that!

llvm-svn: 218558
2014-09-27 01:11:17 +00:00
Todd Fiala e9c9e7070e thread state coordinator: handle when prerequisite pending stop is already stopped.
Change includes new gtest and functionality.

llvm-svn: 218555
2014-09-26 23:42:53 +00:00
Todd Fiala 80bef312b5 gtest: tweaked test runner to fix an extra comma, added more tdd-based thread coordinator behavior.
Starting to flesh out the thread state coordinator class that will be used
by Linux/llgs.

llvm-svn: 218537
2014-09-26 19:08:00 +00:00
Todd Fiala b3185e710e Fixup gtest layout, add Linux ThreadStateCoordinator.cpp.
This change does the following:
* Remove test/c++/...
* Add gtest.
* Add gtest/unittest directory for unittesting individual classes.
* Add an initial Plugins/Process?linux/ThreadStateCoordinatorTest.cpp.
  - currently failing a test (intentional).
  - added a bare-bones ThreadStateCoordinator.cpp to Plugins/Process/Linux,
    more soon. Just enough to prove out running gtest on Ubuntu and MacOSX.
* Added recursive make machinery so that doing a 'make' in gtest/ is
  sufficient to kick off the existing test several directories down.
  - Caveat - I currently short circuit from gtest/unittest/Makefile directly to
    the one and only gtest/unittest/Plugins/Process/Linux directory.  We'll need
    to add the intervening layers.  I haven't done this yet since to fix the
    Xcode test failure correspondence, I may need to add a python layer which
    might just handle the directory crawling.
* Added an Xcode project to the lldb workspace for gtest.
  - Runs the recursive make system in gtest/Makefile.
  - Default target is 'test'.  test and clean are supported.
  - Currently does not support test failure file/line correspondence.
    Requires a bit of text transformation to hook that up.

llvm-svn: 218460
2014-09-25 19:25:07 +00:00
Zachary Turner acee96ae52 Fix up the HostThread interface, making the interface simpler.
Reviewed by: Greg Clayton
Differential Revision: http://reviews.llvm.org/D5417

llvm-svn: 218325
2014-09-23 18:32:09 +00:00
Greg Clayton 615eb7e609 Test suite runs better again after recent fixes that would select a platform if a "file a.out" auto selected a different platform than the selected one.
Changes include:
- fix it so you can select the "host" platform using "platform select host"
- change all callbacks that create platforms to returns shared pointers
- fix TestImageListMultiArchitecture.py to restore the "host" platform by running "platform select host"
- Add a new "PlatformSP Platform::Find(const ConstString &name)" method to get a cached platform
- cache platforms that are created and re-use them instead of always creating a new one

llvm-svn: 218145
2014-09-19 20:11:50 +00:00
Todd Fiala 850f9a25a5 Fix typo in Linux ASLR logging.
llvm-svn: 218133
2014-09-19 18:27:45 +00:00
Todd Fiala 87bac59adc llgs: removed some wait-for-stop code in inferior process launch pipeline.
The $A handler was unnecessarily waiting for the launched app to hit a stop
before returning.  Removed this code.

Renamed the llgs inferior launching code to LaunchProcessForDebugging ()
to prevent it from possibly being mistaken as code that lldb-platform uses
to launch a debugserver process.  We probably want to look at breaking out
llgs-specific and lldb-platform-specific code into separate derived classes,
with common code in a shared base class.

llvm-svn: 218075
2014-09-18 21:02:03 +00:00
Greg Clayton 44272a40dc Hex encode the triple values in case they contain special characters.
llvm-svn: 218001
2014-09-18 00:18:32 +00:00
Greg Clayton 7e2443258f Add better logging for the "$vFile:pwrite:" packet so we can show binary data instead of nothing or unprintable characters. This can easily be extended for other packets that have binary data.
llvm-svn: 218000
2014-09-18 00:17:36 +00:00
David Majnemer 8faf9370fa Clean-up warnings on Linux/GCC
llvm-svn: 217862
2014-09-16 06:34:29 +00:00
Todd Fiala 7b0917a0c5 use std::atomic<> to protect variables being accessed by multiple threads
There are several places where multiple threads are accessing the same variables simultaneously without any kind of protection. I propose using std::atomic<> to make it safer. I did a special build of lldb, using the google tool 'thread sanitizer' which identified many cases of multiple threads accessing the same memory. std::atomic is low overhead and does not use any locks for simple types such as int/bool.

See http://reviews.llvm.org/D5302 for more details.

Change by Shawn Best.

llvm-svn: 217818
2014-09-15 20:07:33 +00:00
Todd Fiala 0fceef8065 lldb fix ARM64 register access - llgs side
See http://reviews.llvm.org/D5341 for more details.

Change by Paul Osmialowski.

llvm-svn: 217788
2014-09-15 17:09:23 +00:00
Todd Fiala 3daa176986 Properly decode architecture type in GDBRemoteCommunicationClient::GetCurrentProcessInfo.
Instead of forcing the remote arch type to MachO all the time, we
inspect the OS/vendor that the remote debug server reports and use it to
set the arch type to MachO, ELF or COFF accordingly.

See thread here for more context:
http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140915/012968.html

Change by Stephane Sezer.

Tested:
MacOSX 10.9.4 x86_64
Ubuntu 14.04 x86_64

llvm-svn: 217779
2014-09-15 16:01:29 +00:00
Todd Fiala 5c9d5bf81e Check for byte order correctness in GDBRemoteCommunicationClient::GetCurrentProcessInfo.
This is useful for checking inconsistencies between what the remote debug server thinks we are debugging and we think we are debugging. This follows the check for pointer byte size done just above.

Change by Stephane Sezer.

Tested:
Ubuntu 14.04 x86_64, llvm-3.5-built lldb
MacOSX 10.9.4, Xcode-Beta(2014-09-09)-built lldb.

llvm-svn: 217773
2014-09-15 15:31:11 +00:00
Todd Fiala 7206c6d11f llgs: fix thread names broken by recent native thread changes.
* Fixes the local stack variable return pointer usage in NativeThreadLinux::GetName().
* Changes NativeThreadProtocol::GetName() to return a std::string.
* Adds a unit test to verify thread names don't regress in the future.  Currently only run on Linux since I know default thread names there.

llvm-svn: 217717
2014-09-12 22:51:49 +00:00
Todd Fiala 49131cfd2e lldb fix ARM64 register access
Apparently, PEEKUSER/POKEUSER is something x86 specific, so I had to rework it for AArch64. This fixes assertion that occurs whenever lldb started on AArch64 device tried to read PC register (or any other register)

See http://reviews.llvm.org/D5232 for more details.

Change by Paul Osmialowski.

llvm-svn: 217691
2014-09-12 16:57:28 +00:00
Todd Fiala 511e5cdce4 llgs: fix Ctrl-C inferior interrupt handling to do the right thing.
* Sends a SIGSTOP to the process.
* Fixes busted SIGSTOP handling.  Now builds a list of non-stopped
  that we wait for the PTRACE group-stop for.  When the final must-stop
  tid gets its group stop, we propagate the process state change.
  Only the signal receiving the notification of the pending SIGSTOP
  is marked with the SIGSTOP signal.  All the rest, if they weren't
  already stopped, are marked as stopped with signal 0.
* Fixes a few broken tests.
* Marks the Linux test I added earlier as expect-pass (no longer XFAIL).

Implements fix for http://llvm.org/bugs/show_bug.cgi?id=20908.

llvm-svn: 217647
2014-09-11 23:29:14 +00:00
Todd Fiala 1109ed4245 llgs: implement qThreadStopInfo.
This change implements this ticket:
http://llvm.org/bugs/show_bug.cgi?id=20899

Adds the qThreadStopInfo RSP command for llgs and includes a test that
verifies both debugserver and llgs respond with something reasonable
on a multithreaded app.

llvm-svn: 217549
2014-09-10 21:28:38 +00:00