Commit Graph

500 Commits

Author SHA1 Message Date
Todd Fiala 726d6a12ad Fix MacOSX cmake build for new HostInfoMacOSX file.
Change by Stephane Sezer.

llvm-svn: 216948
2014-09-02 21:10:23 +00:00
Todd Fiala 4ceced3f59 Consolidate UnixSignals setting/getting in Process.
See http://reviews.llvm.org/D5108 for details.

This change does the following:

* eliminates the Process::GetUnixSignals() virtual method and replaces with a fixed getter.
* replaces the Process UnixSignals storage with a shared pointer.
* adds a Process constructor variant that can be passed the UnixSignalsSP. When the constructor without the UnixSignalsSP is specified, the Host's default UnixSignals is used.
* adds a host-specific version of GetUnixSignals() that is used when we need the host's appropriate UnixSignals variant.
* replaces GetUnixSignals() overrides in PlatformElfCore, ProcessGDBRemote, ProcessFreeBSD and ProcessLinux with code that appropriately sets the Process::UnixSignals for the process.

This change also enables some future patches that will enable llgs to be used for local Linux debugging.

llvm-svn: 216748
2014-08-29 17:35:57 +00:00
Todd Fiala 0b903a0f69 Ensure the Host wait4 thread is able to show pid in thread name.
For hosts that cannot support long thread names, shrink the host
wait4 thread name so that it does not truncate the PID in the thread name.

Change by Shawn Best.

llvm-svn: 216686
2014-08-28 21:21:39 +00:00
Todd Fiala a9882cee50 llgs: add proper exec support for Linux.
This change:
* properly captures execs in NativeProcessLinux.
* clears out all non-main-thread thread metadata in NativeProcessLinux on exec.
* adds a DidExec() method to the NativeProcessProtocol delegate.
* clears out the auxv data cache when we exec (on Linux).

This is a small part of the llgs for local Linux debugging work going on here:
https://github.com/tfiala/lldb/tree/dev-llgs-local

I'm breaking it into small patches.

llvm-svn: 216670
2014-08-28 15:46:54 +00:00
Zachary Turner 0b9bab48bb Fix linker error due to missing static variable instantiation.
llvm-svn: 216612
2014-08-27 20:44:26 +00:00
Zachary Turner 4e82ec9caa Create a HostProcess class.
This is a lightweight wrapper around a pid.  It is intended to be
lightweight enough to serve as a replacement anywhere we currently
store a pid.  It provides convenience methods and common process
operations.

This patch does not yet make use of HostProcess anywhere.

llvm-svn: 216607
2014-08-27 20:15:30 +00:00
Zachary Turner 58a559c07e Update LLDB to use LLVM's DynamicLibrary.
LLDB had implemented its own DynamicLibrary class for plugin
support.  LLVM has an equivalent mechanism, so this patch deletes
the duplicated code in LLDB and updates LLDB to reference the
mechanism provided by LLVM.

llvm-svn: 216606
2014-08-27 20:15:09 +00:00
Todd Fiala e4d6922ceb lldb AArch64 should be listed as yet another 64-bit architecture in HostInfoBase.
See http://reviews.llvm.org/D5070.

Change by Paul Osmialowski.

llvm-svn: 216556
2014-08-27 16:21:41 +00:00
Greg Clayton 0d8400c89c Change back all paths returns for lldb::PathType enumerations from HostInfo::GetLLDBPath() to return the directories in the FileSpec.m_directory field to match previous implementations. This change previously broke some path stuff in upstream branches.
llvm-svn: 216398
2014-08-25 18:21:06 +00:00
Keno Fischer 5777edf05c Resurect preprocessor definitions that got lost moving to HostInfo
When building without XCode on sytems where these constants are
not in the system header (or I presume with older versions of XCode),
these are needed to make this file compile, since unlike most other
uses of MachO specific constants, these use the system headers
rather than the LLVM-defined ones.

