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 607759 fad9d93a2bd7319c90846d05a9af99c95ab10270
parent 607758 7f895eddb97aad8822a9db5e040eed6549926294
child 607760 926f11ffe7ba183c884ca2c51280bce517f8e232
push id68103
push userbwerth@mozilla.com
push dateWed, 12 Jul 2017 21:01:36 +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) {