1 //===-- PlatformDarwin.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/lldb-python.h"
11 
12 #include "PlatformDarwin.h"
13 
14 // C Includes
15 // C++ Includes
16 // Other libraries and framework includes
17 // Project includes
18 #include "lldb/Breakpoint/BreakpointLocation.h"
19 #include "lldb/Core/Debugger.h"
20 #include "lldb/Core/Error.h"
21 #include "lldb/Core/Log.h"
22 #include "lldb/Core/Module.h"
23 #include "lldb/Core/ModuleSpec.h"
24 #include "lldb/Core/Timer.h"
25 #include "lldb/Host/Host.h"
26 #include "lldb/Host/HostInfo.h"
27 #include "lldb/Host/FileSystem.h"
28 #include "lldb/Host/Symbols.h"
29 #include "lldb/Symbol/ObjectFile.h"
30 #include "lldb/Symbol/SymbolFile.h"
31 #include "lldb/Symbol/SymbolVendor.h"
32 #include "lldb/Target/Target.h"
33 #include "llvm/ADT/STLExtras.h"
34 
35 using namespace lldb;
36 using namespace lldb_private;
37 
38 
39 //------------------------------------------------------------------
40 /// Default Constructor
41 //------------------------------------------------------------------
42 PlatformDarwin::PlatformDarwin (bool is_host) :
43     PlatformPOSIX(is_host),  // This is the local host platform
44     m_developer_directory ()
45 {
46 }
47 
48 //------------------------------------------------------------------
49 /// Destructor.
50 ///
51 /// The destructor is virtual since this class is designed to be
52 /// inherited from by the plug-in instance.
53 //------------------------------------------------------------------
54 PlatformDarwin::~PlatformDarwin()
55 {
56 }
57 
58 FileSpecList
59 PlatformDarwin::LocateExecutableScriptingResources (Target *target,
60                                                     Module &module,
61                                                     Stream* feedback_stream)
62 {
63     FileSpecList file_list;
64     if (target && target->GetDebugger().GetScriptLanguage() == eScriptLanguagePython)
65     {
66         // NB some extensions might be meaningful and should not be stripped - "this.binary.file"
67         // should not lose ".file" but GetFileNameStrippingExtension() will do precisely that.
68         // Ideally, we should have a per-platform list of extensions (".exe", ".app", ".dSYM", ".framework")
69         // which should be stripped while leaving "this.binary.file" as-is.
70         FileSpec module_spec = module.GetFileSpec();
71 
72         if (module_spec)
73         {
74             SymbolVendor *symbols = module.GetSymbolVendor ();
75             if (symbols)
76             {
77                 SymbolFile *symfile = symbols->GetSymbolFile();
78                 if (symfile)
79                 {
80                     ObjectFile *objfile = symfile->GetObjectFile();
81                     if (objfile)
82                     {
83                         FileSpec symfile_spec (objfile->GetFileSpec());
84                         if (symfile_spec && symfile_spec.Exists())
85                         {
86                             while (module_spec.GetFilename())
87                             {
88                                 std::string module_basename (module_spec.GetFilename().GetCString());
89                                 std::string original_module_basename (module_basename);
90 
91                                 // FIXME: for Python, we cannot allow certain characters in module
92                                 // filenames we import. Theoretically, different scripting languages may
93                                 // have different sets of forbidden tokens in filenames, and that should
94                                 // be dealt with by each ScriptInterpreter. For now, we just replace dots
95                                 // with underscores, but if we ever support anything other than Python
96                                 // we will need to rework this
97                                 std::replace(module_basename.begin(), module_basename.end(), '.', '_');
98                                 std::replace(module_basename.begin(), module_basename.end(), ' ', '_');
99                                 std::replace(module_basename.begin(), module_basename.end(), '-', '_');
100 
101 
102                                 StreamString path_string;
103                                 StreamString original_path_string;
104                                 // for OSX we are going to be in .dSYM/Contents/Resources/DWARF/<basename>
105                                 // let us go to .dSYM/Contents/Resources/Python/<basename>.py and see if the file exists
106                                 path_string.Printf("%s/../Python/%s.py",symfile_spec.GetDirectory().GetCString(), module_basename.c_str());
107                                 original_path_string.Printf("%s/../Python/%s.py",symfile_spec.GetDirectory().GetCString(), original_module_basename.c_str());
108                                 FileSpec script_fspec(path_string.GetData(), true);
109                                 FileSpec orig_script_fspec(original_path_string.GetData(), true);
110 
111                                 // if we did some replacements of reserved characters, and a file with the untampered name
112                                 // exists, then warn the user that the file as-is shall not be loaded
113                                 if (feedback_stream)
114                                 {
115                                     if (module_basename != original_module_basename
116                                         && orig_script_fspec.Exists())
117                                     {
118                                         if (script_fspec.Exists())
119                                             feedback_stream->Printf("warning: the symbol file '%s' contains a debug script. However, its name"
120                                                                     " '%s' contains reserved characters and as such cannot be loaded. LLDB will"
121                                                                     " load '%s' instead. Consider removing the file with the malformed name to"
122                                                                     " eliminate this warning.\n",
123                                                                     symfile_spec.GetPath().c_str(),
124                                                                     original_path_string.GetData(),
125                                                                     path_string.GetData());
126                                         else
127                                             feedback_stream->Printf("warning: the symbol file '%s' contains a debug script. However, its name"
128                                                                     " contains reserved characters and as such cannot be loaded. If you intend"
129                                                                     " to have this script loaded, please rename '%s' to '%s' and retry.\n",
130                                                                     symfile_spec.GetPath().c_str(),
131                                                                     original_path_string.GetData(),
132                                                                     path_string.GetData());
133                                     }
134                                 }
135 
136                                 if (script_fspec.Exists())
137                                 {
138                                     file_list.Append (script_fspec);
139                                     break;
140                                 }
141 
142                                 // If we didn't find the python file, then keep
143                                 // stripping the extensions and try again
144                                 ConstString filename_no_extension (module_spec.GetFileNameStrippingExtension());
145                                 if (module_spec.GetFilename() == filename_no_extension)
146                                     break;
147 
148                                 module_spec.GetFilename() = filename_no_extension;
149                             }
150                         }
151                     }
152                 }
153             }
154         }
155     }
156     return file_list;
157 }
158 
159 Error
160 PlatformDarwin::ResolveExecutable (const FileSpec &exe_file,
161                                    const ArchSpec &exe_arch,
162                                    lldb::ModuleSP &exe_module_sp,
163                                    const FileSpecList *module_search_paths_ptr)
164 {
165     Error error;
166     // Nothing special to do here, just use the actual file and architecture
167 
168     char exe_path[PATH_MAX];
169     FileSpec resolved_exe_file (exe_file);
170 
171     if (IsHost())
172     {
173         // If we have "ls" as the exe_file, resolve the executable loation based on
174         // the current path variables
175         if (resolved_exe_file.Exists())
176         {
177 
178         }
179         else
180         {
181             exe_file.GetPath (exe_path, sizeof(exe_path));
182             resolved_exe_file.SetFile(exe_path, true);
183         }
184 
185         if (!resolved_exe_file.Exists())
186             resolved_exe_file.ResolveExecutableLocation ();
187 
188         // Resolve any executable within a bundle on MacOSX
189         Host::ResolveExecutableInBundle (resolved_exe_file);
190 
191         if (resolved_exe_file.Exists())
192             error.Clear();
193         else
194         {
195             const uint32_t permissions = resolved_exe_file.GetPermissions();
196             if (permissions && (permissions & eFilePermissionsEveryoneR) == 0)
197                 error.SetErrorStringWithFormat ("executable '%s' is not readable", resolved_exe_file.GetPath().c_str());
198             else
199                 error.SetErrorStringWithFormat ("unable to find executable for '%s'", resolved_exe_file.GetPath().c_str());
200         }
201     }
202     else
203     {
204         if (m_remote_platform_sp)
205         {
206             error = m_remote_platform_sp->ResolveExecutable (exe_file,
207                                                              exe_arch,
208                                                              exe_module_sp,
209                                                              module_search_paths_ptr);
210         }
211         else
212         {
213             // We may connect to a process and use the provided executable (Don't use local $PATH).
214 
215             // Resolve any executable within a bundle on MacOSX
216             Host::ResolveExecutableInBundle (resolved_exe_file);
217 
218             if (resolved_exe_file.Exists())
219                 error.Clear();
220             else
221                 error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", resolved_exe_file.GetFilename().AsCString(""));
222         }
223     }
224 
225 
226     if (error.Success())
227     {
228         ModuleSpec module_spec (resolved_exe_file, exe_arch);
229         if (module_spec.GetArchitecture().IsValid())
230         {
231             error = ModuleList::GetSharedModule (module_spec,
232                                                  exe_module_sp,
233                                                  module_search_paths_ptr,
234                                                  NULL,
235                                                  NULL);
236 
237             if (error.Fail() || exe_module_sp.get() == NULL || exe_module_sp->GetObjectFile() == NULL)
238             {
239                 exe_module_sp.reset();
240                 error.SetErrorStringWithFormat ("'%s' doesn't contain the architecture %s",
241                                                 exe_file.GetPath().c_str(),
242                                                 exe_arch.GetArchitectureName());
243             }
244         }
245         else
246         {
247             // No valid architecture was specified, ask the platform for
248             // the architectures that we should be using (in the correct order)
249             // and see if we can find a match that way
250             StreamString arch_names;
251             for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, module_spec.GetArchitecture()); ++idx)
252             {
253                 error = GetSharedModule (module_spec,
254                                          exe_module_sp,
255                                          module_search_paths_ptr,
256                                          NULL,
257                                          NULL);
258                 // Did we find an executable using one of the
259                 if (error.Success())
260                 {
261                     if (exe_module_sp && exe_module_sp->GetObjectFile())
262                         break;
263                     else
264                         error.SetErrorToGenericError();
265                 }
266 
267                 if (idx > 0)
268                     arch_names.PutCString (", ");
269                 arch_names.PutCString (module_spec.GetArchitecture().GetArchitectureName());
270             }
271 
272             if (error.Fail() || !exe_module_sp)
273             {
274                 if (exe_file.Readable())
275                 {
276                     error.SetErrorStringWithFormat ("'%s' doesn't contain any '%s' platform architectures: %s",
277                                                     exe_file.GetPath().c_str(),
278                                                     GetPluginName().GetCString(),
279                                                     arch_names.GetString().c_str());
280                 }
281                 else
282                 {
283                     error.SetErrorStringWithFormat("'%s' is not readable", exe_file.GetPath().c_str());
284                 }
285             }
286         }
287     }
288 
289     return error;
290 }
291 
292 Error
293 PlatformDarwin::ResolveSymbolFile (Target &target,
294                                    const ModuleSpec &sym_spec,
295                                    FileSpec &sym_file)
296 {
297     Error error;
298     sym_file = sym_spec.GetSymbolFileSpec();
299     if (sym_file.Exists())
300     {
301         if (sym_file.GetFileType() == FileSpec::eFileTypeDirectory)
302         {
303             sym_file = Symbols::FindSymbolFileInBundle (sym_file,
304                                                         sym_spec.GetUUIDPtr(),
305                                                         sym_spec.GetArchitecturePtr());
306         }
307     }
308     else
309     {
310         if (sym_spec.GetUUID().IsValid())
311         {
312 
313         }
314     }
315     return error;
316 
317 }
318 
319 static lldb_private::Error
320 MakeCacheFolderForFile (const FileSpec& module_cache_spec)
321 {
322     FileSpec module_cache_folder = module_cache_spec.CopyByRemovingLastPathComponent();
323     return FileSystem::MakeDirectory(module_cache_folder.GetPath().c_str(), eFilePermissionsDirectoryDefault);
324 }
325 
326 static lldb_private::Error
327 BringInRemoteFile (Platform* platform,
328                    const lldb_private::ModuleSpec &module_spec,
329                    const FileSpec& module_cache_spec)
330 {
331     MakeCacheFolderForFile(module_cache_spec);
332     Error err = platform->GetFile(module_spec.GetFileSpec(), module_cache_spec);
333     return err;
334 }
335 
336 lldb_private::Error
337 PlatformDarwin::GetSharedModuleWithLocalCache (const lldb_private::ModuleSpec &module_spec,
338                                                lldb::ModuleSP &module_sp,
339                                                const lldb_private::FileSpecList *module_search_paths_ptr,
340                                                lldb::ModuleSP *old_module_sp_ptr,
341                                                bool *did_create_ptr)
342 {
343 
344     Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
345     if (log)
346         log->Printf("[%s] Trying to find module %s/%s - platform path %s/%s symbol path %s/%s",
347                      (IsHost() ? "host" : "remote"),
348                      module_spec.GetFileSpec().GetDirectory().AsCString(),
349                      module_spec.GetFileSpec().GetFilename().AsCString(),
350                      module_spec.GetPlatformFileSpec().GetDirectory().AsCString(),
351                      module_spec.GetPlatformFileSpec().GetFilename().AsCString(),
352                      module_spec.GetSymbolFileSpec().GetDirectory().AsCString(),
353                      module_spec.GetSymbolFileSpec().GetFilename().AsCString());
354 
355     Error err;
356 
357     err = ModuleList::GetSharedModule(module_spec, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr);
358     if (module_sp)
359         return err;
360 
361     if (!IsHost())
362     {
363         std::string cache_path(GetLocalCacheDirectory());
364         // Only search for a locally cached file if we have a valid cache path
365         if (!cache_path.empty())
366         {
367             std::string module_path (module_spec.GetFileSpec().GetPath());
368             cache_path.append(module_path);
369             FileSpec module_cache_spec(cache_path.c_str(),false);
370 
371             // if rsync is supported, always bring in the file - rsync will be very efficient
372             // when files are the same on the local and remote end of the connection
373             if (this->GetSupportsRSync())
374             {
375                 err = BringInRemoteFile (this, module_spec, module_cache_spec);
376                 if (err.Fail())
377                     return err;
378                 if (module_cache_spec.Exists())
379                 {
380                     Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
381                     if (log)
382                         log->Printf("[%s] module %s/%s was rsynced and is now there",
383                                      (IsHost() ? "host" : "remote"),
384                                      module_spec.GetFileSpec().GetDirectory().AsCString(),
385                                      module_spec.GetFileSpec().GetFilename().AsCString());
386                     ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
387                     module_sp.reset(new Module(local_spec));
388                     module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
389                     return Error();
390                 }
391             }
392 
393             // try to find the module in the cache
394             if (module_cache_spec.Exists())
395             {
396                 // get the local and remote MD5 and compare
397                 if (m_remote_platform_sp)
398                 {
399                     // when going over the *slow* GDB remote transfer mechanism we first check
400                     // the hashes of the files - and only do the actual transfer if they differ
401                     uint64_t high_local,high_remote,low_local,low_remote;
402                     FileSystem::CalculateMD5(module_cache_spec, low_local, high_local);
403                     m_remote_platform_sp->CalculateMD5(module_spec.GetFileSpec(), low_remote, high_remote);
404                     if (low_local != low_remote || high_local != high_remote)
405                     {
406                         // bring in the remote file
407                         Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
408                         if (log)
409                             log->Printf("[%s] module %s/%s needs to be replaced from remote copy",
410                                          (IsHost() ? "host" : "remote"),
411                                          module_spec.GetFileSpec().GetDirectory().AsCString(),
412                                          module_spec.GetFileSpec().GetFilename().AsCString());
413                         Error err = BringInRemoteFile (this, module_spec, module_cache_spec);
414                         if (err.Fail())
415                             return err;
416                     }
417                 }
418 
419                 ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
420                 module_sp.reset(new Module(local_spec));
421                 module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
422                 Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
423                     if (log)
424                         log->Printf("[%s] module %s/%s was found in the cache",
425                                      (IsHost() ? "host" : "remote"),
426                                      module_spec.GetFileSpec().GetDirectory().AsCString(),
427                                      module_spec.GetFileSpec().GetFilename().AsCString());
428                 return Error();
429             }
430 
431             // bring in the remote module file
432             if (log)
433                 log->Printf("[%s] module %s/%s needs to come in remotely",
434                              (IsHost() ? "host" : "remote"),
435                              module_spec.GetFileSpec().GetDirectory().AsCString(),
436                              module_spec.GetFileSpec().GetFilename().AsCString());
437             Error err = BringInRemoteFile (this, module_spec, module_cache_spec);
438             if (err.Fail())
439                 return err;
440             if (module_cache_spec.Exists())
441             {
442                 Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
443                 if (log)
444                     log->Printf("[%s] module %s/%s is now cached and fine",
445                                  (IsHost() ? "host" : "remote"),
446                                  module_spec.GetFileSpec().GetDirectory().AsCString(),
447                                  module_spec.GetFileSpec().GetFilename().AsCString());
448                 ModuleSpec local_spec(module_cache_spec, module_spec.GetArchitecture());
449                 module_sp.reset(new Module(local_spec));
450                 module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
451                 return Error();
452             }
453             else
454                 return Error("unable to obtain valid module file");
455         }
456         else
457             return Error("no cache path");
458     }
459     else
460         return Error ("unable to resolve module");
461 }
462 
463 Error
464 PlatformDarwin::GetSharedModule (const ModuleSpec &module_spec,
465                                  ModuleSP &module_sp,
466                                  const FileSpecList *module_search_paths_ptr,
467                                  ModuleSP *old_module_sp_ptr,
468                                  bool *did_create_ptr)
469 {
470     Error error;
471     module_sp.reset();
472 
473     if (IsRemote())
474     {
475         // If we have a remote platform always, let it try and locate
476         // the shared module first.
477         if (m_remote_platform_sp)
478         {
479             error = m_remote_platform_sp->GetSharedModule (module_spec,
480                                                            module_sp,
481                                                            module_search_paths_ptr,
482                                                            old_module_sp_ptr,
483                                                            did_create_ptr);
484         }
485     }
486 
487     if (!module_sp)
488     {
489         // Fall back to the local platform and find the file locally
490         error = Platform::GetSharedModule (module_spec,
491                                            module_sp,
492                                            module_search_paths_ptr,
493                                            old_module_sp_ptr,
494                                            did_create_ptr);
495 
496         const FileSpec &platform_file = module_spec.GetFileSpec();
497         if (!module_sp && module_search_paths_ptr && platform_file)
498         {
499             // We can try to pull off part of the file path up to the bundle
500             // directory level and try any module search paths...
501             FileSpec bundle_directory;
502             if (Host::GetBundleDirectory (platform_file, bundle_directory))
503             {
504                 if (platform_file == bundle_directory)
505                 {
506                     ModuleSpec new_module_spec (module_spec);
507                     new_module_spec.GetFileSpec() = bundle_directory;
508                     if (Host::ResolveExecutableInBundle (new_module_spec.GetFileSpec()))
509                     {
510                         Error new_error (Platform::GetSharedModule (new_module_spec,
511                                                                     module_sp,
512                                                                     NULL,
513                                                                     old_module_sp_ptr,
514                                                                     did_create_ptr));
515 
516                         if (module_sp)
517                             return new_error;
518                     }
519                 }
520                 else
521                 {
522                     char platform_path[PATH_MAX];
523                     char bundle_dir[PATH_MAX];
524                     platform_file.GetPath (platform_path, sizeof(platform_path));
525                     const size_t bundle_directory_len = bundle_directory.GetPath (bundle_dir, sizeof(bundle_dir));
526                     char new_path[PATH_MAX];
527                     size_t num_module_search_paths = module_search_paths_ptr->GetSize();
528                     for (size_t i=0; i<num_module_search_paths; ++i)
529                     {
530                         const size_t search_path_len = module_search_paths_ptr->GetFileSpecAtIndex(i).GetPath(new_path, sizeof(new_path));
531                         if (search_path_len < sizeof(new_path))
532                         {
533                             snprintf (new_path + search_path_len, sizeof(new_path) - search_path_len, "/%s", platform_path + bundle_directory_len);
534                             FileSpec new_file_spec (new_path, false);
535                             if (new_file_spec.Exists())
536                             {
537                                 ModuleSpec new_module_spec (module_spec);
538                                 new_module_spec.GetFileSpec() = new_file_spec;
539                                 Error new_error (Platform::GetSharedModule (new_module_spec,
540                                                                             module_sp,
541                                                                             NULL,
542                                                                             old_module_sp_ptr,
543                                                                             did_create_ptr));
544 
545                                 if (module_sp)
546                                 {
547                                     module_sp->SetPlatformFileSpec(new_file_spec);
548                                     return new_error;
549                                 }
550                             }
551                         }
552                     }
553                 }
554             }
555         }
556     }
557     if (module_sp)
558         module_sp->SetPlatformFileSpec(module_spec.GetFileSpec());
559     return error;
560 }
561 
562 size_t
563 PlatformDarwin::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
564 {
565     const uint8_t *trap_opcode = NULL;
566     uint32_t trap_opcode_size = 0;
567     bool bp_is_thumb = false;
568 
569     llvm::Triple::ArchType machine = target.GetArchitecture().GetMachine();
570     switch (machine)
571     {
572     case llvm::Triple::x86:
573     case llvm::Triple::x86_64:
574         {
575             static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
576             trap_opcode = g_i386_breakpoint_opcode;
577             trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
578         }
579         break;
580 
581     case llvm::Triple::aarch64:
582         {
583             // TODO: fix this with actual darwin breakpoint opcode for arm64.
584             // right now debugging uses the Z packets with GDB remote so this
585             // is not needed, but the size needs to be correct...
586             static const uint8_t g_arm64_breakpoint_opcode[] = { 0xFE, 0xDE, 0xFF, 0xE7 };
587             trap_opcode = g_arm64_breakpoint_opcode;
588             trap_opcode_size = sizeof(g_arm64_breakpoint_opcode);
589         }
590         break;
591 
592     case llvm::Triple::thumb:
593         bp_is_thumb = true; // Fall through...
594     case llvm::Triple::arm:
595         {
596             static const uint8_t g_arm_breakpoint_opcode[] = { 0xFE, 0xDE, 0xFF, 0xE7 };
597             static const uint8_t g_thumb_breakpooint_opcode[] = { 0xFE, 0xDE };
598 
599             // Auto detect arm/thumb if it wasn't explicitly specified
600             if (!bp_is_thumb)
601             {
602                 lldb::BreakpointLocationSP bp_loc_sp (bp_site->GetOwnerAtIndex (0));
603                 if (bp_loc_sp)
604                     bp_is_thumb = bp_loc_sp->GetAddress().GetAddressClass () == eAddressClassCodeAlternateISA;
605             }
606             if (bp_is_thumb)
607             {
608                 trap_opcode = g_thumb_breakpooint_opcode;
609                 trap_opcode_size = sizeof(g_thumb_breakpooint_opcode);
610                 break;
611             }
612             trap_opcode = g_arm_breakpoint_opcode;
613             trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
614         }
615         break;
616 
617     case llvm::Triple::ppc:
618     case llvm::Triple::ppc64:
619         {
620             static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 };
621             trap_opcode = g_ppc_breakpoint_opcode;
622             trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
623         }
624         break;
625 
626     default:
627         assert(!"Unhandled architecture in PlatformDarwin::GetSoftwareBreakpointTrapOpcode()");
628         break;
629     }
630 
631     if (trap_opcode && trap_opcode_size)
632     {
633         if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
634             return trap_opcode_size;
635     }
636     return 0;
637 
638 }
639 
640 bool
641 PlatformDarwin::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info)
642 {
643     bool sucess = false;
644     if (IsHost())
645     {
646         sucess = Platform::GetProcessInfo (pid, process_info);
647     }
648     else
649     {
650         if (m_remote_platform_sp)
651             sucess = m_remote_platform_sp->GetProcessInfo (pid, process_info);
652     }
653     return sucess;
654 }
655 
656 uint32_t
657 PlatformDarwin::FindProcesses (const ProcessInstanceInfoMatch &match_info,
658                                ProcessInstanceInfoList &process_infos)
659 {
660     uint32_t match_count = 0;
661     if (IsHost())
662     {
663         // Let the base class figure out the host details
664         match_count = Platform::FindProcesses (match_info, process_infos);
665     }
666     else
667     {
668         // If we are remote, we can only return results if we are connected
669         if (m_remote_platform_sp)
670             match_count = m_remote_platform_sp->FindProcesses (match_info, process_infos);
671     }
672     return match_count;
673 }
674 
675 bool
676 PlatformDarwin::ModuleIsExcludedForNonModuleSpecificSearches (lldb_private::Target &target, const lldb::ModuleSP &module_sp)
677 {
678     if (!module_sp)
679         return false;
680 
681     ObjectFile *obj_file = module_sp->GetObjectFile();
682     if (!obj_file)
683         return false;
684 
685     ObjectFile::Type obj_type = obj_file->GetType();
686     if (obj_type == ObjectFile::eTypeDynamicLinker)
687         return true;
688     else
689         return false;
690 }
691 
692 bool
693 PlatformDarwin::x86GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
694 {
695     ArchSpec host_arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
696     if (host_arch.GetCore() == ArchSpec::eCore_x86_64_x86_64h)
697     {
698         switch (idx)
699         {
700             case 0:
701                 arch = host_arch;
702                 return true;
703 
704             case 1:
705                 arch.SetTriple("x86_64-apple-macosx");
706                 return true;
707 
708             case 2:
709                 arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
710                 return true;
711 
712             default: return false;
713         }
714     }
715     else
716     {
717         if (idx == 0)
718         {
719             arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault);
720             return arch.IsValid();
721         }
722         else if (idx == 1)
723         {
724             ArchSpec platform_arch(HostInfo::GetArchitecture(HostInfo::eArchKindDefault));
725             ArchSpec platform_arch64(HostInfo::GetArchitecture(HostInfo::eArchKind64));
726             if (platform_arch.IsExactMatch(platform_arch64))
727             {
728                 // This macosx platform supports both 32 and 64 bit. Since we already
729                 // returned the 64 bit arch for idx == 0, return the 32 bit arch
730                 // for idx == 1
731                 arch = HostInfo::GetArchitecture(HostInfo::eArchKind32);
732                 return arch.IsValid();
733             }
734         }
735     }
736     return false;
737 }
738 
739 // The architecture selection rules for arm processors
740 // These cpu subtypes have distinct names (e.g. armv7f) but armv7 binaries run fine on an armv7f processor.
741 
742 bool
743 PlatformDarwin::ARMGetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
744 {
745     ArchSpec system_arch (GetSystemArchitecture());
746 
747     const ArchSpec::Core system_core = system_arch.GetCore();
748     switch (system_core)
749     {
750     default:
751         switch (idx)
752         {
753             case  0: arch.SetTriple ("arm64-apple-ios");    return true;
754             case  1: arch.SetTriple ("armv7-apple-ios");    return true;
755             case  2: arch.SetTriple ("armv7f-apple-ios");   return true;
756             case  3: arch.SetTriple ("armv7k-apple-ios");   return true;
757             case  4: arch.SetTriple ("armv7s-apple-ios");   return true;
758             case  5: arch.SetTriple ("armv7m-apple-ios");   return true;
759             case  6: arch.SetTriple ("armv7em-apple-ios");  return true;
760             case  7: arch.SetTriple ("armv6m-apple-ios");   return true;
761             case  8: arch.SetTriple ("armv6-apple-ios");    return true;
762             case  9: arch.SetTriple ("armv5-apple-ios");    return true;
763             case 10: arch.SetTriple ("armv4-apple-ios");    return true;
764             case 11: arch.SetTriple ("arm-apple-ios");      return true;
765             case 12: arch.SetTriple ("thumbv7-apple-ios");  return true;
766             case 13: arch.SetTriple ("thumbv7f-apple-ios"); return true;
767             case 14: arch.SetTriple ("thumbv7k-apple-ios"); return true;
768             case 15: arch.SetTriple ("thumbv7s-apple-ios"); return true;
769             case 16: arch.SetTriple ("thumbv7m-apple-ios"); return true;
770             case 17: arch.SetTriple ("thumbv7em-apple-ios"); return true;
771             case 18: arch.SetTriple ("thumbv6m-apple-ios"); return true;
772             case 19: arch.SetTriple ("thumbv6-apple-ios");  return true;
773             case 20: arch.SetTriple ("thumbv5-apple-ios");  return true;
774             case 21: arch.SetTriple ("thumbv4t-apple-ios"); return true;
775             case 22: arch.SetTriple ("thumb-apple-ios");    return true;
776             default: break;
777         }
778         break;
779 
780     case ArchSpec::eCore_arm_arm64:
781         switch (idx)
782         {
783             case  0: arch.SetTriple ("arm64-apple-ios");   return true;
784             case  1: arch.SetTriple ("armv7s-apple-ios");   return true;
785             case  2: arch.SetTriple ("armv7f-apple-ios");   return true;
786             case  3: arch.SetTriple ("armv7m-apple-ios");   return true;
787             case  4: arch.SetTriple ("armv7em-apple-ios");  return true;
788             case  5: arch.SetTriple ("armv7-apple-ios");    return true;
789             case  6: arch.SetTriple ("armv6m-apple-ios");   return true;
790             case  7: arch.SetTriple ("armv6-apple-ios");    return true;
791             case  8: arch.SetTriple ("armv5-apple-ios");    return true;
792             case  9: arch.SetTriple ("armv4-apple-ios");    return true;
793             case 10: arch.SetTriple ("arm-apple-ios");      return true;
794             case 11: arch.SetTriple ("thumbv7-apple-ios");  return true;
795             case 12: arch.SetTriple ("thumbv7f-apple-ios"); return true;
796             case 13: arch.SetTriple ("thumbv7k-apple-ios"); return true;
797             case 14: arch.SetTriple ("thumbv7s-apple-ios"); return true;
798             case 15: arch.SetTriple ("thumbv7m-apple-ios"); return true;
799             case 16: arch.SetTriple ("thumbv7em-apple-ios"); return true;
800             case 17: arch.SetTriple ("thumbv6m-apple-ios"); return true;
801             case 18: arch.SetTriple ("thumbv6-apple-ios");  return true;
802             case 19: arch.SetTriple ("thumbv5-apple-ios");  return true;
803             case 20: arch.SetTriple ("thumbv4t-apple-ios"); return true;
804             case 21: arch.SetTriple ("thumb-apple-ios");    return true;
805         default: break;
806         }
807         break;
808 
809     case ArchSpec::eCore_arm_armv7f:
810         switch (idx)
811         {
812             case  0: arch.SetTriple ("armv7f-apple-ios");   return true;
813             case  1: arch.SetTriple ("armv7-apple-ios");    return true;
814             case  2: arch.SetTriple ("armv6m-apple-ios");   return true;
815             case  3: arch.SetTriple ("armv6-apple-ios");    return true;
816             case  4: arch.SetTriple ("armv5-apple-ios");    return true;
817             case  5: arch.SetTriple ("armv4-apple-ios");    return true;
818             case  6: arch.SetTriple ("arm-apple-ios");      return true;
819             case  7: arch.SetTriple ("thumbv7f-apple-ios"); return true;
820             case  8: arch.SetTriple ("thumbv7-apple-ios");  return true;
821             case  9: arch.SetTriple ("thumbv6m-apple-ios"); return true;
822             case 10: arch.SetTriple ("thumbv6-apple-ios");  return true;
823             case 11: arch.SetTriple ("thumbv5-apple-ios");  return true;
824             case 12: arch.SetTriple ("thumbv4t-apple-ios"); return true;
825             case 13: arch.SetTriple ("thumb-apple-ios");    return true;
826             default: break;
827         }
828         break;
829 
830     case ArchSpec::eCore_arm_armv7k:
831         switch (idx)
832         {
833             case  0: arch.SetTriple ("armv7k-apple-ios");   return true;
834             case  1: arch.SetTriple ("armv7-apple-ios");    return true;
835             case  2: arch.SetTriple ("armv6m-apple-ios");   return true;
836             case  3: arch.SetTriple ("armv6-apple-ios");    return true;
837             case  4: arch.SetTriple ("armv5-apple-ios");    return true;
838             case  5: arch.SetTriple ("armv4-apple-ios");    return true;
839             case  6: arch.SetTriple ("arm-apple-ios");      return true;
840             case  7: arch.SetTriple ("thumbv7k-apple-ios"); return true;
841             case  8: arch.SetTriple ("thumbv7-apple-ios");  return true;
842             case  9: arch.SetTriple ("thumbv6m-apple-ios"); return true;
843             case 10: arch.SetTriple ("thumbv6-apple-ios");  return true;
844             case 11: arch.SetTriple ("thumbv5-apple-ios");  return true;
845             case 12: arch.SetTriple ("thumbv4t-apple-ios"); return true;
846             case 13: arch.SetTriple ("thumb-apple-ios");    return true;
847             default: break;
848         }
849         break;
850 
851     case ArchSpec::eCore_arm_armv7s:
852         switch (idx)
853         {
854             case  0: arch.SetTriple ("armv7s-apple-ios");   return true;
855             case  1: arch.SetTriple ("armv7-apple-ios");    return true;
856             case  2: arch.SetTriple ("armv6m-apple-ios");   return true;
857             case  3: arch.SetTriple ("armv6-apple-ios");    return true;
858             case  4: arch.SetTriple ("armv5-apple-ios");    return true;
859             case  5: arch.SetTriple ("armv4-apple-ios");    return true;
860             case  6: arch.SetTriple ("arm-apple-ios");      return true;
861             case  7: arch.SetTriple ("thumbv7s-apple-ios"); return true;
862             case  8: arch.SetTriple ("thumbv7-apple-ios");  return true;
863             case  9: arch.SetTriple ("thumbv6m-apple-ios"); return true;
864             case 10: arch.SetTriple ("thumbv6-apple-ios");  return true;
865             case 11: arch.SetTriple ("thumbv5-apple-ios");  return true;
866             case 12: arch.SetTriple ("thumbv4t-apple-ios"); return true;
867             case 13: arch.SetTriple ("thumb-apple-ios");    return true;
868             default: break;
869         }
870         break;
871 
872     case ArchSpec::eCore_arm_armv7m:
873         switch (idx)
874         {
875             case  0: arch.SetTriple ("armv7m-apple-ios");   return true;
876             case  1: arch.SetTriple ("armv7-apple-ios");    return true;
877             case  2: arch.SetTriple ("armv6m-apple-ios");   return true;
878             case  3: arch.SetTriple ("armv6-apple-ios");    return true;
879             case  4: arch.SetTriple ("armv5-apple-ios");    return true;
880             case  5: arch.SetTriple ("armv4-apple-ios");    return true;
881             case  6: arch.SetTriple ("arm-apple-ios");      return true;
882             case  7: arch.SetTriple ("thumbv7m-apple-ios"); return true;
883             case  8: arch.SetTriple ("thumbv7-apple-ios");  return true;
884             case  9: arch.SetTriple ("thumbv6m-apple-ios"); return true;
885             case 10: arch.SetTriple ("thumbv6-apple-ios");  return true;
886             case 11: arch.SetTriple ("thumbv5-apple-ios");  return true;
887             case 12: arch.SetTriple ("thumbv4t-apple-ios"); return true;
888             case 13: arch.SetTriple ("thumb-apple-ios");    return true;
889             default: break;
890         }
891         break;
892 
893     case ArchSpec::eCore_arm_armv7em:
894         switch (idx)
895         {
896             case  0: arch.SetTriple ("armv7em-apple-ios");  return true;
897             case  1: arch.SetTriple ("armv7-apple-ios");    return true;
898             case  2: arch.SetTriple ("armv6m-apple-ios");   return true;
899             case  3: arch.SetTriple ("armv6-apple-ios");    return true;
900             case  4: arch.SetTriple ("armv5-apple-ios");    return true;
901             case  5: arch.SetTriple ("armv4-apple-ios");    return true;
902             case  6: arch.SetTriple ("arm-apple-ios");      return true;
903             case  7: arch.SetTriple ("thumbv7em-apple-ios"); return true;
904             case  8: arch.SetTriple ("thumbv7-apple-ios");  return true;
905             case  9: arch.SetTriple ("thumbv6m-apple-ios"); return true;
906             case 10: arch.SetTriple ("thumbv6-apple-ios");  return true;
907             case 11: arch.SetTriple ("thumbv5-apple-ios");  return true;
908             case 12: arch.SetTriple ("thumbv4t-apple-ios"); return true;
909             case 13: arch.SetTriple ("thumb-apple-ios");    return true;
910             default: break;
911         }
912         break;
913 
914     case ArchSpec::eCore_arm_armv7:
915         switch (idx)
916         {
917             case  0: arch.SetTriple ("armv7-apple-ios");    return true;
918             case  1: arch.SetTriple ("armv6m-apple-ios");   return true;
919             case  2: arch.SetTriple ("armv6-apple-ios");    return true;
920             case  3: arch.SetTriple ("armv5-apple-ios");    return true;
921             case  4: arch.SetTriple ("armv4-apple-ios");    return true;
922             case  5: arch.SetTriple ("arm-apple-ios");      return true;
923             case  6: arch.SetTriple ("thumbv7-apple-ios");  return true;
924             case  7: arch.SetTriple ("thumbv6m-apple-ios"); return true;
925             case  8: arch.SetTriple ("thumbv6-apple-ios");  return true;
926             case  9: arch.SetTriple ("thumbv5-apple-ios");  return true;
927             case 10: arch.SetTriple ("thumbv4t-apple-ios"); return true;
928             case 11: arch.SetTriple ("thumb-apple-ios");    return true;
929             default: break;
930         }
931         break;
932 
933     case ArchSpec::eCore_arm_armv6m:
934         switch (idx)
935         {
936             case 0: arch.SetTriple ("armv6m-apple-ios");   return true;
937             case 1: arch.SetTriple ("armv6-apple-ios");    return true;
938             case 2: arch.SetTriple ("armv5-apple-ios");    return true;
939             case 3: arch.SetTriple ("armv4-apple-ios");    return true;
940             case 4: arch.SetTriple ("arm-apple-ios");      return true;
941             case 5: arch.SetTriple ("thumbv6m-apple-ios"); return true;
942             case 6: arch.SetTriple ("thumbv6-apple-ios");  return true;
943             case 7: arch.SetTriple ("thumbv5-apple-ios");  return true;
944             case 8: arch.SetTriple ("thumbv4t-apple-ios"); return true;
945             case 9: arch.SetTriple ("thumb-apple-ios");    return true;
946             default: break;
947         }
948         break;
949 
950     case ArchSpec::eCore_arm_armv6:
951         switch (idx)
952         {
953             case 0: arch.SetTriple ("armv6-apple-ios");    return true;
954             case 1: arch.SetTriple ("armv5-apple-ios");    return true;
955             case 2: arch.SetTriple ("armv4-apple-ios");    return true;
956             case 3: arch.SetTriple ("arm-apple-ios");      return true;
957             case 4: arch.SetTriple ("thumbv6-apple-ios");  return true;
958             case 5: arch.SetTriple ("thumbv5-apple-ios");  return true;
959             case 6: arch.SetTriple ("thumbv4t-apple-ios"); return true;
960             case 7: arch.SetTriple ("thumb-apple-ios");    return true;
961             default: break;
962         }
963         break;
964 
965     case ArchSpec::eCore_arm_armv5:
966         switch (idx)
967         {
968             case 0: arch.SetTriple ("armv5-apple-ios");    return true;
969             case 1: arch.SetTriple ("armv4-apple-ios");    return true;
970             case 2: arch.SetTriple ("arm-apple-ios");      return true;
971             case 3: arch.SetTriple ("thumbv5-apple-ios");  return true;
972             case 4: arch.SetTriple ("thumbv4t-apple-ios"); return true;
973             case 5: arch.SetTriple ("thumb-apple-ios");    return true;
974             default: break;
975         }
976         break;
977 
978     case ArchSpec::eCore_arm_armv4:
979         switch (idx)
980         {
981             case 0: arch.SetTriple ("armv4-apple-ios");    return true;
982             case 1: arch.SetTriple ("arm-apple-ios");      return true;
983             case 2: arch.SetTriple ("thumbv4t-apple-ios"); return true;
984             case 3: arch.SetTriple ("thumb-apple-ios");    return true;
985             default: break;
986         }
987         break;
988     }
989     arch.Clear();
990     return false;
991 }
992 
993 
994 const char *
995 PlatformDarwin::GetDeveloperDirectory()
996 {
997     if (m_developer_directory.empty())
998     {
999         bool developer_dir_path_valid = false;
1000         char developer_dir_path[PATH_MAX];
1001         FileSpec temp_file_spec;
1002         if (HostInfo::GetLLDBPath(ePathTypeLLDBShlibDir, temp_file_spec))
1003         {
1004             if (temp_file_spec.GetPath (developer_dir_path, sizeof(developer_dir_path)))
1005             {
1006                 char *shared_frameworks = strstr (developer_dir_path, "/SharedFrameworks/LLDB.framework");
1007                 if (shared_frameworks)
1008                 {
1009                     ::snprintf (shared_frameworks,
1010                                 sizeof(developer_dir_path) - (shared_frameworks - developer_dir_path),
1011                                 "/Developer");
1012                     developer_dir_path_valid = true;
1013                 }
1014                 else
1015                 {
1016                     char *lib_priv_frameworks = strstr (developer_dir_path, "/Library/PrivateFrameworks/LLDB.framework");
1017                     if (lib_priv_frameworks)
1018                     {
1019                         *lib_priv_frameworks = '\0';
1020                         developer_dir_path_valid = true;
1021                     }
1022                 }
1023             }
1024         }
1025 
1026         if (!developer_dir_path_valid)
1027         {
1028             std::string xcode_dir_path;
1029             const char *xcode_select_prefix_dir = getenv ("XCODE_SELECT_PREFIX_DIR");
1030             if (xcode_select_prefix_dir)
1031                 xcode_dir_path.append (xcode_select_prefix_dir);
1032             xcode_dir_path.append ("/usr/share/xcode-select/xcode_dir_path");
1033             temp_file_spec.SetFile(xcode_dir_path.c_str(), false);
1034             size_t bytes_read = temp_file_spec.ReadFileContents(0, developer_dir_path, sizeof(developer_dir_path), NULL);
1035             if (bytes_read > 0)
1036             {
1037                 developer_dir_path[bytes_read] = '\0';
1038                 while (developer_dir_path[bytes_read-1] == '\r' ||
1039                        developer_dir_path[bytes_read-1] == '\n')
1040                     developer_dir_path[--bytes_read] = '\0';
1041                 developer_dir_path_valid = true;
1042             }
1043         }
1044 
1045         if (!developer_dir_path_valid)
1046         {
1047             FileSpec xcode_select_cmd ("/usr/bin/xcode-select", false);
1048             if (xcode_select_cmd.Exists())
1049             {
1050                 int exit_status = -1;
1051                 int signo = -1;
1052                 std::string command_output;
1053                 Error error = Host::RunShellCommand ("/usr/bin/xcode-select --print-path",
1054                                                      NULL,                                 // current working directory
1055                                                      &exit_status,
1056                                                      &signo,
1057                                                      &command_output,
1058                                                      2,                                     // short timeout
1059                                                      false);                                // don't run in a shell
1060                 if (error.Success() && exit_status == 0 && !command_output.empty())
1061                 {
1062                     const char *cmd_output_ptr = command_output.c_str();
1063                     developer_dir_path[sizeof (developer_dir_path) - 1] = '\0';
1064                     size_t i;
1065                     for (i = 0; i < sizeof (developer_dir_path) - 1; i++)
1066                     {
1067                         if (cmd_output_ptr[i] == '\r' || cmd_output_ptr[i] == '\n' || cmd_output_ptr[i] == '\0')
1068                             break;
1069                         developer_dir_path[i] = cmd_output_ptr[i];
1070                     }
1071                     developer_dir_path[i] = '\0';
1072 
1073                     FileSpec devel_dir (developer_dir_path, false);
1074                     if (devel_dir.Exists() && devel_dir.IsDirectory())
1075                     {
1076                         developer_dir_path_valid = true;
1077                     }
1078                 }
1079             }
1080         }
1081 
1082         if (developer_dir_path_valid)
1083         {
1084             temp_file_spec.SetFile (developer_dir_path, false);
1085             if (temp_file_spec.Exists())
1086             {
1087                 m_developer_directory.assign (developer_dir_path);
1088                 return m_developer_directory.c_str();
1089             }
1090         }
1091         // Assign a single NULL character so we know we tried to find the device
1092         // support directory and we don't keep trying to find it over and over.
1093         m_developer_directory.assign (1, '\0');
1094     }
1095 
1096     // We should have put a single NULL character into m_developer_directory
1097     // or it should have a valid path if the code gets here
1098     assert (m_developer_directory.empty() == false);
1099     if (m_developer_directory[0])
1100         return m_developer_directory.c_str();
1101     return NULL;
1102 }
1103 
1104 
1105 BreakpointSP
1106 PlatformDarwin::SetThreadCreationBreakpoint (Target &target)
1107 {
1108     BreakpointSP bp_sp;
1109     static const char *g_bp_names[] =
1110     {
1111         "start_wqthread",
1112         "_pthread_wqthread",
1113         "_pthread_start",
1114     };
1115 
1116     static const char *g_bp_modules[] =
1117     {
1118         "libsystem_c.dylib",
1119         "libSystem.B.dylib"
1120     };
1121 
1122     FileSpecList bp_modules;
1123     for (size_t i = 0; i < llvm::array_lengthof(g_bp_modules); i++)
1124     {
1125         const char *bp_module = g_bp_modules[i];
1126         bp_modules.Append(FileSpec(bp_module, false));
1127     }
1128 
1129     bool internal = true;
1130     bool hardware = false;
1131     LazyBool skip_prologue = eLazyBoolNo;
1132     bp_sp = target.CreateBreakpoint (&bp_modules,
1133                                      NULL,
1134                                      g_bp_names,
1135                                      llvm::array_lengthof(g_bp_names),
1136                                      eFunctionNameTypeFull,
1137                                      skip_prologue,
1138                                      internal,
1139                                      hardware);
1140     bp_sp->SetBreakpointKind("thread-creation");
1141 
1142     return bp_sp;
1143 }
1144 
1145 
1146 int32_t
1147 PlatformDarwin::GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info)
1148 {
1149     const FileSpec &shell = launch_info.GetShell();
1150     if (!shell)
1151         return 1;
1152 
1153     std::string shell_string = shell.GetPath();
1154     const char *shell_name = strrchr (shell_string.c_str(), '/');
1155     if (shell_name == NULL)
1156         shell_name = shell_string.c_str();
1157     else
1158         shell_name++;
1159 
1160     if (strcmp (shell_name, "sh") == 0)
1161     {
1162         // /bin/sh re-exec's itself as /bin/bash requiring another resume.
1163         // But it only does this if the COMMAND_MODE environment variable
1164         // is set to "legacy".
1165         char * const *envp = (char * const*)launch_info.GetEnvironmentEntries().GetConstArgumentVector();
1166         if (envp != NULL)
1167         {
1168             for (int i = 0; envp[i] != NULL; i++)
1169             {
1170                 if (strcmp (envp[i], "COMMAND_MODE=legacy" ) == 0)
1171                     return 2;
1172             }
1173         }
1174         return 1;
1175     }
1176     else if (strcmp (shell_name, "csh") == 0
1177             || strcmp (shell_name, "tcsh") == 0
1178             || strcmp (shell_name, "zsh") == 0)
1179     {
1180         // csh and tcsh always seem to re-exec themselves.
1181         return 2;
1182     }
1183     else
1184         return 1;
1185 }
1186 
1187 void
1188 PlatformDarwin::CalculateTrapHandlerSymbolNames ()
1189 {
1190     m_trap_handlers.push_back (ConstString ("_sigtramp"));
1191 }
1192