llvm-svn: 216332
2014-08-23 21:40:29 +00:00
Zachary Turner c25146b67b Fixes a few more places where we were manually setting the filename.
llvm-svn: 216247
2014-08-21 23:56:55 +00:00
Jason Molenda fb700b58cc Bump the verison number in the xcode project files.
llvm-svn: 216245
2014-08-21 23:27:02 +00:00
Jason Molenda 6fd86771f2 Two small fixes to get Mac native + debugserver working after the
HostInfo et al changes from Zachary.  Changes suggested by Zachary
- fixes the problems I was seeing.

llvm-svn: 216243
2014-08-21 23:22:33 +00:00
Zachary Turner a21fee0ee4 Move the rest of the HostInfo functions over.
This should bring HostInfo up to 99% completion.  The remainder
of code in Host will be split into instantiatable classes
representing host processes, threads, dynamic libraries, and
process launching strategies.

llvm-svn: 216230
2014-08-21 21:49:24 +00:00
Zachary Turner e47ffc3b42 Fix compile error on Linux due to previous commit.
llvm-svn: 216227
2014-08-21 21:02:47 +00:00
Zachary Turner b245ecac79 Move GetUsername and GetGroupname to HostInfoPosix
llvm-svn: 216210
2014-08-21 20:02:17 +00:00
Zachary Turner 673b6e4f3a Convert static constructors to be explicitly initialized at startup
llvm-svn: 216197
2014-08-21 17:57:03 +00:00
Zachary Turner 42ff0ad882 Move Host::GetLLDBPath to HostInfo.
This continues the effort to get Host code moved over to HostInfo,
and removes many more instances of preprocessor defines along the
way.

llvm-svn: 216195
2014-08-21 17:29:12 +00:00
Zachary Turner 75172a9567 Revert "Avoid global contstructors and place static variables
inside classes as static local variables and remove the static
ivars. Subclasses should use the accessor functions."

This change moved global statics to function local statics, but
forgot to make the locals static in the function, breaking all
platforms.  Furthermore, MSVC doesn't support thread-safe function
local statics, so any use of a function local static on non
primitive types is undefined behavior on MSVC.

Reverting due to the fact that it's broken on all platforms, but
would like to have a discussion about the thread-safety issue
before it goes back in.

llvm-svn: 216123
2014-08-20 20:53:05 +00:00
Greg Clayton 051fd7cc10 Avoid global contstructors and place static variables inside classes as static local variables and remove the static ivars. Subclasses should use the accessor functions.
llvm-svn: 216080
2014-08-20 17:00:21 +00:00
Zachary Turner 13b1826104 Move Host::GetArchitecture to HostInfo::GetArchitecture.
As a side effect, this patch also eliminates all of the
preprocessor conditionals previously used to implement
GetArchitecture().

llvm-svn: 216074
2014-08-20 16:42:51 +00:00
Zachary Turner c4a4110deb Add includes needed for FreeBSD.
llvm-svn: 216000
2014-08-19 18:38:53 +00:00
Zachary Turner 97a14e60b2 Move some Host logic into HostInfo class.
This patch creates a HostInfo class, a static class used to answer
basic queries about the host platform.  As part of this change,
some functionality is moved from Host to HostInfo, and relevant
fixups are performed in the rest of the codebase.

This is part of a larger effort to isolate more code in the Host
layer into platform-specific groups, to make it easier to make
platform specific changes for a particular Host without breaking
other hosts.

Reviewed by: Greg Clayton

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

llvm-svn: 215992
2014-08-19 17:18:29 +00:00
Zachary Turner 3ffabc2bce Fix an issue with source file groupings in the CMake build.
llvm-svn: 215901
2014-08-18 16:47:33 +00:00
Zachary Turner 4ec5d0d0e1 In the CMake build, convert lldbHost to be a single static library.
Previously lldbHost was built as multiple static libraries such as
lldbHostCommon, lldbHostLinux, etc.  With this patch, the CMake
build produces only a single static library, lldbHost, whose file
set is dynamically created based on the platform.

llvm-svn: 215792
2014-08-15 23:50:36 +00:00
Zachary Turner 3c19a6ac48 Try to fix the Make build
llvm-svn: 215782
2014-08-15 22:50:48 +00:00
Zachary Turner c00cf4a068 Move FileSystem functions out of Host and into their own classes.
More specifically, this change can be summarized as follows:
1) Makes an lldbHostPosix library which contains code common to
   all posix platforms.
