aboutsummaryrefslogtreecommitdiff
path: root/src/client/mac/handler/dynamic_images.cc
diff options
context:
space:
mode:
authornealsid <nealsid@4c0a9323-5329-0410-9bdc-e9ce6186880e>2008-04-12 01:16:18 +0000
committernealsid <nealsid@4c0a9323-5329-0410-9bdc-e9ce6186880e>2008-04-12 01:16:18 +0000
commitb0d807666f3ab5af581e4687eba31717bbde86d5 (patch)
treed153190e24bad5b8617e34c4cd8942d819d42449 /src/client/mac/handler/dynamic_images.cc
parentAdd a parameter to CrashGenerationServer to let the callers set the (diff)
downloadbreakpad-b0d807666f3ab5af581e4687eba31717bbde86d5.tar.xz
Issue 254: The problem is that nlist() is compiled out of libc in
64-bit builds of Leopard. I ported the code over myself and will check it into the Breakpad tree until we decide there's a better longer-term solution. If you want to diff the changes, the Apple source is in libc/gen/nlist.c(I used 498 from 10.5.2). git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@259 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/mac/handler/dynamic_images.cc')
-rw-r--r--src/client/mac/handler/dynamic_images.cc45
1 files changed, 38 insertions, 7 deletions
diff --git a/src/client/mac/handler/dynamic_images.cc b/src/client/mac/handler/dynamic_images.cc
index 0fff084a..b8a6f6c5 100644
--- a/src/client/mac/handler/dynamic_images.cc
+++ b/src/client/mac/handler/dynamic_images.cc
@@ -31,6 +31,7 @@ extern "C" { // needed to compile on Leopard
#include <mach-o/nlist.h>
#include <stdlib.h>
#include <stdio.h>
+ #include "breakpad_nlist_64.h"
}
#include <dlfcn.h>
@@ -244,9 +245,12 @@ DynamicImages::DynamicImages(mach_port_t task)
ReadImageInfoForTask();
}
-//==============================================================================
-// This code was written using dyld_debug.c (from Darwin) as a guide.
-void DynamicImages::ReadImageInfoForTask() {
+void* DynamicImages::GetDyldAllImageInfosPointer()
+{
+
+ const char *imageSymbolName = "_dyld_all_image_infos";
+ const char *dyldPath = "/usr/lib/dyld";
+#ifndef __LP64__
struct nlist l[8];
memset(l, 0, sizeof(l) );
@@ -254,10 +258,37 @@ void DynamicImages::ReadImageInfoForTask() {
// which lives in "dyld". This structure contains information about all
// of the loaded dynamic images.
struct nlist &list = l[0];
- list.n_un.n_name = const_cast<char *>("_dyld_all_image_infos");
- nlist("/usr/lib/dyld", &list);
+ list.n_un.n_name = const_cast<char *>(imageSymbolName);
+ nlist(dyldPath,&list);
+ if(list.n_value) {
+ return reinterpret_cast<void*>(list.n_value);
+ }
+
+ return NULL;
+#else
+ struct nlist_64 l[8];
+ struct nlist_64 &list = l[0];
+
+ memset(l, 0, sizeof(l) );
+
+ const char *symbolNames[2] = { imageSymbolName, "\0" };
+
+ int invalidEntriesCount = breakpad_nlist_64(dyldPath,&list,symbolNames);
+
+ if(invalidEntriesCount != 0) {
+ return NULL;
+ }
+ assert(list.n_value);
+ return reinterpret_cast<void*>(list.n_value);
+#endif
+
+}
+//==============================================================================
+// This code was written using dyld_debug.c (from Darwin) as a guide.
+void DynamicImages::ReadImageInfoForTask() {
+ void *imageList = GetDyldAllImageInfosPointer();
- if (list.n_value) {
+ if (imageList) {
// Read the structure inside of dyld that contains information about
// loaded images. We're reading from the desired task's address space.
@@ -266,7 +297,7 @@ void DynamicImages::ReadImageInfoForTask() {
// "dyld_debug.c" and is said to be nearly always valid.
dyld_all_image_infos *dyldInfo = reinterpret_cast<dyld_all_image_infos*>
(ReadTaskMemory(task_,
- reinterpret_cast<void*>(list.n_value),
+ reinterpret_cast<void*>(imageList),
sizeof(dyld_all_image_infos)));
if (dyldInfo) {