Skip to content

[debugserver] Add platform cache support to improve performance. #2983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lldb/tools/debugserver/source/MacOSX/MachProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class MachProcess {
struct mach_o_information &inf);
JSONGenerator::ObjectSP FormatDynamicLibrariesIntoJSON(
const std::vector<struct binary_image_information> &image_infos);
uint32_t GetPlatform();
/// Get the runtime platform from DYLD via SPI.
uint32_t GetProcessPlatformViaDYLDSPI();
/// Use the dyld SPI present in macOS 10.12, iOS 10, tvOS 10,
Expand Down Expand Up @@ -375,6 +376,7 @@ class MachProcess {

pid_t m_pid; // Process ID of child process
cpu_type_t m_cpu_type; // The CPU type of this process
uint32_t m_platform; // The platform of this process
int m_child_stdin;
int m_child_stdout;
int m_child_stderr;
Expand Down
14 changes: 11 additions & 3 deletions lldb/tools/debugserver/source/MacOSX/MachProcess.mm
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
// DYLD_FORCE_PLATFORM=6. In that case, force the platform to
// macCatalyst and use the macCatalyst version of the host OS
// instead of the macOS deployment target.
if (is_executable && GetProcessPlatformViaDYLDSPI() == PLATFORM_MACCATALYST) {
if (is_executable && GetPlatform() == PLATFORM_MACCATALYST) {
info.platform = PLATFORM_MACCATALYST;
std::string catalyst_version = GetMacCatalystVersionString();
const char *major = catalyst_version.c_str();
Expand Down Expand Up @@ -1103,6 +1103,12 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
bool privateCache;
};

uint32_t MachProcess::GetPlatform() {
if (m_platform == 0)
m_platform = MachProcess::GetProcessPlatformViaDYLDSPI();
return m_platform;
}

uint32_t MachProcess::GetProcessPlatformViaDYLDSPI() {
kern_return_t kern_ret;
uint32_t platform = 0;
Expand Down Expand Up @@ -1158,7 +1164,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,

std::vector<struct binary_image_information> image_infos;
GetAllLoadedBinariesViaDYLDSPI(image_infos);
uint32_t platform = GetProcessPlatformViaDYLDSPI();
uint32_t platform = GetPlatform();
const size_t image_count = image_infos.size();
for (size_t i = 0; i < image_count; i++) {
GetMachOInformationFromMemory(platform,
Expand Down Expand Up @@ -1189,7 +1195,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,

std::vector<struct binary_image_information> all_image_infos;
GetAllLoadedBinariesViaDYLDSPI(all_image_infos);
uint32_t platform = GetProcessPlatformViaDYLDSPI();
uint32_t platform = GetPlatform();

std::vector<struct binary_image_information> image_infos;
const size_t macho_addresses_count = macho_addresses.size();
Expand Down Expand Up @@ -1355,6 +1361,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
// Clear any cached thread list while the pid and task are still valid

m_task.Clear();
m_platform = 0;
// Now clear out all member variables
m_pid = INVALID_NUB_PROCESS;
if (!detaching)
Expand Down Expand Up @@ -1646,6 +1653,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,

// NULL our task out as we have already restored all exception ports
m_task.Clear();
m_platform = 0;

// Clear out any notion of the process we once were
const bool detaching = true;
Expand Down