This revision was automatically updated to reflect the committed changes. Closed by commit rGd40f4636c454: Handle an unknown binary platform type in debugserver (authored by jasonmolenda).
Changed prior to commit: https://reviews.llvm.org/D136719?vs=471272&id=471278#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136719/new/ https://reviews.llvm.org/D136719 Files: lldb/tools/debugserver/source/DNB.cpp lldb/tools/debugserver/source/DNB.h lldb/tools/debugserver/source/MacOSX/MachProcess.h lldb/tools/debugserver/source/MacOSX/MachProcess.mm lldb/tools/debugserver/source/RNBRemote.cpp
Index: lldb/tools/debugserver/source/RNBRemote.cpp =================================================================== --- lldb/tools/debugserver/source/RNBRemote.cpp +++ lldb/tools/debugserver/source/RNBRemote.cpp @@ -6258,12 +6258,12 @@ bool is_executable = true; uint32_t major_version, minor_version, patch_version; - auto *platform = + std::optional<std::string> platform = DNBGetDeploymentInfo(pid, is_executable, lc, load_command_addr, major_version, minor_version, patch_version); if (platform) { os_handled = true; - rep << "ostype:" << platform << ";"; + rep << "ostype:" << *platform << ";"; break; } load_command_addr = load_command_addr + lc.cmdsize; Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm =================================================================== --- lldb/tools/debugserver/source/MacOSX/MachProcess.mm +++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm @@ -720,7 +720,8 @@ return info; } -const char *MachProcess::GetPlatformString(unsigned char platform) { +std::optional<std::string> +MachProcess::GetPlatformString(unsigned char platform) { switch (platform) { case PLATFORM_MACOS: return "macosx"; @@ -742,8 +743,10 @@ return "bridgeos"; case PLATFORM_DRIVERKIT: return "driverkit"; + default: + DNBLogError("Unknown platform %u found for one binary", platform); + return std::nullopt; } - return nullptr; } static bool mach_header_validity_test(uint32_t magic, uint32_t cputype) { @@ -867,7 +870,8 @@ } if (DeploymentInfo deployment_info = GetDeploymentInfo( lc, load_cmds_p, inf.mach_header.filetype == MH_EXECUTE)) { - const char *lc_platform = GetPlatformString(deployment_info.platform); + std::optional<std::string> lc_platform = + GetPlatformString(deployment_info.platform); if (dyld_platform != PLATFORM_MACCATALYST && inf.min_version_os_name == "macosx") { // macCatalyst support. @@ -882,7 +886,7 @@ // processed, ignore this one, which is presumed to be a // PLATFORM_MACCATALYST one. } else { - inf.min_version_os_name = lc_platform; + inf.min_version_os_name = lc_platform.value_or(""); inf.min_version_os_version = ""; inf.min_version_os_version += std::to_string(deployment_info.major_version); Index: lldb/tools/debugserver/source/MacOSX/MachProcess.h =================================================================== --- lldb/tools/debugserver/source/MacOSX/MachProcess.h +++ lldb/tools/debugserver/source/MacOSX/MachProcess.h @@ -16,6 +16,7 @@ #include <CoreFoundation/CoreFoundation.h> #include <mach-o/loader.h> #include <mach/mach.h> +#include <optional> #include <pthread.h> #include <sys/signal.h> #include <uuid/uuid.h> @@ -252,7 +253,7 @@ DeploymentInfo GetDeploymentInfo(const struct load_command &, uint64_t load_command_address, bool is_executable); - static const char *GetPlatformString(unsigned char platform); + static std::optional<std::string> GetPlatformString(unsigned char platform); bool GetMachOInformationFromMemory(uint32_t platform, nub_addr_t mach_o_header_addr, int wordsize, Index: lldb/tools/debugserver/source/DNB.h =================================================================== --- lldb/tools/debugserver/source/DNB.h +++ lldb/tools/debugserver/source/DNB.h @@ -21,6 +21,7 @@ #include <Availability.h> #include <mach/machine.h> #include <mach/thread_info.h> +#include <optional> #include <string> #define DNB_EXPORT __attribute__((visibility("default"))) @@ -134,12 +135,11 @@ nub_size_t DNBProcessGetSharedLibraryInfo(nub_process_t pid, nub_bool_t only_changed, DNBExecutableImageInfo **image_infos) DNB_EXPORT; -const char *DNBGetDeploymentInfo(nub_process_t pid, bool is_executable, - const struct load_command &lc, - uint64_t load_command_address, - uint32_t &major_version, - uint32_t &minor_version, - uint32_t &patch_version); +std::optional<std::string> +DNBGetDeploymentInfo(nub_process_t pid, bool is_executable, + const struct load_command &lc, + uint64_t load_command_address, uint32_t &major_version, + uint32_t &minor_version, uint32_t &patch_version); nub_bool_t DNBProcessSetNameToAddressCallback(nub_process_t pid, DNBCallbackNameToAddress callback, void *baton) DNB_EXPORT; Index: lldb/tools/debugserver/source/DNB.cpp =================================================================== --- lldb/tools/debugserver/source/DNB.cpp +++ lldb/tools/debugserver/source/DNB.cpp @@ -1433,12 +1433,11 @@ return false; } -const char *DNBGetDeploymentInfo(nub_process_t pid, bool is_executable, - const struct load_command &lc, - uint64_t load_command_address, - uint32_t &major_version, - uint32_t &minor_version, - uint32_t &patch_version) { +std::optional<std::string> +DNBGetDeploymentInfo(nub_process_t pid, bool is_executable, + const struct load_command &lc, + uint64_t load_command_address, uint32_t &major_version, + uint32_t &minor_version, uint32_t &patch_version) { MachProcessSP procSP; if (GetProcessSP(pid, procSP)) { // FIXME: This doesn't return the correct result when xctest (a
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits