History log of /external/lldb/source/Host/common/Host.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
a984aa968d40e16e6fe2d53bb0eb64a54964f439 06-Aug-2013 Daniel Malea <daniel.malea@intel.com> Fix bug in Host::getLLDBPath() due to misusing Twine
- use SmallString instead
- original implementation resulted in incorrect behaviour of lldb -P

Fix by Kal Conley!



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@187818 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
7526625a76ca97a2637749b0cc4068bf0bd907fb 01-Aug-2013 Michael Sartain <mikesart@valvesoftware.com> Fix Linux Host::GetCurrentThreadID() to return real tid (not pthread_t).
This fixes threadname logging (--thread-name)
Add "-t" to TestLogging.py script to enable threadsafe and disable threadname logging



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@187599 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
f476592805f813aa7a94f7d6770481503140aae2 25-Jul-2013 Ed Maste <emaste@freebsd.org> Set thread names on FreeBSD

Also move the logic to shorten thread names from linux/Host.cpp to a new
SetShortThreadName as both FreeBSD and Linux need the functionality.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@187149 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
0bbfea68d47cc401b6f8309acc788d8224401ed6 17-Jul-2013 Michael Sartain <mikesart@valvesoftware.com> simple plugin now works with Linux fix assert in SetPluginInfo implement Linux ePathTypeLLDBSystemPlugins and ePathTypeLLDBUserPlugins implement Linux Host::Backtrace and Host::GetEnvironment add .gnu_debugdata comment

Differential Revision: http://llvm-reviews.chandlerc.com/D1159

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@186475 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
0ba7548c72ed9a242415cb78f2351146d7afe3b7 10-Jul-2013 Matt Kopec <Matt.Kopec@intel.com> Add support for listing inferior thread names on Linux.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@186033 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
ca14706d1e1c22f60b2d0793a96f3385d9d2d115 02-Jul-2013 Ed Maste <emaste@freebsd.org> Fix build with LLVM_DISABLE_PYTHON



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@185466 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
fa2cd91f47a7782b9c040058aed369e022e332d3 01-Jul-2013 Sylvestre Ledru <sylvestre@debian.org> Following the modification introduced in llvm by commit 185311

The build system is currently miss-identifying GNU/kFreeBSD as FreeBSD.
This kind of simplification is sometimes useful, but in general it's not correct.

As GNU/kFreeBSD is an hybrid system, for kernel-related issues we want to match the
build definitions used for FreeBSD, whereas for userland-related issues we want to
match the definitions used for other systems with Glibc.

The current modification adjusts the build system so that they can be distinguished,
and explicitly adds GNU/kFreeBSD to the build checks in which it belongs.

Fixes bug #16446.

Patch by Robert Millan in the context of Debian.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@185313 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
3f7faa8002b74d7264ad16616fc4294e07aa2b2f 28-Jun-2013 Ed Maste <emaste@freebsd.org> Move sys/sysctl.h include after its dependency sys/types.h



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@185147 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
750fc7ffc57a863940087366520234581f27043b 25-Jun-2013 Ed Maste <emaste@freebsd.org> Correct use of __FreeBSD_kernel__

It is defined on recent FreeBSD versions, so must not be mutually
exclusive with an #elif FreeBSD block.

Patch submitted by Robert Millan.

Fixes PR#16447.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@184867 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
c350e13fd3351613345141bee7d8b2543df54636 01-Jun-2013 Matt Kopec <Matt.Kopec@intel.com> Add ability to attach/detach to multi-threaded inferiors on Linux.
All running threads will be detected and stopped on attach and all threads get resumed on detach.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@183049 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
3bd2ebd670677dae45010bf53084ff85da7c6a5e 29-May-2013 Andrew Kaylor <andrew.kaylor@intel.com> Adding support for stopping all threads of multithreaded inferiors on Linux. Also adding multithreaded test cases.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@182809 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
0c2921f5b9dab2ca1832bb746ab3aa3f66fdd0b5 15-May-2013 Jim Ingham <jingham@apple.com> Fixed a few obvious errors pointed out by the static analyzer.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181911 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
9b4c5483a697a45744975c395de08b06a6c7d1d0 15-May-2013 Daniel Malea <daniel.malea@intel.com> Implement "platform process list" on Linux
- read process information from /proc
- resolves llvm.org/pr14541 :)

Patch by Mike Sartain!



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181904 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
780b209138d95210812da36f383e7e7d910f83c8 15-May-2013 Sylvestre Ledru <sylvestre@debian.org> Include also sys/wait.h in the case of a FreeBSD kernel with a glibc (Debian KFreeBSD for example)

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181885 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
024497728739eedffc9b79c28337fba22f07f8b4 13-May-2013 Matt Kopec <Matt.Kopec@intel.com> Add setting of lldb thread names on Linux.

Patch by Mike Sartain.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181722 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
6c1a8cfbb81ae38aee68f281b2af4010044cc00d 08-May-2013 Andrew Kaylor <andrew.kaylor@intel.com> Adding support for process attach by pid on Linux.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@181374 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
32657deb2327a78d8d924a48260106bfa74b6b52 01-May-2013 Ashok Thirumurthi <ashok.thirumurthi@intel.com> Build fixes for FreeBSD 9.1.
- TODO: Support extended register sets on FreeBSD.

Patch by Samuel Jacob.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@180879 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
102b2c2681c9a830afe25bfea35557421905e42c 19-Apr-2013 Greg Clayton <gclayton@apple.com> After discussing with Chris Lattner, we require C++11, so lets get rid of the macros and just use C++11.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@179805 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
81a96aa6242f7b559770f5dc62316253cb8cb0d4 18-Apr-2013 Greg Clayton <gclayton@apple.com> Since we use C++11, we should switch over to using std::unique_ptr when C++11 is being used. To do this, we follow what we have done for shared pointers and we define a STD_UNIQUE_PTR macro that can be used and it will "do the right thing". Due to some API differences in std::unique_ptr and due to the fact that we need to be able to compile without C++11, we can't use move semantics so some code needed to change so that it can compile with either C++.

Anyone wanting to use a unique_ptr or auto_ptr should now use the "STD_UNIQUE_PTR(TYPE)" macro.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@179779 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
952e9dc874944fcdbbb224f3ec4fc2c859376f64 28-Mar-2013 Greg Clayton <gclayton@apple.com> <rdar://problem/13521159>

LLDB is crashing when logging is enabled from lldb-perf-clang. This has to do with the global destructor chain as the process and its threads are being torn down.

