diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm --- a/lldb/source/Host/macosx/objcxx/Host.mm +++ b/lldb/source/Host/macosx/objcxx/Host.mm @@ -503,12 +503,12 @@ uint32_t argc = data.GetU32(&offset); llvm::Triple &triple = process_info.GetArchitecture().GetTriple(); const llvm::Triple::ArchType triple_arch = triple.getArch(); - const bool check_for_ios_simulator = + bool check_for_ios_simulator = (triple_arch == llvm::Triple::x86 || triple_arch == llvm::Triple::x86_64); - const char *cstr = data.GetCStr(&offset); - if (cstr) { - process_info.GetExecutableFile().SetFile(cstr, FileSpec::Style::native); + llvm::StringRef str(data.GetCStr(&offset)); + if (!str.empty()) { + process_info.GetExecutableFile().SetFile(str, FileSpec::Style::native); if (match_info_ptr == NULL || NameMatches( @@ -525,27 +525,29 @@ // Now extract all arguments Args &proc_args = process_info.GetArguments(); for (int i = 0; i < static_cast(argc); ++i) { - cstr = data.GetCStr(&offset); - if (cstr) - proc_args.AppendArgument(llvm::StringRef(cstr)); + str = data.GetCStr(&offset); + if (!str.empty()) + proc_args.AppendArgument(str); } Environment &proc_env = process_info.GetEnvironment(); - while ((cstr = data.GetCStr(&offset))) { - if (cstr[0] == '\0') + process_info.GetArchitecture().GetTriple().setOS( + llvm::Triple::MacOSX); + while (true) { + str = data.GetCStr(&offset); + if (str.empty()) break; if (check_for_ios_simulator) { - if (strncmp(cstr, "SIMULATOR_UDID=", strlen("SIMULATOR_UDID=")) == - 0) + if (str.startswith("SIMULATOR_UDID=")) { process_info.GetArchitecture().GetTriple().setOS( llvm::Triple::IOS); - else - process_info.GetArchitecture().GetTriple().setOS( - llvm::Triple::MacOSX); + process_info.GetArchitecture().GetTriple().setEnvironment( + llvm::Triple::Simulator); + check_for_ios_simulator = false; + } } - - proc_env.insert(cstr); + proc_env.insert(str); } return true; }