2) Creates Host/FileSystem.h which defines a common FileSystem
   interface.
3) Implements FileSystem.h in Host/windows and Host/posix.
4) Creates Host/FileCache.h, implemented in Host/common, which
   defines a class useful for storing handles to open files needed
   by the debugger.

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

llvm-svn: 215775
2014-08-15 22:04:21 +00:00
Greg Clayton 5acc12550f Don't crash when specifying a core file that isn't readable.
Fixes include:
1 - added new FileSpec method: bool FileSpec::Readable()
2 - detect when an executable is not readable and give an appropriate error for:
    (lldb) file /tmp/unreadablefile
3 - detect when a core file is not readable and give an appropriate error
4 - detect when a specified core file doesn't exist and give an appropriate error
    
<rdar://problem/17727734>

llvm-svn: 215741
2014-08-15 18:00:45 +00:00
Zachary Turner 696b52878f Refactor FileAction out of ProcessLaunchInfo.
FileAction was previously a nested class in ProcessLaunchInfo.
This led to some unfortunate style consequences, such as requiring
the AddPosixSpawnFileAction() funciton to be defined in the Target
layer, instead of the more appropriate Host layer.  This patch
makes FileAction its own independent class in the Target layer,
and then moves AddPosixSpawnFileAction() into Host as a result.

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

llvm-svn: 215649
2014-08-14 16:01:25 +00:00
Saleem Abdulrasool 1abc1a5e14 Host: remove unused function
Remove unused static function identified by GCC 4.8.2.

llvm-svn: 215300
2014-08-09 22:25:06 +00:00
Zachary Turner e88be264de Implement some common file operations on Windows.
llvm-svn: 215273
2014-08-09 01:29:07 +00:00
Zachary Turner b6d9924439 Fix bug causing FileSpec::GetPath() to crash with a null dest.
llvm-svn: 215262
2014-08-08 23:54:35 +00:00
Jim Ingham e1d263eefc r215124 missed a few Mac OS X only uses of FileSpec::Resolve, fixing to match
the new signature.

llvm-svn: 215159
2014-08-07 22:37:43 +00:00
Ed Maste 42461e9f13 Use standard realloc so FreeBSD Host.cpp can use glibc
To fix building on Debian GNU/kFreeBSD, which uses the FreeBSD kernel
with a GNU userland.

llvm-svn: 215134
2014-08-07 19:28:02 +00:00
Zachary Turner 3f55974024 Optimizations for FileSpec.
llvm-svn: 215124
2014-08-07 17:33:36 +00:00
Zachary Turner df62f20c75 Fix FileSpec to be able to understand Windows paths.
This patch adds the notion of a "path syntax" to FileSpec.  There
are two syntaxes (Posix and Windows) and one "meta syntax",
Host Native, which uses the current platform to figure out the
appropriate syntax for host paths.

This allows paths from one platform to be represented and
manipulated on another platform even if they have different path
syntaxes.

llvm-svn: 215123
2014-08-07 17:33:07 +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
Greg Clayton 7fde1b3b83 Now that setting an architecture from a mach-o CPU type and subtype doesn't set the OS type, make sure to set it.
llvm-svn: 214600
2014-08-02 00:15:37 +00:00
Greg Clayton c76fa8a3eb Resolve the executable _before_ we try to get the module specifications.
Also fixed the host 32 and 64 bit arch to return "x86_64-apple-macosx" again instead of "x86_64-apple-" (unspecified OS) after recent changes.

<rdar://problem/17845078> 

llvm-svn: 214223
2014-07-29 21:27:21 +00:00
Zachary Turner 12f6f53618 [Windows] Delegate str[n]casecmp to the appropriate MSVCRT func.
llvm-svn: 214197
2014-07-29 19:08:55 +00:00
Zachary Turner d8a5273993 Fix compile error on Windows.
A piece of a future patch accidentally made it in, this simply
fixes the error.