All logging channels now make one and only one instance that is kept in a global pointer which is never freed. This guarantees that logging can correctly continue as the process tears itself down.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@178191 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
6f0165b3dc0ecc689f565c792e53dd3397b4a432 27-Feb-2013 Greg Clayton <gclayton@apple.com> Fixed a case where the result of std::string's c_str() method was being called on a local variable and returned as a const char * incorrectly. We used to cache the thread names for threads in the current host process, but we shoudn't be caching that as the names can change over time, so now a std::string is returned from Host::GetThreadName().



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@176217 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
132c49a1c94927a2e1da9e7b383a2512af3b75ee 17-Feb-2013 Greg Clayton <gclayton@apple.com> Added a host call to get the number of CPUs. It should work on all POSIX unixes, linux and Windows.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@175405 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
f1fda3748c39c92d2e79aeba0715baffabd3286b 08-Jan-2013 Matt Kopec <Matt.Kopec@intel.com> Add initial support to trace spawned threads in a process on Linux.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@171864 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
21e32a6354ca6a318332e5e0b32d04c984a4708a 05-Jan-2013 Daniel Malea <daniel.malea@intel.com> Fix lldb -P on Linux
- now prints the correct PYTHONPATH
- update dotest.py to use lldb -P result correctly
- resolves TestPublicAPIHeaders test failure (on Linux)



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@171558 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
d35b7b3bfd21f4fd6b048693563eef1b772ae197 07-Dec-2012 Daniel Malea <daniel.malea@intel.com> More Linux warnings fixes (remove default labels as needed):
- as per http://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations

Patch by Matt Kopec!




git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@169633 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
d891f9b872103235cfd2ed452c6f14a4394d9b3a 05-Dec-2012 Daniel Malea <daniel.malea@intel.com> Fix Linux build warnings due to redefinition of macros:
- add new header lldb-python.h to be included before other system headers
- short term fix (eventually python dependencies must be cleaned up)

Patch by Matt Kopec!




git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@169341 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
5f35a4be95aed0e5b2cb36f7d785bcbfc67284ae 29-Nov-2012 Daniel Malea <daniel.malea@intel.com> Resolve printf formatting warnings on Linux:
- use macros from inttypes.h for format strings instead of OS-specific types

Patch from Matt Kopec!



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@168945 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
124522186fef54f53d86c9195ad0a3b62bbcf027 19-Nov-2012 Daniel Malea <daniel.malea@intel.com> Linux fix: remove reference to cellspu (backend removed in llvm r167984)



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@168322 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
ed0a0fbd021e44727469d6fa20cc337c58bd04c3 18-Oct-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/12462048>
<rdar://problem/12068650>

More fixes to how we handle paths that are used to create a target.

This modification centralizes the location where and how what the user specifies gets resolved. Prior to this fix, the TargetList::CreateTarget variants took a FileSpec object which meant everyone had the opportunity to resolve the path their own way. Now both CreateTarget variants take a "const char *use_exe_path" which allows the TargetList::CreateTarget to centralize where the resolving happens and "do the right thing".




git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@166186 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
0c8446cc220c429fb51f8f9864275c8b1c768533 18-Oct-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/12462048>

LLDB changes argv[0] when debugging a symlink. Now we have the notion of argv0 in the target settings:

target.arg0 (string) =

There is also the program argument that are separate from the first argument that have existed for a while:

target.run-args (arguments) =

When running "target create <exe>", we will place the untouched "<exe>" into target.arg0 to ensure when we run, we run with what the user typed. This has been added to the ProcessLaunchInfo and all other needed places so we always carry around the:
- resolved executable path
- argv0
- program args

Some systems may not support separating argv0 from the resolved executable path and the ProcessLaunchInfo needs to carry all of this information along so that each platform can make that decision.




git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@166137 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
d1f0376029e7843a3ff21d8f1d0c1842d61c55dd 12-Oct-2012 Greg Clayton <gclayton@apple.com> Patch from Andrew Kaylor that centralized where the info for:

ConstString Host::GetVendorString();
ConstString Host::GetOSString();

comes from. It now all comes from the Host::GetArchitecture (eSystemDefaultArchitecture) like the Apple build was doing to minimize the number of places that need to be updated when Host::GetArchitecture () is called.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@165805 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
7971a03710f98eb936a750ce5e860ae429d394cd 11-Oct-2012 Greg Clayton <gclayton@apple.com> Patch from Andrew Kaylor that fixes Linux default host triple values.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@165728 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
b924eb6c5250a9909dc55ac736d231f7ccae423b 27-Sep-2012 Greg Clayton <gclayton@apple.com> Added the ability to download a symboled executable and symbol file given a UUID.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@164753 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
e93725bec81a4433756b2acfa3adc7223bc51a9a 18-Sep-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/12219840>

Don't leak mach ports when calling "mach_thread_self()".



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@164152 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
1a450cd9bc58d024c81501fada890d6947720bbb 07-Sep-2012 Greg Clayton <gclayton@apple.com> Patch from Andrew Kaylor for linux:


The attached patch adds support for debugging 32-bit processes when running a 64-bit lldb on an x86_64 Linux system.

Making this work required two basic changes:

1) Getting lldb to report that it could debug 32-bit processes
2) Changing an assumption about how ptrace works when debugging cross-platform

For the first change, I took a conservative approach and only enabled this for x86_64 Linux platforms. It may be that the change I made in Host.cpp could be extended to other 64-bit Linux platforms, but I'm not familiar enough with the other platforms to know for sure.

For the second change, the Linux ProcessMonitor class was assuming that ptrace(PTRACE_[PEEK|POKE]DATA...) would read/write a "word" based on the child process word size. However, the ptrace documentation says that the "word" size read or written is "determined by the OS variant." I verified experimentally that when ptracing a 32-bit child from a 64-bit parent a 64-bit word is read or written.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@163398 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
67aa5b6d71518b3be449344e271a03a96fc6b48d 30-Jul-2012 Filipe Cabecinhas <me@filcab.net> Make glibc and its developers happy. Circumvent the lack of strlcat in glibc.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@160979 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
df80272eecb8b494866980243c5cef76818b1a91 30-Jul-2012 Filipe Cabecinhas <me@filcab.net> Fixed ePathTypePythonDir for Linux and FreeBSD (at least). This works for non-installed compilations. I will test further.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@160963 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
f7d782b70647870cdf3c2683b3a027660a9534d5 19-May-2012 Filipe Cabecinhas <me@filcab.net> Fixes the case where we created a dummy target, deleted it, and then tried to evaluate an expression with no target.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@157110 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
f42d3f66e0c7bf42fca852e643eb4b4ae540c4c6 17-May-2012 Filipe Cabecinhas <me@filcab.net> We shouldn't save g_dummy_target_sp. Other code will simply call Destroy() on it.

