37 #ifndef CLIENT_MAC_HANDLER_DYNAMIC_IMAGES_H__ 38 #define CLIENT_MAC_HANDLER_DYNAMIC_IMAGES_H__ 40 #include <mach/mach.h> 41 #include <mach-o/dyld.h> 42 #include <mach-o/loader.h> 43 #include <sys/types.h> 101 template<
typename MachBits>
104 template<
typename MachBits>
113 uint64_t load_address,
115 uintptr_t image_mod_date,
118 : header_(header, header + header_size),
119 header_size_(header_size),
128 cpu_type_(cpu_type) {
129 CalculateMemoryAndVersionInfo();
159 uint32_t GetFileType();
178 template<
typename MachBits>
180 template<
typename MachBits>
184 void CalculateMemoryAndVersionInfo();
186 const vector<uint8_t> header_;
189 mach_vm_address_t vmaddr_;
190 mach_vm_size_t vmsize_;
197 cpu_type_t cpu_type_;
213 return (*const_cast<DynamicImageRef*>(
this)->p)
218 return (*const_cast<DynamicImageRef*>(
this)->p).GetLoadAddress() ==
232 template<
typename MachBits>
244 for (
int i = 0; i < GetImageCount(); ++i) {
245 delete image_list_[i];
254 if (i < (
int)image_list_.size()) {
255 return image_list_[i];
262 int GetExecutableImageIndex();
274 static cpu_type_t DetermineTaskCPUType(task_t task);
278 #if defined(__i386__) 279 return CPU_TYPE_I386;
280 #elif defined(__x86_64__) 281 return CPU_TYPE_X86_64;
282 #elif defined(__ppc__) 283 return CPU_TYPE_POWERPC;
284 #elif defined(__ppc64__) 286 #elif defined(__arm__) 289 #error "GetNativeCPUType not implemented for this architecture" 294 template<
typename MachBits>
297 bool IsOurTask() {
return task_ == mach_task_self();}
300 void ReadImageInfoForTask();
301 uint64_t GetDyldAllImageInfosPointer();
304 cpu_type_t cpu_type_;
305 vector<DynamicImageRef> image_list_;
311 const uint64_t address,
313 vector<uint8_t> &bytes);
317 #endif // CLIENT_MAC_HANDLER_DYNAMIC_IMAGES_H__
int GetImageCount() const
mach_vm_address_t GetVMAddr() const
ptrdiff_t GetVMAddrSlide() const
bool processDetachedFromSharedRegion
DynamicImage(uint8_t *header, size_t header_size, uint64_t load_address, string file_path, uintptr_t image_mod_date, mach_port_t task, cpu_type_t cpu_type)
mach_port_t GetTask() const
DynamicImage * operator->()
static cpu_type_t GetNativeCPUType()
mach_header breakpad_mach_header
size_t GetHeaderSize() const
DynamicImage * GetImage(int i)
kern_return_t ReadTaskMemory(task_port_t target_task, const uint64_t address, size_t length, vector< uint8_t > &bytes)
#define CPU_TYPE_POWERPC64
struct google_breakpad::dyld_image_info32 dyld_image_info32
uint32_t GetFileTypeFromHeader(DynamicImage &image)
struct google_breakpad::dyld_image_info64 dyld_image_info64
uint64_t GetModDate() const
struct google_breakpad::dyld_all_image_infos64 dyld_all_image_infos64
uint64_t GetLoadAddress() const
void ReadImageInfo(DynamicImages &images, uint64_t image_list_address)
bool processDetachedFromSharedRegion
DynamicImageRef(const DynamicImageRef &inRef)
DynamicImageRef(DynamicImage *inP)
mach_vm_size_t GetVMSize() const
struct google_breakpad::dyld_all_image_infos32 dyld_all_image_infos32
bool operator<(const DynamicImageRef &inRef) const
bool FindTextSection(DynamicImage &image)
segment_command breakpad_mach_segment_command
bool operator==(const DynamicImageRef &inInfo) const
bool operator<(const DynamicImage &inInfo)