Commit Graph

30 Commits

Author SHA1 Message Date
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 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
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
Todd Fiala 21130fbc04 Fix lldb-gdbserver build.
Build break change by Paul Osmialowski.

Minor changes to argument passing (converted unintentional pass-by-value to pass-by-ref) by Todd.

llvm-svn: 218186
2014-09-20 17:34:48 +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
Zachary Turner 39de311071 Create a HostThread abstraction.
This patch moves creates a thread abstraction that represents a
thread running inside the LLDB process.  This is a replacement for
otherwise using lldb::thread_t, and provides a platform agnostic
interface to managing these threads.

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

Reviewed by: Jim Ingham

llvm-svn: 217460
2014-09-09 20:54:56 +00:00
Todd Fiala 737f43628a llgs: remove all Initialize() calls except for Debugger::Initialize().
See thread here:
http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20140825/012580.html

The original change I made there was due to a segfault.  That was
caused by me directly calling PluginManager::Initialize (), with
PluginManager::Initialize() depending on HostInfo::Initialize () to
have been called already (which it wasn't).

The call to PluginManager::Initialize () was erroneous (at least at the 
current time) since that method is already called by Debugger::Initialize()'s 
implementation.

We will want to revisit initializing a smaller core of the debugger
suitable for lldb-gdbserver and lldb-platform.

llvm-svn: 216581
2014-08-27 19:56:58 +00:00
Todd Fiala 3e9af0dd1d Add missing HostInfo::Initialize() in llgs.
This fixes an llgs segfault on startup.

llvm-svn: 216238
2014-08-21 22:41:25 +00:00
Zachary Turner 98688922b7 Creates a socket host object.
This patch moves the logic of many common socket operations into
its own class lldb_private::Socket.  It then modifies the
ConnectionFileDescriptor class, and a few users of that class,
to use this new Socket class instead of hardcoding socket logic
directly.

Finally, this patch creates a common interface called IOObject for
any objects that support reading and writing, so that endpoints
such as sockets and files can be treated the same.

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

Reviewed by: Todd Fiala, Greg Clayton

llvm-svn: 214984
2014-08-06 18:16:26 +00:00
Todd Fiala 31bde322f3 llgs: add --reverse-connect support.
Also includes --reverse-connect tests for llgs and debugserver.

llvm-svn: 214031
2014-07-26 20:39:17 +00:00
Ed Maste c25d5cc777 Fix lldb-gdbserver build
s_listen_thread had the wrong type.

llvm-svn: 212884
2014-07-12 21:46:39 +00:00
Todd Fiala a6a362a086 llgs: modify to accept --native-regs flag.
This is the last flag sent by lldb-platform that was not accepted
by llgs and is accepted by debugserver.

Conditionalized out a bit more code in prep for Windows
support one day based on _WIN32 define.

Updated the lldb-gdbserver usage string to represent
recent updates to command line arguments (and some older
ones like --attach pid).

Implements https://github.com/tfiala/lldb/issues/37

llvm-svn: 212879
2014-07-12 17:34:24 +00:00
Todd Fiala 289ca249f0 llgs: implement --setsid.
The --setsid (-S) option changes the session id for the lldb-gdbserver process.
This is used by tools such as lldb-platform and allows the user to prevent
llgs from being in the same session as a calling terminal session.
This will prevents terminal group control signals from affecting
lldb-gdbserver.

See also:
https://github.com/tfiala/lldb/issues/38

llvm-svn: 212873
2014-07-12 01:12:44 +00:00
Todd Fiala 67041194b9 Added llgs --named-pipe support and program_name-version_number printout support.
Added a unit test to test debugserver and llgs compliance on --named-pipe support.

Modified llgs to implement --named-pipe support.  (Note: need to revisit with
new generic pipe support).

llvm-svn: 212854
2014-07-11 22:50:13 +00:00
Todd Fiala af245d115b Add lldb-gdbserver support for Linux x86_64.
This change brings in lldb-gdbserver (llgs) specifically for Linux x86_64.
(More architectures coming soon).

Not every debugserver option is covered yet.  Currently
the lldb-gdbserver command line can start unattached,
start attached to a pid (process-name attach not supported yet),
or accept lldb attaching and launching a process or connecting
by process id.

The history of this large change can be found here:
https://github.com/tfiala/lldb/tree/dev-tfiala-native-protocol-linux-x86_64

Until mid/late April, I was not sharing the work and continued
to rebase it off of head (developed via id tfiala@google.com).  I switched over to
user todd.fiala@gmail.com in the middle, and once I went to github, I did
merges rather than rebasing so I could share with others.

llvm-svn: 212069
2014-06-30 21:05:18 +00:00
Todd Fiala 9164d9b304 Fixed up lldb-gdbserver to match slightly different debugserver listener host:port message.
Fixed up typo in lldb-gdbserver name missed when working on the OS X side earlier today for debugserver support.

llvm-svn: 207398
2014-04-28 06:04:46 +00:00
Todd Fiala 02c11e384d lldb-gdbserver: add support for optional host in connection string and handle other startup errors.
This change addresses the following bug:
http://www.llvm.org/bugs/show_bug.cgi?id=18814

llvm-svn: 202910
2014-03-04 23:41:34 +00:00
Ed Maste ba7cc706d9 Remove leftover debug printf
llvm-svn: 200866
2014-02-05 18:49:10 +00:00
Todd Fiala b8b49ec92b Modified GDBProcessCommunicationServer to launch via the platform.
GDBProcessCommunicationServer now optionally takes a PlatformSP that
defaults to the default platform for the host.
GDBProcessCommunicationServer::LaunchProcess () now uses the platform
to launch the process.

lldb-gdbserver now takes an optional --platform={platform_plugin_name}
or -p {platform_plugin_name} command line option. If no platform is
specified, the default platform for the host is used; otherwise, if
the platform_plugin_name matches a registered platform plugin or
matches the default platform's name (which is not necessarily
registered by name in the case of 'host'), that platform is used. If
the platform name cannot be resolved, lldb-gdbserver exits after
printing all the available platform plugin names and the default
platform plugin name.

