diff options
| author | Jason Molenda <jmolenda@apple.com> | 2016-07-07 03:12:01 +0000 |
|---|---|---|
| committer | Jason Molenda <jmolenda@apple.com> | 2016-07-07 03:12:01 +0000 |
| commit | df8aef434dca87737f64b8f1897d14495c1f400f (patch) | |
| tree | 1df2b09ad760d5e4f7a9ebf9bc3fe7b6d443ef56 | |
| parent | 523744dd2b53e67fed50175ae8f2562208756c99 (diff) | |
| download | bcm5719-llvm-df8aef434dca87737f64b8f1897d14495c1f400f.tar.gz bcm5719-llvm-df8aef434dca87737f64b8f1897d14495c1f400f.zip | |
debugserver will now report the minimum version load command
os name and version # from the mach-o binary as it scans the
header/load commands from memory and sends the details back
in the jGetLoadedDynamicLibrariesInfos response. lldb isn't
using these fields yet but I have a suspicion I'm going to
need them soon.
<rdar://problem/25251243>
llvm-svn: 274725
| -rw-r--r-- | lldb/tools/debugserver/source/MacOSX/MachProcess.h | 2 | ||||
| -rw-r--r-- | lldb/tools/debugserver/source/MacOSX/MachProcess.mm | 45 |
2 files changed, 47 insertions, 0 deletions
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.h b/lldb/tools/debugserver/source/MacOSX/MachProcess.h index 7e361172ce7..094c13b8f0a 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.h +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.h @@ -69,6 +69,8 @@ public: struct mach_header_64 mach_header; std::vector<struct mach_o_segment> segments; uuid_t uuid; + std::string min_version_os_name; + std::string min_version_os_version; }; struct binary_image_information diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm index fc796376b01..c5d1ce0942f 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm @@ -631,6 +631,44 @@ MachProcess::GetMachOInformationFromMemory (nub_addr_t mach_o_header_addr, int w if (ReadMemory (load_cmds_p, sizeof (struct uuid_command), &uuidcmd) == sizeof (struct uuid_command)) uuid_copy (inf.uuid, uuidcmd.uuid); } + if (lc.cmd == LC_VERSION_MIN_IPHONEOS || lc.cmd == LC_VERSION_MIN_MACOSX + || lc.cmd == LC_VERSION_MIN_WATCHOS || lc.cmd == LC_VERSION_MIN_TVOS) + { + struct version_min_command vers_cmd; + if (ReadMemory (load_cmds_p, sizeof (struct version_min_command), &vers_cmd) != sizeof (struct version_min_command)) + { + return false; + } + switch (lc.cmd) + { + case LC_VERSION_MIN_IPHONEOS: + inf.min_version_os_name = "iphoneos"; + break; + case LC_VERSION_MIN_MACOSX: + inf.min_version_os_name = "macosx"; + break; + case LC_VERSION_MIN_TVOS: + inf.min_version_os_name = "tvos"; + break; + case LC_VERSION_MIN_WATCHOS: + inf.min_version_os_name = "watchos"; + break; + default: + return false; + } + uint32_t xxxx = vers_cmd.sdk >> 16; + uint32_t yy = (vers_cmd.sdk >> 8) & 0xffu; + uint32_t zz = vers_cmd.sdk & 0xffu; + inf.min_version_os_version = ""; + inf.min_version_os_version += std::to_string(xxxx); + inf.min_version_os_version += "."; + inf.min_version_os_version += std::to_string(yy); + if (zz != 0) + { + inf.min_version_os_version += "."; + inf.min_version_os_version += std::to_string(zz); + } + } load_cmds_p += lc.cmdsize; } return true; @@ -657,6 +695,13 @@ MachProcess::FormatDynamicLibrariesIntoJSON (const std::vector<struct binary_ima uuid_unparse_upper (image_infos[i].macho_info.uuid, uuidstr); image_info_dict_sp->AddStringItem ("uuid", uuidstr); + if (image_infos[i].macho_info.min_version_os_name.empty() == false + && image_infos[i].macho_info.min_version_os_version.empty() == false) + { + image_info_dict_sp->AddStringItem ("min_version_os_name", image_infos[i].macho_info.min_version_os_name); + image_info_dict_sp->AddStringItem ("min_version_os_sdk", image_infos[i].macho_info.min_version_os_version); + } + JSONGenerator::DictionarySP mach_header_dict_sp (new JSONGenerator::Dictionary()); mach_header_dict_sp->AddIntegerItem ("magic", image_infos[i].macho_info.mach_header.magic); mach_header_dict_sp->AddIntegerItem ("cputype", (uint32_t) image_infos[i].macho_info.mach_header.cputype); |