llvm-svn: 214161
2014-07-29 05:39:21 +00:00
Zachary Turner 9e757b7ebe Use llvm Support functions to get the user's home directory.
Assuming that the user's home directory is at ~ is incorrect on
Windows.  This patch delegates the request to LLVM's support
library, which already provides a cross-platform implementation
of this function.

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

llvm-svn: 214093
2014-07-28 16:45:05 +00:00
Todd Fiala e88aea3234 Fix configure/make builds on MacOSX.
Change by Keno Fischer.

llvm-svn: 213904
2014-07-24 23:22:58 +00:00
Todd Fiala 015d818b59 Enable lldb-platform exe support for Linux.
This change enables lldb-platform for Linux.  In addition, it does the following:

* fixes Host::GetLLDBPath() to work on Linux/*BSD for ePathTypeSupportExecutableDir-relative paths.

* adds more logging and comments around lldb-platform startup and remote lldb-platform usage.

* refactors lldb-platform remote-* support for Darwin and Linux into PlatformPOSIX.  This, in theory, is the bulk of what is needed for *BSD to make remote connections to lldb-platform as well (although I haven't tested that yet).  FreeBSD can make similar changes to their Platform* as was made here for PlatformLinux to pick up the rest of the bits.

* teaches GDBRemoteCommunication to use lldb-gdbserver for non-Apple hosts.

llvm-svn: 213707
2014-07-22 23:41:36 +00:00
David Majnemer 8490da15a8 Host: Fix a pointer-to-function to void-pointer cast
reinterpret_cast may not convert a pointer-to-function to a
void-pointer.  Take a detour through intptr_t and *then* convert to a
pointer-to-function.

This silences a warning emitted by GCC when building LLDB.

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

llvm-svn: 213693
2014-07-22 22:00:42 +00:00
Zachary Turner c9bf0c70b5 Make lldb -P work on Windows.
lldb -P, which outputs its python path, works by using Host-layer
facilities to get information about the loaded python module.  This
Host functionality was unimplemented on Windows, so this patch
implements it.  Additionally, it removes a pexpect dependency from
the test runner and uses an equivalent invocation of subprocess.

Reviewed by: Todd Fiala

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

llvm-svn: 213410
2014-07-18 20:36:08 +00:00
Greg Clayton d46bb62610 Fixing warnings shouldn't introduce a crasher.
Fix the warning the correct way without making things crash when ENABLE_MUTEX_ERROR_CHECKING is non enabled.

<rdar://problem/17703039>

llvm-svn: 213394
2014-07-18 18:32:45 +00:00
Todd Fiala 17096d7669 Add Host::MAX_THREAD_NAME_LENGTH constant.
This value gets set to a max uint32_t value when there is no known limit; otherwise,
it is set to a value appropriate for the platform.  For the moment, only
Linux, FreeBSD and NetBSD set it to 16.  All other platforms set it to
the max uint32_t value.

Modifies the Process private state thread names to fit within a 16-character limit
when the max thread name length is <= 16.  These guarantee that the thread names
can be distinguished within the first 16 characters.  Prior to this change, those
threads had names in the final dotted name segment that were not distinguishable
within the first 16 characters.

llvm-svn: 213183
2014-07-16 19:03:16 +00:00
Greg Clayton 52edb364a1 lldb.LLDB_ARCH_DEFAULT now works correctly on Macs with haswell enabled kernels.
<rdar://problem/17604133>

llvm-svn: 213004
2014-07-14 22:53:02 +00:00
Zachary Turner df734cdd39 Fix tests broken by the OptionValidator changes.
The getopt library has a structure called option (lowercase).  We
have a structure called Option (uppercase).  previously the two
structures had exactly the same definitions, and we were doing a
C-style cast of an Option* to an option*.  C-style casts don't
bother to warn you when you cast to unrelated types, but in the
original OptionValidator patch I modified the definition of Option.

This patch fixes the errors by building an array of option
structures and filling it out the correct way before passing it to
the getopt library.

This also fixes one other source of test failures: an uninitialized
read that occurs due to not initializing a field of the
OptionDefinition.

Reviewed By: Todd Fiala

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

llvm-svn: 212628
2014-07-09 16:32:07 +00:00