Bug 1059424 Part 3: Simplify DynamicImages::GetDyldAllImageInfosPointer now that we are minimum macOS 10.9. draft
authorBrad Werth <bwerth@mozilla.com>
Mon, 10 Jul 2017 15:44:37 -0700
changeset 607083 7218ff64f6dc166eabe1b9d15f3e477da0b7196d
parent 607082 6feabbb4b24740a699938762f8ecd4634cd3a89f
child 636935 f8bb14a1b6722b54d7e10a0ae48eb5bd3e3e0b7a
push id67886
push userbwerth@mozilla.com
push dateTue, 11 Jul 2017 20:46:56 +0000
bugs1059424
milestone56.0a1
Bug 1059424 Part 3: Simplify DynamicImages::GetDyldAllImageInfosPointer now that we are minimum macOS 10.9. MozReview-Commit-ID: EMJwpU7LetP
toolkit/crashreporter/breakpad-client/mac/handler/dynamic_images.cc
--- a/toolkit/crashreporter/breakpad-client/mac/handler/dynamic_images.cc
+++ b/toolkit/crashreporter/breakpad-client/mac/handler/dynamic_images.cc
@@ -359,55 +359,25 @@ static uint64_t LookupSymbol(const char*
   if(invalidEntriesCount != 0) {
     return 0;
   }
 
   assert(list.n_value);
   return list.n_value;
 }
 
-#if TARGET_OS_IPHONE || MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6
-static bool HasTaskDyldInfo() {
-  return true;
-}
-#else
-static SInt32 GetOSVersionInternal() {
-  SInt32 os_version = 0;
-  Gestalt(gestaltSystemVersion, &os_version);
-  return os_version;
-}
-
-static SInt32 GetOSVersion() {
-  static SInt32 os_version = GetOSVersionInternal();
-  return os_version;
-}
+uint64_t DynamicImages::GetDyldAllImageInfosPointer() {
+  task_dyld_info_data_t task_dyld_info;
+  mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT;
+  if (task_info(task_, TASK_DYLD_INFO, (task_info_t)&task_dyld_info,
+                &count) != KERN_SUCCESS) {
+    return 0;
+  }
 
-static bool HasTaskDyldInfo() {
-  return GetOSVersion() >= 0x1060;
-}
-#endif  // TARGET_OS_IPHONE || MAC_OS_X_VERSION_MIN_REQUIRED >= 10_6
-
-uint64_t DynamicImages::GetDyldAllImageInfosPointer() {
-  if (HasTaskDyldInfo()) {
-    task_dyld_info_data_t task_dyld_info;
-    mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT;
-    if (task_info(task_, TASK_DYLD_INFO, (task_info_t)&task_dyld_info,
-                  &count) != KERN_SUCCESS) {
-      return 0;
-    }
-
-    return (uint64_t)task_dyld_info.all_image_info_addr;
-  } else {
-    const char *imageSymbolName = "_dyld_all_image_infos";
-    const char *dyldPath = "/usr/lib/dyld";
-
-    if (Is64Bit())
-      return LookupSymbol<MachO64>(imageSymbolName, dyldPath, cpu_type_);
-    return LookupSymbol<MachO32>(imageSymbolName, dyldPath, cpu_type_);
-  }
+  return (uint64_t)task_dyld_info.all_image_info_addr;
 }
 
 //==============================================================================
 // This code was written using dyld_debug.c (from Darwin) as a guide.
 
 template<typename MachBits>
 void ReadImageInfo(DynamicImages& images,
                    uint64_t image_list_address) {