llvm-svn: 200266
2014-01-28 00:34:23 +00:00
Todd Fiala 3e92a2b013 Added reaper for commandline-launched processes.
GDBRemoteCommunicationServer::LaunchProcess () now uses the built-up
ProcessLaunchArgs rather than clearing and setting items from the
function arguments. I added setters for the arguments and launch
flags, which lldb-gdbserver uses for its specification of the
commandline-specified startup app (if one is specified).

LaunchProcess () also adds a new reaper monitor that it applies to
the launched process if no process monitor has already been applied.

This addresses an issue where the 'k' command would generate (possibly
false) warnings about not being able to positively state whether a
killed process actually terminated. GDBRemoteCommunicationServer now
definitely knows the disposition of its children.

llvm-svn: 199959
2014-01-24 00:52:53 +00:00
Todd Fiala 403edc5c57 Move process launching into GDBRemoteCommunicationServer.
lldb-gdbserver was launching the commandline-specified launch process
directly, without GDBRemoteCommunicationServer knowing anything about
it.  As GDBRemoteCommunicationServer is the piece that manages and
knows about processes that the gdb remote protocol discusses with
the client end, it is important that it know about launched processes.

This change also implements the k gdb remote protocol message, having it
kill all known spawned processes when it is received.

(Note: in lldb-gdbserver, the spawned processes are not properly
monitored yet. The response to the k packet will complain that
spawned processes do not really appear to be getting killed even if
they are. This will get addressed soon.)

llvm-svn: 199945
2014-01-23 22:05:44 +00:00
Todd Fiala 4bd862206a Add --lldb-command command-line option to lldb-gdbserver
lldb-gdbserver now takes zero or more --lldb-command {command} options
that get executed by the command interpreter prior to starting up
a child debuggee process.  The short form is -c {command}.  This is
similar to how lldb-platform works.

This command can be used to enable logging in more than just the
gdb-remote log channel.  Here is an example startup sequence that allows
logging of lldb host and process log categories to one file and
gdb-remote packets to another file:

lldb-gdbserver -c 'log enable -f lgs.log lldb process host' \
  -c 'log enable -f lgs_packets.log gdb-remote packets' \
  localhost:5432 ./some_exe

llvm-svn: 199761
2014-01-21 18:46:22 +00:00
Todd Fiala f3d61de532 Enable Linux distribution in vendor portion of host triple.
This change does the following:

* enables building lldb-gdbserver on linux_x86-64 platforms.

  Note - it builds but it has several run-time issues where many gdb
  remote protocol features are not properly implemented yet. I'm
  working on these one at a time.

* lldb-gdbserver: does not enable the eLaunchFlagDebug launch flag on
  Linux. Currently the POSIX launch routine will assert if that flag
  is passed in, presumably because that launch mode is not yet
  available.  This prevents lldb-gdbserver from asserting the moment
  it launches the debuggee process.

* Adds ConstString& Host::GetDistributionId ()

  This method is defined to return an empty result on all platforms
  except for Linux.  On Linux, it makes one attempt to execute
  'lsb_release -i' (both /usr/bin/lsb_release, where it appears
  on ubuntu, and /bin/lsb_release, where it appears on fedora
  if the redhat-lsb package is installed).  If lsb_release is not
  found in either of those locations, or if 'lsb_release -i' does
  not return the first line starting with "Distributor ID:\t",
  then the distribution id is empty.  The method will lower-case
  the id and replace whitespace with underscores.

