Clean up build for 64 bit.

Fix up some broken mac projects.
Consolidate project settings in xcconfig files.

http://breakpad.appspot.com/130001



git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@627 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
dmaclach
2010-07-19 20:43:49 +00:00
parent 786275e719
commit 4ac61acb3a
53 changed files with 1791 additions and 1084 deletions

View File

@@ -137,7 +137,7 @@ __breakpad_fdnlist_64(int fd, breakpad_nlist *list, const char **symbolNames) {
breakpad_nlist space[BUFSIZ/sizeof (breakpad_nlist)];
const register char *s1, *s2;
register int n, m;
register register_t n, m;
int maxlen, nreq;
off_t sa; /* symbol address */
off_t ss; /* start of strings */
@@ -160,14 +160,14 @@ __breakpad_fdnlist_64(int fd, breakpad_nlist *list, const char **symbolNames) {
(N_BADMAG(buf) && *((long *)&buf) != MH_MAGIC &&
NXSwapBigLongToHost(*((long *)&buf)) != FAT_MAGIC) &&
/* nealsid: The following is the big-endian ppc64 check */
(*((uint32_t*)&buf)) != FAT_MAGIC) {
(*((long*)&buf)) != FAT_MAGIC) {
return (-1);
}
/* Deal with fat file if necessary */
if (NXSwapBigLongToHost(*((long *)&buf)) == FAT_MAGIC ||
/* nealsid: The following is the big-endian ppc64 check */
*((int*)&buf) == FAT_MAGIC) {
*((unsigned int *)&buf) == FAT_MAGIC) {
struct host_basic_info hbi;
struct fat_header fh;
struct fat_arch *fat_archs, *fap;
@@ -191,7 +191,7 @@ __breakpad_fdnlist_64(int fd, breakpad_nlist *list, const char **symbolNames) {
}
/* Convert fat_narchs to host byte order */
fh.nfat_arch = NXSwapBigLongToHost(fh.nfat_arch);
fh.nfat_arch = NXSwapBigIntToHost(fh.nfat_arch);
/* Read in the fat archs */
fat_archs = (struct fat_arch *)malloc(fh.nfat_arch *
@@ -201,7 +201,7 @@ __breakpad_fdnlist_64(int fd, breakpad_nlist *list, const char **symbolNames) {
}
if (read(fd, (char *)fat_archs,
sizeof(struct fat_arch) * fh.nfat_arch) !=
sizeof(struct fat_arch) * fh.nfat_arch) {
(ssize_t)sizeof(struct fat_arch) * fh.nfat_arch) {
free(fat_archs);
return (-1);
}
@@ -212,15 +212,15 @@ __breakpad_fdnlist_64(int fd, breakpad_nlist *list, const char **symbolNames) {
*/
for (i = 0; i < fh.nfat_arch; i++) {
fat_archs[i].cputype =
NXSwapBigLongToHost(fat_archs[i].cputype);
NXSwapBigIntToHost(fat_archs[i].cputype);
fat_archs[i].cpusubtype =
NXSwapBigLongToHost(fat_archs[i].cpusubtype);
NXSwapBigIntToHost(fat_archs[i].cpusubtype);
fat_archs[i].offset =
NXSwapBigLongToHost(fat_archs[i].offset);
NXSwapBigIntToHost(fat_archs[i].offset);
fat_archs[i].size =
NXSwapBigLongToHost(fat_archs[i].size);
NXSwapBigIntToHost(fat_archs[i].size);
fat_archs[i].align =
NXSwapBigLongToHost(fat_archs[i].align);
NXSwapBigIntToHost(fat_archs[i].align);
}
fap = NULL;
@@ -257,7 +257,7 @@ __breakpad_fdnlist_64(int fd, breakpad_nlist *list, const char **symbolNames) {
}
}
if (*((int *)&buf) == MH_MAGIC_64) {
if (*((unsigned int *)&buf) == MH_MAGIC_64) {
struct mach_header_64 mh;
struct load_command *load_commands, *lcp;
struct symtab_command *stp;

View File

@@ -129,7 +129,7 @@ static void* ReadTaskString(task_port_t target_task,
size_to_end > kMaxStringLength ? kMaxStringLength : size_to_end;
kern_return_t kr;
return ReadTaskMemory(target_task, address, size_to_read, &kr);
return ReadTaskMemory(target_task, address, (size_t)size_to_read, &kr);
}
return NULL;
@@ -276,13 +276,11 @@ void DynamicImage::Print() {
//==============================================================================
// Loads information about dynamically loaded code in the given task.
DynamicImages::DynamicImages(mach_port_t task)
: task_(task) {
: task_(task), image_list_() {
ReadImageInfoForTask();
}
void* DynamicImages::GetDyldAllImageInfosPointer()
{
void* DynamicImages::GetDyldAllImageInfosPointer() {
const char *imageSymbolName = "_dyld_all_image_infos";
const char *dyldPath = "/usr/lib/dyld";
#ifndef __LP64__
@@ -364,7 +362,7 @@ void DynamicImages::ReadImageInfoForTask() {
// Now determine the total amount we really want to read based on the
// size of the load commands. We need the header plus all of the
// load commands.
unsigned int header_size =
size_t header_size =
sizeof(breakpad_mach_header) + header->sizeofcmds;
free(header);

View File

@@ -103,7 +103,7 @@ class MachHeader {
class DynamicImage {
public:
DynamicImage(breakpad_mach_header *header, // we take ownership
int header_size, // includes load commands
size_t header_size, // includes load commands
breakpad_mach_header *load_address,
char *inFilePath,
uintptr_t image_mod_date,
@@ -112,7 +112,12 @@ class DynamicImage {
header_size_(header_size),
load_address_(load_address),
file_mod_date_(image_mod_date),
task_(task) {
task_(task),
vmaddr_(0),
vmsize_(0),
slide_(0),
version_(0),
file_path_(NULL) {
InitializeFilePath(inFilePath);
CalculateMemoryAndVersionInfo();
}
@@ -128,7 +133,7 @@ class DynamicImage {
breakpad_mach_header *GetMachHeader() {return header_;}
// Size of mach_header plus load commands
int GetHeaderSize() const {return header_size_;}
size_t GetHeaderSize() const {return header_size_;}
// Full path to mach-o binary
char *GetFilePath() {return file_path_;}
@@ -160,6 +165,9 @@ class DynamicImage {
void Print();
private:
DynamicImage(const DynamicImage &);
DynamicImage &operator=(const DynamicImage &);
friend class DynamicImages;
// Sanity checking
@@ -180,7 +188,7 @@ class DynamicImage {
void CalculateMemoryAndVersionInfo();
breakpad_mach_header *header_; // our local copy of the header
int header_size_; // mach_header plus load commands
size_t header_size_; // mach_header plus load commands
breakpad_mach_header *load_address_; // base address image is mapped into
mach_vm_address_t vmaddr_;
mach_vm_size_t vmsize_;
@@ -231,13 +239,13 @@ class DynamicImages {
explicit DynamicImages(mach_port_t task);
~DynamicImages() {
for (int i = 0; i < (int)image_list_.size(); ++i) {
for (int i = 0; i < GetImageCount(); ++i) {
delete image_list_[i];
}
}
// Returns the number of dynamically loaded mach-o images.
int GetImageCount() const {return image_list_.size();}
int GetImageCount() const {return static_cast<int>(image_list_.size());}
// Returns an individual image.
DynamicImage *GetImage(int i) {
@@ -256,14 +264,14 @@ class DynamicImages {
// Debugging
void Print() {
for (int i = 0; i < (int)image_list_.size(); ++i) {
for (int i = 0; i < GetImageCount(); ++i) {
image_list_[i]->Print();
}
}
void TestPrint() {
const breakpad_mach_header *header;
for (int i = 0; i < (int)image_list_.size(); ++i) {
for (int i = 0; i < GetImageCount(); ++i) {
printf("dyld: %p: name = %s\n", _dyld_get_image_header(i),
_dyld_get_image_name(i) );

View File

@@ -61,8 +61,8 @@ static void SoonToCrash() {
Crasher();
}
bool MDCallback(const char *dump_dir, const char *file_name,
void *context, bool success) {
static bool MDCallback(const char *dump_dir, const char *file_name,
void *context, bool success) {
string path(dump_dir);
string dest(dump_dir);
path.append(file_name);

View File

@@ -57,7 +57,8 @@ namespace google_breakpad {
// constructor when generating from within the crashed process
MinidumpGenerator::MinidumpGenerator()
: exception_type_(0),
: writer_(),
exception_type_(0),
exception_code_(0),
exception_subcode_(0),
exception_thread_(0),
@@ -71,12 +72,14 @@ MinidumpGenerator::MinidumpGenerator()
// crashed process
MinidumpGenerator::MinidumpGenerator(mach_port_t crashing_task,
mach_port_t handler_thread)
: exception_type_(0),
: writer_(),
exception_type_(0),
exception_code_(0),
exception_subcode_(0),
exception_thread_(0),
crashing_task_(crashing_task),
handler_thread_(handler_thread) {
handler_thread_(handler_thread),
dynamic_images_(NULL) {
if (crashing_task != mach_task_self()) {
dynamic_images_ = new DynamicImages(crashing_task_);
} else {
@@ -488,7 +491,7 @@ bool MinidumpGenerator::WriteContext(breakpad_thread_state_data_t state,
// not used in the flags register. Since the minidump format
// specifies 32 bits for the flags register, we can truncate safely
// with no loss.
context_ptr->eflags = machine_state->__rflags;
context_ptr->eflags = static_cast<u_int32_t>(machine_state->__rflags);
AddReg(cs);
AddReg(fs);
AddReg(gs);
@@ -727,7 +730,7 @@ bool MinidumpGenerator::WriteModuleStream(unsigned int index,
return false;
module->base_of_image = image->GetVMAddr() + image->GetVMAddrSlide();
module->size_of_image = image->GetVMSize();
module->size_of_image = static_cast<u_int32_t>(image->GetVMSize());
module->module_name_rva = string_location.rva;
// We'll skip the executable module, because they don't have
@@ -794,7 +797,7 @@ bool MinidumpGenerator::WriteModuleStream(unsigned int index,
return false;
module->base_of_image = seg->vmaddr + slide;
module->size_of_image = seg->vmsize;
module->size_of_image = static_cast<u_int32_t>(seg->vmsize);
module->module_name_rva = string_location.rva;
if (!WriteCVRecord(module, cpu_type, name))
@@ -943,8 +946,10 @@ bool MinidumpGenerator::WriteMiscInfoStream(MDRawDirectory *misc_info_stream) {
struct rusage usage;
if (getrusage(RUSAGE_SELF, &usage) != -1) {
// Omit the fractional time since the MDRawMiscInfo only wants seconds
info_ptr->process_user_time = usage.ru_utime.tv_sec;
info_ptr->process_kernel_time = usage.ru_stime.tv_sec;
info_ptr->process_user_time =
static_cast<u_int32_t>(usage.ru_utime.tv_sec);
info_ptr->process_kernel_time =
static_cast<u_int32_t>(usage.ru_stime.tv_sec);
}
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, info_ptr->process_id };
size_t size;
@@ -956,20 +961,22 @@ bool MinidumpGenerator::WriteMiscInfoStream(MDRawDirectory *misc_info_stream) {
true) == KERN_SUCCESS) {
struct kinfo_proc *proc = (struct kinfo_proc *)addr;
if (!sysctl(mib, sizeof(mib) / sizeof(mib[0]), proc, &size, NULL, 0))
info_ptr->process_create_time = proc->kp_proc.p_starttime.tv_sec;
info_ptr->process_create_time =
static_cast<u_int32_t>(proc->kp_proc.p_starttime.tv_sec);
mach_vm_deallocate(mach_task_self(), addr, size);
}
}
// Speed
uint64_t speed;
const uint64_t kOneMillion = 1000 * 1000;
size = sizeof(speed);
sysctlbyname("hw.cpufrequency_max", &speed, &size, NULL, 0);
info_ptr->processor_max_mhz = speed / (1000 * 1000);
info_ptr->processor_mhz_limit = speed / (1000 * 1000);
info_ptr->processor_max_mhz = static_cast<u_int32_t>(speed / kOneMillion);
info_ptr->processor_mhz_limit = static_cast<u_int32_t>(speed / kOneMillion);
size = sizeof(speed);
sysctlbyname("hw.cpufrequency", &speed, &size, NULL, 0);
info_ptr->processor_current_mhz = speed / (1000 * 1000);
info_ptr->processor_current_mhz = static_cast<u_int32_t>(speed / kOneMillion);
return true;
}

View File

@@ -59,7 +59,7 @@ ProtectedMemoryAllocator::~ProtectedMemoryAllocator() {
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
char *ProtectedMemoryAllocator::Allocate(size_t bytes) {
char *ProtectedMemoryAllocator::Allocate(vm_size_t bytes) {
if (valid_ && next_alloc_offset_ + bytes <= pool_size_) {
char *p = (char*)base_address_ + next_alloc_offset_;
next_alloc_offset_ += bytes;

View File

@@ -53,7 +53,7 @@ class ProtectedMemoryAllocator {
// Fails by returning NULL is no more space is available.
// Please note that the pointers returned from this method should not
// be freed in any way (for example by calling free() on them ).
char * Allocate(size_t n);
char * Allocate(vm_size_t n);
// Returns the base address of the allocation pool.
char * GetBaseAddress() { return (char*)base_address_; }
@@ -78,7 +78,7 @@ class ProtectedMemoryAllocator {
private:
vm_size_t pool_size_;
vm_address_t base_address_;
int next_alloc_offset_;
vm_size_t next_alloc_offset_;
bool valid_;
};