clayborg created this revision. clayborg added reviewers: labath, aprantl, JDevlieghere, jingham, jasonmolenda. Herald added a project: LLDB. clayborg requested review of this revision.
This can be done by doing: (lldb) platform select ios-simulator (lldb) platform process list There was code that was trying to detect simulator processes but it had an error in the loop where each time it would check for a env var that starts with "SIMULATOR_UDID=" it would change the architecture to iOS if it found it and MacOSX if it didn't. This meant unless "SIMULATOR_UDID=" was the last environment variable, this loop would never set the OS correctly. We also weren't setting the environment to Simulator which means PlatformAppleSimulator::FindProcesses(...) would never return any valid processes even when there were many. I don't know how I can test this as we don't want a test suite having to launch an iOS simulator, so there are no tests at the moment. If anyone has any ideas on how to test this, please let me know. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D85988 Files: lldb/source/Host/macosx/objcxx/Host.mm Index: lldb/source/Host/macosx/objcxx/Host.mm =================================================================== --- lldb/source/Host/macosx/objcxx/Host.mm +++ 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<int>(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; }
Index: lldb/source/Host/macosx/objcxx/Host.mm =================================================================== --- lldb/source/Host/macosx/objcxx/Host.mm +++ 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<int>(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; }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits