blob: 987d0b27f6c25d81e4cfdfbc89dd898f75297935 [file] [log] [blame]
Greg Clayton8f3b21d2010-09-07 20:11:56 +00001//===-- Host.cpp ------------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/Host/Host.h"
11#include "lldb/Core/ArchSpec.h"
12#include "lldb/Core/ConstString.h"
13#include "lldb/Core/Error.h"
Greg Clayton8f3b21d2010-09-07 20:11:56 +000014#include "lldb/Core/Log.h"
15#include "lldb/Core/StreamString.h"
Greg Clayton14ef59f2011-02-08 00:35:34 +000016#include "lldb/Host/Config.h"
Greg Claytoncd548032011-02-01 01:31:41 +000017#include "lldb/Host/Endian.h"
Greg Claytone4b9c1f2011-03-08 22:40:15 +000018#include "lldb/Host/FileSpec.h"
Greg Clayton8f3b21d2010-09-07 20:11:56 +000019#include "lldb/Host/Mutex.h"
Greg Claytone4b9c1f2011-03-08 22:40:15 +000020#include "lldb/Target/Process.h"
Greg Clayton8f3b21d2010-09-07 20:11:56 +000021
Stephen Wilson7f513ba2011-02-24 19:15:09 +000022#include "llvm/Support/Host.h"
Greg Claytone4b9c1f2011-03-08 22:40:15 +000023#include "llvm/Support/MachO.h"
Stephen Wilson7f513ba2011-02-24 19:15:09 +000024
Greg Clayton8f3b21d2010-09-07 20:11:56 +000025#include <dlfcn.h>
26#include <errno.h>
Greg Clayton24bc5d92011-03-30 18:16:51 +000027#include <grp.h>
Greg Clayton58e26e02011-03-24 04:28:38 +000028#include <netdb.h>
Greg Clayton24bc5d92011-03-30 18:16:51 +000029#include <pwd.h>
30#include <sys/types.h>
31
Greg Clayton8f3b21d2010-09-07 20:11:56 +000032
33#if defined (__APPLE__)
Greg Clayton14ef59f2011-02-08 00:35:34 +000034
Greg Clayton49ce6822010-10-31 03:01:06 +000035#include <dispatch/dispatch.h>
Greg Clayton8f3b21d2010-09-07 20:11:56 +000036#include <libproc.h>
37#include <mach-o/dyld.h>
Greg Claytonb5f67fb2011-02-05 06:36:35 +000038#include <sys/sysctl.h>
Greg Clayton14ef59f2011-02-08 00:35:34 +000039
Greg Clayton24bc5d92011-03-30 18:16:51 +000040
Greg Clayton0f577c22011-02-07 17:43:47 +000041#elif defined (__linux__)
Greg Clayton14ef59f2011-02-08 00:35:34 +000042
Greg Clayton0f577c22011-02-07 17:43:47 +000043#include <sys/wait.h>
Greg Clayton14ef59f2011-02-08 00:35:34 +000044
Greg Clayton8f3b21d2010-09-07 20:11:56 +000045#endif
46
47using namespace lldb;
48using namespace lldb_private;
49
50struct MonitorInfo
51{
52 lldb::pid_t pid; // The process ID to monitor
53 Host::MonitorChildProcessCallback callback; // The callback function to call when "pid" exits or signals
54 void *callback_baton; // The callback baton for the callback function
55 bool monitor_signals; // If true, call the callback when "pid" gets signaled.
56};
57
58static void *
59MonitorChildProcessThreadFunction (void *arg);
60
61lldb::thread_t
62Host::StartMonitoringChildProcess
63(
64 Host::MonitorChildProcessCallback callback,
65 void *callback_baton,
66 lldb::pid_t pid,
67 bool monitor_signals
68)
69{
70 lldb::thread_t thread = LLDB_INVALID_HOST_THREAD;
71 if (callback)
72 {
73 std::auto_ptr<MonitorInfo> info_ap(new MonitorInfo);
74
75 info_ap->pid = pid;
76 info_ap->callback = callback;
77 info_ap->callback_baton = callback_baton;
78 info_ap->monitor_signals = monitor_signals;
79
80 char thread_name[256];
81 ::snprintf (thread_name, sizeof(thread_name), "<lldb.host.wait4(pid=%i)>", pid);
82 thread = ThreadCreate (thread_name,
83 MonitorChildProcessThreadFunction,
84 info_ap.get(),
85 NULL);
86
Greg Clayton09c81ef2011-02-08 01:34:25 +000087 if (IS_VALID_LLDB_HOST_THREAD(thread))
Greg Clayton8f3b21d2010-09-07 20:11:56 +000088 info_ap.release();
89 }
90 return thread;
91}
92
93//------------------------------------------------------------------
94// Scoped class that will disable thread canceling when it is
95// constructed, and exception safely restore the previous value it
96// when it goes out of scope.
97//------------------------------------------------------------------
98class ScopedPThreadCancelDisabler
99{
100public:
101 ScopedPThreadCancelDisabler()
102 {
103 // Disable the ability for this thread to be cancelled
104 int err = ::pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &m_old_state);
105 if (err != 0)
106 m_old_state = -1;
107
108 }
109
110 ~ScopedPThreadCancelDisabler()
111 {
112 // Restore the ability for this thread to be cancelled to what it
113 // previously was.
114 if (m_old_state != -1)
115 ::pthread_setcancelstate (m_old_state, 0);
116 }
117private:
118 int m_old_state; // Save the old cancelability state.
119};
120
121static void *
122MonitorChildProcessThreadFunction (void *arg)
123{
Greg Claytone005f2c2010-11-06 01:53:30 +0000124 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000125 const char *function = __FUNCTION__;
126 if (log)
127 log->Printf ("%s (arg = %p) thread starting...", function, arg);
128
129 MonitorInfo *info = (MonitorInfo *)arg;
130
131 const Host::MonitorChildProcessCallback callback = info->callback;
132 void * const callback_baton = info->callback_baton;
133 const lldb::pid_t pid = info->pid;
134 const bool monitor_signals = info->monitor_signals;
135
136 delete info;
137
138 int status = -1;
139 const int options = 0;
140 struct rusage *rusage = NULL;
141 while (1)
142 {
Caroline Tice926060e2010-10-29 21:48:37 +0000143 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000144 if (log)
145 log->Printf("%s ::wait4 (pid = %i, &status, options = %i, rusage = %p)...", function, pid, options, rusage);
146
147 // Wait for all child processes
148 ::pthread_testcancel ();
149 const lldb::pid_t wait_pid = ::wait4 (pid, &status, options, rusage);
150 ::pthread_testcancel ();
151
152 if (wait_pid == -1)
153 {
154 if (errno == EINTR)
155 continue;
156 else
157 break;
158 }
159 else if (wait_pid == pid)
160 {
161 bool exited = false;
162 int signal = 0;
163 int exit_status = 0;
164 const char *status_cstr = NULL;
165 if (WIFSTOPPED(status))
166 {
167 signal = WSTOPSIG(status);
168 status_cstr = "STOPPED";
169 }
170 else if (WIFEXITED(status))
171 {
172 exit_status = WEXITSTATUS(status);
173 status_cstr = "EXITED";
174 exited = true;
175 }
176 else if (WIFSIGNALED(status))
177 {
178 signal = WTERMSIG(status);
179 status_cstr = "SIGNALED";
180 exited = true;
181 exit_status = -1;
182 }
183 else
184 {
185 status_cstr = "(???)";
186 }
187
188 // Scope for pthread_cancel_disabler
189 {
190 ScopedPThreadCancelDisabler pthread_cancel_disabler;
191
Caroline Tice926060e2010-10-29 21:48:37 +0000192 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000193 if (log)
194 log->Printf ("%s ::wait4 (pid = %i, &status, options = %i, rusage = %p) => pid = %i, status = 0x%8.8x (%s), signal = %i, exit_state = %i",
195 function,
196 wait_pid,
197 options,
198 rusage,
199 pid,
200 status,
201 status_cstr,
202 signal,
203 exit_status);
204
205 if (exited || (signal != 0 && monitor_signals))
206 {
207 bool callback_return = callback (callback_baton, pid, signal, exit_status);
208
209 // If our process exited, then this thread should exit
210 if (exited)
211 break;
212 // If the callback returns true, it means this process should
213 // exit
214 if (callback_return)
215 break;
216 }
217 }
218 }
219 }
220
Caroline Tice926060e2010-10-29 21:48:37 +0000221 log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS);
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000222 if (log)
223 log->Printf ("%s (arg = %p) thread exiting...", __FUNCTION__, arg);
224
225 return NULL;
226}
227
228size_t
229Host::GetPageSize()
230{
231 return ::getpagesize();
232}
233
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000234const ArchSpec &
Greg Clayton395fc332011-02-15 21:59:32 +0000235Host::GetArchitecture (SystemDefaultArchitecture arch_kind)
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000236{
Greg Clayton395fc332011-02-15 21:59:32 +0000237 static bool g_supports_32 = false;
238 static bool g_supports_64 = false;
239 static ArchSpec g_host_arch_32;
240 static ArchSpec g_host_arch_64;
241
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000242#if defined (__APPLE__)
Greg Clayton395fc332011-02-15 21:59:32 +0000243
244 // Apple is different in that it can support both 32 and 64 bit executables
245 // in the same operating system running concurrently. Here we detect the
246 // correct host architectures for both 32 and 64 bit including if 64 bit
247 // executables are supported on the system.
248
249 if (g_supports_32 == false && g_supports_64 == false)
250 {
251 // All apple systems support 32 bit execution.
252 g_supports_32 = true;
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000253 uint32_t cputype, cpusubtype;
Greg Clayton395fc332011-02-15 21:59:32 +0000254 uint32_t is_64_bit_capable = false;
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000255 size_t len = sizeof(cputype);
Greg Clayton395fc332011-02-15 21:59:32 +0000256 ArchSpec host_arch;
257 // These will tell us about the kernel architecture, which even on a 64
258 // bit machine can be 32 bit...
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000259 if (::sysctlbyname("hw.cputype", &cputype, &len, NULL, 0) == 0)
260 {
Greg Clayton395fc332011-02-15 21:59:32 +0000261 len = sizeof (cpusubtype);
262 if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) != 0)
263 cpusubtype = CPU_TYPE_ANY;
264
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000265 len = sizeof (is_64_bit_capable);
266 if (::sysctlbyname("hw.cpu64bit_capable", &is_64_bit_capable, &len, NULL, 0) == 0)
267 {
268 if (is_64_bit_capable)
Greg Clayton395fc332011-02-15 21:59:32 +0000269 g_supports_64 = true;
270 }
271
272 if (is_64_bit_capable)
273 {
Greg Clayton75c703d2011-02-16 04:46:07 +0000274#if defined (__i386__) || defined (__x86_64__)
275 if (cpusubtype == CPU_SUBTYPE_486)
276 cpusubtype = CPU_SUBTYPE_I386_ALL;
277#endif
Greg Clayton395fc332011-02-15 21:59:32 +0000278 if (cputype & CPU_ARCH_ABI64)
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000279 {
Greg Clayton395fc332011-02-15 21:59:32 +0000280 // We have a 64 bit kernel on a 64 bit system
Greg Claytonb3448432011-03-24 21:19:54 +0000281 g_host_arch_32.SetArchitecture (eArchTypeMachO, ~(CPU_ARCH_MASK) & cputype, cpusubtype);
282 g_host_arch_64.SetArchitecture (eArchTypeMachO, cputype, cpusubtype);
Greg Clayton395fc332011-02-15 21:59:32 +0000283 }
284 else
285 {
286 // We have a 32 bit kernel on a 64 bit system
Greg Claytonb3448432011-03-24 21:19:54 +0000287 g_host_arch_32.SetArchitecture (eArchTypeMachO, cputype, cpusubtype);
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000288 cputype |= CPU_ARCH_ABI64;
Greg Claytonb3448432011-03-24 21:19:54 +0000289 g_host_arch_64.SetArchitecture (eArchTypeMachO, cputype, cpusubtype);
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000290 }
291 }
Greg Clayton395fc332011-02-15 21:59:32 +0000292 else
293 {
Greg Claytonb3448432011-03-24 21:19:54 +0000294 g_host_arch_32.SetArchitecture (eArchTypeMachO, cputype, cpusubtype);
Greg Clayton395fc332011-02-15 21:59:32 +0000295 g_host_arch_64.Clear();
296 }
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000297 }
Greg Clayton395fc332011-02-15 21:59:32 +0000298 }
299
300#else // #if defined (__APPLE__)
Stephen Wilson7f513ba2011-02-24 19:15:09 +0000301
Greg Clayton395fc332011-02-15 21:59:32 +0000302 if (g_supports_32 == false && g_supports_64 == false)
303 {
Stephen Wilson7f513ba2011-02-24 19:15:09 +0000304 llvm::Triple triple(llvm::sys::getHostTriple());
Greg Clayton395fc332011-02-15 21:59:32 +0000305
Stephen Wilson7f513ba2011-02-24 19:15:09 +0000306 g_host_arch_32.Clear();
307 g_host_arch_64.Clear();
Greg Clayton395fc332011-02-15 21:59:32 +0000308
Stephen Wilson7f513ba2011-02-24 19:15:09 +0000309 switch (triple.getArch())
310 {
311 default:
312 g_host_arch_32.SetTriple(triple);
313 g_supports_32 = true;
314 break;
Greg Clayton395fc332011-02-15 21:59:32 +0000315
Stephen Wilson7f513ba2011-02-24 19:15:09 +0000316 case llvm::Triple::alpha:
317 case llvm::Triple::x86_64:
318 case llvm::Triple::sparcv9:
319 case llvm::Triple::ppc64:
320 case llvm::Triple::systemz:
321 case llvm::Triple::cellspu:
322 g_host_arch_64.SetTriple(triple);
323 g_supports_64 = true;
324 break;
325 }
Greg Clayton4fefe322011-02-17 02:05:38 +0000326
327 g_supports_32 = g_host_arch_32.IsValid();
328 g_supports_64 = g_host_arch_64.IsValid();
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000329 }
Greg Clayton395fc332011-02-15 21:59:32 +0000330
331#endif // #else for #if defined (__APPLE__)
332
333 if (arch_kind == eSystemDefaultArchitecture32)
334 return g_host_arch_32;
335 else if (arch_kind == eSystemDefaultArchitecture64)
336 return g_host_arch_64;
337
338 if (g_supports_64)
339 return g_host_arch_64;
340
341 return g_host_arch_32;
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000342}
343
344const ConstString &
345Host::GetVendorString()
346{
347 static ConstString g_vendor;
348 if (!g_vendor)
349 {
350#if defined (__APPLE__)
351 char ostype[64];
352 size_t len = sizeof(ostype);
353 if (::sysctlbyname("kern.ostype", &ostype, &len, NULL, 0) == 0)
354 g_vendor.SetCString (ostype);
355 else
356 g_vendor.SetCString("apple");
357#elif defined (__linux__)
358 g_vendor.SetCString("gnu");
359#endif
360 }
361 return g_vendor;
362}
363
364const ConstString &
365Host::GetOSString()
366{
367 static ConstString g_os_string;
368 if (!g_os_string)
369 {
370#if defined (__APPLE__)
371 g_os_string.SetCString("darwin");
372#elif defined (__linux__)
373 g_os_string.SetCString("linux");
374#endif
375 }
376 return g_os_string;
377}
378
379const ConstString &
380Host::GetTargetTriple()
381{
382 static ConstString g_host_triple;
383 if (!(g_host_triple))
384 {
385 StreamString triple;
386 triple.Printf("%s-%s-%s",
Greg Clayton940b1032011-02-23 00:35:02 +0000387 GetArchitecture().GetArchitectureName(),
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000388 GetVendorString().AsCString(),
389 GetOSString().AsCString());
390
391 std::transform (triple.GetString().begin(),
392 triple.GetString().end(),
393 triple.GetString().begin(),
394 ::tolower);
395
396 g_host_triple.SetCString(triple.GetString().c_str());
397 }
398 return g_host_triple;
399}
400
401lldb::pid_t
402Host::GetCurrentProcessID()
403{
404 return ::getpid();
405}
406
407lldb::tid_t
408Host::GetCurrentThreadID()
409{
410#if defined (__APPLE__)
411 return ::mach_thread_self();
412#else
413 return lldb::tid_t(pthread_self());
414#endif
415}
416
417const char *
418Host::GetSignalAsCString (int signo)
419{
420 switch (signo)
421 {
422 case SIGHUP: return "SIGHUP"; // 1 hangup
423 case SIGINT: return "SIGINT"; // 2 interrupt
424 case SIGQUIT: return "SIGQUIT"; // 3 quit
425 case SIGILL: return "SIGILL"; // 4 illegal instruction (not reset when caught)
426 case SIGTRAP: return "SIGTRAP"; // 5 trace trap (not reset when caught)
427 case SIGABRT: return "SIGABRT"; // 6 abort()
428#if defined(_POSIX_C_SOURCE)
429 case SIGPOLL: return "SIGPOLL"; // 7 pollable event ([XSR] generated, not supported)
430#else // !_POSIX_C_SOURCE
431 case SIGEMT: return "SIGEMT"; // 7 EMT instruction
432#endif // !_POSIX_C_SOURCE
433 case SIGFPE: return "SIGFPE"; // 8 floating point exception
434 case SIGKILL: return "SIGKILL"; // 9 kill (cannot be caught or ignored)
435 case SIGBUS: return "SIGBUS"; // 10 bus error
436 case SIGSEGV: return "SIGSEGV"; // 11 segmentation violation
437 case SIGSYS: return "SIGSYS"; // 12 bad argument to system call
438 case SIGPIPE: return "SIGPIPE"; // 13 write on a pipe with no one to read it
439 case SIGALRM: return "SIGALRM"; // 14 alarm clock
440 case SIGTERM: return "SIGTERM"; // 15 software termination signal from kill
441 case SIGURG: return "SIGURG"; // 16 urgent condition on IO channel
442 case SIGSTOP: return "SIGSTOP"; // 17 sendable stop signal not from tty
443 case SIGTSTP: return "SIGTSTP"; // 18 stop signal from tty
444 case SIGCONT: return "SIGCONT"; // 19 continue a stopped process
445 case SIGCHLD: return "SIGCHLD"; // 20 to parent on child stop or exit
446 case SIGTTIN: return "SIGTTIN"; // 21 to readers pgrp upon background tty read
447 case SIGTTOU: return "SIGTTOU"; // 22 like TTIN for output if (tp->t_local&LTOSTOP)
448#if !defined(_POSIX_C_SOURCE)
449 case SIGIO: return "SIGIO"; // 23 input/output possible signal
450#endif
451 case SIGXCPU: return "SIGXCPU"; // 24 exceeded CPU time limit
452 case SIGXFSZ: return "SIGXFSZ"; // 25 exceeded file size limit
453 case SIGVTALRM: return "SIGVTALRM"; // 26 virtual time alarm
454 case SIGPROF: return "SIGPROF"; // 27 profiling time alarm
455#if !defined(_POSIX_C_SOURCE)
456 case SIGWINCH: return "SIGWINCH"; // 28 window size changes
457 case SIGINFO: return "SIGINFO"; // 29 information request
458#endif
459 case SIGUSR1: return "SIGUSR1"; // 30 user defined signal 1
460 case SIGUSR2: return "SIGUSR2"; // 31 user defined signal 2
461 default:
462 break;
463 }
464 return NULL;
465}
466
467void
468Host::WillTerminate ()
469{
470}
471
472#if !defined (__APPLE__) // see macosx/Host.mm
473void
474Host::ThreadCreated (const char *thread_name)
475{
476}
Greg Claytonb749a262010-12-03 06:02:24 +0000477
478void
479Host::Backtrace (Stream &strm, uint32_t max_frames)
480{
Greg Clayton52fd9842011-02-02 02:24:04 +0000481 // TODO: Is there a way to backtrace the current process on linux? Other systems?
Greg Claytonb749a262010-12-03 06:02:24 +0000482}
483
Greg Clayton638351a2010-12-04 00:10:17 +0000484
485size_t
486Host::GetEnvironment (StringList &env)
487{
Greg Clayton52fd9842011-02-02 02:24:04 +0000488 // TODO: Is there a way to the host environment for this process on linux? Other systems?
Greg Clayton638351a2010-12-04 00:10:17 +0000489 return 0;
490}
491
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000492#endif
493
494struct HostThreadCreateInfo
495{
496 std::string thread_name;
497 thread_func_t thread_fptr;
498 thread_arg_t thread_arg;
499
500 HostThreadCreateInfo (const char *name, thread_func_t fptr, thread_arg_t arg) :
501 thread_name (name ? name : ""),
502 thread_fptr (fptr),
503 thread_arg (arg)
504 {
505 }
506};
507
508static thread_result_t
509ThreadCreateTrampoline (thread_arg_t arg)
510{
511 HostThreadCreateInfo *info = (HostThreadCreateInfo *)arg;
512 Host::ThreadCreated (info->thread_name.c_str());
513 thread_func_t thread_fptr = info->thread_fptr;
514 thread_arg_t thread_arg = info->thread_arg;
515
Greg Claytone005f2c2010-11-06 01:53:30 +0000516 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_THREAD));
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000517 if (log)
518 log->Printf("thread created");
519
520 delete info;
521 return thread_fptr (thread_arg);
522}
523
524lldb::thread_t
525Host::ThreadCreate
526(
527 const char *thread_name,
528 thread_func_t thread_fptr,
529 thread_arg_t thread_arg,
530 Error *error
531)
532{
533 lldb::thread_t thread = LLDB_INVALID_HOST_THREAD;
534
535 // Host::ThreadCreateTrampoline will delete this pointer for us.
536 HostThreadCreateInfo *info_ptr = new HostThreadCreateInfo (thread_name, thread_fptr, thread_arg);
537
538 int err = ::pthread_create (&thread, NULL, ThreadCreateTrampoline, info_ptr);
539 if (err == 0)
540 {
541 if (error)
542 error->Clear();
543 return thread;
544 }
545
546 if (error)
547 error->SetError (err, eErrorTypePOSIX);
548
549 return LLDB_INVALID_HOST_THREAD;
550}
551
552bool
553Host::ThreadCancel (lldb::thread_t thread, Error *error)
554{
555 int err = ::pthread_cancel (thread);
556 if (error)
557 error->SetError(err, eErrorTypePOSIX);
558 return err == 0;
559}
560
561bool
562Host::ThreadDetach (lldb::thread_t thread, Error *error)
563{
564 int err = ::pthread_detach (thread);
565 if (error)
566 error->SetError(err, eErrorTypePOSIX);
567 return err == 0;
568}
569
570bool
571Host::ThreadJoin (lldb::thread_t thread, thread_result_t *thread_result_ptr, Error *error)
572{
573 int err = ::pthread_join (thread, thread_result_ptr);
574 if (error)
575 error->SetError(err, eErrorTypePOSIX);
576 return err == 0;
577}
578
579//------------------------------------------------------------------
580// Control access to a static file thread name map using a single
581// static function to avoid a static constructor.
582//------------------------------------------------------------------
583static const char *
584ThreadNameAccessor (bool get, lldb::pid_t pid, lldb::tid_t tid, const char *name)
585{
586 uint64_t pid_tid = ((uint64_t)pid << 32) | (uint64_t)tid;
587
588 static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
589 Mutex::Locker locker(&g_mutex);
590
591 typedef std::map<uint64_t, std::string> thread_name_map;
592 // rdar://problem/8153284
593 // Fixed a crasher where during shutdown, loggings attempted to access the
594 // thread name but the static map instance had already been destructed.
595 // Another approach is to introduce a static guard object which monitors its
596 // own destruction and raises a flag, but this incurs more overhead.
597 static thread_name_map *g_thread_names_ptr = new thread_name_map();
598 thread_name_map &g_thread_names = *g_thread_names_ptr;
599
600 if (get)
601 {
602 // See if the thread name exists in our thread name pool
603 thread_name_map::iterator pos = g_thread_names.find(pid_tid);
604 if (pos != g_thread_names.end())
605 return pos->second.c_str();
606 }
607 else
608 {
609 // Set the thread name
610 g_thread_names[pid_tid] = name;
611 }
612 return NULL;
613}
614
615const char *
616Host::GetThreadName (lldb::pid_t pid, lldb::tid_t tid)
617{
618 const char *name = ThreadNameAccessor (true, pid, tid, NULL);
619 if (name == NULL)
620 {
621#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
622 // We currently can only get the name of a thread in the current process.
623 if (pid == Host::GetCurrentProcessID())
624 {
625 char pthread_name[1024];
626 if (::pthread_getname_np (::pthread_from_mach_thread_np (tid), pthread_name, sizeof(pthread_name)) == 0)
627 {
628 if (pthread_name[0])
629 {
630 // Set the thread in our string pool
631 ThreadNameAccessor (false, pid, tid, pthread_name);
632 // Get our copy of the thread name string
633 name = ThreadNameAccessor (true, pid, tid, NULL);
634 }
635 }
Greg Clayton49ce6822010-10-31 03:01:06 +0000636
637 if (name == NULL)
638 {
639 dispatch_queue_t current_queue = ::dispatch_get_current_queue ();
640 if (current_queue != NULL)
641 name = dispatch_queue_get_label (current_queue);
642 }
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000643 }
644#endif
645 }
646 return name;
647}
648
649void
650Host::SetThreadName (lldb::pid_t pid, lldb::tid_t tid, const char *name)
651{
652 lldb::pid_t curr_pid = Host::GetCurrentProcessID();
653 lldb::tid_t curr_tid = Host::GetCurrentThreadID();
654 if (pid == LLDB_INVALID_PROCESS_ID)
655 pid = curr_pid;
656
657 if (tid == LLDB_INVALID_THREAD_ID)
658 tid = curr_tid;
659
660#if defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5
661 // Set the pthread name if possible
662 if (pid == curr_pid && tid == curr_tid)
663 {
664 ::pthread_setname_np (name);
665 }
666#endif
667 ThreadNameAccessor (false, pid, tid, name);
668}
669
670FileSpec
671Host::GetProgramFileSpec ()
672{
673 static FileSpec g_program_filespec;
674 if (!g_program_filespec)
675 {
676#if defined (__APPLE__)
677 char program_fullpath[PATH_MAX];
678 // If DST is NULL, then return the number of bytes needed.
679 uint32_t len = sizeof(program_fullpath);
680 int err = _NSGetExecutablePath (program_fullpath, &len);
681 if (err == 0)
Greg Clayton20fbf8d2011-01-13 01:23:43 +0000682 g_program_filespec.SetFile (program_fullpath, false);
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000683 else if (err == -1)
684 {
685 char *large_program_fullpath = (char *)::malloc (len + 1);
686
687 err = _NSGetExecutablePath (large_program_fullpath, &len);
688 if (err == 0)
Greg Clayton20fbf8d2011-01-13 01:23:43 +0000689 g_program_filespec.SetFile (large_program_fullpath, false);
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000690
691 ::free (large_program_fullpath);
692 }
693#elif defined (__linux__)
694 char exe_path[PATH_MAX];
Stephen Wilsonf302a9e2011-01-12 04:21:21 +0000695 ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path) - 1);
696 if (len > 0) {
697 exe_path[len] = 0;
Greg Clayton20fbf8d2011-01-13 01:23:43 +0000698 g_program_filespec.SetFile(exe_path, false);
Stephen Wilsonf302a9e2011-01-12 04:21:21 +0000699 }
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000700#elif defined (__FreeBSD__)
701 int exe_path_mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, getpid() };
702 size_t exe_path_size;
703 if (sysctl(exe_path_mib, 4, NULL, &exe_path_size, NULL, 0) == 0)
704 {
Greg Clayton366795e2011-01-13 01:27:55 +0000705 char *exe_path = new char[exe_path_size];
706 if (sysctl(exe_path_mib, 4, exe_path, &exe_path_size, NULL, 0) == 0)
707 g_program_filespec.SetFile(exe_path, false);
708 delete[] exe_path;
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000709 }
710#endif
711 }
712 return g_program_filespec;
713}
714
715FileSpec
716Host::GetModuleFileSpecForHostAddress (const void *host_addr)
717{
718 FileSpec module_filespec;
719 Dl_info info;
720 if (::dladdr (host_addr, &info))
721 {
722 if (info.dli_fname)
Greg Clayton537a7a82010-10-20 20:54:39 +0000723 module_filespec.SetFile(info.dli_fname, true);
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000724 }
725 return module_filespec;
726}
727
728#if !defined (__APPLE__) // see Host.mm
729bool
Greg Clayton24b48ff2010-10-17 22:03:32 +0000730Host::ResolveExecutableInBundle (FileSpec &file)
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000731{
Greg Clayton24b48ff2010-10-17 22:03:32 +0000732 return false;
Greg Clayton8f3b21d2010-09-07 20:11:56 +0000733}
734#endif
735
Greg Clayton14ef59f2011-02-08 00:35:34 +0000736// Opaque info that tracks a dynamic library that was loaded
737struct DynamicLibraryInfo
Greg Clayton52fd9842011-02-02 02:24:04 +0000738{
Greg Clayton14ef59f2011-02-08 00:35:34 +0000739 DynamicLibraryInfo (const FileSpec &fs, int o, void *h) :
740 file_spec (fs),
741 open_options (o),
742 handle (h)
743 {
744 }
745
746 const FileSpec file_spec;
747 uint32_t open_options;
748 void * handle;
749};
750
751void *
752Host::DynamicLibraryOpen (const FileSpec &file_spec, uint32_t options, Error &error)
753{
Greg Clayton52fd9842011-02-02 02:24:04 +0000754 char path[PATH_MAX];
755 if (file_spec.GetPath(path, sizeof(path)))
756 {
Greg Clayton14ef59f2011-02-08 00:35:34 +0000757 int mode = 0;
758
759 if (options & eDynamicLibraryOpenOptionLazy)
760 mode |= RTLD_LAZY;
Greg Claytonbf467b02011-02-08 05:24:57 +0000761 else
762 mode |= RTLD_NOW;
763
Greg Clayton14ef59f2011-02-08 00:35:34 +0000764
765 if (options & eDynamicLibraryOpenOptionLocal)
766 mode |= RTLD_LOCAL;
767 else
768 mode |= RTLD_GLOBAL;
769
770#ifdef LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED
771 if (options & eDynamicLibraryOpenOptionLimitGetSymbol)
772 mode |= RTLD_FIRST;
Greg Clayton0f577c22011-02-07 17:43:47 +0000773#endif
Greg Clayton14ef59f2011-02-08 00:35:34 +0000774
775 void * opaque = ::dlopen (path, mode);
776
777 if (opaque)
Greg Clayton52fd9842011-02-02 02:24:04 +0000778 {
779 error.Clear();
Greg Clayton14ef59f2011-02-08 00:35:34 +0000780 return new DynamicLibraryInfo (file_spec, options, opaque);
Greg Clayton52fd9842011-02-02 02:24:04 +0000781 }
782 else
783 {
784 error.SetErrorString(::dlerror());
785 }
786 }
787 else
788 {
789 error.SetErrorString("failed to extract path");
790 }
Greg Clayton14ef59f2011-02-08 00:35:34 +0000791 return NULL;
Greg Clayton52fd9842011-02-02 02:24:04 +0000792}
793
794Error
Greg Clayton14ef59f2011-02-08 00:35:34 +0000795Host::DynamicLibraryClose (void *opaque)
Greg Clayton52fd9842011-02-02 02:24:04 +0000796{
797 Error error;
Greg Clayton14ef59f2011-02-08 00:35:34 +0000798 if (opaque == NULL)
Greg Clayton52fd9842011-02-02 02:24:04 +0000799 {
800 error.SetErrorString ("invalid dynamic library handle");
801 }
Greg Clayton14ef59f2011-02-08 00:35:34 +0000802 else
Greg Clayton52fd9842011-02-02 02:24:04 +0000803 {
Greg Clayton14ef59f2011-02-08 00:35:34 +0000804 DynamicLibraryInfo *dylib_info = (DynamicLibraryInfo *) opaque;
805 if (::dlclose (dylib_info->handle) != 0)
806 {
807 error.SetErrorString(::dlerror());
808 }
809
810 dylib_info->open_options = 0;
811 dylib_info->handle = 0;
812 delete dylib_info;
Greg Clayton52fd9842011-02-02 02:24:04 +0000813 }
814 return error;
815}
816
817void *
Greg Clayton14ef59f2011-02-08 00:35:34 +0000818Host::DynamicLibraryGetSymbol (void *opaque, const char *symbol_name, Error &error)
Greg Clayton52fd9842011-02-02 02:24:04 +0000819{
Greg Clayton14ef59f2011-02-08 00:35:34 +0000820 if (opaque == NULL)
Greg Clayton52fd9842011-02-02 02:24:04 +0000821 {
822 error.SetErrorString ("invalid dynamic library handle");
Greg Clayton52fd9842011-02-02 02:24:04 +0000823 }
Greg Clayton52fd9842011-02-02 02:24:04 +0000824 else
Greg Clayton14ef59f2011-02-08 00:35:34 +0000825 {
826 DynamicLibraryInfo *dylib_info = (DynamicLibraryInfo *) opaque;
827
828 void *symbol_addr = ::dlsym (dylib_info->handle, symbol_name);
829 if (symbol_addr)
830 {
831#ifndef LLDB_CONFIG_DLOPEN_RTLD_FIRST_SUPPORTED
832 // This host doesn't support limiting searches to this shared library
833 // so we need to verify that the match came from this shared library
834 // if it was requested in the Host::DynamicLibraryOpen() function.
Greg Claytonbf467b02011-02-08 05:24:57 +0000835 if (dylib_info->open_options & eDynamicLibraryOpenOptionLimitGetSymbol)
Greg Clayton14ef59f2011-02-08 00:35:34 +0000836 {
837 FileSpec match_dylib_spec (Host::GetModuleFileSpecForHostAddress (symbol_addr));
838 if (match_dylib_spec != dylib_info->file_spec)
839 {
840 char dylib_path[PATH_MAX];
841 if (dylib_info->file_spec.GetPath (dylib_path, sizeof(dylib_path)))
842 error.SetErrorStringWithFormat ("symbol not found in \"%s\"", dylib_path);
843 else
844 error.SetErrorString ("symbol not found");
845 return NULL;
846 }
847 }
848#endif
849 error.Clear();
850 return symbol_addr;
851 }
852 else
853 {
854 error.SetErrorString(::dlerror());
855 }
856 }
857 return NULL;
Greg Clayton52fd9842011-02-02 02:24:04 +0000858}
Greg Clayton24b48ff2010-10-17 22:03:32 +0000859
860bool
861Host::GetLLDBPath (PathType path_type, FileSpec &file_spec)
862{
Greg Clayton5d187e52011-01-08 20:28:42 +0000863 // To get paths related to LLDB we get the path to the executable that
Greg Clayton24b48ff2010-10-17 22:03:32 +0000864 // contains this function. On MacOSX this will be "LLDB.framework/.../LLDB",
865 // on linux this is assumed to be the "lldb" main executable. If LLDB on
866 // linux is actually in a shared library (lldb.so??) then this function will
867 // need to be modified to "do the right thing".
868
869 switch (path_type)
870 {
871 case ePathTypeLLDBShlibDir:
872 {
873 static ConstString g_lldb_so_dir;
874 if (!g_lldb_so_dir)
875 {
876 FileSpec lldb_file_spec (Host::GetModuleFileSpecForHostAddress ((void *)Host::GetLLDBPath));
877 g_lldb_so_dir = lldb_file_spec.GetDirectory();
878 }
879 file_spec.GetDirectory() = g_lldb_so_dir;
880 return file_spec.GetDirectory();
881 }
882 break;
883
884 case ePathTypeSupportExecutableDir:
885 {
886 static ConstString g_lldb_support_exe_dir;
887 if (!g_lldb_support_exe_dir)
888 {
889 FileSpec lldb_file_spec;
890 if (GetLLDBPath (ePathTypeLLDBShlibDir, lldb_file_spec))
891 {
892 char raw_path[PATH_MAX];
893 char resolved_path[PATH_MAX];
894 lldb_file_spec.GetPath(raw_path, sizeof(raw_path));
895
896#if defined (__APPLE__)
897 char *framework_pos = ::strstr (raw_path, "LLDB.framework");
898 if (framework_pos)
899 {
900 framework_pos += strlen("LLDB.framework");
901 ::strncpy (framework_pos, "/Resources", PATH_MAX - (framework_pos - raw_path));
902 }
903#endif
904 FileSpec::Resolve (raw_path, resolved_path, sizeof(resolved_path));
905 g_lldb_support_exe_dir.SetCString(resolved_path);
906 }
907 }
908 file_spec.GetDirectory() = g_lldb_support_exe_dir;
909 return file_spec.GetDirectory();
910 }
911 break;
912
913 case ePathTypeHeaderDir:
914 {
915 static ConstString g_lldb_headers_dir;
916 if (!g_lldb_headers_dir)
917 {
918#if defined (__APPLE__)
919 FileSpec lldb_file_spec;
920 if (GetLLDBPath (ePathTypeLLDBShlibDir, lldb_file_spec))
921 {
922 char raw_path[PATH_MAX];
923 char resolved_path[PATH_MAX];
924 lldb_file_spec.GetPath(raw_path, sizeof(raw_path));
925
926 char *framework_pos = ::strstr (raw_path, "LLDB.framework");
927 if (framework_pos)
928 {
929 framework_pos += strlen("LLDB.framework");
930 ::strncpy (framework_pos, "/Headers", PATH_MAX - (framework_pos - raw_path));
931 }
932 FileSpec::Resolve (raw_path, resolved_path, sizeof(resolved_path));
933 g_lldb_headers_dir.SetCString(resolved_path);
934 }
935#else
Greg Clayton52fd9842011-02-02 02:24:04 +0000936 // TODO: Anyone know how we can determine this for linux? Other systems??
Greg Clayton24b48ff2010-10-17 22:03:32 +0000937 g_lldb_headers_dir.SetCString ("/opt/local/include/lldb");
938#endif
939 }
940 file_spec.GetDirectory() = g_lldb_headers_dir;
941 return file_spec.GetDirectory();
942 }
943 break;
944
945 case ePathTypePythonDir:
946 {
Greg Clayton52fd9842011-02-02 02:24:04 +0000947 // TODO: Anyone know how we can determine this for linux? Other systems?
Greg Clayton24b48ff2010-10-17 22:03:32 +0000948 // For linux we are currently assuming the location of the lldb
949 // binary that contains this function is the directory that will
950 // contain lldb.so, lldb.py and embedded_interpreter.py...
951
952 static ConstString g_lldb_python_dir;
953 if (!g_lldb_python_dir)
954 {
955 FileSpec lldb_file_spec;
956 if (GetLLDBPath (ePathTypeLLDBShlibDir, lldb_file_spec))
957 {
958 char raw_path[PATH_MAX];
959 char resolved_path[PATH_MAX];
960 lldb_file_spec.GetPath(raw_path, sizeof(raw_path));
961
962#if defined (__APPLE__)
963 char *framework_pos = ::strstr (raw_path, "LLDB.framework");
964 if (framework_pos)
965 {
966 framework_pos += strlen("LLDB.framework");
967 ::strncpy (framework_pos, "/Resources/Python", PATH_MAX - (framework_pos - raw_path));
968 }
969#endif
970 FileSpec::Resolve (raw_path, resolved_path, sizeof(resolved_path));
971 g_lldb_python_dir.SetCString(resolved_path);
972 }
973 }
974 file_spec.GetDirectory() = g_lldb_python_dir;
975 return file_spec.GetDirectory();
976 }
977 break;
978
Greg Clayton52fd9842011-02-02 02:24:04 +0000979 case ePathTypeLLDBSystemPlugins: // System plug-ins directory
980 {
981#if defined (__APPLE__)
982 static ConstString g_lldb_system_plugin_dir;
Greg Clayton58e26e02011-03-24 04:28:38 +0000983 static bool g_lldb_system_plugin_dir_located = false;
984 if (!g_lldb_system_plugin_dir_located)
Greg Clayton52fd9842011-02-02 02:24:04 +0000985 {
Greg Clayton58e26e02011-03-24 04:28:38 +0000986 g_lldb_system_plugin_dir_located = true;
Greg Clayton52fd9842011-02-02 02:24:04 +0000987 FileSpec lldb_file_spec;
988 if (GetLLDBPath (ePathTypeLLDBShlibDir, lldb_file_spec))
989 {
990 char raw_path[PATH_MAX];
991 char resolved_path[PATH_MAX];
992 lldb_file_spec.GetPath(raw_path, sizeof(raw_path));
993
994 char *framework_pos = ::strstr (raw_path, "LLDB.framework");
995 if (framework_pos)
996 {
997 framework_pos += strlen("LLDB.framework");
998 ::strncpy (framework_pos, "/Resources/PlugIns", PATH_MAX - (framework_pos - raw_path));
Greg Clayton58e26e02011-03-24 04:28:38 +0000999 FileSpec::Resolve (raw_path, resolved_path, sizeof(resolved_path));
1000 g_lldb_system_plugin_dir.SetCString(resolved_path);
Greg Clayton52fd9842011-02-02 02:24:04 +00001001 }
Greg Clayton58e26e02011-03-24 04:28:38 +00001002 return false;
Greg Clayton52fd9842011-02-02 02:24:04 +00001003 }
1004 }
Greg Clayton58e26e02011-03-24 04:28:38 +00001005
1006 if (g_lldb_system_plugin_dir)
1007 {
1008 file_spec.GetDirectory() = g_lldb_system_plugin_dir;
1009 return true;
1010 }
Greg Clayton52fd9842011-02-02 02:24:04 +00001011#endif
1012 // TODO: where would system LLDB plug-ins be located on linux? Other systems?
1013 return false;
1014 }
1015 break;
1016
1017 case ePathTypeLLDBUserPlugins: // User plug-ins directory
1018 {
1019#if defined (__APPLE__)
1020 static ConstString g_lldb_user_plugin_dir;
1021 if (!g_lldb_user_plugin_dir)
1022 {
1023 char user_plugin_path[PATH_MAX];
1024 if (FileSpec::Resolve ("~/Library/Application Support/LLDB/PlugIns",
1025 user_plugin_path,
1026 sizeof(user_plugin_path)))
1027 {
1028 g_lldb_user_plugin_dir.SetCString(user_plugin_path);
1029 }
1030 }
1031 file_spec.GetDirectory() = g_lldb_user_plugin_dir;
1032 return file_spec.GetDirectory();
1033#endif
1034 // TODO: where would user LLDB plug-ins be located on linux? Other systems?
1035 return false;
1036 }
Greg Clayton24b48ff2010-10-17 22:03:32 +00001037 default:
1038 assert (!"Unhandled PathType");
1039 break;
1040 }
1041
1042 return false;
1043}
1044
Greg Clayton58e26e02011-03-24 04:28:38 +00001045
1046bool
1047Host::GetHostname (std::string &s)
1048{
1049 char hostname[PATH_MAX];
1050 hostname[sizeof(hostname) - 1] = '\0';
1051 if (::gethostname (hostname, sizeof(hostname) - 1) == 0)
1052 {
1053 struct hostent* h = ::gethostbyname (hostname);
1054 if (h)
1055 s.assign (h->h_name);
1056 else
1057 s.assign (hostname);
1058 return true;
1059 }
1060 return false;
1061}
1062
Greg Clayton24bc5d92011-03-30 18:16:51 +00001063const char *
1064Host::GetUserName (uint32_t uid, std::string &user_name)
1065{
1066 struct passwd user_info;
1067 struct passwd *user_info_ptr = &user_info;
1068 char user_buffer[PATH_MAX];
1069 size_t user_buffer_size = sizeof(user_buffer);
1070 if (::getpwuid_r (uid,
1071 &user_info,
1072 user_buffer,
1073 user_buffer_size,
1074 &user_info_ptr) == 0)
1075 {
1076 if (user_info_ptr)
1077 {
1078 user_name.assign (user_info_ptr->pw_name);
1079 return user_name.c_str();
1080 }
1081 }
1082 user_name.clear();
1083 return NULL;
1084}
1085
1086const char *
1087Host::GetGroupName (uint32_t gid, std::string &group_name)
1088{
1089 char group_buffer[PATH_MAX];
1090 size_t group_buffer_size = sizeof(group_buffer);
1091 struct group group_info;
1092 struct group *group_info_ptr = &group_info;
1093 // Try the threadsafe version first
1094 if (::getgrgid_r (gid,
1095 &group_info,
1096 group_buffer,
1097 group_buffer_size,
1098 &group_info_ptr) == 0)
1099 {
1100 if (group_info_ptr)
1101 {
1102 group_name.assign (group_info_ptr->gr_name);
1103 return group_name.c_str();
1104 }
1105 }
1106 else
1107 {
1108 // The threadsafe version isn't currently working
1109 // for me on darwin, but the non-threadsafe version
1110 // is, so I am calling it below.
1111 group_info_ptr = ::getgrgid (gid);
1112 if (group_info_ptr)
1113 {
1114 group_name.assign (group_info_ptr->gr_name);
1115 return group_name.c_str();
1116 }
1117 }
1118 group_name.clear();
1119 return NULL;
1120}
1121
1122
Greg Claytona733c042011-03-21 21:25:07 +00001123#if !defined (__APPLE__) // see macosx/Host.mm
Greg Claytone4b9c1f2011-03-08 22:40:15 +00001124
Greg Clayton58e26e02011-03-24 04:28:38 +00001125bool
1126Host::GetOSBuildString (std::string &s)
1127{
1128 s.clear();
1129 return false;
1130}
1131
1132bool
1133Host::GetOSKernelDescription (std::string &s)
1134{
1135 s.clear();
1136 return false;
1137}
1138
Greg Claytone4b9c1f2011-03-08 22:40:15 +00001139uint32_t
Greg Clayton24bc5d92011-03-30 18:16:51 +00001140Host::FindProcesses (const ProcessInfoMatch &match_info, ProcessInfoList &process_infos)
Greg Claytone4b9c1f2011-03-08 22:40:15 +00001141{
1142 process_infos.Clear();
Greg Claytone4b9c1f2011-03-08 22:40:15 +00001143 return process_infos.GetSize();
Greg Clayton8f3b21d2010-09-07 20:11:56 +00001144}
1145
Greg Claytone4b9c1f2011-03-08 22:40:15 +00001146bool
1147Host::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info)
Greg Clayton8f3b21d2010-09-07 20:11:56 +00001148{
Greg Claytone4b9c1f2011-03-08 22:40:15 +00001149 process_info.Clear();
1150 return false;
Greg Clayton8f3b21d2010-09-07 20:11:56 +00001151}
1152
Greg Clayton8f3b21d2010-09-07 20:11:56 +00001153bool
Greg Claytonb73620c2010-12-18 01:54:34 +00001154Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no)
Greg Clayton8f3b21d2010-09-07 20:11:56 +00001155{
1156 return false;
1157}
Greg Clayton24b48ff2010-10-17 22:03:32 +00001158
Greg Claytone98ac252010-11-10 04:57:04 +00001159void
1160Host::SetCrashDescriptionWithFormat (const char *format, ...)
1161{
1162}
1163
1164void
1165Host::SetCrashDescription (const char *description)
1166{
1167}
Greg Clayton24b48ff2010-10-17 22:03:32 +00001168
1169lldb::pid_t
1170LaunchApplication (const FileSpec &app_file_spec)
1171{
1172 return LLDB_INVALID_PROCESS_ID;
1173}
1174
1175lldb::pid_t
1176Host::LaunchInNewTerminal
1177(
Greg Claytonb73620c2010-12-18 01:54:34 +00001178 const char *tty_name,
Greg Clayton24b48ff2010-10-17 22:03:32 +00001179 const char **argv,
1180 const char **envp,
Greg Claytonde915be2011-01-23 05:56:20 +00001181 const char *working_dir,
Greg Clayton24b48ff2010-10-17 22:03:32 +00001182 const ArchSpec *arch_spec,
1183 bool stop_at_entry,
1184 bool disable_aslr
1185)
1186{
1187 return LLDB_INVALID_PROCESS_ID;
1188}
1189
Greg Clayton8f3b21d2010-09-07 20:11:56 +00001190#endif