* Modify Host::GetArchitecture () so that linux replaces an unknown
  vendor portion with the results of GetDistributionId () if that
  is non-empty.  This shows up now in qHostInfo remote packet
  responses and on the lldb host side.  Tested with ubuntu and
  fedora (the latter both with the default of not having lsb_release
  installed, and with having lsb_release installed via the redhat-lsb
  package).

  Examples of triples on Linux after this change:

    # x86_64 Unbuntu 12.04 LTS:
    x86_64-ubuntu-linux-gnu

    # x86_64 Fedora 20 Desktop with redhat-lsb package installed
    x86_64-fedora-linux-gnu

    # x86_64 Fedora 20 Desktop without redhat-lsb-core installed
    # (i.e. no /bin/lsb_release available)
    # same as before the change
    x86_64--linux-gnu

  Note I intend to have Android respond with:

    {arch}-android-linux

  when I get to implementing Android lldb-gdbserver support.

llvm-svn: 199510
2014-01-17 20:18:59 +00:00
Greg Clayton 00fe87b488 Modified local spawning in debugserver processes to use a new --reverse-connect option so that debugserver actually connects back to LLDB instead of LLDB connecting to debugserver.
This gets rid of our hacky "get_random_port()" which would grab a random port and tell debugserver to open that port. Now LLDB creates, binds, listens and accepts a connection by binding to port zero and sending the correctly bound port down as the host:port to connect back to.

Fixed the "ConnectionFileDescriptor" to be able to correctly listen for connections from a specified host, localhost, or any host. Prior to this fix "listen://" only accepted the following format:

listen://<port>

But now it can accept:

listen://<port>         // Listen for connection from localhost on port <port>
listen://<host>:<port>  // Listen for connection from <host> and <port>    
listen://*:<port>       // Listen for connection from any host on port <port>

llvm-svn: 196547
2013-12-05 22:58:22 +00:00
Greg Clayton 5fb8f79738 Fixed internal code to not link against and code from "lldb/API/*".
lldb_private::Debugger was #including some "lldb/API" header files which causes tools (lldb-platform and lldb-gdbserver) that link against the internals only (no API layer) to fail to link depending on which calls were being used.

Also fixed the current working directory so that it gets set correctly for remote test suite runs. Now the remote working directory is set to: "ARCH/TESTNUM/..." where ARCH is the current architecture name and "TESTNUM" is the current test number. 

Fixed the "lldb-platform" and "lldb-gdbserver" to not warn about mismatched visibility settings by having each have their own exports file which contains nothing. This forces all symbols to not be exported, and also quiets the linker warnings.

llvm-svn: 196141
2013-12-02 19:35:49 +00:00
Greg Clayton fb90931b60 Improved platform support.
Improved the detection of a valid GDB server where we actually can connect to a socket, but then it doesn't read or write anything (which happens with some USB mux software).

Host::MakeDirectory() now can make as many intermediate directories as needed.

The testsuite now has very initial support for remote test suite running. When running on a remote platform, the setUp function for the test will make a new directory and select it as the working directory on the remote host. 

Added a common function that can be used to create the short option string for getopt_long calls.

llvm-svn: 195541
2013-11-23 01:58:15 +00:00
Greg Clayton d4724cfdb1 Make sure the getopt variables are correctly initialized for any option parsing.
Added a new "--port-offset PORT" option to lldb-platform so it can be used with USB mux type scenarios.

llvm-svn: 195486
2013-11-22 18:55:04 +00:00
Greg Clayton 904c145d4c Exit if launch doesn't succeed.
llvm-svn: 195371
2013-11-21 19:03:34 +00:00
Greg Clayton dd59dcb6d1 Added the ability to launch the program that was specified on the command line and have it waiting for a NativeProcessProtocol to attach.
llvm-svn: 195370
2013-11-21 18:58:35 +00:00
Greg Clayton be94a04055 Start the correct host abstraction of process and thread.
Added a new "Host/Debug.h" which contains the pure virtual class definitions for NativeProcessProtocol and NativeThreadProtocol. These classes are host layer classes that, over time, every host that supports debugging will implement once.

Then the new "lldb-gdbserver" binary in the tools directory will be able to make a remote debugging binary from these native classes, and we will also be able to have a new lldb_private::Process class that implements native debugging using these classes.

So as soon as linux and MacOSX switch over to using this layer, everyone will get native and remote debugging.

This check-in is primarily to get the needed code in so that poeple can start trying to implement the NativeProcessProtocol and NativeThreadProtocol and use it in the GDBRemoteCommunicationServer class to implement a GDB server for remote debugging.

llvm-svn: 195369
2013-11-21 18:39:32 +00:00