aboutsummaryrefslogtreecommitdiff
path: root/src/common/mac
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/mac')
-rw-r--r--src/common/mac/MachIPC.h20
-rw-r--r--src/common/mac/MachIPC.mm26
-rw-r--r--src/common/mac/dump_syms.cc70
-rw-r--r--src/common/mac/dump_syms.h24
-rw-r--r--src/common/mac/macho_id.cc32
-rw-r--r--src/common/mac/macho_id.h28
-rw-r--r--src/common/mac/macho_reader.cc38
-rw-r--r--src/common/mac/macho_reader.h46
-rw-r--r--src/common/mac/macho_reader_unittest.cc86
-rw-r--r--src/common/mac/macho_walker.cc20
-rw-r--r--src/common/mac/macho_walker.h26
-rw-r--r--src/common/mac/string_utilities.cc4
-rw-r--r--src/common/mac/string_utilities.h2
-rw-r--r--src/common/mac/super_fat_arch.h2
14 files changed, 212 insertions, 212 deletions
diff --git a/src/common/mac/MachIPC.h b/src/common/mac/MachIPC.h
index 71419be9..a3fae5a1 100644
--- a/src/common/mac/MachIPC.h
+++ b/src/common/mac/MachIPC.h
@@ -73,7 +73,7 @@
// mach_port_t task = message.GetTranslatedPort(0);
// mach_port_t thread = message.GetTranslatedPort(1);
//
-// char *messageString = message.GetData();
+// char* messageString = message.GetData();
//
// printf("message string = %s\n", messageString);
// }
@@ -164,7 +164,7 @@ class MachMessage {
public:
// The receiver of the message can retrieve the raw data this way
- uint8_t *GetData() {
+ uint8_t* GetData() {
return GetDataLength() > 0 ? GetDataPacket()->data : NULL;
}
@@ -181,10 +181,10 @@ class MachMessage {
// Adds a descriptor (typically a mach port) to be translated
// returns true if successful, otherwise not enough space
- bool AddDescriptor(const MachMsgPortDescriptor &desc);
+ bool AddDescriptor(const MachMsgPortDescriptor& desc);
int GetDescriptorCount() const { return body.msgh_descriptor_count; }
- MachMsgPortDescriptor *GetDescriptor(int n);
+ MachMsgPortDescriptor* GetDescriptor(int n);
// Convenience method which gets the mach port described by the descriptor
mach_port_t GetTranslatedPort(int n);
@@ -193,7 +193,7 @@ class MachMessage {
bool IsSimpleMessage() const { return GetDescriptorCount() == 0; }
// Sets raw data for the message (returns false if not enough space)
- bool SetData(void *data, int32_t data_length);
+ bool SetData(void* data, int32_t data_length);
protected:
// Consider this an abstract base class - must create an actual instance
@@ -216,7 +216,7 @@ class MachMessage {
MessageDataPacket* GetDataPacket();
void SetDescriptorCount(int n);
- void SetDescriptor(int n, const MachMsgPortDescriptor &desc);
+ void SetDescriptor(int n, const MachMsgPortDescriptor& desc);
// Returns total message size setting msgh_size in the header to this value
mach_msg_size_t CalculateSize();
@@ -250,7 +250,7 @@ class MachSendMessage : public MachMessage {
class ReceivePort {
public:
// Creates a new mach port for receiving messages and registers a name for it
- explicit ReceivePort(const char *receive_port_name);
+ explicit ReceivePort(const char* receive_port_name);
// Given an already existing mach port, use it. We take ownership of the
// port and deallocate it in our destructor.
@@ -262,7 +262,7 @@ class ReceivePort {
~ReceivePort();
// Waits on the mach port until message received or timeout
- kern_return_t WaitForMessage(MachReceiveMessage *out_message,
+ kern_return_t WaitForMessage(MachReceiveMessage* out_message,
mach_msg_timeout_t timeout);
// The underlying mach port that we wrap
@@ -280,13 +280,13 @@ class ReceivePort {
class MachPortSender {
public:
// get a port with send rights corresponding to a named registered service
- explicit MachPortSender(const char *receive_port_name);
+ explicit MachPortSender(const char* receive_port_name);
// Given an already existing mach port, use it.
explicit MachPortSender(mach_port_t send_port);
- kern_return_t SendMessage(MachSendMessage &message,
+ kern_return_t SendMessage(MachSendMessage& message,
mach_msg_timeout_t timeout);
private:
diff --git a/src/common/mac/MachIPC.mm b/src/common/mac/MachIPC.mm
index dc9773f7..b41a825d 100644
--- a/src/common/mac/MachIPC.mm
+++ b/src/common/mac/MachIPC.mm
@@ -52,7 +52,7 @@ MachSendMessage::MachSendMessage(int32_t message_id) : MachMessage() {
//==============================================================================
// returns true if successful
-bool MachMessage::SetData(void *data,
+bool MachMessage::SetData(void* data,
int32_t data_length) {
// first check to make sure we have enough space
size_t size = CalculateSize();
@@ -90,9 +90,9 @@ mach_msg_size_t MachMessage::CalculateSize() {
}
//==============================================================================
-MachMessage::MessageDataPacket *MachMessage::GetDataPacket() {
+MachMessage::MessageDataPacket* MachMessage::GetDataPacket() {
size_t desc_size = sizeof(MachMsgPortDescriptor)*GetDescriptorCount();
- MessageDataPacket *packet =
+ MessageDataPacket* packet =
reinterpret_cast<MessageDataPacket*>(padding + desc_size);
return packet;
@@ -100,15 +100,15 @@ MachMessage::MessageDataPacket *MachMessage::GetDataPacket() {
//==============================================================================
void MachMessage::SetDescriptor(int n,
- const MachMsgPortDescriptor &desc) {
- MachMsgPortDescriptor *desc_array =
+ const MachMsgPortDescriptor& desc) {
+ MachMsgPortDescriptor* desc_array =
reinterpret_cast<MachMsgPortDescriptor*>(padding);
desc_array[n] = desc;
}
//==============================================================================
// returns true if successful otherwise there was not enough space
-bool MachMessage::AddDescriptor(const MachMsgPortDescriptor &desc) {
+bool MachMessage::AddDescriptor(const MachMsgPortDescriptor& desc) {
// first check to make sure we have enough space
int size = CalculateSize();
size_t new_size = size + sizeof(MachMsgPortDescriptor);
@@ -119,7 +119,7 @@ bool MachMessage::AddDescriptor(const MachMsgPortDescriptor &desc) {
// unfortunately, we need to move the data to allow space for the
// new descriptor
- u_int8_t *p = reinterpret_cast<u_int8_t*>(GetDataPacket());
+ u_int8_t* p = reinterpret_cast<u_int8_t*>(GetDataPacket());
bcopy(p, p+sizeof(MachMsgPortDescriptor), GetDataLength()+2*sizeof(int32_t));
SetDescriptor(GetDescriptorCount(), desc);
@@ -142,9 +142,9 @@ void MachMessage::SetDescriptorCount(int n) {
}
//==============================================================================
-MachMsgPortDescriptor *MachMessage::GetDescriptor(int n) {
+MachMsgPortDescriptor* MachMessage::GetDescriptor(int n) {
if (n < GetDescriptorCount()) {
- MachMsgPortDescriptor *desc =
+ MachMsgPortDescriptor* desc =
reinterpret_cast<MachMsgPortDescriptor*>(padding);
return desc + n;
}
@@ -164,7 +164,7 @@ mach_port_t MachMessage::GetTranslatedPort(int n) {
//==============================================================================
// create a new mach port for receiving messages and register a name for it
-ReceivePort::ReceivePort(const char *receive_port_name) {
+ReceivePort::ReceivePort(const char* receive_port_name) {
mach_port_t current_task = mach_task_self();
init_result_ = mach_port_allocate(current_task,
@@ -227,7 +227,7 @@ ReceivePort::~ReceivePort() {
}
//==============================================================================
-kern_return_t ReceivePort::WaitForMessage(MachReceiveMessage *out_message,
+kern_return_t ReceivePort::WaitForMessage(MachReceiveMessage* out_message,
mach_msg_timeout_t timeout) {
if (!out_message) {
return KERN_INVALID_ARGUMENT;
@@ -261,7 +261,7 @@ kern_return_t ReceivePort::WaitForMessage(MachReceiveMessage *out_message,
//==============================================================================
// get a port with send rights corresponding to a named registered service
-MachPortSender::MachPortSender(const char *receive_port_name) {
+MachPortSender::MachPortSender(const char* receive_port_name) {
mach_port_t task_bootstrap_port = 0;
init_result_ = task_get_bootstrap_port(mach_task_self(),
&task_bootstrap_port);
@@ -281,7 +281,7 @@ MachPortSender::MachPortSender(mach_port_t send_port)
}
//==============================================================================
-kern_return_t MachPortSender::SendMessage(MachSendMessage &message,
+kern_return_t MachPortSender::SendMessage(MachSendMessage& message,
mach_msg_timeout_t timeout) {
if (message.head.msgh_size == 0) {
return KERN_INVALID_VALUE; // just for safety -- never should occur
diff --git a/src/common/mac/dump_syms.cc b/src/common/mac/dump_syms.cc
index 2734ff6f..24bcd653 100644
--- a/src/common/mac/dump_syms.cc
+++ b/src/common/mac/dump_syms.cc
@@ -120,7 +120,7 @@ vector<string> list_directory(const string& directory) {
namespace google_breakpad {
-bool DumpSymbols::Read(const string &filename) {
+bool DumpSymbols::Read(const string& filename) {
struct stat st;
if (stat(filename.c_str(), &st) == -1) {
fprintf(stderr, "Could not access object file %s: %s\n",
@@ -195,7 +195,7 @@ bool DumpSymbols::Read(const string &filename) {
// Get our own copy of fat_reader's object file list.
size_t object_files_count;
- const SuperFatArch *object_files =
+ const SuperFatArch* object_files =
fat_reader.object_files(&object_files_count);
if (object_files_count == 0) {
fprintf(stderr, "Fat binary file contains *no* architectures: %s\n",
@@ -212,7 +212,7 @@ bool DumpSymbols::Read(const string &filename) {
bool DumpSymbols::SetArchitecture(cpu_type_t cpu_type,
cpu_subtype_t cpu_subtype) {
// Find the best match for the architecture the user requested.
- const SuperFatArch *best_match = FindBestMatchForArchitecture(
+ const SuperFatArch* best_match = FindBestMatchForArchitecture(
cpu_type, cpu_subtype);
if (!best_match) return false;
@@ -221,9 +221,9 @@ bool DumpSymbols::SetArchitecture(cpu_type_t cpu_type,
return true;
}
-bool DumpSymbols::SetArchitecture(const std::string &arch_name) {
+bool DumpSymbols::SetArchitecture(const std::string& arch_name) {
bool arch_set = false;
- const NXArchInfo *arch_info =
+ const NXArchInfo* arch_info =
google_breakpad::BreakpadGetArchInfoFromName(arch_name.c_str());
if (arch_info) {
arch_set = SetArchitecture(arch_info->cputype, arch_info->cpusubtype);
@@ -251,7 +251,7 @@ SuperFatArch* DumpSymbols::FindBestMatchForArchitecture(
// If all the object files can be converted to struct fat_arch, use
// NXFindBestFatArch.
if (can_convert_to_fat_arch) {
- const struct fat_arch *best_match
+ const struct fat_arch* best_match
= NXFindBestFatArch(cpu_type, cpu_subtype, &fat_arch_vector[0],
static_cast<uint32_t>(fat_arch_vector.size()));
@@ -311,7 +311,7 @@ string DumpSymbols::Identifier() {
class DumpSymbols::DumperRangesHandler:
public DwarfCUToModule::RangesHandler {
public:
- DumperRangesHandler(const uint8_t *buffer, uint64_t size,
+ DumperRangesHandler(const uint8_t* buffer, uint64_t size,
dwarf2reader::ByteReader* reader)
: buffer_(buffer), size_(size), reader_(reader) { }
@@ -325,7 +325,7 @@ class DumpSymbols::DumperRangesHandler:
}
private:
- const uint8_t *buffer_;
+ const uint8_t* buffer_;
uint64_t size_;
dwarf2reader::ByteReader* reader_;
};
@@ -337,7 +337,7 @@ class DumpSymbols::DumperLineToModule:
public DwarfCUToModule::LineToModuleHandler {
public:
// Create a line-to-module converter using BYTE_READER.
- DumperLineToModule(dwarf2reader::ByteReader *byte_reader)
+ DumperLineToModule(dwarf2reader::ByteReader* byte_reader)
: byte_reader_(byte_reader) { }
void StartCompilationUnit(const string& compilation_dir) {
@@ -357,7 +357,7 @@ class DumpSymbols::DumperLineToModule:
}
private:
string compilation_dir_;
- dwarf2reader::ByteReader *byte_reader_; // WEAK
+ dwarf2reader::ByteReader* byte_reader_; // WEAK
};
bool DumpSymbols::CreateEmptyModule(scoped_ptr<Module>& module) {
@@ -369,7 +369,7 @@ bool DumpSymbols::CreateEmptyModule(scoped_ptr<Module>& module) {
selected_object_file_ = &object_files_[0];
else {
// Look for an object file whose architecture matches our own.
- const NXArchInfo *local_arch = NXGetLocalArchInfo();
+ const NXArchInfo* local_arch = NXGetLocalArchInfo();
if (!SetArchitecture(local_arch->cputype, local_arch->cpusubtype)) {
fprintf(stderr, "%s: object file contains more than one"
" architecture, none of which match the current"
@@ -385,11 +385,11 @@ bool DumpSymbols::CreateEmptyModule(scoped_ptr<Module>& module) {
// Find the name of the selected file's architecture, to appear in
// the MODULE record and in error messages.
- const NXArchInfo *selected_arch_info =
+ const NXArchInfo* selected_arch_info =
google_breakpad::BreakpadGetArchInfoFromCpuType(
selected_object_file_->cputype, selected_object_file_->cpusubtype);
- const char *selected_arch_name = selected_arch_info->name;
+ const char* selected_arch_name = selected_arch_info->name;
if (strcmp(selected_arch_name, "i386") == 0)
selected_arch_name = "x86";
@@ -418,9 +418,9 @@ bool DumpSymbols::CreateEmptyModule(scoped_ptr<Module>& module) {
return true;
}
-void DumpSymbols::ReadDwarf(google_breakpad::Module *module,
- const mach_o::Reader &macho_reader,
- const mach_o::SectionMap &dwarf_sections,
+void DumpSymbols::ReadDwarf(google_breakpad::Module* module,
+ const mach_o::Reader& macho_reader,
+ const mach_o::SectionMap& dwarf_sections,
bool handle_inter_cu_refs) const {
// Build a byte reader of the appropriate endianness.
ByteReader byte_reader(macho_reader.big_endian()
@@ -461,7 +461,7 @@ void DumpSymbols::ReadDwarf(google_breakpad::Module *module,
dwarf2reader::SectionMap::const_iterator ranges_entry =
file_context.section_map().find("__debug_ranges");
if (ranges_entry != file_context.section_map().end()) {
- const std::pair<const uint8_t *, uint64_t>& ranges_section =
+ const std::pair<const uint8_t*, uint64_t>& ranges_section =
ranges_entry->second;
ranges_handler.reset(
new DumperRangesHandler(ranges_section.first, ranges_section.second,
@@ -490,9 +490,9 @@ void DumpSymbols::ReadDwarf(google_breakpad::Module *module,
}
}
-bool DumpSymbols::ReadCFI(google_breakpad::Module *module,
- const mach_o::Reader &macho_reader,
- const mach_o::Section &section,
+bool DumpSymbols::ReadCFI(google_breakpad::Module* module,
+ const mach_o::Reader& macho_reader,
+ const mach_o::Section& section,
bool eh_frame) const {
// Find the appropriate set of register names for this file's
// architecture.
@@ -511,7 +511,7 @@ bool DumpSymbols::ReadCFI(google_breakpad::Module *module,
register_names = DwarfCFIToModule::RegisterNames::ARM64();
break;
default: {
- const NXArchInfo *arch = google_breakpad::BreakpadGetArchInfoFromCpuType(
+ const NXArchInfo* arch = google_breakpad::BreakpadGetArchInfoFromCpuType(
macho_reader.cpu_type(), macho_reader.cpu_subtype());
fprintf(stderr, "%s: cannot convert DWARF call frame information for ",
selected_object_name_.c_str());
@@ -526,7 +526,7 @@ bool DumpSymbols::ReadCFI(google_breakpad::Module *module,
}
// Find the call frame information and its size.
- const uint8_t *cfi = section.contents.start;
+ const uint8_t* cfi = section.contents.start;
size_t cfi_size = section.contents.Size();
// Plug together the parser, handler, and their entourages.
@@ -558,9 +558,9 @@ class DumpSymbols::LoadCommandDumper:
public:
// Create a load command dumper handling load commands from READER's
// file, and adding data to MODULE.
- LoadCommandDumper(const DumpSymbols &dumper,
- google_breakpad::Module *module,
- const mach_o::Reader &reader,
+ LoadCommandDumper(const DumpSymbols& dumper,
+ google_breakpad::Module* module,
+ const mach_o::Reader& reader,
SymbolData symbol_data,
bool handle_inter_cu_refs)
: dumper_(dumper),
@@ -569,18 +569,18 @@ class DumpSymbols::LoadCommandDumper:
symbol_data_(symbol_data),
handle_inter_cu_refs_(handle_inter_cu_refs) { }
- bool SegmentCommand(const mach_o::Segment &segment);
- bool SymtabCommand(const ByteBuffer &entries, const ByteBuffer &strings);
+ bool SegmentCommand(const mach_o::Segment& segment);
+ bool SymtabCommand(const ByteBuffer& entries, const ByteBuffer& strings);
private:
- const DumpSymbols &dumper_;
- google_breakpad::Module *module_; // WEAK
- const mach_o::Reader &reader_;
+ const DumpSymbols& dumper_;
+ google_breakpad::Module* module_; // WEAK
+ const mach_o::Reader& reader_;
const SymbolData symbol_data_;
const bool handle_inter_cu_refs_;
};
-bool DumpSymbols::LoadCommandDumper::SegmentCommand(const Segment &segment) {
+bool DumpSymbols::LoadCommandDumper::SegmentCommand(const Segment& segment) {
mach_o::SectionMap section_map;
if (!reader_.MapSegmentSections(segment, &section_map))
return false;
@@ -615,8 +615,8 @@ bool DumpSymbols::LoadCommandDumper::SegmentCommand(const Segment &segment) {
return true;
}
-bool DumpSymbols::LoadCommandDumper::SymtabCommand(const ByteBuffer &entries,
- const ByteBuffer &strings) {
+bool DumpSymbols::LoadCommandDumper::SymtabCommand(const ByteBuffer& entries,
+ const ByteBuffer& strings) {
StabsToModule stabs_to_module(module_);
// Mac OS X STABS are never "unitized", and the size of the 'value' field
// matches the address size of the executable.
@@ -658,7 +658,7 @@ bool DumpSymbols::ReadSymbolData(Module** out_module) {
return true;
}
-bool DumpSymbols::WriteSymbolFile(std::ostream &stream) {
+bool DumpSymbols::WriteSymbolFile(std::ostream& stream) {
Module* module = NULL;
if (ReadSymbolData(&module) && module) {
@@ -673,7 +673,7 @@ bool DumpSymbols::WriteSymbolFile(std::ostream &stream) {
// Read the selected object file's debugging information, and write out the
// header only to |stream|. Return true on success; if an error occurs, report
// it and return false.
-bool DumpSymbols::WriteSymbolFileHeader(std::ostream &stream) {
+bool DumpSymbols::WriteSymbolFileHeader(std::ostream& stream) {
scoped_ptr<Module> module;
if (!CreateEmptyModule(module))
return false;
diff --git a/src/common/mac/dump_syms.h b/src/common/mac/dump_syms.h
index 1e57f86d..daebf876 100644
--- a/src/common/mac/dump_syms.h
+++ b/src/common/mac/dump_syms.h
@@ -70,7 +70,7 @@ class DumpSymbols {
// the name of a universal binary, a Mach-O file, or a dSYM bundle
// containing either of the above. On success, return true; if there is a
// problem reading |filename|, report it and return false.
- bool Read(const std::string &filename);
+ bool Read(const std::string& filename);
// If this dumper's file includes an object file for |cpu_type| and
// |cpu_subtype|, then select that object file for dumping, and return
@@ -91,7 +91,7 @@ class DumpSymbols {
// the dumper will dump those symbols; and if it contains more than one
// object file, then the dumper will dump the object file whose
// architecture matches that of this dumper program.
- bool SetArchitecture(const std::string &arch_name);
+ bool SetArchitecture(const std::string& arch_name);
// Return a pointer to an array of SuperFatArch structures describing the
// object files contained in this dumper's file. Set *|count| to the number
@@ -100,7 +100,7 @@ class DumpSymbols {
//
// If there are no available architectures, this function
// may return NULL.
- const SuperFatArch* AvailableArchitectures(size_t *count) {
+ const SuperFatArch* AvailableArchitectures(size_t* count) {
*count = object_files_.size();
if (object_files_.size() > 0)
return &object_files_[0];
@@ -110,12 +110,12 @@ class DumpSymbols {
// Read the selected object file's debugging information, and write it out to
// |stream|. Return true on success; if an error occurs, report it and
// return false.
- bool WriteSymbolFile(std::ostream &stream);
+ bool WriteSymbolFile(std::ostream& stream);
// Read the selected object file's debugging information, and write out the
// header only to |stream|. Return true on success; if an error occurs, report
// it and return false.
- bool WriteSymbolFileHeader(std::ostream &stream);
+ bool WriteSymbolFileHeader(std::ostream& stream);
// As above, but simply return the debugging information in module
// instead of writing it to a stream. The caller owns the resulting
@@ -142,9 +142,9 @@ class DumpSymbols {
// Read debugging information from |dwarf_sections|, which was taken from
// |macho_reader|, and add it to |module|.
- void ReadDwarf(google_breakpad::Module *module,
- const mach_o::Reader &macho_reader,
- const mach_o::SectionMap &dwarf_sections,
+ void ReadDwarf(google_breakpad::Module* module,
+ const mach_o::Reader& macho_reader,
+ const mach_o::SectionMap& dwarf_sections,
bool handle_inter_cu_refs) const;
// Read DWARF CFI or .eh_frame data from |section|, belonging to
@@ -152,9 +152,9 @@ class DumpSymbols {
// then the data is .eh_frame-format data; otherwise, it is standard DWARF
// .debug_frame data. On success, return true; on failure, report
// the problem and return false.
- bool ReadCFI(google_breakpad::Module *module,
- const mach_o::Reader &macho_reader,
- const mach_o::Section &section,
+ bool ReadCFI(google_breakpad::Module* module,
+ const mach_o::Reader& macho_reader,
+ const mach_o::Section& section,
bool eh_frame) const;
// The selection of what type of symbol data to read/write.
@@ -184,7 +184,7 @@ class DumpSymbols {
// The object file in object_files_ selected to dump, or NULL if
// SetArchitecture hasn't been called yet.
- const SuperFatArch *selected_object_file_;
+ const SuperFatArch* selected_object_file_;
// A string that identifies the selected object file, for use in error
// messages. This is usually object_filename_, but if that refers to a
diff --git a/src/common/mac/macho_id.cc b/src/common/mac/macho_id.cc
index c396ad88..3cf1d4b5 100644
--- a/src/common/mac/macho_id.cc
+++ b/src/common/mac/macho_id.cc
@@ -53,7 +53,7 @@ using google_breakpad::MD5Init;
using google_breakpad::MD5Update;
using google_breakpad::MD5Final;
-MachoID::MachoID(const char *path)
+MachoID::MachoID(const char* path)
: memory_(0),
memory_size_(0),
crc_(0),
@@ -62,7 +62,7 @@ MachoID::MachoID(const char *path)
snprintf(path_, sizeof(path_), "%s", path);
}
-MachoID::MachoID(const char *path, void *memory, size_t size)
+MachoID::MachoID(const char* path, void* memory, size_t size)
: memory_(memory),
memory_size_(size),
crc_(0),
@@ -82,7 +82,7 @@ MachoID::~MachoID() {
// MAX_BLOCK is the largest n such that 255n(n+1)/2 + (n+1)(MAX_BLOCK-1) <= 2^32-1
#define MAX_BLOCK 5552
-void MachoID::UpdateCRC(unsigned char *bytes, size_t size) {
+void MachoID::UpdateCRC(unsigned char* bytes, size_t size) {
// Unrolled loops for summing
#define DO1(buf,i) {sum1 += (buf)[i]; sum2 += sum1;}
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
@@ -122,11 +122,11 @@ void MachoID::UpdateCRC(unsigned char *bytes, size_t size) {
}
}
-void MachoID::UpdateMD5(unsigned char *bytes, size_t size) {
+void MachoID::UpdateMD5(unsigned char* bytes, size_t size) {
MD5Update(&md5_context_, bytes, static_cast<unsigned>(size));
}
-void MachoID::Update(MachoWalker *walker, off_t offset, size_t size) {
+void MachoID::Update(MachoWalker* walker, off_t offset, size_t size) {
if (!update_function_ || !size)
return;
@@ -237,7 +237,7 @@ bool MachoID::MD5(cpu_type_t cpu_type, cpu_subtype_t cpu_subtype, unsigned char
bool MachoID::WalkHeader(cpu_type_t cpu_type,
cpu_subtype_t cpu_subtype,
MachoWalker::LoadCommandCallback callback,
- void *context) {
+ void* context) {
if (memory_) {
MachoWalker walker(memory_, memory_size_, callback, context);
return walker.WalkHeader(cpu_type, cpu_subtype);
@@ -248,9 +248,9 @@ bool MachoID::WalkHeader(cpu_type_t cpu_type,
}
// static
-bool MachoID::WalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
- bool swap, void *context) {
- MachoID *macho_id = (MachoID *)context;
+bool MachoID::WalkerCB(MachoWalker* walker, load_command* cmd, off_t offset,
+ bool swap, void* context) {
+ MachoID* macho_id = (MachoID*)context;
if (cmd->cmd == LC_SEGMENT) {
struct segment_command seg;
@@ -327,11 +327,11 @@ bool MachoID::WalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
}
// static
-bool MachoID::UUIDWalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
- bool swap, void *context) {
+bool MachoID::UUIDWalkerCB(MachoWalker* walker, load_command* cmd, off_t offset,
+ bool swap, void* context) {
if (cmd->cmd == LC_UUID) {
- struct breakpad_uuid_command *uuid_cmd =
- (struct breakpad_uuid_command *)context;
+ struct breakpad_uuid_command* uuid_cmd =
+ (struct breakpad_uuid_command*)context;
if (!walker->ReadBytes(uuid_cmd, sizeof(struct breakpad_uuid_command),
offset))
@@ -348,10 +348,10 @@ bool MachoID::UUIDWalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
}
// static
-bool MachoID::IDWalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
- bool swap, void *context) {
+bool MachoID::IDWalkerCB(MachoWalker* walker, load_command* cmd, off_t offset,
+ bool swap, void* context) {
if (cmd->cmd == LC_ID_DYLIB) {
- struct dylib_command *dylib_cmd = (struct dylib_command *)context;
+ struct dylib_command* dylib_cmd = (struct dylib_command*)context;
if (!walker->ReadBytes(dylib_cmd, sizeof(struct dylib_command), offset))
return false;
diff --git a/src/common/mac/macho_id.h b/src/common/mac/macho_id.h
index 10375491..e8874c37 100644
--- a/src/common/mac/macho_id.h
+++ b/src/common/mac/macho_id.h
@@ -45,8 +45,8 @@ namespace MacFileUtilities {
class MachoID {
public:
- MachoID(const char *path);
- MachoID(const char *path, void *memory, size_t size);
+ MachoID(const char* path);
+ MachoID(const char* path, void* memory, size_t size);
~MachoID();
// For the given |cpu_type| and |cpu_subtype|, return a UUID from the LC_UUID
@@ -78,40 +78,40 @@ class MachoID {
private:
// Signature of class member function to be called with data read from file
- typedef void (MachoID::*UpdateFunction)(unsigned char *bytes, size_t size);
+ typedef void (MachoID::*UpdateFunction)(unsigned char* bytes, size_t size);
// Update the CRC value by examining |size| |bytes| and applying the algorithm
// to each byte.
- void UpdateCRC(unsigned char *bytes, size_t size);
+ void UpdateCRC(unsigned char* bytes, size_t size);
// Update the MD5 value by examining |size| |bytes| and applying the algorithm
// to each byte.
- void UpdateMD5(unsigned char *bytes, size_t size);
+ void UpdateMD5(unsigned char* bytes, size_t size);
// Bottleneck for update routines
- void Update(MachoWalker *walker, off_t offset, size_t size);
+ void Update(MachoWalker* walker, off_t offset, size_t size);
// Factory for the MachoWalker
bool WalkHeader(cpu_type_t cpu_type, cpu_subtype_t cpu_subtype,
- MachoWalker::LoadCommandCallback callback, void *context);
+ MachoWalker::LoadCommandCallback callback, void* context);
// The callback from the MachoWalker for CRC and MD5
- static bool WalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
- bool swap, void *context);
+ static bool WalkerCB(MachoWalker* walker, load_command* cmd, off_t offset,
+ bool swap, void* context);
// The callback from the MachoWalker for LC_UUID
- static bool UUIDWalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
- bool swap, void *context);
+ static bool UUIDWalkerCB(MachoWalker* walker, load_command* cmd, off_t offset,
+ bool swap, void* context);
// The callback from the MachoWalker for LC_ID_DYLIB
- static bool IDWalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
- bool swap, void *context);
+ static bool IDWalkerCB(MachoWalker* walker, load_command* cmd, off_t offset,
+ bool swap, void* context);
// File path
char path_[PATH_MAX];
// Memory region to read from
- void *memory_;
+ void* memory_;
// Size of the memory region
size_t memory_size_;
diff --git a/src/common/mac/macho_reader.cc b/src/common/mac/macho_reader.cc
index 91e1fdd2..b42506cc 100644
--- a/src/common/mac/macho_reader.cc
+++ b/src/common/mac/macho_reader.cc
@@ -81,7 +81,7 @@ void FatReader::Reporter::MisplacedObjectFile() {
" to contain\n", filename_.c_str());
}
-bool FatReader::Read(const uint8_t *buffer, size_t size) {
+bool FatReader::Read(const uint8_t* buffer, size_t size) {
buffer_.start = buffer;
buffer_.end = buffer + size;
ByteCursor cursor(&buffer_);
@@ -196,19 +196,19 @@ void Reader::Reporter::LoadCommandTooShort(size_t i, LoadCommandType type) {
filename_.c_str(), i, type);
}
-void Reader::Reporter::SectionsMissing(const string &name) {
+void Reader::Reporter::SectionsMissing(const string& name) {
fprintf(stderr, "%s: the load command for segment '%s'"
" is too short to hold the section headers it claims to have\n",
filename_.c_str(), name.c_str());
}
-void Reader::Reporter::MisplacedSegmentData(const string &name) {
+void Reader::Reporter::MisplacedSegmentData(const string& name) {
fprintf(stderr, "%s: the segment '%s' claims its contents lie beyond"
" the end of the file\n", filename_.c_str(), name.c_str());
}
-void Reader::Reporter::MisplacedSectionData(const string &section,
- const string &segment) {
+void Reader::Reporter::MisplacedSectionData(const string& section,
+ const string& segment) {
fprintf(stderr, "%s: the section '%s' in segment '%s'"
" claims its contents lie outside the segment's contents\n",
filename_.c_str(), section.c_str(), segment.c_str());
@@ -225,7 +225,7 @@ void Reader::Reporter::UnsupportedCPUType(cpu_type_t cpu_type) {
filename_.c_str(), cpu_type);
}
-bool Reader::Read(const uint8_t *buffer,
+bool Reader::Read(const uint8_t* buffer,
size_t size,
cpu_type_t expected_cpu_type,
cpu_subtype_t expected_cpu_subtype) {
@@ -309,7 +309,7 @@ bool Reader::Read(const uint8_t *buffer,
return true;
}
-bool Reader::WalkLoadCommands(Reader::LoadCommandHandler *handler) const {
+bool Reader::WalkLoadCommands(Reader::LoadCommandHandler* handler) const {
ByteCursor list_cursor(&load_commands_, big_endian_);
for (size_t index = 0; index < load_command_count_; ++index) {
@@ -422,13 +422,13 @@ class Reader::SegmentFinder : public LoadCommandHandler {
public:
// Create a load command handler that looks for a segment named NAME,
// and sets SEGMENT to describe it if found.
- SegmentFinder(const string &name, Segment *segment)
+ SegmentFinder(const string& name, Segment* segment)
: name_(name), segment_(segment), found_() { }
// Return true if the traversal found the segment, false otherwise.
bool found() const { return found_; }
- bool SegmentCommand(const Segment &segment) {
+ bool SegmentCommand(const Segment& segment) {
if (segment.name == name_) {
*segment_ = segment;
found_ = true;
@@ -439,23 +439,23 @@ class Reader::SegmentFinder : public LoadCommandHandler {
private:
// The name of the segment our creator is looking for.
- const string &name_;
+ const string& name_;
// Where we should store the segment if found. (WEAK)
- Segment *segment_;
+ Segment* segment_;
// True if we found the segment.
bool found_;
};
-bool Reader::FindSegment(const string &name, Segment *segment) const {
+bool Reader::FindSegment(const string& name, Segment* segment) const {
SegmentFinder finder(name, segment);
WalkLoadCommands(&finder);
return finder.found();
}
-bool Reader::WalkSegmentSections(const Segment &segment,
- SectionHandler *handler) const {
+bool Reader::WalkSegmentSections(const Segment& segment,
+ SectionHandler* handler) const {
size_t word_size = segment.bits_64 ? 8 : 4;
ByteCursor cursor(&segment.section_list, big_endian_);
@@ -537,18 +537,18 @@ class Reader::SectionMapper: public SectionHandler {
public:
// Create a SectionHandler that populates MAP with an entry for
// each section it is given.
- SectionMapper(SectionMap *map) : map_(map) { }
- bool HandleSection(const Section &section) {
+ SectionMapper(SectionMap* map) : map_(map) { }
+ bool HandleSection(const Section& section) {
(*map_)[section.section_name] = section;
return true;
}
private:
// The map under construction. (WEAK)
- SectionMap *map_;
+ SectionMap* map_;
};
-bool Reader::MapSegmentSections(const Segment &segment,
- SectionMap *section_map) const {
+bool Reader::MapSegmentSections(const Segment& segment,
+ SectionMap* section_map) const {
section_map->clear();
SectionMapper mapper(section_map);
return WalkSegmentSections(segment, &mapper);
diff --git a/src/common/mac/macho_reader.h b/src/common/mac/macho_reader.h
index 145d17d1..02762c55 100644
--- a/src/common/mac/macho_reader.h
+++ b/src/common/mac/macho_reader.h
@@ -78,7 +78,7 @@ class FatReader {
class Reporter {
public:
// Create a reporter that attributes problems to |filename|.
- explicit Reporter(const string &filename) : filename_(filename) { }
+ explicit Reporter(const string& filename) : filename_(filename) { }
virtual ~Reporter() { }
@@ -101,7 +101,7 @@ class FatReader {
};
// Create a fat binary file reader that uses |reporter| to report problems.
- explicit FatReader(Reporter *reporter) : reporter_(reporter) { }
+ explicit FatReader(Reporter* reporter) : reporter_(reporter) { }
// Read the |size| bytes at |buffer| as a fat binary file. On success,
// return true; on failure, report the problem to reporter_ and return
@@ -110,7 +110,7 @@ class FatReader {
// If the data is a plain Mach-O file, rather than a fat binary file,
// then the reader behaves as if it had found a fat binary file whose
// single object file is the Mach-O file.
- bool Read(const uint8_t *buffer, size_t size);
+ bool Read(const uint8_t* buffer, size_t size);
// Return an array of 'SuperFatArch' structures describing the
// object files present in this fat binary file. Set |size| to the
@@ -130,7 +130,7 @@ class FatReader {
// possible to use the result with OS X functions like NXFindBestFatArch,
// so that the symbol dumper will behave consistently with other OS X
// utilities that work with fat binaries.
- const SuperFatArch* object_files(size_t *count) const {
+ const SuperFatArch* object_files(size_t* count) const {
*count = object_files_.size();
if (object_files_.size() > 0)
return &object_files_[0];
@@ -139,7 +139,7 @@ class FatReader {
private:
// We use this to report problems parsing the file's contents. (WEAK)
- Reporter *reporter_;
+ Reporter* reporter_;
// The contents of the fat binary or Mach-O file we're parsing. We do not
// own the storage it refers to.
@@ -240,7 +240,7 @@ class Reader {
class Reporter {
public:
// Create a reporter that attributes problems to |filename|.
- explicit Reporter(const string &filename) : filename_(filename) { }
+ explicit Reporter(const string& filename) : filename_(filename) { }
virtual ~Reporter() { }
// Reporter functions for fatal errors return void; the reader will
@@ -282,16 +282,16 @@ class Reader {
// The LC_SEGMENT or LC_SEGMENT_64 load command for the segment named
// |name| is too short to hold the sections that its header says it does.
// (This more specific than LoadCommandTooShort.)
- virtual void SectionsMissing(const string &name);
+ virtual void SectionsMissing(const string& name);
// The segment named |name| claims that its contents lie beyond the end
// of the file.
- virtual void MisplacedSegmentData(const string &name);
+ virtual void MisplacedSegmentData(const string& name);
// The section named |section| in the segment named |segment| claims that
// its contents do not lie entirely within the segment.
- virtual void MisplacedSectionData(const string &section,
- const string &segment);
+ virtual void MisplacedSectionData(const string& section,
+ const string& segment);
// The LC_SYMTAB command claims that symbol table contents are located
// beyond the end of the file.
@@ -315,7 +315,7 @@ class Reader {
// Called to report that the segment's section list contains |section|.
// This should return true if the iteration should continue, or false
// if it should stop.
- virtual bool HandleSection(const Section &section) = 0;
+ virtual bool HandleSection(const Section& section) = 0;
};
// A handler for the load commands in a Mach-O file.
@@ -341,20 +341,20 @@ class Reader {
// cannot parse the command type or its size, we call
// reporter_->IncompleteLoadCommand instead.)
virtual bool UnknownCommand(LoadCommandType type,
- const ByteBuffer &contents) {
+ const ByteBuffer& contents) {
return true;
}
// The load command is LC_SEGMENT or LC_SEGMENT_64, defining a segment
// with the properties given in |segment|.
- virtual bool SegmentCommand(const Segment &segment) {
+ virtual bool SegmentCommand(const Segment& segment) {
return true;
}
// The load command is LC_SYMTAB. |entries| holds the array of nlist
// entries, and |names| holds the strings the entries refer to.
- virtual bool SymtabCommand(const ByteBuffer &entries,
- const ByteBuffer &names) {
+ virtual bool SymtabCommand(const ByteBuffer& entries,
+ const ByteBuffer& names) {
return true;
}
@@ -362,7 +362,7 @@ class Reader {
};
// Create a Mach-O file reader that reports problems to |reporter|.
- explicit Reader(Reporter *reporter)
+ explicit Reader(Reporter* reporter)
: reporter_(reporter) { }
// Read the given data as a Mach-O file. The reader retains pointers
@@ -371,11 +371,11 @@ class Reader {
//
// At most one of these functions should be invoked once on each Reader
// instance.
- bool Read(const uint8_t *buffer,
+ bool Read(const uint8_t* buffer,
size_t size,
cpu_type_t expected_cpu_type,
cpu_subtype_t expected_cpu_subtype);
- bool Read(const ByteBuffer &buffer,
+ bool Read(const ByteBuffer& buffer,
cpu_type_t expected_cpu_type,
cpu_subtype_t expected_cpu_subtype) {
return Read(buffer.start,
@@ -402,25 +402,25 @@ class Reader {
// a handler function returns false. If we encounter a malformed load
// command, report it via reporter_ and return false. Return true if all
// load commands were parseable and all handlers returned true.
- bool WalkLoadCommands(LoadCommandHandler *handler) const;
+ bool WalkLoadCommands(LoadCommandHandler* handler) const;
// Set |segment| to describe the segment named |name|, if present. If
// found, |segment|'s byte buffers refer to a subregion of the bytes
// passed to Read. If we find the section, return true; otherwise,
// return false.
- bool FindSegment(const string &name, Segment *segment) const;
+ bool FindSegment(const string& name, Segment* segment) const;
// Apply |handler| to each section defined in |segment|. If |handler| returns
// false, stop iterating and return false. If all calls to |handler| return
// true and we reach the end of the section list, return true.
- bool WalkSegmentSections(const Segment &segment, SectionHandler *handler)
+ bool WalkSegmentSections(const Segment& segment, SectionHandler* handler)
const;
// Clear |section_map| and then populate it with a map of the sections
// in |segment|, from section names to Section structures.
// Each Section's contents refer to bytes in |segment|'s contents.
// On success, return true; if a problem occurs, report it and return false.
- bool MapSegmentSections(const Segment &segment, SectionMap *section_map)
+ bool MapSegmentSections(const Segment& segment, SectionMap* section_map)
const;
private:
@@ -429,7 +429,7 @@ class Reader {
class SectionMapper;
// We use this to report problems parsing the file's contents. (WEAK)
- Reporter *reporter_;
+ Reporter* reporter_;
// The contents of the Mach-O file we're parsing. We do not own the
// storage it refers to.
diff --git a/src/common/mac/macho_reader_unittest.cc b/src/common/mac/macho_reader_unittest.cc
index d8459d8c..dccda4e7 100644
--- a/src/common/mac/macho_reader_unittest.cc
+++ b/src/common/mac/macho_reader_unittest.cc
@@ -75,7 +75,7 @@ using testing::_;
class MockFatReaderReporter: public FatReader::Reporter {
public:
- MockFatReaderReporter(const string &filename)
+ MockFatReaderReporter(const string& filename)
: FatReader::Reporter(filename) { }
MOCK_METHOD0(BadHeader, void());
MOCK_METHOD0(MisplacedObjectFile, void());
@@ -84,7 +84,7 @@ class MockFatReaderReporter: public FatReader::Reporter {
class MockReaderReporter: public Reader::Reporter {
public:
- MockReaderReporter(const string &filename) : Reader::Reporter(filename) { }
+ MockReaderReporter(const string& filename) : Reader::Reporter(filename) { }
MOCK_METHOD0(BadHeader, void());
MOCK_METHOD4(CPUTypeMismatch, void(cpu_type_t cpu_type,
cpu_subtype_t cpu_subtype,
@@ -95,24 +95,24 @@ class MockReaderReporter: public Reader::Reporter {
MOCK_METHOD3(LoadCommandsOverrun, void(size_t claimed, size_t i,
LoadCommandType type));
MOCK_METHOD2(LoadCommandTooShort, void(size_t i, LoadCommandType type));
- MOCK_METHOD1(SectionsMissing, void(const string &name));
- MOCK_METHOD1(MisplacedSegmentData, void(const string &name));
- MOCK_METHOD2(MisplacedSectionData, void(const string &section,
- const string &segment));
+ MOCK_METHOD1(SectionsMissing, void(const string& name));
+ MOCK_METHOD1(MisplacedSegmentData, void(const string& name));
+ MOCK_METHOD2(MisplacedSectionData, void(const string& section,
+ const string& segment));
MOCK_METHOD0(MisplacedSymbolTable, void());
MOCK_METHOD1(UnsupportedCPUType, void(cpu_type_t cpu_type));
};
class MockLoadCommandHandler: public Reader::LoadCommandHandler {
public:
- MOCK_METHOD2(UnknownCommand, bool(LoadCommandType, const ByteBuffer &));
- MOCK_METHOD1(SegmentCommand, bool(const Segment &));
- MOCK_METHOD2(SymtabCommand, bool(const ByteBuffer &, const ByteBuffer &));
+ MOCK_METHOD2(UnknownCommand, bool(LoadCommandType, const ByteBuffer&));
+ MOCK_METHOD1(SegmentCommand, bool(const Segment&));
+ MOCK_METHOD2(SymtabCommand, bool(const ByteBuffer&, const ByteBuffer&));
};
class MockSectionHandler: public Reader::SectionHandler {
public:
- MOCK_METHOD1(HandleSection, bool(const Section &section));
+ MOCK_METHOD1(HandleSection, bool(const Section& section));
};
@@ -221,7 +221,7 @@ struct FatReaderFixture {
}
void ReadFat(bool expect_parse_success = true) {
ASSERT_TRUE(fat.GetContents(&contents));
- fat_bytes = reinterpret_cast<const uint8_t *>(contents.data());
+ fat_bytes = reinterpret_cast<const uint8_t*>(contents.data());
if (expect_parse_success) {
EXPECT_TRUE(reader.Read(fat_bytes, contents.size()));
size_t fat_files_count;
@@ -238,7 +238,7 @@ struct FatReaderFixture {
MockFatReaderReporter reporter;
FatReader reader;
string contents;
- const uint8_t *fat_bytes;
+ const uint8_t* fat_bytes;
vector<struct fat_arch> object_files;
};
@@ -487,16 +487,16 @@ class WithConfiguration {
private:
// The innermost WithConfiguration in whose dynamic scope we are
// currently executing.
- static WithConfiguration *current_;
+ static WithConfiguration* current_;
// The innermost WithConfiguration whose dynamic scope encloses this
// WithConfiguration.
Endianness endianness_;
size_t word_size_;
- WithConfiguration *saved_;
+ WithConfiguration* saved_;
};
-WithConfiguration *WithConfiguration::current_ = NULL;
+WithConfiguration* WithConfiguration::current_ = NULL;
// A test_assembler::Section with a size that we can cite. The start(),
// Here() and Mark() member functions of a SizedSection always represent
@@ -527,7 +527,7 @@ class SizedSection: public test_assembler::Section {
// Append SECTION to the end of this section, and call its Finish member.
// Return a reference to this section.
- SizedSection &Place(SizedSection *section) {
+ SizedSection& Place(SizedSection* section) {
assert(section->endianness() == endianness());
section->Finish();
section->start() = Here();
@@ -563,7 +563,7 @@ class LoadedSection: public SizedSection {
// Placing a loaded section within a loaded section sets the relationship
// between their addresses.
- LoadedSection &Place(LoadedSection *section) {
+ LoadedSection& Place(LoadedSection* section) {
section->address() = address() + Size();
SizedSection::Place(section);
return *this;
@@ -583,7 +583,7 @@ class SegmentLoadCommand: public SizedSection {
// The load command will refer to CONTENTS, which must be Placed in the
// file separately, at the desired position. Return a reference to this
// section.
- SegmentLoadCommand &Header(const string &name, const LoadedSection &contents,
+ SegmentLoadCommand& Header(const string& name, const LoadedSection& contents,
uint32_t maxprot, uint32_t initprot,
uint32_t flags) {
assert(contents.word_size() == word_size());
@@ -608,16 +608,16 @@ class SegmentLoadCommand: public SizedSection {
// memory. If this label is still undefined by the time we place this
// segment, it defaults to the final size of the segment's in-file
// contents. Return a reference to this load command.
- Label &vmsize() { return vmsize_; }
+ Label& vmsize() { return vmsize_; }
// Add a section entry with the given characteristics to this segment
// load command. Return a reference to this. The section entry will refer
// to CONTENTS, which must be Placed in the segment's contents
// separately, at the desired position.
- SegmentLoadCommand &AppendSectionEntry(const string &section_name,
- const string &segment_name,
+ SegmentLoadCommand& AppendSectionEntry(const string& section_name,
+ const string& segment_name,
uint32_t alignment, uint32_t flags,
- const LoadedSection &contents) {
+ const LoadedSection& contents) {
AppendCString(section_name, 16);
AppendCString(segment_name, 16);
Append(endianness(), word_size() / 8, contents.address());
@@ -671,14 +671,14 @@ class LoadCommands: public SizedSection {
Label final_command_count() const { return final_command_count_; }
// Increment the command count; return a reference to this section.
- LoadCommands &CountCommand() {
+ LoadCommands& CountCommand() {
command_count_++;
return *this;
}
// Place COMMAND, containing a load command, at the end of this section.
// Return a reference to this section.
- LoadCommands &Place(SizedSection *section) {
+ LoadCommands& Place(SizedSection* section) {
SizedSection::Place(section);
CountCommand();
return *this;
@@ -710,7 +710,7 @@ class MachOFile: public SizedSection {
// Create a Mach-O file header using the given characteristics and load
// command list. This Places COMMANDS immediately after the header.
// Return a reference to this section.
- MachOFile &Header(LoadCommands *commands,
+ MachOFile& Header(LoadCommands* commands,
cpu_type_t cpu_type = CPU_TYPE_X86,
cpu_subtype_t cpu_subtype = CPU_SUBTYPE_I386_ALL,
FileType file_type = MH_EXECUTE,
@@ -752,12 +752,12 @@ struct ReaderFixture {
EXPECT_CALL(load_command_handler, SegmentCommand(_)).Times(0);
}
- void ReadFile(MachOFile *file,
+ void ReadFile(MachOFile* file,
bool expect_parse_success,
cpu_type_t expected_cpu_type,
cpu_subtype_t expected_cpu_subtype) {
ASSERT_TRUE(file->GetContents(&file_contents));
- file_bytes = reinterpret_cast<const uint8_t *>(file_contents.data());
+ file_bytes = reinterpret_cast<const uint8_t*>(file_contents.data());
if (expect_parse_success) {
EXPECT_TRUE(reader.Read(file_bytes,
file_contents.size(),
@@ -772,7 +772,7 @@ struct ReaderFixture {
}
string file_contents;
- const uint8_t *file_bytes;
+ const uint8_t* file_bytes;
MockReaderReporter reporter;
Reader reader;
MockLoadCommandHandler load_command_handler;
@@ -1343,14 +1343,14 @@ TEST_F(LoadCommand, ThreeLoadCommands) {
EXPECT_TRUE(reader.WalkLoadCommands(&load_command_handler));
}
-static inline Matcher<const Section &> MatchSection(
+static inline Matcher<const Section&> MatchSection(
Matcher<bool> bits_64,
- Matcher<const string &> section_name,
- Matcher<const string &> segment_name,
+ Matcher<const string&> section_name,
+ Matcher<const string&> segment_name,
Matcher<uint64_t> address,
Matcher<uint32_t> alignment,
Matcher<uint32_t> flags,
- Matcher<const ByteBuffer &> contents) {
+ Matcher<const ByteBuffer&> contents) {
return AllOf(AllOf(Field(&Section::bits_64, bits_64),
Field(&Section::section_name, section_name),
Field(&Section::segment_name, segment_name),
@@ -1360,10 +1360,10 @@ static inline Matcher<const Section &> MatchSection(
Field(&Section::contents, contents)));
}
-static inline Matcher<const Section &> MatchSection(
+static inline Matcher<const Section&> MatchSection(
Matcher<bool> bits_64,
- Matcher<const string &> section_name,
- Matcher<const string &> segment_name,
+ Matcher<const string&> section_name,
+ Matcher<const string&> segment_name,
Matcher<uint64_t> address) {
return AllOf(Field(&Section::bits_64, bits_64),
Field(&Section::section_name, section_name),
@@ -1410,7 +1410,7 @@ TEST_F(LoadCommand, OneSegmentTwoSections) {
contents1.start = file_bytes + section1.start().Value();
contents1.end = contents1.start + section1.final_size().Value();
EXPECT_EQ("buddha's hand",
- string(reinterpret_cast<const char *>(contents1.start),
+ string(reinterpret_cast<const char*>(contents1.start),
contents1.Size()));
EXPECT_CALL(section_handler,
HandleSection(MatchSection(true, "mandarin", "kishu",
@@ -1422,7 +1422,7 @@ TEST_F(LoadCommand, OneSegmentTwoSections) {
contents2.start = file_bytes + section2.start().Value();
contents2.end = contents2.start + section2.final_size().Value();
EXPECT_EQ("kumquat",
- string(reinterpret_cast<const char *>(contents2.start),
+ string(reinterpret_cast<const char*>(contents2.start),
contents2.Size()));
EXPECT_CALL(section_handler,
HandleSection(MatchSection(true, "bergamot", "cara cara",
@@ -1716,7 +1716,7 @@ class StringAssembler: public SizedSection {
public:
// Add the string S to this StringAssembler, and return the string's
// offset within this compilation unit's strings.
- size_t Add(const string &s) {
+ size_t Add(const string& s) {
size_t offset = Size();
AppendCString(s);
return offset;
@@ -1728,7 +1728,7 @@ class StringAssembler: public SizedSection {
class SymbolAssembler: public SizedSection {
public:
// Create a SymbolAssembler that uses StringAssembler for its strings.
- explicit SymbolAssembler(StringAssembler *string_assembler)
+ explicit SymbolAssembler(StringAssembler* string_assembler)
: string_assembler_(string_assembler),
entry_count_(0) { }
@@ -1737,7 +1737,7 @@ class SymbolAssembler: public SizedSection {
// its compilation unit's portion of the .stabstr section; this can be a
// value generated by a StringAssembler. Return a reference to this
// SymbolAssembler.
- SymbolAssembler &Symbol(uint8_t type, uint8_t other, Label descriptor,
+ SymbolAssembler& Symbol(uint8_t type, uint8_t other, Label descriptor,
Label value, Label name) {
D32(name);
D8(type);
@@ -1749,14 +1749,14 @@ class SymbolAssembler: public SizedSection {
}
// As above, but automatically add NAME to our StringAssembler.
- SymbolAssembler &Symbol(uint8_t type, uint8_t other, Label descriptor,
- Label value, const string &name) {
+ SymbolAssembler& Symbol(uint8_t type, uint8_t other, Label descriptor,
+ Label value, const string& name) {
return Symbol(type, other, descriptor, value, string_assembler_->Add(name));
}
private:
// The strings for our STABS entries.
- StringAssembler *string_assembler_;
+ StringAssembler* string_assembler_;
// The number of entries in this compilation unit so far.
size_t entry_count_;
diff --git a/src/common/mac/macho_walker.cc b/src/common/mac/macho_walker.cc
index 1acd8665..a42128b8 100644
--- a/src/common/mac/macho_walker.cc
+++ b/src/common/mac/macho_walker.cc
@@ -47,8 +47,8 @@
namespace MacFileUtilities {
-MachoWalker::MachoWalker(const char *path, LoadCommandCallback callback,
- void *context)
+MachoWalker::MachoWalker(const char* path, LoadCommandCallback callback,
+ void* context)
: file_(-1),
memory_(NULL),
memory_size_(0),
@@ -60,8 +60,8 @@ MachoWalker::MachoWalker(const char *path, LoadCommandCallback callback,
file_ = open(path, O_RDONLY);
}
-MachoWalker::MachoWalker(void *memory, size_t size,
- LoadCommandCallback callback, void *context)
+MachoWalker::MachoWalker(void* memory, size_t size,
+ LoadCommandCallback callback, void* context)
: file_(-1),
memory_(memory),
memory_size_(size),
@@ -82,7 +82,7 @@ bool MachoWalker::WalkHeader(cpu_type_t cpu_type, cpu_subtype_t cpu_subtype) {
cpu_subtype_t valid_cpu_subtype = cpu_subtype;
// if |cpu_type| is 0, use the native cpu type.
if (cpu_type == 0) {
- const NXArchInfo *arch = NXGetLocalArchInfo();
+ const NXArchInfo* arch = NXGetLocalArchInfo();
assert(arch);
valid_cpu_type = arch->cputype;
valid_cpu_subtype = CPU_SUBTYPE_MULTIPLE;
@@ -98,7 +98,7 @@ bool MachoWalker::WalkHeader(cpu_type_t cpu_type, cpu_subtype_t cpu_subtype) {
return false;
}
-bool MachoWalker::ReadBytes(void *buffer, size_t size, off_t offset) {
+bool MachoWalker::ReadBytes(void* buffer, size_t size, off_t offset) {
if (memory_) {
if (offset < 0)
return false;
@@ -109,14 +109,14 @@ bool MachoWalker::ReadBytes(void *buffer, size_t size, off_t offset) {
size = memory_size_ - static_cast<size_t>(offset);
result = false;
}
- memcpy(buffer, static_cast<char *>(memory_) + offset, size);
+ memcpy(buffer, static_cast<char*>(memory_) + offset, size);
return result;
} else {
return pread(file_, buffer, size, offset) == (ssize_t)size;
}
}
-bool MachoWalker::CurrentHeader(struct mach_header_64 *header, off_t *offset) {
+bool MachoWalker::CurrentHeader(struct mach_header_64* header, off_t* offset) {
if (current_header_) {
memcpy(header, current_header_, sizeof(mach_header_64));
*offset = current_header_offset_;
@@ -128,7 +128,7 @@ bool MachoWalker::CurrentHeader(struct mach_header_64 *header, off_t *offset) {
bool MachoWalker::FindHeader(cpu_type_t cpu_type,
cpu_subtype_t cpu_subtype,
- off_t &offset) {
+ off_t& offset) {
// Read the magic bytes that's common amongst all mach-o files
uint32_t magic;
if (!ReadBytes(&magic, sizeof(magic), 0))
@@ -211,7 +211,7 @@ bool MachoWalker::WalkHeaderAtOffset(off_t offset) {
// Copy the data into the mach_header_64 structure. Since the 32-bit and
// 64-bit only differ in the last field (reserved), this is safe to do.
struct mach_header_64 header64;
- memcpy((void *)&header64, (const void *)&header, sizeof(header));
+ memcpy((void*)&header64, (const void*)&header, sizeof(header));
header64.reserved = 0;
current_header_ = &header64;
diff --git a/src/common/mac/macho_walker.h b/src/common/mac/macho_walker.h
index dd535814..168f30e6 100644
--- a/src/common/mac/macho_walker.h
+++ b/src/common/mac/macho_walker.h
@@ -49,12 +49,12 @@ class MachoWalker {
// beginning of the file (not header) where the command was read. If |swap|
// is set, then any command data (other than the returned load_command) should
// be swapped when read
- typedef bool (*LoadCommandCallback)(MachoWalker *walker, load_command *cmd,
- off_t offset, bool swap, void *context);
+ typedef bool (*LoadCommandCallback)(MachoWalker* walker, load_command* cmd,
+ off_t offset, bool swap, void* context);
- MachoWalker(const char *path, LoadCommandCallback callback, void *context);
- MachoWalker(void *memory, size_t size, LoadCommandCallback callback,
- void *context);
+ MachoWalker(const char* path, LoadCommandCallback callback, void* context);
+ MachoWalker(void* memory, size_t size, LoadCommandCallback callback,
+ void* context);
~MachoWalker();
// Begin walking the header for |cpu_type| and |cpu_subtype|. If |cpu_type|
@@ -67,17 +67,17 @@ class MachoWalker {
bool WalkHeader(cpu_type_t cpu_type, cpu_subtype_t cpu_subtype);
// Read |size| bytes from the opened file at |offset| into |buffer|
- bool ReadBytes(void *buffer, size_t size, off_t offset);
+ bool ReadBytes(void* buffer, size_t size, off_t offset);
// Return the current header and header offset
- bool CurrentHeader(struct mach_header_64 *header, off_t *offset);
+ bool CurrentHeader(struct mach_header_64* header, off_t* offset);
private:
// Locate (if any) the header offset for |cpu_type| and return in |offset|.
// Return true if found, false otherwise.
bool FindHeader(cpu_type_t cpu_type,
cpu_subtype_t cpu_subtype,
- off_t &offset);
+ off_t& offset);
// Process an individual header starting at |offset| from the start of the
// file. Return true if successful, false otherwise.
@@ -91,27 +91,27 @@ class MachoWalker {
int file_;
// Memory location to read from.
- void *memory_;
+ void* memory_;
// Size of the memory segment we can read from.
size_t memory_size_;
// User specified callback & context
LoadCommandCallback callback_;
- void *callback_context_;
+ void* callback_context_;
// Current header, size, and offset. The mach_header_64 is used for both
// 32-bit and 64-bit headers because they only differ in their last field
// (reserved). By adding the |current_header_size_| and the
// |current_header_offset_|, you can determine the offset in the file just
// after the header.
- struct mach_header_64 *current_header_;
+ struct mach_header_64* current_header_;
unsigned long current_header_size_;
off_t current_header_offset_;
private:
- MachoWalker(const MachoWalker &);
- MachoWalker &operator=(const MachoWalker &);
+ MachoWalker(const MachoWalker&);
+ MachoWalker& operator=(const MachoWalker&);
};
} // namespace MacFileUtilities
diff --git a/src/common/mac/string_utilities.cc b/src/common/mac/string_utilities.cc
index 07c0f426..cb155403 100644
--- a/src/common/mac/string_utilities.cc
+++ b/src/common/mac/string_utilities.cc
@@ -48,12 +48,12 @@ std::string ConvertToString(CFStringRef str) {
CFStringGetBytes(str, CFRangeMake(0, length), kCFStringEncodingUTF8, 0,
false, buffer.get(), maxUTF8Length, &actualUTF8Length);
buffer[actualUTF8Length] = 0;
- result.assign((const char *)buffer.get());
+ result.assign((const char*)buffer.get());
return result;
}
-unsigned int IntegerValueAtIndex(string &str, unsigned int idx) {
+unsigned int IntegerValueAtIndex(string& str, unsigned int idx) {
string digits("0123456789"), temp;
size_t start = 0;
size_t end;
diff --git a/src/common/mac/string_utilities.h b/src/common/mac/string_utilities.h
index 6d89c834..e87304c1 100644
--- a/src/common/mac/string_utilities.h
+++ b/src/common/mac/string_utilities.h
@@ -45,7 +45,7 @@ string ConvertToString(CFStringRef str);
// Return the idx'th decimal integer in str, separated by non-decimal-digits
// E.g., str = 10.4.8, idx = 1 -> 4
-unsigned int IntegerValueAtIndex(string &str, unsigned int idx);
+unsigned int IntegerValueAtIndex(string& str, unsigned int idx);
} // namespace MacStringUtils
diff --git a/src/common/mac/super_fat_arch.h b/src/common/mac/super_fat_arch.h
index 501c8652..d7fa018a 100644
--- a/src/common/mac/super_fat_arch.h
+++ b/src/common/mac/super_fat_arch.h
@@ -57,7 +57,7 @@ class SuperFatArch {
align(0) {
}
- explicit SuperFatArch(const struct fat_arch &arch) :
+ explicit SuperFatArch(const struct fat_arch& arch) :
cputype(arch.cputype),
cpusubtype(arch.cpusubtype),
offset(arch.offset),