TestBackticksWithoutATarget.BackticksWithNoTargetTestCase was calling
GetDummyTarget() when executing for x86_64. When performing session
tearDown, it would get destroyed (and everything would be invalid (arch,
etc).

Then the test would run for i386. The dummy target wasn't being
reinitialized and was invalid. lldb complained that 'current process state
is unsuitable for expression parsing'.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@156994 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
469e08dc1f776a3401c62ff60afb1978d5659e72 15-May-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/11451919>

Fixed the test suite not working on i386 due to recent default arch detection changes.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@156796 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
ca0761b02bdddb54005a699b37bb73ed9d76c623 12-May-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/11439169>

"lldb -a i386" doesn't set the calculator mode correctly if run on a 64 bit system.

The previous logic always used the current host architecture, not the default architecture. The default arch gets set into a static varaible in lldb_private::Target when an arch is set from the command line:

lldb -a i386

We now use the default arch correctly.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@156680 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
5b0025fb034bfa6d4ee639f6342f56d9845ada7b 12-May-2012 Greg Clayton <gclayton@apple.com> <rdar://problem/11439022>

Restore expressions with no target.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@156669 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
35dd496005e197ca80e6becc47932ee0cfdf92c5 04-May-2012 Jim Ingham <jingham@apple.com> Fix a think in Mutex::Locker::Locker(pthread_mutex_t *) Really should lock the mutex handed in, not the m_mutex_ptr that you've set to NULL...
Rework the Host.cpp::ThreadNameAccessor to use ThreadSafeSTLMap - we've got it so we might as well use it. Also works around a problem with the
Mutex::Locker class raising fallacious asserts in debug mode when used with pthread_mutex_t's that weren't backed by Mutex objects.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@156193 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
97471184b8823c949bc68bbf54ea3edf3845a750 14-Apr-2012 Greg Clayton <gclayton@apple.com> Added a new host function that allows us to run shell command and get the output from them along with the status and signal:

Error
Host::RunShellCommand (const char *command,
const char *working_dir,
int *status_ptr,
int *signo_ptr,
std::string *command_output_ptr,
uint32_t timeout_sec);

This will allow us to use this functionality in the host lldb_private::Platform, and also use it in our lldb-platform binary. It leverages the existing code in Host::LaunchProcess and ProcessLaunchInfo.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@154730 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
1831e78a6253392fca1c99e555e7adaa3f372647 07-Apr-2012 Jim Ingham <jingham@apple.com> We sometimes need to be able to call functions (via Process::RunThreadPlan) from code run on the private state thread. To do that we have to
spin up a temporary "private state thread" that will respond to events from the lower level process plugins. This check-in should work to do
that, but it is still buggy. However, if you don't call functions on the private state thread, these changes make no difference.

This patch also moves the code in the AppleObjCRuntime step-through-trampoline handler that might call functions (in the case where the debug
server doesn't support the memory allocate/deallocate packet) out to a safe place to do that call.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@154230 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
d1040dd360c07305a30d33b5d4501cb9dfb03114 25-Feb-2012 Han Ming Ong <hanming@apple.com> <rdar://problem/3535148>

Added ability to debug root processes on OS X. This uses XPC service that is available on Lion and above only.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@151419 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
9ce953807eb814a93b449dc243de4f7bf32c3115 14-Feb-2012 Greg Clayton <gclayton@apple.com> Full core file support has been added for mach-o core files.

Tracking modules down when you have a UUID and a path has been improved.

DynamicLoaderDarwinKernel no longer parses mach-o load commands and it
now uses the memory based modules now that we can load modules from memory.

Added a target setting named "target.exec-search-paths" which can be used
to supply a list of directories to use when trying to look for executables.
This allows one or more directories to be used when searching for modules
that may not exist in the SDK/PDK. The target automatically adds the directory
for the main executable to this list so this should help us in tracking down
shared libraries and other binaries.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@150426 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
df6dc88322f103b263092d752db4490e628a1cbd 05-Jan-2012 Greg Clayton <gclayton@apple.com> Added code in the Host layer that can report system log messages
so that we don't have "fprintf (stderr, ...)" calls sprinkled everywhere.
Changed all needed locations over to using this.

For non-darwin, we log to stderr only. On darwin, we log to stderr _and_
to ASL (Apple System Log facility). This will allow GUI apps to have a place
for these error and warning messages to go, and also allows the command line
apps to log directly to the terminal.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@147596 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
c518fe7609f40c3b00eaa29e5596e59aeac7d4ba 17-Nov-2011 Greg Clayton <gclayton@apple.com> Now that I fixed the uninitialized callback problem, I can enable GCD pid
monitoring on darwin in the host layer.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144918 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
1c4642c6ab741d85c98d4288cf922c9a2ef77007 16-Nov-2011 Greg Clayton <gclayton@apple.com> Made the darwin host layer properly reap any child processes that it spawns.
After recent changes we weren't reaping child processes resulting in many
zombie processes.

This was fixed by adding more settings to the ProcessLaunchOptions class
that allow clients to specify a callback function and baton to be notified
when their process dies. If one is not supplied a default callback will be
used that "does the right thing".

Cleaned up a race condition in the ProcessGDBRemote class that would attempt
to monitor when debugserver died.

Added an extra boolean to the process monitor callbacks that indicate if a
process exited or not. If your process exited with a zero exit status and no
signal, both items could be zero.

Modified the process monitor functions to not require a callback function
in order to reap the child process.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144780 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
b47c99887354d7b3e2875703c0de5cb398190b2c 05-Nov-2011 Peter Collingbourne <peter@pcc.me.uk> Update a missed getHostTriple call, fixes non-__APPLE__ build

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@143774 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
06c306cce353ec1bc413a2d61fc79c5f1161efb4 04-Nov-2011 Benjamin Kramer <benny.kra@googlemail.com> Fix linux build after r143679.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@143703 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
193cc83d10ec6a780c9d80c429638a8cd42a0952 04-Nov-2011 Greg Clayton <gclayton@apple.com> Fixed a build issue on an older Xcode.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@143679 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
3e4238d47a6d1a3106f357d2e7b495870721c7ae 04-Nov-2011 Greg Clayton <gclayton@apple.com> Fixed the Xcode project building of LLVM to be a bit more user friendly:

- If you download and build the sources in the Xcode project, x86_64 builds
by default using the "llvm.zip" checkpointed LLVM.
- If you delete the "lldb/llvm.zip" and the "lldb/llvm" folder, and build the
Xcode project will download the right LLVM sources and build them from
scratch
- If you have a "lldb/llvm" folder already that contains a "lldb/llvm/lib"
directory, we will use the sources you have placed in the LLDB directory.

Python can now be disabled for platforms that don't support it.

Changed the way the libllvmclang.a files get used. They now all get built into
arch specific directories and never get merged into universal binaries as this
was causing issues where you would have to go and delete the file if you wanted
to build an extra architecture slice.



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@143678 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
2dc22608375075113d9b4d01aa2f023f06ea95ff 03-Nov-2011 Benjamin Kramer <benny.kra@googlemail.com> The alpha and system z backends were removed.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@143613 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
f35a96c63732a1b3adf875ea44c7d3d7de6f8eec 27-Oct-2011 Sean Callanan <scallanan@apple.com> Added a function to the Host that gets a dummy target
for it, so that people who want to use LLDB as a
calculator can run simple expressions without needing
a target or process.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@143147 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
5f0559d972936a26d6571df94d7aabf989eb97e9 05-Aug-2011 Peter Collingbourne <peter@pcc.me.uk> Complete Host::Backtrace prototype. Fixes Linux build.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@136951 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
4b66329ac82b5f3d939bd31b4d1498da9257d85a 02-Aug-2011 Johnny Chen <johnny.chen@apple.com> Patch by David Forsythe to build lldb on FreeBSD!

I did not take the patch for ClangExpressionParser.cpp since there was a
recent change by Peter for the same line. Feel free to disagree. :-)

Reference:
----------------------------------------------------------------------
r136580 | pcc | 2011-07-30 15:42:24 -0700 (Sat, 30 Jul 2011) | 3 lines

Add reloc arg to standard JIT createJIT()

Fixes non-__APPLE__ build. Patch by Matt Johnson!
----------------------------------------------------------------------

Also, I ignore the part of the patch to remove the RegisterContextDarwin*.h/.cpp.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@136720 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
2bc9eb3ba78efc64a273729b480bafc3bbaa433a 19-Jul-2011 Johnny Chen <johnny.chen@apple.com> Patch by Matt Johnson to silence G++ warnings!
Used hand merge to apply the diffs. I did not apply the diffs for FormatManager.h and
the diffs for memberwise initialization for ValueObject.cpp because they changed since.
I will ask my colleague to apply them later.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@135508 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
de9eadc2e60fe8b5df20e9cf93af5c9290c08099 13-May-2011 Johnny Chen <johnny.chen@apple.com> This method has been removed from the API. This fix the compilation
breakage due to its presence.

Patch by Marco Minutoli <mminutoli@gmail.com>


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@131303 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
b72d0f098e45936fa72e26b1a026c603e17e2d6c 12-Apr-2011 Greg Clayton <gclayton@apple.com> Moved the execution context that was in the Debugger into
the CommandInterpreter where it was always being used.

Make sure that Modules can track their object file offsets correctly to
allow opening of sub object files (like the "__commpage" on darwin).

Modified the Platforms to be able to launch processes. The first part of this
move is the platform soon will become the entity that launches your program
and when it does, it uses a new ProcessLaunchInfo class which encapsulates
all process launching settings. This simplifies the internal APIs needed for
launching. I want to slowly phase out process launching from the process
classes, so for now we can still launch just as we used to, but eventually
the platform is the object that should do the launching.

Modified the Host::LaunchProcess in the MacOSX Host.mm to correctly be able
to launch processes with all of the new eLaunchFlag settings. Modified any
code that was manually launching processes to use the Host::LaunchProcess
functions.

Fixed an issue where lldb_private::Args had implicitly defined copy
constructors that could do the wrong thing. This has now been fixed by adding
an appropriate copy constructor and assignment operator.

Make sure we don't add empty ModuleSP entries to a module list.

Fixed the commpage module creation on MacOSX, but we still need to train
the MacOSX dynamic loader to not get rid of it when it doesn't have an entry
in the all image infos.

Abstracted many more calls from in ProcessGDBRemote down into the
GDBRemoteCommunicationClient subclass to make the classes cleaner and more
efficient.

Fixed the default iOS ARM register context to be correct and also added support
for targets that don't support the qThreadStopInfo packet by selecting the
current thread (only if needed) and then sending a stop reply packet.

Debugserver can now start up with a --unix-socket (-u for short) and can
then bind to port zero and send the port it bound to to a listening process
on the other end. This allows the GDB remote platform to spawn new GDB server
instances (debugserver) to allow platform debugging.







git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@129351 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
ec2d9787bed36e9eda6eac1996c7bed76c8d3da4 08-Apr-2011 Stephen Wilson <wilsons@start.ca> Add missing headers.

Something changed in commit r129112 where a few standard headers vanished from
the include chain when building on Linux. Fix up by including limits.h for
INT_MAX and PATH_MAX where needed, and stdio.h for printf().



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@129130 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
24bc5d9bfad2a1c562c27e7cf37e1c56d85c45e7 30-Mar-2011 Greg Clayton <gclayton@apple.com> Many improvements to the Platform base class and subclasses. The base Platform
class now implements the Host functionality for a lot of things that make
sense by default so that subclasses can check:

int
PlatformSubclass::Foo ()
{
if (IsHost())
return Platform::Foo (); // Let the platform base class do the host specific stuff

// Platform subclass specific code...
int result = ...
return result;
}

Added new functions to the platform:

virtual const char *Platform::GetUserName (uint32_t uid);
virtual const char *Platform::GetGroupName (uint32_t gid);

The user and group names are cached locally so that remote platforms can avoid
sending packets multiple times to resolve this information.

Added the parent process ID to the ProcessInfo class.

Added a new ProcessInfoMatch class which helps us to match processes up
and changed the Host layer over to using this new class. The new class allows
us to search for processs:
1 - by name (equal to, starts with, ends with, contains, and regex)
2 - by pid
3 - And further check for parent pid == value, uid == value, gid == value,
euid == value, egid == value, arch == value, parent == value.

This is all hookup up to the "platform process list" command which required
adding dumping routines to dump process information. If the Host class
implements the process lookup routines, you can now lists processes on
your local machine:

machine1.foo.com % lldb
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari
94727 244 username usergroup username usergroup x86_64-apple-darwin Xcode
92742 92710 username usergroup username usergroup i386-apple-darwin debugserver


This of course also works remotely with the lldb-platform:

machine1.foo.com % lldb-platform --listen 1234

machine2.foo.com % lldb
(lldb) platform create remote-macosx
Platform: remote-macosx
Connected: no
(lldb) platform connect connect://localhost:1444
Platform: remote-macosx
Triple: x86_64-apple-darwin
OS Version: 10.6.7 (10J869)
Kernel: Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
Hostname: machine1.foo.com
Connected: yes
(lldb) platform process list
PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE NAME
====== ====== ========== ========== ========== ========== ======================== ============================
99556 244 username usergroup username usergroup x86_64-apple-darwin trustevaluation
99548 65539 username usergroup username usergroup x86_64-apple-darwin lldb
99538 1 username usergroup username usergroup x86_64-apple-darwin FileMerge
94943 1 username usergroup username usergroup x86_64-apple-darwin mdworker
94852 244 username usergroup username usergroup x86_64-apple-darwin Safari

The lldb-platform implements everything with the Host:: layer, so this should
"just work" for linux. I will probably be adding more stuff to the Host layer
for launching processes and attaching to processes so that this support should
eventually just work as well.

Modified the target to be able to be created with an architecture that differs
from the main executable. This is needed for iOS debugging since we can have
an "armv6" binary which can run on an "armv7" machine, so we want to be able
to do:

% lldb
(lldb) platform create remote-ios
(lldb) file --arch armv7 a.out

Where "a.out" is an armv6 executable. The platform then can correctly decide
to open all "armv7" images for all dependent shared libraries.

Modified the disassembly to show the current PC value. Example output:

(lldb) disassemble --frame
a.out`main:
0x1eb7: pushl %ebp
0x1eb8: movl %esp, %ebp
0x1eba: pushl %ebx
0x1ebb: subl $20, %esp
0x1ebe: calll 0x1ec3 ; main + 12 at test.c:18
0x1ec3: popl %ebx
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf
0x1edb: leal 213(%ebx), %eax
0x1ee1: movl %eax, (%esp)
0x1ee4: calll 0x1f1e ; puts
0x1ee9: calll 0x1f0c ; getchar
0x1eee: movl $20, (%esp)
0x1ef5: calll 0x1e6a ; sleep_loop at test.c:6
0x1efa: movl $12, %eax
0x1eff: addl $20, %esp
0x1f02: popl %ebx
0x1f03: leave
0x1f04: ret

This can be handy when dealing with the new --line options that was recently
added:

(lldb) disassemble --line
a.out`main + 13 at test.c:19
18 {
-> 19 printf("Process: %i\n\n", getpid());
20 puts("Press any key to continue..."); getchar();
-> 0x1ec4: calll 0x1f12 ; getpid
0x1ec9: movl %eax, 4(%esp)
0x1ecd: leal 199(%ebx), %eax
0x1ed3: movl %eax, (%esp)
0x1ed6: calll 0x1f18 ; printf

Modified the ModuleList to have a lookup based solely on a UUID. Since the
UUID is typically the MD5 checksum of a binary image, there is no need
to give the path and architecture when searching for a pre-existing
image in an image list.

Now that we support remote debugging a bit better, our lldb_private::Module
needs to be able to track what the original path for file was as the platform
knows it, as well as where the file is locally. The module has the two
following functions to retrieve both paths:

const FileSpec &Module::GetFileSpec () const;
const FileSpec &Module::GetPlatformFileSpec () const;





git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128563 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
b344843f75ef893762c93fd0a22d2d45712ce74d 24-Mar-2011 Greg Clayton <gclayton@apple.com> Fixed the LLDB build so that we can have private types, private enums and
public types and public enums. This was done to keep the SWIG stuff from
parsing all sorts of enums and types that weren't needed, and allows us to
abstract our API better.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128239 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
58e26e0935138225477fd61283215ceff2068899 24-Mar-2011 Greg Clayton <gclayton@apple.com> Did a lot more work on abtracting and organizing the platforms.

On Mac OS X we now have 3 platforms:
PlatformDarwin - must be subclassed to fill in the missing pure virtual funcs
but this implements all the common functionality between
remote-macosx and remote-ios. It also allows for another
platform to be used (remote-gdb-server for now) when doing
remote connections. Keeping this pluggable will allow for
flexibility.
PlatformMacOSX - Now implements both local and remote macosx desktop platforms.
PlatformRemoteiOS - Remote only iOS that knows how to locate SDK files in the
cached SDK locations on the host.

A new agnostic platform has been created:
PlatformRemoteGDBServer - this implements the platform using the GDB remote
protocol and uses the built in lldb_private::Host
static functions to implement many queries.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128193 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
a733c04608cc94592a15d27583529588e19db552 21-Mar-2011 Greg Clayton <gclayton@apple.com> Added real user/group id, effective user/group id, and parent
process ID to the ProcessInfo.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@128023 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
e4b9c1fb338ee1ada72e6a3c198afb342d68c5c1 08-Mar-2011 Greg Clayton <gclayton@apple.com> LLDB now has "Platform" plug-ins. Platform plug-ins are plug-ins that provide
an interface to a local or remote debugging platform. By default each host OS
that supports LLDB should be registering a "default" platform that will be
used unless a new platform is selected. Platforms are responsible for things
such as:
- getting process information by name or by processs ID
- finding platform files. This is useful for remote debugging where there is
an SDK with files that might already or need to be cached for debug access.
- getting a list of platform supported architectures in the exact order they
should be selected. This helps the native x86 platform on MacOSX select the
correct x86_64/i386 slice from universal binaries.
- Connect to remote platforms for remote debugging
- Resolving an executable including finding an executable inside platform
specific bundles (macosx uses .app bundles that contain files) and also
selecting the appropriate slice of universal files for a given platform.

So by default there is always a local platform, but remote platforms can be
connected to. I will soon be adding a new "platform" command that will support
the following commands:
(lldb) platform connect --name machine1 macosx connect://host:port
Connected to "machine1" platform.
(lldb) platform disconnect macosx

This allows LLDB to be well setup to do remote debugging and also once
connected process listing and finding for things like:
(lldb) process attach --name x<TAB>

The currently selected platform plug-in can now auto complete any available
processes that start with "x". The responsibilities for the platform plug-in
will soon grow and expand.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@127286 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
7f513ba286dff6c8b12ccb910ec4435eef488e9b 24-Feb-2011 Stephen Wilson <wilsons@start.ca> Host: linux: Use llvm::sys::getHostTriple for the default host ArchSpec.

Previously we were using a set of preprocessor defines and returning an ArchSpec
without any OS/Vendor information. This fixes an issue with plugin resolution
on Linux where a valid OS component is needed.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@126404 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
940b103224f3062578c7a7e6e76d8bf4a7956f2a 23-Feb-2011 Greg Clayton <gclayton@apple.com> Abtracted all mach-o and ELF out of ArchSpec. This patch is a modified form
of Stephen Wilson's idea (thanks for the input Stephen!). What I ended up
doing was:
- Got rid of ArchSpec::CPU (which was a generic CPU enumeration that mimics
the contents of llvm::Triple::ArchType). We now rely upon the llvm::Triple
to give us the machine type from llvm::Triple::ArchType.
- There is a new ArchSpec::Core definition which further qualifies the CPU
core we are dealing with into a single enumeration. If you need support for
a new Core and want to debug it in LLDB, it must be added to this list. In
the future we can allow for dynamic core registration, but for now it is
hard coded.
- The ArchSpec can now be initialized with a llvm::Triple or with a C string
that represents the triple (it can just be an arch still like "i386").
- The ArchSpec can still initialize itself with a architecture type -- mach-o
with cpu type and subtype, or ELF with e_machine + e_flags -- and this will
then get translated into the internal llvm::Triple::ArchSpec + ArchSpec::Core.
The mach-o cpu type and subtype can be accessed using the getter functions:

uint32_t
ArchSpec::GetMachOCPUType () const;

uint32_t
ArchSpec::GetMachOCPUSubType () const;

But these functions are just converting out internal llvm::Triple::ArchSpec
+ ArchSpec::Core back into mach-o. Same goes for ELF.

All code has been updated to deal with the changes.

This should abstract us until later when the llvm::TargetSpec stuff gets
finalized and we can then adopt it.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@126278 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
4fefe326fba2e20d2cd81597334064918cbb4a90 17-Feb-2011 Greg Clayton <gclayton@apple.com> Modified version of Marco Minutoli's host arch patch.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125706 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
75c703dd8b492bad25a987b96853626641ae7246 16-Feb-2011 Greg Clayton <gclayton@apple.com> The DynamicLoader plug-in instance now lives up in lldb_private::Process where
it should live and the lldb_private::Process takes care of managing the
auto pointer to the dynamic loader instance.

Also, now that the ArchSpec contains the target triple, we are able to
correctly set the Target architecture in DidLaunch/DidAttach in the subclasses,
and then the lldb_private::Process will find the dynamic loader plug-in
by letting the dynamic loader plug-ins inspect the arch/triple in the target.

So now the ProcessGDBRemote plug-in is another step closer to be purely
process/platform agnostic.

I updated the ProcessMacOSX and the ProcessLinux plug-ins accordingly.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125650 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
395fc33dc4b06c048ed35047ec461bc092ef2df3 15-Feb-2011 Greg Clayton <gclayton@apple.com> Made lldb_private::ArchSpec contain much more than just an architecture. It
now, in addition to cpu type/subtype and architecture flavor, contains:
- byte order (big endian, little endian)
- address size in bytes
- llvm::Triple for true target triple support and for more powerful plug-in
selection.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125602 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
bf467b0f74953c0bbe5a05128601f621cdf51733 08-Feb-2011 Greg Clayton <gclayton@apple.com> A patch from Stephen Wilson that fixes some issues with my previous dynamic
loader changes.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125084 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
5f54ac373b119a4c6693e4875c48aa761fba0c86 08-Feb-2011 Greg Clayton <gclayton@apple.com> Moved FileSpec into the Host layer since it will vary from host to host.
We have a common unix implementation in lldb/source/Host/common/FileSpec.cpp.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125078 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
09c81efd010d1c9ac8821bad00cdfc9747fcae79 08-Feb-2011 Greg Clayton <gclayton@apple.com> Patch that allows for thread_t to be something more complex than an
integer. Modified patch from Kirk Beitz.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125067 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
14ef59fe5728d862c040cf5a6b99c384229a34ee 08-Feb-2011 Greg Clayton <gclayton@apple.com> Cleaned up the dynamic library open/getsymbol/close code to use abstracted
flags such that symbols can be searched for within a shared library if desired.
Platforms that support the RTLD_FIRST flag can still take advantage of their
quicker lookups, and other platforms can still get the same fucntionality
with a little extra work.

Also changed LLDB_CONFIG flags over to either being defined, or not being
defined to stay in line with current open source practices and to prepare for
using autoconf or cmake to configure LLDB builds.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125064 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
0f577c2ab79604f7300ac66afebcaa4a4b2dceef 07-Feb-2011 Greg Clayton <gclayton@apple.com> Added a "ArchSpec::SetElfArch()" that was removed by a previous patch and
avoid using RTLD_FIRST with dlopen to keep things compatible with other *NIX
variants. Patch from Jai Menon.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125015 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
b5f67fb8c443a769f92ae7a0067a4f968bcb0412 05-Feb-2011 Greg Clayton <gclayton@apple.com> Apple specific fix for Host.cpp from Kirk Beitz.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124942 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
e71e258286a1713dbb2d366d8b81ff2f28e0216f 04-Feb-2011 Greg Clayton <gclayton@apple.com> Added support for attaching to a remote debug server with the new command:
(lldb) process connect <remote-url>

Currently when you specify a file with the file command it helps us to find
a process plug-in that is suitable for debugging. If you specify a file you
can rely upon this to find the correct debugger plug-in:

% lldb a.out
Current executable set to 'a.out' (x86_64).
(lldb) process connect connect://localhost:2345
...

If you don't specify a file, you will need to specify the plug-in name that
you wish to use:

% lldb
(lldb) process connect --plugin process.gdb-remote connect://localhost:2345

Other connection URL examples:

(lldb) process connect connect://localhost:2345
(lldb) process connect tcp://127.0.0.1
(lldb) process connect file:///dev/ttyS1

We are currently treating the "connect://host:port" as a way to do raw socket
connections. If there is a URL for this already, please let me know and we
will adopt it.

So now you can connect to a remote debug server with the ProcessGDBRemote
plug-in. After connection, it will ask for the pid info using the "qC" packet
and if it responds with a valid process ID, it will be equivalent to attaching.
If it response with an error or invalid process ID, the LLDB process will be
in a new state: eStateConnected. This allows us to then download a program or
specify the program to run (using the 'A' packet), or specify a process to
attach to (using the "vAttach" packets), or query info about the processes
that might be available.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124846 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
52fd984f7e67c3a0ab18d5565f40356bcfa84822 02-Feb-2011 Greg Clayton <gclayton@apple.com> Modified the PluginManager to be ready for loading plug-ins from a system
LLDB plugin directory and a user LLDB plugin directory. We currently still
need to work out at what layer the plug-ins will be, but at least we are
prepared for plug-ins. Plug-ins will attempt to be loaded from the
"/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Plugins"
folder, and from the "~/Library/Application Support/LLDB/Plugins" folder on
MacOSX. Each plugin will be scanned for:

extern "C" bool LLDBPluginInitialize(void);
extern "C" void LLDBPluginTerminate(void);

If at least LLDBPluginInitialize is found, the plug-in will be loaded. The
LLDBPluginInitialize function returns a bool that indicates if the plug-in
should stay loaded or not (plug-ins might check the current OS, current
hardware, or anything else and determine they don't want to run on the current
host). The plug-in is uniqued by path and added to a static loaded plug-in
map. The plug-in scanning happens during "lldb_private::Initialize()" which
calls to the PluginManager::Initialize() function. Likewise with termination
lldb_private::Terminate() calls PluginManager::Terminate(). The paths for the
plug-in directories is fetched through new Host calls:

bool Host::GetLLDBPath (ePathTypeLLDBSystemPlugins, dir_spec);
bool Host::GetLLDBPath (ePathTypeLLDBUserPlugins, dir_spec);

This way linux and other systems can define their own appropriate locations
for plug-ins to be loaded.

To allow dynamic shared library loading, the Host layer has also been modified
to include shared library open, close and get symbol:

static void *
Host::DynamicLibraryOpen (const FileSpec &file_spec,
Error &error);

static Error
Host::DynamicLibraryClose (void *dynamic_library_handle);

static void *
Host::DynamicLibraryGetSymbol (void *dynamic_library_handle,
const char *symbol_name,
Error &error);

lldb_private::FileSpec also has been modified to support directory enumeration
in an attempt to abstract the directory enumeration into one spot in the code.
The directory enumertion function is static and takes a callback:


typedef enum EnumerateDirectoryResult
{
eEnumerateDirectoryResultNext, // Enumerate next entry in the current directory
eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a directory or symlink, or next if not
eEnumerateDirectoryResultExit, // Exit from the current directory at the current level.
eEnumerateDirectoryResultQuit // Stop directory enumerations at any level
};

typedef FileSpec::EnumerateDirectoryResult (*EnumerateDirectoryCallbackType) (void *baton,
FileSpec::FileType file_type,
const FileSpec &spec);

static FileSpec::EnumerateDirectoryResult
FileSpec::EnumerateDirectory (const char *dir_path,
bool find_directories,
bool find_files,
bool find_other,
EnumerateDirectoryCallbackType callback,
void *callback_baton);

This allow clients to specify the directory to search, and specifies if only
files, directories or other (pipe, symlink, fifo, etc) files will cause the
callback to be called. The callback also gets to return with the action that
should be performed after this directory entry. eEnumerateDirectoryResultNext
specifies to continue enumerating through a directory with the next entry.
eEnumerateDirectoryResultEnter specifies to recurse down into a directory
entry, or if the file is not a directory or symlink/alias to a directory, then
just iterate to the next entry. eEnumerateDirectoryResultExit specifies to
exit the current directory and skip any entries that might be remaining, yet
continue enumerating to the next entry in the parent directory. And finally
eEnumerateDirectoryResultQuit means to abort all directory enumerations at
all levels.

Modified the Declaration class to not include column information currently
since we don't have any compilers that currently support column based
declaration information. Columns support can be re-enabled with the
additions of a #define.

Added the ability to find an EmulateInstruction plug-in given a target triple
and optional plug-in name in the plug-in manager.

Fixed a few cases where opendir/readdir was being used, but yet not closedir
was being used. Soon these will be deprecated in favor of the new directory
enumeration call that was added to the FileSpec class.





git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124716 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
cd548034fa23113e995b8463d14f910ba2f7298c 01-Feb-2011 Greg Clayton <gclayton@apple.com> Endian patch from Kirk Beitz that allows better cross platform building.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124643 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
de915beb5febe597505ba33fdc2c39eea2abdbd4 23-Jan-2011 Greg Clayton <gclayton@apple.com> Added a new variant of SBTarget::Launch() that deprectates the old one that
takes separate file handles for stdin, stdout, and stder and also allows for
the working directory to be specified.

Added support to "process launch" to a new option: --working-dir=PATH. We
can now set the working directory. If this is not set, it defaults to that
of the process that has LLDB loaded. Added the working directory to the
host LaunchInNewTerminal function to allows the current working directory
to be set in processes that are spawned in their own terminal. Also hooked this
up to the lldb_private::Process and all mac plug-ins. The linux plug-in had its
API changed, but nothing is making use of it yet. Modfied "debugserver" and
"darwin-debug" to also handle the current working directory options and modified
the code in LLDB that spawns these tools to pass the info along.

Fixed ProcessGDBRemote to properly pass along all file handles for stdin, stdout
and stderr.

After clearing the default values for the stdin/out/err file handles for
process to be NULL, we had a crasher in UserSettingsController::UpdateStringVariable
which is now fixed. Also fixed the setting of boolean values to be able to
be set as "true", "yes", "on", "1" for true (case insensitive) and "false", "no",
"off", or "0" for false.

Fixed debugserver to properly handle files for STDIN, STDOUT and STDERR that are not
already opened. Previous to this fix debugserver would only correctly open and dupe
file handles for the slave side of a pseudo terminal. It now correctly handles
getting STDIN for the inferior from a file, and spitting STDOUT and STDERR out to
files. Also made sure the file handles were correctly opened with the NOCTTY flag
for terminals.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@124060 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
366795e6d866f5698fad1d55e4357e0dafc60edc 13-Jan-2011 Greg Clayton <gclayton@apple.com> Plug Free BSD memory leak.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@123357 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
2b9f976fbf708a0144119142015d6ed32363d55f 13-Jan-2011 Greg Clayton <gclayton@apple.com> Call SetFile instead of constructing a temp object and assigning to g_program_filespec for Free BSD port.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@123356 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
20fbf8d0b4ad24fb11d949b96b7fc5379eafb29e 13-Jan-2011 Greg Clayton <gclayton@apple.com> Don't have the program path be resolved when they already are when assigning g_program_filespec in the Host calls.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@123355 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
f302a9e10a78430bbd8608dd8aca0d543db54890 12-Jan-2011 Stephen Wilson <wilsons@start.ca> Null terminate path returned by readlink().



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@123307 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
5d187e5495ee17f6763337a6ae28c2a7b07e4945 08-Jan-2011 Greg Clayton <gclayton@apple.com> Spelling changes applied from lldb_spelling.diffs from Bruce Mitchener.

Thanks Bruce!



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@123083 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
9e3f7461c50249052e154247254185dedfe630cd 20-Dec-2010 Johnny Chen <johnny.chen@apple.com> Patch from Stephen:

Provide a missing resolve_path argument in calls to FileSpec's
constructor for both Linux and FreeBSD code fragments.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@122275 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
b73620c1b988324095aae0510f1867cf9a402fbe 18-Dec-2010 Greg Clayton <gclayton@apple.com> Linux patches from Stephen Wilson.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@122130 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
638351aee118e89c658ca295cb4e9d1db7849bef 04-Dec-2010 Greg Clayton <gclayton@apple.com> Added the ability for a process to inherit the current host environment. This
was done as an settings variable in the process for now. We will eventually
move all environment stuff over to the target, but we will leave it with the
process for now. The default setting is for a process to inherit the host
environment. This can be disabled by setting the "inherit-env" setting to
false in the process.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@120862 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
b749a265a2b97f9cef71c362dfd6dae26c8f2973 03-Dec-2010 Greg Clayton <gclayton@apple.com> Fixed a race condition that could cause ProcessGDBRemote::DoResume() to return
an error saying the resume timed out. Previously the thread that was trying
to resume the process would eventually call ProcessGDBRemote::DoResume() which
would broadcast an event over to the async GDB remote thread which would sent the
continue packet to the remote gdb server. Right after this was sent, it would
set a predicate boolean value (protected by a mutex and condition) and then the
thread that issued the ProcessGDBRemote::DoResume() would then wait for that
condition variable to be set. If the async gdb thread was too quick though, the
predicate boolean value could have been set to true and back to false by the
time the thread that issued the ProcessGDBRemote::DoResume() checks the boolean
value. So we can't use the predicate value as a handshake. I have changed the code
over to using a Event by having the GDB remote communication object post an
event:

GDBRemoteCommunication::eBroadcastBitRunPacketSent

This allows reliable handshaking between the two threads and avoids the erroneous
ProcessGDBRemote::DoResume() errors.

Added a host backtrace service to allow in process backtraces when trying to track
down tricky issues. I need to see if LLVM has any backtracing abilities abstracted
in it already, and if so, use that, but I needed something ASAP for the current issue
I was working on. The static function is:

void
Host::Backtrace (Stream &strm, uint32_t max_frames);

And it will backtrace at most "max_frames" frames for the current thread and can be
used with any of the Stream subclasses for logging.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@120793 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
e98ac25604b3d967158917f6fdd5289b3096fd80 10-Nov-2010 Greg Clayton <gclayton@apple.com> Modified lldb_private::SymboleFile to be able to override where its TypeList
comes from by using a virtual function to provide it from the Module's
SymbolVendor by default. This allows the DWARF parser, when being used to
parse DWARF in .o files with a parent DWARF + debug map parser, to get its
type list from the DWARF + debug map parser so when we go and find full
definitions for types (that might come from other .o files), we can use the
type list from the debug map parser. Otherwise we ended up mixing clang types
from one .o file (say a const pointer to a forward declaration "class A") with
the a full type from another .o file. This causes expression parsing, when
copying the clang types from those parsed by the DWARF parser into the
expression AST, to fail -- for good reason. Now all types are created in the
same list.

Also added host support for crash description strings that can be set before
doing a piece of work. On MacOSX, this ties in with CrashReporter support
that allows a string to be dispalyed when the app crashes and allows
LLDB.framework to print a description string in the crash log. Right now this
is hookup up the the CommandInterpreter::HandleCommand() where each command
notes that it is about to be executed, so if we crash while trying to do this
command, we should be able to see the command that caused LLDB to exit. For
all other platforms, this is a nop.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@118672 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
e005f2ce03c489ebde9110678a29cbfe8488d5b4 06-Nov-2010 Greg Clayton <gclayton@apple.com> Modified all logging calls to hand out shared pointers to make sure we
don't crash if we disable logging when some code already has a copy of the
logger. Prior to this fix, logs were handed out as pointers and if they were
held onto while a log got disabled, then it could cause a crash. Now all logs
are handed out as shared pointers so this problem shouldn't happen anymore.
We are also using our new shared pointers that put the shared pointer count
and the object into the same allocation for a tad better performance.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@118319 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
49ce682dfa7993d31206cea19ce7006cd3f3077e 31-Oct-2010 Greg Clayton <gclayton@apple.com> Cleaned up the API logging a lot more to reduce redundant information and
keep the file size a bit smaller.

Exposed SBValue::GetExpressionPath() so SBValue users can get an expression
path for their values.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@117851 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
926060e198137f8a64face70455324a8cd4362a5 29-Oct-2010 Caroline Tice <ctice@apple.com> Add the ability to disable individual log categories, rather
than just the entire log channel.

Add checks, where appropriate, to make sure a log channel/category has
not been disabled before attempting to write to it.




git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@117715 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
537a7a86687683fd403ce652d178fbc89e06ef9f 20-Oct-2010 Greg Clayton <gclayton@apple.com> Fixed an issue where we were resolving paths when we should have been.

So the issue here was that we have lldb_private::FileSpec that by default was
always resolving a path when using the:

FileSpec::FileSpec (const char *path);

and in the:

void FileSpec::SetFile(const char *pathname, bool resolve = true);

This isn't what we want in many many cases. One example is you have "/tmp" on
your file system which is really "/private/tmp". You compile code in that
directory and end up with debug info that mentions "/tmp/file.c". Then you
type:

(lldb) breakpoint set --file file.c --line 5

If your current working directory is "/tmp", then "file.c" would be turned
into "/private/tmp/file.c" which won't match anything in the debug info.
Also, it should have been just a FileSpec with no directory and a filename
of "file.c" which could (and should) potentially match any instances of "file.c"
in the debug info.

So I removed the constructor that just takes a path:

FileSpec::FileSpec (const char *path); // REMOVED

You must now use the other constructor that has a "bool resolve" parameter that you must always supply:

FileSpec::FileSpec (const char *path, bool resolve);

I also removed the default parameter to SetFile():

void FileSpec::SetFile(const char *pathname, bool resolve);

And fixed all of the code to use the right settings.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@116944 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
24b48ff28b7c60dd4598212c3e77935a0fc1142d 18-Oct-2010 Greg Clayton <gclayton@apple.com> Added a new Host call to find LLDB related paths:

static bool
Host::GetLLDBPath (lldb::PathType path_type, FileSpec &file_spec);

This will fill in "file_spec" with an appropriate path that is appropriate
for the current Host OS. MacOSX will return paths within the LLDB.framework,
and other unixes will return the paths they want. The current PathType
enums are:

typedef enum PathType
{
ePathTypeLLDBShlibDir, // The directory where the lldb.so (unix) or LLDB mach-o file in LLDB.framework (MacOSX) exists
ePathTypeSupportExecutableDir, // Find LLDB support executable directory (debugserver, etc)
ePathTypeHeaderDir, // Find LLDB header file directory
ePathTypePythonDir // Find Python modules (PYTHONPATH) directory
} PathType;

All places that were finding executables are and python paths are now updated
to use this Host call.

Added another new host call to launch the inferior in a terminal. This ability
will be very host specific and doesn't need to be supported on all systems.
MacOSX currently will create a new .command file and tell Terminal.app to open
the .command file. It also uses the new "darwin-debug" app which is a small
app that uses posix to exec (no fork) and stop at the entry point of the
program. The GDB remote plug-in is almost able launch a process and attach to
it, it currently will spawn the process, but it won't attach to it just yet.
This will let LLDB not have to share the terminal with another process and a
new terminal window will pop up when you launch. This won't get hooked up
until we work out all of the kinks. The new Host function is:

static lldb::pid_t
Host::LaunchInNewTerminal (
const char **argv, // argv[0] is executable
const char **envp,
const ArchSpec *arch_spec,
bool stop_at_entry,
bool disable_aslr);

Cleaned up FileSpec::GetPath to not use strncpy() as it was always zero
filling the entire path buffer.

Fixed an issue with the dynamic checker function where I missed a '$' prefix
that should have been added.





git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@116690 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
fb8876dcd13abe460b337ce7b50aad3b5757ee53 11-Oct-2010 Greg Clayton <gclayton@apple.com> Plugged memory leak.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@116175 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
e9ca3a4130bfb76765256549e01c759da8ec2f1d 12-Sep-2010 Caroline Tice <ctice@apple.com> Remove Host::ResolveExecutableLocation (very recent addition); replace use of
it with llvm::sys::Program::FindProgramByName.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@113709 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
eddffe93d2c9ebb575e7b03fe1c5e71f9ecaf9f1 10-Sep-2010 Caroline Tice <ctice@apple.com> If the file the user specifies can't be found in the current directory,
and the user didn't specify a particular directory, search for the file
using the $PATH environment variable.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@113575 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp
8f3b21daa0d509ac49b2b82f45aaed35f6874502 07-Sep-2010 Greg Clayton <gclayton@apple.com> Patch from Jay Cornwall that modifies the LLDB "Host" layer to reuse more
code between linux, darwin and BSD.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@113263 91177308-0d34-0410-b5e6-96231b3b80d8
/external/lldb/source/Host/common/Host.cpp