diff options
author | nealsid <nealsid@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2008-04-25 00:37:19 +0000 |
---|---|---|
committer | nealsid <nealsid@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2008-04-25 00:37:19 +0000 |
commit | 4c39c138fe2a68206c2143d7401a113a1c4b130b (patch) | |
tree | 3fce0e66f9fafc93cfc16c5db17458222cbf832a /src/client/mac/handler/dynamic_images.cc | |
parent | Add one more parameter to the ClientDumpRequestCallback in crash generation s... (diff) | |
download | breakpad-4c39c138fe2a68206c2143d7401a113a1c4b130b.tar.xz |
Issue 258: Added test cases for ReadTaskMemory, reorganized project file, renamed filenames inside comments
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@263 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client/mac/handler/dynamic_images.cc')
-rw-r--r-- | src/client/mac/handler/dynamic_images.cc | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/client/mac/handler/dynamic_images.cc b/src/client/mac/handler/dynamic_images.cc index 0d63d5a7..d48c2f6b 100644 --- a/src/client/mac/handler/dynamic_images.cc +++ b/src/client/mac/handler/dynamic_images.cc @@ -31,9 +31,9 @@ extern "C" { // needed to compile on Leopard #include <mach-o/nlist.h> #include <stdlib.h> #include <stdio.h> - #include "breakpad_nlist_64.h" } +#include "breakpad_nlist_64.h" #include <dlfcn.h> #include <mach/mach_vm.h> #include <algorithm> @@ -128,7 +128,8 @@ static void* ReadTaskString(task_port_t target_task, mach_vm_size_t size_to_read = size_to_end > kMaxStringLength ? kMaxStringLength : size_to_end; - return ReadTaskMemory(target_task, address, size_to_read); + kern_return_t kr; + return ReadTaskMemory(target_task, address, size_to_read, &kr); } return NULL; @@ -139,7 +140,8 @@ static void* ReadTaskString(task_port_t target_task, // and should be freed by the caller. void* ReadTaskMemory(task_port_t target_task, const void* address, - size_t length) { + size_t length, + kern_return_t *kr) { void* result = NULL; int systemPageSize = getpagesize(); @@ -155,12 +157,19 @@ void* ReadTaskMemory(task_port_t target_task, uint8_t* local_start; uint32_t local_length; - kern_return_t r = mach_vm_read(target_task, - page_address, - page_size, - reinterpret_cast<vm_offset_t*>(&local_start), - &local_length); + kern_return_t r; + r = mach_vm_read(target_task, + page_address, + page_size, + reinterpret_cast<vm_offset_t*>(&local_start), + &local_length); + + + if(kr != NULL) { + *kr = r; + } + if (r == KERN_SUCCESS) { result = malloc(length); if (result != NULL) { @@ -289,6 +298,7 @@ void DynamicImages::ReadImageInfoForTask() { void *imageList = GetDyldAllImageInfosPointer(); if (imageList) { + kern_return_t kr; // Read the structure inside of dyld that contains information about // loaded images. We're reading from the desired task's address space. @@ -298,7 +308,7 @@ void DynamicImages::ReadImageInfoForTask() { dyld_all_image_infos *dyldInfo = reinterpret_cast<dyld_all_image_infos*> (ReadTaskMemory(task_, reinterpret_cast<void*>(imageList), - sizeof(dyld_all_image_infos))); + sizeof(dyld_all_image_infos), &kr)); if (dyldInfo) { // number of loaded images @@ -309,7 +319,7 @@ void DynamicImages::ReadImageInfoForTask() { dyld_image_info *infoArray = reinterpret_cast<dyld_image_info*> (ReadTaskMemory(task_, dyldInfo->infoArray, - count*sizeof(dyld_image_info))); + count*sizeof(dyld_image_info), &kr)); image_list_.reserve(count); @@ -320,7 +330,7 @@ void DynamicImages::ReadImageInfoForTask() { breakpad_mach_header *header = reinterpret_cast<breakpad_mach_header*> (ReadTaskMemory(task_, info.load_address_, - sizeof(breakpad_mach_header))); + sizeof(breakpad_mach_header), &kr)); if (!header) break; // bail on this dynamic image @@ -334,7 +344,7 @@ void DynamicImages::ReadImageInfoForTask() { free(header); header = reinterpret_cast<breakpad_mach_header*> - (ReadTaskMemory(task_, info.load_address_, header_size)); + (ReadTaskMemory(task_, info.load_address_, header_size, &kr)); // Read the file name from the task's memory space. char *file_path = NULL; |