From 09b056975dacd1f0f815ad820b6dc9913b0118a3 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 23 Jun 2020 18:55:43 -0400 Subject: fix pointer style to match the style guide We do this in a lot of places, but we're inconsistent. Normalize the code to the Google C++ style guide. Change-Id: Ic2aceab661ce8f6b993dda21b1cdf5d2198dcbbf Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2262932 Reviewed-by: Sterling Augustine Reviewed-by: Mark Mentovai --- src/client/ios/Breakpad.h | 46 ++-- src/client/ios/Breakpad.mm | 300 ++++++++++----------- src/client/ios/exception_handler_no_mach.cc | 6 +- src/client/ios/exception_handler_no_mach.h | 42 +-- .../ios/handler/ios_exception_minidump_generator.h | 14 +- .../handler/ios_exception_minidump_generator.mm | 20 +- .../crash_generation/crash_generation_server.cc | 6 +- .../linux/dump_writer_common/ucontext_reader.cc | 10 +- .../linux/dump_writer_common/ucontext_reader.h | 6 +- src/client/linux/handler/exception_handler.cc | 6 +- src/client/linux/handler/exception_handler.h | 4 +- .../linux/handler/exception_handler_unittest.cc | 10 +- src/client/linux/log/log.cc | 4 +- .../minidump_writer/directory_reader_unittest.cc | 2 +- src/client/linux/minidump_writer/line_reader.h | 2 +- .../linux/minidump_writer/line_reader_unittest.cc | 14 +- src/client/linux/minidump_writer/linux_dumper.cc | 10 +- src/client/linux/minidump_writer/linux_dumper.h | 4 +- .../linux_dumper_unittest_helper.cc | 8 +- .../linux_ptrace_dumper_unittest.cc | 2 +- .../linux/minidump_writer/minidump_writer.cc | 8 +- .../minidump_writer/minidump_writer_unittest.cc | 12 +- .../minidump_writer_unittest_utils.cc | 2 +- .../proc_cpuinfo_reader_unittest.cc | 6 +- .../linux/sender/google_crash_report_sender.cc | 2 +- src/client/mac/Framework/Breakpad.h | 22 +- src/client/mac/Framework/Breakpad.mm | 204 +++++++------- src/client/mac/Framework/OnDemandServer.h | 12 +- src/client/mac/Framework/OnDemandServer.mm | 12 +- src/client/mac/crash_generation/ConfigFile.h | 22 +- src/client/mac/crash_generation/ConfigFile.mm | 28 +- src/client/mac/crash_generation/Inspector.h | 14 +- src/client/mac/crash_generation/Inspector.mm | 30 +-- .../crash_generation/crash_generation_server.cc | 16 +- .../mac/crash_generation/crash_generation_server.h | 32 +-- src/client/mac/handler/breakpad_nlist_64.cc | 77 +++--- src/client/mac/handler/breakpad_nlist_64.h | 12 +- src/client/mac/handler/dynamic_images.cc | 44 +-- src/client/mac/handler/dynamic_images.h | 26 +- src/client/mac/handler/exception_handler.cc | 6 +- src/client/mac/handler/exception_handler.h | 62 ++--- src/client/mac/handler/minidump_generator.cc | 184 ++++++------- src/client/mac/handler/minidump_generator.h | 70 ++--- .../mac/handler/testcases/DynamicImagesTests.cc | 6 +- .../mac/handler/testcases/breakpad_nlist_test.cc | 12 +- .../mac/handler/testcases/breakpad_nlist_test.h | 2 +- src/client/mac/testapp/main.m | 2 +- .../mac/tests/crash_generation_server_test.cc | 8 +- src/client/mac/tests/exception_handler_test.cc | 14 +- src/client/mac/tests/minidump_generator_test.cc | 2 +- src/client/minidump_file_writer-inl.h | 4 +- src/client/minidump_file_writer.cc | 30 +-- src/client/minidump_file_writer.h | 42 +-- src/client/minidump_file_writer_unittest.cc | 17 +- src/client/solaris/handler/exception_handler.cc | 22 +- src/client/solaris/handler/exception_handler.h | 32 +-- .../solaris/handler/exception_handler_test.cc | 14 +- src/client/solaris/handler/minidump_generator.cc | 176 ++++++------ src/client/solaris/handler/minidump_generator.h | 8 +- src/client/solaris/handler/minidump_test.cc | 2 +- src/client/solaris/handler/solaris_lwp.cc | 72 ++--- src/client/solaris/handler/solaris_lwp.h | 16 +- src/client/windows/handler/exception_handler.cc | 6 +- src/client/windows/handler/exception_handler.h | 8 +- src/client/windows/sender/crash_report_sender.cc | 14 +- src/client/windows/sender/crash_report_sender.h | 18 +- src/client/windows/unittests/dump_analysis.cc | 4 +- .../unittests/exception_handler_death_test.cc | 18 +- .../unittests/exception_handler_nesting_test.cc | 6 +- .../windows/unittests/exception_handler_test.cc | 20 +- src/common/android/testing/pthread_fixes.h | 2 +- src/common/byte_cursor.h | 49 ++-- src/common/byte_cursor_unittest.cc | 12 +- src/common/dwarf/bytereader-inl.h | 18 +- src/common/dwarf/bytereader.cc | 8 +- src/common/dwarf/bytereader.h | 28 +- src/common/dwarf/bytereader_unittest.cc | 2 +- src/common/dwarf/cfi_assembler.cc | 12 +- src/common/dwarf/cfi_assembler.h | 44 +-- src/common/dwarf/dwarf2diehandler.cc | 22 +- src/common/dwarf/dwarf2diehandler.h | 14 +- src/common/dwarf/dwarf2diehandler_unittest.cc | 10 +- src/common/dwarf/dwarf2reader.cc | 284 +++++++++---------- src/common/dwarf/dwarf2reader.h | 88 +++--- src/common/dwarf/dwarf2reader_cfi_unittest.cc | 52 ++-- src/common/dwarf/dwarf2reader_die_unittest.cc | 14 +- src/common/dwarf/dwarf2reader_test_common.h | 12 +- src/common/dwarf/elf_reader.cc | 150 +++++------ src/common/dwarf/elf_reader.h | 36 +-- src/common/dwarf/functioninfo.cc | 2 +- src/common/dwarf_cfi_to_module.cc | 12 +- src/common/dwarf_cfi_to_module.h | 28 +- src/common/dwarf_cfi_to_module_unittest.cc | 8 +- src/common/dwarf_cu_to_module.cc | 118 ++++---- src/common/dwarf_cu_to_module.h | 36 +-- src/common/dwarf_cu_to_module_unittest.cc | 170 ++++++------ src/common/dwarf_line_to_module.cc | 12 +- src/common/dwarf_line_to_module.h | 10 +- src/common/dwarf_line_to_module_unittest.cc | 8 +- src/common/dwarf_range_list_handler.cc | 2 +- src/common/dwarf_range_list_handler.h | 4 +- src/common/language.cc | 22 +- src/common/language.h | 4 +- src/common/linux/breakpad_getcontext.S | 4 +- src/common/linux/dump_symbols.cc | 44 +-- src/common/linux/dump_symbols.h | 10 +- src/common/linux/elf_symbols_to_module.cc | 20 +- src/common/linux/elf_symbols_to_module.h | 6 +- src/common/linux/elf_symbols_to_module_unittest.cc | 2 +- src/common/linux/elfutils.cc | 22 +- src/common/linux/elfutils.h | 8 +- src/common/linux/file_id.cc | 6 +- src/common/linux/file_id_unittest.cc | 4 +- src/common/linux/guid_creator.cc | 8 +- src/common/linux/http_upload.cc | 56 ++-- src/common/linux/http_upload.h | 24 +- src/common/linux/libcurl_wrapper.cc | 10 +- src/common/linux/libcurl_wrapper.h | 26 +- src/common/linux/linux_libc_support.cc | 2 +- src/common/linux/symbol_upload.cc | 10 +- src/common/linux/synth_elf.cc | 4 +- src/common/linux/synth_elf.h | 4 +- src/common/linux/synth_elf_unittest.cc | 4 +- src/common/linux/tests/crash_generator.cc | 2 +- src/common/mac/MachIPC.h | 20 +- src/common/mac/MachIPC.mm | 26 +- src/common/mac/dump_syms.cc | 70 ++--- src/common/mac/dump_syms.h | 24 +- src/common/mac/macho_id.cc | 32 +-- src/common/mac/macho_id.h | 28 +- src/common/mac/macho_reader.cc | 38 +-- src/common/mac/macho_reader.h | 46 ++-- src/common/mac/macho_reader_unittest.cc | 86 +++--- src/common/mac/macho_walker.cc | 20 +- src/common/mac/macho_walker.h | 26 +- src/common/mac/string_utilities.cc | 4 +- src/common/mac/string_utilities.h | 2 +- src/common/mac/super_fat_arch.h | 2 +- src/common/md5.cc | 14 +- src/common/memory_allocator.h | 22 +- src/common/memory_allocator_unittest.cc | 6 +- src/common/module.cc | 56 ++-- src/common/module.h | 60 ++--- src/common/module_unittest.cc | 2 +- src/common/solaris/dump_symbols.cc | 149 +++++----- src/common/solaris/dump_symbols.h | 2 +- src/common/solaris/file_id.cc | 36 +-- src/common/solaris/guid_creator.cc | 4 +- src/common/stabs_reader.cc | 26 +- src/common/stabs_reader.h | 36 +-- src/common/stabs_reader_unittest.cc | 36 +-- src/common/stabs_to_module.cc | 10 +- src/common/stabs_to_module.h | 6 +- src/common/stabs_to_module_unittest.cc | 10 +- src/common/string_conversion.cc | 58 ++-- src/common/string_conversion.h | 8 +- src/common/test_assembler.cc | 48 ++-- src/common/test_assembler.h | 70 ++--- src/common/test_assembler_unittest.cc | 8 +- src/common/windows/http_upload.cc | 22 +- src/common/windows/http_upload.h | 4 +- src/common/windows/omap.cc | 8 +- src/common/windows/pdb_source_line_writer.cc | 48 ++-- src/common/windows/pdb_source_line_writer.h | 10 +- src/common/windows/pe_util.cc | 4 +- src/common/windows/string_utils-inl.h | 22 +- src/common/windows/string_utils.cc | 6 +- .../processor/basic_source_line_resolver.h | 40 +-- src/google_breakpad/processor/minidump.h | 38 +-- src/google_breakpad/processor/minidump_processor.h | 2 +- .../processor/source_line_resolver_base.h | 40 +-- .../processor/source_line_resolver_interface.h | 24 +- src/google_breakpad/processor/symbol_supplier.h | 28 +- src/processor/address_map-inl.h | 8 +- src/processor/address_map.h | 6 +- src/processor/address_map_unittest.cc | 2 +- src/processor/basic_code_module.h | 14 +- src/processor/basic_code_modules.h | 4 +- src/processor/basic_source_line_resolver.cc | 100 +++---- src/processor/basic_source_line_resolver_types.h | 28 +- .../basic_source_line_resolver_unittest.cc | 32 +-- src/processor/call_stack.cc | 2 +- src/processor/cfi_frame_info-inl.h | 14 +- src/processor/cfi_frame_info.cc | 32 +-- src/processor/cfi_frame_info.h | 52 ++-- src/processor/cfi_frame_info_unittest.cc | 26 +- src/processor/contained_range_map-inl.h | 6 +- src/processor/contained_range_map.h | 16 +- src/processor/contained_range_map_unittest.cc | 2 +- src/processor/disassembler_x86.cc | 12 +- src/processor/disassembler_x86.h | 4 +- src/processor/exploitability_linux.cc | 68 ++--- src/processor/exploitability_linux.h | 34 +-- src/processor/exploitability_win.cc | 16 +- src/processor/fast_source_line_resolver.cc | 22 +- src/processor/fast_source_line_resolver_types.h | 30 +-- .../fast_source_line_resolver_unittest.cc | 22 +- src/processor/logging.cc | 8 +- src/processor/logging.h | 16 +- src/processor/map_serializers-inl.h | 54 ++-- src/processor/map_serializers.h | 26 +- src/processor/map_serializers_unittest.cc | 10 +- src/processor/microdump_stackwalk.cc | 2 +- src/processor/minidump.cc | 34 +-- src/processor/minidump_dump.cc | 4 +- src/processor/minidump_processor.cc | 72 ++--- src/processor/minidump_processor_unittest.cc | 80 +++--- src/processor/minidump_stackwalk.cc | 2 +- src/processor/minidump_unittest.cc | 118 ++++---- src/processor/module_comparer.cc | 4 +- src/processor/module_comparer.h | 2 +- src/processor/module_factory.h | 6 +- src/processor/module_serializer.cc | 28 +- src/processor/module_serializer.h | 26 +- src/processor/pathname_stripper.cc | 2 +- src/processor/pathname_stripper.h | 2 +- src/processor/pathname_stripper_unittest.cc | 2 +- src/processor/postfix_evaluator-inl.h | 32 +-- src/processor/postfix_evaluator.h | 30 +-- src/processor/postfix_evaluator_unittest.cc | 24 +- src/processor/process_state.cc | 2 +- src/processor/range_map-inl.h | 22 +- src/processor/range_map.h | 30 +-- src/processor/range_map_unittest.cc | 18 +- src/processor/simple_serializer-inl.h | 44 +-- src/processor/simple_serializer.h | 4 +- src/processor/simple_symbol_supplier.cc | 32 +-- src/processor/simple_symbol_supplier.h | 40 +-- src/processor/source_line_resolver_base.cc | 48 ++-- src/processor/source_line_resolver_base_types.h | 20 +- src/processor/stackwalk_common.cc | 82 +++--- src/processor/stackwalker_address_list_unittest.cc | 4 +- src/processor/stackwalker_amd64.cc | 6 +- src/processor/stackwalker_amd64.h | 4 +- src/processor/stackwalker_amd64_unittest.cc | 46 ++-- src/processor/stackwalker_arm.cc | 8 +- src/processor/stackwalker_arm.h | 6 +- src/processor/stackwalker_arm64.cc | 8 +- src/processor/stackwalker_arm64.h | 6 +- src/processor/stackwalker_arm64_unittest.cc | 36 +-- src/processor/stackwalker_arm_unittest.cc | 44 +-- src/processor/stackwalker_selftest.cc | 2 +- src/processor/stackwalker_unittest_utils.h | 64 ++--- src/processor/stackwalker_x86.cc | 8 +- src/processor/stackwalker_x86.h | 6 +- src/processor/stackwalker_x86_unittest.cc | 104 +++---- src/processor/static_address_map-inl.h | 4 +- src/processor/static_address_map.h | 6 +- src/processor/static_address_map_unittest.cc | 8 +- src/processor/static_contained_range_map-inl.h | 4 +- src/processor/static_contained_range_map.h | 2 +- src/processor/static_map-inl.h | 6 +- src/processor/static_map.h | 8 +- src/processor/static_map_iterator-inl.h | 2 +- src/processor/static_map_iterator.h | 2 +- src/processor/static_map_unittest.cc | 8 +- src/processor/static_range_map-inl.h | 18 +- src/processor/static_range_map.h | 14 +- src/processor/static_range_map_unittest.cc | 2 +- src/processor/synth_minidump.cc | 54 ++-- src/processor/synth_minidump.h | 88 +++--- src/processor/testdata/linux_test_app.cc | 8 +- src/processor/testdata/test_app.cc | 10 +- src/processor/tokenize.cc | 17 +- src/processor/tokenize.h | 8 +- src/processor/windows_frame_info.h | 8 +- src/tools/linux/dump_syms/dump_syms.cc | 2 +- src/tools/linux/md2core/minidump-2-core.cc | 12 +- src/tools/linux/symupload/minidump_upload.cc | 2 +- src/tools/linux/symupload/sym_upload.cc | 2 +- .../mac/crash_report/on_demand_symbol_supplier.h | 44 +-- .../mac/crash_report/on_demand_symbol_supplier.mm | 94 +++---- src/tools/mac/dump_syms/dump_syms_tool.cc | 4 +- src/tools/mac/dump_syms/macho_dump.cc | 32 +-- src/tools/solaris/dump_syms/dump_syms.cc | 4 +- .../dump_syms/testdata/dump_syms_regtest.cc | 6 +- .../converter/ms_symbol_server_converter.cc | 62 ++--- .../windows/converter/ms_symbol_server_converter.h | 40 +-- src/tools/windows/converter_exe/converter.cc | 124 ++++----- src/tools/windows/converter_exe/http_download.cc | 10 +- src/tools/windows/converter_exe/http_download.h | 4 +- src/tools/windows/converter_exe/tokenizer.cc | 4 +- src/tools/windows/converter_exe/tokenizer.h | 4 +- src/tools/windows/converter_exe/winhttp_client.cc | 4 +- src/tools/windows/converter_exe/wininet_client.cc | 4 +- src/tools/windows/dump_syms/dump_syms.cc | 2 +- src/tools/windows/dump_syms/dump_syms_unittest.cc | 4 +- .../dump_syms/testdata/dump_syms_regtest.cc | 6 +- src/tools/windows/symupload/symupload.cc | 20 +- 289 files changed, 3771 insertions(+), 3776 deletions(-) (limited to 'src') diff --git a/src/client/ios/Breakpad.h b/src/client/ios/Breakpad.h index fa790f77..6c9b8bd6 100644 --- a/src/client/ios/Breakpad.h +++ b/src/client/ios/Breakpad.h @@ -37,7 +37,7 @@ // // These files can then be uploaded to a server. -typedef void *BreakpadRef; +typedef void* BreakpadRef; #ifdef __cplusplus extern "C" { @@ -60,15 +60,15 @@ extern "C" { typedef bool (*BreakpadFilterCallback)(int exception_type, int exception_code, mach_port_t crashing_thread, - void *context); + void* context); // Optional user-defined function that will be called after a network upload // of a crash report. // |report_id| will be the id returned by the server, or "ERR" if an error // occurred. // |error| will contain the error, or nil if no error occured. -typedef void (*BreakpadUploadCompletionCallback)(NSString *report_id, - NSError *error); +typedef void (*BreakpadUploadCompletionCallback)(NSString* report_id, + NSError* error); // Create a new BreakpadRef object and install it as an exception // handler. The |parameters| will typically be the contents of your @@ -163,7 +163,7 @@ typedef void (*BreakpadUploadCompletionCallback)(NSString *report_id, // internal values. // Returns a new BreakpadRef object on success, NULL otherwise. -BreakpadRef BreakpadCreate(NSDictionary *parameters); +BreakpadRef BreakpadCreate(NSDictionary* parameters); // Uninstall and release the data associated with |ref|. void BreakpadRelease(BreakpadRef ref); @@ -187,20 +187,20 @@ void BreakpadRelease(BreakpadRef ref); // TODO (nealsid): separate server parameter dictionary from the // dictionary used to configure Breakpad, and document limits for each // independently. -void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value); -NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key); -void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key); +void BreakpadSetKeyValue(BreakpadRef ref, NSString* key, NSString* value); +NSString* BreakpadKeyValue(BreakpadRef ref, NSString* key); +void BreakpadRemoveKeyValue(BreakpadRef ref, NSString* key); // You can use this method to specify parameters that will be uploaded // to the crash server. They will be automatically encoded as // necessary. Note that as mentioned above there are limits on both // the number of keys and their length. -void BreakpadAddUploadParameter(BreakpadRef ref, NSString *key, - NSString *value); +void BreakpadAddUploadParameter(BreakpadRef ref, NSString* key, + NSString* value); // This method will remove a previously-added parameter from the // upload parameter set. -void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key); +void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString* key); // Method to handle uploading data to the server @@ -208,10 +208,10 @@ void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key); int BreakpadGetCrashReportCount(BreakpadRef ref); // Returns the next upload configuration. The report file is deleted. -NSDictionary *BreakpadGetNextReportConfiguration(BreakpadRef ref); +NSDictionary* BreakpadGetNextReportConfiguration(BreakpadRef ref); // Returns the date of the most recent crash report. -NSDate *BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref); +NSDate* BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref); // Upload next report to the server. void BreakpadUploadNextReport(BreakpadRef ref); @@ -220,7 +220,7 @@ void BreakpadUploadNextReport(BreakpadRef ref); // |server_parameters| is additional server parameters to send. void BreakpadUploadNextReportWithParameters( BreakpadRef ref, - NSDictionary *server_parameters, + NSDictionary* server_parameters, BreakpadUploadCompletionCallback callback); // Upload a report to the server. @@ -228,8 +228,8 @@ void BreakpadUploadNextReportWithParameters( // |configuration| is the configuration of the breakpad report to send. void BreakpadUploadReportWithParametersAndConfiguration( BreakpadRef ref, - NSDictionary *server_parameters, - NSDictionary *configuration, + NSDictionary* server_parameters, + NSDictionary* configuration, BreakpadUploadCompletionCallback callback); // Handles the network response of a breakpad upload. This function is needed if @@ -239,21 +239,21 @@ void BreakpadUploadReportWithParametersAndConfiguration( // BreakpadUploadReportWithParametersAndConfiguration. // |data| and |error| contain the network response. void BreakpadHandleNetworkResponse(BreakpadRef ref, - NSDictionary *configuration, - NSData *data, - NSError *error); + NSDictionary* configuration, + NSData* data, + NSError* error); // Upload a file to the server. |data| is the content of the file to sent. // |server_parameters| is additional server parameters to send. -void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name, - NSDictionary *server_parameters); +void BreakpadUploadData(BreakpadRef ref, NSData* data, NSString* name, + NSDictionary* server_parameters); // Generate a breakpad minidump and configuration file in the dump directory. // The report will be available for uploading. The paths of the created files // are returned in the dictionary. |server_parameters| is additional server // parameters to add in the config file. -NSDictionary *BreakpadGenerateReport(BreakpadRef ref, - NSDictionary *server_parameters); +NSDictionary* BreakpadGenerateReport(BreakpadRef ref, + NSDictionary* server_parameters); #ifdef __cplusplus } diff --git a/src/client/ios/Breakpad.mm b/src/client/ios/Breakpad.mm index 2b61bbe3..11c51746 100644 --- a/src/client/ios/Breakpad.mm +++ b/src/client/ios/Breakpad.mm @@ -84,9 +84,9 @@ using google_breakpad::LongStringDictionary; // allocation of C++ objects. Note that we don't use operator delete() // but instead call the objects destructor directly: object->~ClassName(); // -ProtectedMemoryAllocator *gMasterAllocator = NULL; -ProtectedMemoryAllocator *gKeyValueAllocator = NULL; -ProtectedMemoryAllocator *gBreakpadAllocator = NULL; +ProtectedMemoryAllocator* gMasterAllocator = NULL; +ProtectedMemoryAllocator* gKeyValueAllocator = NULL; +ProtectedMemoryAllocator* gBreakpadAllocator = NULL; // Mutex for thread-safe access to the key/value dictionary used by breakpad. // It's a global instead of an instance variable of Breakpad @@ -101,8 +101,8 @@ pthread_mutex_t gDictionaryMutex; // Its destructor will first re-protect the memory then release the lock. class ProtectedMemoryLocker { public: - ProtectedMemoryLocker(pthread_mutex_t *mutex, - ProtectedMemoryAllocator *allocator) + ProtectedMemoryLocker(pthread_mutex_t* mutex, + ProtectedMemoryAllocator* allocator) : mutex_(mutex), allocator_(allocator) { // Lock the mutex @@ -127,17 +127,17 @@ class ProtectedMemoryLocker { ProtectedMemoryLocker(const ProtectedMemoryLocker&); ProtectedMemoryLocker& operator=(const ProtectedMemoryLocker&); - pthread_mutex_t *mutex_; - ProtectedMemoryAllocator *allocator_; + pthread_mutex_t* mutex_; + ProtectedMemoryAllocator* allocator_; }; //============================================================================= class Breakpad { public: // factory method - static Breakpad *Create(NSDictionary *parameters) { + static Breakpad* Create(NSDictionary* parameters) { // Allocate from our special allocation pool - Breakpad *breakpad = + Breakpad* breakpad = new (gBreakpadAllocator->Allocate(sizeof(Breakpad))) Breakpad(); @@ -155,62 +155,62 @@ class Breakpad { ~Breakpad(); - void SetKeyValue(NSString *key, NSString *value); - NSString *KeyValue(NSString *key); - void RemoveKeyValue(NSString *key); - NSArray *CrashReportsToUpload(); - NSString *NextCrashReportToUpload(); - NSDictionary *NextCrashReportConfiguration(); - NSDictionary *FixedUpCrashReportConfiguration(NSDictionary *configuration); - NSDate *DateOfMostRecentCrashReport(); - void UploadNextReport(NSDictionary *server_parameters); - void UploadReportWithConfiguration(NSDictionary *configuration, - NSDictionary *server_parameters, + void SetKeyValue(NSString* key, NSString* value); + NSString* KeyValue(NSString* key); + void RemoveKeyValue(NSString* key); + NSArray* CrashReportsToUpload(); + NSString* NextCrashReportToUpload(); + NSDictionary* NextCrashReportConfiguration(); + NSDictionary* FixedUpCrashReportConfiguration(NSDictionary* configuration); + NSDate* DateOfMostRecentCrashReport(); + void UploadNextReport(NSDictionary* server_parameters); + void UploadReportWithConfiguration(NSDictionary* configuration, + NSDictionary* server_parameters, BreakpadUploadCompletionCallback callback); - void UploadData(NSData *data, NSString *name, - NSDictionary *server_parameters); - void HandleNetworkResponse(NSDictionary *configuration, - NSData *data, - NSError *error); - NSDictionary *GenerateReport(NSDictionary *server_parameters); + void UploadData(NSData* data, NSString* name, + NSDictionary* server_parameters); + void HandleNetworkResponse(NSDictionary* configuration, + NSData* data, + NSError* error); + NSDictionary* GenerateReport(NSDictionary* server_parameters); private: Breakpad() : handler_(NULL), config_params_(NULL) {} - bool Initialize(NSDictionary *parameters); + bool Initialize(NSDictionary* parameters); - bool ExtractParameters(NSDictionary *parameters); + bool ExtractParameters(NSDictionary* parameters); // Dispatches to HandleMinidump() - static bool HandleMinidumpCallback(const char *dump_dir, - const char *minidump_id, - void *context, bool succeeded); + static bool HandleMinidumpCallback(const char* dump_dir, + const char* minidump_id, + void* context, bool succeeded); - bool HandleMinidump(const char *dump_dir, - const char *minidump_id); + bool HandleMinidump(const char* dump_dir, + const char* minidump_id); // NSException handler - static void UncaughtExceptionHandler(NSException *exception); + static void UncaughtExceptionHandler(NSException* exception); // Handle an uncaught NSException. - void HandleUncaughtException(NSException *exception); + void HandleUncaughtException(NSException* exception); // Since ExceptionHandler (w/o namespace) is defined as typedef in OSX's // MachineExceptions.h, we have to explicitly name the handler. - google_breakpad::ExceptionHandler *handler_; // The actual handler (STRONG) + google_breakpad::ExceptionHandler* handler_; // The actual handler (STRONG) - LongStringDictionary *config_params_; // Create parameters (STRONG) + LongStringDictionary* config_params_; // Create parameters (STRONG) ConfigFile config_file_; // A static reference to the current Breakpad instance. Used for handling // NSException. - static Breakpad *current_breakpad_; + static Breakpad* current_breakpad_; }; -Breakpad *Breakpad::current_breakpad_ = NULL; +Breakpad* Breakpad::current_breakpad_ = NULL; #pragma mark - #pragma mark Helper functions @@ -221,14 +221,14 @@ Breakpad *Breakpad::current_breakpad_ = NULL; //============================================================================= static BOOL IsDebuggerActive() { BOOL result = NO; - NSUserDefaults *stdDefaults = [NSUserDefaults standardUserDefaults]; + NSUserDefaults* stdDefaults = [NSUserDefaults standardUserDefaults]; // We check both defaults and the environment variable here BOOL ignoreDebugger = [stdDefaults boolForKey:@IGNORE_DEBUGGER]; if (!ignoreDebugger) { - char *ignoreDebuggerStr = getenv(IGNORE_DEBUGGER); + char* ignoreDebuggerStr = getenv(IGNORE_DEBUGGER); ignoreDebugger = (ignoreDebuggerStr ? strtol(ignoreDebuggerStr, NULL, 10) : 0) != 0; } @@ -240,7 +240,7 @@ static BOOL IsDebuggerActive() { size_t actualSize; if (sysctl(mib, mibSize, NULL, &actualSize, NULL, 0) == 0) { - struct kinfo_proc *info = (struct kinfo_proc *)malloc(actualSize); + struct kinfo_proc* info = (struct kinfo_proc*)malloc(actualSize); if (info) { // This comes from looking at the Darwin xnu Kernel @@ -256,10 +256,10 @@ static BOOL IsDebuggerActive() { } //============================================================================= -bool Breakpad::HandleMinidumpCallback(const char *dump_dir, - const char *minidump_id, - void *context, bool succeeded) { - Breakpad *breakpad = (Breakpad *)context; +bool Breakpad::HandleMinidumpCallback(const char* dump_dir, + const char* minidump_id, + void* context, bool succeeded) { + Breakpad* breakpad = (Breakpad*)context; // If our context is damaged or something, just return false to indicate that // the handler should continue without us. @@ -270,7 +270,7 @@ bool Breakpad::HandleMinidumpCallback(const char *dump_dir, } //============================================================================= -void Breakpad::UncaughtExceptionHandler(NSException *exception) { +void Breakpad::UncaughtExceptionHandler(NSException* exception) { NSSetUncaughtExceptionHandler(NULL); if (current_breakpad_) { current_breakpad_->HandleUncaughtException(exception); @@ -282,7 +282,7 @@ void Breakpad::UncaughtExceptionHandler(NSException *exception) { #pragma mark - //============================================================================= -bool Breakpad::Initialize(NSDictionary *parameters) { +bool Breakpad::Initialize(NSDictionary* parameters) { // Initialize current_breakpad_ = this; config_params_ = NULL; @@ -325,21 +325,21 @@ Breakpad::~Breakpad() { } //============================================================================= -bool Breakpad::ExtractParameters(NSDictionary *parameters) { - NSString *serverType = [parameters objectForKey:@BREAKPAD_SERVER_TYPE]; - NSString *display = [parameters objectForKey:@BREAKPAD_PRODUCT_DISPLAY]; - NSString *product = [parameters objectForKey:@BREAKPAD_PRODUCT]; - NSString *version = [parameters objectForKey:@BREAKPAD_VERSION]; - NSString *urlStr = [parameters objectForKey:@BREAKPAD_URL]; - NSString *vendor = +bool Breakpad::ExtractParameters(NSDictionary* parameters) { + NSString* serverType = [parameters objectForKey:@BREAKPAD_SERVER_TYPE]; + NSString* display = [parameters objectForKey:@BREAKPAD_PRODUCT_DISPLAY]; + NSString* product = [parameters objectForKey:@BREAKPAD_PRODUCT]; + NSString* version = [parameters objectForKey:@BREAKPAD_VERSION]; + NSString* urlStr = [parameters objectForKey:@BREAKPAD_URL]; + NSString* vendor = [parameters objectForKey:@BREAKPAD_VENDOR]; // We check both parameters and the environment variable here. - char *envVarDumpSubdirectory = getenv(BREAKPAD_DUMP_DIRECTORY); - NSString *dumpSubdirectory = envVarDumpSubdirectory ? + char* envVarDumpSubdirectory = getenv(BREAKPAD_DUMP_DIRECTORY); + NSString* dumpSubdirectory = envVarDumpSubdirectory ? [NSString stringWithUTF8String:envVarDumpSubdirectory] : [parameters objectForKey:@BREAKPAD_DUMP_DIRECTORY]; - NSDictionary *serverParameters = + NSDictionary* serverParameters = [parameters objectForKey:@BREAKPAD_SERVER_PARAMETER_DICT]; if (!product) @@ -360,7 +360,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) { } if (!dumpSubdirectory) { - NSString *cachePath = + NSString* cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) @@ -388,7 +388,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) { new (gKeyValueAllocator->Allocate(sizeof(LongStringDictionary))) LongStringDictionary(); - LongStringDictionary &dictionary = *config_params_; + LongStringDictionary& dictionary = *config_params_; dictionary.SetKeyValue(BREAKPAD_SERVER_TYPE, [serverType UTF8String]); dictionary.SetKeyValue(BREAKPAD_PRODUCT_DISPLAY, [display UTF8String]); @@ -407,8 +407,8 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) { if (serverParameters) { // For each key-value pair, call BreakpadAddUploadParameter() - NSEnumerator *keyEnumerator = [serverParameters keyEnumerator]; - NSString *aParameter; + NSEnumerator* keyEnumerator = [serverParameters keyEnumerator]; + NSString* aParameter; while ((aParameter = [keyEnumerator nextObject])) { BreakpadAddUploadParameter(this, aParameter, [serverParameters objectForKey:aParameter]); @@ -418,7 +418,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) { } //============================================================================= -void Breakpad::SetKeyValue(NSString *key, NSString *value) { +void Breakpad::SetKeyValue(NSString* key, NSString* value) { // We allow nil values. This is the same as removing the keyvalue. if (!config_params_ || !key) return; @@ -427,7 +427,7 @@ void Breakpad::SetKeyValue(NSString *key, NSString *value) { } //============================================================================= -NSString *Breakpad::KeyValue(NSString *key) { +NSString* Breakpad::KeyValue(NSString* key) { if (!config_params_ || !key) return nil; @@ -436,44 +436,44 @@ NSString *Breakpad::KeyValue(NSString *key) { } //============================================================================= -void Breakpad::RemoveKeyValue(NSString *key) { +void Breakpad::RemoveKeyValue(NSString* key) { if (!config_params_ || !key) return; config_params_->RemoveKey([key UTF8String]); } //============================================================================= -NSArray *Breakpad::CrashReportsToUpload() { - NSString *directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); +NSArray* Breakpad::CrashReportsToUpload() { + NSString* directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); if (!directory) return nil; - NSArray *dirContents = [[NSFileManager defaultManager] + NSArray* dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directory error:nil]; - NSArray *configs = [dirContents filteredArrayUsingPredicate:[NSPredicate + NSArray* configs = [dirContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self BEGINSWITH 'Config-'"]]; return configs; } //============================================================================= -NSString *Breakpad::NextCrashReportToUpload() { - NSString *directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); +NSString* Breakpad::NextCrashReportToUpload() { + NSString* directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); if (!directory) return nil; - NSString *config = [CrashReportsToUpload() lastObject]; + NSString* config = [CrashReportsToUpload() lastObject]; if (!config) return nil; return [NSString stringWithFormat:@"%@/%@", directory, config]; } //============================================================================= -NSDictionary *Breakpad::NextCrashReportConfiguration() { - NSDictionary *configuration = [Uploader readConfigurationDataFromFile:NextCrashReportToUpload()]; +NSDictionary* Breakpad::NextCrashReportConfiguration() { + NSDictionary* configuration = [Uploader readConfigurationDataFromFile:NextCrashReportToUpload()]; return FixedUpCrashReportConfiguration(configuration); } //============================================================================= -NSDictionary *Breakpad::FixedUpCrashReportConfiguration(NSDictionary *configuration) { - NSMutableDictionary *fixedConfiguration = [[configuration mutableCopy] autorelease]; +NSDictionary* Breakpad::FixedUpCrashReportConfiguration(NSDictionary* configuration) { + NSMutableDictionary* fixedConfiguration = [[configuration mutableCopy] autorelease]; // kReporterMinidumpDirectoryKey can become stale because the app's data container path includes // an UUID that is not guaranteed to stay the same over time. [fixedConfiguration setObject:KeyValue(@BREAKPAD_DUMP_DIRECTORY) @@ -482,19 +482,19 @@ NSDictionary *Breakpad::FixedUpCrashReportConfiguration(NSDictionary *configurat } //============================================================================= -NSDate *Breakpad::DateOfMostRecentCrashReport() { - NSString *directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); +NSDate* Breakpad::DateOfMostRecentCrashReport() { + NSString* directory = KeyValue(@BREAKPAD_DUMP_DIRECTORY); if (!directory) { return nil; } - NSFileManager *fileManager = [NSFileManager defaultManager]; - NSArray *dirContents = [fileManager contentsOfDirectoryAtPath:directory error:nil]; - NSArray *dumps = [dirContents filteredArrayUsingPredicate:[NSPredicate + NSFileManager* fileManager = [NSFileManager defaultManager]; + NSArray* dirContents = [fileManager contentsOfDirectoryAtPath:directory error:nil]; + NSArray* dumps = [dirContents filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self ENDSWITH '.dmp'"]]; - NSDate *mostRecentCrashReportDate = nil; - for (NSString *dump in dumps) { - NSString *filePath = [directory stringByAppendingPathComponent:dump]; - NSDate *crashReportDate = + NSDate* mostRecentCrashReportDate = nil; + for (NSString* dump in dumps) { + NSString* filePath = [directory stringByAppendingPathComponent:dump]; + NSDate* crashReportDate = [[fileManager attributesOfItemAtPath:filePath error:nil] fileCreationDate]; if (!mostRecentCrashReportDate) { mostRecentCrashReportDate = crashReportDate; @@ -506,29 +506,29 @@ NSDate *Breakpad::DateOfMostRecentCrashReport() { } //============================================================================= -void Breakpad::HandleNetworkResponse(NSDictionary *configuration, - NSData *data, - NSError *error) { - Uploader *uploader = [[[Uploader alloc] +void Breakpad::HandleNetworkResponse(NSDictionary* configuration, + NSData* data, + NSError* error) { + Uploader* uploader = [[[Uploader alloc] initWithConfig:configuration] autorelease]; [uploader handleNetworkResponse:data withError:error]; } //============================================================================= void Breakpad::UploadReportWithConfiguration( - NSDictionary *configuration, - NSDictionary *server_parameters, + NSDictionary* configuration, + NSDictionary* server_parameters, BreakpadUploadCompletionCallback callback) { - Uploader *uploader = [[[Uploader alloc] + Uploader* uploader = [[[Uploader alloc] initWithConfig:configuration] autorelease]; if (!uploader) return; - for (NSString *key in server_parameters) { + for (NSString* key in server_parameters) { [uploader addServerParameter:[server_parameters objectForKey:key] forKey:key]; } if (callback) { - [uploader setUploadCompletionBlock:^(NSString *report_id, NSError *error) { + [uploader setUploadCompletionBlock:^(NSString* report_id, NSError* error) { dispatch_async(dispatch_get_main_queue(), ^{ callback(report_id, error); }); @@ -538,8 +538,8 @@ void Breakpad::UploadReportWithConfiguration( } //============================================================================= -void Breakpad::UploadNextReport(NSDictionary *server_parameters) { - NSDictionary *configuration = NextCrashReportConfiguration(); +void Breakpad::UploadNextReport(NSDictionary* server_parameters) { + NSDictionary* configuration = NextCrashReportConfiguration(); if (configuration) { return UploadReportWithConfiguration(configuration, server_parameters, nullptr); @@ -547,19 +547,19 @@ void Breakpad::UploadNextReport(NSDictionary *server_parameters) { } //============================================================================= -void Breakpad::UploadData(NSData *data, NSString *name, - NSDictionary *server_parameters) { - NSMutableDictionary *config = [NSMutableDictionary dictionary]; +void Breakpad::UploadData(NSData* data, NSString* name, + NSDictionary* server_parameters) { + NSMutableDictionary* config = [NSMutableDictionary dictionary]; LongStringDictionary::Iterator it(*config_params_); - while (const LongStringDictionary::Entry *next = it.Next()) { + while (const LongStringDictionary::Entry* next = it.Next()) { [config setValue:[NSString stringWithUTF8String:next->value] forKey:[NSString stringWithUTF8String:next->key]]; } - Uploader *uploader = + Uploader* uploader = [[[Uploader alloc] initWithConfig:config] autorelease]; - for (NSString *key in server_parameters) { + for (NSString* key in server_parameters) { [uploader addServerParameter:[server_parameters objectForKey:key] forKey:key]; } @@ -567,11 +567,11 @@ void Breakpad::UploadData(NSData *data, NSString *name, } //============================================================================= -NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) { - NSString *dumpDirAsNSString = KeyValue(@BREAKPAD_DUMP_DIRECTORY); +NSDictionary* Breakpad::GenerateReport(NSDictionary* server_parameters) { + NSString* dumpDirAsNSString = KeyValue(@BREAKPAD_DUMP_DIRECTORY); if (!dumpDirAsNSString) return nil; - const char *dumpDir = [dumpDirAsNSString UTF8String]; + const char* dumpDir = [dumpDirAsNSString UTF8String]; google_breakpad::MinidumpGenerator generator(mach_task_self(), MACH_PORT_NULL); @@ -582,7 +582,7 @@ NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) { return nil; LongStringDictionary params = *config_params_; - for (NSString *key in server_parameters) { + for (NSString* key in server_parameters) { params.SetKeyValue([key UTF8String], [[server_parameters objectForKey:key] UTF8String]); } @@ -590,8 +590,8 @@ NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) { config_file.WriteFile(dumpDir, ¶ms, dumpDir, dumpId.c_str()); // Handle results. - NSMutableDictionary *result = [NSMutableDictionary dictionary]; - NSString *dumpFullPath = [NSString stringWithUTF8String:dumpFilename.c_str()]; + NSMutableDictionary* result = [NSMutableDictionary dictionary]; + NSString* dumpFullPath = [NSString stringWithUTF8String:dumpFilename.c_str()]; [result setValue:dumpFullPath forKey:@BREAKPAD_OUTPUT_DUMP_FILE]; [result setValue:[NSString stringWithUTF8String:config_file.GetFilePath()] @@ -600,8 +600,8 @@ NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) { } //============================================================================= -bool Breakpad::HandleMinidump(const char *dump_dir, - const char *minidump_id) { +bool Breakpad::HandleMinidump(const char* dump_dir, + const char* minidump_id) { config_file_.WriteFile(dump_dir, config_params_, dump_dir, @@ -613,7 +613,7 @@ bool Breakpad::HandleMinidump(const char *dump_dir, } //============================================================================= -void Breakpad::HandleUncaughtException(NSException *exception) { +void Breakpad::HandleUncaughtException(NSException* exception) { // Generate the minidump. google_breakpad::IosExceptionMinidumpGenerator generator(exception); const std::string minidump_path = @@ -650,7 +650,7 @@ void Breakpad::HandleUncaughtException(NSException *exception) { #pragma mark Public API //============================================================================= -BreakpadRef BreakpadCreate(NSDictionary *parameters) { +BreakpadRef BreakpadCreate(NSDictionary* parameters) { try { // This is confusing. Our two main allocators for breakpad memory are: // - gKeyValueAllocator for the key/value memory @@ -690,8 +690,8 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) { ProtectedMemoryAllocator(breakpad_pool_size); // Stack-based autorelease pool for Breakpad::Create() obj-c code. - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - Breakpad *breakpad = Breakpad::Create(parameters); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + Breakpad* breakpad = Breakpad::Create(parameters); if (breakpad) { // Make read-only to protect against memory smashers @@ -731,7 +731,7 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) { //============================================================================= void BreakpadRelease(BreakpadRef ref) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (gMasterAllocator) { gMasterAllocator->Unprotect(); @@ -764,10 +764,10 @@ void BreakpadRelease(BreakpadRef ref) { } //============================================================================= -void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value) { +void BreakpadSetKeyValue(BreakpadRef ref, NSString* key, NSString* value) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && key && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); @@ -780,20 +780,20 @@ void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value) { } void BreakpadAddUploadParameter(BreakpadRef ref, - NSString *key, - NSString *value) { + NSString* key, + NSString* value) { // The only difference, internally, between an upload parameter and // a key value one that is set with BreakpadSetKeyValue is that we // prepend the keyname with a special prefix. This informs the // crash sender that the parameter should be sent along with the // POST of the crash dump upload. try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && key && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); - NSString *prefixedKey = [@BREAKPAD_SERVER_PARAMETER_PREFIX + NSString* prefixedKey = [@BREAKPAD_SERVER_PARAMETER_PREFIX stringByAppendingString:key]; breakpad->SetKeyValue(prefixedKey, value); } @@ -803,15 +803,15 @@ void BreakpadAddUploadParameter(BreakpadRef ref, } void BreakpadRemoveUploadParameter(BreakpadRef ref, - NSString *key) { + NSString* key) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && key && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); - NSString *prefixedKey = [NSString stringWithFormat:@"%@%@", + NSString* prefixedKey = [NSString stringWithFormat:@"%@%@", @BREAKPAD_SERVER_PARAMETER_PREFIX, key]; breakpad->RemoveKeyValue(prefixedKey); } @@ -820,12 +820,12 @@ void BreakpadRemoveUploadParameter(BreakpadRef ref, } } //============================================================================= -NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key) { - NSString *value = nil; +NSString* BreakpadKeyValue(BreakpadRef ref, NSString* key) { + NSString* value = nil; try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (!breakpad || !key || !gKeyValueAllocator) return nil; @@ -841,10 +841,10 @@ NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key) { } //============================================================================= -void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) { +void BreakpadRemoveKeyValue(BreakpadRef ref, NSString* key) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && key && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); @@ -860,7 +860,7 @@ void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) { int BreakpadGetCrashReportCount(BreakpadRef ref) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad) { return static_cast([breakpad->CrashReportsToUpload() count]); @@ -877,9 +877,9 @@ void BreakpadUploadNextReport(BreakpadRef ref) { } //============================================================================= -NSDictionary *BreakpadGetNextReportConfiguration(BreakpadRef ref) { +NSDictionary* BreakpadGetNextReportConfiguration(BreakpadRef ref) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad) return breakpad->NextCrashReportConfiguration(); } catch(...) { // don't let exceptions leave this C API @@ -889,9 +889,9 @@ NSDictionary *BreakpadGetNextReportConfiguration(BreakpadRef ref) { } //============================================================================= -NSDate *BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref) { +NSDate* BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad) { return breakpad->DateOfMostRecentCrashReport(); } @@ -904,11 +904,11 @@ NSDate *BreakpadGetDateOfMostRecentCrashReport(BreakpadRef ref) { //============================================================================= void BreakpadUploadReportWithParametersAndConfiguration( BreakpadRef ref, - NSDictionary *server_parameters, - NSDictionary *configuration, + NSDictionary* server_parameters, + NSDictionary* configuration, BreakpadUploadCompletionCallback callback) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (!breakpad || !configuration) return; breakpad->UploadReportWithConfiguration(configuration, server_parameters, @@ -922,13 +922,13 @@ void BreakpadUploadReportWithParametersAndConfiguration( //============================================================================= void BreakpadUploadNextReportWithParameters( BreakpadRef ref, - NSDictionary *server_parameters, + NSDictionary* server_parameters, BreakpadUploadCompletionCallback callback) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (!breakpad) return; - NSDictionary *configuration = breakpad->NextCrashReportConfiguration(); + NSDictionary* configuration = breakpad->NextCrashReportConfiguration(); if (!configuration) return; return BreakpadUploadReportWithParametersAndConfiguration( @@ -939,12 +939,12 @@ void BreakpadUploadNextReportWithParameters( } void BreakpadHandleNetworkResponse(BreakpadRef ref, - NSDictionary *configuration, - NSData *data, - NSError *error) { + NSDictionary* configuration, + NSData* data, + NSError* error) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && configuration) breakpad->HandleNetworkResponse(configuration,data, error); @@ -954,11 +954,11 @@ void BreakpadHandleNetworkResponse(BreakpadRef ref, } //============================================================================= -void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name, - NSDictionary *server_parameters) { +void BreakpadUploadData(BreakpadRef ref, NSData* data, NSString* name, + NSDictionary* server_parameters) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad) { breakpad->UploadData(data, name, server_parameters); @@ -969,11 +969,11 @@ void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name, } //============================================================================= -NSDictionary *BreakpadGenerateReport(BreakpadRef ref, - NSDictionary *server_parameters) { +NSDictionary* BreakpadGenerateReport(BreakpadRef ref, + NSDictionary* server_parameters) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad) { return breakpad->GenerateReport(server_parameters); diff --git a/src/client/ios/exception_handler_no_mach.cc b/src/client/ios/exception_handler_no_mach.cc index 7fcf2d83..cb26449d 100644 --- a/src/client/ios/exception_handler_no_mach.cc +++ b/src/client/ios/exception_handler_no_mach.cc @@ -47,7 +47,7 @@ // for more details. #if USE_PROTECTED_ALLOCATIONS #include "client/mac/handler/protected_memory_allocator.h" - extern ProtectedMemoryAllocator *gBreakpadAllocator; + extern ProtectedMemoryAllocator* gBreakpadAllocator; #endif namespace google_breakpad { @@ -72,10 +72,10 @@ static union { char protected_buffer[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); #endif // defined PAGE_MAX_SIZE #endif // USE_PROTECTED_ALLOCATIONS - google_breakpad::ExceptionHandler *handler; + google_breakpad::ExceptionHandler* handler; } gProtectedData; -ExceptionHandler::ExceptionHandler(const string &dump_path, +ExceptionHandler::ExceptionHandler(const string& dump_path, FilterCallback filter, MinidumpCallback callback, void* callback_context, diff --git a/src/client/ios/exception_handler_no_mach.h b/src/client/ios/exception_handler_no_mach.h index 6d99565b..ec598dcf 100644 --- a/src/client/ios/exception_handler_no_mach.h +++ b/src/client/ios/exception_handler_no_mach.h @@ -53,7 +53,7 @@ class ExceptionHandler { // attempting to write a minidump. If a FilterCallback returns false, Breakpad // will immediately report the exception as unhandled without writing a // minidump, allowing another handler the opportunity to handle it. - typedef bool (*FilterCallback)(void *context); + typedef bool (*FilterCallback)(void* context); // A callback function to run after the minidump has been written. // |minidump_id| is a unique id for the dump, so the minidump @@ -63,18 +63,18 @@ class ExceptionHandler { // Return true if the exception was fully handled and breakpad should exit. // Return false to allow any other exception handlers to process the // exception. - typedef bool (*MinidumpCallback)(const char *dump_dir, - const char *minidump_id, - void *context, bool succeeded); + typedef bool (*MinidumpCallback)(const char* dump_dir, + const char* minidump_id, + void* context, bool succeeded); // A callback function which will be called directly if an exception occurs. // This bypasses the minidump file writing and simply gives the client // the exception information. - typedef bool (*DirectCallback)( void *context, - int exception_type, - int exception_code, - int exception_subcode, - mach_port_t thread_name); + typedef bool (*DirectCallback)(void* context, + int exception_type, + int exception_code, + int exception_subcode, + mach_port_t thread_name); // Creates a new ExceptionHandler instance to handle writing minidumps. // Minidump files will be written to dump_path, and the optional callback @@ -84,22 +84,22 @@ class ExceptionHandler { // be written when WriteMinidump is called. // If port_name is non-NULL, attempt to perform out-of-process dump generation // If port_name is NULL, in-process dump generation will be used. - ExceptionHandler(const string &dump_path, + ExceptionHandler(const string& dump_path, FilterCallback filter, MinidumpCallback callback, - void *callback_context, bool install_handler, - const char *port_name); + void* callback_context, bool install_handler, + const char* port_name); // A special constructor if we want to bypass minidump writing and // simply get a callback with the exception information. ExceptionHandler(DirectCallback callback, - void *callback_context, + void* callback_context, bool install_handler); ~ExceptionHandler(); // Get and set the minidump path. string dump_path() const { return dump_path_; } - void set_dump_path(const string &dump_path) { + void set_dump_path(const string& dump_path) { dump_path_ = dump_path; dump_path_c_ = dump_path_.c_str(); UpdateNextID(); // Necessary to put dump_path_ in next_minidump_path_. @@ -126,7 +126,7 @@ class ExceptionHandler { bool WriteMinidumpWithException(int exception_type, int exception_code, int exception_subcode, - breakpad_ucontext_t *task_context, + breakpad_ucontext_t* task_context, mach_port_t thread_name, bool exit_after_write, bool report_current_thread); @@ -135,8 +135,8 @@ class ExceptionHandler { static void SignalHandler(int sig, siginfo_t* info, void* uc); // disallow copy ctor and operator= - explicit ExceptionHandler(const ExceptionHandler &); - void operator=(const ExceptionHandler &); + explicit ExceptionHandler(const ExceptionHandler&); + void operator=(const ExceptionHandler&); // Generates a new ID and stores it in next_minidump_id_, and stores the // path of the next minidump to be written in next_minidump_path_. @@ -152,15 +152,15 @@ class ExceptionHandler { string next_minidump_path_; // Pointers to the UTF-8 versions of above - const char *dump_path_c_; - const char *next_minidump_id_c_; - const char *next_minidump_path_c_; + const char* dump_path_c_; + const char* next_minidump_id_c_; + const char* next_minidump_path_c_; // The callback function and pointer to be passed back after the minidump // has been written FilterCallback filter_; MinidumpCallback callback_; - void *callback_context_; + void* callback_context_; // The callback function to be passed back when we don't want a minidump // file to be written diff --git a/src/client/ios/handler/ios_exception_minidump_generator.h b/src/client/ios/handler/ios_exception_minidump_generator.h index 21133e63..e48444a7 100644 --- a/src/client/ios/handler/ios_exception_minidump_generator.h +++ b/src/client/ios/handler/ios_exception_minidump_generator.h @@ -41,12 +41,12 @@ namespace google_breakpad { class IosExceptionMinidumpGenerator : public MinidumpGenerator { public: - explicit IosExceptionMinidumpGenerator(NSException *exception); + explicit IosExceptionMinidumpGenerator(NSException* exception); virtual ~IosExceptionMinidumpGenerator(); protected: - virtual bool WriteExceptionStream(MDRawDirectory *exception_stream); - virtual bool WriteThreadStream(mach_port_t thread_id, MDRawThread *thread); + virtual bool WriteExceptionStream(MDRawDirectory* exception_stream); + virtual bool WriteThreadStream(mach_port_t thread_id, MDRawThread* thread); private: @@ -57,16 +57,16 @@ class IosExceptionMinidumpGenerator : public MinidumpGenerator { uintptr_t GetLRFromException(); // Write a virtual thread context for the crashing site. - bool WriteCrashingContext(MDLocationDescriptor *register_location); + bool WriteCrashingContext(MDLocationDescriptor* register_location); // Per-CPU implementations of the above method. #ifdef HAS_ARM_SUPPORT - bool WriteCrashingContextARM(MDLocationDescriptor *register_location); + bool WriteCrashingContextARM(MDLocationDescriptor* register_location); #endif #ifdef HAS_ARM64_SUPPORT - bool WriteCrashingContextARM64(MDLocationDescriptor *register_location); + bool WriteCrashingContextARM64(MDLocationDescriptor* register_location); #endif - NSArray *return_addresses_; + NSArray* return_addresses_; }; } // namespace google_breakpad diff --git a/src/client/ios/handler/ios_exception_minidump_generator.mm b/src/client/ios/handler/ios_exception_minidump_generator.mm index f57bdf21..2a5d76d7 100644 --- a/src/client/ios/handler/ios_exception_minidump_generator.mm +++ b/src/client/ios/handler/ios_exception_minidump_generator.mm @@ -52,7 +52,7 @@ const uintptr_t kExpectedFinalSp = 0; // Append the given value to the sp position of the stack represented // by memory. -void AppendToMemory(uint8_t *memory, uintptr_t sp, uintptr_t data) { +void AppendToMemory(uint8_t* memory, uintptr_t sp, uintptr_t data) { memcpy(memory + sp, &data, sizeof(data)); } #endif @@ -62,7 +62,7 @@ void AppendToMemory(uint8_t *memory, uintptr_t sp, uintptr_t data) { namespace google_breakpad { IosExceptionMinidumpGenerator::IosExceptionMinidumpGenerator( - NSException *exception) + NSException* exception) : MinidumpGenerator(mach_task_self(), 0) { return_addresses_ = [[exception callStackReturnAddresses] retain]; SetExceptionInformation(kExceptionType, @@ -76,7 +76,7 @@ IosExceptionMinidumpGenerator::~IosExceptionMinidumpGenerator() { } bool IosExceptionMinidumpGenerator::WriteCrashingContext( - MDLocationDescriptor *register_location) { + MDLocationDescriptor* register_location) { #ifdef HAS_ARM_SUPPORT return WriteCrashingContextARM(register_location); #elif defined(HAS_ARM64_SUPPORT) @@ -89,12 +89,12 @@ bool IosExceptionMinidumpGenerator::WriteCrashingContext( #ifdef HAS_ARM_SUPPORT bool IosExceptionMinidumpGenerator::WriteCrashingContextARM( - MDLocationDescriptor *register_location) { + MDLocationDescriptor* register_location) { TypedMDRVA context(&writer_); if (!context.Allocate()) return false; *register_location = context.location(); - MDRawContextARM *context_ptr = context.get(); + MDRawContextARM* context_ptr = context.get(); memset(context_ptr, 0, sizeof(MDRawContextARM)); context_ptr->context_flags = MD_CONTEXT_ARM_FULL; context_ptr->iregs[MD_CONTEXT_ARM_REG_IOS_FP] = kExpectedFinalFp; // FP @@ -107,12 +107,12 @@ bool IosExceptionMinidumpGenerator::WriteCrashingContextARM( #ifdef HAS_ARM64_SUPPORT bool IosExceptionMinidumpGenerator::WriteCrashingContextARM64( - MDLocationDescriptor *register_location) { + MDLocationDescriptor* register_location) { TypedMDRVA context(&writer_); if (!context.Allocate()) return false; *register_location = context.location(); - MDRawContextARM64_Old *context_ptr = context.get(); + MDRawContextARM64_Old* context_ptr = context.get(); memset(context_ptr, 0, sizeof(*context_ptr)); context_ptr->context_flags = MD_CONTEXT_ARM64_FULL_OLD; context_ptr->iregs[MD_CONTEXT_ARM64_REG_FP] = kExpectedFinalFp; // FP @@ -132,7 +132,7 @@ uintptr_t IosExceptionMinidumpGenerator::GetLRFromException() { } bool IosExceptionMinidumpGenerator::WriteExceptionStream( - MDRawDirectory *exception_stream) { + MDRawDirectory* exception_stream) { #if defined(HAS_ARM_SUPPORT) || defined(HAS_ARM64_SUPPORT) TypedMDRVA exception(&writer_); @@ -141,7 +141,7 @@ bool IosExceptionMinidumpGenerator::WriteExceptionStream( exception_stream->stream_type = MD_EXCEPTION_STREAM; exception_stream->location = exception.location(); - MDRawExceptionStream *exception_ptr = exception.get(); + MDRawExceptionStream* exception_ptr = exception.get(); exception_ptr->thread_id = pthread_mach_thread_np(pthread_self()); // This naming is confusing, but it is the proper translation from @@ -160,7 +160,7 @@ bool IosExceptionMinidumpGenerator::WriteExceptionStream( } bool IosExceptionMinidumpGenerator::WriteThreadStream(mach_port_t thread_id, - MDRawThread *thread) { + MDRawThread* thread) { #if defined(HAS_ARM_SUPPORT) || defined(HAS_ARM64_SUPPORT) if (pthread_mach_thread_np(pthread_self()) != thread_id) return MinidumpGenerator::WriteThreadStream(thread_id, thread); diff --git a/src/client/linux/crash_generation/crash_generation_server.cc b/src/client/linux/crash_generation/crash_generation_server.cc index 26c50a5c..8332f59d 100644 --- a/src/client/linux/crash_generation/crash_generation_server.cc +++ b/src/client/linux/crash_generation/crash_generation_server.cc @@ -229,7 +229,7 @@ CrashGenerationServer::ClientEvent(short revents) // Walk the control payload and extract the file descriptor and validated pid. pid_t crashing_pid = -1; int signal_fd = -1; - for (struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); hdr; + for (struct cmsghdr* hdr = CMSG_FIRSTHDR(&msg); hdr; hdr = CMSG_NXTHDR(&msg, hdr)) { if (hdr->cmsg_level != SOL_SOCKET) continue; @@ -248,7 +248,7 @@ CrashGenerationServer::ClientEvent(short revents) signal_fd = reinterpret_cast(CMSG_DATA(hdr))[0]; } } else if (hdr->cmsg_type == SCM_CREDENTIALS) { - const struct ucred *cred = + const struct ucred* cred = reinterpret_cast(CMSG_DATA(hdr)); crashing_pid = cred->pid; } @@ -324,7 +324,7 @@ CrashGenerationServer::MakeMinidumpFilename(string& outFilename) // static void* -CrashGenerationServer::ThreadMain(void *arg) +CrashGenerationServer::ThreadMain(void* arg) { reinterpret_cast(arg)->Run(); return NULL; diff --git a/src/client/linux/dump_writer_common/ucontext_reader.cc b/src/client/linux/dump_writer_common/ucontext_reader.cc index ee515c41..6eec1be2 100644 --- a/src/client/linux/dump_writer_common/ucontext_reader.cc +++ b/src/client/linux/dump_writer_common/ucontext_reader.cc @@ -48,7 +48,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) { return uc->uc_mcontext.gregs[REG_EIP]; } -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc, +void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc, const fpstate_t* fp) { const greg_t* regs = uc->uc_mcontext.gregs; @@ -96,7 +96,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) { return uc->uc_mcontext.gregs[REG_RIP]; } -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc, +void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc, const fpstate_t* fpregs) { const greg_t* regs = uc->uc_mcontext.gregs; @@ -153,7 +153,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) { return uc->uc_mcontext.arm_pc; } -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) { +void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc) { out->context_flags = MD_CONTEXT_ARM_FULL; out->iregs[0] = uc->uc_mcontext.arm_r0; @@ -192,7 +192,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) { return uc->uc_mcontext.pc; } -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc, +void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc, const struct fpsimd_context* fpregs) { out->context_flags = MD_CONTEXT_ARM64_FULL_OLD; @@ -218,7 +218,7 @@ uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) { return uc->uc_mcontext.pc; } -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) { +void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc) { #if _MIPS_SIM == _ABI64 out->context_flags = MD_CONTEXT_MIPS64_FULL; #elif _MIPS_SIM == _ABIO32 diff --git a/src/client/linux/dump_writer_common/ucontext_reader.h b/src/client/linux/dump_writer_common/ucontext_reader.h index 8e74a8a5..7d410088 100644 --- a/src/client/linux/dump_writer_common/ucontext_reader.h +++ b/src/client/linux/dump_writer_common/ucontext_reader.h @@ -50,13 +50,13 @@ struct UContextReader { // out: the minidump structure // info: the collection of register structures. #if defined(__i386__) || defined(__x86_64) - static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc, + static void FillCPUContext(RawContextCPU* out, const ucontext_t* uc, const fpstate_t* fp); #elif defined(__aarch64__) - static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc, + static void FillCPUContext(RawContextCPU* out, const ucontext_t* uc, const struct fpsimd_context* fpregs); #else - static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc); + static void FillCPUContext(RawContextCPU* out, const ucontext_t* uc); #endif }; diff --git a/src/client/linux/handler/exception_handler.cc b/src/client/linux/handler/exception_handler.cc index c65feaa1..ca353c40 100644 --- a/src/client/linux/handler/exception_handler.cc +++ b/src/client/linux/handler/exception_handler.cc @@ -419,8 +419,8 @@ struct ThreadArgument { // This is the entry function for the cloned process. We are in a compromised // context here: see the top of the file. // static -int ExceptionHandler::ThreadEntry(void *arg) { - const ThreadArgument *thread_arg = reinterpret_cast(arg); +int ExceptionHandler::ThreadEntry(void* arg) { + const ThreadArgument* thread_arg = reinterpret_cast(arg); // Close the write end of the pipe. This allows us to fail if the parent dies // while waiting for the continue signal. @@ -495,7 +495,7 @@ bool ExceptionHandler::SimulateSignalDelivery(int sig) { } // This function may run in a compromised context: see the top of the file. -bool ExceptionHandler::GenerateDump(CrashContext *context) { +bool ExceptionHandler::GenerateDump(CrashContext* context) { if (IsOutOfProcess()) return crash_generation_client_->RequestDump(context, sizeof(*context)); diff --git a/src/client/linux/handler/exception_handler.h b/src/client/linux/handler/exception_handler.h index f44483ff..f80843ea 100644 --- a/src/client/linux/handler/exception_handler.h +++ b/src/client/linux/handler/exception_handler.h @@ -82,7 +82,7 @@ class ExceptionHandler { // attempting to write a minidump. If a FilterCallback returns false, // Breakpad will immediately report the exception as unhandled without // writing a minidump, allowing another handler the opportunity to handle it. - typedef bool (*FilterCallback)(void *context); + typedef bool (*FilterCallback)(void* context); // A callback function to run after the minidump has been written. // |descriptor| contains the file descriptor or file path containing the @@ -234,7 +234,7 @@ class ExceptionHandler { static void RestoreHandlersLocked(); void PreresolveSymbols(); - bool GenerateDump(CrashContext *context); + bool GenerateDump(CrashContext* context); void SendContinueSignalToChild(); void WaitForContinueSignal(); diff --git a/src/client/linux/handler/exception_handler_unittest.cc b/src/client/linux/handler/exception_handler_unittest.cc index 8d8809fa..35dcbfd4 100644 --- a/src/client/linux/handler/exception_handler_unittest.cc +++ b/src/client/linux/handler/exception_handler_unittest.cc @@ -201,7 +201,7 @@ static bool DoneCallback(const MinidumpDescriptor& descriptor, // optimize them out. In the case of ExceptionHandlerTest::ExternalDumper, // GCC-4.9 optimized out the entire set up of ExceptionHandler, causing // test failure. -volatile int *p_null; // external linkage, so GCC can't tell that it +volatile int* p_null; // external linkage, so GCC can't tell that it // remains NULL. Volatile just for a good measure. static void DoNullPointerDereference() { *p_null = 1; @@ -994,7 +994,7 @@ CrashHandler(const void* crash_context, size_t crash_context_size, msg.msg_control = cmsg; msg.msg_controllen = sizeof(cmsg); - struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); + struct cmsghdr* hdr = CMSG_FIRSTHDR(&msg); hdr->cmsg_level = SOL_SOCKET; hdr->cmsg_type = SCM_RIGHTS; hdr->cmsg_len = CMSG_LEN(sizeof(int)); @@ -1003,7 +1003,7 @@ CrashHandler(const void* crash_context, size_t crash_context_size, hdr->cmsg_level = SOL_SOCKET; hdr->cmsg_type = SCM_CREDENTIALS; hdr->cmsg_len = CMSG_LEN(sizeof(struct ucred)); - struct ucred *cred = reinterpret_cast(CMSG_DATA(hdr)); + struct ucred* cred = reinterpret_cast(CMSG_DATA(hdr)); cred->uid = getuid(); cred->gid = getgid(); cred->pid = getpid(); @@ -1056,7 +1056,7 @@ TEST(ExceptionHandlerTest, ExternalDumper) { pid_t crashing_pid = -1; int signal_fd = -1; - for (struct cmsghdr *hdr = CMSG_FIRSTHDR(&msg); hdr; + for (struct cmsghdr* hdr = CMSG_FIRSTHDR(&msg); hdr; hdr = CMSG_NXTHDR(&msg, hdr)) { if (hdr->cmsg_level != SOL_SOCKET) continue; @@ -1066,7 +1066,7 @@ TEST(ExceptionHandlerTest, ExternalDumper) { ASSERT_EQ(sizeof(int), len); signal_fd = *(reinterpret_cast(CMSG_DATA(hdr))); } else if (hdr->cmsg_type == SCM_CREDENTIALS) { - const struct ucred *cred = + const struct ucred* cred = reinterpret_cast(CMSG_DATA(hdr)); crashing_pid = cred->pid; } diff --git a/src/client/linux/log/log.cc b/src/client/linux/log/log.cc index fc23aa6d..31879409 100644 --- a/src/client/linux/log/log.cc +++ b/src/client/linux/log/log.cc @@ -44,8 +44,8 @@ namespace { // __android_log_buf_write() is not exported in the NDK and is being used by // dynamic runtime linking. Its declaration is taken from Android's // system/core/include/log/log.h. -using AndroidLogBufferWriteFunc = int (*)(int bufID, int prio, const char *tag, - const char *text); +using AndroidLogBufferWriteFunc = int (*)(int bufID, int prio, const char* tag, + const char* text); const int kAndroidCrashLogId = 4; // From LOG_ID_CRASH in log.h. const char kAndroidLogTag[] = "google-breakpad"; diff --git a/src/client/linux/minidump_writer/directory_reader_unittest.cc b/src/client/linux/minidump_writer/directory_reader_unittest.cc index 326f9e36..7292a636 100644 --- a/src/client/linux/minidump_writer/directory_reader_unittest.cc +++ b/src/client/linux/minidump_writer/directory_reader_unittest.cc @@ -47,7 +47,7 @@ typedef testing::Test DirectoryReaderTest; TEST(DirectoryReaderTest, CompareResults) { std::set dent_set; - DIR *const dir = opendir("/proc/self"); + DIR* const dir = opendir("/proc/self"); ASSERT_TRUE(dir != NULL); struct dirent* dent; diff --git a/src/client/linux/minidump_writer/line_reader.h b/src/client/linux/minidump_writer/line_reader.h index 779cfeb6..9fc4b7cc 100644 --- a/src/client/linux/minidump_writer/line_reader.h +++ b/src/client/linux/minidump_writer/line_reader.h @@ -61,7 +61,7 @@ class LineReader { // // One must call |PopLine| after this function, otherwise you'll continue to // get the same line over and over. - bool GetNextLine(const char **line, unsigned *len) { + bool GetNextLine(const char** line, unsigned* len) { for (;;) { if (buf_used_ == 0 && hit_eof_) return false; diff --git a/src/client/linux/minidump_writer/line_reader_unittest.cc b/src/client/linux/minidump_writer/line_reader_unittest.cc index 29686f04..e1ac445a 100644 --- a/src/client/linux/minidump_writer/line_reader_unittest.cc +++ b/src/client/linux/minidump_writer/line_reader_unittest.cc @@ -59,7 +59,7 @@ TEST(LineReaderTest, EmptyFile) { ASSERT_TRUE(file.IsOk()); LineReader reader(file.GetFd()); - const char *line; + const char* line; unsigned len; ASSERT_FALSE(reader.GetNextLine(&line, &len)); } @@ -69,7 +69,7 @@ TEST(LineReaderTest, OneLineTerminated) { ASSERT_TRUE(file.IsOk()); LineReader reader(file.GetFd()); - const char *line; + const char* line; unsigned int len; ASSERT_TRUE(reader.GetNextLine(&line, &len)); ASSERT_EQ((unsigned int)1, len); @@ -85,7 +85,7 @@ TEST(LineReaderTest, OneLine) { ASSERT_TRUE(file.IsOk()); LineReader reader(file.GetFd()); - const char *line; + const char* line; unsigned len; ASSERT_TRUE(reader.GetNextLine(&line, &len)); ASSERT_EQ((unsigned)1, len); @@ -101,7 +101,7 @@ TEST(LineReaderTest, TwoLinesTerminated) { ASSERT_TRUE(file.IsOk()); LineReader reader(file.GetFd()); - const char *line; + const char* line; unsigned len; ASSERT_TRUE(reader.GetNextLine(&line, &len)); ASSERT_EQ((unsigned)1, len); @@ -123,7 +123,7 @@ TEST(LineReaderTest, TwoLines) { ASSERT_TRUE(file.IsOk()); LineReader reader(file.GetFd()); - const char *line; + const char* line; unsigned len; ASSERT_TRUE(reader.GetNextLine(&line, &len)); ASSERT_EQ((unsigned)1, len); @@ -147,7 +147,7 @@ TEST(LineReaderTest, MaxLength) { ASSERT_TRUE(file.IsOk()); LineReader reader(file.GetFd()); - const char *line; + const char* line; unsigned len; ASSERT_TRUE(reader.GetNextLine(&line, &len)); ASSERT_EQ(sizeof(l), len); @@ -163,7 +163,7 @@ TEST(LineReaderTest, TooLong) { ASSERT_TRUE(file.IsOk()); LineReader reader(file.GetFd()); - const char *line; + const char* line; unsigned len; ASSERT_FALSE(reader.GetNextLine(&line, &len)); } diff --git a/src/client/linux/minidump_writer/linux_dumper.cc b/src/client/linux/minidump_writer/linux_dumper.cc index 1112035b..7fd6532a 100644 --- a/src/client/linux/minidump_writer/linux_dumper.cc +++ b/src/client/linux/minidump_writer/linux_dumper.cc @@ -135,7 +135,7 @@ const size_t kHpageMask = (~(kHpageSize - 1)); // next is backed by some file. // curr and next are contiguous. // offset(next) == sizeof(curr) -void TryRecoverMappings(MappingInfo *curr, MappingInfo *next) { +void TryRecoverMappings(MappingInfo* curr, MappingInfo* next) { // Merged segments are marked with size = 0. if (curr->size == 0 || next->size == 0) return; @@ -167,8 +167,8 @@ void TryRecoverMappings(MappingInfo *curr, MappingInfo *next) { // next and prev are backed by the same file. // prev, curr and next are contiguous. // offset(next) == offset(prev) + sizeof(prev) + sizeof(curr) -void TryRecoverMappings(MappingInfo *prev, MappingInfo *curr, - MappingInfo *next) { +void TryRecoverMappings(MappingInfo* prev, MappingInfo* curr, + MappingInfo* next) { // Merged segments are marked with size = 0. if (prev->size == 0 || curr->size == 0 || next->size == 0) return; @@ -551,11 +551,11 @@ bool LinuxDumper::EnumerateMappings() { // See http://www.trilithium.com/johan/2005/08/linux-gate/ for more // information. const void* linux_gate_loc = - reinterpret_cast(auxv_[AT_SYSINFO_EHDR]); + reinterpret_cast(auxv_[AT_SYSINFO_EHDR]); // Although the initial executable is usually the first mapping, it's not // guaranteed (see http://crosbug.com/25355); therefore, try to use the // actual entry point to find the mapping. - const void* entry_point_loc = reinterpret_cast(auxv_[AT_ENTRY]); + const void* entry_point_loc = reinterpret_cast(auxv_[AT_ENTRY]); const int fd = sys_open(maps_path, O_RDONLY, 0); if (fd < 0) diff --git a/src/client/linux/minidump_writer/linux_dumper.h b/src/client/linux/minidump_writer/linux_dumper.h index f4a75d90..7bee160f 100644 --- a/src/client/linux/minidump_writer/linux_dumper.h +++ b/src/client/linux/minidump_writer/linux_dumper.h @@ -110,8 +110,8 @@ class LinuxDumper { } // These are only valid after a call to |Init|. - const wasteful_vector &threads() { return threads_; } - const wasteful_vector &mappings() { return mappings_; } + const wasteful_vector& threads() { return threads_; } + const wasteful_vector& mappings() { return mappings_; } const MappingInfo* FindMapping(const void* address) const; // Find the mapping which the given memory address falls in. Unlike // FindMapping, this method uses the unadjusted mapping address diff --git a/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc b/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc index 3ad48e50..331f4bb3 100644 --- a/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc +++ b/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc @@ -55,8 +55,8 @@ #error This test has not been ported to this platform. #endif -void *thread_function(void *data) { - int pipefd = *static_cast(data); +void* thread_function(void* data) { + int pipefd = *static_cast(data); volatile pid_t* thread_id = new pid_t; *thread_id = syscall(__NR_gettid); // Signal parent that a thread has started. @@ -65,13 +65,13 @@ void *thread_function(void *data) { perror("ERROR: parent notification failed"); return NULL; } - register volatile pid_t *thread_id_ptr asm(TID_PTR_REGISTER) = thread_id; + register volatile pid_t* thread_id_ptr asm(TID_PTR_REGISTER) = thread_id; while (true) asm volatile ("" : : "r" (thread_id_ptr)); return NULL; } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { if (argc < 3) { fprintf(stderr, "usage: linux_dumper_unittest_helper <# of threads>\n"); diff --git a/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc b/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc index ea6b9a12..da71e15d 100644 --- a/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc +++ b/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc @@ -337,7 +337,7 @@ TEST_F(LinuxPtraceDumperChildTest, MappingsIncludeLinuxGate) { ASSERT_TRUE(dumper.Init()); void* linux_gate_loc = - reinterpret_cast(dumper.auxv()[AT_SYSINFO_EHDR]); + reinterpret_cast(dumper.auxv()[AT_SYSINFO_EHDR]); ASSERT_TRUE(linux_gate_loc); bool found_linux_gate = false; diff --git a/src/client/linux/minidump_writer/minidump_writer.cc b/src/client/linux/minidump_writer/minidump_writer.cc index f8cdf2a1..32634ef0 100644 --- a/src/client/linux/minidump_writer/minidump_writer.cc +++ b/src/client/linux/minidump_writer/minidump_writer.cc @@ -740,14 +740,14 @@ class MinidumpWriter { } bool WriteDSODebugStream(MDRawDirectory* dirent) { - ElfW(Phdr)* phdr = reinterpret_cast(dumper_->auxv()[AT_PHDR]); + ElfW(Phdr)* phdr = reinterpret_cast(dumper_->auxv()[AT_PHDR]); char* base; int phnum = dumper_->auxv()[AT_PHNUM]; if (!phnum || !phdr) return false; // Assume the program base is at the beginning of the same page as the PHDR - base = reinterpret_cast(reinterpret_cast(phdr) & ~0xfff); + base = reinterpret_cast(reinterpret_cast(phdr) & ~0xfff); // Search for the program PT_DYNAMIC segment ElfW(Addr) dyn_addr = 0; @@ -768,7 +768,7 @@ class MinidumpWriter { if (!dyn_addr) return false; - ElfW(Dyn) *dynamic = reinterpret_cast(dyn_addr + base); + ElfW(Dyn)* dynamic = reinterpret_cast(dyn_addr + base); // The dynamic linker makes information available that helps gdb find all // DSOs loaded into the program. If this information is indeed available, @@ -1222,7 +1222,7 @@ class MinidumpWriter { Buffers* next; size_t len; uint8_t data[kBufSize]; - } *buffers = reinterpret_cast(Alloc(sizeof(Buffers))); + }* buffers = reinterpret_cast(Alloc(sizeof(Buffers))); buffers->next = NULL; buffers->len = 0; diff --git a/src/client/linux/minidump_writer/minidump_writer_unittest.cc b/src/client/linux/minidump_writer/minidump_writer_unittest.cc index 3017a49a..ac93a343 100644 --- a/src/client/linux/minidump_writer/minidump_writer_unittest.cc +++ b/src/client/linux/minidump_writer/minidump_writer_unittest.cc @@ -299,10 +299,10 @@ TEST(MinidumpWriterTest, MinidumpStacksSkippedIfRequested) { Minidump minidump(templ); ASSERT_TRUE(minidump.Read()); - MinidumpThreadList *threads = minidump.GetThreadList(); + MinidumpThreadList* threads = minidump.GetThreadList(); int threads_with_stacks = 0; for (unsigned int i = 0; i < threads->thread_count(); ++i) { - MinidumpThread *thread = threads->GetThreadAtIndex(i); + MinidumpThread* thread = threads->GetThreadAtIndex(i); if (thread->GetMemory()) { ++threads_with_stacks; } @@ -353,13 +353,13 @@ TEST(MinidumpWriterTest, StacksAreSanitizedIfRequested) { #else 0x0defaced; #endif - MinidumpThreadList *threads = minidump.GetThreadList(); + MinidumpThreadList* threads = minidump.GetThreadList(); for (unsigned int i = 0; i < threads->thread_count(); ++i) { - MinidumpThread *thread = threads->GetThreadAtIndex(i); - MinidumpMemoryRegion *mem = thread->GetMemory(); + MinidumpThread* thread = threads->GetThreadAtIndex(i); + MinidumpMemoryRegion* mem = thread->GetMemory(); ASSERT_TRUE(mem != nullptr); uint32_t sz = mem->GetSize(); - const uint8_t *data = mem->GetMemory(); + const uint8_t* data = mem->GetMemory(); ASSERT_TRUE(memmem(data, sz, &defaced, sizeof(defaced)) != nullptr); } close(fds[1]); diff --git a/src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc b/src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc index 9f46fa65..8e2319e7 100644 --- a/src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc +++ b/src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc @@ -41,7 +41,7 @@ namespace google_breakpad { string GetHelperBinary() { string helper_path; - char *bindir = getenv("bindir"); + char* bindir = getenv("bindir"); if (bindir) { helper_path = string(bindir) + "/"; } else { diff --git a/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc b/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc index 6037c7e6..d9b1203e 100644 --- a/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc +++ b/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc @@ -65,7 +65,7 @@ TEST(ProcCpuInfoReaderTest, EmptyFile) { ASSERT_TRUE(file.IsOk()); ProcCpuInfoReader reader(file.GetFd()); - const char *field; + const char* field; ASSERT_FALSE(reader.GetNextField(&field)); } @@ -74,7 +74,7 @@ TEST(ProcCpuInfoReaderTest, OneLineTerminated) { ASSERT_TRUE(file.IsOk()); ProcCpuInfoReader reader(file.GetFd()); - const char *field; + const char* field; ASSERT_TRUE(reader.GetNextField(&field)); ASSERT_STREQ("foo", field); ASSERT_STREQ("bar", reader.GetValue()); @@ -87,7 +87,7 @@ TEST(ProcCpuInfoReaderTest, OneLine) { ASSERT_TRUE(file.IsOk()); ProcCpuInfoReader reader(file.GetFd()); - const char *field; + const char* field; size_t value_len; ASSERT_TRUE(reader.GetNextField(&field)); ASSERT_STREQ("foo", field); diff --git a/src/client/linux/sender/google_crash_report_sender.cc b/src/client/linux/sender/google_crash_report_sender.cc index f83a0e89..6bf337a8 100644 --- a/src/client/linux/sender/google_crash_report_sender.cc +++ b/src/client/linux/sender/google_crash_report_sender.cc @@ -84,7 +84,7 @@ bool CheckForRequiredFlagsOrDie() { return true; } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { google::InitGoogleLogging(argv[0]); google::ParseCommandLineFlags(&argc, &argv, true); if (!CheckForRequiredFlagsOrDie()) { diff --git a/src/client/mac/Framework/Breakpad.h b/src/client/mac/Framework/Breakpad.h index dc7e45d1..9e191ce2 100644 --- a/src/client/mac/Framework/Breakpad.h +++ b/src/client/mac/Framework/Breakpad.h @@ -45,7 +45,7 @@ // OnDemandServer and restored in Inspector. #define BREAKPAD_BOOTSTRAP_PARENT_PORT "com.Breakpad.BootstrapParent" -typedef void *BreakpadRef; +typedef void* BreakpadRef; #ifdef __cplusplus extern "C" { @@ -65,7 +65,7 @@ extern "C" { typedef bool (*BreakpadFilterCallback)(int exception_type, int exception_code, mach_port_t crashing_thread, - void *context); + void* context); // Create a new BreakpadRef object and install it as an exception // handler. The |parameters| will typically be the contents of your @@ -226,7 +226,7 @@ typedef bool (*BreakpadFilterCallback)(int exception_type, // Only used in crash_report_sender. // Returns a new BreakpadRef object on success, NULL otherwise. -BreakpadRef BreakpadCreate(NSDictionary *parameters); +BreakpadRef BreakpadCreate(NSDictionary* parameters); // Uninstall and release the data associated with |ref|. void BreakpadRelease(BreakpadRef ref); @@ -238,7 +238,7 @@ void BreakpadRelease(BreakpadRef ref); // Context is a pointer to arbitrary data to make the callback with. void BreakpadSetFilterCallback(BreakpadRef ref, BreakpadFilterCallback callback, - void *context); + void* context); // User defined key and value string storage. Generally this is used // to configure Breakpad's internal operation, such as whether the @@ -259,23 +259,23 @@ void BreakpadSetFilterCallback(BreakpadRef ref, // TODO (nealsid): separate server parameter dictionary from the // dictionary used to configure Breakpad, and document limits for each // independently. -void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value); -NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key); -void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key); +void BreakpadSetKeyValue(BreakpadRef ref, NSString* key, NSString* value); +NSString* BreakpadKeyValue(BreakpadRef ref, NSString* key); +void BreakpadRemoveKeyValue(BreakpadRef ref, NSString* key); // You can use this method to specify parameters that will be uploaded // to the crash server. They will be automatically encoded as // necessary. Note that as mentioned above there are limits on both // the number of keys and their length. -void BreakpadAddUploadParameter(BreakpadRef ref, NSString *key, - NSString *value); +void BreakpadAddUploadParameter(BreakpadRef ref, NSString* key, + NSString* value); // This method will remove a previously-added parameter from the // upload parameter set. -void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString *key); +void BreakpadRemoveUploadParameter(BreakpadRef ref, NSString* key); // Add a log file for Breakpad to read and send upon crash dump -void BreakpadAddLogFile(BreakpadRef ref, NSString *logPathname); +void BreakpadAddLogFile(BreakpadRef ref, NSString* logPathname); // Generate a minidump and send void BreakpadGenerateAndSendReport(BreakpadRef ref); diff --git a/src/client/mac/Framework/Breakpad.mm b/src/client/mac/Framework/Breakpad.mm index b2140549..1a46b597 100644 --- a/src/client/mac/Framework/Breakpad.mm +++ b/src/client/mac/Framework/Breakpad.mm @@ -81,9 +81,9 @@ using google_breakpad::SimpleStringDictionary; // allocation of C++ objects. Note that we don't use operator delete() // but instead call the objects destructor directly: object->~ClassName(); // -ProtectedMemoryAllocator *gMasterAllocator = NULL; -ProtectedMemoryAllocator *gKeyValueAllocator = NULL; -ProtectedMemoryAllocator *gBreakpadAllocator = NULL; +ProtectedMemoryAllocator* gMasterAllocator = NULL; +ProtectedMemoryAllocator* gKeyValueAllocator = NULL; +ProtectedMemoryAllocator* gBreakpadAllocator = NULL; // Mutex for thread-safe access to the key/value dictionary used by breakpad. // It's a global instead of an instance variable of Breakpad @@ -98,8 +98,8 @@ pthread_mutex_t gDictionaryMutex; // Its destructor will first re-protect the memory then release the lock. class ProtectedMemoryLocker { public: - ProtectedMemoryLocker(pthread_mutex_t *mutex, - ProtectedMemoryAllocator *allocator) + ProtectedMemoryLocker(pthread_mutex_t* mutex, + ProtectedMemoryAllocator* allocator) : mutex_(mutex), allocator_(allocator) { // Lock the mutex @@ -124,17 +124,17 @@ class ProtectedMemoryLocker { ProtectedMemoryLocker(const ProtectedMemoryLocker&); ProtectedMemoryLocker& operator=(const ProtectedMemoryLocker&); - pthread_mutex_t *mutex_; - ProtectedMemoryAllocator *allocator_; + pthread_mutex_t* mutex_; + ProtectedMemoryAllocator* allocator_; }; //============================================================================= class Breakpad { public: // factory method - static Breakpad *Create(NSDictionary *parameters) { + static Breakpad* Create(NSDictionary* parameters) { // Allocate from our special allocation pool - Breakpad *breakpad = + Breakpad* breakpad = new (gBreakpadAllocator->Allocate(sizeof(Breakpad))) Breakpad(); @@ -152,13 +152,13 @@ class Breakpad { ~Breakpad(); - void SetKeyValue(NSString *key, NSString *value); - NSString *KeyValue(NSString *key); - void RemoveKeyValue(NSString *key); + void SetKeyValue(NSString* key, NSString* value); + NSString* KeyValue(NSString* key); + void RemoveKeyValue(NSString* key); void GenerateAndSendReport(); - void SetFilterCallback(BreakpadFilterCallback callback, void *context) { + void SetFilterCallback(BreakpadFilterCallback callback, void* context) { filter_callback_ = callback; filter_callback_context_ = context; } @@ -173,14 +173,14 @@ class Breakpad { inspector_path_[0] = 0; } - bool Initialize(NSDictionary *parameters); - bool InitializeInProcess(NSDictionary *parameters); - bool InitializeOutOfProcess(NSDictionary *parameters); + bool Initialize(NSDictionary* parameters); + bool InitializeInProcess(NSDictionary* parameters); + bool InitializeOutOfProcess(NSDictionary* parameters); - bool ExtractParameters(NSDictionary *parameters); + bool ExtractParameters(NSDictionary* parameters); // Dispatches to HandleException() - static bool ExceptionHandlerDirectCallback(void *context, + static bool ExceptionHandlerDirectCallback(void* context, int exception_type, int exception_code, int exception_subcode, @@ -194,28 +194,28 @@ class Breakpad { // Dispatches to HandleMinidump(). // This gets called instead of ExceptionHandlerDirectCallback when running // with the BREAKPAD_IN_PROCESS option. - static bool HandleMinidumpCallback(const char *dump_dir, - const char *minidump_id, - void *context, + static bool HandleMinidumpCallback(const char* dump_dir, + const char* minidump_id, + void* context, bool succeeded); // This is only used when BREAKPAD_IN_PROCESS is YES. - bool HandleMinidump(const char *dump_dir, const char *minidump_id); + bool HandleMinidump(const char* dump_dir, const char* minidump_id); // Since ExceptionHandler (w/o namespace) is defined as typedef in OSX's // MachineExceptions.h, we have to explicitly name the handler. - google_breakpad::ExceptionHandler *handler_; // The actual handler (STRONG) + google_breakpad::ExceptionHandler* handler_; // The actual handler (STRONG) char inspector_path_[PATH_MAX]; // Path to inspector tool - SimpleStringDictionary *config_params_; // Create parameters (STRONG) + SimpleStringDictionary* config_params_; // Create parameters (STRONG) OnDemandServer inspector_; bool send_and_exit_; // Exit after sending, if true BreakpadFilterCallback filter_callback_; - void *filter_callback_context_; + void* filter_callback_context_; }; #pragma mark - @@ -227,14 +227,14 @@ class Breakpad { //============================================================================= static BOOL IsDebuggerActive() { BOOL result = NO; - NSUserDefaults *stdDefaults = [NSUserDefaults standardUserDefaults]; + NSUserDefaults* stdDefaults = [NSUserDefaults standardUserDefaults]; // We check both defaults and the environment variable here BOOL ignoreDebugger = [stdDefaults boolForKey:@IGNORE_DEBUGGER]; if (!ignoreDebugger) { - char *ignoreDebuggerStr = getenv(IGNORE_DEBUGGER); + char* ignoreDebuggerStr = getenv(IGNORE_DEBUGGER); ignoreDebugger = (ignoreDebuggerStr ? strtol(ignoreDebuggerStr, NULL, 10) : 0) != 0; } @@ -245,7 +245,7 @@ static BOOL IsDebuggerActive() { size_t actualSize; if (sysctl(mib, mibSize, NULL, &actualSize, NULL, 0) == 0) { - struct kinfo_proc *info = (struct kinfo_proc *)malloc(actualSize); + struct kinfo_proc* info = (struct kinfo_proc*)malloc(actualSize); if (info) { // This comes from looking at the Darwin xnu Kernel @@ -261,12 +261,12 @@ static BOOL IsDebuggerActive() { } //============================================================================= -bool Breakpad::ExceptionHandlerDirectCallback(void *context, - int exception_type, - int exception_code, - int exception_subcode, - mach_port_t crashing_thread) { - Breakpad *breakpad = (Breakpad *)context; +bool Breakpad::ExceptionHandlerDirectCallback(void* context, + int exception_type, + int exception_code, + int exception_subcode, + mach_port_t crashing_thread) { + Breakpad* breakpad = (Breakpad*)context; // If our context is damaged or something, just return false to indicate that // the handler should continue without us. @@ -280,11 +280,11 @@ bool Breakpad::ExceptionHandlerDirectCallback(void *context, } //============================================================================= -bool Breakpad::HandleMinidumpCallback(const char *dump_dir, - const char *minidump_id, - void *context, +bool Breakpad::HandleMinidumpCallback(const char* dump_dir, + const char* minidump_id, + void* context, bool succeeded) { - Breakpad *breakpad = (Breakpad *)context; + Breakpad* breakpad = (Breakpad*)context; // If our context is damaged or something, just return false to indicate that // the handler should continue without us. @@ -307,9 +307,9 @@ bool Breakpad::HandleMinidumpCallback(const char *dump_dir, // simple non-static C name // extern "C" { -NSString * GetResourcePath(); -NSString * GetResourcePath() { - NSString *resourcePath = nil; +NSString* GetResourcePath(); +NSString* GetResourcePath() { + NSString* resourcePath = nil; // If there are multiple breakpads installed then calling bundleWithIdentifier // will not work properly, so only use that as a backup plan. @@ -320,17 +320,17 @@ NSString * GetResourcePath() { // Get the pathname to the code which contains this function Dl_info info; if (dladdr((const void*)GetResourcePath, &info) != 0) { - NSFileManager *filemgr = [NSFileManager defaultManager]; - NSString *filePath = + NSFileManager* filemgr = [NSFileManager defaultManager]; + NSString* filePath = [filemgr stringWithFileSystemRepresentation:info.dli_fname length:strlen(info.dli_fname)]; - NSString *bundlePath = [filePath stringByDeletingLastPathComponent]; + NSString* bundlePath = [filePath stringByDeletingLastPathComponent]; // The "Resources" directory should be in the same directory as the // executable code, since that's how the Breakpad framework is built. resourcePath = [bundlePath stringByAppendingPathComponent:@"Resources/"]; } else { // fallback plan - NSBundle *bundle = + NSBundle* bundle = [NSBundle bundleWithIdentifier:@"com.Google.BreakpadFramework"]; resourcePath = [bundle resourcePath]; } @@ -340,7 +340,7 @@ NSString * GetResourcePath() { } // extern "C" //============================================================================= -bool Breakpad::Initialize(NSDictionary *parameters) { +bool Breakpad::Initialize(NSDictionary* parameters) { // Initialize config_params_ = NULL; handler_ = NULL; @@ -375,7 +375,7 @@ bool Breakpad::InitializeInProcess(NSDictionary* parameters) { //============================================================================= bool Breakpad::InitializeOutOfProcess(NSDictionary* parameters) { // Get path to Inspector executable. - NSString *inspectorPathString = KeyValue(@BREAKPAD_INSPECTOR_LOCATION); + NSString* inspectorPathString = KeyValue(@BREAKPAD_INSPECTOR_LOCATION); // Standardize path (resolve symlinkes, etc.) and escape spaces inspectorPathString = [inspectorPathString stringByStandardizingPath]; @@ -434,34 +434,34 @@ Breakpad::~Breakpad() { } //============================================================================= -bool Breakpad::ExtractParameters(NSDictionary *parameters) { - NSUserDefaults *stdDefaults = [NSUserDefaults standardUserDefaults]; - NSString *skipConfirm = [stdDefaults stringForKey:@BREAKPAD_SKIP_CONFIRM]; - NSString *sendAndExit = [stdDefaults stringForKey:@BREAKPAD_SEND_AND_EXIT]; - - NSString *serverType = [parameters objectForKey:@BREAKPAD_SERVER_TYPE]; - NSString *display = [parameters objectForKey:@BREAKPAD_PRODUCT_DISPLAY]; - NSString *product = [parameters objectForKey:@BREAKPAD_PRODUCT]; - NSString *version = [parameters objectForKey:@BREAKPAD_VERSION]; - NSString *urlStr = [parameters objectForKey:@BREAKPAD_URL]; - NSString *interval = [parameters objectForKey:@BREAKPAD_REPORT_INTERVAL]; - NSString *inspectorPathString = +bool Breakpad::ExtractParameters(NSDictionary* parameters) { + NSUserDefaults* stdDefaults = [NSUserDefaults standardUserDefaults]; + NSString* skipConfirm = [stdDefaults stringForKey:@BREAKPAD_SKIP_CONFIRM]; + NSString* sendAndExit = [stdDefaults stringForKey:@BREAKPAD_SEND_AND_EXIT]; + + NSString* serverType = [parameters objectForKey:@BREAKPAD_SERVER_TYPE]; + NSString* display = [parameters objectForKey:@BREAKPAD_PRODUCT_DISPLAY]; + NSString* product = [parameters objectForKey:@BREAKPAD_PRODUCT]; + NSString* version = [parameters objectForKey:@BREAKPAD_VERSION]; + NSString* urlStr = [parameters objectForKey:@BREAKPAD_URL]; + NSString* interval = [parameters objectForKey:@BREAKPAD_REPORT_INTERVAL]; + NSString* inspectorPathString = [parameters objectForKey:@BREAKPAD_INSPECTOR_LOCATION]; - NSString *reporterPathString = + NSString* reporterPathString = [parameters objectForKey:@BREAKPAD_REPORTER_EXE_LOCATION]; - NSString *timeout = [parameters objectForKey:@BREAKPAD_CONFIRM_TIMEOUT]; - NSArray *logFilePaths = [parameters objectForKey:@BREAKPAD_LOGFILES]; - NSString *logFileTailSize = + NSString* timeout = [parameters objectForKey:@BREAKPAD_CONFIRM_TIMEOUT]; + NSArray* logFilePaths = [parameters objectForKey:@BREAKPAD_LOGFILES]; + NSString* logFileTailSize = [parameters objectForKey:@BREAKPAD_LOGFILE_UPLOAD_SIZE]; - NSString *requestUserText = + NSString* requestUserText = [parameters objectForKey:@BREAKPAD_REQUEST_COMMENTS]; - NSString *requestEmail = [parameters objectForKey:@BREAKPAD_REQUEST_EMAIL]; - NSString *vendor = + NSString* requestEmail = [parameters objectForKey:@BREAKPAD_REQUEST_EMAIL]; + NSString* vendor = [parameters objectForKey:@BREAKPAD_VENDOR]; - NSString *dumpSubdirectory = + NSString* dumpSubdirectory = [parameters objectForKey:@BREAKPAD_DUMP_DIRECTORY]; - NSDictionary *serverParameters = + NSDictionary* serverParameters = [parameters objectForKey:@BREAKPAD_SERVER_PARAMETER_DICT]; // These may have been set above as user prefs, which take priority. @@ -536,7 +536,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) { } // Find the helper applications if not specified in user config. - NSString *resourcePath = nil; + NSString* resourcePath = nil; if (!inspectorPathString || !reporterPathString) { resourcePath = GetResourcePath(); if (!resourcePath) { @@ -591,7 +591,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) { new (gKeyValueAllocator->Allocate(sizeof(SimpleStringDictionary)) ) SimpleStringDictionary(); - SimpleStringDictionary &dictionary = *config_params_; + SimpleStringDictionary& dictionary = *config_params_; dictionary.SetKeyValue(BREAKPAD_SERVER_TYPE, [serverType UTF8String]); dictionary.SetKeyValue(BREAKPAD_PRODUCT_DISPLAY, [display UTF8String]); @@ -633,8 +633,8 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) { if (serverParameters) { // For each key-value pair, call BreakpadAddUploadParameter() - NSEnumerator *keyEnumerator = [serverParameters keyEnumerator]; - NSString *aParameter; + NSEnumerator* keyEnumerator = [serverParameters keyEnumerator]; + NSString* aParameter; while ((aParameter = [keyEnumerator nextObject])) { BreakpadAddUploadParameter(this, aParameter, [serverParameters objectForKey:aParameter]); @@ -644,7 +644,7 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) { } //============================================================================= -void Breakpad::SetKeyValue(NSString *key, NSString *value) { +void Breakpad::SetKeyValue(NSString* key, NSString* value) { // We allow nil values. This is the same as removing the keyvalue. if (!config_params_ || !key) return; @@ -653,16 +653,16 @@ void Breakpad::SetKeyValue(NSString *key, NSString *value) { } //============================================================================= -NSString *Breakpad::KeyValue(NSString *key) { +NSString* Breakpad::KeyValue(NSString* key) { if (!config_params_ || !key) return nil; - const char *value = config_params_->GetValueForKey([key UTF8String]); + const char* value = config_params_->GetValueForKey([key UTF8String]); return value ? [NSString stringWithUTF8String:value] : nil; } //============================================================================= -void Breakpad::RemoveKeyValue(NSString *key) { +void Breakpad::RemoveKeyValue(NSString* key) { if (!config_params_ || !key) return; config_params_->RemoveKey([key UTF8String]); @@ -722,7 +722,7 @@ bool Breakpad::HandleException(int exception_type, if (result == KERN_SUCCESS) { // Now, send a series of key-value pairs to the Inspector. - const SimpleStringDictionary::Entry *entry = NULL; + const SimpleStringDictionary::Entry* entry = NULL; SimpleStringDictionary::Iterator iter(*config_params_); while ( (entry = iter.Next()) ) { @@ -759,7 +759,7 @@ bool Breakpad::HandleException(int exception_type, } //============================================================================= -bool Breakpad::HandleMinidump(const char *dump_dir, const char *minidump_id) { +bool Breakpad::HandleMinidump(const char* dump_dir, const char* minidump_id) { google_breakpad::ConfigFile config_file; config_file.WriteFile(dump_dir, config_params_, dump_dir, minidump_id); google_breakpad::LaunchReporter( @@ -775,7 +775,7 @@ bool Breakpad::HandleMinidump(const char *dump_dir, const char *minidump_id) { #pragma mark Public API //============================================================================= -BreakpadRef BreakpadCreate(NSDictionary *parameters) { +BreakpadRef BreakpadCreate(NSDictionary* parameters) { try { // This is confusing. Our two main allocators for breakpad memory are: // - gKeyValueAllocator for the key/value memory @@ -815,8 +815,8 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) { ProtectedMemoryAllocator(breakpad_pool_size); // Stack-based autorelease pool for Breakpad::Create() obj-c code. - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - Breakpad *breakpad = Breakpad::Create(parameters); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + Breakpad* breakpad = Breakpad::Create(parameters); if (breakpad) { // Make read-only to protect against memory smashers @@ -856,7 +856,7 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) { //============================================================================= void BreakpadRelease(BreakpadRef ref) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (gMasterAllocator) { gMasterAllocator->Unprotect(); @@ -889,10 +889,10 @@ void BreakpadRelease(BreakpadRef ref) { } //============================================================================= -void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value) { +void BreakpadSetKeyValue(BreakpadRef ref, NSString* key, NSString* value) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && key && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); @@ -905,20 +905,20 @@ void BreakpadSetKeyValue(BreakpadRef ref, NSString *key, NSString *value) { } void BreakpadAddUploadParameter(BreakpadRef ref, - NSString *key, - NSString *value) { + NSString* key, + NSString* value) { // The only difference, internally, between an upload parameter and // a key value one that is set with BreakpadSetKeyValue is that we // prepend the keyname with a special prefix. This informs the // crash sender that the parameter should be sent along with the // POST of the crash dump upload. try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && key && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); - NSString *prefixedKey = [@BREAKPAD_SERVER_PARAMETER_PREFIX + NSString* prefixedKey = [@BREAKPAD_SERVER_PARAMETER_PREFIX stringByAppendingString:key]; breakpad->SetKeyValue(prefixedKey, value); } @@ -928,15 +928,15 @@ void BreakpadAddUploadParameter(BreakpadRef ref, } void BreakpadRemoveUploadParameter(BreakpadRef ref, - NSString *key) { + NSString* key) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && key && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); - NSString *prefixedKey = [NSString stringWithFormat:@"%@%@", + NSString* prefixedKey = [NSString stringWithFormat:@"%@%@", @BREAKPAD_SERVER_PARAMETER_PREFIX, key]; breakpad->RemoveKeyValue(prefixedKey); } @@ -945,12 +945,12 @@ void BreakpadRemoveUploadParameter(BreakpadRef ref, } } //============================================================================= -NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key) { - NSString *value = nil; +NSString* BreakpadKeyValue(BreakpadRef ref, NSString* key) { + NSString* value = nil; try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (!breakpad || !key || !gKeyValueAllocator) return nil; @@ -966,10 +966,10 @@ NSString *BreakpadKeyValue(BreakpadRef ref, NSString *key) { } //============================================================================= -void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) { +void BreakpadRemoveKeyValue(BreakpadRef ref, NSString* key) { try { // Not called at exception time - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && key && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); @@ -984,7 +984,7 @@ void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) { //============================================================================= void BreakpadGenerateAndSendReport(BreakpadRef ref) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && gKeyValueAllocator) { ProtectedMemoryLocker locker(&gDictionaryMutex, gKeyValueAllocator); @@ -1001,10 +1001,10 @@ void BreakpadGenerateAndSendReport(BreakpadRef ref) { //============================================================================= void BreakpadSetFilterCallback(BreakpadRef ref, BreakpadFilterCallback callback, - void *context) { + void* context) { try { - Breakpad *breakpad = (Breakpad *)ref; + Breakpad* breakpad = (Breakpad*)ref; if (breakpad && gBreakpadAllocator) { // share the dictionary mutex here (we really don't need a mutex) @@ -1018,14 +1018,14 @@ void BreakpadSetFilterCallback(BreakpadRef ref, } //============================================================================ -void BreakpadAddLogFile(BreakpadRef ref, NSString *logPathname) { +void BreakpadAddLogFile(BreakpadRef ref, NSString* logPathname) { int logFileCounter = 0; - NSString *logFileKey = [NSString stringWithFormat:@"%@%d", + NSString* logFileKey = [NSString stringWithFormat:@"%@%d", @BREAKPAD_LOGFILE_KEY_PREFIX, logFileCounter]; - NSString *existingLogFilename = nil; + NSString* existingLogFilename = nil; existingLogFilename = BreakpadKeyValue(ref, logFileKey); // Find the first log file key that we can use by testing for existence while (existingLogFilename) { diff --git a/src/client/mac/Framework/OnDemandServer.h b/src/client/mac/Framework/OnDemandServer.h index d4db5d3a..be0d2b79 100644 --- a/src/client/mac/Framework/OnDemandServer.h +++ b/src/client/mac/Framework/OnDemandServer.h @@ -41,7 +41,7 @@ // Example Usage : // // kern_return_t result; -// OnDemandServer *server = OnDemandServer::Create("/tmp/myserver", +// OnDemandServer* server = OnDemandServer::Create("/tmp/myserver", // "com.MyCompany.MyServiceName", // true, // &result); @@ -88,8 +88,8 @@ class OnDemandServer { } // Creates the bootstrap server and service - kern_return_t Initialize(const char *server_command, - const char *service_name, + kern_return_t Initialize(const char* server_command, + const char* service_name, bool unregister_on_cleanup); // Returns an OnDemandServer object if successful, or NULL if there's @@ -110,10 +110,10 @@ class OnDemandServer { // out_result : if non-NULL, returns the result // this value will be KERN_SUCCESS if Create() returns non-NULL // - static OnDemandServer *Create(const char *server_command, - const char *service_name, + static OnDemandServer* Create(const char *server_command, + const char* service_name, bool unregister_on_cleanup, - kern_return_t *out_result); + kern_return_t* out_result); // Cleans up and if LaunchOnDemand() has not yet been called then // the bootstrap service will be unregistered. diff --git a/src/client/mac/Framework/OnDemandServer.mm b/src/client/mac/Framework/OnDemandServer.mm index a2ffa434..b6b59ca5 100644 --- a/src/client/mac/Framework/OnDemandServer.mm +++ b/src/client/mac/Framework/OnDemandServer.mm @@ -49,11 +49,11 @@ #endif //============================================================================== -OnDemandServer *OnDemandServer::Create(const char *server_command, - const char *service_name, +OnDemandServer* OnDemandServer::Create(const char* server_command, + const char* service_name, bool unregister_on_cleanup, - kern_return_t *out_result) { - OnDemandServer *server = new OnDemandServer(); + kern_return_t* out_result) { + OnDemandServer* server = new OnDemandServer(); if (!server) return NULL; @@ -74,8 +74,8 @@ OnDemandServer *OnDemandServer::Create(const char *server_command, } //============================================================================== -kern_return_t OnDemandServer::Initialize(const char *server_command, - const char *service_name, +kern_return_t OnDemandServer::Initialize(const char* server_command, + const char* service_name, bool unregister_on_cleanup) { unregister_on_cleanup_ = unregister_on_cleanup; diff --git a/src/client/mac/crash_generation/ConfigFile.h b/src/client/mac/crash_generation/ConfigFile.h index f2da7c24..11bc2e43 100644 --- a/src/client/mac/crash_generation/ConfigFile.h +++ b/src/client/mac/crash_generation/ConfigFile.h @@ -35,7 +35,7 @@ namespace google_breakpad { -BOOL EnsureDirectoryPathExists(NSString *dirPath); +BOOL EnsureDirectoryPathExists(NSString* dirPath); //============================================================================= class ConfigFile { @@ -50,11 +50,11 @@ class ConfigFile { } void WriteFile(const char* directory, - const SimpleStringDictionary *configurationParameters, - const char *dump_dir, - const char *minidump_id); + const SimpleStringDictionary* configurationParameters, + const char* dump_dir, + const char* minidump_id); - const char *GetFilePath() { return config_file_path_; } + const char* GetFilePath() { return config_file_path_; } void Unlink() { if (config_file_ != -1) @@ -64,16 +64,16 @@ class ConfigFile { } private: - BOOL WriteData(const void *data, size_t length); + BOOL WriteData(const void* data, size_t length); - BOOL AppendConfigData(const char *key, - const void *data, + BOOL AppendConfigData(const char* key, + const void* data, size_t length); - BOOL AppendConfigString(const char *key, - const char *value); + BOOL AppendConfigString(const char* key, + const char* value); - BOOL AppendCrashTimeParameters(const char *processStartTimeString); + BOOL AppendCrashTimeParameters(const char* processStartTimeString); int config_file_; // descriptor for config file char config_file_path_[PATH_MAX]; // Path to configuration file diff --git a/src/client/mac/crash_generation/ConfigFile.mm b/src/client/mac/crash_generation/ConfigFile.mm index acab7de8..57d07590 100644 --- a/src/client/mac/crash_generation/ConfigFile.mm +++ b/src/client/mac/crash_generation/ConfigFile.mm @@ -42,10 +42,10 @@ namespace google_breakpad { //============================================================================= -BOOL EnsureDirectoryPathExists(NSString *dirPath) { - NSFileManager *mgr = [NSFileManager defaultManager]; +BOOL EnsureDirectoryPathExists(NSString* dirPath) { + NSFileManager* mgr = [NSFileManager defaultManager]; - NSDictionary *attrs = + NSDictionary* attrs = [NSDictionary dictionaryWithObject:[NSNumber numberWithUnsignedLong:0750] forKey:NSFilePosixPermissions]; @@ -56,15 +56,15 @@ BOOL EnsureDirectoryPathExists(NSString *dirPath) { } //============================================================================= -BOOL ConfigFile::WriteData(const void *data, size_t length) { +BOOL ConfigFile::WriteData(const void* data, size_t length) { size_t result = write(config_file_, data, length); return result == length; } //============================================================================= -BOOL ConfigFile::AppendConfigData(const char *key, - const void *data, size_t length) { +BOOL ConfigFile::AppendConfigData(const char* key, + const void* data, size_t length) { assert(config_file_ != -1); if (!key) { @@ -88,13 +88,13 @@ BOOL ConfigFile::AppendConfigData(const char *key, } //============================================================================= -BOOL ConfigFile::AppendConfigString(const char *key, - const char *value) { +BOOL ConfigFile::AppendConfigString(const char* key, + const char* value) { return AppendConfigData(key, value, strlen(value)); } //============================================================================= -BOOL ConfigFile::AppendCrashTimeParameters(const char *processStartTimeString) { +BOOL ConfigFile::AppendCrashTimeParameters(const char* processStartTimeString) { // Set process uptime parameter struct timeval tv; gettimeofday(&tv, NULL); @@ -118,9 +118,9 @@ BOOL ConfigFile::AppendCrashTimeParameters(const char *processStartTimeString) { //============================================================================= void ConfigFile::WriteFile(const char* directory, - const SimpleStringDictionary *configurationParameters, - const char *dump_dir, - const char *minidump_id) { + const SimpleStringDictionary* configurationParameters, + const char* dump_dir, + const char* minidump_id) { assert(config_file_ == -1); @@ -146,9 +146,9 @@ void ConfigFile::WriteFile(const char* directory, // Write out the configuration parameters BOOL result = YES; - const SimpleStringDictionary &dictionary = *configurationParameters; + const SimpleStringDictionary& dictionary = *configurationParameters; - const SimpleStringDictionary::Entry *entry = NULL; + const SimpleStringDictionary::Entry* entry = NULL; SimpleStringDictionary::Iterator iter(dictionary); while ((entry = iter.Next())) { diff --git a/src/client/mac/crash_generation/Inspector.h b/src/client/mac/crash_generation/Inspector.h index 7f923ed6..c9671136 100644 --- a/src/client/mac/crash_generation/Inspector.h +++ b/src/client/mac/crash_generation/Inspector.h @@ -63,7 +63,7 @@ struct KeyValueMessageData { public: KeyValueMessageData() {} explicit KeyValueMessageData( - const google_breakpad::SimpleStringDictionary::Entry &inEntry) { + const google_breakpad::SimpleStringDictionary::Entry& inEntry) { strlcpy(key, inEntry.key, sizeof(key) ); strlcpy(value, inEntry.value, sizeof(value) ); } @@ -80,7 +80,7 @@ namespace google_breakpad { //============================================================================= class MinidumpLocation { public: - MinidumpLocation(NSString *minidumpDir) { + MinidumpLocation(NSString* minidumpDir) { // Ensure that the path exists. Fallback to /tmp if unable to locate path. assert(minidumpDir); if (!EnsureDirectoryPathExists(minidumpDir)) { @@ -100,8 +100,8 @@ class MinidumpLocation { strlcpy(minidump_id_, next_minidump_id.c_str(), sizeof(minidump_id_)); } - const char *GetPath() { return minidump_dir_path_; } - const char *GetID() { return minidump_id_; } + const char* GetPath() { return minidump_dir_path_; } + const char* GetID() { return minidump_id_; } private: char minidump_dir_path_[PATH_MAX]; // Path to minidump directory @@ -116,7 +116,7 @@ class Inspector { // given a bootstrap service name, receives mach messages // from a crashed process, then inspects it, creates a minidump file // and asks the user if he wants to upload it to a server. - void Inspect(const char *receive_port_name); + void Inspect(const char* receive_port_name); private: // The Inspector is invoked with its bootstrap port set to the bootstrap @@ -131,8 +131,8 @@ class Inspector { // ServiceCheckOut. kern_return_t ResetBootstrapPort(); - kern_return_t ServiceCheckIn(const char *receive_port_name); - kern_return_t ServiceCheckOut(const char *receive_port_name); + kern_return_t ServiceCheckIn(const char* receive_port_name); + kern_return_t ServiceCheckOut(const char* receive_port_name); kern_return_t ReadMessages(); diff --git a/src/client/mac/crash_generation/Inspector.mm b/src/client/mac/crash_generation/Inspector.mm index dc6f4808..d5fc29e0 100644 --- a/src/client/mac/crash_generation/Inspector.mm +++ b/src/client/mac/crash_generation/Inspector.mm @@ -52,7 +52,7 @@ namespace google_breakpad { //============================================================================= -void Inspector::Inspect(const char *receive_port_name) { +void Inspector::Inspect(const char* receive_port_name) { kern_return_t result = ResetBootstrapPort(); if (result != KERN_SUCCESS) { return; @@ -143,7 +143,7 @@ kern_return_t Inspector::ResetBootstrapPort() { } //============================================================================= -kern_return_t Inspector::ServiceCheckIn(const char *receive_port_name) { +kern_return_t Inspector::ServiceCheckIn(const char* receive_port_name) { // We need to get the mach port representing this service, so we can // get information from the crashed process. kern_return_t kr = bootstrap_check_in(bootstrap_subset_port_, @@ -160,7 +160,7 @@ kern_return_t Inspector::ServiceCheckIn(const char *receive_port_name) { } //============================================================================= -kern_return_t Inspector::ServiceCheckOut(const char *receive_port_name) { +kern_return_t Inspector::ServiceCheckOut(const char* receive_port_name) { // We're done receiving mach messages from the crashed process, // so clean up a bit. kern_return_t kr; @@ -198,7 +198,7 @@ kern_return_t Inspector::ReadMessages() { kern_return_t result = receive_port.WaitForMessage(&message, 1000); if (result == KERN_SUCCESS) { - InspectorInfo &info = (InspectorInfo &)*message.GetData(); + InspectorInfo& info = (InspectorInfo&)*message.GetData(); exception_type_ = info.exception_type; exception_code_ = info.exception_code; exception_subcode_ = info.exception_subcode; @@ -237,7 +237,7 @@ kern_return_t Inspector::ReadMessages() { result = receive_port.WaitForMessage(¶meter_message, 1000); if(result == KERN_SUCCESS) { - KeyValueMessageData &key_value_data = + KeyValueMessageData& key_value_data = (KeyValueMessageData&)*parameter_message.GetData(); // If we get a blank key, make sure we don't increment the // parameter count; in some cases (notably on-demand generation @@ -267,27 +267,27 @@ bool Inspector::InspectTask() { // keep the task quiet while we're looking at it task_suspend(remote_task_); - NSString *minidumpDir; + NSString* minidumpDir; - const char *minidumpDirectory = + const char* minidumpDirectory = config_params_.GetValueForKey(BREAKPAD_DUMP_DIRECTORY); // If the client app has not specified a minidump directory, // use a default of Library// if (!minidumpDirectory || 0 == strlen(minidumpDirectory)) { - NSArray *libraryDirectories = + NSArray* libraryDirectories = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); - NSString *applicationSupportDirectory = + NSString* applicationSupportDirectory = [libraryDirectories objectAtIndex:0]; - NSString *library_subdirectory = [NSString + NSString* library_subdirectory = [NSString stringWithUTF8String:kDefaultLibrarySubdirectory]; - NSString *breakpad_product = [NSString + NSString* breakpad_product = [NSString stringWithUTF8String:config_params_.GetValueForKey(BREAKPAD_PRODUCT)]; - NSArray *path_components = [NSArray + NSArray* path_components = [NSArray arrayWithObjects:applicationSupportDirectory, library_subdirectory, breakpad_product, @@ -306,11 +306,11 @@ bool Inspector::InspectTask() { // assumes system encoding and in RTL locales will prepend an LTR override // character for paths beginning with '/' which fileSystemRepresentation does // not remove. Filed as rdar://6889706 . - NSString *path_ns = [NSString + NSString* path_ns = [NSString stringWithUTF8String:minidumpLocation.GetPath()]; - NSString *pathid_ns = [NSString + NSString* pathid_ns = [NSString stringWithUTF8String:minidumpLocation.GetID()]; - NSString *minidumpPath = [path_ns stringByAppendingPathComponent:pathid_ns]; + NSString* minidumpPath = [path_ns stringByAppendingPathComponent:pathid_ns]; minidumpPath = [minidumpPath stringByAppendingPathExtension:@"dmp"]; diff --git a/src/client/mac/crash_generation/crash_generation_server.cc b/src/client/mac/crash_generation/crash_generation_server.cc index 451e8d9c..ae44e8bf 100644 --- a/src/client/mac/crash_generation/crash_generation_server.cc +++ b/src/client/mac/crash_generation/crash_generation_server.cc @@ -38,15 +38,15 @@ namespace google_breakpad { CrashGenerationServer::CrashGenerationServer( - const char *mach_port_name, + const char* mach_port_name, FilterCallback filter, - void *filter_context, + void* filter_context, OnClientDumpRequestCallback dump_callback, - void *dump_context, + void* dump_context, OnClientExitingCallback exit_callback, - void *exit_context, + void* exit_context, bool generate_dumps, - const std::string &dump_path) + const std::string& dump_path) : filter_(filter), filter_context_(filter_context), dump_callback_(dump_callback), @@ -90,8 +90,8 @@ bool CrashGenerationServer::Stop() { } // static -void *CrashGenerationServer::WaitForMessages(void *server) { - CrashGenerationServer *self = +void* CrashGenerationServer::WaitForMessages(void* server) { + CrashGenerationServer* self = reinterpret_cast(server); while (self->WaitForOneMessage()) {} return NULL; @@ -104,7 +104,7 @@ bool CrashGenerationServer::WaitForOneMessage() { if (result == KERN_SUCCESS) { switch (message.GetMessageID()) { case kDumpRequestMessage: { - ExceptionInfo &info = (ExceptionInfo &)*message.GetData(); + ExceptionInfo& info = (ExceptionInfo&)*message.GetData(); mach_port_t remote_task = message.GetTranslatedPort(0); mach_port_t crashing_thread = message.GetTranslatedPort(1); diff --git a/src/client/mac/crash_generation/crash_generation_server.h b/src/client/mac/crash_generation/crash_generation_server.h index 85bd5b5e..82fef146 100644 --- a/src/client/mac/crash_generation/crash_generation_server.h +++ b/src/client/mac/crash_generation/crash_generation_server.h @@ -59,14 +59,14 @@ class CrashGenerationServer { // WARNING: callbacks may be invoked on a different thread // than that which creates the CrashGenerationServer. They must // be thread safe. - typedef void (*OnClientDumpRequestCallback)(void *context, - const ClientInfo &client_info, - const std::string &file_path); + typedef void (*OnClientDumpRequestCallback)(void* context, + const ClientInfo& client_info, + const std::string& file_path); - typedef void (*OnClientExitingCallback)(void *context, - const ClientInfo &client_info); + typedef void (*OnClientExitingCallback)(void* context, + const ClientInfo& client_info); // If a FilterCallback returns false, the dump will not be written. - typedef bool (*FilterCallback)(void *context); + typedef bool (*FilterCallback)(void* context); // Create an instance with the given parameters. // @@ -83,15 +83,15 @@ class CrashGenerationServer { // passed for this parameter. // dump_path: Path for generating dumps; required only if true is // passed for generateDumps parameter; NULL can be passed otherwise. - CrashGenerationServer(const char *mach_port_name, + CrashGenerationServer(const char* mach_port_name, FilterCallback filter, - void *filter_context, + void* filter_context, OnClientDumpRequestCallback dump_callback, - void *dump_context, + void* dump_context, OnClientExitingCallback exit_callback, - void *exit_context, + void* exit_context, bool generate_dumps, - const std::string &dump_path); + const std::string& dump_path); ~CrashGenerationServer(); @@ -105,24 +105,24 @@ class CrashGenerationServer { private: // Return a unique filename at which a minidump can be written. - bool MakeMinidumpFilename(std::string &outFilename); + bool MakeMinidumpFilename(std::string& outFilename); // Loop reading client messages and responding to them until // a quit message is received. - static void *WaitForMessages(void *server); + static void* WaitForMessages(void* server); // Wait for a single client message and respond to it. Returns false // if a quit message was received or if an error occurred. bool WaitForOneMessage(); FilterCallback filter_; - void *filter_context_; + void* filter_context_; OnClientDumpRequestCallback dump_callback_; - void *dump_context_; + void* dump_context_; OnClientExitingCallback exit_callback_; - void *exit_context_; + void* exit_context_; bool generate_dumps_; diff --git a/src/client/mac/handler/breakpad_nlist_64.cc b/src/client/mac/handler/breakpad_nlist_64.cc index 3492b823..b4f04c91 100644 --- a/src/client/mac/handler/breakpad_nlist_64.cc +++ b/src/client/mac/handler/breakpad_nlist_64.cc @@ -131,7 +131,7 @@ struct MachBits { template int -__breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, +__breakpad_fdnlist(int fd, nlist_type* list, const char** symbolNames, cpu_type_t cpu_type); /* @@ -139,9 +139,9 @@ __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, */ template -int breakpad_nlist_common(const char *name, - nlist_type *list, - const char **symbolNames, +int breakpad_nlist_common(const char* name, + nlist_type* list, + const char** symbolNames, cpu_type_t cpu_type) { int fd = open(name, O_RDONLY, 0); if (fd < 0) @@ -151,16 +151,16 @@ int breakpad_nlist_common(const char *name, return n; } -int breakpad_nlist(const char *name, - struct nlist *list, - const char **symbolNames, +int breakpad_nlist(const char* name, + struct nlist* list, + const char** symbolNames, cpu_type_t cpu_type) { return breakpad_nlist_common(name, list, symbolNames, cpu_type); } -int breakpad_nlist(const char *name, - struct nlist_64 *list, - const char **symbolNames, +int breakpad_nlist(const char* name, + struct nlist_64* list, + const char** symbolNames, cpu_type_t cpu_type) { return breakpad_nlist_common(name, list, symbolNames, cpu_type); } @@ -168,7 +168,7 @@ int breakpad_nlist(const char *name, /* Note: __fdnlist() is called from kvm_nlist in libkvm's kvm.c */ template -int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, +int __breakpad_fdnlist(int fd, nlist_type* list, const char** symbolNames, cpu_type_t cpu_type) { typedef typename MachBits::mach_header_type mach_header_type; typedef typename MachBits::word_type word_type; @@ -189,9 +189,9 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, } struct exec buf; - if (read(fd, (char *)&buf, sizeof(buf)) != sizeof(buf) || - (N_BADMAG(buf) && *((uint32_t *)&buf) != magic && - CFSwapInt32BigToHost(*((uint32_t *)&buf)) != FAT_MAGIC && + if (read(fd, (char*)&buf, sizeof(buf)) != sizeof(buf) || + (N_BADMAG(buf) && *((uint32_t*)&buf) != magic && + CFSwapInt32BigToHost(*((uint32_t*)&buf)) != FAT_MAGIC && /* The following is the big-endian ppc64 check */ (*((uint32_t*)&buf)) != FAT_MAGIC)) { return -1; @@ -199,15 +199,15 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, /* Deal with fat file if necessary */ unsigned arch_offset = 0; - if (CFSwapInt32BigToHost(*((uint32_t *)&buf)) == FAT_MAGIC || + if (CFSwapInt32BigToHost(*((uint32_t*)&buf)) == FAT_MAGIC || /* The following is the big-endian ppc64 check */ - *((unsigned int *)&buf) == FAT_MAGIC) { + *((unsigned int*)&buf) == FAT_MAGIC) { /* Read in the fat header */ struct fat_header fh; if (lseek(fd, 0, SEEK_SET) == -1) { return -1; } - if (read(fd, (char *)&fh, sizeof(fh)) != sizeof(fh)) { + if (read(fd, (char*)&fh, sizeof(fh)) != sizeof(fh)) { return -1; } @@ -215,12 +215,12 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, fh.nfat_arch = CFSwapInt32BigToHost(fh.nfat_arch); /* Read in the fat archs */ - struct fat_arch *fat_archs = - (struct fat_arch *)malloc(fh.nfat_arch * sizeof(struct fat_arch)); + struct fat_arch* fat_archs = + (struct fat_arch*)malloc(fh.nfat_arch * sizeof(struct fat_arch)); if (fat_archs == NULL) { return -1; } - if (read(fd, (char *)fat_archs, + if (read(fd, (char*)fat_archs, sizeof(struct fat_arch) * fh.nfat_arch) != (ssize_t)(sizeof(struct fat_arch) * fh.nfat_arch)) { free(fat_archs); @@ -244,7 +244,7 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, CFSwapInt32BigToHost(fat_archs[i].align); } - struct fat_arch *fap = NULL; + struct fat_arch* fap = NULL; for (unsigned i = 0; i < fh.nfat_arch; i++) { if (fat_archs[i].cputype == cpu_type) { fap = &fat_archs[i]; @@ -263,7 +263,7 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, if (lseek(fd, arch_offset, SEEK_SET) == -1) { return -1; } - if (read(fd, (char *)&buf, sizeof(buf)) != sizeof(buf)) { + if (read(fd, (char*)&buf, sizeof(buf)) != sizeof(buf)) { return -1; } } @@ -271,48 +271,45 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, off_t sa; /* symbol address */ off_t ss; /* start of strings */ register_t n; - if (*((unsigned int *)&buf) == magic) { + if (*((unsigned int*)&buf) == magic) { if (lseek(fd, arch_offset, SEEK_SET) == -1) { return -1; } mach_header_type mh; - if (read(fd, (char *)&mh, sizeof(mh)) != sizeof(mh)) { + if (read(fd, (char*)&mh, sizeof(mh)) != sizeof(mh)) { return -1; } - struct load_command *load_commands = - (struct load_command *)malloc(mh.sizeofcmds); + struct load_command* load_commands = + (struct load_command*)malloc(mh.sizeofcmds); if (load_commands == NULL) { return -1; } - if (read(fd, (char *)load_commands, mh.sizeofcmds) != + if (read(fd, (char*)load_commands, mh.sizeofcmds) != (ssize_t)mh.sizeofcmds) { free(load_commands); return -1; } - struct symtab_command *stp = NULL; - struct load_command *lcp = load_commands; + struct symtab_command* stp = NULL; + struct load_command* lcp = load_commands; // iterate through all load commands, looking for // LC_SYMTAB load command for (uint32_t i = 0; i < mh.ncmds; i++) { if (lcp->cmdsize % sizeof(word_type) != 0 || lcp->cmdsize <= 0 || - (char *)lcp + lcp->cmdsize > - (char *)load_commands + mh.sizeofcmds) { + (char*)lcp + lcp->cmdsize > (char*)load_commands + mh.sizeofcmds) { free(load_commands); return -1; } if (lcp->cmd == LC_SYMTAB) { - if (lcp->cmdsize != - sizeof(struct symtab_command)) { + if (lcp->cmdsize != sizeof(struct symtab_command)) { free(load_commands); return -1; } - stp = (struct symtab_command *)lcp; + stp = (struct symtab_command*)lcp; break; } - lcp = (struct load_command *) - ((char *)lcp + lcp->cmdsize); + lcp = (struct load_command*)((char*)lcp + lcp->cmdsize); } if (stp == NULL) { free(load_commands); @@ -347,7 +344,7 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, if (n < m) m = n; - if (read(fd, (char *)space, m) != m) + if (read(fd, (char*)space, m) != m) break; n -= m; off_t savpos = lseek(fd, 0, SEEK_CUR); @@ -368,13 +365,13 @@ int __breakpad_fdnlist(int fd, nlist_type *list, const char **symbolNames, if (read(fd, nambuf, maxlen+1) == -1) { return -1; } - const char *s2 = nambuf; - for (nlist_type *p = list; + const char* s2 = nambuf; + for (nlist_type* p = list; symbolNames[p-list] && symbolNames[p-list][0]; p++) { // get the symbol name the user has passed in that // corresponds to the nlist entry that we're looking at - const char *s1 = symbolNames[p - list]; + const char* s1 = symbolNames[p - list]; while (*s1) { if (*s1++ != *s2++) goto cont; diff --git a/src/client/mac/handler/breakpad_nlist_64.h b/src/client/mac/handler/breakpad_nlist_64.h index e8e2e083..a1a3e83c 100644 --- a/src/client/mac/handler/breakpad_nlist_64.h +++ b/src/client/mac/handler/breakpad_nlist_64.h @@ -36,13 +36,13 @@ #include -int breakpad_nlist(const char *name, - struct nlist *list, - const char **symbolNames, +int breakpad_nlist(const char* name, + struct nlist* list, + const char** symbolNames, cpu_type_t cpu_type); -int breakpad_nlist(const char *name, - struct nlist_64 *list, - const char **symbolNames, +int breakpad_nlist(const char* name, + struct nlist_64* list, + const char** symbolNames, cpu_type_t cpu_type); #endif /* CLIENT_MAC_HANDLER_BREAKPAD_NLIST_H__ */ diff --git a/src/client/mac/handler/dynamic_images.cc b/src/client/mac/handler/dynamic_images.cc index cdba6df4..b78c2087 100644 --- a/src/client/mac/handler/dynamic_images.cc +++ b/src/client/mac/handler/dynamic_images.cc @@ -66,7 +66,7 @@ struct task_dyld_info { mach_vm_size_t all_image_info_size; }; typedef struct task_dyld_info task_dyld_info_data_t; -typedef struct task_dyld_info *task_dyld_info_t; +typedef struct task_dyld_info* task_dyld_info_t; #define TASK_DYLD_INFO_COUNT (sizeof(task_dyld_info_data_t) / sizeof(natural_t)) #endif @@ -88,7 +88,7 @@ using std::vector; // static mach_vm_size_t GetMemoryRegionSize(task_port_t target_task, const uint64_t address, - mach_vm_size_t *size_to_end) { + mach_vm_size_t* size_to_end) { mach_vm_address_t region_base = (mach_vm_address_t)address; mach_vm_size_t region_size; natural_t nesting_level = 0; @@ -182,7 +182,7 @@ static string ReadTaskString(task_port_t target_task, kern_return_t ReadTaskMemory(task_port_t target_task, const uint64_t address, size_t length, - vector &bytes) { + vector& bytes) { int systemPageSize = getpagesize(); // use the negative of the page size for the mask to find the page address @@ -250,16 +250,16 @@ bool FindTextSection(DynamicImage& image) { return false; } - const struct load_command *cmd = - reinterpret_cast(header + 1); + const struct load_command* cmd = + reinterpret_cast(header + 1); bool found_text_section = false; bool found_dylib_id_command = false; for (unsigned int i = 0; cmd && (i < header->ncmds); ++i) { if (!found_text_section) { if (cmd->cmd == MachBits::segment_load_command) { - const mach_segment_command_type *seg = - reinterpret_cast(cmd); + const mach_segment_command_type* seg = + reinterpret_cast(cmd); if (!strcmp(seg->segname, "__TEXT")) { image.vmaddr_ = static_cast(seg->vmaddr); @@ -277,8 +277,8 @@ bool FindTextSection(DynamicImage& image) { if (!found_dylib_id_command) { if (cmd->cmd == LC_ID_DYLIB) { - const struct dylib_command *dc = - reinterpret_cast(cmd); + const struct dylib_command* dc = + reinterpret_cast(cmd); image.version_ = dc->dylib.current_version; found_dylib_id_command = true; @@ -289,8 +289,8 @@ bool FindTextSection(DynamicImage& image) { return true; } - cmd = reinterpret_cast - (reinterpret_cast(cmd) + cmd->cmdsize); + cmd = reinterpret_cast + (reinterpret_cast(cmd) + cmd->cmdsize); } return false; @@ -349,8 +349,8 @@ static uint64_t LookupSymbol(const char* symbol_name, typedef typename MachBits::nlist_type nlist_type; nlist_type symbol_info[8] = {}; - const char *symbolNames[2] = { symbol_name, "\0" }; - nlist_type &list = symbol_info[0]; + const char* symbolNames[2] = { symbol_name, "\0" }; + nlist_type& list = symbol_info[0]; int invalidEntriesCount = breakpad_nlist(filename, &list, symbolNames, @@ -396,8 +396,8 @@ uint64_t DynamicImages::GetDyldAllImageInfosPointer() { return (uint64_t)task_dyld_info.all_image_info_addr; } else { - const char *imageSymbolName = "_dyld_all_image_infos"; - const char *dyldPath = "/usr/lib/dyld"; + const char* imageSymbolName = "_dyld_all_image_infos"; + const char* dyldPath = "/usr/lib/dyld"; if (Is64Bit()) return LookupSymbol(imageSymbolName, dyldPath, cpu_type_); @@ -428,7 +428,7 @@ void ReadImageInfo(DynamicImages& images, dyld_all_info_bytes) != KERN_SUCCESS) return; - dyld_all_image_infos *dyldInfo = + dyld_all_image_infos* dyldInfo = reinterpret_cast(&dyld_all_info_bytes[0]); // number of loaded images @@ -443,12 +443,12 @@ void ReadImageInfo(DynamicImages& images, dyld_info_array_bytes) != KERN_SUCCESS) return; - dyld_image_info *infoArray = + dyld_image_info* infoArray = reinterpret_cast(&dyld_info_array_bytes[0]); images.image_list_.reserve(count); for (int i = 0; i < count; ++i) { - dyld_image_info &info = infoArray[i]; + dyld_image_info& info = infoArray[i]; // First read just the mach_header from the image in the task. vector mach_header_bytes; @@ -458,7 +458,7 @@ void ReadImageInfo(DynamicImages& images, mach_header_bytes) != KERN_SUCCESS) continue; // bail on this dynamic image - mach_header_type *header = + mach_header_type* header = reinterpret_cast(&mach_header_bytes[0]); // Now determine the total amount necessary to read the header @@ -482,7 +482,7 @@ void ReadImageInfo(DynamicImages& images, } // Create an object representing this image and add it to our list. - DynamicImage *new_image; + DynamicImage* new_image; new_image = new DynamicImage(&mach_header_bytes[0], header_size, info.load_address_, @@ -522,7 +522,7 @@ void DynamicImages::ReadImageInfoForTask() { } //============================================================================== -DynamicImage *DynamicImages::GetExecutableImage() { +DynamicImage* DynamicImages::GetExecutableImage() { int executable_index = GetExecutableImageIndex(); if (executable_index >= 0) { @@ -538,7 +538,7 @@ int DynamicImages::GetExecutableImageIndex() { int image_count = GetImageCount(); for (int i = 0; i < image_count; ++i) { - DynamicImage *image = GetImage(i); + DynamicImage* image = GetImage(i); if (image->GetFileType() == MH_EXECUTE) { return i; } diff --git a/src/client/mac/handler/dynamic_images.h b/src/client/mac/handler/dynamic_images.h index 65147900..e81ea7f3 100644 --- a/src/client/mac/handler/dynamic_images.h +++ b/src/client/mac/handler/dynamic_images.h @@ -108,7 +108,7 @@ uint32_t GetFileTypeFromHeader(DynamicImage& image); // Represents a single dynamically loaded mach-o image class DynamicImage { public: - DynamicImage(uint8_t *header, // data is copied + DynamicImage(uint8_t* header, // data is copied size_t header_size, // includes load commands uint64_t load_address, string file_path, @@ -163,7 +163,7 @@ class DynamicImage { uint32_t GetVersion() {return version_;} // For sorting - bool operator<(const DynamicImage &inInfo) { + bool operator<(const DynamicImage& inInfo) { return GetLoadAddress() < inInfo.GetLoadAddress(); } @@ -171,8 +171,8 @@ class DynamicImage { bool IsValid() {return GetVMSize() != 0;} private: - DynamicImage(const DynamicImage &); - DynamicImage &operator=(const DynamicImage &); + DynamicImage(const DynamicImage&); + DynamicImage& operator=(const DynamicImage&); friend class DynamicImages; template @@ -205,26 +205,26 @@ class DynamicImage { // class DynamicImageRef { public: - explicit DynamicImageRef(DynamicImage *inP) : p(inP) {} + explicit DynamicImageRef(DynamicImage* inP) : p(inP) {} // The copy constructor is required by STL - DynamicImageRef(const DynamicImageRef &inRef) : p(inRef.p) {} + DynamicImageRef(const DynamicImageRef& inRef) : p(inRef.p) {} - bool operator<(const DynamicImageRef &inRef) const { + bool operator<(const DynamicImageRef& inRef) const { return (*const_cast(this)->p) < (*const_cast(inRef).p); } - bool operator==(const DynamicImageRef &inInfo) const { + bool operator==(const DynamicImageRef& inInfo) const { return (*const_cast(this)->p).GetLoadAddress() == (*const_cast(inInfo)).GetLoadAddress(); } // Be just like DynamicImage* - DynamicImage *operator->() {return p;} + DynamicImage* operator->() {return p;} operator DynamicImage*() {return p;} private: - DynamicImage *p; + DynamicImage* p; }; // Helper function to deal with 32-bit/64-bit Mach-O differences. @@ -250,7 +250,7 @@ class DynamicImages { int GetImageCount() const {return static_cast(image_list_.size());} // Returns an individual image. - DynamicImage *GetImage(int i) { + DynamicImage* GetImage(int i) { if (i < (int)image_list_.size()) { return image_list_[i]; } @@ -258,7 +258,7 @@ class DynamicImages { } // Returns the image corresponding to the main executable. - DynamicImage *GetExecutableImage(); + DynamicImage* GetExecutableImage(); int GetExecutableImageIndex(); // Returns the task which we're looking at. @@ -312,7 +312,7 @@ class DynamicImages { kern_return_t ReadTaskMemory(task_port_t target_task, const uint64_t address, size_t length, - vector &bytes); + vector& bytes); } // namespace google_breakpad diff --git a/src/client/mac/handler/exception_handler.cc b/src/client/mac/handler/exception_handler.cc index 2a19d46a..287fe1be 100644 --- a/src/client/mac/handler/exception_handler.cc +++ b/src/client/mac/handler/exception_handler.cc @@ -220,7 +220,7 @@ kern_return_t catch_exception_raise(mach_port_t port, mach_port_t failed_thread, } #endif -ExceptionHandler::ExceptionHandler(const string &dump_path, +ExceptionHandler::ExceptionHandler(const string& dump_path, FilterCallback filter, MinidumpCallback callback, void* callback_context, @@ -304,7 +304,7 @@ bool ExceptionHandler::WriteMinidump(bool write_exception_stream) { } // static -bool ExceptionHandler::WriteMinidump(const string &dump_path, +bool ExceptionHandler::WriteMinidump(const string& dump_path, bool write_exception_stream, MinidumpCallback callback, void* callback_context) { @@ -316,7 +316,7 @@ bool ExceptionHandler::WriteMinidump(const string &dump_path, // static bool ExceptionHandler::WriteMinidumpForChild(mach_port_t child, mach_port_t child_blamed_thread, - const string &dump_path, + const string& dump_path, MinidumpCallback callback, void* callback_context) { ScopedTaskSuspend suspend(child); diff --git a/src/client/mac/handler/exception_handler.h b/src/client/mac/handler/exception_handler.h index f1d9ae92..fe7491fd 100644 --- a/src/client/mac/handler/exception_handler.h +++ b/src/client/mac/handler/exception_handler.h @@ -75,7 +75,7 @@ class ExceptionHandler { // attempting to write a minidump. If a FilterCallback returns false, Breakpad // will immediately report the exception as unhandled without writing a // minidump, allowing another handler the opportunity to handle it. - typedef bool (*FilterCallback)(void *context); + typedef bool (*FilterCallback)(void* context); // A callback function to run after the minidump has been written. // |minidump_id| is a unique id for the dump, so the minidump @@ -85,18 +85,18 @@ class ExceptionHandler { // Return true if the exception was fully handled and breakpad should exit. // Return false to allow any other exception handlers to process the // exception. - typedef bool (*MinidumpCallback)(const char *dump_dir, - const char *minidump_id, - void *context, bool succeeded); + typedef bool (*MinidumpCallback)(const char* dump_dir, + const char* minidump_id, + void* context, bool succeeded); // A callback function which will be called directly if an exception occurs. // This bypasses the minidump file writing and simply gives the client // the exception information. - typedef bool (*DirectCallback)( void *context, - int exception_type, - int exception_code, - int exception_subcode, - mach_port_t thread_name); + typedef bool (*DirectCallback)(void* context, + int exception_type, + int exception_code, + int exception_subcode, + mach_port_t thread_name); // Creates a new ExceptionHandler instance to handle writing minidumps. // Minidump files will be written to dump_path, and the optional callback @@ -106,22 +106,22 @@ class ExceptionHandler { // be written when WriteMinidump is called. // If port_name is non-NULL, attempt to perform out-of-process dump generation // If port_name is NULL, in-process dump generation will be used. - ExceptionHandler(const string &dump_path, + ExceptionHandler(const string& dump_path, FilterCallback filter, MinidumpCallback callback, - void *callback_context, bool install_handler, - const char *port_name); + void* callback_context, bool install_handler, + const char* port_name); // A special constructor if we want to bypass minidump writing and // simply get a callback with the exception information. ExceptionHandler(DirectCallback callback, - void *callback_context, + void* callback_context, bool install_handler); ~ExceptionHandler(); // Get and set the minidump path. string dump_path() const { return dump_path_; } - void set_dump_path(const string &dump_path) { + void set_dump_path(const string& dump_path) { dump_path_ = dump_path; dump_path_c_ = dump_path_.c_str(); UpdateNextID(); // Necessary to put dump_path_ in next_minidump_path_. @@ -137,23 +137,23 @@ class ExceptionHandler { // Convenience form of WriteMinidump which does not require an // ExceptionHandler instance. - static bool WriteMinidump(const string &dump_path, MinidumpCallback callback, - void *callback_context) { + static bool WriteMinidump(const string& dump_path, MinidumpCallback callback, + void* callback_context) { return WriteMinidump(dump_path, false, callback, callback_context); } - static bool WriteMinidump(const string &dump_path, + static bool WriteMinidump(const string& dump_path, bool write_exception_stream, MinidumpCallback callback, - void *callback_context); + void* callback_context); // Write a minidump of child immediately. This can be used to capture // the execution state of a child process independently of a crash. static bool WriteMinidumpForChild(mach_port_t child, - mach_port_t child_blamed_thread, - const std::string &dump_path, - MinidumpCallback callback, - void *callback_context); + mach_port_t child_blamed_thread, + const std::string& dump_path, + MinidumpCallback callback, + void* callback_context); // Returns whether out-of-process dump generation is used or not. bool IsOutOfProcess() const { @@ -189,21 +189,21 @@ class ExceptionHandler { bool WriteMinidumpWithException(int exception_type, int exception_code, int exception_subcode, - breakpad_ucontext_t *task_context, + breakpad_ucontext_t* task_context, mach_port_t thread_name, bool exit_after_write, bool report_current_thread); // When installed, this static function will be call from a newly created // pthread with |this| as the argument - static void *WaitForMessage(void *exception_handler_class); + static void* WaitForMessage(void* exception_handler_class); // Signal handler for SIGABRT. static void SignalHandler(int sig, siginfo_t* info, void* uc); // disallow copy ctor and operator= - explicit ExceptionHandler(const ExceptionHandler &); - void operator=(const ExceptionHandler &); + explicit ExceptionHandler(const ExceptionHandler&); + void operator=(const ExceptionHandler&); // Generates a new ID and stores it in next_minidump_id_, and stores the // path of the next minidump to be written in next_minidump_path_. @@ -224,15 +224,15 @@ class ExceptionHandler { string next_minidump_path_; // Pointers to the UTF-8 versions of above - const char *dump_path_c_; - const char *next_minidump_id_c_; - const char *next_minidump_path_c_; + const char* dump_path_c_; + const char* next_minidump_id_c_; + const char* next_minidump_path_c_; // The callback function and pointer to be passed back after the minidump // has been written FilterCallback filter_; MinidumpCallback callback_; - void *callback_context_; + void* callback_context_; // The callback function to be passed back when we don't want a minidump // file to be written @@ -247,7 +247,7 @@ class ExceptionHandler { // These variables save the previous exception handler's data so that it // can be re-installed when this handler is uninstalled - ExceptionParameters *previous_; + ExceptionParameters* previous_; // True, if we've installed the exception handler bool installed_exception_handler_; diff --git a/src/client/mac/handler/minidump_generator.cc b/src/client/mac/handler/minidump_generator.cc index 50df9002..e0351c4b 100644 --- a/src/client/mac/handler/minidump_generator.cc +++ b/src/client/mac/handler/minidump_generator.cc @@ -191,12 +191,12 @@ void MinidumpGenerator::GatherSystemInformation() { os_build_number_ = IntegerValueAtIndex(product_str, 2); } -void MinidumpGenerator::SetTaskContext(breakpad_ucontext_t *task_context) { +void MinidumpGenerator::SetTaskContext(breakpad_ucontext_t* task_context) { task_context_ = task_context; } -string MinidumpGenerator::UniqueNameInDirectory(const string &dir, - string *unique_name) { +string MinidumpGenerator::UniqueNameInDirectory(const string& dir, + string* unique_name) { CFUUIDRef uuid = CFUUIDCreate(NULL); CFStringRef uuid_cfstr = CFUUIDCreateString(NULL, uuid); CFRelease(uuid); @@ -220,7 +220,7 @@ string MinidumpGenerator::UniqueNameInDirectory(const string &dir, return path; } -bool MinidumpGenerator::Write(const char *path) { +bool MinidumpGenerator::Write(const char* path) { WriteStreamFN writers[] = { &MinidumpGenerator::WriteThreadListStream, &MinidumpGenerator::WriteMemoryListStream, @@ -256,10 +256,10 @@ bool MinidumpGenerator::Write(const char *path) { if (!dir.AllocateArray(writer_count)) return false; - MDRawHeader *header_ptr = header.get(); + MDRawHeader* header_ptr = header.get(); header_ptr->signature = MD_HEADER_SIGNATURE; header_ptr->version = MD_HEADER_VERSION; - time(reinterpret_cast(&(header_ptr->time_date_stamp))); + time(reinterpret_cast(&(header_ptr->time_date_stamp))); header_ptr->stream_count = writer_count; header_ptr->stream_directory_rva = dir.position(); @@ -335,7 +335,7 @@ size_t MinidumpGenerator::CalculateStackSize(mach_vm_address_t start_addr) { bool MinidumpGenerator::WriteStackFromStartAddress( mach_vm_address_t start_addr, - MDMemoryDescriptor *stack_location) { + MDMemoryDescriptor* stack_location) { UntypedMDRVA memory(&writer_); bool result = false; @@ -372,7 +372,7 @@ bool MinidumpGenerator::WriteStackFromStartAddress( result = memory.Copy(&stack_memory[0], size); } else { - result = memory.Copy(reinterpret_cast(start_addr), size); + result = memory.Copy(reinterpret_cast(start_addr), size); } } @@ -383,7 +383,7 @@ bool MinidumpGenerator::WriteStackFromStartAddress( } bool MinidumpGenerator::WriteStack(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location) { + MDMemoryDescriptor* stack_location) { switch (cpu_type_) { #ifdef HAS_ARM_SUPPORT case CPU_TYPE_ARM: @@ -411,7 +411,7 @@ bool MinidumpGenerator::WriteStack(breakpad_thread_state_data_t state, } bool MinidumpGenerator::WriteContext(breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location) { + MDLocationDescriptor* register_location) { switch (cpu_type_) { #ifdef HAS_ARM_SUPPORT case CPU_TYPE_ARM: @@ -469,33 +469,33 @@ uint64_t MinidumpGenerator::CurrentPCForStack( #ifdef HAS_ARM_SUPPORT bool MinidumpGenerator::WriteStackARM(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location) { - arm_thread_state_t *machine_state = - reinterpret_cast(state); + MDMemoryDescriptor* stack_location) { + arm_thread_state_t* machine_state = + reinterpret_cast(state); mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, sp); return WriteStackFromStartAddress(start_addr, stack_location); } uint64_t MinidumpGenerator::CurrentPCForStackARM(breakpad_thread_state_data_t state) { - arm_thread_state_t *machine_state = - reinterpret_cast(state); + arm_thread_state_t* machine_state = + reinterpret_cast(state); return REGISTER_FROM_THREADSTATE(machine_state, pc); } bool MinidumpGenerator::WriteContextARM(breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location) + MDLocationDescriptor* register_location) { TypedMDRVA context(&writer_); - arm_thread_state_t *machine_state = - reinterpret_cast(state); + arm_thread_state_t* machine_state = + reinterpret_cast(state); if (!context.Allocate()) return false; *register_location = context.location(); - MDRawContextARM *context_ptr = context.get(); + MDRawContextARM* context_ptr = context.get(); context_ptr->context_flags = MD_CONTEXT_ARM_FULL; #define AddGPR(a) context_ptr->iregs[a] = REGISTER_FROM_THREADSTATE(machine_state, r[a]) @@ -526,34 +526,34 @@ bool MinidumpGenerator::WriteContextARM(breakpad_thread_state_data_t state, #ifdef HAS_ARM64_SUPPORT bool MinidumpGenerator::WriteStackARM64(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location) { - arm_thread_state64_t *machine_state = - reinterpret_cast(state); + MDMemoryDescriptor* stack_location) { + arm_thread_state64_t* machine_state = + reinterpret_cast(state); mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, sp); return WriteStackFromStartAddress(start_addr, stack_location); } uint64_t MinidumpGenerator::CurrentPCForStackARM64(breakpad_thread_state_data_t state) { - arm_thread_state64_t *machine_state = - reinterpret_cast(state); + arm_thread_state64_t* machine_state = + reinterpret_cast(state); return REGISTER_FROM_THREADSTATE(machine_state, pc); } bool MinidumpGenerator::WriteContextARM64(breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location) + MDLocationDescriptor* register_location) { TypedMDRVA context(&writer_); - arm_thread_state64_t *machine_state = - reinterpret_cast(state); + arm_thread_state64_t* machine_state = + reinterpret_cast(state); if (!context.Allocate()) return false; *register_location = context.location(); - MDRawContextARM64_Old *context_ptr = context.get(); + MDRawContextARM64_Old* context_ptr = context.get(); context_ptr->context_flags = MD_CONTEXT_ARM64_FULL_OLD; #define AddGPR(a) \ @@ -602,49 +602,49 @@ MinidumpGenerator::WriteContextARM64(breakpad_thread_state_data_t state, #ifdef HAS_PCC_SUPPORT bool MinidumpGenerator::WriteStackPPC(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location) { - ppc_thread_state_t *machine_state = - reinterpret_cast(state); + MDMemoryDescriptor* stack_location) { + ppc_thread_state_t* machine_state = + reinterpret_cast(state); mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, r1); return WriteStackFromStartAddress(start_addr, stack_location); } bool MinidumpGenerator::WriteStackPPC64(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location) { - ppc_thread_state64_t *machine_state = - reinterpret_cast(state); + MDMemoryDescriptor* stack_location) { + ppc_thread_state64_t* machine_state = + reinterpret_cast(state); mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, r1); return WriteStackFromStartAddress(start_addr, stack_location); } uint64_t MinidumpGenerator::CurrentPCForStackPPC(breakpad_thread_state_data_t state) { - ppc_thread_state_t *machine_state = - reinterpret_cast(state); + ppc_thread_state_t* machine_state = + reinterpret_cast(state); return REGISTER_FROM_THREADSTATE(machine_state, srr0); } uint64_t MinidumpGenerator::CurrentPCForStackPPC64(breakpad_thread_state_data_t state) { - ppc_thread_state64_t *machine_state = - reinterpret_cast(state); + ppc_thread_state64_t* machine_state = + reinterpret_cast(state); return REGISTER_FROM_THREADSTATE(machine_state, srr0); } bool MinidumpGenerator::WriteContextPPC(breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location) + MDLocationDescriptor* register_location) { TypedMDRVA context(&writer_); - ppc_thread_state_t *machine_state = - reinterpret_cast(state); + ppc_thread_state_t* machine_state = + reinterpret_cast(state); if (!context.Allocate()) return false; *register_location = context.location(); - MDRawContextPPC *context_ptr = context.get(); + MDRawContextPPC* context_ptr = context.get(); context_ptr->context_flags = MD_CONTEXT_PPC_BASE; #define AddReg(a) context_ptr->a = static_cast<__typeof__(context_ptr->a)>( \ @@ -701,16 +701,16 @@ bool MinidumpGenerator::WriteContextPPC(breakpad_thread_state_data_t state, bool MinidumpGenerator::WriteContextPPC64( breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location) { + MDLocationDescriptor* register_location) { TypedMDRVA context(&writer_); - ppc_thread_state64_t *machine_state = - reinterpret_cast(state); + ppc_thread_state64_t* machine_state = + reinterpret_cast(state); if (!context.Allocate()) return false; *register_location = context.location(); - MDRawContextPPC64 *context_ptr = context.get(); + MDRawContextPPC64* context_ptr = context.get(); context_ptr->context_flags = MD_CONTEXT_PPC_BASE; #define AddReg(a) context_ptr->a = static_cast<__typeof__(context_ptr->a)>( \ @@ -768,18 +768,18 @@ bool MinidumpGenerator::WriteContextPPC64( #ifdef HAS_X86_SUPPORT bool MinidumpGenerator::WriteStackX86(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location) { - i386_thread_state_t *machine_state = - reinterpret_cast(state); + MDMemoryDescriptor* stack_location) { + i386_thread_state_t* machine_state = + reinterpret_cast(state); mach_vm_address_t start_addr = REGISTER_FROM_THREADSTATE(machine_state, esp); return WriteStackFromStartAddress(start_addr, stack_location); } bool MinidumpGenerator::WriteStackX86_64(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location) { - x86_thread_state64_t *machine_state = - reinterpret_cast(state); + MDMemoryDescriptor* stack_location) { + x86_thread_state64_t* machine_state = + reinterpret_cast(state); mach_vm_address_t start_addr = static_cast( REGISTER_FROM_THREADSTATE(machine_state, rsp)); @@ -788,32 +788,32 @@ bool MinidumpGenerator::WriteStackX86_64(breakpad_thread_state_data_t state, uint64_t MinidumpGenerator::CurrentPCForStackX86(breakpad_thread_state_data_t state) { - i386_thread_state_t *machine_state = - reinterpret_cast(state); + i386_thread_state_t* machine_state = + reinterpret_cast(state); return REGISTER_FROM_THREADSTATE(machine_state, eip); } uint64_t MinidumpGenerator::CurrentPCForStackX86_64(breakpad_thread_state_data_t state) { - x86_thread_state64_t *machine_state = - reinterpret_cast(state); + x86_thread_state64_t* machine_state = + reinterpret_cast(state); return REGISTER_FROM_THREADSTATE(machine_state, rip); } bool MinidumpGenerator::WriteContextX86(breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location) + MDLocationDescriptor* register_location) { TypedMDRVA context(&writer_); - i386_thread_state_t *machine_state = - reinterpret_cast(state); + i386_thread_state_t* machine_state = + reinterpret_cast(state); if (!context.Allocate()) return false; *register_location = context.location(); - MDRawContextX86 *context_ptr = context.get(); + MDRawContextX86* context_ptr = context.get(); #define AddReg(a) context_ptr->a = static_cast<__typeof__(context_ptr->a)>( \ REGISTER_FROM_THREADSTATE(machine_state, a)) @@ -844,16 +844,16 @@ bool MinidumpGenerator::WriteContextX86(breakpad_thread_state_data_t state, bool MinidumpGenerator::WriteContextX86_64( breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location) { + MDLocationDescriptor* register_location) { TypedMDRVA context(&writer_); - x86_thread_state64_t *machine_state = - reinterpret_cast(state); + x86_thread_state64_t* machine_state = + reinterpret_cast(state); if (!context.Allocate()) return false; *register_location = context.location(); - MDRawContextAMD64 *context_ptr = context.get(); + MDRawContextAMD64* context_ptr = context.get(); #define AddReg(a) context_ptr->a = static_cast<__typeof__(context_ptr->a)>( \ REGISTER_FROM_THREADSTATE(machine_state, a)) @@ -892,7 +892,7 @@ bool MinidumpGenerator::WriteContextX86_64( bool MinidumpGenerator::GetThreadState(thread_act_t target_thread, thread_state_t state, - mach_msg_type_number_t *count) { + mach_msg_type_number_t* count) { if (task_context_ && target_thread == mach_thread_self()) { switch (cpu_type_) { #ifdef HAS_ARM_SUPPORT @@ -963,7 +963,7 @@ bool MinidumpGenerator::GetThreadState(thread_act_t target_thread, } bool MinidumpGenerator::WriteThreadStream(mach_port_t thread_id, - MDRawThread *thread) { + MDRawThread* thread) { breakpad_thread_state_data_t state; mach_msg_type_number_t state_count = static_cast(sizeof(state)); @@ -986,7 +986,7 @@ bool MinidumpGenerator::WriteThreadStream(mach_port_t thread_id, } bool MinidumpGenerator::WriteThreadListStream( - MDRawDirectory *thread_list_stream) { + MDRawDirectory* thread_list_stream) { TypedMDRVA list(&writer_); thread_act_port_array_t threads_for_task; mach_msg_type_number_t thread_count; @@ -1027,7 +1027,7 @@ bool MinidumpGenerator::WriteThreadListStream( } bool MinidumpGenerator::WriteMemoryListStream( - MDRawDirectory *memory_list_stream) { + MDRawDirectory* memory_list_stream) { TypedMDRVA list(&writer_); // If the dump has an exception, include some memory around the @@ -1119,7 +1119,7 @@ bool MinidumpGenerator::WriteMemoryListStream( } else { // In-process, just copy from local memory. ip_memory.Copy( - reinterpret_cast(ip_memory_d.start_of_memory_range), + reinterpret_cast(ip_memory_d.start_of_memory_range), ip_memory_d.memory.data_size); } @@ -1133,7 +1133,7 @@ bool MinidumpGenerator::WriteMemoryListStream( } bool -MinidumpGenerator::WriteExceptionStream(MDRawDirectory *exception_stream) { +MinidumpGenerator::WriteExceptionStream(MDRawDirectory* exception_stream) { TypedMDRVA exception(&writer_); if (!exception.Allocate()) @@ -1141,7 +1141,7 @@ MinidumpGenerator::WriteExceptionStream(MDRawDirectory *exception_stream) { exception_stream->stream_type = MD_EXCEPTION_STREAM; exception_stream->location = exception.location(); - MDRawExceptionStream *exception_ptr = exception.get(); + MDRawExceptionStream* exception_ptr = exception.get(); exception_ptr->thread_id = exception_thread_; // This naming is confusing, but it is the proper translation from @@ -1168,7 +1168,7 @@ MinidumpGenerator::WriteExceptionStream(MDRawDirectory *exception_stream) { } bool MinidumpGenerator::WriteSystemInfoStream( - MDRawDirectory *system_info_stream) { + MDRawDirectory* system_info_stream) { TypedMDRVA info(&writer_); if (!info.Allocate()) @@ -1181,7 +1181,7 @@ bool MinidumpGenerator::WriteSystemInfoStream( uint32_t number_of_processors; size_t len = sizeof(number_of_processors); sysctlbyname("hw.ncpu", &number_of_processors, &len, NULL, 0); - MDRawSystemInfo *info_ptr = info.get(); + MDRawSystemInfo* info_ptr = info.get(); switch (cpu_type_) { #ifdef HAS_ARM_SUPPORT @@ -1292,10 +1292,10 @@ bool MinidumpGenerator::WriteSystemInfoStream( } bool MinidumpGenerator::WriteModuleStream(unsigned int index, - MDRawModule *module) { + MDRawModule* module) { if (dynamic_images_) { // we're in a different process than the crashed process - DynamicImage *image = dynamic_images_->GetImage(index); + DynamicImage* image = dynamic_images_->GetImage(index); if (!image) return false; @@ -1337,7 +1337,7 @@ bool MinidumpGenerator::WriteModuleStream(unsigned int index, } } else { // Getting module info in the crashed process - const breakpad_mach_header *header; + const breakpad_mach_header* header; header = (breakpad_mach_header*)_dyld_get_image_header(index); if (!header) return false; @@ -1357,16 +1357,16 @@ bool MinidumpGenerator::WriteModuleStream(unsigned int index, int cpu_type = header->cputype; unsigned long slide = _dyld_get_image_vmaddr_slide(index); const char* name = _dyld_get_image_name(index); - const struct load_command *cmd = - reinterpret_cast(header + 1); + const struct load_command* cmd = + reinterpret_cast(header + 1); memset(module, 0, sizeof(MDRawModule)); for (unsigned int i = 0; cmd && (i < header->ncmds); i++) { if (cmd->cmd == LC_SEGMENT_ARCH) { - const breakpad_mach_segment_command *seg = - reinterpret_cast(cmd); + const breakpad_mach_segment_command* seg = + reinterpret_cast(cmd); if (!strcmp(seg->segname, "__TEXT")) { MDLocationDescriptor string_location; @@ -1389,7 +1389,7 @@ bool MinidumpGenerator::WriteModuleStream(unsigned int index, } } - cmd = reinterpret_cast((char *)cmd + cmd->cmdsize); + cmd = reinterpret_cast((char*)cmd + cmd->cmdsize); } } @@ -1405,7 +1405,7 @@ int MinidumpGenerator::FindExecutableModule() { } } else { int image_count = _dyld_image_count(); - const struct mach_header *header; + const struct mach_header* header; for (int index = 0; index < image_count; ++index) { header = _dyld_get_image_header(index); @@ -1419,12 +1419,12 @@ int MinidumpGenerator::FindExecutableModule() { return 0; } -bool MinidumpGenerator::WriteCVRecord(MDRawModule *module, int cpu_type, - const char *module_path, bool in_memory) { +bool MinidumpGenerator::WriteCVRecord(MDRawModule* module, int cpu_type, + const char* module_path, bool in_memory) { TypedMDRVA cv(&writer_); // Only return the last path component of the full module path - const char *module_name = strrchr(module_path, '/'); + const char* module_name = strrchr(module_path, '/'); // Increment past the slash if (module_name) @@ -1441,7 +1441,7 @@ bool MinidumpGenerator::WriteCVRecord(MDRawModule *module, int cpu_type, return false; module->cv_record = cv.location(); - MDCVInfoPDB70 *cv_ptr = cv.get(); + MDCVInfoPDB70* cv_ptr = cv.get(); cv_ptr->cv_signature = MD_CVINFOPDB70_SIGNATURE; cv_ptr->age = 0; @@ -1450,7 +1450,7 @@ bool MinidumpGenerator::WriteCVRecord(MDRawModule *module, int cpu_type, bool result = false; if (in_memory) { MacFileUtilities::MachoID macho(module_path, - reinterpret_cast(module->base_of_image), + reinterpret_cast(module->base_of_image), static_cast(module->size_of_image)); result = macho.UUIDCommand(cpu_type, CPU_SUBTYPE_MULTIPLE, identifier); if (!result) @@ -1487,7 +1487,7 @@ bool MinidumpGenerator::WriteCVRecord(MDRawModule *module, int cpu_type, } bool MinidumpGenerator::WriteModuleListStream( - MDRawDirectory *module_list_stream) { + MDRawDirectory* module_list_stream) { TypedMDRVA list(&writer_); uint32_t image_count = dynamic_images_ ? @@ -1525,7 +1525,7 @@ bool MinidumpGenerator::WriteModuleListStream( return true; } -bool MinidumpGenerator::WriteMiscInfoStream(MDRawDirectory *misc_info_stream) { +bool MinidumpGenerator::WriteMiscInfoStream(MDRawDirectory* misc_info_stream) { TypedMDRVA info(&writer_); if (!info.Allocate()) @@ -1534,7 +1534,7 @@ bool MinidumpGenerator::WriteMiscInfoStream(MDRawDirectory *misc_info_stream) { misc_info_stream->stream_type = MD_MISC_INFO_STREAM; misc_info_stream->location = info.location(); - MDRawMiscInfo *info_ptr = info.get(); + MDRawMiscInfo* info_ptr = info.get(); info_ptr->size_of_info = static_cast(sizeof(MDRawMiscInfo)); info_ptr->flags1 = MD_MISCINFO_FLAGS1_PROCESS_ID | MD_MISCINFO_FLAGS1_PROCESS_TIMES | @@ -1577,7 +1577,7 @@ bool MinidumpGenerator::WriteMiscInfoStream(MDRawDirectory *misc_info_stream) { } bool MinidumpGenerator::WriteBreakpadInfoStream( - MDRawDirectory *breakpad_info_stream) { + MDRawDirectory* breakpad_info_stream) { TypedMDRVA info(&writer_); if (!info.Allocate()) @@ -1585,7 +1585,7 @@ bool MinidumpGenerator::WriteBreakpadInfoStream( breakpad_info_stream->stream_type = MD_BREAKPAD_INFO_STREAM; breakpad_info_stream->location = info.location(); - MDRawBreakpadInfo *info_ptr = info.get(); + MDRawBreakpadInfo* info_ptr = info.get(); if (exception_thread_ && exception_type_) { info_ptr->validity = MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID | diff --git a/src/client/mac/handler/minidump_generator.h b/src/client/mac/handler/minidump_generator.h index f3aa9bd3..e3a271b0 100644 --- a/src/client/mac/handler/minidump_generator.h +++ b/src/client/mac/handler/minidump_generator.h @@ -106,12 +106,12 @@ class MinidumpGenerator { // Return /.dmp // Sets |unique_name| (if requested) to the unique name for the minidump - static string UniqueNameInDirectory(const string &dir, string *unique_name); + static string UniqueNameInDirectory(const string& dir, string* unique_name); // Write out the minidump into |path| // All of the components of |path| must exist and be writable // Return true if successful, false otherwise - bool Write(const char *path); + bool Write(const char* path); // Specify some exception information, if applicable void SetExceptionInformation(int type, int code, int subcode, @@ -125,7 +125,7 @@ class MinidumpGenerator { // Specify the task context. If |task_context| is not NULL, it will be used // to retrieve the context of the current thread, instead of using // |thread_get_state|. - void SetTaskContext(breakpad_ucontext_t *task_context); + void SetTaskContext(breakpad_ucontext_t* task_context); // Gather system information. This should be call at least once before using // the MinidumpGenerator class. @@ -133,81 +133,81 @@ class MinidumpGenerator { protected: // Overridable Stream writers - virtual bool WriteExceptionStream(MDRawDirectory *exception_stream); + virtual bool WriteExceptionStream(MDRawDirectory* exception_stream); // Overridable Helper - virtual bool WriteThreadStream(mach_port_t thread_id, MDRawThread *thread); + virtual bool WriteThreadStream(mach_port_t thread_id, MDRawThread* thread); private: - typedef bool (MinidumpGenerator::*WriteStreamFN)(MDRawDirectory *); + typedef bool (MinidumpGenerator::*WriteStreamFN)(MDRawDirectory*); // Stream writers - bool WriteThreadListStream(MDRawDirectory *thread_list_stream); - bool WriteMemoryListStream(MDRawDirectory *memory_list_stream); - bool WriteSystemInfoStream(MDRawDirectory *system_info_stream); - bool WriteModuleListStream(MDRawDirectory *module_list_stream); - bool WriteMiscInfoStream(MDRawDirectory *misc_info_stream); - bool WriteBreakpadInfoStream(MDRawDirectory *breakpad_info_stream); + bool WriteThreadListStream(MDRawDirectory* thread_list_stream); + bool WriteMemoryListStream(MDRawDirectory* memory_list_stream); + bool WriteSystemInfoStream(MDRawDirectory* system_info_stream); + bool WriteModuleListStream(MDRawDirectory* module_list_stream); + bool WriteMiscInfoStream(MDRawDirectory* misc_info_stream); + bool WriteBreakpadInfoStream(MDRawDirectory* breakpad_info_stream); // Helpers uint64_t CurrentPCForStack(breakpad_thread_state_data_t state); bool GetThreadState(thread_act_t target_thread, thread_state_t state, - mach_msg_type_number_t *count); + mach_msg_type_number_t* count); bool WriteStackFromStartAddress(mach_vm_address_t start_addr, - MDMemoryDescriptor *stack_location); + MDMemoryDescriptor* stack_location); bool WriteStack(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location); + MDMemoryDescriptor* stack_location); bool WriteContext(breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location); - bool WriteCVRecord(MDRawModule *module, int cpu_type, - const char *module_path, bool in_memory); - bool WriteModuleStream(unsigned int index, MDRawModule *module); + MDLocationDescriptor* register_location); + bool WriteCVRecord(MDRawModule* module, int cpu_type, + const char* module_path, bool in_memory); + bool WriteModuleStream(unsigned int index, MDRawModule* module); size_t CalculateStackSize(mach_vm_address_t start_addr); int FindExecutableModule(); // Per-CPU implementations of these methods #ifdef HAS_ARM_SUPPORT bool WriteStackARM(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location); + MDMemoryDescriptor* stack_location); bool WriteContextARM(breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location); + MDLocationDescriptor* register_location); uint64_t CurrentPCForStackARM(breakpad_thread_state_data_t state); #endif #ifdef HAS_ARM64_SUPPORT bool WriteStackARM64(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location); + MDMemoryDescriptor* stack_location); bool WriteContextARM64(breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location); + MDLocationDescriptor* register_location); uint64_t CurrentPCForStackARM64(breakpad_thread_state_data_t state); #endif #ifdef HAS_PPC_SUPPORT bool WriteStackPPC(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location); + MDMemoryDescriptor* stack_location); bool WriteContextPPC(breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location); + MDLocationDescriptor* register_location); uint64_t CurrentPCForStackPPC(breakpad_thread_state_data_t state); bool WriteStackPPC64(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location); + MDMemoryDescriptor* stack_location); bool WriteContextPPC64(breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location); + MDLocationDescriptor* register_location); uint64_t CurrentPCForStackPPC64(breakpad_thread_state_data_t state); #endif #ifdef HAS_X86_SUPPORT bool WriteStackX86(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location); + MDMemoryDescriptor* stack_location); bool WriteContextX86(breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location); + MDLocationDescriptor* register_location); uint64_t CurrentPCForStackX86(breakpad_thread_state_data_t state); bool WriteStackX86_64(breakpad_thread_state_data_t state, - MDMemoryDescriptor *stack_location); + MDMemoryDescriptor* stack_location); bool WriteContextX86_64(breakpad_thread_state_data_t state, - MDLocationDescriptor *register_location); + MDLocationDescriptor* register_location); uint64_t CurrentPCForStackX86_64(breakpad_thread_state_data_t state); #endif // disallow copy ctor and operator= - explicit MinidumpGenerator(const MinidumpGenerator &); - void operator=(const MinidumpGenerator &); + explicit MinidumpGenerator(const MinidumpGenerator&); + void operator=(const MinidumpGenerator&); protected: // Use this writer to put the data to disk @@ -232,10 +232,10 @@ class MinidumpGenerator { static int os_build_number_; // Context of the task to dump. - breakpad_ucontext_t *task_context_; + breakpad_ucontext_t* task_context_; // Information about dynamically loaded code - DynamicImages *dynamic_images_; + DynamicImages* dynamic_images_; // PageAllocator makes it possible to allocate memory // directly from the system, even while handling an exception. diff --git a/src/client/mac/handler/testcases/DynamicImagesTests.cc b/src/client/mac/handler/testcases/DynamicImagesTests.cc index 0fc7825b..0a80e434 100644 --- a/src/client/mac/handler/testcases/DynamicImagesTests.cc +++ b/src/client/mac/handler/testcases/DynamicImagesTests.cc @@ -42,7 +42,7 @@ DynamicImagesTests test2(TEST_INVOCATION(DynamicImagesTests, DynamicImagesTests test3(TEST_INVOCATION(DynamicImagesTests, ReadLibrariesFromLocalTaskTest)); -DynamicImagesTests::DynamicImagesTests(TestInvocation *invocation) +DynamicImagesTests::DynamicImagesTests(TestInvocation* invocation) : TestCase(invocation) { } @@ -54,7 +54,7 @@ void DynamicImagesTests::ReadTaskMemoryTest() { // pick test2 as a symbol we know to be valid to read // anything will work, really - void *addr = reinterpret_cast(&test2); + void* addr = reinterpret_cast(&test2); std::vector buf(getpagesize()); fprintf(stderr, "reading 0x%p\n", addr); @@ -71,7 +71,7 @@ void DynamicImagesTests::ReadTaskMemoryTest() { void DynamicImagesTests::ReadLibrariesFromLocalTaskTest() { mach_port_t me = mach_task_self(); - google_breakpad::DynamicImages *d = new google_breakpad::DynamicImages(me); + google_breakpad::DynamicImages* d = new google_breakpad::DynamicImages(me); fprintf(stderr,"Local task image count: %d\n", d->GetImageCount()); diff --git a/src/client/mac/handler/testcases/breakpad_nlist_test.cc b/src/client/mac/handler/testcases/breakpad_nlist_test.cc index e7332bfb..2014b907 100644 --- a/src/client/mac/handler/testcases/breakpad_nlist_test.cc +++ b/src/client/mac/handler/testcases/breakpad_nlist_test.cc @@ -40,7 +40,7 @@ BreakpadNlistTest test1(TEST_INVOCATION(BreakpadNlistTest, CompareToNM)); -BreakpadNlistTest::BreakpadNlistTest(TestInvocation *invocation) +BreakpadNlistTest::BreakpadNlistTest(TestInvocation* invocation) : TestCase(invocation) { } @@ -55,7 +55,7 @@ void BreakpadNlistTest::CompareToNM() { system("/usr/bin/nm -arch ppc64 /usr/lib/dyld > /tmp/dyld-namelist.txt"); #endif - FILE *fd = fopen("/tmp/dyld-namelist.txt", "rt"); + FILE* fd = fopen("/tmp/dyld-namelist.txt", "rt"); char oneNMAddr[30]; char symbolType; @@ -63,10 +63,10 @@ void BreakpadNlistTest::CompareToNM() { while (!feof(fd)) { fscanf(fd, "%s %c %s", oneNMAddr, &symbolType, symbolName); breakpad_nlist symbolList[2]; - breakpad_nlist &list = symbolList[0]; + breakpad_nlist& list = symbolList[0]; memset(symbolList, 0, sizeof(breakpad_nlist)*2); - const char *symbolNames[2]; + const char* symbolNames[2]; symbolNames[0] = (const char*)symbolName; symbolNames[1] = "\0"; breakpad_nlist_64("/usr/lib/dyld", &list, symbolNames); @@ -79,12 +79,12 @@ void BreakpadNlistTest::CompareToNM() { fclose(fd); } -bool BreakpadNlistTest::IsSymbolMoreThanOnceInDyld(const char *symbolName) { +bool BreakpadNlistTest::IsSymbolMoreThanOnceInDyld(const char* symbolName) { // These are the symbols that occur more than once when nm dumps // the symbol table of /usr/lib/dyld. Our nlist program returns // the first address because it's doing a search so we need to exclude // these from causing the test to fail - const char *multipleSymbols[] = { + const char* multipleSymbols[] = { "__Z41__static_initialization_and_destruction_0ii", "___tcf_0", "___tcf_1", diff --git a/src/client/mac/handler/testcases/breakpad_nlist_test.h b/src/client/mac/handler/testcases/breakpad_nlist_test.h index e93657cc..ee8010c7 100644 --- a/src/client/mac/handler/testcases/breakpad_nlist_test.h +++ b/src/client/mac/handler/testcases/breakpad_nlist_test.h @@ -47,7 +47,7 @@ class BreakpadNlistTest : public TestCase { // /usr/lib/dyld. So we track those so we don't report failures // in mismatches between what our nlist returns and what nm has // for the duplicate symbols. - bool IsSymbolMoreThanOnceInDyld(const char *symbolName); + bool IsSymbolMoreThanOnceInDyld(const char* symbolName); public: explicit BreakpadNlistTest(TestInvocation* invocation); diff --git a/src/client/mac/testapp/main.m b/src/client/mac/testapp/main.m index 1ed19bf9..de673326 100644 --- a/src/client/mac/testapp/main.m +++ b/src/client/mac/testapp/main.m @@ -30,5 +30,5 @@ #import int main(int argc, char *argv[]) { - return NSApplicationMain(argc, (const char **) argv); + return NSApplicationMain(argc, (const char**)argv); } diff --git a/src/client/mac/tests/crash_generation_server_test.cc b/src/client/mac/tests/crash_generation_server_test.cc index 0164f4a2..128f25c1 100644 --- a/src/client/mac/tests/crash_generation_server_test.cc +++ b/src/client/mac/tests/crash_generation_server_test.cc @@ -147,8 +147,8 @@ TEST_F(CrashGenerationServerTest, testRequestDumpNoDump) { globfree(&dirContents); } -void dumpCallback(void *context, const ClientInfo &client_info, - const std::string &file_path) { +void dumpCallback(void* context, const ClientInfo& client_info, + const std::string& file_path) { if (context) { CrashGenerationServerTest* self = reinterpret_cast(context); @@ -158,7 +158,7 @@ void dumpCallback(void *context, const ClientInfo &client_info, } } -void *RequestDump(void *context) { +void* RequestDump(void* context) { CrashGenerationClient client((const char*)context); bool result = client.RequestDump(); return (void*)(result ? 0 : 1); @@ -206,7 +206,7 @@ TEST_F(CrashGenerationServerTest, testRequestDump) { } static void Crasher() { - int *a = (int*)0x42; + int* a = (int*)0x42; fprintf(stdout, "Going to crash...\n"); fprintf(stdout, "A = %d", *a); diff --git a/src/client/mac/tests/exception_handler_test.cc b/src/client/mac/tests/exception_handler_test.cc index d5b505a1..50f03f81 100644 --- a/src/client/mac/tests/exception_handler_test.cc +++ b/src/client/mac/tests/exception_handler_test.cc @@ -71,7 +71,7 @@ class ExceptionHandlerTest : public Test { }; static void Crasher() { - int *a = (int*)0x42; + int* a = (int*)0x42; fprintf(stdout, "Going to crash...\n"); fprintf(stdout, "A = %d", *a); @@ -86,8 +86,8 @@ static void SoonToCrash(void(*crasher)()) { crasher(); } -static 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); path.append("/"); path.append(file_name); @@ -179,9 +179,9 @@ TEST_F(ExceptionHandlerTest, InProcessAbort) { InProcessCrash(true); } -static bool DumpNameMDCallback(const char *dump_dir, const char *file_name, - void *context, bool success) { - ExceptionHandlerTest *self = reinterpret_cast(context); +static bool DumpNameMDCallback(const char* dump_dir, const char* file_name, + void* context, bool success) { + ExceptionHandlerTest* self = reinterpret_cast(context); if (dump_dir && file_name) { self->lastDumpName = dump_dir; self->lastDumpName += "/"; @@ -652,7 +652,7 @@ TEST_F(ExceptionHandlerTest, InstructionPointerMemoryNullPointer) { ASSERT_EQ((unsigned int)1, memory_list->region_count()); } -static void *Junk(void *) { +static void* Junk(void*) { sleep(1000000); return NULL; } diff --git a/src/client/mac/tests/minidump_generator_test.cc b/src/client/mac/tests/minidump_generator_test.cc index b1fa5d02..1f374657 100644 --- a/src/client/mac/tests/minidump_generator_test.cc +++ b/src/client/mac/tests/minidump_generator_test.cc @@ -79,7 +79,7 @@ class MinidumpGeneratorTest : public Test { AutoTempDir tempDir; }; -static void *Junk(void* data) { +static void* Junk(void* data) { bool* wait = reinterpret_cast(data); while (!*wait) { usleep(10000); diff --git a/src/client/minidump_file_writer-inl.h b/src/client/minidump_file_writer-inl.h index 0e12e00b..bdac2dae 100644 --- a/src/client/minidump_file_writer-inl.h +++ b/src/client/minidump_file_writer-inl.h @@ -69,7 +69,7 @@ inline bool TypedMDRVA::AllocateObjectAndArray(size_t count, } template -inline bool TypedMDRVA::CopyIndex(unsigned int index, MDType *item) { +inline bool TypedMDRVA::CopyIndex(unsigned int index, MDType* item) { assert(allocation_state_ == ARRAY); return writer_->Copy( static_cast(position_ + index * minidump_size::size()), @@ -78,7 +78,7 @@ inline bool TypedMDRVA::CopyIndex(unsigned int index, MDType *item) { template inline bool TypedMDRVA::CopyIndexAfterObject(unsigned int index, - const void *src, + const void* src, size_t length) { assert(allocation_state_ == SINGLE_OBJECT_WITH_ARRAY); return writer_->Copy( diff --git a/src/client/minidump_file_writer.cc b/src/client/minidump_file_writer.cc index a1957f32..5c3c5cbb 100644 --- a/src/client/minidump_file_writer.cc +++ b/src/client/minidump_file_writer.cc @@ -101,7 +101,7 @@ MinidumpFileWriter::~MinidumpFileWriter() { Close(); } -bool MinidumpFileWriter::Open(const char *path) { +bool MinidumpFileWriter::Open(const char* path) { assert(file_ == -1); #if defined(__linux__) && __linux__ file_ = sys_open(path, O_WRONLY | O_CREAT | O_EXCL, 0600); @@ -145,9 +145,9 @@ bool MinidumpFileWriter::Close() { return result; } -bool MinidumpFileWriter::CopyStringToMDString(const wchar_t *str, +bool MinidumpFileWriter::CopyStringToMDString(const wchar_t* str, unsigned int length, - TypedMDRVA *mdstring) { + TypedMDRVA* mdstring) { bool result = true; if (sizeof(wchar_t) == sizeof(uint16_t)) { // Shortcut if wchar_t is the same size as MDString's buffer @@ -178,9 +178,9 @@ bool MinidumpFileWriter::CopyStringToMDString(const wchar_t *str, return result; } -bool MinidumpFileWriter::CopyStringToMDString(const char *str, +bool MinidumpFileWriter::CopyStringToMDString(const char* str, unsigned int length, - TypedMDRVA *mdstring) { + TypedMDRVA* mdstring) { bool result = true; uint16_t out[2]; int out_idx = 0; @@ -205,9 +205,9 @@ bool MinidumpFileWriter::CopyStringToMDString(const char *str, } template -bool MinidumpFileWriter::WriteStringCore(const CharType *str, +bool MinidumpFileWriter::WriteStringCore(const CharType* str, unsigned int length, - MDLocationDescriptor *location) { + MDLocationDescriptor* location) { assert(str); assert(location); // Calculate the mdstring length by either limiting to |length| as passed in @@ -240,18 +240,18 @@ bool MinidumpFileWriter::WriteStringCore(const CharType *str, return result; } -bool MinidumpFileWriter::WriteString(const wchar_t *str, unsigned int length, - MDLocationDescriptor *location) { +bool MinidumpFileWriter::WriteString(const wchar_t* str, unsigned int length, + MDLocationDescriptor* location) { return WriteStringCore(str, length, location); } -bool MinidumpFileWriter::WriteString(const char *str, unsigned int length, - MDLocationDescriptor *location) { +bool MinidumpFileWriter::WriteString(const char* str, unsigned int length, + MDLocationDescriptor* location) { return WriteStringCore(str, length, location); } -bool MinidumpFileWriter::WriteMemory(const void *src, size_t size, - MDMemoryDescriptor *output) { +bool MinidumpFileWriter::WriteMemory(const void* src, size_t size, + MDMemoryDescriptor* output) { assert(src); assert(output); UntypedMDRVA mem(this); @@ -307,7 +307,7 @@ MDRVA MinidumpFileWriter::Allocate(size_t size) { return current_position; } -bool MinidumpFileWriter::Copy(MDRVA position, const void *src, ssize_t size) { +bool MinidumpFileWriter::Copy(MDRVA position, const void* src, ssize_t size) { assert(src); assert(size); assert(file_ != -1); @@ -340,7 +340,7 @@ bool UntypedMDRVA::Allocate(size_t size) { return position_ != MinidumpFileWriter::kInvalidMDRVA; } -bool UntypedMDRVA::Copy(MDRVA pos, const void *src, size_t size) { +bool UntypedMDRVA::Copy(MDRVA pos, const void* src, size_t size) { assert(src); assert(size); assert(pos + size <= position_ + size_); diff --git a/src/client/minidump_file_writer.h b/src/client/minidump_file_writer.h index ce32b6d0..c66dc591 100644 --- a/src/client/minidump_file_writer.h +++ b/src/client/minidump_file_writer.h @@ -77,7 +77,7 @@ public: // Open |path| as the destination of the minidump data. If |path| already // exists, then Open() will fail. // Return true on success, or false on failure. - bool Open(const char *path); + bool Open(const char* path); // Sets the file descriptor |file| as the destination of the minidump data. // Can be used as an alternative to Open() when a file descriptor is @@ -98,20 +98,20 @@ public: // entire NULL terminated string. Copying will stop at the first NULL. // |location| the allocated location // Return true on success, or false on failure - bool WriteString(const wchar_t *str, unsigned int length, - MDLocationDescriptor *location); + bool WriteString(const wchar_t* str, unsigned int length, + MDLocationDescriptor* location); // Same as above, except with |str| as a UTF-8 string - bool WriteString(const char *str, unsigned int length, - MDLocationDescriptor *location); + bool WriteString(const char* str, unsigned int length, + MDLocationDescriptor* location); // Write |size| bytes starting at |src| into the current position. // Return true on success and set |output| to position, or false on failure - bool WriteMemory(const void *src, size_t size, MDMemoryDescriptor *output); + bool WriteMemory(const void* src, size_t size, MDMemoryDescriptor* output); // Copies |size| bytes from |src| to |position| // Return true on success, or false on failure - bool Copy(MDRVA position, const void *src, ssize_t size); + bool Copy(MDRVA position, const void* src, ssize_t size); // Return the current position for writing to the minidump inline MDRVA position() const { return position_; } @@ -141,21 +141,21 @@ public: // variant may need to create a MDString that has more characters than the // source |str|, whereas the UTF-8 variant may coalesce characters to form // a single UTF-16 character. - bool CopyStringToMDString(const wchar_t *str, unsigned int length, - TypedMDRVA *mdstring); - bool CopyStringToMDString(const char *str, unsigned int length, - TypedMDRVA *mdstring); + bool CopyStringToMDString(const wchar_t* str, unsigned int length, + TypedMDRVA* mdstring); + bool CopyStringToMDString(const char* str, unsigned int length, + TypedMDRVA* mdstring); // The common templated code for writing a string template - bool WriteStringCore(const CharType *str, unsigned int length, - MDLocationDescriptor *location); + bool WriteStringCore(const CharType* str, unsigned int length, + MDLocationDescriptor* location); }; // Represents an untyped allocated chunk class UntypedMDRVA { public: - explicit UntypedMDRVA(MinidumpFileWriter *writer) + explicit UntypedMDRVA(MinidumpFileWriter* writer) : writer_(writer), position_(writer->position()), size_(0) {} @@ -179,16 +179,16 @@ class UntypedMDRVA { // Copy |size| bytes starting at |src| into the minidump at |position| // Return true on success, or false on failure - bool Copy(MDRVA position, const void *src, size_t size); + bool Copy(MDRVA position, const void* src, size_t size); // Copy |size| bytes from |src| to the current position - inline bool Copy(const void *src, size_t size) { + inline bool Copy(const void* src, size_t size) { return Copy(position_, src, size); } protected: // Writer we associate with - MinidumpFileWriter *writer_; + MinidumpFileWriter* writer_; // Position of the start of the data MDRVA position_; @@ -206,7 +206,7 @@ template class TypedMDRVA : public UntypedMDRVA { public: // Constructs an unallocated MDRVA - explicit TypedMDRVA(MinidumpFileWriter *writer) + explicit TypedMDRVA(MinidumpFileWriter* writer) : UntypedMDRVA(writer), data_(), allocation_state_(UNALLOCATED) {} @@ -220,7 +220,7 @@ class TypedMDRVA : public UntypedMDRVA { // Address of object data_ of MDType. This is not declared const as the // typical usage will be to access the underlying |data_| object as to // alter its contents. - MDType *get() { return &data_; } + MDType* get() { return &data_; } // Allocates minidump_size::size() bytes. // Must not call more than once. @@ -245,12 +245,12 @@ class TypedMDRVA : public UntypedMDRVA { // Copy |item| to |index| // Must have been allocated using AllocateArray(). // Return true on success, or false on failure - bool CopyIndex(unsigned int index, MDType *item); + bool CopyIndex(unsigned int index, MDType* item); // Copy |size| bytes starting at |str| to |index| // Must have been allocated using AllocateObjectAndArray(). // Return true on success, or false on failure - bool CopyIndexAfterObject(unsigned int index, const void *src, size_t size); + bool CopyIndexAfterObject(unsigned int index, const void* src, size_t size); // Write data_ bool Flush(); diff --git a/src/client/minidump_file_writer_unittest.cc b/src/client/minidump_file_writer_unittest.cc index 256e3371..16c407d2 100644 --- a/src/client/minidump_file_writer_unittest.cc +++ b/src/client/minidump_file_writer_unittest.cc @@ -70,16 +70,16 @@ typedef struct { ArrayStructure array[0]; } ObjectAndArrayStructure; -static bool WriteFile(const char *path) { +static bool WriteFile(const char* path) { MinidumpFileWriter writer; if (writer.Open(path)) { // Test a single structure google_breakpad::TypedMDRVA strings(&writer); ASSERT_TRUE(strings.Allocate()); strings.get()->integer_value = 0xBEEF; - const char *first = "First String"; + const char* first = "First String"; ASSERT_TRUE(writer.WriteString(first, 0, &strings.get()->first_string)); - const wchar_t *second = L"Second String"; + const wchar_t* second = L"Second String"; ASSERT_TRUE(writer.WriteString(second, 0, &strings.get()->second_string)); // Test an array structure @@ -111,7 +111,7 @@ static bool WriteFile(const char *path) { return writer.Close(); } -static bool CompareFile(const char *path) { +static bool CompareFile(const char* path) { unsigned long expected[] = { #if defined(__BIG_ENDIAN__) 0x0000beef, 0x0000001e, 0x00000018, 0x00000020, 0x00000038, 0x00000000, @@ -146,13 +146,14 @@ static bool CompareFile(const char *path) { }; size_t expected_byte_count = sizeof(expected); int fd = open(path, O_RDONLY, 0600); - void *buffer = malloc(expected_byte_count); + void* buffer = malloc(expected_byte_count); ASSERT_NE(fd, -1); ASSERT_TRUE(buffer); ASSERT_EQ(read(fd, buffer, expected_byte_count), static_cast(expected_byte_count)); - char *b1, *b2; + char* b1; + char* b2; b1 = reinterpret_cast(buffer); b2 = reinterpret_cast(expected); while (*b1 == *b2) { @@ -167,13 +168,13 @@ static bool CompareFile(const char *path) { } static bool RunTests() { - const char *path = "/tmp/minidump_file_writer_unittest.dmp"; + const char* path = "/tmp/minidump_file_writer_unittest.dmp"; ASSERT_TRUE(WriteFile(path)); ASSERT_TRUE(CompareFile(path)); unlink(path); return true; } -extern "C" int main(int argc, const char *argv[]) { +extern "C" int main(int argc, const char* argv[]) { return RunTests() ? 0 : 1; } diff --git a/src/client/solaris/handler/exception_handler.cc b/src/client/solaris/handler/exception_handler.cc index 7fc8d255..c96683f6 100644 --- a/src/client/solaris/handler/exception_handler.cc +++ b/src/client/solaris/handler/exception_handler.cc @@ -54,15 +54,15 @@ static const int kSigTable[] = { SIGBUS }; -std::vector *ExceptionHandler::handler_stack_ = NULL; +std::vector* ExceptionHandler::handler_stack_ = NULL; int ExceptionHandler::handler_stack_index_ = 0; pthread_mutex_t ExceptionHandler::handler_stack_mutex_ = PTHREAD_MUTEX_INITIALIZER; -ExceptionHandler::ExceptionHandler(const string &dump_path, +ExceptionHandler::ExceptionHandler(const string& dump_path, FilterCallback filter, MinidumpCallback callback, - void *callback_context, + void* callback_context, bool install_handler) : filter_(filter), callback_(callback), @@ -79,7 +79,7 @@ ExceptionHandler::ExceptionHandler(const string &dump_path, pthread_mutex_lock(&handler_stack_mutex_); if (handler_stack_ == NULL) - handler_stack_ = new std::vector; + handler_stack_ = new std::vector; handler_stack_->push_back(this); pthread_mutex_unlock(&handler_stack_mutex_); } @@ -92,7 +92,7 @@ ExceptionHandler::~ExceptionHandler() { handler_stack_->pop_back(); } else { print_message1(2, "warning: removing Breakpad handler out of order\n"); - for (std::vector::iterator iterator = + for (std::vector::iterator iterator = handler_stack_->begin(); iterator != handler_stack_->end(); ++iterator) { @@ -116,9 +116,9 @@ bool ExceptionHandler::WriteMinidump() { } // static -bool ExceptionHandler::WriteMinidump(const string &dump_path, +bool ExceptionHandler::WriteMinidump(const string& dump_path, MinidumpCallback callback, - void *callback_context) { + void* callback_context) { ExceptionHandler handler(dump_path, NULL, callback, callback_context, false); return handler.InternalWriteMinidump(0, 0, NULL); @@ -166,7 +166,7 @@ void ExceptionHandler::TeardownAllHandlers() { // static void ExceptionHandler::HandleException(int signo) { -//void ExceptionHandler::HandleException(int signo, siginfo_t *sip, ucontext_t *sig_ctx) { +//void ExceptionHandler::HandleException(int signo, siginfo_t* sip, ucontext_t* sig_ctx) { // The context information about the signal is put on the stack of // the signal handler frame as value parameter. For some reasons, the // prototype of the handler doesn't declare this information as parameter, we @@ -181,14 +181,14 @@ void ExceptionHandler::HandleException(int signo) { uintptr_t current_ebp = (uintptr_t)_getfp(); pthread_mutex_lock(&handler_stack_mutex_); - ExceptionHandler *current_handler = + ExceptionHandler* current_handler = handler_stack_->at(handler_stack_->size() - ++handler_stack_index_); pthread_mutex_unlock(&handler_stack_mutex_); // Restore original handler. current_handler->TeardownHandler(signo); - ucontext_t *sig_ctx = NULL; + ucontext_t* sig_ctx = NULL; if (current_handler->InternalWriteMinidump(signo, current_ebp, &sig_ctx)) { // if (current_handler->InternalWriteMinidump(signo, &sig_ctx)) { // Fully handled this exception, safe to exit. @@ -218,7 +218,7 @@ void ExceptionHandler::HandleException(int signo) { bool ExceptionHandler::InternalWriteMinidump(int signo, uintptr_t sighandler_ebp, - ucontext_t **sig_ctx) { + ucontext_t** sig_ctx) { if (filter_ && !filter_(callback_context_)) return false; diff --git a/src/client/solaris/handler/exception_handler.h b/src/client/solaris/handler/exception_handler.h index 4d72485f..cd6c85ea 100644 --- a/src/client/solaris/handler/exception_handler.h +++ b/src/client/solaris/handler/exception_handler.h @@ -79,7 +79,7 @@ class ExceptionHandler { // attempting to write a minidump. If a FilterCallback returns false, // Breakpad will immediately report the exception as unhandled without // writing a minidump, allowing another handler the opportunity to handle it. - typedef bool (*FilterCallback)(void *context); + typedef bool (*FilterCallback)(void* context); // A callback function to run after the minidump has been written. // minidump_id is a unique id for the dump, so the minidump @@ -97,9 +97,9 @@ class ExceptionHandler { // should normally return the value of |succeeded|, or when they wish to // not report an exception of handled, false. Callbacks will rarely want to // return true directly (unless |succeeded| is true). - typedef bool (*MinidumpCallback)(const char *dump_path, - const char *minidump_id, - void *context, + typedef bool (*MinidumpCallback)(const char* dump_path, + const char* minidump_id, + void* context, bool succeeded); // Creates a new ExceptionHandler instance to handle writing minidumps. @@ -110,15 +110,15 @@ class ExceptionHandler { // If install_handler is true, then a minidump will be written whenever // an unhandled exception occurs. If it is false, minidumps will only // be written when WriteMinidump is called. - ExceptionHandler(const string &dump_path, + ExceptionHandler(const string& dump_path, FilterCallback filter, MinidumpCallback callback, - void *callback_context, + void* callback_context, bool install_handler); ~ExceptionHandler(); // Get and Set the minidump path. string dump_path() const { return dump_path_; } - void set_dump_path(const string &dump_path) { + void set_dump_path(const string& dump_path) { dump_path_ = dump_path; dump_path_c_ = dump_path_.c_str(); } @@ -129,9 +129,9 @@ class ExceptionHandler { // Convenience form of WriteMinidump which does not require an // ExceptionHandler instance. - static bool WriteMinidump(const string &dump_path, + static bool WriteMinidump(const string& dump_path, MinidumpCallback callback, - void *callback_context); + void* callback_context); private: // Setup crash handler. @@ -144,7 +144,7 @@ class ExceptionHandler { void TeardownAllHandlers(); // Runs the main loop for the exception handler thread. - static void* ExceptionHandlerThreadMain(void *lpParameter); + static void* ExceptionHandlerThreadMain(void* lpParameter); // Signal handler. static void HandleException(int signo); @@ -157,20 +157,20 @@ class ExceptionHandler { // for the second and third parameters if you are not calling // this from a signal handler. bool InternalWriteMinidump(int signo, uintptr_t sighandler_ebp, - ucontext_t **sig_ctx); + ucontext_t** sig_ctx); private: // The callbacks before and after writing the dump file. FilterCallback filter_; MinidumpCallback callback_; - void *callback_context_; + void* callback_context_; // The directory in which a minidump will be written, set by the dump_path // argument to the constructor, or set_dump_path. string dump_path_; // C style dump path. Keep this when setting dump path, since calling // c_str() of std::string when crashing may not be safe. - const char *dump_path_c_; + const char* dump_path_c_; // True if the ExceptionHandler installed an unhandled exception filter // when created (with an install_handler parameter set to true). @@ -183,7 +183,7 @@ class ExceptionHandler { // The global exception handler stack. This is need becuase there may exist // multiple ExceptionHandler instances in a process. Each will have itself // registered in this stack. - static std::vector *handler_stack_; + static std::vector* handler_stack_; // The index of the handler that should handle the next exception. static int handler_stack_index_; static pthread_mutex_t handler_stack_mutex_; @@ -192,8 +192,8 @@ class ExceptionHandler { MinidumpGenerator minidump_generator_; // disallow copy ctor and operator= - explicit ExceptionHandler(const ExceptionHandler &); - void operator=(const ExceptionHandler &); + explicit ExceptionHandler(const ExceptionHandler&); + void operator=(const ExceptionHandler&); }; } // namespace google_breakpad diff --git a/src/client/solaris/handler/exception_handler_test.cc b/src/client/solaris/handler/exception_handler_test.cc index 6bb8e18d..4d2b33fa 100644 --- a/src/client/solaris/handler/exception_handler_test.cc +++ b/src/client/solaris/handler/exception_handler_test.cc @@ -49,7 +49,7 @@ static int foo2(int arg) { // Stack variable, used for debugging stack dumps. int c = 0xcccccccc; fprintf(stderr, "Thread trying to crash: %x\n", getpid()); - c = *reinterpret_cast(0x5); + c = *reinterpret_cast(0x5); return c; } @@ -60,7 +60,7 @@ static int foo(int arg) { return b; } -static void *thread_crash(void *) { +static void* thread_crash(void*) { // Stack variable, used for debugging stack dumps. int a = 0xaaaaaaaa; sleep(3); @@ -69,7 +69,7 @@ static void *thread_crash(void *) { return NULL; } -static void *thread_main(void *) { +static void* thread_main(void*) { while (!should_exit) sleep(1); return NULL; @@ -91,9 +91,9 @@ static void CreateThread(int num) { } // Callback when minidump written. -static bool MinidumpCallback(const char *dump_path, - const char *minidump_id, - void *context, +static bool MinidumpCallback(const char* dump_path, + const char* minidump_id, + void* context, bool succeeded) { int index = reinterpret_cast(context); if (index == 0) { @@ -104,7 +104,7 @@ static bool MinidumpCallback(const char *dump_path, return false; } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { int handler_index = 1; ExceptionHandler handler_ignore(".", NULL, MinidumpCallback, (void*)handler_index, true); diff --git a/src/client/solaris/handler/minidump_generator.cc b/src/client/solaris/handler/minidump_generator.cc index 7485025f..56756665 100644 --- a/src/client/solaris/handler/minidump_generator.cc +++ b/src/client/solaris/handler/minidump_generator.cc @@ -50,7 +50,7 @@ using namespace google_breakpad; // Argument for the writer function. struct WriterArgument { - MinidumpFileWriter *minidump_writer; + MinidumpFileWriter* minidump_writer; // Pid of the lwp who called WriteMinidumpToFile int requester_pid; @@ -73,15 +73,15 @@ struct WriterArgument { // User context when crash happens. Can be NULL if this is a requested dump. // This is actually an out parameter, but it will be filled in at the start // of the writer LWP. - ucontext_t *sig_ctx; + ucontext_t* sig_ctx; // Used to get information about the lwps. - SolarisLwp *lwp_lister; + SolarisLwp* lwp_lister; }; // Holding context information for the callback of finding the crashing lwp. struct FindCrashLwpContext { - const SolarisLwp *lwp_lister; + const SolarisLwp* lwp_lister; uintptr_t crashing_stack_bottom; int crashing_lwpid; @@ -96,11 +96,11 @@ struct FindCrashLwpContext { // It will compare the stack bottom of the provided lwp with the stack // bottom of the crashed lwp, it they are eqaul, this lwp is the one // who crashed. -bool IsLwpCrashedCallback(lwpstatus_t *lsp, void *context) { - FindCrashLwpContext *crashing_context = - static_cast(context); - const SolarisLwp *lwp_lister = crashing_context->lwp_lister; - const prgregset_t *gregs = &(lsp->pr_reg); +bool IsLwpCrashedCallback(lwpstatus_t* lsp, void* context) { + FindCrashLwpContext* crashing_context = + static_cast(context); + const SolarisLwp* lwp_lister = crashing_context->lwp_lister; + const prgregset_t* gregs = &(lsp->pr_reg); #if TARGET_CPU_SPARC uintptr_t last_ebp = (*gregs)[R_FP]; #elif TARGET_CPU_X86 @@ -121,7 +121,7 @@ bool IsLwpCrashedCallback(lwpstatus_t *lsp, void *context) { // This is done based on stack bottom comparing. int FindCrashingLwp(uintptr_t crashing_stack_bottom, int requester_pid, - const SolarisLwp *lwp_lister) { + const SolarisLwp* lwp_lister) { FindCrashLwpContext context; context.lwp_lister = lwp_lister; context.crashing_stack_bottom = crashing_stack_bottom; @@ -131,17 +131,17 @@ int FindCrashingLwp(uintptr_t crashing_stack_bottom, return context.crashing_lwpid; } -bool WriteLwpStack(const SolarisLwp *lwp_lister, +bool WriteLwpStack(const SolarisLwp* lwp_lister, uintptr_t last_esp, - UntypedMDRVA *memory, - MDMemoryDescriptor *loc) { + UntypedMDRVA* memory, + MDMemoryDescriptor* loc) { uintptr_t stack_bottom = lwp_lister->GetLwpStackBottom(last_esp); if (stack_bottom >= last_esp) { int size = stack_bottom - last_esp; if (size > 0) { if (!memory->Allocate(size)) return false; - memory->Copy(reinterpret_cast(last_esp), size); + memory->Copy(reinterpret_cast(last_esp), size); loc->start_of_memory_range = last_esp; loc->memory = memory->location(); } @@ -151,7 +151,7 @@ bool WriteLwpStack(const SolarisLwp *lwp_lister, } #if TARGET_CPU_SPARC -bool WriteContext(MDRawContextSPARC *context, ucontext_t *sig_ctx) { +bool WriteContext(MDRawContextSPARC* context, ucontext_t* sig_ctx) { assert(sig_ctx != NULL); int* regs = sig_ctx->uc_mcontext.gregs; context->context_flags = MD_CONTEXT_SPARC_FULL; @@ -170,13 +170,13 @@ bool WriteContext(MDRawContextSPARC *context, ucontext_t *sig_ctx) { for ( int i = 1 ; i < 16; ++i ) { context->g_r[i] = (uintptr_t)(sig_ctx->uc_mcontext.gregs[i + 3]); } - context->g_r[30] = (uintptr_t)(((struct frame *)context->g_r[14])->fr_savfp); + context->g_r[30] = (uintptr_t)(((struct frame*)context->g_r[14])->fr_savfp); return true; } -bool WriteContext(MDRawContextSPARC *context, prgregset_t regs, - prfpregset_t *fp_regs) { +bool WriteContext(MDRawContextSPARC* context, prgregset_t regs, + prfpregset_t* fp_regs) { if (!context || !regs) return false; @@ -195,8 +195,8 @@ bool WriteContext(MDRawContextSPARC *context, prgregset_t regs, return true; } #elif TARGET_CPU_X86 -bool WriteContext(MDRawContextX86 *context, prgregset_t regs, - prfpregset_t *fp_regs) { +bool WriteContext(MDRawContextX86* context, prgregset_t regs, + prfpregset_t* fp_regs) { if (!context || !regs) return false; @@ -228,10 +228,10 @@ bool WriteContext(MDRawContextX86 *context, prgregset_t regs, // signal. This makes the current stack not reliable, and our stack walker // won't figure out the whole call stack for this. So we write the stack at the // time of the crash into the minidump file, not the current stack. -bool WriteCrashedLwpStream(MinidumpFileWriter *minidump_writer, - const WriterArgument *writer_args, - const lwpstatus_t *lsp, - MDRawThread *lwp) { +bool WriteCrashedLwpStream(MinidumpFileWriter* minidump_writer, + const WriterArgument* writer_args, + const lwpstatus_t* lsp, + MDRawThread* lwp) { assert(writer_args->sig_ctx != NULL); lwp->thread_id = lsp->pr_lwpid; @@ -264,16 +264,16 @@ bool WriteCrashedLwpStream(MinidumpFileWriter *minidump_writer, lwp->thread_context = context.location(); memset(context.get(), 0, sizeof(MDRawContextX86)); return WriteContext(context.get(), - (int *)&writer_args->sig_ctx->uc_mcontext.gregs, + (int*)&writer_args->sig_ctx->uc_mcontext.gregs, &writer_args->sig_ctx->uc_mcontext.fpregs); #endif } -bool WriteLwpStream(MinidumpFileWriter *minidump_writer, - const SolarisLwp *lwp_lister, - const lwpstatus_t *lsp, MDRawThread *lwp) { +bool WriteLwpStream(MinidumpFileWriter* minidump_writer, + const SolarisLwp* lwp_lister, + const lwpstatus_t* lsp, MDRawThread* lwp) { prfpregset_t fp_regs = lsp->pr_fpreg; - const prgregset_t *gregs = &(lsp->pr_reg); + const prgregset_t* gregs = &(lsp->pr_reg); UntypedMDRVA memory(minidump_writer); #if TARGET_CPU_SPARC if (!WriteLwpStack(lwp_lister, @@ -306,10 +306,10 @@ bool WriteLwpStream(MinidumpFileWriter *minidump_writer, lwp->thread_context = context.location(); memset(context.get(), 0, sizeof(MDRawContextX86)); #endif /* TARGET_CPU_XXX */ - return WriteContext(context.get(), (int *)gregs, &fp_regs); + return WriteContext(context.get(), (int*)gregs, &fp_regs); } -bool WriteCPUInformation(MDRawSystemInfo *sys_info) { +bool WriteCPUInformation(MDRawSystemInfo* sys_info) { struct utsname uts; char *major, *minor, *build; @@ -337,8 +337,8 @@ bool WriteCPUInformation(MDRawSystemInfo *sys_info) { return true; } -bool WriteOSInformation(MinidumpFileWriter *minidump_writer, - MDRawSystemInfo *sys_info) { +bool WriteOSInformation(MinidumpFileWriter* minidump_writer, + MDRawSystemInfo* sys_info) { sys_info->platform_id = MD_OS_SOLARIS; struct utsname uts; @@ -346,7 +346,7 @@ bool WriteOSInformation(MinidumpFileWriter *minidump_writer, char os_version[512]; size_t space_left = sizeof(os_version); memset(os_version, 0, space_left); - const char *os_info_table[] = { + const char* os_info_table[] = { uts.sysname, uts.release, uts.version, @@ -354,7 +354,7 @@ bool WriteOSInformation(MinidumpFileWriter *minidump_writer, "OpenSolaris", NULL }; - for (const char **cur_os_info = os_info_table; + for (const char** cur_os_info = os_info_table; *cur_os_info != NULL; ++cur_os_info) { if (cur_os_info != os_info_table && space_left > 1) { @@ -379,21 +379,21 @@ bool WriteOSInformation(MinidumpFileWriter *minidump_writer, // Callback context for get writting lwp information. struct LwpInfoCallbackCtx { - MinidumpFileWriter *minidump_writer; - const WriterArgument *writer_args; - TypedMDRVA *list; + MinidumpFileWriter* minidump_writer; + const WriterArgument* writer_args; + TypedMDRVA* list; int lwp_index; }; -bool LwpInformationCallback(lwpstatus_t *lsp, void *context) { +bool LwpInformationCallback(lwpstatus_t* lsp, void* context) { bool success = true; - LwpInfoCallbackCtx *callback_context = - static_cast(context); + LwpInfoCallbackCtx* callback_context = + static_cast(context); // The current lwp is the one to handle the crash. Ignore it. if (lsp->pr_lwpid != pthread_self()) { - LwpInfoCallbackCtx *callback_context = - static_cast(context); + LwpInfoCallbackCtx* callback_context = + static_cast(context); MDRawThread lwp; memset(&lwp, 0, sizeof(MDRawThread)); @@ -417,11 +417,11 @@ bool LwpInformationCallback(lwpstatus_t *lsp, void *context) { return success; } -bool WriteLwpListStream(MinidumpFileWriter *minidump_writer, - const WriterArgument *writer_args, - MDRawDirectory *dir) { +bool WriteLwpListStream(MinidumpFileWriter* minidump_writer, + const WriterArgument* writer_args, + MDRawDirectory* dir) { // Get the lwp information. - const SolarisLwp *lwp_lister = writer_args->lwp_lister; + const SolarisLwp* lwp_lister = writer_args->lwp_lister; int lwp_count = lwp_lister->GetLwpCount(); if (lwp_count < 0) return false; @@ -444,14 +444,14 @@ bool WriteLwpListStream(MinidumpFileWriter *minidump_writer, return written == lwp_count; } -bool WriteCVRecord(MinidumpFileWriter *minidump_writer, - MDRawModule *module, - const char *module_path, - char *realname) { +bool WriteCVRecord(MinidumpFileWriter* minidump_writer, + MDRawModule* module, + const char* module_path, + char* realname) { TypedMDRVA cv(minidump_writer); char path[PATH_MAX]; - const char *module_name = module_path ? module_path : ""; + const char* module_name = module_path ? module_path : ""; snprintf(path, sizeof(path), "/proc/self/object/%s", module_name); size_t module_name_length = strlen(realname); @@ -461,7 +461,7 @@ bool WriteCVRecord(MinidumpFileWriter *minidump_writer, return false; module->cv_record = cv.location(); - MDCVInfoPDB70 *cv_ptr = cv.get(); + MDCVInfoPDB70* cv_ptr = cv.get(); memset(cv_ptr, 0, sizeof(MDCVInfoPDB70)); cv_ptr->cv_signature = MD_CVINFOPDB70_SIGNATURE; cv_ptr->age = 0; @@ -489,15 +489,15 @@ bool WriteCVRecord(MinidumpFileWriter *minidump_writer, } struct ModuleInfoCallbackCtx { - MinidumpFileWriter *minidump_writer; - const WriterArgument *writer_args; - TypedMDRVA *list; + MinidumpFileWriter* minidump_writer; + const WriterArgument* writer_args; + TypedMDRVA* list; int module_index; }; -bool ModuleInfoCallback(const ModuleInfo &module_info, void *context) { - ModuleInfoCallbackCtx *callback_context = - static_cast(context); +bool ModuleInfoCallback(const ModuleInfo& module_info, void* context) { + ModuleInfoCallbackCtx* callback_context = + static_cast(context); // Skip those modules without name, or those that are not modules. if (strlen(module_info.name) == 0) return true; @@ -507,7 +507,7 @@ bool ModuleInfoCallback(const ModuleInfo &module_info, void *context) { MDLocationDescriptor loc; char path[PATH_MAX]; char buf[PATH_MAX]; - char *realname; + char* realname; int count; snprintf(path, sizeof (path), "/proc/self/path/%s", module_info.name); @@ -535,9 +535,9 @@ bool ModuleInfoCallback(const ModuleInfo &module_info, void *context) { return true; } -bool WriteModuleListStream(MinidumpFileWriter *minidump_writer, - const WriterArgument *writer_args, - MDRawDirectory *dir) { +bool WriteModuleListStream(MinidumpFileWriter* minidump_writer, + const WriterArgument* writer_args, + MDRawDirectory* dir) { TypedMDRVA list(minidump_writer); int module_count = writer_args->lwp_lister->GetModuleCount(); @@ -558,9 +558,9 @@ bool WriteModuleListStream(MinidumpFileWriter *minidump_writer, return writer_args->lwp_lister->ListModules(&callback) == module_count; } -bool WriteSystemInfoStream(MinidumpFileWriter *minidump_writer, - const WriterArgument *writer_args, - MDRawDirectory *dir) { +bool WriteSystemInfoStream(MinidumpFileWriter* minidump_writer, + const WriterArgument* writer_args, + MDRawDirectory* dir) { TypedMDRVA sys_info(minidump_writer); if (!sys_info.Allocate()) @@ -573,9 +573,9 @@ bool WriteSystemInfoStream(MinidumpFileWriter *minidump_writer, WriteOSInformation(minidump_writer, sys_info.get()); } -bool WriteExceptionStream(MinidumpFileWriter *minidump_writer, - const WriterArgument *writer_args, - MDRawDirectory *dir) { +bool WriteExceptionStream(MinidumpFileWriter* minidump_writer, + const WriterArgument* writer_args, + MDRawDirectory* dir) { // This happenes when this is not a crash, but a requested dump. if (writer_args->sig_ctx == NULL) return false; @@ -620,14 +620,14 @@ bool WriteExceptionStream(MinidumpFileWriter *minidump_writer, exception.get()->thread_context = context.location(); memset(context.get(), 0, sizeof(MDRawContextX86)); return WriteContext(context.get(), - (int *)&writer_args->sig_ctx->uc_mcontext.gregs, + (int*)&writer_args->sig_ctx->uc_mcontext.gregs, NULL); #endif } -bool WriteMiscInfoStream(MinidumpFileWriter *minidump_writer, - const WriterArgument *writer_args, - MDRawDirectory *dir) { +bool WriteMiscInfoStream(MinidumpFileWriter* minidump_writer, + const WriterArgument* writer_args, + MDRawDirectory* dir) { TypedMDRVA info(minidump_writer); if (!info.Allocate()) @@ -642,9 +642,9 @@ bool WriteMiscInfoStream(MinidumpFileWriter *minidump_writer, return true; } -bool WriteBreakpadInfoStream(MinidumpFileWriter *minidump_writer, - const WriterArgument *writer_args, - MDRawDirectory *dir) { +bool WriteBreakpadInfoStream(MinidumpFileWriter* minidump_writer, + const WriterArgument* writer_args, + MDRawDirectory* dir) { TypedMDRVA info(minidump_writer); if (!info.Allocate()) @@ -662,16 +662,16 @@ bool WriteBreakpadInfoStream(MinidumpFileWriter *minidump_writer, class AutoLwpResumer { public: - AutoLwpResumer(SolarisLwp *lwp) : lwp_(lwp) {} + AutoLwpResumer(SolarisLwp* lwp) : lwp_(lwp) {} ~AutoLwpResumer() { lwp_->ControlAllLwps(false); } private: - SolarisLwp *lwp_; + SolarisLwp* lwp_; }; // Prototype of writer functions. -typedef bool (*WriteStreamFN)(MinidumpFileWriter *, - const WriterArgument *, - MDRawDirectory *); +typedef bool (*WriteStreamFN)(MinidumpFileWriter*, + const WriterArgument*, + MDRawDirectory*); // Function table to writer a full minidump. const WriteStreamFN writers[] = { @@ -684,9 +684,9 @@ const WriteStreamFN writers[] = { }; // Will call each writer function in the writers table. -//void* MinidumpGenerator::Write(void *argument) { -void* Write(void *argument) { - WriterArgument *writer_args = static_cast(argument); +//void* MinidumpGenerator::Write(void* argument) { +void* Write(void* argument) { + WriterArgument* writer_args = static_cast(argument); if (!writer_args->lwp_lister->ControlAllLwps(true)) return NULL; @@ -712,7 +712,7 @@ void* Write(void *argument) { writer_args->crashed_lwpid = crashed_lwpid; } - MinidumpFileWriter *minidump_writer = writer_args->minidump_writer; + MinidumpFileWriter* minidump_writer = writer_args->minidump_writer; TypedMDRVA header(minidump_writer); TypedMDRVA dir(minidump_writer); if (!header.Allocate()) @@ -750,10 +750,10 @@ MinidumpGenerator::~MinidumpGenerator() { // Write minidump into file. // It runs in a different thread from the crashing thread. -bool MinidumpGenerator::WriteMinidumpToFile(const char *file_pathname, +bool MinidumpGenerator::WriteMinidumpToFile(const char* file_pathname, int signo, uintptr_t sighandler_ebp, - ucontext_t **sig_ctx) const { + ucontext_t** sig_ctx) const { // The exception handler thread. pthread_t handler_thread; @@ -775,7 +775,7 @@ bool MinidumpGenerator::WriteMinidumpToFile(const char *file_pathname, argument.sighandler_ebp = sighandler_ebp; argument.sig_ctx = NULL; - pthread_create(&handler_thread, NULL, Write, (void *)&argument); + pthread_create(&handler_thread, NULL, Write, (void*)&argument); pthread_join(handler_thread, NULL); return true; } diff --git a/src/client/solaris/handler/minidump_generator.h b/src/client/solaris/handler/minidump_generator.h index 882f9e1d..daa6fe01 100644 --- a/src/client/solaris/handler/minidump_generator.h +++ b/src/client/solaris/handler/minidump_generator.h @@ -48,10 +48,10 @@ namespace google_breakpad { // class MinidumpGenerator { // Callback run for writing lwp information in the process. - friend bool LwpInformationCallback(lwpstatus_t *lsp, void *context); + friend bool LwpInformationCallback(lwpstatus_t* lsp, void* context); // Callback run for writing module information in the process. - friend bool ModuleInfoCallback(const ModuleInfo &module_info, void *context); + friend bool ModuleInfoCallback(const ModuleInfo& module_info, void* context); public: MinidumpGenerator(); @@ -59,10 +59,10 @@ class MinidumpGenerator { ~MinidumpGenerator(); // Write minidump. - bool WriteMinidumpToFile(const char *file_pathname, + bool WriteMinidumpToFile(const char* file_pathname, int signo, uintptr_t sighandler_ebp, - ucontext_t **sig_ctx) const; + ucontext_t** sig_ctx) const; }; } // namespace google_breakpad diff --git a/src/client/solaris/handler/minidump_test.cc b/src/client/solaris/handler/minidump_test.cc index 33302d86..5f685ef2 100644 --- a/src/client/solaris/handler/minidump_test.cc +++ b/src/client/solaris/handler/minidump_test.cc @@ -40,7 +40,7 @@ using google_breakpad::MinidumpGenerator; static bool doneWritingReport = false; -static void *Reporter(void *) { +static void* Reporter(void*) { char buffer[PATH_MAX]; MinidumpGenerator md; diff --git a/src/client/solaris/handler/solaris_lwp.cc b/src/client/solaris/handler/solaris_lwp.cc index 0148997a..cb6cc8ab 100644 --- a/src/client/solaris/handler/solaris_lwp.cc +++ b/src/client/solaris/handler/solaris_lwp.cc @@ -69,10 +69,10 @@ struct AddressValidatingContext { }; // Convert from string to int. -static bool LocalAtoi(char *s, int *r) { +static bool LocalAtoi(char* s, int* r) { assert(s != NULL); assert(r != NULL); - char *endptr = NULL; + char* endptr = NULL; int ret = strtol(s, &endptr, 10); if (endptr == s) return false; @@ -82,10 +82,10 @@ static bool LocalAtoi(char *s, int *r) { // Callback invoked for each mapped module. // It uses the module's adderss range to validate the address. -static bool AddressNotInModuleCallback(const ModuleInfo &module_info, - void *context) { - AddressValidatingContext *addr = - reinterpret_cast(context); +static bool AddressNotInModuleCallback(const ModuleInfo& module_info, + void* context) { + AddressValidatingContext* addr = + reinterpret_cast(context); if (addr->is_mapped = ((module_info.start_addr > 0) && (addr->address >= module_info.start_addr) && (addr->address <= module_info.start_addr + @@ -97,16 +97,16 @@ static bool AddressNotInModuleCallback(const ModuleInfo &module_info, } static int IterateLwpAll(int pid, - CallbackParam *callback_param) { + CallbackParam* callback_param) { char lwp_path[40]; - DIR *dir; + DIR* dir; int count = 0; snprintf(lwp_path, sizeof (lwp_path), "/proc/%d/lwp", (int)pid); if ((dir = opendir(lwp_path)) == NULL) return -1; - struct dirent *entry = NULL; + struct dirent* entry = NULL; while ((entry = readdir(dir)) != NULL) { if ((strcmp(entry->d_name, ".") != 0) && (strcmp(entry->d_name, "..") != 0)) { @@ -128,22 +128,22 @@ static int IterateLwpAll(int pid, } #if defined(__i386) && !defined(NO_FRAME_POINTER) -void *GetNextFrame(void **last_ebp) { - void *sp = *last_ebp; +void* GetNextFrame(void** last_ebp) { + void* sp = *last_ebp; if ((unsigned long)sp == (unsigned long)last_ebp) return NULL; - if ((unsigned long)sp & (sizeof(void *) - 1)) + if ((unsigned long)sp & (sizeof(void*) - 1)) return NULL; if ((unsigned long)sp - (unsigned long)last_ebp > 100000) return NULL; return sp; } #elif defined(__sparc) -void *GetNextFrame(void *last_ebp) { - return reinterpret_cast(last_ebp)->fr_savfp; +void* GetNextFrame(void* last_ebp) { + return reinterpret_cast(last_ebp)->fr_savfp; } #else -void *GetNextFrame(void **last_ebp) { +void* GetNextFrame(void** last_ebp) { return reinterpret_cast(last_ebp); } #endif @@ -159,12 +159,12 @@ class AutoCloser { // Control the execution of the lwp. // Suspend/Resume lwp based on the value of context. -static bool ControlLwp(int lwpid, void *context) { +static bool ControlLwp(int lwpid, void* context) { // The current thread is the one to handle the crash. Ignore it. if (lwpid != pthread_self()) { int ctlfd; char procname[PATH_MAX]; - bool suspend = *(bool *)context; + bool suspend = *(bool*)context; // Open the /proc/$pid/lwp/$lwpid/lwpctl files snprintf(procname, sizeof (procname), "/proc/self/lwp/%d/lwpctl", lwpid); @@ -193,7 +193,7 @@ static bool ControlLwp(int lwpid, void *context) { * prheader_t at the start (/proc/$pid/lstatus or /proc/$pid/lpsinfo). * Return true on success. */ -static bool read_lfile(int pid, const char *lname, prheader_t *lhp) { +static bool read_lfile(int pid, const char* lname, prheader_t* lhp) { char lpath[PATH_MAX]; struct stat statb; int fd; @@ -242,14 +242,14 @@ int SolarisLwp::GetLwpCount() const { } int SolarisLwp::Lwp_iter_all(int pid, - CallbackParam *callback_param) const { - lwpstatus_t *Lsp; - lwpstatus_t *sp; + CallbackParam* callback_param) const { + lwpstatus_t* Lsp; + lwpstatus_t* sp; prheader_t lphp[HEADER_MAX]; prheader_t lhp[HEADER_MAX]; - prheader_t *Lphp = lphp; - prheader_t *Lhp = lhp; - lwpsinfo_t *Lpsp; + prheader_t* Lphp = lphp; + prheader_t* Lhp = lhp; + lwpsinfo_t* Lpsp; long nstat; long ninfo; int rv = 0; @@ -264,13 +264,13 @@ int SolarisLwp::Lwp_iter_all(int pid, return -1; } - Lsp = (lwpstatus_t *)(uintptr_t)(Lhp + 1); - Lpsp = (lwpsinfo_t *)(uintptr_t)(Lphp + 1); + Lsp = (lwpstatus_t*)(uintptr_t)(Lhp + 1); + Lpsp = (lwpsinfo_t*)(uintptr_t)(Lphp + 1); for (ninfo = Lphp->pr_nent; ninfo != 0; --ninfo) { if (Lpsp->pr_sname != 'Z') { sp = Lsp; - Lsp = (lwpstatus_t *)((uintptr_t)Lsp + Lhp->pr_entsize); + Lsp = (lwpstatus_t*)((uintptr_t)Lsp + Lhp->pr_entsize); } else { sp = NULL; } @@ -278,7 +278,7 @@ int SolarisLwp::Lwp_iter_all(int pid, !(callback_param->call_back)(sp, callback_param->context)) break; ++rv; - Lpsp = (lwpsinfo_t *)((uintptr_t)Lpsp + Lphp->pr_entsize); + Lpsp = (lwpsinfo_t*)((uintptr_t)Lpsp + Lphp->pr_entsize); } return rv; @@ -298,12 +298,12 @@ int SolarisLwp::GetModuleCount() const { } int SolarisLwp::ListModules( - CallbackParam *callback_param) const { - const char *maps_path = "/proc/self/map"; + CallbackParam* callback_param) const { + const char* maps_path = "/proc/self/map"; struct stat status; int fd = 0, num; prmap_t map_array[MAP_MAX]; - prmap_t *maps = map_array; + prmap_t* maps = map_array; size_t size; if ((fd = open(maps_path, O_RDONLY)) == -1) { @@ -326,12 +326,12 @@ int SolarisLwp::ListModules( return -1; } - if (read(fd, (void *)maps, size) < 0) { + if (read(fd, (void*)maps, size) < 0) { print_message2(2, "failed to read %d\n", fd); return -1; } - prmap_t *_maps; + prmap_t* _maps; int _num; int module_count = 0; @@ -345,7 +345,7 @@ int SolarisLwp::ListModules( */ for (_num = 0, _maps = maps; _num < num; ++_num, ++_maps) { ModuleInfo module; - char *name = _maps->pr_mapname; + char* name = _maps->pr_mapname; memset(&module, 0, sizeof (module)); module.start_addr = _maps->pr_vaddr; @@ -403,7 +403,7 @@ bool SolarisLwp::IsAddressMapped(uintptr_t address) const { // The Solaris stack looks like this: // http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/lib/libproc/common/Pstack.c#81 bool SolarisLwp::FindSigContext(uintptr_t sighandler_ebp, - ucontext_t **sig_ctx) { + ucontext_t** sig_ctx) { uintptr_t previous_ebp; uintptr_t sig_ebp; const int MAX_STACK_DEPTH = 50; @@ -416,7 +416,7 @@ bool SolarisLwp::FindSigContext(uintptr_t sighandler_ebp, *sig_ctx = reinterpret_cast(sighandler_ebp + sizeof (struct frame)); uintptr_t sig_esp = (*sig_ctx)->uc_mcontext.gregs[REG_O6]; if (sig_esp < previous_ebp && sig_esp > sighandler_ebp) - sig_ebp = (uintptr_t)(((struct frame *)sig_esp)->fr_savfp); + sig_ebp = (uintptr_t)(((struct frame*)sig_esp)->fr_savfp); #elif TARGET_CPU_X86 previous_ebp = reinterpret_cast(GetNextFrame( diff --git a/src/client/solaris/handler/solaris_lwp.h b/src/client/solaris/handler/solaris_lwp.h index 0914cfcd..afe352ce 100644 --- a/src/client/solaris/handler/solaris_lwp.h +++ b/src/client/solaris/handler/solaris_lwp.h @@ -70,17 +70,17 @@ struct ModuleInfo { // A callback to run when getting a lwp in the process. // Return true will go on to the next lwp while return false will stop the // iteration. -typedef bool (*LwpCallback)(lwpstatus_t* lsp, void *context); +typedef bool (*LwpCallback)(lwpstatus_t* lsp, void* context); // A callback to run when a new module is found in the process. // Return true will go on to the next module while return false will stop the // iteration. -typedef bool (*ModuleCallback)(const ModuleInfo &module_info, void *context); +typedef bool (*ModuleCallback)(const ModuleInfo& module_info, void* context); // A callback to run when getting a lwpid in the process. // Return true will go on to the next lwp while return false will stop the // iteration. -typedef bool (*LwpidCallback)(int lwpid, void *context); +typedef bool (*LwpidCallback)(int lwpid, void* context); // Holding the callback information. template @@ -88,12 +88,12 @@ struct CallbackParam { // Callback function address. CallbackFunc call_back; // Callback context; - void *context; + void* context; CallbackParam() : call_back(NULL), context(NULL) { } - CallbackParam(CallbackFunc func, void *func_context) : + CallbackParam(CallbackFunc func, void* func_context) : call_back(func), context(func_context) { } }; @@ -129,7 +129,7 @@ class SolarisLwp { // Whenever there is a lwp found, the callback will be invoked to process // the information. // Return the callback return value or -1 on error. - int Lwp_iter_all(int pid, CallbackParam *callback_param) const; + int Lwp_iter_all(int pid, CallbackParam* callback_param) const; // Get the module count of the current process. int GetModuleCount() const; @@ -138,13 +138,13 @@ class SolarisLwp { // Whenever a module is found, the callback will be invoked to process the // information. // Return how may modules are found. - int ListModules(CallbackParam *callback_param) const; + int ListModules(CallbackParam* callback_param) const; // Get the bottom of the stack from esp. uintptr_t GetLwpStackBottom(uintptr_t current_esp) const; // Finds a signal context on the stack given the ebp of our signal handler. - bool FindSigContext(uintptr_t sighandler_ebp, ucontext_t **sig_ctx); + bool FindSigContext(uintptr_t sighandler_ebp, ucontext_t** sig_ctx); private: // Check if the address is a valid virtual address. diff --git a/src/client/windows/handler/exception_handler.cc b/src/client/windows/handler/exception_handler.cc index ad45b200..20d63a84 100644 --- a/src/client/windows/handler/exception_handler.cc +++ b/src/client/windows/handler/exception_handler.cc @@ -118,7 +118,7 @@ ExceptionHandler::ExceptionHandler( NULL); // custom_info - not used } -ExceptionHandler::ExceptionHandler(const wstring &dump_path, +ExceptionHandler::ExceptionHandler(const wstring& dump_path, FilterCallback filter, MinidumpCallback callback, void* callback_context, @@ -383,7 +383,7 @@ bool ExceptionHandler::RequestUpload(DWORD crash_id) { // static DWORD ExceptionHandler::ExceptionHandlerThreadMain(void* lpParameter) { - ExceptionHandler* self = reinterpret_cast(lpParameter); + ExceptionHandler* self = reinterpret_cast(lpParameter); assert(self); assert(self->handler_start_semaphore_ != NULL); assert(self->handler_finish_semaphore_ != NULL); @@ -765,7 +765,7 @@ bool ExceptionHandler::WriteMinidumpForException(EXCEPTION_POINTERS* exinfo) { } // static -bool ExceptionHandler::WriteMinidump(const wstring &dump_path, +bool ExceptionHandler::WriteMinidump(const wstring& dump_path, MinidumpCallback callback, void* callback_context, MINIDUMP_TYPE dump_type) { diff --git a/src/client/windows/handler/exception_handler.h b/src/client/windows/handler/exception_handler.h index 11babe51..eb5adaac 100644 --- a/src/client/windows/handler/exception_handler.h +++ b/src/client/windows/handler/exception_handler.h @@ -218,7 +218,7 @@ class ExceptionHandler { // Get and set the minidump path. wstring dump_path() const { return dump_path_; } - void set_dump_path(const wstring &dump_path) { + void set_dump_path(const wstring& dump_path) { dump_path_ = dump_path; dump_path_c_ = dump_path_.c_str(); UpdateNextID(); // Necessary to put dump_path_ in next_minidump_path_. @@ -237,7 +237,7 @@ class ExceptionHandler { // Convenience form of WriteMinidump which does not require an // ExceptionHandler instance. - static bool WriteMinidump(const wstring &dump_path, + static bool WriteMinidump(const wstring& dump_path, MinidumpCallback callback, void* callback_context, MINIDUMP_TYPE dump_type = MiniDumpNormal); @@ -513,8 +513,8 @@ class ExceptionHandler { static volatile LONG instance_count_; // disallow copy ctor and operator= - explicit ExceptionHandler(const ExceptionHandler &); - void operator=(const ExceptionHandler &); + explicit ExceptionHandler(const ExceptionHandler&); + void operator=(const ExceptionHandler&); }; } // namespace google_breakpad diff --git a/src/client/windows/sender/crash_report_sender.cc b/src/client/windows/sender/crash_report_sender.cc index eb2b422a..7fc64483 100644 --- a/src/client/windows/sender/crash_report_sender.cc +++ b/src/client/windows/sender/crash_report_sender.cc @@ -45,12 +45,12 @@ namespace google_breakpad { static const char kCheckpointSignature[] = "GBP1\n"; -CrashReportSender::CrashReportSender(const wstring &checkpoint_file) +CrashReportSender::CrashReportSender(const wstring& checkpoint_file) : checkpoint_file_(checkpoint_file), max_reports_per_day_(-1), last_sent_date_(-1), reports_sent_(0) { - FILE *fd; + FILE* fd; if (OpenCheckpointFile(L"r", &fd) == 0) { ReadCheckpoint(fd); fclose(fd); @@ -58,8 +58,8 @@ CrashReportSender::CrashReportSender(const wstring &checkpoint_file) } ReportResult CrashReportSender::SendCrashReport( - const wstring &url, const map ¶meters, - const map &files, wstring *report_code) { + const wstring& url, const map& parameters, + const map& files, wstring* report_code) { int today = GetCurrentDate(); if (today == last_sent_date_ && max_reports_per_day_ != -1 && @@ -82,7 +82,7 @@ ReportResult CrashReportSender::SendCrashReport( } } -void CrashReportSender::ReadCheckpoint(FILE *fd) { +void CrashReportSender::ReadCheckpoint(FILE* fd) { char buf[128]; if (!fgets(buf, sizeof(buf), fd) || strcmp(buf, kCheckpointSignature) != 0) { @@ -108,7 +108,7 @@ void CrashReportSender::ReportSent(int today) { ++reports_sent_; // Update the checkpoint file - FILE *fd; + FILE* fd; if (OpenCheckpointFile(L"w", &fd) == 0) { fputs(kCheckpointSignature, fd); fprintf(fd, "%d\n", last_sent_date_); @@ -124,7 +124,7 @@ int CrashReportSender::GetCurrentDate() const { system_time.wDay; } -int CrashReportSender::OpenCheckpointFile(const wchar_t *mode, FILE **fd) { +int CrashReportSender::OpenCheckpointFile(const wchar_t* mode, FILE** fd) { if (checkpoint_file_.empty()) { return ENOENT; } diff --git a/src/client/windows/sender/crash_report_sender.h b/src/client/windows/sender/crash_report_sender.h index 7786cc69..e6055857 100644 --- a/src/client/windows/sender/crash_report_sender.h +++ b/src/client/windows/sender/crash_report_sender.h @@ -65,7 +65,7 @@ class CrashReportSender { // If checkpoint_file is non-empty, breakpad will persist crash report // state to this file. A checkpoint file is required for // set_max_reports_per_day() to function properly. - explicit CrashReportSender(const wstring &checkpoint_file); + explicit CrashReportSender(const wstring& checkpoint_file); ~CrashReportSender() {} // Sets the maximum number of crash reports that will be sent in a 24-hour @@ -87,14 +87,14 @@ class CrashReportSender { // the return value is RESULT_SUCCEEDED), a code uniquely identifying the // report will be returned in report_code. // (Otherwise, report_code will be unchanged.) - ReportResult SendCrashReport(const wstring &url, - const map ¶meters, - const map &files, - wstring *report_code); + ReportResult SendCrashReport(const wstring& url, + const map& parameters, + const map& files, + wstring* report_code); private: // Reads persistent state from a checkpoint file. - void ReadCheckpoint(FILE *fd); + void ReadCheckpoint(FILE* fd); // Called when a new report has been sent, to update the checkpoint state. void ReportSent(int today); @@ -104,7 +104,7 @@ class CrashReportSender { // Opens the checkpoint file with the specified mode. // Returns zero on success, or an error code on failure. - int OpenCheckpointFile(const wchar_t *mode, FILE **fd); + int OpenCheckpointFile(const wchar_t* mode, FILE** fd); wstring checkpoint_file_; int max_reports_per_day_; @@ -114,8 +114,8 @@ class CrashReportSender { int reports_sent_; // Disallow copy constructor and operator= - explicit CrashReportSender(const CrashReportSender &); - void operator=(const CrashReportSender &); + explicit CrashReportSender(const CrashReportSender&); + void operator=(const CrashReportSender&); }; } // namespace google_breakpad diff --git a/src/client/windows/unittests/dump_analysis.cc b/src/client/windows/unittests/dump_analysis.cc index 53d4ddbd..0bb8f6c4 100644 --- a/src/client/windows/unittests/dump_analysis.cc +++ b/src/client/windows/unittests/dump_analysis.cc @@ -127,8 +127,8 @@ size_t DumpAnalysis::GetStreamImpl(ULONG stream_number, void** stream) const { return ret ? memory_list_size : 0; } -bool DumpAnalysis::HasMemoryImpl(const void *addr_in, size_t structuresize, - void **structure) const { +bool DumpAnalysis::HasMemoryImpl(const void* addr_in, size_t structuresize, + void** structure) const { uintptr_t address = reinterpret_cast(addr_in); MINIDUMP_MEMORY_LIST* memory_list = NULL; size_t memory_list_size = GetStream(MemoryListStream, &memory_list); diff --git a/src/client/windows/unittests/exception_handler_death_test.cc b/src/client/windows/unittests/exception_handler_death_test.cc index 5ef9e64d..04034e8d 100644 --- a/src/client/windows/unittests/exception_handler_death_test.cc +++ b/src/client/windows/unittests/exception_handler_death_test.cc @@ -52,7 +52,7 @@ const char kSuccessIndicator[] = "success"; const char kFailureIndicator[] = "failure"; // Utility function to test for a path's existence. -BOOL DoesPathExist(const TCHAR *path_name); +BOOL DoesPathExist(const TCHAR* path_name); enum OutOfProcGuarantee { OUT_OF_PROC_GUARANTEED, @@ -92,7 +92,7 @@ void ExceptionHandlerDeathTest::SetUp() { CreateDirectory(temp_path_, NULL); } -BOOL DoesPathExist(const TCHAR *path_name) { +BOOL DoesPathExist(const TCHAR* path_name) { DWORD flags = GetFileAttributes(path_name); if (flags == INVALID_FILE_ATTRIBUTES) { return FALSE; @@ -135,15 +135,15 @@ TEST_F(ExceptionHandlerDeathTest, InProcTest) { // Disable GTest SEH handler testing::DisableExceptionHandlerInScope disable_exception_handler; - int *i = NULL; + int* i = NULL; ASSERT_DEATH((*i)++, kSuccessIndicator); } static bool gDumpCallbackCalled = false; -void clientDumpCallback(void *dump_context, - const google_breakpad::ClientInfo *client_info, - const std::wstring *dump_path) { +void clientDumpCallback(void* dump_context, + const google_breakpad::ClientInfo* client_info, + const std::wstring* dump_path) { gDumpCallbackCalled = true; } @@ -152,7 +152,7 @@ void ExceptionHandlerDeathTest::DoCrashAccessViolation( scoped_ptr exc; if (out_of_proc_guarantee == OUT_OF_PROC_GUARANTEED) { - google_breakpad::CrashGenerationClient *client = + google_breakpad::CrashGenerationClient* client = new google_breakpad::CrashGenerationClient(kPipeName, MiniDumpNormal, NULL); // custom_info @@ -184,7 +184,7 @@ void ExceptionHandlerDeathTest::DoCrashAccessViolation( // if it's not true we'll still get an error rather than the crash // being expected. ASSERT_TRUE(exc->IsOutOfProcess()); - int *i = NULL; + int* i = NULL; printf("%d\n", (*i)++); } @@ -283,7 +283,7 @@ TEST_F(ExceptionHandlerDeathTest, PureVirtualCallTest) { EXPECT_EXIT(DoCrashPureVirtualCall(), ::testing::ExitedWithCode(0), ""); } -wstring find_minidump_in_directory(const wstring &directory) { +wstring find_minidump_in_directory(const wstring& directory) { wstring search_path = directory + L"\\*"; WIN32_FIND_DATA find_data; HANDLE find_handle = FindFirstFileW(search_path.c_str(), &find_data); diff --git a/src/client/windows/unittests/exception_handler_nesting_test.cc b/src/client/windows/unittests/exception_handler_nesting_test.cc index 3ae1d7cd..e24bd18b 100644 --- a/src/client/windows/unittests/exception_handler_nesting_test.cc +++ b/src/client/windows/unittests/exception_handler_nesting_test.cc @@ -49,7 +49,7 @@ const char kFilterReturnsFalse[] = "filter_returns_false"; const char kCallbackReturnsTrue[] = "callback_returns_true"; const char kCallbackReturnsFalse[] = "callback_returns_false"; -bool DoesPathExist(const wchar_t *path_name) { +bool DoesPathExist(const wchar_t* path_name) { DWORD flags = GetFileAttributes(path_name); if (flags == INVALID_FILE_ATTRIBUTES) { return false; @@ -128,12 +128,12 @@ bool MinidumpWrittenCallback(const wchar_t* dump_path, } -void DoCrash(const char *message) { +void DoCrash(const char* message) { if (message) { fprintf(stderr, "%s", message); fflush(stderr); } - int *i = NULL; + int* i = NULL; (*i)++; ASSERT_TRUE(false); diff --git a/src/client/windows/unittests/exception_handler_test.cc b/src/client/windows/unittests/exception_handler_test.cc index a4ce12a8..51196ca0 100644 --- a/src/client/windows/unittests/exception_handler_test.cc +++ b/src/client/windows/unittests/exception_handler_test.cc @@ -87,13 +87,13 @@ class ExceptionHandlerTest : public ::testing::Test { void DoCrashPureVirtualCall(); // Utility function to test for a path's existence. - static BOOL DoesPathExist(const TCHAR *path_name); + static BOOL DoesPathExist(const TCHAR* path_name); // Client callback. static void ClientDumpCallback( - void *dump_context, - const google_breakpad::ClientInfo *client_info, - const std::wstring *dump_path); + void* dump_context, + const google_breakpad::ClientInfo* client_info, + const std::wstring* dump_path); static bool DumpCallback(const wchar_t* dump_path, const wchar_t* minidump_id, @@ -141,7 +141,7 @@ void ExceptionHandlerTest::TearDown() { } } -BOOL ExceptionHandlerTest::DoesPathExist(const TCHAR *path_name) { +BOOL ExceptionHandlerTest::DoesPathExist(const TCHAR* path_name) { DWORD flags = GetFileAttributes(path_name); if (flags == INVALID_FILE_ATTRIBUTES) { return FALSE; @@ -151,9 +151,9 @@ BOOL ExceptionHandlerTest::DoesPathExist(const TCHAR *path_name) { // static void ExceptionHandlerTest::ClientDumpCallback( - void *dump_context, - const google_breakpad::ClientInfo *client_info, - const wstring *dump_path) { + void* dump_context, + const google_breakpad::ClientInfo* client_info, + const wstring* dump_path) { dump_file = *dump_path; // Create the full dump file name from the dump path. full_dump_file = dump_file.substr(0, dump_file.length() - 4) + L"-full.dmp"; @@ -174,7 +174,7 @@ bool ExceptionHandlerTest::DumpCallback(const wchar_t* dump_path, } void ExceptionHandlerTest::DoCrashInvalidParameter() { - google_breakpad::ExceptionHandler *exc = + google_breakpad::ExceptionHandler* exc = new google_breakpad::ExceptionHandler( temp_path_, NULL, NULL, NULL, google_breakpad::ExceptionHandler::HANDLER_INVALID_PARAMETER, @@ -206,7 +206,7 @@ struct PureVirtualCall : public PureVirtualCallBase { }; void ExceptionHandlerTest::DoCrashPureVirtualCall() { - google_breakpad::ExceptionHandler *exc = + google_breakpad::ExceptionHandler* exc = new google_breakpad::ExceptionHandler( temp_path_, NULL, NULL, NULL, google_breakpad::ExceptionHandler::HANDLER_PURECALL, diff --git a/src/common/android/testing/pthread_fixes.h b/src/common/android/testing/pthread_fixes.h index 20c12084..b0a3d82e 100644 --- a/src/common/android/testing/pthread_fixes.h +++ b/src/common/android/testing/pthread_fixes.h @@ -80,7 +80,7 @@ int pthread_barrier_wait(pthread_barrier_t* barrier) { return 0; } -int pthread_barrier_destroy(pthread_barrier_t *barrier) { +int pthread_barrier_destroy(pthread_barrier_t* barrier) { barrier->count = 0; pthread_cond_destroy(&barrier->cond); pthread_mutex_destroy(&barrier->mutex); diff --git a/src/common/byte_cursor.h b/src/common/byte_cursor.h index accd54e0..28bb8e76 100644 --- a/src/common/byte_cursor.h +++ b/src/common/byte_cursor.h @@ -52,16 +52,16 @@ namespace google_breakpad { // A buffer holding a series of bytes. struct ByteBuffer { ByteBuffer() : start(0), end(0) { } - ByteBuffer(const uint8_t *set_start, size_t set_size) + ByteBuffer(const uint8_t* set_start, size_t set_size) : start(set_start), end(set_start + set_size) { } ~ByteBuffer() { }; // Equality operators. Useful in unit tests, and when we're using // ByteBuffers to refer to regions of a larger buffer. - bool operator==(const ByteBuffer &that) const { + bool operator==(const ByteBuffer& that) const { return start == that.start && end == that.end; } - bool operator!=(const ByteBuffer &that) const { + bool operator!=(const ByteBuffer& that) const { return start != that.start || end != that.end; } @@ -71,7 +71,8 @@ struct ByteBuffer { return end - start; } - const uint8_t *start, *end; + const uint8_t* start; + const uint8_t* end; }; // A cursor pointing into a ByteBuffer that can parse numbers of various @@ -82,8 +83,8 @@ class ByteCursor { public: // Create a cursor reading bytes from the start of BUFFER. By default, the // cursor reads multi-byte values in little-endian form. - ByteCursor(const ByteBuffer *buffer, bool big_endian = false) - : buffer_(buffer), here_(buffer->start), + ByteCursor(const ByteBuffer* buffer, bool big_endian = false) + : buffer_(buffer), here_(buffer->start), big_endian_(big_endian), complete_(true) { } // Accessor and setter for this cursor's endianness flag. @@ -92,8 +93,8 @@ class ByteCursor { // Accessor and setter for this cursor's current position. The setter // returns a reference to this cursor. - const uint8_t *here() const { return here_; } - ByteCursor &set_here(const uint8_t *here) { + const uint8_t* here() const { return here_; } + ByteCursor& set_here(const uint8_t* here) { assert(buffer_->start <= here && here <= buffer_->end); here_ = here; return *this; @@ -116,7 +117,7 @@ class ByteCursor { // this cursor's complete_ flag, and store a dummy value in *RESULT. // Return a reference to this cursor. template - ByteCursor &Read(size_t size, bool is_signed, T *result) { + ByteCursor& Read(size_t size, bool is_signed, T* result) { if (CheckAvailable(size)) { T v = 0; if (big_endian_) { @@ -145,7 +146,7 @@ class ByteCursor { // read off the end of our buffer, clear this cursor's complete_ flag. // Return a reference to this cursor. template - ByteCursor &operator>>(T &result) { + ByteCursor& operator>>(T& result) { bool T_is_signed = (T)-1 < 0; return Read(sizeof(T), T_is_signed, &result); } @@ -154,7 +155,7 @@ class ByteCursor { // cursor to the end of them. If we read off the end of our buffer, // clear this cursor's complete_ flag, and set *POINTER to NULL. // Return a reference to this cursor. - ByteCursor &Read(uint8_t *buffer, size_t size) { + ByteCursor& Read(uint8_t* buffer, size_t size) { if (CheckAvailable(size)) { memcpy(buffer, here_, size); here_ += size; @@ -166,11 +167,11 @@ class ByteCursor { // byte buffer does not contain a terminating zero, clear this cursor's // complete_ flag, and set STR to the empty string. Return a reference to // this cursor. - ByteCursor &CString(string *str) { - const uint8_t *end - = static_cast(memchr(here_, '\0', Available())); + ByteCursor& CString(string* str) { + const uint8_t* end + = static_cast(memchr(here_, '\0', Available())); if (end) { - str->assign(reinterpret_cast(here_), end - here_); + str->assign(reinterpret_cast(here_), end - here_); here_ = end + 1; } else { str->clear(); @@ -193,14 +194,14 @@ class ByteCursor { // // - Otherwise, set *STR to a copy of those LIMIT bytes, and advance the // cursor by LIMIT bytes. - ByteCursor &CString(string *str, size_t limit) { + ByteCursor& CString(string* str, size_t limit) { if (CheckAvailable(limit)) { - const uint8_t *end - = static_cast(memchr(here_, '\0', limit)); + const uint8_t* end + = static_cast(memchr(here_, '\0', limit)); if (end) - str->assign(reinterpret_cast(here_), end - here_); + str->assign(reinterpret_cast(here_), end - here_); else - str->assign(reinterpret_cast(here_), limit); + str->assign(reinterpret_cast(here_), limit); here_ += limit; } else { str->clear(); @@ -213,7 +214,7 @@ class ByteCursor { // cursor. If we read off the end of our buffer, clear this cursor's // complete_ flag, and set *POINTER to NULL. Return a reference to this // cursor. - ByteCursor &PointTo(const uint8_t **pointer, size_t size = 0) { + ByteCursor& PointTo(const uint8_t** pointer, size_t size = 0) { if (CheckAvailable(size)) { *pointer = here_; here_ += size; @@ -226,7 +227,7 @@ class ByteCursor { // Skip SIZE bytes at the cursor. If doing so would advance us off // the end of our buffer, clear this cursor's complete_ flag, and // set *POINTER to NULL. Return a reference to this cursor. - ByteCursor &Skip(size_t size) { + ByteCursor& Skip(size_t size) { if (CheckAvailable(size)) here_ += size; return *this; @@ -247,10 +248,10 @@ class ByteCursor { } // The buffer we're reading bytes from. - const ByteBuffer *buffer_; + const ByteBuffer* buffer_; // The next byte within buffer_ that we'll read. - const uint8_t *here_; + const uint8_t* here_; // True if we should read numbers in big-endian form; false if we // should read in little-endian form. diff --git a/src/common/byte_cursor_unittest.cc b/src/common/byte_cursor_unittest.cc index 06bfd89d..45e6f2b4 100644 --- a/src/common/byte_cursor_unittest.cc +++ b/src/common/byte_cursor_unittest.cc @@ -593,7 +593,7 @@ TEST(Extractor, Signed4) { int32_t a; // For some reason, G++ 4.4.1 complains: // warning: array subscript is above array bounds - // in ByteCursor::Read(size_t, bool, T *) as it inlines this call, but + // in ByteCursor::Read(size_t, bool, T*) as it inlines this call, but // I'm not able to see how such a reference would occur. EXPECT_TRUE(cursor >> a); EXPECT_EQ(-380377902, a); @@ -627,7 +627,7 @@ TEST(Extractor, Unsigned4) { uint32_t a; // For some reason, G++ 4.4.1 complains: // warning: array subscript is above array bounds - // in ByteCursor::Read(size_t, bool, T *) as it inlines this call, but + // in ByteCursor::Read(size_t, bool, T*) as it inlines this call, but // I'm not able to see how such a reference would occur. EXPECT_TRUE(cursor >> a); EXPECT_EQ(0xe953e4d2, a); @@ -718,10 +718,10 @@ TEST(Strings, PointTo) { ByteBuffer buffer(data, sizeof(data)); ByteCursor cursor(&buffer); - const uint8_t *received1; - const uint8_t *received2; - const uint8_t *received3; - const uint8_t *received4; + const uint8_t* received1; + const uint8_t* received2; + const uint8_t* received3; + const uint8_t* received4; EXPECT_FALSE(cursor .PointTo(&received1, 3) .PointTo(&received2, 3) diff --git a/src/common/dwarf/bytereader-inl.h b/src/common/dwarf/bytereader-inl.h index 235d75ee..448be237 100644 --- a/src/common/dwarf/bytereader-inl.h +++ b/src/common/dwarf/bytereader-inl.h @@ -36,11 +36,11 @@ namespace dwarf2reader { -inline uint8_t ByteReader::ReadOneByte(const uint8_t *buffer) const { +inline uint8_t ByteReader::ReadOneByte(const uint8_t* buffer) const { return buffer[0]; } -inline uint16_t ByteReader::ReadTwoBytes(const uint8_t *buffer) const { +inline uint16_t ByteReader::ReadTwoBytes(const uint8_t* buffer) const { const uint16_t buffer0 = buffer[0]; const uint16_t buffer1 = buffer[1]; if (endian_ == ENDIANNESS_LITTLE) { @@ -61,7 +61,7 @@ inline uint64_t ByteReader::ReadThreeBytes(const uint8_t* buffer) const { } } -inline uint64_t ByteReader::ReadFourBytes(const uint8_t *buffer) const { +inline uint64_t ByteReader::ReadFourBytes(const uint8_t* buffer) const { const uint32_t buffer0 = buffer[0]; const uint32_t buffer1 = buffer[1]; const uint32_t buffer2 = buffer[2]; @@ -73,7 +73,7 @@ inline uint64_t ByteReader::ReadFourBytes(const uint8_t *buffer) const { } } -inline uint64_t ByteReader::ReadEightBytes(const uint8_t *buffer) const { +inline uint64_t ByteReader::ReadEightBytes(const uint8_t* buffer) const { const uint64_t buffer0 = buffer[0]; const uint64_t buffer1 = buffer[1]; const uint64_t buffer2 = buffer[2]; @@ -95,7 +95,7 @@ inline uint64_t ByteReader::ReadEightBytes(const uint8_t *buffer) const { // information, plus one bit saying whether the number continues or // not. -inline uint64_t ByteReader::ReadUnsignedLEB128(const uint8_t *buffer, +inline uint64_t ByteReader::ReadUnsignedLEB128(const uint8_t* buffer, size_t* len) const { uint64_t result = 0; size_t num_read = 0; @@ -120,7 +120,7 @@ inline uint64_t ByteReader::ReadUnsignedLEB128(const uint8_t *buffer, // Read a signed LEB128 number. These are like regular LEB128 // numbers, except the last byte may have a sign bit set. -inline int64_t ByteReader::ReadSignedLEB128(const uint8_t *buffer, +inline int64_t ByteReader::ReadSignedLEB128(const uint8_t* buffer, size_t* len) const { int64_t result = 0; unsigned int shift = 0; @@ -140,18 +140,18 @@ inline int64_t ByteReader::ReadSignedLEB128(const uint8_t *buffer, return result; } -inline uint64_t ByteReader::ReadOffset(const uint8_t *buffer) const { +inline uint64_t ByteReader::ReadOffset(const uint8_t* buffer) const { assert(this->offset_reader_); return (this->*offset_reader_)(buffer); } -inline uint64_t ByteReader::ReadAddress(const uint8_t *buffer) const { +inline uint64_t ByteReader::ReadAddress(const uint8_t* buffer) const { assert(this->address_reader_); return (this->*address_reader_)(buffer); } inline void ByteReader::SetCFIDataBase(uint64_t section_base, - const uint8_t *buffer_base) { + const uint8_t* buffer_base) { section_base_ = section_base; buffer_base_ = buffer_base; have_section_base_ = true; diff --git a/src/common/dwarf/bytereader.cc b/src/common/dwarf/bytereader.cc index 0b27dd58..ac5064a7 100644 --- a/src/common/dwarf/bytereader.cc +++ b/src/common/dwarf/bytereader.cc @@ -63,7 +63,7 @@ void ByteReader::SetAddressSize(uint8_t size) { } } -uint64_t ByteReader::ReadInitialLength(const uint8_t *start, size_t* len) { +uint64_t ByteReader::ReadInitialLength(const uint8_t* start, size_t* len) { const uint64_t initial_length = ReadFourBytes(start); start += 4; @@ -101,9 +101,9 @@ bool ByteReader::UsableEncoding(DwarfPointerEncoding encoding) const { } } -uint64_t ByteReader::ReadEncodedPointer(const uint8_t *buffer, +uint64_t ByteReader::ReadEncodedPointer(const uint8_t* buffer, DwarfPointerEncoding encoding, - size_t *len) const { + size_t* len) const { // UsableEncoding doesn't approve of DW_EH_PE_omit, so we shouldn't // see it here. assert(encoding != DW_EH_PE_omit); @@ -130,7 +130,7 @@ uint64_t ByteReader::ReadEncodedPointer(const uint8_t *buffer, // Round up to the next boundary. uint64_t aligned = (offset + AddressSize() - 1) & -AddressSize(); // Convert back to a pointer. - const uint8_t *aligned_buffer = buffer_base_ + (aligned - skew); + const uint8_t* aligned_buffer = buffer_base_ + (aligned - skew); // Finally, store the length and actually fetch the pointer. *len = aligned_buffer - buffer + AddressSize(); return ReadAddress(aligned_buffer); diff --git a/src/common/dwarf/bytereader.h b/src/common/dwarf/bytereader.h index d0c3b964..5d7a9a7f 100644 --- a/src/common/dwarf/bytereader.h +++ b/src/common/dwarf/bytereader.h @@ -62,11 +62,11 @@ class ByteReader { // Read a single byte from BUFFER and return it as an unsigned 8 bit // number. - uint8_t ReadOneByte(const uint8_t *buffer) const; + uint8_t ReadOneByte(const uint8_t* buffer) const; // Read two bytes from BUFFER and return them as an unsigned 16 bit // number, using this ByteReader's endianness. - uint16_t ReadTwoBytes(const uint8_t *buffer) const; + uint16_t ReadTwoBytes(const uint8_t* buffer) const; // Read three bytes from BUFFER and return them as an unsigned 64 bit // number, using this ByteReader's endianness. DWARF 5 uses this encoding @@ -78,11 +78,11 @@ class ByteReader { // a uint64_t so that it is compatible with ReadAddress and // ReadOffset. The number it returns will never be outside the range // of an unsigned 32 bit integer. - uint64_t ReadFourBytes(const uint8_t *buffer) const; + uint64_t ReadFourBytes(const uint8_t* buffer) const; // Read eight bytes from BUFFER and return them as an unsigned 64 // bit number, using this ByteReader's endianness. - uint64_t ReadEightBytes(const uint8_t *buffer) const; + uint64_t ReadEightBytes(const uint8_t* buffer) const; // Read an unsigned LEB128 (Little Endian Base 128) number from // BUFFER and return it as an unsigned 64 bit integer. Set LEN to @@ -101,7 +101,7 @@ class ByteReader { // In other words, we break VALUE into groups of seven bits, put // them in little-endian order, and then write them as eight-bit // bytes with the high bit on all but the last. - uint64_t ReadUnsignedLEB128(const uint8_t *buffer, size_t *len) const; + uint64_t ReadUnsignedLEB128(const uint8_t* buffer, size_t* len) const; // Read a signed LEB128 number from BUFFER and return it as an // signed 64 bit integer. Set LEN to the number of bytes read. @@ -120,7 +120,7 @@ class ByteReader { // In other words, we break VALUE into groups of seven bits, put // them in little-endian order, and then write them as eight-bit // bytes with the high bit on all but the last. - int64_t ReadSignedLEB128(const uint8_t *buffer, size_t *len) const; + int64_t ReadSignedLEB128(const uint8_t* buffer, size_t* len) const; // Indicate that addresses on this architecture are SIZE bytes long. SIZE // must be either 4 or 8. (DWARF allows addresses to be any number of @@ -143,7 +143,7 @@ class ByteReader { // Read an address from BUFFER and return it as an unsigned 64 bit // integer, respecting this ByteReader's endianness and address size. You // must call SetAddressSize before calling this function. - uint64_t ReadAddress(const uint8_t *buffer) const; + uint64_t ReadAddress(const uint8_t* buffer) const; // DWARF actually defines two slightly different formats: 32-bit DWARF // and 64-bit DWARF. This is *not* related to the size of registers or @@ -180,14 +180,14 @@ class ByteReader { // - The 32-bit value 0xffffffff, followed by a 64-bit byte count, // indicating that the data whose length is being measured uses // the 64-bit DWARF format. - uint64_t ReadInitialLength(const uint8_t *start, size_t *len); + uint64_t ReadInitialLength(const uint8_t* start, size_t* len); // Read an offset from BUFFER and return it as an unsigned 64 bit // integer, respecting the ByteReader's endianness. In 32-bit DWARF, the // offset is 4 bytes long; in 64-bit DWARF, the offset is eight bytes // long. You must call ReadInitialLength or SetOffsetSize before calling // this function; see the comments above for details. - uint64_t ReadOffset(const uint8_t *buffer) const; + uint64_t ReadOffset(const uint8_t* buffer) const; // Return the current offset size, in bytes. // A return value of 4 indicates that we are reading 32-bit DWARF. @@ -242,7 +242,7 @@ class ByteReader { // is BUFFER_BASE. This allows us to find the address that a given // byte in our buffer would have when loaded into the program the // data describes. We need this to resolve DW_EH_PE_pcrel pointers. - void SetCFIDataBase(uint64_t section_base, const uint8_t *buffer_base); + void SetCFIDataBase(uint64_t section_base, const uint8_t* buffer_base); // Indicate that the base address of the program's ".text" section // is TEXT_BASE. We need this to resolve DW_EH_PE_textrel pointers. @@ -281,15 +281,15 @@ class ByteReader { // base address this reader hasn't been given, so you should check // with ValidEncoding and UsableEncoding first if you would rather // die in a more helpful way. - uint64_t ReadEncodedPointer(const uint8_t *buffer, + uint64_t ReadEncodedPointer(const uint8_t* buffer, DwarfPointerEncoding encoding, - size_t *len) const; + size_t* len) const; Endianness GetEndianness() const; private: // Function pointer type for our address and offset readers. - typedef uint64_t (ByteReader::*AddressReader)(const uint8_t *) const; + typedef uint64_t (ByteReader::*AddressReader)(const uint8_t*) const; // Read an offset from BUFFER and return it as an unsigned 64 bit // integer. DWARF2/3 define offsets as either 4 or 8 bytes, @@ -312,7 +312,7 @@ class ByteReader { bool have_section_base_, have_text_base_, have_data_base_; bool have_function_base_; uint64_t section_base_, text_base_, data_base_, function_base_; - const uint8_t *buffer_base_; + const uint8_t* buffer_base_; }; } // namespace dwarf2reader diff --git a/src/common/dwarf/bytereader_unittest.cc b/src/common/dwarf/bytereader_unittest.cc index e66062d1..3d7924b9 100644 --- a/src/common/dwarf/bytereader_unittest.cc +++ b/src/common/dwarf/bytereader_unittest.cc @@ -73,7 +73,7 @@ TEST_F(Reader, SimpleConstructor) { .LEB128(-0x4f337badf4483f83LL) .D32(0xfec319c9); ASSERT_TRUE(section.GetContents(&contents)); - const uint8_t *data = reinterpret_cast(contents.data()); + const uint8_t* data = reinterpret_cast(contents.data()); EXPECT_EQ(0xc0U, reader.ReadOneByte(data)); EXPECT_EQ(0xcf0dU, reader.ReadTwoBytes(data + 1)); EXPECT_EQ(0x96fdd219U, reader.ReadFourBytes(data + 3)); diff --git a/src/common/dwarf/cfi_assembler.cc b/src/common/dwarf/cfi_assembler.cc index 2dc22085..858fd561 100644 --- a/src/common/dwarf/cfi_assembler.cc +++ b/src/common/dwarf/cfi_assembler.cc @@ -41,11 +41,11 @@ namespace google_breakpad { using dwarf2reader::DwarfPointerEncoding; -CFISection &CFISection::CIEHeader(uint64_t code_alignment_factor, +CFISection& CFISection::CIEHeader(uint64_t code_alignment_factor, int data_alignment_factor, unsigned return_address_register, uint8_t version, - const string &augmentation, + const string& augmentation, bool dwarf64, uint8_t address_size, uint8_t segment_size) { @@ -78,7 +78,7 @@ CFISection &CFISection::CIEHeader(uint64_t code_alignment_factor, return *this; } -CFISection &CFISection::FDEHeader(Label cie_pointer, +CFISection& CFISection::FDEHeader(Label cie_pointer, uint64_t initial_location, uint64_t address_range, bool dwarf64) { @@ -113,7 +113,7 @@ CFISection &CFISection::FDEHeader(Label cie_pointer, return *this; } -CFISection &CFISection::FinishEntry() { +CFISection& CFISection::FinishEntry() { assert(entry_length_); Align(address_size_, dwarf2reader::DW_CFA_nop); entry_length_->length = Here() - entry_length_->start; @@ -123,9 +123,9 @@ CFISection &CFISection::FinishEntry() { return *this; } -CFISection &CFISection::EncodedPointer(uint64_t address, +CFISection& CFISection::EncodedPointer(uint64_t address, DwarfPointerEncoding encoding, - const EncodedPointerBases &bases) { + const EncodedPointerBases& bases) { // Omitted data is extremely easy to emit. if (encoding == dwarf2reader::DW_EH_PE_omit) return *this; diff --git a/src/common/dwarf/cfi_assembler.h b/src/common/dwarf/cfi_assembler.h index bd7354d1..d60ecc9e 100644 --- a/src/common/dwarf/cfi_assembler.h +++ b/src/common/dwarf/cfi_assembler.h @@ -120,7 +120,7 @@ class CFISection: public Section { // Use the addresses in BASES as the base addresses for encoded // pointers in subsequent calls to FDEHeader or EncodedPointer. // This function makes a copy of BASES. - void SetEncodedPointerBases(const EncodedPointerBases &bases) { + void SetEncodedPointerBases(const EncodedPointerBases& bases) { encoded_pointer_bases_ = bases; } @@ -133,11 +133,11 @@ class CFISection: public Section { // Before calling this function, you will typically want to use Mark // or Here to make a label to pass to FDEHeader that refers to this // CIE's position in the section. - CFISection &CIEHeader(uint64_t code_alignment_factor, + CFISection& CIEHeader(uint64_t code_alignment_factor, int data_alignment_factor, unsigned return_address_register, uint8_t version = 3, - const string &augmentation = "", + const string& augmentation = "", bool dwarf64 = false, uint8_t address_size = 8, uint8_t segment_size = 0); @@ -152,7 +152,7 @@ class CFISection: public Section { // 0xffffff00 bytes. (The "initial length" is always a 32-bit // value.) Nor does it support .debug_frame sections longer than // 0xffffff00 bytes. - CFISection &FDEHeader(Label cie_pointer, + CFISection& FDEHeader(Label cie_pointer, uint64_t initial_location, uint64_t address_range, bool dwarf64 = false); @@ -161,11 +161,11 @@ class CFISection: public Section { // started, after padding with DW_CFA_nops for alignment. This // defines the label representing the entry's length, cited in the // entry's header. Return a reference to this section. - CFISection &FinishEntry(); + CFISection& FinishEntry(); // Append the contents of BLOCK as a DW_FORM_block value: an // unsigned LEB128 length, followed by that many bytes of data. - CFISection &Block(const string &block) { + CFISection& Block(const string& block) { ULEB128(block.size()); Append(block); return *this; @@ -173,11 +173,11 @@ class CFISection: public Section { // Append ADDRESS to this section, in the appropriate size and // endianness. Return a reference to this section. - CFISection &Address(uint64_t address) { + CFISection& Address(uint64_t address) { Section::Append(endianness(), address_size_, address); return *this; } - CFISection &Address(Label address) { + CFISection& Address(Label address) { Section::Append(endianness(), address_size_, address); return *this; } @@ -191,26 +191,26 @@ class CFISection: public Section { // // (C++ doesn't let me use default arguments here, because I want to // refer to members of *this in the default argument expression.) - CFISection &EncodedPointer(uint64_t address) { + CFISection& EncodedPointer(uint64_t address) { return EncodedPointer(address, pointer_encoding_, encoded_pointer_bases_); } - CFISection &EncodedPointer(uint64_t address, DwarfPointerEncoding encoding) { + CFISection& EncodedPointer(uint64_t address, DwarfPointerEncoding encoding) { return EncodedPointer(address, encoding, encoded_pointer_bases_); } - CFISection &EncodedPointer(uint64_t address, DwarfPointerEncoding encoding, - const EncodedPointerBases &bases); + CFISection& EncodedPointer(uint64_t address, DwarfPointerEncoding encoding, + const EncodedPointerBases& bases); // Restate some member functions, to keep chaining working nicely. - CFISection &Mark(Label *label) { Section::Mark(label); return *this; } - CFISection &D8(uint8_t v) { Section::D8(v); return *this; } - CFISection &D16(uint16_t v) { Section::D16(v); return *this; } - CFISection &D16(Label v) { Section::D16(v); return *this; } - CFISection &D32(uint32_t v) { Section::D32(v); return *this; } - CFISection &D32(const Label &v) { Section::D32(v); return *this; } - CFISection &D64(uint64_t v) { Section::D64(v); return *this; } - CFISection &D64(const Label &v) { Section::D64(v); return *this; } - CFISection &LEB128(long long v) { Section::LEB128(v); return *this; } - CFISection &ULEB128(uint64_t v) { Section::ULEB128(v); return *this; } + CFISection& Mark(Label* label) { Section::Mark(label); return *this; } + CFISection& D8(uint8_t v) { Section::D8(v); return *this; } + CFISection& D16(uint16_t v) { Section::D16(v); return *this; } + CFISection& D16(Label v) { Section::D16(v); return *this; } + CFISection& D32(uint32_t v) { Section::D32(v); return *this; } + CFISection& D32(const Label& v) { Section::D32(v); return *this; } + CFISection& D64(uint64_t v) { Section::D64(v); return *this; } + CFISection& D64(const Label& v) { Section::D64(v); return *this; } + CFISection& LEB128(long long v) { Section::LEB128(v); return *this; } + CFISection& ULEB128(uint64_t v) { Section::ULEB128(v); return *this; } private: // A length value that we've appended to the section, but is not yet diff --git a/src/common/dwarf/dwarf2diehandler.cc b/src/common/dwarf/dwarf2diehandler.cc index 63845018..f5a0683e 100644 --- a/src/common/dwarf/dwarf2diehandler.cc +++ b/src/common/dwarf/dwarf2diehandler.cc @@ -43,7 +43,7 @@ namespace dwarf2reader { DIEDispatcher::~DIEDispatcher() { while (!die_handlers_.empty()) { - HandlerStack &entry = die_handlers_.top(); + HandlerStack& entry = die_handlers_.top(); if (entry.handler_ != root_handler_) delete entry.handler_; die_handlers_.pop(); @@ -60,7 +60,7 @@ bool DIEDispatcher::StartCompilationUnit(uint64_t offset, uint8_t address_size, bool DIEDispatcher::StartDIE(uint64_t offset, enum DwarfTag tag) { // The stack entry for the parent of this DIE, if there is one. - HandlerStack *parent = die_handlers_.empty() ? NULL : &die_handlers_.top(); + HandlerStack* parent = die_handlers_.empty() ? NULL : &die_handlers_.top(); // Does this call indicate that we're done receiving the parent's // attributes' values? If so, call its EndAttributes member function. @@ -78,7 +78,7 @@ bool DIEDispatcher::StartDIE(uint64_t offset, enum DwarfTag tag) { } // Find a handler for this DIE. - DIEHandler *handler; + DIEHandler* handler; if (parent) { if (parent->handler_) // Ask the parent to find a handler. @@ -115,7 +115,7 @@ bool DIEDispatcher::StartDIE(uint64_t offset, enum DwarfTag tag) { void DIEDispatcher::EndDIE(uint64_t offset) { assert(!die_handlers_.empty()); - HandlerStack *entry = &die_handlers_.top(); + HandlerStack* entry = &die_handlers_.top(); if (entry->handler_) { // This entry had better be the handler for this DIE. assert(entry->offset_ == offset); @@ -139,7 +139,7 @@ void DIEDispatcher::ProcessAttributeUnsigned(uint64_t offset, enum DwarfAttribute attr, enum DwarfForm form, uint64_t data) { - HandlerStack ¤t = die_handlers_.top(); + HandlerStack& current = die_handlers_.top(); // This had better be an attribute of the DIE we were meant to handle. assert(offset == current.offset_); current.handler_->ProcessAttributeUnsigned(attr, form, data); @@ -149,7 +149,7 @@ void DIEDispatcher::ProcessAttributeSigned(uint64_t offset, enum DwarfAttribute attr, enum DwarfForm form, int64_t data) { - HandlerStack ¤t = die_handlers_.top(); + HandlerStack& current = die_handlers_.top(); // This had better be an attribute of the DIE we were meant to handle. assert(offset == current.offset_); current.handler_->ProcessAttributeSigned(attr, form, data); @@ -159,7 +159,7 @@ void DIEDispatcher::ProcessAttributeReference(uint64_t offset, enum DwarfAttribute attr, enum DwarfForm form, uint64_t data) { - HandlerStack ¤t = die_handlers_.top(); + HandlerStack& current = die_handlers_.top(); // This had better be an attribute of the DIE we were meant to handle. assert(offset == current.offset_); current.handler_->ProcessAttributeReference(attr, form, data); @@ -168,9 +168,9 @@ void DIEDispatcher::ProcessAttributeReference(uint64_t offset, void DIEDispatcher::ProcessAttributeBuffer(uint64_t offset, enum DwarfAttribute attr, enum DwarfForm form, - const uint8_t *data, + const uint8_t* data, uint64_t len) { - HandlerStack ¤t = die_handlers_.top(); + HandlerStack& current = die_handlers_.top(); // This had better be an attribute of the DIE we were meant to handle. assert(offset == current.offset_); current.handler_->ProcessAttributeBuffer(attr, form, data, len); @@ -180,7 +180,7 @@ void DIEDispatcher::ProcessAttributeString(uint64_t offset, enum DwarfAttribute attr, enum DwarfForm form, const string& data) { - HandlerStack ¤t = die_handlers_.top(); + HandlerStack& current = die_handlers_.top(); // This had better be an attribute of the DIE we were meant to handle. assert(offset == current.offset_); current.handler_->ProcessAttributeString(attr, form, data); @@ -190,7 +190,7 @@ void DIEDispatcher::ProcessAttributeSignature(uint64_t offset, enum DwarfAttribute attr, enum DwarfForm form, uint64_t signature) { - HandlerStack ¤t = die_handlers_.top(); + HandlerStack& current = die_handlers_.top(); // This had better be an attribute of the DIE we were meant to handle. assert(offset == current.offset_); current.handler_->ProcessAttributeSignature(attr, form, signature); diff --git a/src/common/dwarf/dwarf2diehandler.h b/src/common/dwarf/dwarf2diehandler.h index 871ba436..028a6d11 100644 --- a/src/common/dwarf/dwarf2diehandler.h +++ b/src/common/dwarf/dwarf2diehandler.h @@ -208,7 +208,7 @@ class DIEHandler { uint64_t data) { } virtual void ProcessAttributeBuffer(enum DwarfAttribute attr, enum DwarfForm form, - const uint8_t *data, + const uint8_t* data, uint64_t len) { } virtual void ProcessAttributeString(enum DwarfAttribute attr, enum DwarfForm form, @@ -244,7 +244,7 @@ class DIEHandler { // it is. // // The default definition skips all children. - virtual DIEHandler *FindChildHandler(uint64_t offset, enum DwarfTag tag) { + virtual DIEHandler* FindChildHandler(uint64_t offset, enum DwarfTag tag) { return NULL; } @@ -288,7 +288,7 @@ class DIEDispatcher: public Dwarf2Handler { // Create a Dwarf2Handler which uses ROOT_HANDLER as the handler for // the compilation unit's root die, as described for the DIEHandler // class. - DIEDispatcher(RootDIEHandler *root_handler) : root_handler_(root_handler) { } + DIEDispatcher(RootDIEHandler* root_handler) : root_handler_(root_handler) { } // Destroying a DIEDispatcher destroys all active handler objects // except the root handler. ~DIEDispatcher(); @@ -311,12 +311,12 @@ class DIEDispatcher: public Dwarf2Handler { void ProcessAttributeBuffer(uint64_t offset, enum DwarfAttribute attr, enum DwarfForm form, - const uint8_t *data, + const uint8_t* data, uint64_t len); void ProcessAttributeString(uint64_t offset, enum DwarfAttribute attr, enum DwarfForm form, - const string &data); + const string& data); void ProcessAttributeSignature(uint64_t offset, enum DwarfAttribute attr, enum DwarfForm form, @@ -335,7 +335,7 @@ class DIEDispatcher: public Dwarf2Handler { // The handler object interested in this DIE's attributes and // children. If NULL, we're not interested in either. - DIEHandler *handler_; + DIEHandler* handler_; // Have we reported the end of this DIE's attributes to the handler? bool reported_attributes_end_; @@ -358,7 +358,7 @@ class DIEDispatcher: public Dwarf2Handler { // The root handler. We don't push it on die_handlers_ until we // actually get the StartDIE call for the root. - RootDIEHandler *root_handler_; + RootDIEHandler* root_handler_; }; } // namespace dwarf2reader diff --git a/src/common/dwarf/dwarf2diehandler_unittest.cc b/src/common/dwarf/dwarf2diehandler_unittest.cc index 01b70489..552c3d11 100644 --- a/src/common/dwarf/dwarf2diehandler_unittest.cc +++ b/src/common/dwarf/dwarf2diehandler_unittest.cc @@ -69,9 +69,9 @@ class MockDIEHandler: public DIEHandler { MOCK_METHOD3(ProcessAttributeReference, void(DwarfAttribute, DwarfForm, uint64_t)); MOCK_METHOD4(ProcessAttributeBuffer, - void(DwarfAttribute, DwarfForm, const uint8_t *, uint64_t)); + void(DwarfAttribute, DwarfForm, const uint8_t*, uint64_t)); MOCK_METHOD3(ProcessAttributeString, - void(DwarfAttribute, DwarfForm, const string &)); + void(DwarfAttribute, DwarfForm, const string&)); MOCK_METHOD3(ProcessAttributeSignature, void(DwarfAttribute, DwarfForm, uint64_t)); MOCK_METHOD0(EndAttributes, bool()); @@ -88,9 +88,9 @@ class MockRootDIEHandler: public RootDIEHandler { MOCK_METHOD3(ProcessAttributeReference, void(DwarfAttribute, DwarfForm, uint64_t)); MOCK_METHOD4(ProcessAttributeBuffer, - void(DwarfAttribute, DwarfForm, const uint8_t *, uint64_t)); + void(DwarfAttribute, DwarfForm, const uint8_t*, uint64_t)); MOCK_METHOD3(ProcessAttributeString, - void(DwarfAttribute, DwarfForm, const string &)); + void(DwarfAttribute, DwarfForm, const string&)); MOCK_METHOD3(ProcessAttributeSignature, void(DwarfAttribute, DwarfForm, uint64_t)); MOCK_METHOD0(EndAttributes, bool()); @@ -339,7 +339,7 @@ TEST(Dwarf2DIEHandler, FindAndSkipChildren) { EXPECT_CALL(mock_root_handler, FindChildHandler(0x97412be24875de9dLL, (DwarfTag) 0x505a068b)) - .WillOnce(Return((DIEHandler *) NULL)); + .WillOnce(Return((DIEHandler*) NULL)); // Third child DIE. EXPECT_CALL(mock_root_handler, diff --git a/src/common/dwarf/dwarf2reader.cc b/src/common/dwarf/dwarf2reader.cc index ad82a5f4..aca83677 100644 --- a/src/common/dwarf/dwarf2reader.cc +++ b/src/common/dwarf/dwarf2reader.cc @@ -122,9 +122,9 @@ void CompilationUnit::ReadAbbrevs() { // The only way to check whether we are reading over the end of the // buffer would be to first compute the size of the leb128 data by // reading it, then go back and read it again. - const uint8_t *abbrev_start = iter->second.first + + const uint8_t* abbrev_start = iter->second.first + header_.abbrev_offset; - const uint8_t *abbrevptr = abbrev_start; + const uint8_t* abbrevptr = abbrev_start; #ifndef NDEBUG const uint64_t abbrev_length = iter->second.second - header_.abbrev_offset; #endif @@ -171,7 +171,7 @@ void CompilationUnit::ReadAbbrevs() { } // Skips a single DIE's attributes. -const uint8_t *CompilationUnit::SkipDIE(const uint8_t* start, +const uint8_t* CompilationUnit::SkipDIE(const uint8_t* start, const Abbrev& abbrev) { for (AttributeList::const_iterator i = abbrev.attributes.begin(); i != abbrev.attributes.end(); @@ -182,7 +182,7 @@ const uint8_t *CompilationUnit::SkipDIE(const uint8_t* start, } // Skips a single attribute form's data. -const uint8_t *CompilationUnit::SkipAttribute(const uint8_t *start, +const uint8_t* CompilationUnit::SkipAttribute(const uint8_t* start, enum DwarfForm form) { size_t len; @@ -219,7 +219,7 @@ const uint8_t *CompilationUnit::SkipAttribute(const uint8_t *start, case DW_FORM_ref_sig8: return start + 8; case DW_FORM_string: - return start + strlen(reinterpret_cast(start)) + 1; + return start + strlen(reinterpret_cast(start)) + 1; case DW_FORM_udata: case DW_FORM_ref_udata: case DW_FORM_strx: @@ -311,7 +311,7 @@ size_t CompilationUnit::ReadTypeOffset(const uint8_t* headerptr) { // abbrevs, and an address size. DWARF5 adds a unit_type to distinguish // between partial-, full-, skeleton-, split-, and type- compilation units. void CompilationUnit::ReadHeader() { - const uint8_t *headerptr = buffer_; + const uint8_t* headerptr = buffer_; size_t initial_length_size; assert(headerptr + 4 < buffer_ + buffer_length_); @@ -455,8 +455,8 @@ void CompilationUnit::ProcessFormStringIndex( // If one really wanted, you could merge SkipAttribute and // ProcessAttribute // This is all boring data manipulation and calling of the handler. -const uint8_t *CompilationUnit::ProcessAttribute( - uint64_t dieoffset, const uint8_t *start, enum DwarfAttribute attr, +const uint8_t* CompilationUnit::ProcessAttribute( + uint64_t dieoffset, const uint8_t* start, enum DwarfAttribute attr, enum DwarfForm form) { size_t len; @@ -490,7 +490,7 @@ const uint8_t *CompilationUnit::ProcessAttribute( reader_->ReadEightBytes(start)); return start + 8; case DW_FORM_string: { - const char *str = reinterpret_cast(start); + const char* str = reinterpret_cast(start); ProcessAttributeString(dieoffset, attr, form, str); return start + strlen(str) + 1; } @@ -588,7 +588,7 @@ const uint8_t *CompilationUnit::ProcessAttribute( const uint64_t offset = reader_->ReadOffset(start); assert(string_buffer_ + offset < string_buffer_ + string_buffer_length_); - const char *str = reinterpret_cast(string_buffer_ + offset); + const char* str = reinterpret_cast(string_buffer_ + offset); ProcessAttributeString(dieoffset, attr, form, str); return start + reader_->OffsetSize(); } @@ -662,8 +662,8 @@ const uint8_t *CompilationUnit::ProcessAttribute( return NULL; } -const uint8_t *CompilationUnit::ProcessDIE(uint64_t dieoffset, - const uint8_t *start, +const uint8_t* CompilationUnit::ProcessDIE(uint64_t dieoffset, + const uint8_t* start, const Abbrev& abbrev) { for (AttributeList::const_iterator i = abbrev.attributes.begin(); i != abbrev.attributes.end(); @@ -684,12 +684,12 @@ const uint8_t *CompilationUnit::ProcessDIE(uint64_t dieoffset, } void CompilationUnit::ProcessDIEs() { - const uint8_t *dieptr = after_header_; + const uint8_t* dieptr = after_header_; size_t len; // lengthstart is the place the length field is based on. // It is the point in the header after the initial length field - const uint8_t *lengthstart = buffer_; + const uint8_t* lengthstart = buffer_; // In 64 bit dwarf, the initial length is 12 bytes, because of the // 0xffffffff at the start. @@ -827,7 +827,7 @@ void CompilationUnit::ReadDebugSectionsFromDwo(ElfReader* elf_reader, if (section_data != NULL) sections->insert(std::make_pair( base_name, std::make_pair( - reinterpret_cast(section_data), + reinterpret_cast(section_data), section_size))); } } @@ -856,11 +856,11 @@ void DwpReader::Initialize() { &string_buffer_size_); version_ = byte_reader_.ReadFourBytes( - reinterpret_cast(cu_index_)); + reinterpret_cast(cu_index_)); if (version_ == 1) { nslots_ = byte_reader_.ReadFourBytes( - reinterpret_cast(cu_index_) + reinterpret_cast(cu_index_) + 3 * sizeof(uint32_t)); phash_ = cu_index_ + 4 * sizeof(uint32_t); pindex_ = phash_ + nslots_ * sizeof(uint64_t); @@ -870,11 +870,11 @@ void DwpReader::Initialize() { } } else if (version_ == 2) { ncolumns_ = byte_reader_.ReadFourBytes( - reinterpret_cast(cu_index_) + sizeof(uint32_t)); + reinterpret_cast(cu_index_) + sizeof(uint32_t)); nunits_ = byte_reader_.ReadFourBytes( - reinterpret_cast(cu_index_) + 2 * sizeof(uint32_t)); + reinterpret_cast(cu_index_) + 2 * sizeof(uint32_t)); nslots_ = byte_reader_.ReadFourBytes( - reinterpret_cast(cu_index_) + 3 * sizeof(uint32_t)); + reinterpret_cast(cu_index_) + 3 * sizeof(uint32_t)); phash_ = cu_index_ + 4 * sizeof(uint32_t); pindex_ = phash_ + nslots_ * sizeof(uint64_t); offset_table_ = pindex_ + nslots_ * sizeof(uint32_t); @@ -902,7 +902,7 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id, // can read a list of section indexes for the debug sections // for the CU whose dwo_id we are looking for. int index = byte_reader_.ReadFourBytes( - reinterpret_cast(pindex_) + reinterpret_cast(pindex_) + slot * sizeof(uint32_t)); const char* shndx_list = shndx_pool_ + index * sizeof(uint32_t); for (;;) { @@ -911,7 +911,7 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id, return; } unsigned int shndx = byte_reader_.ReadFourBytes( - reinterpret_cast(shndx_list)); + reinterpret_cast(shndx_list)); shndx_list += sizeof(uint32_t); if (shndx == 0) break; @@ -925,26 +925,26 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id, section_data = elf_reader_->GetSectionByIndex(shndx, §ion_size); sections->insert(std::make_pair( ".debug_abbrev", - std::make_pair(reinterpret_cast (section_data), + std::make_pair(reinterpret_cast (section_data), section_size))); } else if (!strncmp(section_name, ".debug_info", strlen(".debug_info"))) { section_data = elf_reader_->GetSectionByIndex(shndx, §ion_size); sections->insert(std::make_pair( ".debug_info", - std::make_pair(reinterpret_cast (section_data), + std::make_pair(reinterpret_cast (section_data), section_size))); } else if (!strncmp(section_name, ".debug_str_offsets", strlen(".debug_str_offsets"))) { section_data = elf_reader_->GetSectionByIndex(shndx, §ion_size); sections->insert(std::make_pair( ".debug_str_offsets", - std::make_pair(reinterpret_cast (section_data), + std::make_pair(reinterpret_cast (section_data), section_size))); } } sections->insert(std::make_pair( ".debug_str", - std::make_pair(reinterpret_cast (string_buffer_), + std::make_pair(reinterpret_cast (string_buffer_), string_buffer_size_))); } else if (version_ == 2) { uint32_t index = LookupCUv2(dwo_id); @@ -969,33 +969,33 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id, } for (unsigned int col = 0u; col < ncolumns_; ++col) { uint32_t section_id = - byte_reader_.ReadFourBytes(reinterpret_cast(id_row) + byte_reader_.ReadFourBytes(reinterpret_cast(id_row) + col * sizeof(uint32_t)); uint32_t offset = byte_reader_.ReadFourBytes( - reinterpret_cast(offset_row) + reinterpret_cast(offset_row) + col * sizeof(uint32_t)); uint32_t size = byte_reader_.ReadFourBytes( - reinterpret_cast(size_row) + col * sizeof(uint32_t)); + reinterpret_cast(size_row) + col * sizeof(uint32_t)); if (section_id == DW_SECT_ABBREV) { sections->insert(std::make_pair( ".debug_abbrev", - std::make_pair(reinterpret_cast (abbrev_data_) + std::make_pair(reinterpret_cast (abbrev_data_) + offset, size))); } else if (section_id == DW_SECT_INFO) { sections->insert(std::make_pair( ".debug_info", - std::make_pair(reinterpret_cast (info_data_) + std::make_pair(reinterpret_cast (info_data_) + offset, size))); } else if (section_id == DW_SECT_STR_OFFSETS) { sections->insert(std::make_pair( ".debug_str_offsets", - std::make_pair(reinterpret_cast (str_offsets_data_) + std::make_pair(reinterpret_cast (str_offsets_data_) + offset, size))); } } sections->insert(std::make_pair( ".debug_str", - std::make_pair(reinterpret_cast (string_buffer_), + std::make_pair(reinterpret_cast (string_buffer_), string_buffer_size_))); } } @@ -1003,14 +1003,14 @@ void DwpReader::ReadDebugSectionsForCU(uint64_t dwo_id, int DwpReader::LookupCU(uint64_t dwo_id) { uint32_t slot = static_cast(dwo_id) & (nslots_ - 1); uint64_t probe = byte_reader_.ReadEightBytes( - reinterpret_cast(phash_) + slot * sizeof(uint64_t)); + reinterpret_cast(phash_) + slot * sizeof(uint64_t)); if (probe != 0 && probe != dwo_id) { uint32_t secondary_hash = (static_cast(dwo_id >> 32) & (nslots_ - 1)) | 1; do { slot = (slot + secondary_hash) & (nslots_ - 1); probe = byte_reader_.ReadEightBytes( - reinterpret_cast(phash_) + slot * sizeof(uint64_t)); + reinterpret_cast(phash_) + slot * sizeof(uint64_t)); } while (probe != 0 && probe != dwo_id); } if (probe == 0) @@ -1021,24 +1021,24 @@ int DwpReader::LookupCU(uint64_t dwo_id) { uint32_t DwpReader::LookupCUv2(uint64_t dwo_id) { uint32_t slot = static_cast(dwo_id) & (nslots_ - 1); uint64_t probe = byte_reader_.ReadEightBytes( - reinterpret_cast(phash_) + slot * sizeof(uint64_t)); + reinterpret_cast(phash_) + slot * sizeof(uint64_t)); uint32_t index = byte_reader_.ReadFourBytes( - reinterpret_cast(pindex_) + slot * sizeof(uint32_t)); + reinterpret_cast(pindex_) + slot * sizeof(uint32_t)); if (index != 0 && probe != dwo_id) { uint32_t secondary_hash = (static_cast(dwo_id >> 32) & (nslots_ - 1)) | 1; do { slot = (slot + secondary_hash) & (nslots_ - 1); probe = byte_reader_.ReadEightBytes( - reinterpret_cast(phash_) + slot * sizeof(uint64_t)); + reinterpret_cast(phash_) + slot * sizeof(uint64_t)); index = byte_reader_.ReadFourBytes( - reinterpret_cast(pindex_) + slot * sizeof(uint32_t)); + reinterpret_cast(pindex_) + slot * sizeof(uint32_t)); } while (index != 0 && probe != dwo_id); } return index; } -LineInfo::LineInfo(const uint8_t *buffer, uint64_t buffer_length, +LineInfo::LineInfo(const uint8_t* buffer, uint64_t buffer_length, ByteReader* reader, const uint8_t* string_buffer, size_t string_buffer_length, const uint8_t* line_string_buffer, @@ -1185,7 +1185,7 @@ void LineInfo::ReadFileRow(const uint8_t** lineptr, // The header for a debug_line section is mildly complicated, because // the line info is very tightly encoded. void LineInfo::ReadHeader() { - const uint8_t *lineptr = buffer_; + const uint8_t* lineptr = buffer_; size_t initial_length_size; const uint64_t initial_length @@ -1331,12 +1331,12 @@ void LineInfo::ReadHeader() { /* static */ bool LineInfo::ProcessOneOpcode(ByteReader* reader, LineInfoHandler* handler, - const struct LineInfoHeader &header, - const uint8_t *start, + const struct LineInfoHeader& header, + const uint8_t* start, struct LineStateMachine* lsm, size_t* len, uintptr pc, - bool *lsm_passes_pc) { + bool* lsm_passes_pc) { size_t oplen = 0; size_t templen; uint8_t opcode = reader->ReadOneByte(start); @@ -1473,7 +1473,7 @@ bool LineInfo::ProcessOneOpcode(ByteReader* reader, } break; case DW_LNE_define_file: { - const char *filename = reinterpret_cast(start); + const char* filename = reinterpret_cast(start); templen = strlen(filename) + 1; start += templen; @@ -1520,7 +1520,7 @@ void LineInfo::ReadLines() { // lengthstart is the place the length field is based on. // It is the point in the header after the initial length field - const uint8_t *lengthstart = buffer_; + const uint8_t* lengthstart = buffer_; // In 64 bit dwarf, the initial length is 12 bytes, because of the // 0xffffffff at the start. @@ -1529,7 +1529,7 @@ void LineInfo::ReadLines() { else lengthstart += 4; - const uint8_t *lineptr = after_header_; + const uint8_t* lineptr = after_header_; lsm.Reset(header_.default_is_stmt); // The LineInfoHandler interface expects each line's length along @@ -1568,8 +1568,8 @@ void LineInfo::ReadLines() { after_header_ = lengthstart + header_.total_length; } -RangeListReader::RangeListReader(const uint8_t *buffer, uint64_t size, - ByteReader *reader, RangeListHandler *handler) +RangeListReader::RangeListReader(const uint8_t* buffer, uint64_t size, + ByteReader* reader, RangeListHandler* handler) : buffer_(buffer), size_(size), reader_(reader), handler_(handler) { } bool RangeListReader::ReadRangeList(uint64_t offset) { @@ -1625,17 +1625,17 @@ class CallFrameInfo::Rule { // this rule. If REG is kCFARegister, then this rule describes how to compute // the canonical frame address. Return what the HANDLER member function // returned. - virtual bool Handle(Handler *handler, + virtual bool Handle(Handler* handler, uint64_t address, int reg) const = 0; // Equality on rules. We use these to decide which rules we need // to report after a DW_CFA_restore_state instruction. - virtual bool operator==(const Rule &rhs) const = 0; + virtual bool operator==(const Rule& rhs) const = 0; - bool operator!=(const Rule &rhs) const { return ! (*this == rhs); } + bool operator!=(const Rule& rhs) const { return ! (*this == rhs); } // Return a pointer to a copy of this rule. - virtual Rule *Copy() const = 0; + virtual Rule* Copy() const = 0; // If this is a base+offset rule, change its base register to REG. // Otherwise, do nothing. (Ugly, but required for DW_CFA_def_cfa_register.) @@ -1651,16 +1651,16 @@ class CallFrameInfo::UndefinedRule: public CallFrameInfo::Rule { public: UndefinedRule() { } ~UndefinedRule() { } - bool Handle(Handler *handler, uint64_t address, int reg) const { + bool Handle(Handler* handler, uint64_t address, int reg) const { return handler->UndefinedRule(address, reg); } - bool operator==(const Rule &rhs) const { + bool operator==(const Rule& rhs) const { // dynamic_cast is allowed by the Google C++ Style Guide, if the use has // been carefully considered; cheap RTTI-like workarounds are forbidden. - const UndefinedRule *our_rhs = dynamic_cast(&rhs); + const UndefinedRule* our_rhs = dynamic_cast(&rhs); return (our_rhs != NULL); } - Rule *Copy() const { return new UndefinedRule(*this); } + Rule* Copy() const { return new UndefinedRule(*this); } }; // Rule: the register's value is the same as that it had in the caller. @@ -1668,16 +1668,16 @@ class CallFrameInfo::SameValueRule: public CallFrameInfo::Rule { public: SameValueRule() { } ~SameValueRule() { } - bool Handle(Handler *handler, uint64_t address, int reg) const { + bool Handle(Handler* handler, uint64_t address, int reg) const { return handler->SameValueRule(address, reg); } - bool operator==(const Rule &rhs) const { + bool operator==(const Rule& rhs) const { // dynamic_cast is allowed by the Google C++ Style Guide, if the use has // been carefully considered; cheap RTTI-like workarounds are forbidden. - const SameValueRule *our_rhs = dynamic_cast(&rhs); + const SameValueRule* our_rhs = dynamic_cast(&rhs); return (our_rhs != NULL); } - Rule *Copy() const { return new SameValueRule(*this); } + Rule* Copy() const { return new SameValueRule(*this); } }; // Rule: the register is saved at OFFSET from BASE_REGISTER. BASE_REGISTER @@ -1687,18 +1687,18 @@ class CallFrameInfo::OffsetRule: public CallFrameInfo::Rule { OffsetRule(int base_register, long offset) : base_register_(base_register), offset_(offset) { } ~OffsetRule() { } - bool Handle(Handler *handler, uint64_t address, int reg) const { + bool Handle(Handler* handler, uint64_t address, int reg) const { return handler->OffsetRule(address, reg, base_register_, offset_); } - bool operator==(const Rule &rhs) const { + bool operator==(const Rule& rhs) const { // dynamic_cast is allowed by the Google C++ Style Guide, if the use has // been carefully considered; cheap RTTI-like workarounds are forbidden. - const OffsetRule *our_rhs = dynamic_cast(&rhs); + const OffsetRule* our_rhs = dynamic_cast(&rhs); return (our_rhs && base_register_ == our_rhs->base_register_ && offset_ == our_rhs->offset_); } - Rule *Copy() const { return new OffsetRule(*this); } + Rule* Copy() const { return new OffsetRule(*this); } // We don't actually need SetBaseRegister or SetOffset here, since they // are only ever applied to CFA rules, for DW_CFA_def_cfa_offset, and it // doesn't make sense to use OffsetRule for computing the CFA: it @@ -1716,18 +1716,18 @@ class CallFrameInfo::ValOffsetRule: public CallFrameInfo::Rule { ValOffsetRule(int base_register, long offset) : base_register_(base_register), offset_(offset) { } ~ValOffsetRule() { } - bool Handle(Handler *handler, uint64_t address, int reg) const { + bool Handle(Handler* handler, uint64_t address, int reg) const { return handler->ValOffsetRule(address, reg, base_register_, offset_); } - bool operator==(const Rule &rhs) const { + bool operator==(const Rule& rhs) const { // dynamic_cast is allowed by the Google C++ Style Guide, if the use has // been carefully considered; cheap RTTI-like workarounds are forbidden. - const ValOffsetRule *our_rhs = dynamic_cast(&rhs); + const ValOffsetRule* our_rhs = dynamic_cast(&rhs); return (our_rhs && base_register_ == our_rhs->base_register_ && offset_ == our_rhs->offset_); } - Rule *Copy() const { return new ValOffsetRule(*this); } + Rule* Copy() const { return new ValOffsetRule(*this); } void SetBaseRegister(unsigned reg) { base_register_ = reg; } void SetOffset(long long offset) { offset_ = offset; } private: @@ -1741,16 +1741,16 @@ class CallFrameInfo::RegisterRule: public CallFrameInfo::Rule { explicit RegisterRule(int register_number) : register_number_(register_number) { } ~RegisterRule() { } - bool Handle(Handler *handler, uint64_t address, int reg) const { + bool Handle(Handler* handler, uint64_t address, int reg) const { return handler->RegisterRule(address, reg, register_number_); } - bool operator==(const Rule &rhs) const { + bool operator==(const Rule& rhs) const { // dynamic_cast is allowed by the Google C++ Style Guide, if the use has // been carefully considered; cheap RTTI-like workarounds are forbidden. - const RegisterRule *our_rhs = dynamic_cast(&rhs); + const RegisterRule* our_rhs = dynamic_cast(&rhs); return (our_rhs && register_number_ == our_rhs->register_number_); } - Rule *Copy() const { return new RegisterRule(*this); } + Rule* Copy() const { return new RegisterRule(*this); } private: int register_number_; }; @@ -1758,19 +1758,19 @@ class CallFrameInfo::RegisterRule: public CallFrameInfo::Rule { // Rule: EXPRESSION evaluates to the address at which the register is saved. class CallFrameInfo::ExpressionRule: public CallFrameInfo::Rule { public: - explicit ExpressionRule(const string &expression) + explicit ExpressionRule(const string& expression) : expression_(expression) { } ~ExpressionRule() { } - bool Handle(Handler *handler, uint64_t address, int reg) const { + bool Handle(Handler* handler, uint64_t address, int reg) const { return handler->ExpressionRule(address, reg, expression_); } - bool operator==(const Rule &rhs) const { + bool operator==(const Rule& rhs) const { // dynamic_cast is allowed by the Google C++ Style Guide, if the use has // been carefully considered; cheap RTTI-like workarounds are forbidden. - const ExpressionRule *our_rhs = dynamic_cast(&rhs); + const ExpressionRule* our_rhs = dynamic_cast(&rhs); return (our_rhs && expression_ == our_rhs->expression_); } - Rule *Copy() const { return new ExpressionRule(*this); } + Rule* Copy() const { return new ExpressionRule(*this); } private: string expression_; }; @@ -1778,20 +1778,20 @@ class CallFrameInfo::ExpressionRule: public CallFrameInfo::Rule { // Rule: EXPRESSION evaluates to the address at which the register is saved. class CallFrameInfo::ValExpressionRule: public CallFrameInfo::Rule { public: - explicit ValExpressionRule(const string &expression) + explicit ValExpressionRule(const string& expression) : expression_(expression) { } ~ValExpressionRule() { } - bool Handle(Handler *handler, uint64_t address, int reg) const { + bool Handle(Handler* handler, uint64_t address, int reg) const { return handler->ValExpressionRule(address, reg, expression_); } - bool operator==(const Rule &rhs) const { + bool operator==(const Rule& rhs) const { // dynamic_cast is allowed by the Google C++ Style Guide, if the use has // been carefully considered; cheap RTTI-like workarounds are forbidden. - const ValExpressionRule *our_rhs = - dynamic_cast(&rhs); + const ValExpressionRule* our_rhs = + dynamic_cast(&rhs); return (our_rhs && expression_ == our_rhs->expression_); } - Rule *Copy() const { return new ValExpressionRule(*this); } + Rule* Copy() const { return new ValExpressionRule(*this); } private: string expression_; }; @@ -1800,51 +1800,51 @@ class CallFrameInfo::ValExpressionRule: public CallFrameInfo::Rule { class CallFrameInfo::RuleMap { public: RuleMap() : cfa_rule_(NULL) { } - RuleMap(const RuleMap &rhs) : cfa_rule_(NULL) { *this = rhs; } + RuleMap(const RuleMap& rhs) : cfa_rule_(NULL) { *this = rhs; } ~RuleMap() { Clear(); } - RuleMap &operator=(const RuleMap &rhs); + RuleMap& operator=(const RuleMap& rhs); // Set the rule for computing the CFA to RULE. Take ownership of RULE. - void SetCFARule(Rule *rule) { delete cfa_rule_; cfa_rule_ = rule; } + void SetCFARule(Rule* rule) { delete cfa_rule_; cfa_rule_ = rule; } // Return the current CFA rule. Unlike RegisterRule, this RuleMap retains // ownership of the rule. We use this for DW_CFA_def_cfa_offset and // DW_CFA_def_cfa_register, and for detecting references to the CFA before // a rule for it has been established. - Rule *CFARule() const { return cfa_rule_; } + Rule* CFARule() const { return cfa_rule_; } // Return the rule for REG, or NULL if there is none. The caller takes // ownership of the result. - Rule *RegisterRule(int reg) const; + Rule* RegisterRule(int reg) const; // Set the rule for computing REG to RULE. Take ownership of RULE. - void SetRegisterRule(int reg, Rule *rule); + void SetRegisterRule(int reg, Rule* rule); // Make all the appropriate calls to HANDLER as if we were changing from // this RuleMap to NEW_RULES at ADDRESS. We use this to implement // DW_CFA_restore_state, where lots of rules can change simultaneously. // Return true if all handlers returned true; otherwise, return false. - bool HandleTransitionTo(Handler *handler, uint64_t address, - const RuleMap &new_rules) const; + bool HandleTransitionTo(Handler* handler, uint64_t address, + const RuleMap& new_rules) const; private: // A map from register numbers to Rules. - typedef std::map RuleByNumber; + typedef std::map RuleByNumber; // Remove all register rules and clear cfa_rule_. void Clear(); // The rule for computing the canonical frame address. This RuleMap owns // this rule. - Rule *cfa_rule_; + Rule* cfa_rule_; // A map from register numbers to postfix expressions to recover // their values. This RuleMap owns the Rules the map refers to. RuleByNumber registers_; }; -CallFrameInfo::RuleMap &CallFrameInfo::RuleMap::operator=(const RuleMap &rhs) { +CallFrameInfo::RuleMap& CallFrameInfo::RuleMap::operator=(const RuleMap& rhs) { Clear(); // Since each map owns the rules it refers to, assignment must copy them. if (rhs.cfa_rule_) cfa_rule_ = rhs.cfa_rule_->Copy(); @@ -1854,7 +1854,7 @@ CallFrameInfo::RuleMap &CallFrameInfo::RuleMap::operator=(const RuleMap &rhs) { return *this; } -CallFrameInfo::Rule *CallFrameInfo::RuleMap::RegisterRule(int reg) const { +CallFrameInfo::Rule* CallFrameInfo::RuleMap::RegisterRule(int reg) const { assert(reg != Handler::kCFARegister); RuleByNumber::const_iterator it = registers_.find(reg); if (it != registers_.end()) @@ -1863,18 +1863,18 @@ CallFrameInfo::Rule *CallFrameInfo::RuleMap::RegisterRule(int reg) const { return NULL; } -void CallFrameInfo::RuleMap::SetRegisterRule(int reg, Rule *rule) { +void CallFrameInfo::RuleMap::SetRegisterRule(int reg, Rule* rule) { assert(reg != Handler::kCFARegister); assert(rule); - Rule **slot = ®isters_[reg]; + Rule** slot = ®isters_[reg]; delete *slot; *slot = rule; } bool CallFrameInfo::RuleMap::HandleTransitionTo( - Handler *handler, + Handler* handler, uint64_t address, - const RuleMap &new_rules) const { + const RuleMap& new_rules) const { // Transition from cfa_rule_ to new_rules.cfa_rule_. if (cfa_rule_ && new_rules.cfa_rule_) { if (*cfa_rule_ != *new_rules.cfa_rule_ && @@ -1954,7 +1954,7 @@ class CallFrameInfo::State { public: // Create a call frame information interpreter state with the given // reporter, reader, handler, and initial call frame info address. - State(ByteReader *reader, Handler *handler, Reporter *reporter, + State(ByteReader* reader, Handler* handler, Reporter* reporter, uint64_t address) : reader_(reader), handler_(handler), reporter_(reporter), address_(address), entry_(NULL), cursor_(NULL) { } @@ -1962,11 +1962,11 @@ class CallFrameInfo::State { // Interpret instructions from CIE, save the resulting rule set for // DW_CFA_restore instructions, and return true. On error, report // the problem to reporter_ and return false. - bool InterpretCIE(const CIE &cie); + bool InterpretCIE(const CIE& cie); // Interpret instructions from FDE, and return true. On error, // report the problem to reporter_ and return false. - bool InterpretFDE(const FDE &fde); + bool InterpretFDE(const FDE& fde); private: // The operands of a CFI instruction, for ParseOperands. @@ -1996,7 +1996,7 @@ class CallFrameInfo::State { // '8' an eight-byte offset (OPERANDS->offset) // 'e' a DW_FORM_block holding a (OPERANDS->expression) // DWARF expression - bool ParseOperands(const char *format, Operands *operands); + bool ParseOperands(const char* format, Operands* operands); // Interpret one CFI instruction from STATE's instruction stream, update // STATE, report any rule changes to handler_, and return true. On @@ -2019,7 +2019,7 @@ class CallFrameInfo::State { // Specify that REG can be recovered using RULE, and return true. On // failure, report and return false. - bool DoRule(unsigned reg, Rule *rule); + bool DoRule(unsigned reg, Rule* rule); // Specify that REG can be found at OFFSET from the CFA, and return true. // On failure, report and return false. (Subroutine for DW_CFA_offset, @@ -2047,23 +2047,23 @@ class CallFrameInfo::State { } // For reading multi-byte values with the appropriate endianness. - ByteReader *reader_; + ByteReader* reader_; // The handler to which we should report the data we find. - Handler *handler_; + Handler* handler_; // For reporting problems in the info we're parsing. - Reporter *reporter_; + Reporter* reporter_; // The code address to which the next instruction in the stream applies. uint64_t address_; // The entry whose instructions we are currently processing. This is // first a CIE, and then an FDE. - const Entry *entry_; + const Entry* entry_; // The next instruction to process. - const uint8_t *cursor_; + const uint8_t* cursor_; // The current set of rules. RuleMap rules_; @@ -2078,7 +2078,7 @@ class CallFrameInfo::State { std::stack saved_rules_; }; -bool CallFrameInfo::State::InterpretCIE(const CIE &cie) { +bool CallFrameInfo::State::InterpretCIE(const CIE& cie) { entry_ = &cie; cursor_ = entry_->instructions; while (cursor_ < entry_->end) @@ -2090,7 +2090,7 @@ bool CallFrameInfo::State::InterpretCIE(const CIE &cie) { return true; } -bool CallFrameInfo::State::InterpretFDE(const FDE &fde) { +bool CallFrameInfo::State::InterpretFDE(const FDE& fde) { entry_ = &fde; cursor_ = entry_->instructions; while (cursor_ < entry_->end) @@ -2099,10 +2099,10 @@ bool CallFrameInfo::State::InterpretFDE(const FDE &fde) { return true; } -bool CallFrameInfo::State::ParseOperands(const char *format, - Operands *operands) { +bool CallFrameInfo::State::ParseOperands(const char* format, + Operands* operands) { size_t len; - const char *operand; + const char* operand; for (operand = format; *operand; operand++) { size_t bytes_left = entry_->end - cursor_; @@ -2161,7 +2161,7 @@ bool CallFrameInfo::State::ParseOperands(const char *format, if (len > bytes_left || expression_length > bytes_left - len) return ReportIncomplete(); cursor_ += len; - operands->expression = string(reinterpret_cast(cursor_), + operands->expression = string(reinterpret_cast(cursor_), expression_length); cursor_ += expression_length; break; @@ -2176,7 +2176,7 @@ bool CallFrameInfo::State::ParseOperands(const char *format, } bool CallFrameInfo::State::DoInstruction() { - CIE *cie = entry_->cie; + CIE* cie = entry_->cie; Operands ops; // Our entry's kind should have been set by now. @@ -2266,7 +2266,7 @@ bool CallFrameInfo::State::DoInstruction() { // Change the base register used to compute the CFA. case DW_CFA_def_cfa_register: { if (!ParseOperands("r", &ops)) return false; - Rule *cfa_rule = rules_.CFARule(); + Rule* cfa_rule = rules_.CFARule(); if (!cfa_rule) { if (!DoDefCFA(ops.register_number, ops.offset)) { reporter_->NoCFARule(entry_->offset, entry_->kind, CursorOffset()); @@ -2299,7 +2299,7 @@ bool CallFrameInfo::State::DoInstruction() { case DW_CFA_def_cfa_expression: { if (!ParseOperands("e", &ops)) return false; - Rule *rule = new ValExpressionRule(ops.expression); + Rule* rule = new ValExpressionRule(ops.expression); rules_.SetCFARule(rule); if (!rule->Handle(handler_, address_, Handler::kCFARegister)) @@ -2406,7 +2406,7 @@ bool CallFrameInfo::State::DoInstruction() { CursorOffset()); return false; } - const RuleMap &new_rules = saved_rules_.top(); + const RuleMap& new_rules = saved_rules_.top(); if (rules_.CFARule() && !new_rules.CFARule()) { reporter_->ClearingCFARule(entry_->offset, entry_->kind, CursorOffset()); @@ -2458,14 +2458,14 @@ bool CallFrameInfo::State::DoInstruction() { } bool CallFrameInfo::State::DoDefCFA(unsigned base_register, long offset) { - Rule *rule = new ValOffsetRule(base_register, offset); + Rule* rule = new ValOffsetRule(base_register, offset); rules_.SetCFARule(rule); return rule->Handle(handler_, address_, Handler::kCFARegister); } bool CallFrameInfo::State::DoDefCFAOffset(long offset) { - Rule *cfa_rule = rules_.CFARule(); + Rule* cfa_rule = rules_.CFARule(); if (!cfa_rule) { reporter_->NoCFARule(entry_->offset, entry_->kind, CursorOffset()); return false; @@ -2475,7 +2475,7 @@ bool CallFrameInfo::State::DoDefCFAOffset(long offset) { Handler::kCFARegister); } -bool CallFrameInfo::State::DoRule(unsigned reg, Rule *rule) { +bool CallFrameInfo::State::DoRule(unsigned reg, Rule* rule) { rules_.SetRegisterRule(reg, rule); return rule->Handle(handler_, address_, reg); } @@ -2504,7 +2504,7 @@ bool CallFrameInfo::State::DoRestore(unsigned reg) { reporter_->RestoreInCIE(entry_->offset, CursorOffset()); return false; } - Rule *rule = cie_rules_.RegisterRule(reg); + Rule* rule = cie_rules_.RegisterRule(reg); if (!rule) { // This isn't really the right thing to do, but since CFI generally // only mentions callee-saves registers, and GCC's convention for @@ -2515,8 +2515,8 @@ bool CallFrameInfo::State::DoRestore(unsigned reg) { return DoRule(reg, rule); } -bool CallFrameInfo::ReadEntryPrologue(const uint8_t *cursor, Entry *entry) { - const uint8_t *buffer_end = buffer_ + buffer_length_; +bool CallFrameInfo::ReadEntryPrologue(const uint8_t* cursor, Entry* entry) { + const uint8_t* buffer_end = buffer_ + buffer_length_; // Initialize enough of ENTRY for use in error reporting. entry->offset = cursor - buffer_; @@ -2593,8 +2593,8 @@ bool CallFrameInfo::ReadEntryPrologue(const uint8_t *cursor, Entry *entry) { return true; } -bool CallFrameInfo::ReadCIEFields(CIE *cie) { - const uint8_t *cursor = cie->fields; +bool CallFrameInfo::ReadCIEFields(CIE* cie) { + const uint8_t* cursor = cie->fields; size_t len; assert(cie->kind == kCIE); @@ -2625,13 +2625,13 @@ bool CallFrameInfo::ReadCIEFields(CIE *cie) { return false; } - const uint8_t *augmentation_start = cursor; - const uint8_t *augmentation_end = - reinterpret_cast(memchr(augmentation_start, '\0', + const uint8_t* augmentation_start = cursor; + const uint8_t* augmentation_end = + reinterpret_cast(memchr(augmentation_start, '\0', cie->end - augmentation_start)); if (! augmentation_end) return ReportIncomplete(cie); cursor = augmentation_end; - cie->augmentation = string(reinterpret_cast(augmentation_start), + cie->augmentation = string(reinterpret_cast(augmentation_start), cursor - augmentation_start); // Skip the terminating '\0'. cursor++; @@ -2692,9 +2692,9 @@ bool CallFrameInfo::ReadCIEFields(CIE *cie) { if (size_t(cie->end - cursor) < len + data_size) return ReportIncomplete(cie); cursor += len; - const uint8_t *data = cursor; + const uint8_t* data = cursor; cursor += data_size; - const uint8_t *data_end = cursor; + const uint8_t* data_end = cursor; cie->has_z_lsda = false; cie->has_z_personality = false; @@ -2785,8 +2785,8 @@ bool CallFrameInfo::ReadCIEFields(CIE *cie) { return true; } -bool CallFrameInfo::ReadFDEFields(FDE *fde) { - const uint8_t *cursor = fde->fields; +bool CallFrameInfo::ReadFDEFields(FDE* fde) { + const uint8_t* cursor = fde->fields; size_t size; fde->address = reader_->ReadEncodedPointer(cursor, fde->cie->pointer_encoding, @@ -2852,10 +2852,10 @@ bool CallFrameInfo::ReadFDEFields(FDE *fde) { } bool CallFrameInfo::Start() { - const uint8_t *buffer_end = buffer_ + buffer_length_; - const uint8_t *cursor; + const uint8_t* buffer_end = buffer_ + buffer_length_; + const uint8_t* cursor; bool all_ok = true; - const uint8_t *entry_end; + const uint8_t* entry_end; bool ok; // Traverse all the entries in buffer_, skipping CIEs and offering @@ -2986,7 +2986,7 @@ bool CallFrameInfo::Start() { return all_ok; } -const char *CallFrameInfo::KindName(EntryKind kind) { +const char* CallFrameInfo::KindName(EntryKind kind) { if (kind == CallFrameInfo::kUnknown) return "entry"; else if (kind == CallFrameInfo::kCIE) @@ -2999,7 +2999,7 @@ const char *CallFrameInfo::KindName(EntryKind kind) { } } -bool CallFrameInfo::ReportIncomplete(Entry *entry) { +bool CallFrameInfo::ReportIncomplete(Entry* entry) { reporter_->Incomplete(entry->offset, entry->kind); return false; } @@ -3058,7 +3058,7 @@ void CallFrameInfo::Reporter::UnrecognizedVersion(uint64_t offset, int version) } void CallFrameInfo::Reporter::UnrecognizedAugmentation(uint64_t offset, - const string &aug) { + const string& aug) { fprintf(stderr, "%s: CFI frame description entry at offset 0x%" PRIx64 " in '%s':" " CIE specifies unrecognized augmentation: '%s'\n", diff --git a/src/common/dwarf/dwarf2reader.h b/src/common/dwarf/dwarf2reader.h index e52f74c5..83cd6767 100644 --- a/src/common/dwarf/dwarf2reader.h +++ b/src/common/dwarf/dwarf2reader.h @@ -64,13 +64,13 @@ class DwpReader; // This maps from a string naming a section to a pair containing a // the data for the section, and the size of the section. -typedef std::map > SectionMap; +typedef std::map > SectionMap; // Abstract away the difference between elf and mach-o section names. // Elf-names use ".section_name, mach-o uses "__section_name". Pass "name" in // the elf form, ".section_name". const SectionMap::const_iterator GetSectionByName(const SectionMap& - sections, const char *name); + sections, const char* name); typedef std::list > AttributeList; @@ -88,7 +88,7 @@ struct LineInfoHeader { uint8_t opcode_base; // Use a pointer so that signalsafe_addr2line is able to use this structure // without heap allocation problem. - std::vector *std_opcode_lengths; + std::vector* std_opcode_lengths; }; class LineInfo { @@ -125,12 +125,12 @@ class LineInfo { // lsm's old address < PC <= lsm's new address static bool ProcessOneOpcode(ByteReader* reader, LineInfoHandler* handler, - const struct LineInfoHeader &header, - const uint8_t *start, + const struct LineInfoHeader& header, + const uint8_t* start, struct LineStateMachine* lsm, size_t* len, uintptr pc, - bool *lsm_passes_pc); + bool* lsm_passes_pc); private: // Reads the DWARF2/3 header for this line info. @@ -171,7 +171,7 @@ class LineInfo { // buffer is the buffer for our line info, starting at exactly where // the line info to read is. after_header is the place right after // the end of the line information header. - const uint8_t *buffer_; + const uint8_t* buffer_; #ifndef NDEBUG uint64_t buffer_length_; #endif @@ -182,7 +182,7 @@ class LineInfo { const uint8_t* line_string_buffer_; uint64_t line_string_buffer_length_; - const uint8_t *after_header_; + const uint8_t* after_header_; }; // This class is the main interface between the line info reader and @@ -239,16 +239,16 @@ class RangeListHandler { class RangeListReader { public: - RangeListReader(const uint8_t *buffer, uint64_t size, ByteReader *reader, - RangeListHandler *handler); + RangeListReader(const uint8_t* buffer, uint64_t size, ByteReader* reader, + RangeListHandler* handler); bool ReadRangeList(uint64_t offset); private: - const uint8_t *buffer_; + const uint8_t* buffer_; uint64_t size_; ByteReader* reader_; - RangeListHandler *handler_; + RangeListHandler* handler_; }; // This class is the main interface between the reader and the @@ -322,7 +322,7 @@ class Dwarf2Handler { virtual void ProcessAttributeBuffer(uint64_t offset, enum DwarfAttribute attr, enum DwarfForm form, - const uint8_t *data, + const uint8_t* data, uint64_t len) { } // Called when we have an attribute with string data to give to our handler. @@ -461,14 +461,14 @@ class CompilationUnit { // Processes a single DIE for this compilation unit and return a new // pointer just past the end of it - const uint8_t *ProcessDIE(uint64_t dieoffset, - const uint8_t *start, + const uint8_t* ProcessDIE(uint64_t dieoffset, + const uint8_t* start, const Abbrev& abbrev); // Processes a single attribute and return a new pointer just past the // end of it - const uint8_t *ProcessAttribute(uint64_t dieoffset, - const uint8_t *start, + const uint8_t* ProcessAttribute(uint64_t dieoffset, + const uint8_t* start, enum DwarfAttribute attr, enum DwarfForm form); @@ -564,11 +564,11 @@ class CompilationUnit { // Skips the die with attributes specified in ABBREV starting at // START, and return the new place to position the stream to. - const uint8_t *SkipDIE(const uint8_t *start, const Abbrev& abbrev); + const uint8_t* SkipDIE(const uint8_t* start, const Abbrev& abbrev); // Skips the attribute starting at START, with FORM, and return the // new place to position the stream to. - const uint8_t *SkipAttribute(const uint8_t *start, enum DwarfForm form); + const uint8_t* SkipAttribute(const uint8_t* start, enum DwarfForm form); // Process the actual debug information in a split DWARF file. void ProcessSplitDwarf(); @@ -587,9 +587,9 @@ class CompilationUnit { // buffer is the buffer for our CU, starting at .debug_info + offset // passed in from constructor. // after_header points to right after the compilation unit header. - const uint8_t *buffer_; + const uint8_t* buffer_; uint64_t buffer_length_; - const uint8_t *after_header_; + const uint8_t* after_header_; // The associated ByteReader that handles endianness issues for us ByteReader* reader_; @@ -608,7 +608,7 @@ class CompilationUnit { // String section buffer and length, if we have a string section. // This is here to avoid doing a section lookup for strings in // ProcessAttribute, which is in the hot path for DWARF2 reading. - const uint8_t *string_buffer_; + const uint8_t* string_buffer_; uint64_t string_buffer_length_; // Similarly for .debug_line_string. @@ -984,8 +984,8 @@ class CallFrameInfo { // The mechanics of C++ exception handling, personality routines, // and language-specific data areas are described here, rather nicely: // http://www.codesourcery.com/public/cxx-abi/abi-eh.html - CallFrameInfo(const uint8_t *buffer, size_t buffer_length, - ByteReader *reader, Handler *handler, Reporter *reporter, + CallFrameInfo(const uint8_t* buffer, size_t buffer_length, + ByteReader* reader, Handler* handler, Reporter* reporter, bool eh_frame = false) : buffer_(buffer), buffer_length_(buffer_length), reader_(reader), handler_(handler), reporter_(reporter), @@ -999,7 +999,7 @@ class CallFrameInfo { bool Start(); // Return the textual name of KIND. For error reporting. - static const char *KindName(EntryKind kind); + static const char* KindName(EntryKind kind); private: @@ -1012,7 +1012,7 @@ class CallFrameInfo { size_t offset; // The start of this entry in the buffer. - const uint8_t *start; + const uint8_t* start; // Which kind of entry this is. // @@ -1023,16 +1023,16 @@ class CallFrameInfo { // The end of this entry's common prologue (initial length and id), and // the start of this entry's kind-specific fields. - const uint8_t *fields; + const uint8_t* fields; // The start of this entry's instructions. - const uint8_t *instructions; + const uint8_t* instructions; // The address past the entry's last byte in the buffer. (Note that // since offset points to the entry's initial length field, and the // length field is the number of bytes after that field, this is not // simply buffer_ + offset + length.) - const uint8_t *end; + const uint8_t* end; // For both DWARF CFI and .eh_frame sections, this is the CIE id in a // CIE, and the offset of the associated CIE in an FDE. @@ -1040,7 +1040,7 @@ class CallFrameInfo { // The CIE that applies to this entry, if we've parsed it. If this is a // CIE, then this field points to this structure. - CIE *cie; + CIE* cie; }; // A common information entry (CIE). @@ -1114,14 +1114,14 @@ class CallFrameInfo { // true. On failure, report the problem, and return false. Even if we // return false, set ENTRY->end to the first byte after the entry if we // were able to figure that out, or NULL if we weren't. - bool ReadEntryPrologue(const uint8_t *cursor, Entry *entry); + bool ReadEntryPrologue(const uint8_t* cursor, Entry* entry); // Parse the fields of a CIE after the entry prologue, including any 'z' // augmentation data. Assume that the 'Entry' fields of CIE are // populated; use CIE->fields and CIE->end as the start and limit for // parsing. On success, populate the rest of *CIE, and return true; on // failure, report the problem and return false. - bool ReadCIEFields(CIE *cie); + bool ReadCIEFields(CIE* cie); // Parse the fields of an FDE after the entry prologue, including any 'z' // augmentation data. Assume that the 'Entry' fields of *FDE are @@ -1129,12 +1129,12 @@ class CallFrameInfo { // parsing. Assume that FDE->cie is fully initialized. On success, // populate the rest of *FDE, and return true; on failure, report the // problem and return false. - bool ReadFDEFields(FDE *fde); + bool ReadFDEFields(FDE* fde); // Report that ENTRY is incomplete, and return false. This is just a // trivial wrapper for invoking reporter_->Incomplete; it provides a // little brevity. - bool ReportIncomplete(Entry *entry); + bool ReportIncomplete(Entry* entry); // Return true if ENCODING has the DW_EH_PE_indirect bit set. static bool IsIndirectEncoding(DwarfPointerEncoding encoding) { @@ -1142,17 +1142,17 @@ class CallFrameInfo { } // The contents of the DWARF .debug_info section we're parsing. - const uint8_t *buffer_; + const uint8_t* buffer_; size_t buffer_length_; // For reading multi-byte values with the appropriate endianness. - ByteReader *reader_; + ByteReader* reader_; // The handler to which we should report the data we find. - Handler *handler_; + Handler* handler_; // For reporting problems in the info we're parsing. - Reporter *reporter_; + Reporter* reporter_; // True if we are processing .eh_frame-format data. bool eh_frame_; @@ -1185,7 +1185,7 @@ class CallFrameInfo::Handler { // process a given FDE, the parser reiterates the appropriate CIE's // contents at the beginning of the FDE's rules. virtual bool Entry(size_t offset, uint64_t address, uint64_t length, - uint8_t version, const string &augmentation, + uint8_t version, const string& augmentation, unsigned return_address) = 0; // When the Entry function returns true, the parser calls these @@ -1234,13 +1234,13 @@ class CallFrameInfo::Handler { // At ADDRESS, the DWARF expression EXPRESSION yields the address at // which REG was saved. virtual bool ExpressionRule(uint64_t address, int reg, - const string &expression) = 0; + const string& expression) = 0; // At ADDRESS, the DWARF expression EXPRESSION yields the caller's // value for REG. (This rule doesn't provide an address at which the // register's value is saved.) virtual bool ValExpressionRule(uint64_t address, int reg, - const string &expression) = 0; + const string& expression) = 0; // Indicate that the rules for the address range reported by the // last call to Entry are complete. End should return true if @@ -1317,8 +1317,8 @@ class CallFrameInfo::Reporter { // in a Mach-O section named __debug_frame. If we support // Linux-style exception handling data, we could be reading an // .eh_frame section. - Reporter(const string &filename, - const string §ion = ".debug_frame") + Reporter(const string& filename, + const string& section = ".debug_frame") : filename_(filename), section_(section) { } virtual ~Reporter() { } @@ -1358,7 +1358,7 @@ class CallFrameInfo::Reporter { // which we don't recognize. We cannot parse DWARF CFI if it uses // augmentations we don't recognize. virtual void UnrecognizedAugmentation(uint64_t offset, - const string &augmentation); + const string& augmentation); // The pointer encoding ENCODING, specified by the CIE at OFFSET, is not // a valid encoding. diff --git a/src/common/dwarf/dwarf2reader_cfi_unittest.cc b/src/common/dwarf/dwarf2reader_cfi_unittest.cc index ebe612e1..8e5d68b4 100644 --- a/src/common/dwarf/dwarf2reader_cfi_unittest.cc +++ b/src/common/dwarf/dwarf2reader_cfi_unittest.cc @@ -87,7 +87,7 @@ using testing::_; #ifdef WRITE_ELF void WriteELFFrameSection(const char *filename, const char *section_name, - const CFISection §ion); + const CFISection& section); #define PERHAPS_WRITE_DEBUG_FRAME_FILE(name, section) \ WriteELFFrameSection("cfitest-" name, ".debug_frame", section); #define PERHAPS_WRITE_EH_FRAME_FILE(name, section) \ @@ -100,7 +100,7 @@ void WriteELFFrameSection(const char *filename, const char *section_name, class MockCallFrameInfoHandler: public CallFrameInfo::Handler { public: MOCK_METHOD6(Entry, bool(size_t offset, uint64_t address, uint64_t length, - uint8_t version, const string &augmentation, + uint8_t version, const string& augmentation, unsigned return_address)); MOCK_METHOD2(UndefinedRule, bool(uint64_t address, int reg)); MOCK_METHOD2(SameValueRule, bool(uint64_t address, int reg)); @@ -110,9 +110,9 @@ class MockCallFrameInfoHandler: public CallFrameInfo::Handler { long offset)); MOCK_METHOD3(RegisterRule, bool(uint64_t address, int reg, int base_register)); MOCK_METHOD3(ExpressionRule, bool(uint64_t address, int reg, - const string &expression)); + const string& expression)); MOCK_METHOD3(ValExpressionRule, bool(uint64_t address, int reg, - const string &expression)); + const string& expression)); MOCK_METHOD0(End, bool()); MOCK_METHOD2(PersonalityRoutine, bool(uint64_t address, bool indirect)); MOCK_METHOD2(LanguageSpecificDataArea, bool(uint64_t address, bool indirect)); @@ -129,7 +129,7 @@ class MockCallFrameErrorReporter: public CallFrameInfo::Reporter { MOCK_METHOD2(UnexpectedAddressSize, void(uint64_t, uint8_t)); MOCK_METHOD2(UnexpectedSegmentSize, void(uint64_t, uint8_t)); MOCK_METHOD2(UnrecognizedVersion, void(uint64_t, int version)); - MOCK_METHOD2(UnrecognizedAugmentation, void(uint64_t, const string &)); + MOCK_METHOD2(UnrecognizedAugmentation, void(uint64_t, const string&)); MOCK_METHOD2(InvalidPointerEncoding, void(uint64_t, uint8_t)); MOCK_METHOD2(UnusablePointerEncoding, void(uint64_t, uint8_t)); MOCK_METHOD2(RestoreInCIE, void(uint64_t, uint64_t)); @@ -218,7 +218,7 @@ TEST_F(CFI, IncompleteLength32) { ByteReader byte_reader(ENDIANNESS_BIG); byte_reader.SetAddressSize(8); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size() - 2, &byte_reader, &handler, &reporter); EXPECT_FALSE(parser.Start()); @@ -244,7 +244,7 @@ TEST_F(CFI, IncompleteLength64) { ByteReader byte_reader(ENDIANNESS_LITTLE); byte_reader.SetAddressSize(4); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size() - 4, &byte_reader, &handler, &reporter); EXPECT_FALSE(parser.Start()); @@ -269,7 +269,7 @@ TEST_F(CFI, IncompleteId32) { ByteReader byte_reader(ENDIANNESS_BIG); byte_reader.SetAddressSize(8); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_FALSE(parser.Start()); @@ -296,7 +296,7 @@ TEST_F(CFI, BadId32) { ByteReader byte_reader(ENDIANNESS_BIG); byte_reader.SetAddressSize(8); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_FALSE(parser.Start()); @@ -318,7 +318,7 @@ TEST_F(CFI, SingleCIE) { EXPECT_TRUE(section.GetContents(&contents)); ByteReader byte_reader(ENDIANNESS_LITTLE); byte_reader.SetAddressSize(4); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_TRUE(parser.Start()); @@ -349,7 +349,7 @@ TEST_F(CFI, OneFDE) { EXPECT_TRUE(section.GetContents(&contents)); ByteReader byte_reader(ENDIANNESS_BIG); byte_reader.SetAddressSize(4); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_TRUE(parser.Start()); @@ -393,7 +393,7 @@ TEST_F(CFI, TwoFDEsOneCIE) { EXPECT_TRUE(section.GetContents(&contents)); ByteReader byte_reader(ENDIANNESS_BIG); byte_reader.SetAddressSize(4); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_TRUE(parser.Start()); @@ -443,7 +443,7 @@ TEST_F(CFI, TwoFDEsTwoCIEs) { EXPECT_TRUE(section.GetContents(&contents)); ByteReader byte_reader(ENDIANNESS_LITTLE); byte_reader.SetAddressSize(8); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_TRUE(parser.Start()); @@ -488,7 +488,7 @@ TEST_F(CFI, BadVersion) { EXPECT_TRUE(section.GetContents(&contents)); ByteReader byte_reader(ENDIANNESS_BIG); byte_reader.SetAddressSize(4); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_FALSE(parser.Start()); @@ -533,7 +533,7 @@ TEST_F(CFI, BadAugmentation) { EXPECT_TRUE(section.GetContents(&contents)); ByteReader byte_reader(ENDIANNESS_BIG); byte_reader.SetAddressSize(4); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_FALSE(parser.Start()); @@ -568,7 +568,7 @@ TEST_F(CFI, CIEVersion1ReturnColumn) { EXPECT_TRUE(section.GetContents(&contents)); ByteReader byte_reader(ENDIANNESS_BIG); byte_reader.SetAddressSize(4); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_TRUE(parser.Start()); @@ -603,7 +603,7 @@ TEST_F(CFI, CIEVersion3ReturnColumn) { EXPECT_TRUE(section.GetContents(&contents)); ByteReader byte_reader(ENDIANNESS_BIG); byte_reader.SetAddressSize(4); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_TRUE(parser.Start()); @@ -633,7 +633,7 @@ TEST_F(CFI, CIEVersion4AdditionalFields) { string contents; EXPECT_TRUE(section.GetContents(&contents)); ByteReader byte_reader(ENDIANNESS_BIG); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_TRUE(parser.Start()); @@ -663,7 +663,7 @@ TEST_F(CFI, CIEVersion4AdditionalFields32BitAddress) { string contents; EXPECT_TRUE(section.GetContents(&contents)); ByteReader byte_reader(ENDIANNESS_BIG); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_TRUE(parser.Start()); @@ -690,7 +690,7 @@ TEST_F(CFI, CIEVersion4AdditionalFieldsUnexpectedAddressSize) { string contents; EXPECT_TRUE(section.GetContents(&contents)); ByteReader byte_reader(ENDIANNESS_BIG); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_FALSE(parser.Start()); @@ -715,7 +715,7 @@ TEST_F(CFI, CIEVersion4AdditionalFieldsUnexpectedSegmentSize) { string contents; EXPECT_TRUE(section.GetContents(&contents)); ByteReader byte_reader(ENDIANNESS_BIG); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); EXPECT_FALSE(parser.Start()); @@ -797,7 +797,7 @@ struct CFIInsnFixture: public CFIFixture { } ByteReader byte_reader(endianness); byte_reader.SetAddressSize(section->AddressSize()); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter); if (succeeds) @@ -2120,10 +2120,10 @@ struct EHFrameFixture: public CFIInsnFixture { ByteReader byte_reader(endianness); byte_reader.SetAddressSize(section->AddressSize()); byte_reader.SetCFIDataBase(encoded_pointer_bases.cfi, - reinterpret_cast(contents.data())); + reinterpret_cast(contents.data())); byte_reader.SetTextBase(encoded_pointer_bases.text); byte_reader.SetDataBase(encoded_pointer_bases.data); - CallFrameInfo parser(reinterpret_cast(contents.data()), + CallFrameInfo parser(reinterpret_cast(contents.data()), contents.size(), &byte_reader, &handler, &reporter, true); if (succeeds) @@ -2468,7 +2468,7 @@ struct ELFSectionHeader { uint64_t entry_size; }; -void AppendSectionHeader(CFISection *table, const ELFSectionHeader &header) { +void AppendSectionHeader(CFISection* table, const ELFSectionHeader& header) { (*table) .D32(header.name) // name, index in string tbl .D32(header.type) // type @@ -2483,7 +2483,7 @@ void AppendSectionHeader(CFISection *table, const ELFSectionHeader &header) { } void WriteELFFrameSection(const char *filename, const char *cfi_name, - const CFISection &cfi) { + const CFISection& cfi) { int elf_class = cfi.AddressSize() == 4 ? ELFCLASS32 : ELFCLASS64; int elf_data = (cfi.endianness() == kBigEndian ? ELFDATA2MSB : ELFDATA2LSB); diff --git a/src/common/dwarf/dwarf2reader_die_unittest.cc b/src/common/dwarf/dwarf2reader_die_unittest.cc index ab9f7cb7..87819322 100644 --- a/src/common/dwarf/dwarf2reader_die_unittest.cc +++ b/src/common/dwarf/dwarf2reader_die_unittest.cc @@ -93,7 +93,7 @@ class MockDwarf2Handler: public Dwarf2Handler { MOCK_METHOD5(ProcessAttributeBuffer, void(uint64_t offset, enum DwarfAttribute attr, enum DwarfForm form, - const uint8_t *data, + const uint8_t* data, uint64_t len)); MOCK_METHOD4(ProcessAttributeString, void(uint64_t offset, enum DwarfAttribute attr, @@ -128,17 +128,17 @@ struct DIEFixture { // to |info|, and whose .debug_abbrev section refers to |abbrevs|. This // function returns a reference to the same SectionMap each time; new // calls wipe out maps established by earlier calls. - const SectionMap &MakeSectionMap() { + const SectionMap& MakeSectionMap() { // Copy the sections' contents into strings that will live as long as // the map itself. assert(info.GetContents(&info_contents)); assert(abbrevs.GetContents(&abbrevs_contents)); section_map.clear(); section_map[".debug_info"].first - = reinterpret_cast(info_contents.data()); + = reinterpret_cast(info_contents.data()); section_map[".debug_info"].second = info_contents.size(); section_map[".debug_abbrev"].first - = reinterpret_cast(abbrevs_contents.data()); + = reinterpret_cast(abbrevs_contents.data()); section_map[".debug_abbrev"].second = abbrevs_contents.size(); return section_map; } @@ -240,7 +240,7 @@ struct DwarfFormsFixture: public DIEFixture { // childless DIE of the given tag, with one attribute of the given name // and form. The 'info' fixture member is left just after the abbrev // code, waiting for the attribute value to be appended. - void StartSingleAttributeDIE(const DwarfHeaderParams ¶ms, + void StartSingleAttributeDIE(const DwarfHeaderParams& params, DwarfTag tag, DwarfAttribute name, DwarfForm form) { // Create the abbreviation table. @@ -260,7 +260,7 @@ struct DwarfFormsFixture: public DIEFixture { // Set up handler to expect a compilation unit matching |params|, // containing one childless DIE of the given tag, in the sequence s. Stop // just before the expectations. - void ExpectBeginCompilationUnit(const DwarfHeaderParams ¶ms, + void ExpectBeginCompilationUnit(const DwarfHeaderParams& params, DwarfTag tag, uint64_t offset=0) { EXPECT_CALL(handler, StartCompilationUnit(offset, params.address_size, @@ -279,7 +279,7 @@ struct DwarfFormsFixture: public DIEFixture { .WillOnce(Return()); } - void ParseCompilationUnit(const DwarfHeaderParams ¶ms, + void ParseCompilationUnit(const DwarfHeaderParams& params, uint64_t offset=0) { ByteReader byte_reader(params.endianness == kLittleEndian ? ENDIANNESS_LITTLE : ENDIANNESS_BIG); diff --git a/src/common/dwarf/dwarf2reader_test_common.h b/src/common/dwarf/dwarf2reader_test_common.h index c81d54a8..1934094d 100644 --- a/src/common/dwarf/dwarf2reader_test_common.h +++ b/src/common/dwarf/dwarf2reader_test_common.h @@ -70,7 +70,7 @@ class TestCompilationUnit: public google_breakpad::test_assembler::Section { // Append a DWARF compilation unit header to the section, with the given // DWARF version, abbrev table offset, and address size. - TestCompilationUnit &Header(int version, const Label &abbrev_offset, + TestCompilationUnit& Header(int version, const Label& abbrev_offset, size_t address_size) { if (format_size_ == 4) { D32(length_); @@ -92,7 +92,7 @@ class TestCompilationUnit: public google_breakpad::test_assembler::Section { } // Mark the end of this header's DIEs. - TestCompilationUnit &Finish() { + TestCompilationUnit& Finish() { length_ = Size() - post_length_offset_; return *this; } @@ -122,7 +122,7 @@ class TestAbbrevTable: public google_breakpad::test_assembler::Section { // Start a new abbreviation table entry for abbreviation code |code|, // encoding a DIE whose tag is |tag|, and which has children if and only // if |has_children| is true. - TestAbbrevTable &Abbrev(int code, DwarfTag tag, DwarfHasChild has_children) { + TestAbbrevTable& Abbrev(int code, DwarfTag tag, DwarfHasChild has_children) { assert(code != 0); ULEB128(code); ULEB128(static_cast(tag)); @@ -132,21 +132,21 @@ class TestAbbrevTable: public google_breakpad::test_assembler::Section { // Add an attribute to the current abbreviation code whose name is |name| // and whose form is |form|. - TestAbbrevTable &Attribute(DwarfAttribute name, DwarfForm form) { + TestAbbrevTable& Attribute(DwarfAttribute name, DwarfForm form) { ULEB128(static_cast(name)); ULEB128(static_cast(form)); return *this; } // Finish the current abbreviation code. - TestAbbrevTable &EndAbbrev() { + TestAbbrevTable& EndAbbrev() { ULEB128(0); ULEB128(0); return *this; } // Finish the current abbreviation table. - TestAbbrevTable &EndTable() { + TestAbbrevTable& EndTable() { ULEB128(0); return *this; } diff --git a/src/common/dwarf/elf_reader.cc b/src/common/dwarf/elf_reader.cc index 1b665213..bbfdba68 100644 --- a/src/common/dwarf/elf_reader.cc +++ b/src/common/dwarf/elf_reader.cc @@ -130,11 +130,11 @@ class Elf32 { static const int kElfClass = ELFCLASS32; // Given a symbol pointer, return the binding type (eg STB_WEAK). - static char Bind(const Elf32_Sym *sym) { + static char Bind(const Elf32_Sym* sym) { return ELF32_ST_BIND(sym->st_info); } // Given a symbol pointer, return the symbol type (eg STT_FUNC). - static char Type(const Elf32_Sym *sym) { + static char Type(const Elf32_Sym* sym) { return ELF32_ST_TYPE(sym->st_info); } @@ -158,10 +158,10 @@ class Elf64 { // What should be in the EI_CLASS header. static const int kElfClass = ELFCLASS64; - static char Bind(const Elf64_Sym *sym) { + static char Bind(const Elf64_Sym* sym) { return ELF64_ST_BIND(sym->st_info); } - static char Type(const Elf64_Sym *sym) { + static char Type(const Elf64_Sym* sym) { return ELF64_ST_TYPE(sym->st_info); } static int r_sym(const Elf64_Xword r_info) { @@ -182,8 +182,8 @@ class Elf64 { template class ElfSectionReader { public: - ElfSectionReader(const char *name, const string &path, int fd, - const typename ElfArch::Shdr §ion_header) + ElfSectionReader(const char* name, const string& path, int fd, + const typename ElfArch::Shdr& section_header) : contents_aligned_(NULL), contents_(NULL), header_(section_header) { @@ -199,7 +199,7 @@ class ElfSectionReader { contents_aligned_ = mmap(NULL, size_aligned_, PROT_READ, MAP_SHARED, fd, offset_aligned); // Set where the offset really should begin. - contents_ = reinterpret_cast(contents_aligned_) + + contents_ = reinterpret_cast(contents_aligned_) + (header_.sh_offset - offset_aligned); // Check for and handle any compressed contents. @@ -217,24 +217,24 @@ class ElfSectionReader { } // Return the section header for this section. - typename ElfArch::Shdr const &header() const { return header_; } + typename ElfArch::Shdr const& header() const { return header_; } // Return memory at the given offset within this section. - const char *GetOffset(typename ElfArch::Word bytes) const { + const char* GetOffset(typename ElfArch::Word bytes) const { return contents_ + bytes; } - const char *contents() const { return contents_; } + const char* contents() const { return contents_; } size_t section_size() const { return section_size_; } private: // page-aligned file contents - void *contents_aligned_; + void* contents_aligned_; // contents as usable by the client. For non-compressed sections, // pointer within contents_aligned_ to where the section data // begins; for compressed sections, pointer to the decompressed // data. - char *contents_; + char* contents_; // size of contents_aligned_ size_t size_aligned_; // size of contents. @@ -249,7 +249,7 @@ class ElfSectionReader { template class SymbolIterator { public: - SymbolIterator(ElfReaderImpl *reader, + SymbolIterator(ElfReaderImpl* reader, typename ElfArch::Word section_type) : symbol_section_(reader->GetSectionByType(section_type)), string_section_(NULL), @@ -280,7 +280,7 @@ class SymbolIterator { // Return a pointer to the current symbol. // REQUIRES: !done() - const typename ElfArch::Sym *GetSymbol() const { + const typename ElfArch::Sym* GetSymbol() const { return reinterpret_cast( symbol_section_->GetOffset(symbol_within_section_ * symbol_section_->header().sh_entsize)); @@ -288,7 +288,7 @@ class SymbolIterator { // Return the name of the current symbol, NULL if it has none. // REQUIRES: !done() - const char *GetSymbolName() const { + const char* GetSymbolName() const { int name_offset = GetSymbol()->st_name; if (name_offset == 0) return NULL; @@ -300,8 +300,8 @@ class SymbolIterator { } private: - const ElfSectionReader *const symbol_section_; - const ElfSectionReader *string_section_; + const ElfSectionReader* const symbol_section_; + const ElfSectionReader* string_section_; int num_symbols_in_section_; int symbol_within_section_; }; @@ -326,7 +326,7 @@ static inline bool MyHasSuffixString(const string& str, const string& suffix) { template class ElfReaderImpl { public: - explicit ElfReaderImpl(const string &path, int fd) + explicit ElfReaderImpl(const string& path, int fd) : path_(path), fd_(fd), section_headers_(NULL), @@ -347,7 +347,7 @@ class ElfReaderImpl { // "opd_section_" must always be checked for NULL before use. opd_section_ = GetSectionInfoByName(".opd", &opd_info_); for (unsigned int k = 0u; k < GetNumSections(); ++k) { - const char *name = GetSectionName(section_headers_[k].sh_name); + const char* name = GetSectionName(section_headers_[k].sh_name); if (strncmp(name, ".text", strlen(".text")) == 0) { base_for_text_ = section_headers_[k].sh_addr - section_headers_[k].sh_offset; @@ -384,7 +384,7 @@ class ElfReaderImpl { // to see if the ELF file appears to match the current // architecture. If error is non-NULL, it will be set with a reason // in case of failure. - static bool IsArchElfFile(int fd, string *error) { + static bool IsArchElfFile(int fd, string* error) { unsigned char header[EI_NIDENT]; if (pread(fd, header, sizeof(header), 0) != sizeof(header)) { if (error != NULL) *error = "Could not read header"; @@ -415,7 +415,7 @@ class ElfReaderImpl { } // Return true if we can use this symbol in Address-to-Symbol map. - bool CanUseSymbol(const char *name, const typename ElfArch::Sym *sym) { + bool CanUseSymbol(const char* name, const typename ElfArch::Sym* sym) { // For now we only save FUNC and NOTYPE symbols. For now we just // care about functions, but some functions written in assembler // don't have a proper ELF type attached to them, so we store @@ -444,7 +444,7 @@ class ElfReaderImpl { // Iterate over the symbols in a section, either SHT_DYNSYM or // SHT_SYMTAB. Add all symbols to the given SymbolMap. /* - void GetSymbolPositions(SymbolMap *symbols, + void GetSymbolPositions(SymbolMap* symbols, typename ElfArch::Word section_type, uint64_t mem_offset, uint64_t file_offset) { @@ -453,10 +453,10 @@ class ElfReaderImpl { AddrToSymMap addr_to_sym_map; for (SymbolIterator it(this, section_type); !it.done(); it.Next()) { - const char *name = it.GetSymbolName(); + const char* name = it.GetSymbolName(); if (name == NULL) continue; - const typename ElfArch::Sym *sym = it.GetSymbol(); + const typename ElfArch::Sym* sym = it.GetSymbol(); if (CanUseSymbol(name, sym)) { const int sec = sym->st_shndx; @@ -519,9 +519,9 @@ class ElfReaderImpl { if (addr_to_sym_map.empty()) { return; } - const ElfSectionReader *const symbol_section = + const ElfSectionReader* const symbol_section = this->GetSectionByType(section_type); - const ElfSectionReader *const string_section = + const ElfSectionReader* const string_section = this->GetSection(symbol_section->header().sh_link); typename AddrToSymMap::iterator curr = addr_to_sym_map.begin(); @@ -532,8 +532,8 @@ class ElfReaderImpl { for (; curr != addr_to_sym_map.end(); ++curr) { const uint64_t prev_addr = prev->first; const uint64_t curr_addr = curr->first; - const typename ElfArch::Sym *const prev_sym = prev->second; - const typename ElfArch::Sym *const curr_sym = curr->second; + const typename ElfArch::Sym* const prev_sym = prev->second; + const typename ElfArch::Sym* const curr_sym = curr->second; if (prev_addr + prev_sym->st_size <= curr_addr || // The next condition is true if two symbols overlap like this: // @@ -552,7 +552,7 @@ class ElfReaderImpl { // (e.g. 0619e071) will produce the current symbol, // which is the desired outcome. prev_addr + prev_sym->st_size < curr_addr + curr_sym->st_size) { - const char *name = string_section->GetOffset(curr_sym->st_name); + const char* name = string_section->GetOffset(curr_sym->st_name); symbols->AddSymbol(name, curr_addr, curr_sym->st_size); prev = curr; } else { @@ -572,20 +572,20 @@ class ElfReaderImpl { */ void VisitSymbols(typename ElfArch::Word section_type, - ElfReader::SymbolSink *sink) { + ElfReader::SymbolSink* sink) { VisitSymbols(section_type, sink, -1, -1, false); } void VisitSymbols(typename ElfArch::Word section_type, - ElfReader::SymbolSink *sink, + ElfReader::SymbolSink* sink, int symbol_binding, int symbol_type, bool get_raw_symbol_values) { for (SymbolIterator it(this, section_type); !it.done(); it.Next()) { - const char *name = it.GetSymbolName(); + const char* name = it.GetSymbolName(); if (!name) continue; - const typename ElfArch::Sym *sym = it.GetSymbol(); + const typename ElfArch::Sym* sym = it.GetSymbol(); if ((symbol_binding < 0 || ElfArch::Bind(sym) == symbol_binding) && (symbol_type < 0 || ElfArch::Type(sym) == symbol_type)) { typename ElfArch::Sym symbol = *sym; @@ -691,7 +691,7 @@ class ElfReaderImpl { // Return an ElfSectionReader for the first section of the given // type by iterating through all section headers. Returns NULL if // the section type is not found. - const ElfSectionReader *GetSectionByType( + const ElfSectionReader* GetSectionByType( typename ElfArch::Word section_type) { for (unsigned int k = 0u; k < GetNumSections(); ++k) { if (section_headers_[k].sh_type == section_type) { @@ -703,14 +703,14 @@ class ElfReaderImpl { // Return the name of section "shndx". Returns NULL if the section // is not found. - const char *GetSectionNameByIndex(int shndx) { + const char* GetSectionNameByIndex(int shndx) { return GetSectionName(section_headers_[shndx].sh_name); } // Return a pointer to section "shndx", and store the size in // "size". Returns NULL if the section is not found. - const char *GetSectionContentsByIndex(int shndx, size_t *size) { - const ElfSectionReader *section = GetSection(shndx); + const char* GetSectionContentsByIndex(int shndx, size_t* size) { + const ElfSectionReader* section = GetSection(shndx); if (section != NULL) { *size = section->section_size(); return section->contents(); @@ -721,16 +721,16 @@ class ElfReaderImpl { // Return a pointer to the first section of the given name by // iterating through all section headers, and store the size in // "size". Returns NULL if the section name is not found. - const char *GetSectionContentsByName(const string §ion_name, - size_t *size) { + const char* GetSectionContentsByName(const string& section_name, + size_t* size) { for (unsigned int k = 0u; k < GetNumSections(); ++k) { // When searching for sections in a .dwp file, the sections // we're looking for will always be at the end of the section // table, so reverse the direction of iteration. int shndx = is_dwp_ ? GetNumSections() - k - 1 : k; - const char *name = GetSectionName(section_headers_[shndx].sh_name); + const char* name = GetSectionName(section_headers_[shndx].sh_name); if (name != NULL && ElfReader::SectionNamesMatch(section_name, name)) { - const ElfSectionReader *section = GetSection(shndx); + const ElfSectionReader* section = GetSection(shndx); if (section == NULL) { return NULL; } else { @@ -744,16 +744,16 @@ class ElfReaderImpl { // This is like GetSectionContentsByName() but it returns a lot of extra // information about the section. - const char *GetSectionInfoByName(const string §ion_name, - ElfReader::SectionInfo *info) { + const char* GetSectionInfoByName(const string& section_name, + ElfReader::SectionInfo* info) { for (unsigned int k = 0u; k < GetNumSections(); ++k) { // When searching for sections in a .dwp file, the sections // we're looking for will always be at the end of the section // table, so reverse the direction of iteration. int shndx = is_dwp_ ? GetNumSections() - k - 1 : k; - const char *name = GetSectionName(section_headers_[shndx].sh_name); + const char* name = GetSectionName(section_headers_[shndx].sh_name); if (name != NULL && ElfReader::SectionNamesMatch(section_name, name)) { - const ElfSectionReader *section = GetSection(shndx); + const ElfSectionReader* section = GetSection(shndx); if (section == NULL) { return NULL; } else { @@ -797,7 +797,7 @@ class ElfReaderImpl { // Debug sections are likely to be near the end, so reverse the // direction of iteration. for (int k = GetNumSections() - 1; k >= 0; --k) { - const char *name = GetSectionName(section_headers_[k].sh_name); + const char* name = GetSectionName(section_headers_[k].sh_name); if (strncmp(name, ".debug", strlen(".debug")) == 0) return true; if (strncmp(name, ".zdebug", strlen(".zdebug")) == 0) return true; } @@ -816,7 +816,7 @@ class ElfReaderImpl { } private: - typedef vector > AddrToSymMap; + typedef vector > AddrToSymMap; static bool AddrToSymSorter(const typename AddrToSymMap::value_type& lhs, const typename AddrToSymMap::value_type& rhs) { @@ -854,8 +854,8 @@ class ElfReaderImpl { // Given an offset into the section header string table, return the // section name. - const char *GetSectionName(typename ElfArch::Word sh_name) { - const ElfSectionReader *shstrtab = + const char* GetSectionName(typename ElfArch::Word sh_name) { + const ElfSectionReader* shstrtab = GetSection(GetStringTableIndex()); if (shstrtab != NULL) { return shstrtab->GetOffset(sh_name); @@ -865,15 +865,15 @@ class ElfReaderImpl { // Return an ElfSectionReader for the given section. The reader will // be freed when this object is destroyed. - const ElfSectionReader *GetSection(int num) { - const char *name; + const ElfSectionReader* GetSection(int num) { + const char* name; // Hard-coding the name for the section-name string table prevents // infinite recursion. if (num == GetStringTableIndex()) name = ".shstrtab"; else name = GetSectionNameByIndex(num); - ElfSectionReader *& reader = sections_[num]; + ElfSectionReader*& reader = sections_[num]; if (reader == NULL) reader = new ElfSectionReader(name, path_, fd_, section_headers_[num]); @@ -883,7 +883,7 @@ class ElfReaderImpl { // Parse out the overall header information from the file and assert // that it looks sane. This contains information like the magic // number and target architecture. - bool ParseHeaders(int fd, const string &path) { + bool ParseHeaders(int fd, const string& path) { // Read in the global ELF header. if (pread(fd, &header_, sizeof(header_), 0) != sizeof(header_)) { return false; @@ -985,11 +985,11 @@ class ElfReaderImpl { // Array of GetNumSections() section headers, allocated when we read // in the global header. - typename ElfArch::Shdr *section_headers_; + typename ElfArch::Shdr* section_headers_; // Array of GetNumProgramHeaders() program headers, allocated when we read // in the global header. - typename ElfArch::Phdr *program_headers_; + typename ElfArch::Phdr* program_headers_; // An array of pointers to ElfSectionReaders. Sections are // mmaped as they're needed and not released until this object is @@ -1000,7 +1000,7 @@ class ElfReaderImpl { // values for funtion symbols values. Function descriptors are kept in the // .opd section and are dereferenced to find the function address. ElfReader::SectionInfo opd_info_; - const char *opd_section_; // Must be checked for NULL before use. + const char* opd_section_; // Must be checked for NULL before use. int64_t base_for_text_; // Read PLT-related sections for the current architecture. @@ -1026,7 +1026,7 @@ class ElfReaderImpl { bool is_dwp_; }; -ElfReader::ElfReader(const string &path) +ElfReader::ElfReader(const string& path) : path_(path), fd_(-1), impl32_(NULL), impl64_(NULL) { // linux 2.6.XX kernel can show deleted files like this: // /var/run/nscd/dbYLJYaE (deleted) @@ -1063,7 +1063,7 @@ ElfReader::~ElfReader() { #endif template -static bool IsElfFile(const int fd, const string &path) { +static bool IsElfFile(const int fd, const string& path) { if (fd < 0) return false; if (!ElfReaderImpl::IsArchElfFile(fd, NULL)) { @@ -1086,7 +1086,7 @@ bool ElfReader::IsElf64File() const { } /* -void ElfReader::AddSymbols(SymbolMap *symbols, +void ElfReader::AddSymbols(SymbolMap* symbols, uint64_t mem_offset, uint64_t file_offset, uint64_t length) { if (fd_ < 0) @@ -1109,17 +1109,17 @@ void ElfReader::AddSymbols(SymbolMap *symbols, } */ -void ElfReader::VisitSymbols(ElfReader::SymbolSink *sink) { +void ElfReader::VisitSymbols(ElfReader::SymbolSink* sink) { VisitSymbols(sink, -1, -1); } -void ElfReader::VisitSymbols(ElfReader::SymbolSink *sink, +void ElfReader::VisitSymbols(ElfReader::SymbolSink* sink, int symbol_binding, int symbol_type) { VisitSymbols(sink, symbol_binding, symbol_type, false); } -void ElfReader::VisitSymbols(ElfReader::SymbolSink *sink, +void ElfReader::VisitSymbols(ElfReader::SymbolSink* sink, int symbol_binding, int symbol_type, bool get_raw_symbol_values) { @@ -1148,7 +1148,7 @@ uint64_t ElfReader::VaddrOfFirstLoadSegment() { } } -const char *ElfReader::GetSectionName(int shndx) { +const char* ElfReader::GetSectionName(int shndx) { if (shndx < 0 || static_cast(shndx) >= GetNumSections()) return NULL; if (IsElf32File()) { return GetImpl32()->GetSectionNameByIndex(shndx); @@ -1169,7 +1169,7 @@ uint64_t ElfReader::GetNumSections() { } } -const char *ElfReader::GetSectionByIndex(int shndx, size_t *size) { +const char* ElfReader::GetSectionByIndex(int shndx, size_t* size) { if (IsElf32File()) { return GetImpl32()->GetSectionContentsByIndex(shndx, size); } else if (IsElf64File()) { @@ -1179,8 +1179,8 @@ const char *ElfReader::GetSectionByIndex(int shndx, size_t *size) { } } -const char *ElfReader::GetSectionByName(const string §ion_name, - size_t *size) { +const char* ElfReader::GetSectionByName(const string& section_name, + size_t* size) { if (IsElf32File()) { return GetImpl32()->GetSectionContentsByName(section_name, size); } else if (IsElf64File()) { @@ -1190,8 +1190,8 @@ const char *ElfReader::GetSectionByName(const string §ion_name, } } -const char *ElfReader::GetSectionInfoByName(const string §ion_name, - SectionInfo *info) { +const char* ElfReader::GetSectionInfoByName(const string& section_name, + SectionInfo* info) { if (IsElf32File()) { return GetImpl32()->GetSectionInfoByName(section_name, info); } else if (IsElf64File()) { @@ -1201,7 +1201,7 @@ const char *ElfReader::GetSectionInfoByName(const string §ion_name, } } -bool ElfReader::SectionNamesMatch(const string &name, const string &sh_name) { +bool ElfReader::SectionNamesMatch(const string& name, const string& sh_name) { if ((name.find(".debug_", 0) == 0) && (sh_name.find(".zdebug_", 0) == 0)) { const string name_suffix(name, strlen(".debug_")); const string sh_name_suffix(sh_name, strlen(".zdebug_")); @@ -1220,14 +1220,14 @@ bool ElfReader::IsDynamicSharedObject() { } } -ElfReaderImpl *ElfReader::GetImpl32() { +ElfReaderImpl* ElfReader::GetImpl32() { if (impl32_ == NULL) { impl32_ = new ElfReaderImpl(path_, fd_); } return impl32_; } -ElfReaderImpl *ElfReader::GetImpl64() { +ElfReaderImpl* ElfReader::GetImpl64() { if (impl64_ == NULL) { impl64_ = new ElfReaderImpl(path_, fd_); } @@ -1238,7 +1238,7 @@ ElfReaderImpl *ElfReader::GetImpl64() { // debug info (debug_only=true) or symbol table (debug_only=false). // Otherwise, return false. template -static bool IsNonStrippedELFBinaryImpl(const string &path, const int fd, +static bool IsNonStrippedELFBinaryImpl(const string& path, const int fd, bool debug_only) { if (!ElfReaderImpl::IsArchElfFile(fd, NULL)) return false; ElfReaderImpl elf_reader(path, fd); @@ -1248,7 +1248,7 @@ static bool IsNonStrippedELFBinaryImpl(const string &path, const int fd, } // Helper for the IsNon[Debug]StrippedELFBinary functions. -static bool IsNonStrippedELFBinaryHelper(const string &path, +static bool IsNonStrippedELFBinaryHelper(const string& path, bool debug_only) { const int fd = open(path.c_str(), O_RDONLY); if (fd == -1) { @@ -1264,11 +1264,11 @@ static bool IsNonStrippedELFBinaryHelper(const string &path, return false; } -bool ElfReader::IsNonStrippedELFBinary(const string &path) { +bool ElfReader::IsNonStrippedELFBinary(const string& path) { return IsNonStrippedELFBinaryHelper(path, false); } -bool ElfReader::IsNonDebugStrippedELFBinary(const string &path) { +bool ElfReader::IsNonDebugStrippedELFBinary(const string& path) { return IsNonStrippedELFBinaryHelper(path, true); } } // namespace dwarf2reader diff --git a/src/common/dwarf/elf_reader.h b/src/common/dwarf/elf_reader.h index 8eaa5aa9..0aa92285 100644 --- a/src/common/dwarf/elf_reader.h +++ b/src/common/dwarf/elf_reader.h @@ -34,7 +34,7 @@ class ElfReaderImpl; class ElfReader { public: - explicit ElfReader(const string &path); + explicit ElfReader(const string& path); ~ElfReader(); // Parse the ELF prologue of this file and return whether it was @@ -62,29 +62,29 @@ class ElfReader { // mem_offset - position at which the segment is mapped into memory // file_offset - offset in the file where the mapping begins // length - length of the mapped segment - void AddSymbols(SymbolMap *symbols, + void AddSymbols(SymbolMap* symbols, uint64_t mem_offset, uint64_t file_offset, uint64_t length); class SymbolSink { public: virtual ~SymbolSink() {} - virtual void AddSymbol(const char *name, uint64_t address, + virtual void AddSymbol(const char* name, uint64_t address, uint64_t size) = 0; }; // Like AddSymbols above, but with no address correction. // Processes any SHT_SYMTAB section, followed by any SHT_DYNSYM section. - void VisitSymbols(SymbolSink *sink); + void VisitSymbols(SymbolSink* sink); // Like VisitSymbols above, but for a specific symbol binding/type. // A negative value for the binding and type parameters means any // binding or type. - void VisitSymbols(SymbolSink *sink, int symbol_binding, int symbol_type); + void VisitSymbols(SymbolSink* sink, int symbol_binding, int symbol_type); // Like VisitSymbols above but can optionally export raw symbol values instead // of adjusted ones. - void VisitSymbols(SymbolSink *sink, int symbol_binding, int symbol_type, + void VisitSymbols(SymbolSink* sink, int symbol_binding, int symbol_type, bool get_raw_symbol_values); // p_vaddr of the first PT_LOAD segment (if any), or 0 if no PT_LOAD @@ -95,7 +95,7 @@ class ElfReader { // Return the name of section "shndx". Returns NULL if the section // is not found. - const char *GetSectionName(int shndx); + const char* GetSectionName(int shndx); // Return the number of sections in the given ELF file. uint64_t GetNumSections(); @@ -104,14 +104,14 @@ class ElfReader { // the pointer to the section and store the size in "size". // On error, return NULL. The returned section data is only valid // until the ElfReader gets destroyed. - const char *GetSectionByIndex(int shndx, size_t *size); + const char* GetSectionByIndex(int shndx, size_t* size); // Get section with "section_name" (ex. ".text", ".symtab") in the // given ELF file. On success, return the pointer to the section // and store the size in "size". On error, return NULL. The // returned section data is only valid until the ElfReader gets // destroyed. - const char *GetSectionByName(const string §ion_name, size_t *size); + const char* GetSectionByName(const string& section_name, size_t* size); // This is like GetSectionByName() but it returns a lot of extra information // about the section. The SectionInfo structure is almost identical to @@ -129,37 +129,37 @@ class ElfReader { uint64_t addralign; // Section alignment. uint64_t entsize; // Entry size if section holds a table. }; - const char *GetSectionInfoByName(const string §ion_name, - SectionInfo *info); + const char* GetSectionInfoByName(const string& section_name, + SectionInfo* info); // Check if "path" is an ELF binary that has not been stripped of symbol // tables. This function supports both 32-bit and 64-bit ELF binaries. - static bool IsNonStrippedELFBinary(const string &path); + static bool IsNonStrippedELFBinary(const string& path); // Check if "path" is an ELF binary that has not been stripped of debug // info. Unlike IsNonStrippedELFBinary, this function will return // false for binaries passed through "strip -S". - static bool IsNonDebugStrippedELFBinary(const string &path); + static bool IsNonDebugStrippedELFBinary(const string& path); // Match a requested section name with the section name as it // appears in the elf-file, adjusting for compressed debug section // names. For example, returns true if name == ".debug_abbrev" and // sh_name == ".zdebug_abbrev" - static bool SectionNamesMatch(const string &name, const string &sh_name); + static bool SectionNamesMatch(const string& name, const string& sh_name); private: // Lazily initialize impl32_ and return it. - ElfReaderImpl *GetImpl32(); + ElfReaderImpl* GetImpl32(); // Ditto for impl64_. - ElfReaderImpl *GetImpl64(); + ElfReaderImpl* GetImpl64(); // Path of the file we're reading. const string path_; // Read-only file descriptor for the file. May be -1 if there was an // error during open. int fd_; - ElfReaderImpl *impl32_; - ElfReaderImpl *impl64_; + ElfReaderImpl* impl32_; + ElfReaderImpl* impl64_; }; } // namespace dwarf2reader diff --git a/src/common/dwarf/functioninfo.cc b/src/common/dwarf/functioninfo.cc index 28c4f935..6b9a92a3 100644 --- a/src/common/dwarf/functioninfo.cc +++ b/src/common/dwarf/functioninfo.cc @@ -144,7 +144,7 @@ bool CUFunctionInfoHandler::StartDIE(uint64_t offset, enum DwarfTag tag) { void CUFunctionInfoHandler::ProcessAttributeString(uint64_t offset, enum DwarfAttribute attr, enum DwarfForm form, - const string &data) { + const string& data) { if (current_function_info_) { if (attr == DW_AT_name) current_function_info_->name = data; diff --git a/src/common/dwarf_cfi_to_module.cc b/src/common/dwarf_cfi_to_module.cc index 3dd85edd..eb19c132 100644 --- a/src/common/dwarf_cfi_to_module.cc +++ b/src/common/dwarf_cfi_to_module.cc @@ -143,7 +143,7 @@ vector DwarfCFIToModule::RegisterNames::MIPS() { } bool DwarfCFIToModule::Entry(size_t offset, uint64_t address, uint64_t length, - uint8_t version, const string &augmentation, + uint8_t version, const string& augmentation, unsigned return_address) { assert(!entry_); @@ -190,7 +190,7 @@ string DwarfCFIToModule::RegisterName(int i) { } void DwarfCFIToModule::Record(Module::Address address, int reg, - const string &rule) { + const string& rule) { assert(entry_); // Place the name in our global set of strings, and then use the string @@ -247,14 +247,14 @@ bool DwarfCFIToModule::RegisterRule(uint64_t address, int reg, } bool DwarfCFIToModule::ExpressionRule(uint64_t address, int reg, - const string &expression) { + const string& expression) { reporter_->ExpressionsNotSupported(entry_offset_, RegisterName(reg)); // Treat this as a non-fatal error. return true; } bool DwarfCFIToModule::ValExpressionRule(uint64_t address, int reg, - const string &expression) { + const string& expression) { reporter_->ExpressionsNotSupported(entry_offset_, RegisterName(reg)); // Treat this as a non-fatal error. return true; @@ -274,7 +274,7 @@ void DwarfCFIToModule::Reporter::UnnamedRegister(size_t offset, int reg) { } void DwarfCFIToModule::Reporter::UndefinedNotSupported(size_t offset, - const string ®) { + const string& reg) { fprintf(stderr, "%s, section '%s': " "the call frame entry at offset 0x%zx sets the rule for " "register '%s' to 'undefined', but the Breakpad symbol file format" @@ -283,7 +283,7 @@ void DwarfCFIToModule::Reporter::UndefinedNotSupported(size_t offset, } void DwarfCFIToModule::Reporter::ExpressionsNotSupported(size_t offset, - const string ®) { + const string& reg) { fprintf(stderr, "%s, section '%s': " "the call frame entry at offset 0x%zx uses a DWARF expression to" " describe how to recover register '%s', " diff --git a/src/common/dwarf_cfi_to_module.h b/src/common/dwarf_cfi_to_module.h index 4d2db7ee..35bdb5fd 100644 --- a/src/common/dwarf_cfi_to_module.h +++ b/src/common/dwarf_cfi_to_module.h @@ -71,7 +71,7 @@ class DwarfCFIToModule: public CallFrameInfo::Handler { // stream. FILE is the name of the file we're processing, and // SECTION is the name of the section within that file that we're // looking at (.debug_frame, .eh_frame, etc.). - Reporter(const string &file, const string §ion) + Reporter(const string& file, const string& section) : file_(file), section_(section) { } virtual ~Reporter() { } @@ -83,13 +83,13 @@ class DwarfCFIToModule: public CallFrameInfo::Handler { // The DWARF CFI entry at OFFSET says that REG is undefined, but the // Breakpad symbol file format cannot express this. - virtual void UndefinedNotSupported(size_t offset, const string ®); + virtual void UndefinedNotSupported(size_t offset, const string& reg); // The DWARF CFI entry at OFFSET says that REG uses a DWARF // expression to find its value, but DwarfCFIToModule is not // capable of translating DWARF expressions to Breakpad postfix // expressions. - virtual void ExpressionsNotSupported(size_t offset, const string ®); + virtual void ExpressionsNotSupported(size_t offset, const string& reg); protected: string file_, section_; @@ -118,7 +118,7 @@ class DwarfCFIToModule: public CallFrameInfo::Handler { private: // Given STRINGS, an array of C strings with SIZE elements, return an // equivalent vector. - static vector MakeVector(const char * const *strings, size_t size); + static vector MakeVector(const char* const* strings, size_t size); }; // Create a handler for the dwarf2reader::CallFrameInfo parser that @@ -130,15 +130,15 @@ class DwarfCFIToModule: public CallFrameInfo::Handler { // // Use REPORTER for reporting problems encountered in the conversion // process. - DwarfCFIToModule(Module *module, const vector ®ister_names, - Reporter *reporter) + DwarfCFIToModule(Module* module, const vector& register_names, + Reporter* reporter) : module_(module), register_names_(register_names), reporter_(reporter), entry_(NULL), return_address_(-1), cfa_name_(".cfa"), ra_name_(".ra") { } virtual ~DwarfCFIToModule() { delete entry_; } virtual bool Entry(size_t offset, uint64_t address, uint64_t length, - uint8_t version, const string &augmentation, + uint8_t version, const string& augmentation, unsigned return_address); virtual bool UndefinedRule(uint64_t address, int reg); virtual bool SameValueRule(uint64_t address, int reg); @@ -148,9 +148,9 @@ class DwarfCFIToModule: public CallFrameInfo::Handler { int base_register, long offset); virtual bool RegisterRule(uint64_t address, int reg, int base_register); virtual bool ExpressionRule(uint64_t address, int reg, - const string &expression); + const string& expression); virtual bool ValExpressionRule(uint64_t address, int reg, - const string &expression); + const string& expression); virtual bool End(); private: @@ -158,19 +158,19 @@ class DwarfCFIToModule: public CallFrameInfo::Handler { string RegisterName(int i); // Record RULE for register REG at ADDRESS. - void Record(Module::Address address, int reg, const string &rule); + void Record(Module::Address address, int reg, const string& rule); // The module to which we should add entries. - Module *module_; + Module* module_; // Map from register numbers to register names. - const vector ®ister_names_; + const vector& register_names_; // The reporter to use to report problems. - Reporter *reporter_; + Reporter* reporter_; // The current entry we're constructing. - Module::StackFrameEntry *entry_; + Module::StackFrameEntry* entry_; // The section offset of the current frame description entry, for // use in error messages. diff --git a/src/common/dwarf_cfi_to_module_unittest.cc b/src/common/dwarf_cfi_to_module_unittest.cc index 60a9a3ee..58c3cca3 100644 --- a/src/common/dwarf_cfi_to_module_unittest.cc +++ b/src/common/dwarf_cfi_to_module_unittest.cc @@ -47,11 +47,11 @@ using testing::Test; using testing::_; struct MockCFIReporter: public DwarfCFIToModule::Reporter { - MockCFIReporter(const string &file, const string §ion) + MockCFIReporter(const string& file, const string& section) : Reporter(file, section) { } MOCK_METHOD2(UnnamedRegister, void(size_t offset, int reg)); - MOCK_METHOD2(UndefinedNotSupported, void(size_t offset, const string ®)); - MOCK_METHOD2(ExpressionsNotSupported, void(size_t offset, const string ®)); + MOCK_METHOD2(UndefinedNotSupported, void(size_t offset, const string& reg)); + MOCK_METHOD2(ExpressionsNotSupported, void(size_t offset, const string& reg)); }; struct DwarfCFIToModuleFixture { @@ -80,7 +80,7 @@ struct DwarfCFIToModuleFixture { vector register_names; MockCFIReporter reporter; DwarfCFIToModule handler; - vector entries; + vector entries; }; class Entry: public DwarfCFIToModuleFixture, public Test { }; diff --git a/src/common/dwarf_cu_to_module.cc b/src/common/dwarf_cu_to_module.cc index ec2badc9..3a520857 100644 --- a/src/common/dwarf_cu_to_module.cc +++ b/src/common/dwarf_cu_to_module.cc @@ -128,8 +128,8 @@ struct DwarfCUToModule::FilePrivate { AbstractOriginByOffset origins; }; -DwarfCUToModule::FileContext::FileContext(const string &filename, - Module *module, +DwarfCUToModule::FileContext::FileContext(const string& filename, + Module* module, bool handle_inter_cu_refs) : filename_(filename), module_(module), @@ -141,7 +141,7 @@ DwarfCUToModule::FileContext::~FileContext() { } void DwarfCUToModule::FileContext::AddSectionToSectionMap( - const string& name, const uint8_t *contents, uint64_t length) { + const string& name, const uint8_t* contents, uint64_t length) { section_map_[name] = std::make_pair(contents, length); } @@ -170,8 +170,8 @@ bool DwarfCUToModule::FileContext::IsUnhandledInterCUReference( // parsing. This is for data shared across the CU's entire DIE tree, // and parameters from the code invoking the CU parser. struct DwarfCUToModule::CUContext { - CUContext(FileContext *file_context_arg, WarningReporter *reporter_arg, - RangesHandler *ranges_handler_arg) + CUContext(FileContext* file_context_arg, WarningReporter* reporter_arg, + RangesHandler* ranges_handler_arg) : file_context(file_context_arg), reporter(reporter_arg), ranges_handler(ranges_handler_arg), @@ -181,23 +181,23 @@ struct DwarfCUToModule::CUContext { ranges(0) {} ~CUContext() { - for (vector::iterator it = functions.begin(); + for (vector::iterator it = functions.begin(); it != functions.end(); ++it) { delete *it; } }; // The DWARF-bearing file into which this CU was incorporated. - FileContext *file_context; + FileContext* file_context; // For printing error messages. - WarningReporter *reporter; + WarningReporter* reporter; // For reading ranges from the .debug_ranges section - RangesHandler *ranges_handler; + RangesHandler* ranges_handler; // The source language of this compilation unit. - const Language *language; + const Language* language; // Addresses covered by this CU. If high_pc_ is non-zero then the CU covers // low_pc to high_pc, otherwise ranges is non-zero and low_pc represents @@ -211,11 +211,11 @@ struct DwarfCUToModule::CUContext { // assign them lines and add them to file_context->module. // // Destroying this destroys all the functions this vector points to. - vector functions; + vector functions; // Keep a list of forward references from DW_AT_abstract_origin and // DW_AT_specification attributes so names can be fixed up. - std::map forward_ref_die_to_func; + std::map forward_ref_die_to_func; }; // Information about the context of a particular DIE. This is for @@ -241,7 +241,7 @@ class DwarfCUToModule::GenericDIEHandler: public dwarf2reader::DIEHandler { // Create a handler for the DIE at OFFSET whose compilation unit is // described by CU_CONTEXT, and whose immediate context is described // by PARENT_CONTEXT. - GenericDIEHandler(CUContext *cu_context, DIEContext *parent_context, + GenericDIEHandler(CUContext* cu_context, DIEContext* parent_context, uint64_t offset) : cu_context_(cu_context), parent_context_(parent_context), @@ -266,7 +266,7 @@ class DwarfCUToModule::GenericDIEHandler: public dwarf2reader::DIEHandler { // handle DW_AT_specification, or simply not override it. void ProcessAttributeString(enum DwarfAttribute attr, enum DwarfForm form, - const string &data); + const string& data); protected: // Compute and return the fully-qualified name of the DIE. If this @@ -279,8 +279,8 @@ class DwarfCUToModule::GenericDIEHandler: public dwarf2reader::DIEHandler { // have been seen. string ComputeQualifiedName(); - CUContext *cu_context_; - DIEContext *parent_context_; + CUContext* cu_context_; + DIEContext* parent_context_; uint64_t offset_; // Place the name in the global set of strings. Even though this looks @@ -289,7 +289,7 @@ class DwarfCUToModule::GenericDIEHandler: public dwarf2reader::DIEHandler { // share copies of strings whenever possible. // FIXME: Should this return something like a string_ref to avoid the // assumption about how strings are implemented? - string AddStringToPool(const string &str); + string AddStringToPool(const string& str); // If this DIE has a DW_AT_declaration attribute, this is its value. // It is false on DIEs with no DW_AT_declaration attribute. @@ -298,7 +298,7 @@ class DwarfCUToModule::GenericDIEHandler: public dwarf2reader::DIEHandler { // If this DIE has a DW_AT_specification attribute, this is the // Specification structure for the DIE the attribute refers to. // Otherwise, this is NULL. - Specification *specification_; + Specification* specification_; // If this DIE has a DW_AT_specification or DW_AT_abstract_origin and it is a // forward reference, no Specification will be available. Track the reference @@ -335,7 +335,7 @@ void DwarfCUToModule::GenericDIEHandler::ProcessAttributeReference( uint64_t data) { switch (attr) { case dwarf2reader::DW_AT_specification: { - FileContext *file_context = cu_context_->file_context; + FileContext* file_context = cu_context_->file_context; if (file_context->IsUnhandledInterCUReference( data, cu_context_->reporter->cu_offset())) { cu_context_->reporter->UnhandledInterCUReference(offset_, data); @@ -346,7 +346,7 @@ void DwarfCUToModule::GenericDIEHandler::ProcessAttributeReference( // here, but it's better to leave the real work to our // EndAttribute member function, at which point we know we have // seen all the DIE's attributes. - SpecificationByOffset *specifications = + SpecificationByOffset* specifications = &file_context->file_private_->specifications; SpecificationByOffset::iterator spec = specifications->find(data); if (spec != specifications->end()) { @@ -362,7 +362,7 @@ void DwarfCUToModule::GenericDIEHandler::ProcessAttributeReference( } } -string DwarfCUToModule::GenericDIEHandler::AddStringToPool(const string &str) { +string DwarfCUToModule::GenericDIEHandler::AddStringToPool(const string& str) { pair::iterator, bool> result = cu_context_->file_context->file_private_->common_strings.insert(str); return *result.first; @@ -371,7 +371,7 @@ string DwarfCUToModule::GenericDIEHandler::AddStringToPool(const string &str) { void DwarfCUToModule::GenericDIEHandler::ProcessAttributeString( enum DwarfAttribute attr, enum DwarfForm form, - const string &data) { + const string& data) { switch (attr) { case dwarf2reader::DW_AT_name: name_attribute_ = AddStringToPool(data); @@ -404,7 +404,7 @@ string DwarfCUToModule::GenericDIEHandler::ComputeQualifiedName() { // Use the demangled name, if one is available. Demangled names are // preferable to those inferred from the DWARF structure because they // include argument types. - const string *qualified_name = NULL; + const string* qualified_name = NULL; if (!demangled_name_.empty()) { // Found it is this DIE. qualified_name = &demangled_name_; @@ -413,8 +413,8 @@ string DwarfCUToModule::GenericDIEHandler::ComputeQualifiedName() { qualified_name = &specification_->qualified_name; } - const string *unqualified_name = NULL; - const string *enclosing_name; + const string* unqualified_name = NULL; + const string* enclosing_name; if (!qualified_name) { // Find the unqualified name. If the DIE has its own DW_AT_name // attribute, then use that; otherwise, check the specification. @@ -466,7 +466,7 @@ string DwarfCUToModule::GenericDIEHandler::ComputeQualifiedName() { // A handler class for DW_TAG_subprogram DIEs. class DwarfCUToModule::FuncHandler: public GenericDIEHandler { public: - FuncHandler(CUContext *cu_context, DIEContext *parent_context, + FuncHandler(CUContext* cu_context, DIEContext* parent_context, uint64_t offset) : GenericDIEHandler(cu_context, parent_context, offset), low_pc_(0), high_pc_(0), high_pc_form_(dwarf2reader::DW_FORM_addr), @@ -605,7 +605,7 @@ void DwarfCUToModule::FuncHandler::Finish() { Module::Range range(low_pc_, high_pc_ - low_pc_); ranges.push_back(range); } else { - RangesHandler *ranges_handler = cu_context_->ranges_handler; + RangesHandler* ranges_handler = cu_context_->ranges_handler; if (ranges_handler) { if (!ranges_handler->ReadRanges(ranges_, cu_context_->low_pc, &ranges)) { @@ -668,11 +668,11 @@ void DwarfCUToModule::FuncHandler::Finish() { // component to their names: namespaces, classes, etc. class DwarfCUToModule::NamedScopeHandler: public GenericDIEHandler { public: - NamedScopeHandler(CUContext *cu_context, DIEContext *parent_context, + NamedScopeHandler(CUContext* cu_context, DIEContext* parent_context, uint64_t offset) : GenericDIEHandler(cu_context, parent_context, offset) { } bool EndAttributes(); - DIEHandler *FindChildHandler(uint64_t offset, enum DwarfTag tag); + DIEHandler* FindChildHandler(uint64_t offset, enum DwarfTag tag); private: DIEContext child_context_; // A context for our children. @@ -683,7 +683,7 @@ bool DwarfCUToModule::NamedScopeHandler::EndAttributes() { return true; } -dwarf2reader::DIEHandler *DwarfCUToModule::NamedScopeHandler::FindChildHandler( +dwarf2reader::DIEHandler* DwarfCUToModule::NamedScopeHandler::FindChildHandler( uint64_t offset, enum DwarfTag tag) { switch (tag) { @@ -725,7 +725,7 @@ void DwarfCUToModule::WarningReporter::UnknownAbstractOrigin(uint64_t offset, filename_.c_str(), offset, target); } -void DwarfCUToModule::WarningReporter::MissingSection(const string &name) { +void DwarfCUToModule::WarningReporter::MissingSection(const string& name) { CUHeading(); fprintf(stderr, "%s: warning: couldn't find DWARF '%s' section\n", filename_.c_str(), name.c_str()); @@ -748,7 +748,7 @@ void DwarfCUToModule::WarningReporter::UncoveredHeading() { } void DwarfCUToModule::WarningReporter::UncoveredFunction( - const Module::Function &function) { + const Module::Function& function) { if (!uncovered_warnings_enabled_) return; UncoveredHeading(); @@ -757,7 +757,7 @@ void DwarfCUToModule::WarningReporter::UncoveredFunction( function.name.c_str()); } -void DwarfCUToModule::WarningReporter::UncoveredLine(const Module::Line &line) { +void DwarfCUToModule::WarningReporter::UncoveredLine(const Module::Line& line) { if (!uncovered_warnings_enabled_) return; UncoveredHeading(); @@ -772,7 +772,7 @@ void DwarfCUToModule::WarningReporter::UnnamedFunction(uint64_t offset) { filename_.c_str(), offset); } -void DwarfCUToModule::WarningReporter::DemangleError(const string &input) { +void DwarfCUToModule::WarningReporter::DemangleError(const string& input) { CUHeading(); fprintf(stderr, "%s: warning: failed to demangle %s\n", filename_.c_str(), input.c_str()); @@ -800,10 +800,10 @@ void DwarfCUToModule::WarningReporter::MissingRanges() { "the .debug_ranges section is missing.\n", filename_.c_str()); } -DwarfCUToModule::DwarfCUToModule(FileContext *file_context, - LineToModuleHandler *line_reader, - RangesHandler *ranges_handler, - WarningReporter *reporter) +DwarfCUToModule::DwarfCUToModule(FileContext* file_context, + LineToModuleHandler* line_reader, + RangesHandler* ranges_handler, + WarningReporter* reporter) : line_reader_(line_reader), cu_context_(new CUContext(file_context, reporter, ranges_handler)), child_context_(new DIEContext()), @@ -853,7 +853,7 @@ void DwarfCUToModule::ProcessAttributeUnsigned(enum DwarfAttribute attr, void DwarfCUToModule::ProcessAttributeString(enum DwarfAttribute attr, enum DwarfForm form, - const string &data) { + const string& data) { switch (attr) { case dwarf2reader::DW_AT_name: cu_context_->reporter->SetCUName(data); @@ -870,7 +870,7 @@ bool DwarfCUToModule::EndAttributes() { return true; } -dwarf2reader::DIEHandler *DwarfCUToModule::FindChildHandler( +dwarf2reader::DIEHandler* DwarfCUToModule::FindChildHandler( uint64_t offset, enum DwarfTag tag) { switch (tag) { @@ -932,7 +932,7 @@ void DwarfCUToModule::SetLanguage(DwarfLanguage language) { } void DwarfCUToModule::ReadSourceLines(uint64_t offset) { - const dwarf2reader::SectionMap §ion_map + const dwarf2reader::SectionMap& section_map = cu_context_->file_context->section_map(); dwarf2reader::SectionMap::const_iterator map_entry = dwarf2reader::GetSectionByName(section_map, ".debug_line"); @@ -974,30 +974,30 @@ void DwarfCUToModule::ReadSourceLines(uint64_t offset) { namespace { class FunctionRange { public: - FunctionRange(const Module::Range &range, Module::Function *function) : + FunctionRange(const Module::Range& range, Module::Function* function) : address(range.address), size(range.size), function(function) { } - void AddLine(Module::Line &line) { + void AddLine(Module::Line& line) { function->lines.push_back(line); } Module::Address address; Module::Address size; - Module::Function *function; + Module::Function* function; }; // Fills an array of ranges with pointers to the functions which owns // them. The array is sorted in ascending order and the ranges are non // empty and non-overlapping. -static void FillSortedFunctionRanges(vector &dest_ranges, - vector *functions) { - for (vector::const_iterator func_it = functions->cbegin(); +static void FillSortedFunctionRanges(vector& dest_ranges, + vector* functions) { + for (vector::const_iterator func_it = functions->cbegin(); func_it != functions->cend(); func_it++) { - Module::Function *func = *func_it; - vector &ranges = func->ranges; + Module::Function* func = *func_it; + vector& ranges = func->ranges; for (vector::const_iterator ranges_it = ranges.cbegin(); ranges_it != ranges.cend(); ++ranges_it) { @@ -1009,7 +1009,7 @@ static void FillSortedFunctionRanges(vector &dest_ranges, } sort(dest_ranges.begin(), dest_ranges.end(), - [](const FunctionRange &fr1, const FunctionRange &fr2) { + [](const FunctionRange& fr1, const FunctionRange& fr2) { return fr1.address < fr2.address; } ); @@ -1017,7 +1017,7 @@ static void FillSortedFunctionRanges(vector &dest_ranges, // Return true if ADDRESS falls within the range of ITEM. template -inline bool within(const T &item, Module::Address address) { +inline bool within(const T& item, Module::Address address) { // Because Module::Address is unsigned, and unsigned arithmetic // wraps around, this will be false if ADDRESS falls before the // start of ITEM, or if it falls after ITEM's end. @@ -1026,8 +1026,8 @@ inline bool within(const T &item, Module::Address address) { } void DwarfCUToModule::AssignLinesToFunctions() { - vector *functions = &cu_context_->functions; - WarningReporter *reporter = cu_context_->reporter; + vector* functions = &cu_context_->functions; + WarningReporter* reporter = cu_context_->reporter; // This would be simpler if we assumed that source line entries // don't cross function boundaries. However, there's no real reason @@ -1047,12 +1047,12 @@ void DwarfCUToModule::AssignLinesToFunctions() { // The last line that we used any piece of. We use this only for // generating warnings. - const Module::Line *last_line_used = NULL; + const Module::Line* last_line_used = NULL; // The last function and line we warned about --- so we can avoid // doing so more than once. - const Module::Function *last_function_cited = NULL; - const Module::Line *last_line_cited = NULL; + const Module::Function* last_function_cited = NULL; + const Module::Line* last_line_cited = NULL; // Prepare a sorted list of ranges with range-to-function mapping vector sorted_ranges; @@ -1068,8 +1068,8 @@ void DwarfCUToModule::AssignLinesToFunctions() { // Pointers to the referents of func_it and line_it, or NULL if the // iterator is at the end of the sequence. - FunctionRange *range; - const Module::Line *line; + FunctionRange* range; + const Module::Line* line; // Start current at the beginning of the first line or function, // whichever is earlier. @@ -1232,7 +1232,7 @@ void DwarfCUToModule::Finish() { if (has_source_line_info_) ReadSourceLines(source_line_offset_); - vector *functions = &cu_context_->functions; + vector* functions = &cu_context_->functions; // Dole out lines to the appropriate functions. AssignLinesToFunctions(); diff --git a/src/common/dwarf_cu_to_module.h b/src/common/dwarf_cu_to_module.h index b948aec7..3e15b667 100644 --- a/src/common/dwarf_cu_to_module.h +++ b/src/common/dwarf_cu_to_module.h @@ -79,14 +79,14 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { // to true to handle debugging symbols with DW_FORM_ref_addr entries. class FileContext { public: - FileContext(const string &filename, - Module *module, + FileContext(const string& filename, + Module* module, bool handle_inter_cu_refs); ~FileContext(); // Add CONTENTS of size LENGTH to the section map as NAME. void AddSectionToSectionMap(const string& name, - const uint8_t *contents, + const uint8_t* contents, uint64_t length); // Clear the section map for testing. @@ -114,7 +114,7 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { dwarf2reader::SectionMap section_map_; // The Module to which we're contributing definitions. - Module *module_; + Module* module_; // True if we are handling references between compilation units. const bool handle_inter_cu_refs_; @@ -163,7 +163,7 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { uint64_t string_section_length, const uint8_t* line_string_section, uint64_t line_string_length, - Module *module, vector *lines) = 0; + Module* module, vector* lines) = 0; }; // The interface DwarfCUToModule uses to report warnings. The member @@ -174,14 +174,14 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { public: // Warn about problems in the DWARF file FILENAME, in the // compilation unit at OFFSET. - WarningReporter(const string &filename, uint64_t cu_offset) + WarningReporter(const string& filename, uint64_t cu_offset) : filename_(filename), cu_offset_(cu_offset), printed_cu_header_(false), printed_unpaired_header_(false), uncovered_warnings_enabled_(false) { } virtual ~WarningReporter() { } // Set the name of the compilation unit we're processing to NAME. - virtual void SetCUName(const string &name) { cu_name_ = name; } + virtual void SetCUName(const string& name) { cu_name_ = name; } // Accessor and setter for uncovered_warnings_enabled_. // UncoveredFunction and UncoveredLine only report a problem if that is @@ -204,17 +204,17 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { virtual void UnknownAbstractOrigin(uint64_t offset, uint64_t target); // We were unable to find the DWARF section named SECTION_NAME. - virtual void MissingSection(const string §ion_name); + virtual void MissingSection(const string& section_name); // The CU's DW_AT_stmt_list offset OFFSET is bogus. virtual void BadLineInfoOffset(uint64_t offset); // FUNCTION includes code covered by no line number data. - virtual void UncoveredFunction(const Module::Function &function); + virtual void UncoveredFunction(const Module::Function& function); // Line number NUMBER in LINE_FILE, of length LENGTH, includes code // covered by no function. - virtual void UncoveredLine(const Module::Line &line); + virtual void UncoveredLine(const Module::Line& line); // The DW_TAG_subprogram DIE at OFFSET has no name specified directly // in the DIE, nor via a DW_AT_specification or DW_AT_abstract_origin @@ -222,7 +222,7 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { virtual void UnnamedFunction(uint64_t offset); // __cxa_demangle() failed to demangle INPUT. - virtual void DemangleError(const string &input); + virtual void DemangleError(const string& input); // The DW_FORM_ref_addr at OFFSET to TARGET was not handled because // FilePrivate did not retain the inter-CU specification data. @@ -261,10 +261,10 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { // FILE_CONTEXT->module. Use LINE_READER to handle the compilation // unit's line number data. Use REPORTER to report problems with the // data we find. - DwarfCUToModule(FileContext *file_context, - LineToModuleHandler *line_reader, - RangesHandler *ranges_handler, - WarningReporter *reporter); + DwarfCUToModule(FileContext* file_context, + LineToModuleHandler* line_reader, + RangesHandler* ranges_handler, + WarningReporter* reporter); ~DwarfCUToModule(); void ProcessAttributeSigned(enum DwarfAttribute attr, @@ -275,9 +275,9 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { uint64_t data); void ProcessAttributeString(enum DwarfAttribute attr, enum DwarfForm form, - const string &data); + const string& data); bool EndAttributes(); - DIEHandler *FindChildHandler(uint64_t offset, enum DwarfTag tag); + DIEHandler* FindChildHandler(uint64_t offset, enum DwarfTag tag); // Assign all our source Lines to the Functions that cover their // addresses, and then add them to module_. @@ -323,7 +323,7 @@ class DwarfCUToModule: public dwarf2reader::RootDIEHandler { // destructor deletes them. // The handler to use to handle line number data. - LineToModuleHandler *line_reader_; + LineToModuleHandler* line_reader_; // This compilation unit's context. scoped_ptr cu_context_; diff --git a/src/common/dwarf_cu_to_module_unittest.cc b/src/common/dwarf_cu_to_module_unittest.cc index 1b7e2bf5..8545c67d 100644 --- a/src/common/dwarf_cu_to_module_unittest.cc +++ b/src/common/dwarf_cu_to_module_unittest.cc @@ -77,17 +77,17 @@ class MockLineToModuleHandler: public DwarfCUToModule::LineToModuleHandler { class MockWarningReporter: public DwarfCUToModule::WarningReporter { public: - MockWarningReporter(const string &filename, uint64_t cu_offset) + MockWarningReporter(const string& filename, uint64_t cu_offset) : DwarfCUToModule::WarningReporter(filename, cu_offset) { } - MOCK_METHOD1(SetCUName, void(const string &name)); + MOCK_METHOD1(SetCUName, void(const string& name)); MOCK_METHOD2(UnknownSpecification, void(uint64_t offset, uint64_t target)); MOCK_METHOD2(UnknownAbstractOrigin, void(uint64_t offset, uint64_t target)); - MOCK_METHOD1(MissingSection, void(const string §ion_name)); + MOCK_METHOD1(MissingSection, void(const string& section_name)); MOCK_METHOD1(BadLineInfoOffset, void(uint64_t offset)); - MOCK_METHOD1(UncoveredFunction, void(const Module::Function &function)); - MOCK_METHOD1(UncoveredLine, void(const Module::Line &line)); + MOCK_METHOD1(UncoveredFunction, void(const Module::Function& function)); + MOCK_METHOD1(UncoveredLine, void(const Module::Line& line)); MOCK_METHOD1(UnnamedFunction, void(uint64_t offset)); - MOCK_METHOD1(DemangleError, void(const string &input)); + MOCK_METHOD1(DemangleError, void(const string& input)); MOCK_METHOD2(UnhandledInterCUReference, void(uint64_t offset, uint64_t target)); }; @@ -116,7 +116,7 @@ class CUFixtureBase { class AppendLinesFunctor { public: explicit AppendLinesFunctor( - const vector *lines) : lines_(lines) { } + const vector* lines) : lines_(lines) { } void operator()(const uint8_t* program, uint64_t length, const uint8_t* string_section, uint64_t string_section_length, @@ -126,7 +126,7 @@ class CUFixtureBase { lines->insert(lines->end(), lines_->begin(), lines_->end()); } private: - const vector *lines_; + const vector* lines_; }; CUFixtureBase() @@ -169,7 +169,7 @@ class CUFixtureBase { // when it invokes its LineToModuleHandler. Call this before calling // StartCU. void PushLine(Module::Address address, Module::Address size, - const string &filename, int line_number); + const string& filename, int line_number); // Use LANGUAGE for the compilation unit. More precisely, arrange // for StartCU to pass the compilation unit's root DIE a @@ -190,28 +190,28 @@ class CUFixtureBase { void StartCU(); // Have HANDLER process some strange attribute/form/value triples. - void ProcessStrangeAttributes(dwarf2reader::DIEHandler *handler); + void ProcessStrangeAttributes(dwarf2reader::DIEHandler* handler); // Start a child DIE of PARENT with the given tag and name. Leave // the handler ready to hear about children: call EndAttributes, but // not Finish. - DIEHandler *StartNamedDIE(DIEHandler *parent, DwarfTag tag, - const string &name); + DIEHandler* StartNamedDIE(DIEHandler* parent, DwarfTag tag, + const string& name); // Start a child DIE of PARENT with the given tag and a // DW_AT_specification attribute whose value is SPECIFICATION. Leave // the handler ready to hear about children: call EndAttributes, but // not Finish. If NAME is non-zero, use it as the DW_AT_name // attribute. - DIEHandler *StartSpecifiedDIE(DIEHandler *parent, DwarfTag tag, - uint64_t specification, const char *name = NULL); + DIEHandler* StartSpecifiedDIE(DIEHandler* parent, DwarfTag tag, + uint64_t specification, const char* name = NULL); // Define a function as a child of PARENT with the given name, address, and // size. If high_pc_form is DW_FORM_addr then the DW_AT_high_pc attribute // will be written as an address; otherwise it will be written as the // function's size. Call EndAttributes and Finish; one cannot define // children of the defined function's DIE. - void DefineFunction(DIEHandler *parent, const string &name, + void DefineFunction(DIEHandler* parent, const string& name, Module::Address address, Module::Address size, const char* mangled_name, DwarfForm high_pc_form = dwarf2reader::DW_FORM_addr); @@ -219,32 +219,32 @@ class CUFixtureBase { // Create a declaration DIE as a child of PARENT with the given // offset, tag and name. If NAME is the empty string, don't provide // a DW_AT_name attribute. Call EndAttributes and Finish. - void DeclarationDIE(DIEHandler *parent, uint64_t offset, - DwarfTag tag, const string &name, - const string &mangled_name); + void DeclarationDIE(DIEHandler* parent, uint64_t offset, + DwarfTag tag, const string& name, + const string& mangled_name); // Create a definition DIE as a child of PARENT with the given tag // that refers to the declaration DIE at offset SPECIFICATION as its // specification. If NAME is non-empty, pass it as the DW_AT_name // attribute. If SIZE is non-zero, record ADDRESS and SIZE as // low_pc/high_pc attributes. - void DefinitionDIE(DIEHandler *parent, DwarfTag tag, - uint64_t specification, const string &name, + void DefinitionDIE(DIEHandler* parent, DwarfTag tag, + uint64_t specification, const string& name, Module::Address address = 0, Module::Address size = 0); // Create an inline DW_TAG_subprogram DIE as a child of PARENT. If // SPECIFICATION is non-zero, then the DIE refers to the declaration DIE at // offset SPECIFICATION as its specification. If Name is non-empty, pass it // as the DW_AT_name attribute. - void AbstractInstanceDIE(DIEHandler *parent, uint64_t offset, + void AbstractInstanceDIE(DIEHandler* parent, uint64_t offset, DwarfInline type, uint64_t specification, - const string &name, + const string& name, DwarfForm form = dwarf2reader::DW_FORM_data1); // Create a DW_TAG_subprogram DIE as a child of PARENT that refers to // ORIGIN in its DW_AT_abstract_origin attribute. If NAME is the empty // string, don't provide a DW_AT_name attribute. - void DefineInlineInstanceDIE(DIEHandler *parent, const string &name, + void DefineInlineInstanceDIE(DIEHandler* parent, const string& name, uint64_t origin, Module::Address address, Module::Address size); @@ -259,7 +259,7 @@ class CUFixtureBase { // Test that the I'th function (ordered by address) in the module // this.module_ has the given name, address, and size, and that its // parameter size is zero. - void TestFunction(int i, const string &name, + void TestFunction(int i, const string& name, Module::Address address, Module::Address size); // Test that the number of source lines owned by the I'th function @@ -270,7 +270,7 @@ class CUFixtureBase { // (again, by address) has the given address, size, filename, and // line number. void TestLine(int i, int j, Module::Address address, Module::Address size, - const string &filename, int number); + const string& filename, int number); // Actual objects under test. Module module_; @@ -308,7 +308,7 @@ class CUFixtureBase { // If functions_filled_ is true, this is a table of functions we've // extracted from module_, sorted by address. - vector functions_; + vector functions_; // True if we have filled the above vector with this.module_'s function list. bool functions_filled_; }; @@ -318,7 +318,7 @@ const size_t CUFixtureBase::dummy_line_size_ = sizeof(CUFixtureBase::dummy_line_program_); void CUFixtureBase::PushLine(Module::Address address, Module::Address size, - const string &filename, int line_number) { + const string& filename, int line_number) { Module::Line l; l.address = address; l.size = size; @@ -376,7 +376,7 @@ void CUFixtureBase::StartCU() { } void CUFixtureBase::ProcessStrangeAttributes( - dwarf2reader::DIEHandler *handler) { + dwarf2reader::DIEHandler* handler) { handler->ProcessAttributeUnsigned((DwarfAttribute) 0xf560dead, (DwarfForm) 0x4106e4db, 0xa592571997facda1ULL); @@ -395,10 +395,10 @@ void CUFixtureBase::ProcessStrangeAttributes( "strange string"); } -DIEHandler *CUFixtureBase::StartNamedDIE(DIEHandler *parent, +DIEHandler* CUFixtureBase::StartNamedDIE(DIEHandler* parent, DwarfTag tag, - const string &name) { - dwarf2reader::DIEHandler *handler + const string& name) { + dwarf2reader::DIEHandler* handler = parent->FindChildHandler(0x8f4c783c0467c989ULL, tag); if (!handler) return NULL; @@ -415,11 +415,11 @@ DIEHandler *CUFixtureBase::StartNamedDIE(DIEHandler *parent, return handler; } -DIEHandler *CUFixtureBase::StartSpecifiedDIE(DIEHandler *parent, +DIEHandler* CUFixtureBase::StartSpecifiedDIE(DIEHandler* parent, DwarfTag tag, uint64_t specification, - const char *name) { - dwarf2reader::DIEHandler *handler + const char* name) { + dwarf2reader::DIEHandler* handler = parent->FindChildHandler(0x8f4c783c0467c989ULL, tag); if (!handler) return NULL; @@ -439,12 +439,12 @@ DIEHandler *CUFixtureBase::StartSpecifiedDIE(DIEHandler *parent, return handler; } -void CUFixtureBase::DefineFunction(dwarf2reader::DIEHandler *parent, - const string &name, Module::Address address, +void CUFixtureBase::DefineFunction(dwarf2reader::DIEHandler* parent, + const string& name, Module::Address address, Module::Address size, const char* mangled_name, DwarfForm high_pc_form) { - dwarf2reader::DIEHandler *func + dwarf2reader::DIEHandler* func = parent->FindChildHandler(0xe34797c7e68590a8LL, dwarf2reader::DW_TAG_subprogram); ASSERT_TRUE(func != NULL); @@ -474,11 +474,11 @@ void CUFixtureBase::DefineFunction(dwarf2reader::DIEHandler *parent, delete func; } -void CUFixtureBase::DeclarationDIE(DIEHandler *parent, uint64_t offset, +void CUFixtureBase::DeclarationDIE(DIEHandler* parent, uint64_t offset, DwarfTag tag, - const string &name, - const string &mangled_name) { - dwarf2reader::DIEHandler *die = parent->FindChildHandler(offset, tag); + const string& name, + const string& mangled_name) { + dwarf2reader::DIEHandler* die = parent->FindChildHandler(offset, tag); ASSERT_TRUE(die != NULL); if (!name.empty()) die->ProcessAttributeString(dwarf2reader::DW_AT_name, @@ -497,13 +497,13 @@ void CUFixtureBase::DeclarationDIE(DIEHandler *parent, uint64_t offset, delete die; } -void CUFixtureBase::DefinitionDIE(DIEHandler *parent, +void CUFixtureBase::DefinitionDIE(DIEHandler* parent, DwarfTag tag, uint64_t specification, - const string &name, + const string& name, Module::Address address, Module::Address size) { - dwarf2reader::DIEHandler *die + dwarf2reader::DIEHandler* die = parent->FindChildHandler(0x6ccfea031a9e6cc9ULL, tag); ASSERT_TRUE(die != NULL); die->ProcessAttributeReference(dwarf2reader::DW_AT_specification, @@ -526,13 +526,13 @@ void CUFixtureBase::DefinitionDIE(DIEHandler *parent, delete die; } -void CUFixtureBase::AbstractInstanceDIE(DIEHandler *parent, +void CUFixtureBase::AbstractInstanceDIE(DIEHandler* parent, uint64_t offset, DwarfInline type, uint64_t specification, - const string &name, + const string& name, DwarfForm form) { - dwarf2reader::DIEHandler *die + dwarf2reader::DIEHandler* die = parent->FindChildHandler(offset, dwarf2reader::DW_TAG_subprogram); ASSERT_TRUE(die != NULL); if (specification != 0ULL) @@ -554,12 +554,12 @@ void CUFixtureBase::AbstractInstanceDIE(DIEHandler *parent, delete die; } -void CUFixtureBase::DefineInlineInstanceDIE(DIEHandler *parent, - const string &name, +void CUFixtureBase::DefineInlineInstanceDIE(DIEHandler* parent, + const string& name, uint64_t origin, Module::Address address, Module::Address size) { - dwarf2reader::DIEHandler *func + dwarf2reader::DIEHandler* func = parent->FindChildHandler(0x11c70f94c6e87ccdLL, dwarf2reader::DW_TAG_subprogram); ASSERT_TRUE(func != NULL); @@ -597,13 +597,13 @@ void CUFixtureBase::TestFunctionCount(size_t expected) { ASSERT_EQ(expected, functions_.size()); } -void CUFixtureBase::TestFunction(int i, const string &name, +void CUFixtureBase::TestFunction(int i, const string& name, Module::Address address, Module::Address size) { FillFunctions(); ASSERT_LT((size_t) i, functions_.size()); - Module::Function *function = functions_[i]; + Module::Function* function = functions_[i]; EXPECT_EQ(name, function->name); EXPECT_EQ(address, function->address); EXPECT_EQ(size, function->ranges[0].size); @@ -619,12 +619,12 @@ void CUFixtureBase::TestLineCount(int i, size_t expected) { void CUFixtureBase::TestLine(int i, int j, Module::Address address, Module::Address size, - const string &filename, int number) { + const string& filename, int number) { FillFunctions(); ASSERT_LT((size_t) i, functions_.size()); ASSERT_LT((size_t) j, functions_[i]->lines.size()); - Module::Line *line = &functions_[i]->lines[j]; + Module::Line* line = &functions_[i]->lines[j]; EXPECT_EQ(address, line->address); EXPECT_EQ(size, line->size); EXPECT_EQ(filename, line->file->name.c_str()); @@ -711,7 +711,7 @@ TEST_F(SimpleCU, IrrelevantRootChildren) { TEST_F(SimpleCU, IrrelevantNamedScopeChildren) { StartCU(); - DIEHandler *class_A_handler + DIEHandler* class_A_handler = StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type, "class_A"); EXPECT_TRUE(class_A_handler != NULL); EXPECT_FALSE(class_A_handler @@ -861,7 +861,7 @@ INSTANTIATE_TEST_CASE_P(AllSituations, FuncLinePairing, ValuesIn(situations)); TEST_P(FuncLinePairing, Pairing) { - const Situation &s = GetParam(); + const Situation& s = GetParam(); PushLine(s.lines[0].start, s.lines[0].end - s.lines[0].start, "line-file", 67636963); @@ -1057,7 +1057,7 @@ TEST_P(CXXQualifiedNames, TwoFunctions) { PushLine(20, 1, "filename2", 95115701); StartCU(); - DIEHandler *enclosure_handler = StartNamedDIE(&root_handler_, tag, + DIEHandler* enclosure_handler = StartNamedDIE(&root_handler_, tag, "Enclosure"); EXPECT_TRUE(enclosure_handler != NULL); DefineFunction(enclosure_handler, "func_B", 10, 1, NULL); @@ -1078,11 +1078,11 @@ TEST_P(CXXQualifiedNames, FuncInEnclosureInNamespace) { PushLine(10, 1, "line-file", 69819327); StartCU(); - DIEHandler *namespace_handler + DIEHandler* namespace_handler = StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_namespace, "Namespace"); EXPECT_TRUE(namespace_handler != NULL); - DIEHandler *enclosure_handler = StartNamedDIE(namespace_handler, tag, + DIEHandler* enclosure_handler = StartNamedDIE(namespace_handler, tag, "Enclosure"); EXPECT_TRUE(enclosure_handler != NULL); DefineFunction(enclosure_handler, "function", 10, 1, NULL); @@ -1101,15 +1101,15 @@ TEST_F(CXXQualifiedNames, FunctionInClassInStructInNamespace) { PushLine(10, 1, "filename1", 69819327); StartCU(); - DIEHandler *namespace_handler + DIEHandler* namespace_handler = StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_namespace, "namespace_A"); EXPECT_TRUE(namespace_handler != NULL); - DIEHandler *struct_handler + DIEHandler* struct_handler = StartNamedDIE(namespace_handler, dwarf2reader::DW_TAG_structure_type, "struct_B"); EXPECT_TRUE(struct_handler != NULL); - DIEHandler *class_handler + DIEHandler* class_handler = StartNamedDIE(struct_handler, dwarf2reader::DW_TAG_class_type, "class_C"); DefineFunction(class_handler, "function_D", 10, 1, NULL); @@ -1127,7 +1127,7 @@ TEST_F(CXXQualifiedNames, FunctionInClassInStructInNamespace) { struct LanguageAndQualifiedName { dwarf2reader::DwarfLanguage language; - const char *name; + const char* name; }; const LanguageAndQualifiedName LanguageAndQualifiedNameCases[] = { @@ -1149,13 +1149,13 @@ INSTANTIATE_TEST_CASE_P(LanguageAndQualifiedName, QualifiedForLanguage, ValuesIn(LanguageAndQualifiedNameCases)); TEST_P(QualifiedForLanguage, MemberFunction) { - const LanguageAndQualifiedName ¶m = GetParam(); + const LanguageAndQualifiedName& param = GetParam(); PushLine(10, 1, "line-file", 212966758); SetLanguage(param.language); StartCU(); - DIEHandler *class_handler + DIEHandler* class_handler = StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type, "class_A"); DefineFunction(class_handler, "function_B", 10, 1, NULL); @@ -1172,14 +1172,14 @@ TEST_P(QualifiedForLanguage, MemberFunction) { } TEST_P(QualifiedForLanguage, MemberFunctionSignedLanguage) { - const LanguageAndQualifiedName ¶m = GetParam(); + const LanguageAndQualifiedName& param = GetParam(); PushLine(10, 1, "line-file", 212966758); SetLanguage(param.language); SetLanguageSigned(true); StartCU(); - DIEHandler *class_handler + DIEHandler* class_handler = StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type, "class_A"); DefineFunction(class_handler, "function_B", 10, 1, NULL); @@ -1282,7 +1282,7 @@ TEST_F(Specifications, MemberFunction) { PushLine(0x3341a248634e7170ULL, 0x5f6938ee5553b953ULL, "line-file", 18116691); StartCU(); - DIEHandler *class_handler + DIEHandler* class_handler = StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type, "class_A"); DeclarationDIE(class_handler, 0x7d83028c431406e8ULL, dwarf2reader::DW_TAG_subprogram, "declaration-name", ""); @@ -1305,7 +1305,7 @@ TEST_F(Specifications, FunctionDeclarationParent) { StartCU(); { - DIEHandler *class_handler + DIEHandler* class_handler = StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type, "class_A"); ASSERT_TRUE(class_handler != NULL); @@ -1333,7 +1333,7 @@ TEST_F(Specifications, NamedScopeDeclarationParent) { StartCU(); { - DIEHandler *space_handler + DIEHandler* space_handler = StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_namespace, "space_A"); ASSERT_TRUE(space_handler != NULL); @@ -1345,7 +1345,7 @@ TEST_F(Specifications, NamedScopeDeclarationParent) { } { - DIEHandler *class_handler + DIEHandler* class_handler = StartSpecifiedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type, 0x419bb1d12f9a73a2ULL, "class-definition-name"); ASSERT_TRUE(class_handler != NULL); @@ -1437,7 +1437,7 @@ TEST_F(Specifications, LongChain) { // space_A::space_B::struct_C::struct_D::union_E::union_F:: // class_G::class_H::func_I { - DIEHandler *space_A_handler + DIEHandler* space_A_handler = StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_namespace, "space_A"); DeclarationDIE(space_A_handler, 0x2e111126496596e2ULL, @@ -1447,10 +1447,10 @@ TEST_F(Specifications, LongChain) { } { - DIEHandler *space_B_handler + DIEHandler* space_B_handler = StartSpecifiedDIE(&root_handler_, dwarf2reader::DW_TAG_namespace, 0x2e111126496596e2ULL); - DIEHandler *struct_C_handler + DIEHandler* struct_C_handler = StartNamedDIE(space_B_handler, dwarf2reader::DW_TAG_structure_type, "struct_C"); DeclarationDIE(struct_C_handler, 0x20cd423bf2a25a4cULL, @@ -1462,10 +1462,10 @@ TEST_F(Specifications, LongChain) { } { - DIEHandler *struct_D_handler + DIEHandler* struct_D_handler = StartSpecifiedDIE(&root_handler_, dwarf2reader::DW_TAG_structure_type, 0x20cd423bf2a25a4cULL); - DIEHandler *union_E_handler + DIEHandler* union_E_handler = StartNamedDIE(struct_D_handler, dwarf2reader::DW_TAG_union_type, "union_E"); DeclarationDIE(union_E_handler, 0xe25c84805aa58c32ULL, @@ -1477,10 +1477,10 @@ TEST_F(Specifications, LongChain) { } { - DIEHandler *union_F_handler + DIEHandler* union_F_handler = StartSpecifiedDIE(&root_handler_, dwarf2reader::DW_TAG_union_type, 0xe25c84805aa58c32ULL); - DIEHandler *class_G_handler + DIEHandler* class_G_handler = StartNamedDIE(union_F_handler, dwarf2reader::DW_TAG_class_type, "class_G"); DeclarationDIE(class_G_handler, 0xb70d960dcc173b6eULL, @@ -1492,7 +1492,7 @@ TEST_F(Specifications, LongChain) { } { - DIEHandler *class_H_handler + DIEHandler* class_H_handler = StartSpecifiedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type, 0xb70d960dcc173b6eULL); DeclarationDIE(class_H_handler, 0x27ff829e3bf69f37ULL, @@ -1542,7 +1542,7 @@ TEST_F(Specifications, InterCU) { ASSERT_TRUE(root2_handler.StartRootDIE(1, dwarf2reader::DW_TAG_compile_unit)); ASSERT_TRUE(root2_handler.EndAttributes()); - DIEHandler *class_A_handler + DIEHandler* class_A_handler = StartSpecifiedDIE(&root2_handler, dwarf2reader::DW_TAG_class_type, 0xb8fbfdd5f0b26fceULL); DeclarationDIE(class_A_handler, 0xb01fef8b380bd1a2ULL, @@ -1565,7 +1565,7 @@ TEST_F(Specifications, InterCU) { root3_handler.Finish(); } - vector functions; + vector functions; m.GetFunctions(&functions, functions.end()); EXPECT_EQ(1U, functions.size()); EXPECT_STREQ("class_A::member_func_B", functions[0]->name.c_str()); @@ -1602,7 +1602,7 @@ TEST_F(Specifications, UnhandledInterCU) { dwarf2reader::DW_TAG_compile_unit)); ASSERT_TRUE(root2_handler.EndAttributes()); EXPECT_CALL(reporter_, UnhandledInterCUReference(_, _)).Times(1); - DIEHandler *class_A_handler + DIEHandler* class_A_handler = StartSpecifiedDIE(&root2_handler, dwarf2reader::DW_TAG_class_type, 0xb8fbfdd5f0b26fceULL); DeclarationDIE(class_A_handler, 0xb01fef8b380bd1a2ULL, @@ -1665,7 +1665,7 @@ TEST_F(Specifications, ClassDefinitionHasOwnName) { DeclarationDIE(&root_handler_, 0xd0fe467ec2f1a58cULL, dwarf2reader::DW_TAG_class_type, "class-declaration-name", ""); - dwarf2reader::DIEHandler *class_definition + dwarf2reader::DIEHandler* class_definition = StartSpecifiedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type, 0xd0fe467ec2f1a58cULL, "class-definition-name"); ASSERT_TRUE(class_definition); @@ -1696,7 +1696,7 @@ TEST_F(Specifications, PreferSpecificationParents) { StartCU(); { - dwarf2reader::DIEHandler *declaration_class_handler = + dwarf2reader::DIEHandler* declaration_class_handler = StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type, "declaration-class"); DeclarationDIE(declaration_class_handler, 0x9ddb35517455ef7aULL, @@ -1706,7 +1706,7 @@ TEST_F(Specifications, PreferSpecificationParents) { delete declaration_class_handler; } { - dwarf2reader::DIEHandler *definition_class_handler + dwarf2reader::DIEHandler* definition_class_handler = StartNamedDIE(&root_handler_, dwarf2reader::DW_TAG_class_type, "definition-class"); DefinitionDIE(definition_class_handler, dwarf2reader::DW_TAG_subprogram, diff --git a/src/common/dwarf_line_to_module.cc b/src/common/dwarf_line_to_module.cc index 443d7448..fe808c08 100644 --- a/src/common/dwarf_line_to_module.cc +++ b/src/common/dwarf_line_to_module.cc @@ -44,18 +44,18 @@ // it until we actually have to deal with DWARF on Windows. // Return true if PATH is an absolute path, false if it is relative. -static bool PathIsAbsolute(const string &path) { +static bool PathIsAbsolute(const string& path) { return (path.size() >= 1 && path[0] == '/'); } -static bool HasTrailingSlash(const string &path) { +static bool HasTrailingSlash(const string& path) { return (path.size() >= 1 && path[path.size() - 1] == '/'); } // If PATH is an absolute path, return PATH. If PATH is a relative path, // treat it as relative to BASE and return the combined path. -static string ExpandPath(const string &path, - const string &base) { +static string ExpandPath(const string& path, + const string& base) { if (PathIsAbsolute(path) || base.empty()) return path; return base + (HasTrailingSlash(base) ? "" : "/") + path; @@ -63,14 +63,14 @@ static string ExpandPath(const string &path, namespace google_breakpad { -void DwarfLineToModule::DefineDir(const string &name, uint32_t dir_num) { +void DwarfLineToModule::DefineDir(const string& name, uint32_t dir_num) { // Directory number zero is reserved to mean the compilation // directory. Silently ignore attempts to redefine it. if (dir_num != 0) directories_[dir_num] = ExpandPath(name, compilation_dir_); } -void DwarfLineToModule::DefineFile(const string &name, int32_t file_num, +void DwarfLineToModule::DefineFile(const string& name, int32_t file_num, uint32_t dir_num, uint64_t mod_time, uint64_t length) { if (file_num == -1) diff --git a/src/common/dwarf_line_to_module.h b/src/common/dwarf_line_to_module.h index f54ccaf5..f80f1b07 100644 --- a/src/common/dwarf_line_to_module.h +++ b/src/common/dwarf_line_to_module.h @@ -121,7 +121,7 @@ class DwarfLineToModule: public dwarf2reader::LineInfoHandler { // sort out which lines belong to which functions; we don't add them // to any particular function in MODULE ourselves. DwarfLineToModule(Module *module, const string& compilation_dir, - vector *lines) + vector* lines) : module_(module), compilation_dir_(compilation_dir), lines_(lines), @@ -132,8 +132,8 @@ class DwarfLineToModule: public dwarf2reader::LineInfoHandler { ~DwarfLineToModule() { } - void DefineDir(const string &name, uint32_t dir_num); - void DefineFile(const string &name, int32_t file_num, + void DefineDir(const string& name, uint32_t dir_num); + void DefineFile(const string& name, int32_t file_num, uint32_t dir_num, uint64_t mod_time, uint64_t length); void AddLine(uint64_t address, uint64_t length, @@ -142,7 +142,7 @@ class DwarfLineToModule: public dwarf2reader::LineInfoHandler { private: typedef std::map DirectoryTable; - typedef std::map FileTable; + typedef std::map FileTable; // The module we're contributing debugging info to. Owned by our // client. @@ -161,7 +161,7 @@ class DwarfLineToModule: public dwarf2reader::LineInfoHandler { // to the appropriate function from module_ until we've read the // function info as well. Instead, we accumulate lines here, and let // whoever constructed this sort it all out. - vector *lines_; + vector* lines_; // A table mapping directory numbers to paths. DirectoryTable directories_; diff --git a/src/common/dwarf_line_to_module_unittest.cc b/src/common/dwarf_line_to_module_unittest.cc index 7c0fcfd3..90b6570d 100644 --- a/src/common/dwarf_line_to_module_unittest.cc +++ b/src/common/dwarf_line_to_module_unittest.cc @@ -51,7 +51,7 @@ TEST(SimpleModule, One) { h.AddLine(0x6fd126fbf74f2680LL, 0x63c9a14cf556712bLL, 0x30bf0f27, 0x4c090cbf, 0x1cf9fe0d); - vector files; + vector files; m.GetFiles(&files); EXPECT_EQ(1U, files.size()); EXPECT_STREQ("/file1", files[0]->name.c_str()); @@ -86,7 +86,7 @@ TEST(SimpleModule, Many) { h.AddLine(0xe2d72a37f8d9403aULL, 0x034dfab5b0d4d236ULL, 0x63beb4a5, 0x75047044U, 0xb6a0016cU); - vector files; + vector files; m.GetFiles(&files); ASSERT_EQ(5U, files.size()); EXPECT_STREQ("/directory1/file1", files[0]->name.c_str()); @@ -133,7 +133,7 @@ TEST(Filenames, Absolute) { h.AddLine(1, 1, 1, 0, 0); - vector files; + vector files; m.GetFiles(&files); ASSERT_EQ(1U, files.size()); EXPECT_STREQ("/absolute", files[0]->name.c_str()); @@ -151,7 +151,7 @@ TEST(Filenames, Relative) { h.AddLine(1, 1, 1, 0, 0); - vector files; + vector files; m.GetFiles(&files); ASSERT_EQ(1U, files.size()); EXPECT_STREQ("/directory1/relative", files[0]->name.c_str()); diff --git a/src/common/dwarf_range_list_handler.cc b/src/common/dwarf_range_list_handler.cc index cc9e39ce..58982aac 100644 --- a/src/common/dwarf_range_list_handler.cc +++ b/src/common/dwarf_range_list_handler.cc @@ -51,7 +51,7 @@ void DwarfRangeListHandler::SetBaseAddress(uint64_t base_address) { void DwarfRangeListHandler::Finish() { std::sort(ranges_->begin(), ranges_->end(), - [](const Module::Range &a, const Module::Range &b) { + [](const Module::Range& a, const Module::Range& b) { return a.address < b.address; } ); diff --git a/src/common/dwarf_range_list_handler.h b/src/common/dwarf_range_list_handler.h index 83a34694..2adb2f9a 100644 --- a/src/common/dwarf_range_list_handler.h +++ b/src/common/dwarf_range_list_handler.h @@ -51,7 +51,7 @@ namespace google_breakpad { class DwarfRangeListHandler: public dwarf2reader::RangeListHandler { public: - DwarfRangeListHandler(uint64_t base_address, vector *ranges) + DwarfRangeListHandler(uint64_t base_address, vector* ranges) : base_address_(base_address), ranges_(ranges) { } ~DwarfRangeListHandler() { } @@ -71,7 +71,7 @@ class DwarfRangeListHandler: public dwarf2reader::RangeListHandler { uint64_t base_address_; // The list of ranges to be populated - vector *ranges_; + vector* ranges_; }; } // namespace google_breakpad diff --git a/src/common/language.cc b/src/common/language.cc index 440d4de1..381c8bd4 100644 --- a/src/common/language.cc +++ b/src/common/language.cc @@ -67,8 +67,8 @@ class CPPLanguage: public Language { public: CPPLanguage() {} - string MakeQualifiedName(const string &parent_name, - const string &name) const { + string MakeQualifiedName(const string& parent_name, + const string& name) const { return MakeQualifiedNameWithSeparator(parent_name, "::", name); } @@ -108,7 +108,7 @@ class CPPLanguage: public Language { } private: - static bool IsMangledName(const string &name) { + static bool IsMangledName(const string& name) { // NOTE: For proper cross-compilation support, this should depend on target // binary's platform, not current build platform. #if defined(__APPLE__) @@ -130,8 +130,8 @@ class JavaLanguage: public Language { public: JavaLanguage() {} - string MakeQualifiedName(const string &parent_name, - const string &name) const { + string MakeQualifiedName(const string& parent_name, + const string& name) const { return MakeQualifiedNameWithSeparator(parent_name, ".", name); } }; @@ -143,8 +143,8 @@ class SwiftLanguage: public Language { public: SwiftLanguage() {} - string MakeQualifiedName(const string &parent_name, - const string &name) const { + string MakeQualifiedName(const string& parent_name, + const string& name) const { return MakeQualifiedNameWithSeparator(parent_name, ".", name); } @@ -167,8 +167,8 @@ class RustLanguage: public Language { public: RustLanguage() {} - string MakeQualifiedName(const string &parent_name, - const string &name) const { + string MakeQualifiedName(const string& parent_name, + const string& name) const { return MakeQualifiedNameWithSeparator(parent_name, ".", name); } @@ -202,8 +202,8 @@ class AssemblerLanguage: public Language { AssemblerLanguage() {} bool HasFunctions() const { return false; } - string MakeQualifiedName(const string &parent_name, - const string &name) const { + string MakeQualifiedName(const string& parent_name, + const string& name) const { return name; } }; diff --git a/src/common/language.h b/src/common/language.h index 2d2dbcd9..892ea862 100644 --- a/src/common/language.h +++ b/src/common/language.h @@ -74,8 +74,8 @@ class Language { // take into account the parent and child DIE types, allow languages // to use their own data type for complex parent names, etc. But if // C++ doesn't need all that, who would? - virtual string MakeQualifiedName (const string &parent_name, - const string &name) const = 0; + virtual string MakeQualifiedName (const string& parent_name, + const string& name) const = 0; enum DemangleResult { // Demangling was not performed because it’s not appropriate to attempt. diff --git a/src/common/linux/breakpad_getcontext.S b/src/common/linux/breakpad_getcontext.S index fea0109d..528dba7a 100644 --- a/src/common/linux/breakpad_getcontext.S +++ b/src/common/linux/breakpad_getcontext.S @@ -32,7 +32,7 @@ #include "common/linux/ucontext_constants.h" -/* int getcontext (ucontext_t *ucp) */ +/* int getcontext (ucontext_t* ucp) */ #if defined(__arm__) @@ -336,7 +336,7 @@ symbol: .frame sp, framesize, rpc; .size function,.-function #endif -/* int getcontext (ucontext_t *ucp) */ +/* int getcontext (ucontext_t* ucp) */ NESTED (breakpad_getcontext, FRAME_SIZE, ra) .mask 0x10000000, 0 diff --git a/src/common/linux/dump_symbols.cc b/src/common/linux/dump_symbols.cc index 997977b8..8ecf0bc4 100644 --- a/src/common/linux/dump_symbols.cc +++ b/src/common/linux/dump_symbols.cc @@ -144,7 +144,7 @@ class MmapWrapper { munmap(base_, size_); } } - void set(void *mapped_address, size_t mapped_size) { + void set(void* mapped_address, size_t mapped_size) { is_set_ = true; base_ = mapped_address; size_ = mapped_size; @@ -232,7 +232,7 @@ bool LoadStabs(const typename ElfClass::Ehdr* elf_header, // owned by a function) with the results. class 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) { } @@ -246,7 +246,7 @@ class DumperRangesHandler : public DwarfCUToModule::RangesHandler { } private: - const uint8_t *buffer_; + const uint8_t* buffer_; uint64_t size_; dwarf2reader::ByteReader* reader_; }; @@ -257,7 +257,7 @@ class DumperRangesHandler : public DwarfCUToModule::RangesHandler { class DumperLineToModule: public DwarfCUToModule::LineToModuleHandler { public: // Create a line-to-module converter using BYTE_READER. - explicit DumperLineToModule(dwarf2reader::ByteReader *byte_reader) + explicit DumperLineToModule(dwarf2reader::ByteReader* byte_reader) : byte_reader_(byte_reader) { } void StartCompilationUnit(const string& compilation_dir) { compilation_dir_ = compilation_dir; @@ -278,7 +278,7 @@ class DumperLineToModule: public DwarfCUToModule::LineToModuleHandler { } private: string compilation_dir_; - dwarf2reader::ByteReader *byte_reader_; + dwarf2reader::ByteReader* byte_reader_; }; template @@ -308,7 +308,7 @@ bool LoadDwarf(const string& dwarf_filename, string name = GetOffset(elf_header, section_names->sh_offset) + section->sh_name; - const uint8_t *contents = GetOffset(elf_header, + const uint8_t* contents = GetOffset(elf_header, section->sh_offset); file_context.AddSectionToSectionMap(name, contents, section->sh_size); } @@ -318,7 +318,7 @@ bool LoadDwarf(const string& dwarf_filename, dwarf2reader::SectionMap::const_iterator ranges_entry = file_context.section_map().find(".debug_ranges"); if (ranges_entry != file_context.section_map().end()) { - const std::pair& ranges_section = + const std::pair& ranges_section = ranges_entry->second; ranges_handler.reset( new DumperRangesHandler(ranges_section.first, ranges_section.second, @@ -330,7 +330,7 @@ bool LoadDwarf(const string& dwarf_filename, dwarf2reader::SectionMap::const_iterator debug_info_entry = file_context.section_map().find(".debug_info"); assert(debug_info_entry != file_context.section_map().end()); - const std::pair& debug_info_section = + const std::pair& debug_info_section = debug_info_entry->second; // This should never have been called if the file doesn't have a // .debug_info section. @@ -409,7 +409,7 @@ bool LoadDwarfCFI(const string& dwarf_filename, dwarf2reader::ENDIANNESS_BIG : dwarf2reader::ENDIANNESS_LITTLE; // Find the call frame information and its size. - const uint8_t *cfi = + const uint8_t* cfi = GetOffset(elf_header, section->sh_offset); size_t cfi_size = section->sh_size; @@ -497,13 +497,13 @@ bool IsSameFile(const char* left_abspath, const string& right_path) { // Read the .gnu_debuglink and get the debug file name. If anything goes // wrong, return an empty string. -string ReadDebugLink(const uint8_t *debuglink, +string ReadDebugLink(const uint8_t* debuglink, const size_t debuglink_size, const bool big_endian, const string& obj_file, const std::vector& debug_dirs) { // Include '\0' + CRC32 (4 bytes). - size_t debuglink_len = strlen(reinterpret_cast(debuglink)) + 5; + size_t debuglink_len = strlen(reinterpret_cast(debuglink)) + 5; debuglink_len = 4 * ((debuglink_len + 3) / 4); // Round up to 4 bytes. // Sanity check. @@ -525,7 +525,7 @@ string ReadDebugLink(const uint8_t *debuglink, for (it = debug_dirs.begin(); it < debug_dirs.end(); ++it) { const string& debug_dir = *it; debuglink_path = debug_dir + "/" + - reinterpret_cast(debuglink); + reinterpret_cast(debuglink); // There is the annoying case of /path/to/foo.so having foo.so as the // debug link file name. Thus this may end up opening /path/to/foo.so again, @@ -599,7 +599,7 @@ class LoadSymbolsInfo { // Keeps track of which sections have been loaded so sections don't // accidentally get loaded twice from two different files. - void LoadedSection(const string §ion) { + void LoadedSection(const string& section) { if (loaded_sections_.count(section) == 0) { loaded_sections_.insert(section); } else { @@ -610,7 +610,7 @@ class LoadSymbolsInfo { // The ELF file and linked debug file are expected to have the same preferred // loading address. - void set_loading_addr(Addr addr, const string &filename) { + void set_loading_addr(Addr addr, const string& filename) { if (!has_loading_addr_) { loading_addr_ = addr; loaded_file_ = filename; @@ -687,7 +687,7 @@ bool LoadSymbols(const string& obj_file, const Shdr* section_names = sections + elf_header->e_shstrndx; const char* names = GetOffset(elf_header, section_names->sh_offset); - const char *names_end = names + section_names->sh_size; + const char* names_end = names + section_names->sh_size; bool found_debug_info_section = false; bool found_usable_info = false; @@ -867,7 +867,7 @@ bool LoadSymbols(const string& obj_file, names_end, elf_header->e_shnum); if (gnu_debuglink_section) { if (!info->debug_dirs().empty()) { - const uint8_t *debuglink_contents = + const uint8_t* debuglink_contents = GetOffset(elf_header, gnu_debuglink_section->sh_offset); string debuglink_file = @@ -964,7 +964,7 @@ bool InitModuleForElfClass(const typename ElfClass::Ehdr* elf_header, return false; } - const char *architecture = ElfArchitecture(elf_header); + const char* architecture = ElfArchitecture(elf_header); if (!architecture) { fprintf(stderr, "%s: unrecognized ELF machine architecture: %d\n", obj_filename.c_str(), elf_header->e_machine); @@ -1074,12 +1074,12 @@ bool ReadSymbolDataInternal(const uint8_t* obj_file, return false; } -bool WriteSymbolFile(const string &load_path, - const string &obj_file, - const string &obj_os, +bool WriteSymbolFile(const string& load_path, + const string& obj_file, + const string& obj_os, const std::vector& debug_dirs, const DumpOptions& options, - std::ostream &sym_stream) { + std::ostream& sym_stream) { Module* module; if (!ReadSymbolData(load_path, obj_file, obj_os, debug_dirs, options, &module)) @@ -1096,7 +1096,7 @@ bool WriteSymbolFile(const string &load_path, bool WriteSymbolFileHeader(const string& load_path, const string& obj_file, const string& obj_os, - std::ostream &sym_stream) { + std::ostream& sym_stream) { MmapWrapper map_wrapper; void* elf_header = NULL; if (!LoadELF(load_path, &map_wrapper, &elf_header)) { diff --git a/src/common/linux/dump_symbols.h b/src/common/linux/dump_symbols.h index eaddd8b2..b033ce00 100644 --- a/src/common/linux/dump_symbols.h +++ b/src/common/linux/dump_symbols.h @@ -62,12 +62,12 @@ struct DumpOptions { // If OBJ_FILE has been stripped but contains a .gnu_debuglink section, // then look for the debug file in DEBUG_DIRS. // SYMBOL_DATA allows limiting the type of symbol data written. -bool WriteSymbolFile(const string &load_path, - const string &obj_file, - const string &obj_os, +bool WriteSymbolFile(const string& load_path, + const string& obj_file, + const string& obj_os, const std::vector& debug_dirs, const DumpOptions& options, - std::ostream &sym_stream); + std::ostream& sym_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 @@ -76,7 +76,7 @@ bool WriteSymbolFile(const string &load_path, bool WriteSymbolFileHeader(const string& load_path, const string& obj_file, const string& obj_os, - std::ostream &sym_stream); + std::ostream& sym_stream); // As above, but simply return the debugging information in MODULE // instead of writing it to a stream. The caller owns the resulting diff --git a/src/common/linux/elf_symbols_to_module.cc b/src/common/linux/elf_symbols_to_module.cc index 562875e1..81e985a7 100644 --- a/src/common/linux/elf_symbols_to_module.cc +++ b/src/common/linux/elf_symbols_to_module.cc @@ -69,7 +69,7 @@ public: // otherwise. Assume each symbol has a 'value' field whose size is // VALUE_SIZE. // - ELFSymbolIterator(const ByteBuffer *buffer, bool big_endian, + ELFSymbolIterator(const ByteBuffer* buffer, bool big_endian, size_t value_size) : value_size_(value_size), cursor_(buffer, big_endian) { // Actually, weird sizes could be handled just fine, but they're @@ -81,13 +81,13 @@ public: // Move to the next symbol. This function's behavior is undefined if // at_end() is true when it is called. - ELFSymbolIterator &operator++() { Fetch(); symbol_.index++; return *this; } + ELFSymbolIterator& operator++() { Fetch(); symbol_.index++; return *this; } // Dereferencing this iterator produces a reference to an Symbol structure // that holds the current symbol's values. The symbol is owned by this // SymbolIterator, and will be invalidated at the next call to operator++. - const Symbol &operator*() const { return symbol_; } - const Symbol *operator->() const { return &symbol_; } + const Symbol& operator*() const { return symbol_; } + const Symbol* operator->() const { return &symbol_; } private: // Read the symbol at cursor_, and set symbol_ appropriately. @@ -126,21 +126,21 @@ private: Symbol symbol_; }; -const char *SymbolString(ptrdiff_t offset, ByteBuffer& strings) { +const char* SymbolString(ptrdiff_t offset, ByteBuffer& strings) { if (offset < 0 || (size_t) offset >= strings.Size()) { // Return the null string. offset = 0; } - return reinterpret_cast(strings.start + offset); + return reinterpret_cast(strings.start + offset); } -bool ELFSymbolsToModule(const uint8_t *symtab_section, +bool ELFSymbolsToModule(const uint8_t* symtab_section, size_t symtab_size, - const uint8_t *string_section, + const uint8_t* string_section, size_t string_size, const bool big_endian, size_t value_size, - Module *module) { + Module* module) { ByteBuffer symbols(symtab_section, symtab_size); // Ensure that the string section is null-terminated. if (string_section[string_size - 1] != '\0') { @@ -156,7 +156,7 @@ bool ELFSymbolsToModule(const uint8_t *symtab_section, while(!iterator->at_end) { if (ELF32_ST_TYPE(iterator->info) == STT_FUNC && iterator->shndx != SHN_UNDEF) { - Module::Extern *ext = new Module::Extern(iterator->value); + Module::Extern* ext = new Module::Extern(iterator->value); ext->name = SymbolString(iterator->name_offset, strings); #if !defined(__ANDROID__) // Android NDK doesn't provide abi::__cxa_demangle. int status = 0; diff --git a/src/common/linux/elf_symbols_to_module.h b/src/common/linux/elf_symbols_to_module.h index 2e7c0971..861f7252 100644 --- a/src/common/linux/elf_symbols_to_module.h +++ b/src/common/linux/elf_symbols_to_module.h @@ -44,13 +44,13 @@ namespace google_breakpad { class Module; -bool ELFSymbolsToModule(const uint8_t *symtab_section, +bool ELFSymbolsToModule(const uint8_t* symtab_section, size_t symtab_size, - const uint8_t *string_section, + const uint8_t* string_section, size_t string_size, const bool big_endian, size_t value_size, - Module *module); + Module* module); } // namespace google_breakpad diff --git a/src/common/linux/elf_symbols_to_module_unittest.cc b/src/common/linux/elf_symbols_to_module_unittest.cc index 8984449a..3f665898 100644 --- a/src/common/linux/elf_symbols_to_module_unittest.cc +++ b/src/common/linux/elf_symbols_to_module_unittest.cc @@ -86,7 +86,7 @@ public: // 4 or 8 (bytes) size_t value_size; - vector externs; + vector externs; }; class ELFSymbolsToModuleTest32 : public ELFSymbolsToModuleTestFixture, diff --git a/src/common/linux/elfutils.cc b/src/common/linux/elfutils.cc index 9532d5ad..ce9e9c1c 100644 --- a/src/common/linux/elfutils.cc +++ b/src/common/linux/elfutils.cc @@ -40,11 +40,11 @@ namespace google_breakpad { namespace { template -void FindElfClassSection(const char *elf_base, - const char *section_name, +void FindElfClassSection(const char* elf_base, + const char* section_name, typename ElfClass::Word section_type, - const void **section_start, - size_t *section_size) { + const void** section_start, + size_t* section_size) { typedef typename ElfClass::Ehdr Ehdr; typedef typename ElfClass::Shdr Shdr; @@ -62,7 +62,7 @@ void FindElfClassSection(const char *elf_base, const Shdr* section_names = sections + elf_header->e_shstrndx; const char* names = GetOffset(elf_header, section_names->sh_offset); - const char *names_end = names + section_names->sh_size; + const char* names_end = names + section_names->sh_size; const Shdr* section = FindElfSectionByName(section_name, section_type, @@ -76,9 +76,9 @@ void FindElfClassSection(const char *elf_base, } template -void FindElfClassSegment(const char *elf_base, +void FindElfClassSegment(const char* elf_base, typename ElfClass::Word segment_type, - wasteful_vector *segments) { + wasteful_vector* segments) { typedef typename ElfClass::Ehdr Ehdr; typedef typename ElfClass::Phdr Phdr; @@ -117,11 +117,11 @@ int ElfClass(const void* elf_base) { return elf_header->e_ident[EI_CLASS]; } -bool FindElfSection(const void *elf_mapped_base, - const char *section_name, +bool FindElfSection(const void* elf_mapped_base, + const char* section_name, uint32_t section_type, - const void **section_start, - size_t *section_size) { + const void** section_start, + size_t* section_size) { assert(elf_mapped_base); assert(section_start); assert(section_size); diff --git a/src/common/linux/elfutils.h b/src/common/linux/elfutils.h index aefb6cf5..ec5872a4 100644 --- a/src/common/linux/elfutils.h +++ b/src/common/linux/elfutils.h @@ -86,11 +86,11 @@ int ElfClass(const void* elf_base); // in the ELF binary data at |elf_mapped_base|. On success, returns true // and sets |*section_start| to point to the start of the section data, // and |*section_size| to the size of the section's data. -bool FindElfSection(const void *elf_mapped_base, - const char *section_name, +bool FindElfSection(const void* elf_mapped_base, + const char* section_name, uint32_t section_type, - const void **section_start, - size_t *section_size); + const void** section_start, + size_t* section_size); // Internal helper method, exposed for convenience for callers // that already have more info. diff --git a/src/common/linux/file_id.cc b/src/common/linux/file_id.cc index 67921c45..9944af7a 100644 --- a/src/common/linux/file_id.cc +++ b/src/common/linux/file_id.cc @@ -61,7 +61,7 @@ FileID::FileID(const char* path) : path_(path) {} // These functions are also used inside the crashed process, so be safe // and use the syscall/libc wrappers instead of direct syscalls or libc. -static bool ElfClassBuildIDNoteIdentifier(const void *section, size_t length, +static bool ElfClassBuildIDNoteIdentifier(const void* section, size_t length, wasteful_vector& identifier) { static_assert(sizeof(ElfClass32::Nhdr) == sizeof(ElfClass64::Nhdr), "Elf32_Nhdr and Elf64_Nhdr should be the same"); @@ -69,7 +69,7 @@ static bool ElfClassBuildIDNoteIdentifier(const void *section, size_t length, const void* section_end = reinterpret_cast(section) + length; const Nhdr* note_header = reinterpret_cast(section); - while (reinterpret_cast(note_header) < section_end) { + while (reinterpret_cast(note_header) < section_end) { if (note_header->n_type == NT_GNU_BUILD_ID) break; note_header = reinterpret_cast( @@ -77,7 +77,7 @@ static bool ElfClassBuildIDNoteIdentifier(const void *section, size_t length, NOTE_PADDING(note_header->n_namesz) + NOTE_PADDING(note_header->n_descsz)); } - if (reinterpret_cast(note_header) >= section_end || + if (reinterpret_cast(note_header) >= section_end || note_header->n_descsz == 0) { return false; } diff --git a/src/common/linux/file_id_unittest.cc b/src/common/linux/file_id_unittest.cc index f4f9ac45..477783d9 100644 --- a/src/common/linux/file_id_unittest.cc +++ b/src/common/linux/file_id_unittest.cc @@ -261,7 +261,7 @@ TYPED_TEST(FileIDTest, BuildIDPH) { elf.AddSection(".text", text, SHT_PROGBITS); Notes notes(kLittleEndian); notes.AddNote(0, "Linux", - reinterpret_cast("\0x42\0x02\0\0"), 4); + reinterpret_cast("\0x42\0x02\0\0"), 4); notes.AddNote(NT_GNU_BUILD_ID, "GNU", kExpectedIdentifierBytes, sizeof(kExpectedIdentifierBytes)); int note_idx = elf.AddSection(".note", notes, SHT_NOTE); @@ -292,7 +292,7 @@ TYPED_TEST(FileIDTest, BuildIDMultiplePH) { elf.AddSection(".text", text, SHT_PROGBITS); Notes notes1(kLittleEndian); notes1.AddNote(0, "Linux", - reinterpret_cast("\0x42\0x02\0\0"), 4); + reinterpret_cast("\0x42\0x02\0\0"), 4); Notes notes2(kLittleEndian); notes2.AddNote(NT_GNU_BUILD_ID, "GNU", kExpectedIdentifierBytes, sizeof(kExpectedIdentifierBytes)); diff --git a/src/common/linux/guid_creator.cc b/src/common/linux/guid_creator.cc index 03e3d781..63740638 100644 --- a/src/common/linux/guid_creator.cc +++ b/src/common/linux/guid_creator.cc @@ -105,7 +105,7 @@ class GUIDGenerator { private: #ifdef HAVE_ARC4RANDOM static void CreateGuidFromArc4Random(GUID *guid) { - char *buf = reinterpret_cast(guid); + char *buf = reinterpret_cast(guid); for (size_t i = 0; i < sizeof(GUID); i += sizeof(uint32_t)) { uint32_t random_data = arc4random(); @@ -129,7 +129,7 @@ class GUIDGenerator { #if defined(HAVE_SYS_RANDOM_H) && defined(HAVE_GETRANDOM) static bool CreateGUIDFromGetrandom(GUID *guid) { - char *buf = reinterpret_cast(guid); + char *buf = reinterpret_cast(guid); int read_bytes = getrandom(buf, sizeof(GUID), GRND_NONBLOCK); return (read_bytes == static_cast(sizeof(GUID))); @@ -139,7 +139,7 @@ class GUIDGenerator { // Populate the GUID using random bytes read from /dev/urandom, returns false // if the GUID wasn't fully populated with random data. static bool CreateGUIDFromDevUrandom(GUID *guid) { - char *buf = reinterpret_cast(guid); + char *buf = reinterpret_cast(guid); int fd = open("/dev/urandom", O_RDONLY | O_CLOEXEC); if (fd == -1) { @@ -154,7 +154,7 @@ class GUIDGenerator { // Populate the GUID using a stream of random bytes obtained from rand(). static void CreateGUIDFromRand(GUID *guid) { - char *buf = reinterpret_cast(guid); + char *buf = reinterpret_cast(guid); InitOnce(); diff --git a/src/common/linux/http_upload.cc b/src/common/linux/http_upload.cc index 702526af..ace12b84 100644 --- a/src/common/linux/http_upload.cc +++ b/src/common/linux/http_upload.cc @@ -36,14 +36,14 @@ namespace { // Callback to get the response data from server. -static size_t WriteCallback(void *ptr, size_t size, - size_t nmemb, void *userp) { +static size_t WriteCallback(void* ptr, size_t size, + size_t nmemb, void* userp) { if (!userp) return 0; - string *response = reinterpret_cast(userp); + string* response = reinterpret_cast(userp); size_t real_size = size * nmemb; - response->append(reinterpret_cast(ptr), real_size); + response->append(reinterpret_cast(ptr), real_size); return real_size; } @@ -54,15 +54,15 @@ namespace google_breakpad { static const char kUserAgent[] = "Breakpad/1.0 (Linux)"; // static -bool HTTPUpload::SendRequest(const string &url, - const map ¶meters, - const map &files, - const string &proxy, - const string &proxy_user_pwd, - const string &ca_certificate_file, - string *response_body, - long *response_code, - string *error_description) { +bool HTTPUpload::SendRequest(const string& url, + const map& parameters, + const map& files, + const string& proxy, + const string& proxy_user_pwd, + const string& ca_certificate_file, + string* response_body, + long* response_code, + string* error_description) { if (response_code != NULL) *response_code = 0; @@ -101,7 +101,7 @@ bool HTTPUpload::SendRequest(const string &url, CURL* (*curl_easy_init)(void); *(void**) (&curl_easy_init) = dlsym(curl_lib, "curl_easy_init"); - CURL *curl = (*curl_easy_init)(); + CURL* curl = (*curl_easy_init)(); if (error_description != NULL) *error_description = "No Error"; @@ -111,7 +111,7 @@ bool HTTPUpload::SendRequest(const string &url, } CURLcode err_code = CURLE_OK; - CURLcode (*curl_easy_setopt)(CURL *, CURLoption, ...); + CURLcode (*curl_easy_setopt)(CURL*, CURLoption, ...); *(void**) (&curl_easy_setopt) = dlsym(curl_lib, "curl_easy_setopt"); (*curl_easy_setopt)(curl, CURLOPT_URL, url.c_str()); (*curl_easy_setopt)(curl, CURLOPT_USERAGENT, kUserAgent); @@ -128,10 +128,10 @@ bool HTTPUpload::SendRequest(const string &url, if (!ca_certificate_file.empty()) (*curl_easy_setopt)(curl, CURLOPT_CAINFO, ca_certificate_file.c_str()); - struct curl_httppost *formpost = NULL; - struct curl_httppost *lastptr = NULL; + struct curl_httppost* formpost = NULL; + struct curl_httppost* lastptr = NULL; // Add form data. - CURLFORMcode (*curl_formadd)(struct curl_httppost **, struct curl_httppost **, ...); + CURLFORMcode (*curl_formadd)(struct curl_httppost**, struct curl_httppost**, ...); *(void**) (&curl_formadd) = dlsym(curl_lib, "curl_formadd"); map::const_iterator iter = parameters.begin(); for (; iter != parameters.end(); ++iter) @@ -151,9 +151,9 @@ bool HTTPUpload::SendRequest(const string &url, (*curl_easy_setopt)(curl, CURLOPT_HTTPPOST, formpost); // Disable 100-continue header. - struct curl_slist *headerlist = NULL; + struct curl_slist* headerlist = NULL; char buf[] = "Expect:"; - struct curl_slist* (*curl_slist_append)(struct curl_slist *, const char *); + struct curl_slist* (*curl_slist_append)(struct curl_slist*, const char*); *(void**) (&curl_slist_append) = dlsym(curl_lib, "curl_slist_append"); headerlist = (*curl_slist_append)(headerlist, buf); (*curl_easy_setopt)(curl, CURLOPT_HTTPHEADER, headerlist); @@ -161,17 +161,17 @@ bool HTTPUpload::SendRequest(const string &url, if (response_body != NULL) { (*curl_easy_setopt)(curl, CURLOPT_WRITEFUNCTION, WriteCallback); (*curl_easy_setopt)(curl, CURLOPT_WRITEDATA, - reinterpret_cast(response_body)); + reinterpret_cast(response_body)); } // Fail if 400+ is returned from the web server. (*curl_easy_setopt)(curl, CURLOPT_FAILONERROR, 1); - CURLcode (*curl_easy_perform)(CURL *); + CURLcode (*curl_easy_perform)(CURL*); *(void**) (&curl_easy_perform) = dlsym(curl_lib, "curl_easy_perform"); err_code = (*curl_easy_perform)(curl); if (response_code != NULL) { - CURLcode (*curl_easy_getinfo)(CURL *, CURLINFO, ...); + CURLcode (*curl_easy_getinfo)(CURL*, CURLINFO, ...); *(void**) (&curl_easy_getinfo) = dlsym(curl_lib, "curl_easy_getinfo"); (*curl_easy_getinfo)(curl, CURLINFO_RESPONSE_CODE, response_code); } @@ -186,16 +186,16 @@ bool HTTPUpload::SendRequest(const string &url, if (error_description != NULL) *error_description = (*curl_easy_strerror)(err_code); - void (*curl_easy_cleanup)(CURL *); + void (*curl_easy_cleanup)(CURL*); *(void**) (&curl_easy_cleanup) = dlsym(curl_lib, "curl_easy_cleanup"); (*curl_easy_cleanup)(curl); if (formpost != NULL) { - void (*curl_formfree)(struct curl_httppost *); + void (*curl_formfree)(struct curl_httppost*); *(void**) (&curl_formfree) = dlsym(curl_lib, "curl_formfree"); (*curl_formfree)(formpost); } if (headerlist != NULL) { - void (*curl_slist_free_all)(struct curl_slist *); + void (*curl_slist_free_all)(struct curl_slist*); *(void**) (&curl_slist_free_all) = dlsym(curl_lib, "curl_slist_free_all"); (*curl_slist_free_all)(headerlist); } @@ -211,10 +211,10 @@ bool HTTPUpload::CheckCurlLib(void* curl_lib) { } // static -bool HTTPUpload::CheckParameters(const map ¶meters) { +bool HTTPUpload::CheckParameters(const map& parameters) { for (map::const_iterator pos = parameters.begin(); pos != parameters.end(); ++pos) { - const string &str = pos->first; + const string& str = pos->first; if (str.size() == 0) return false; // disallow empty parameter names for (unsigned int i = 0; i < str.size(); ++i) { diff --git a/src/common/linux/http_upload.h b/src/common/linux/http_upload.h index bc1d5d57..13f3d56c 100644 --- a/src/common/linux/http_upload.h +++ b/src/common/linux/http_upload.h @@ -58,21 +58,21 @@ class HTTPUpload { // received (or 0 if the request failed before getting an HTTP response). // If the send fails, a description of the error will be // returned in error_description. - static bool SendRequest(const string &url, - const map ¶meters, - const map &files, - const string &proxy, - const string &proxy_user_pwd, - const string &ca_certificate_file, - string *response_body, - long *response_code, - string *error_description); + static bool SendRequest(const string& url, + const map& parameters, + const map& files, + const string& proxy, + const string& proxy_user_pwd, + const string& ca_certificate_file, + string* response_body, + long* response_code, + string* error_description); private: // Checks that the given list of parameters has only printable // ASCII characters in the parameter name, and does not contain // any quote (") characters. Returns true if so. - static bool CheckParameters(const map ¶meters); + static bool CheckParameters(const map& parameters); // Checks the curl_lib parameter points to a valid curl lib. static bool CheckCurlLib(void* curl_lib); @@ -80,8 +80,8 @@ class HTTPUpload { // No instances of this class should be created. // Disallow all constructors, destructors, and operator=. HTTPUpload(); - explicit HTTPUpload(const HTTPUpload &); - void operator=(const HTTPUpload &); + explicit HTTPUpload(const HTTPUpload&); + void operator=(const HTTPUpload&); ~HTTPUpload(); }; diff --git a/src/common/linux/libcurl_wrapper.cc b/src/common/linux/libcurl_wrapper.cc index e96c2038..fdb200f8 100644 --- a/src/common/linux/libcurl_wrapper.cc +++ b/src/common/linux/libcurl_wrapper.cc @@ -88,14 +88,14 @@ bool LibcurlWrapper::AddFile(const string& upload_file_path, } // Callback to get the response data from server. -static size_t WriteCallback(void *ptr, size_t size, - size_t nmemb, void *userp) { +static size_t WriteCallback(void* ptr, size_t size, + size_t nmemb, void* userp) { if (!userp) return 0; - string *response = reinterpret_cast(userp); + string* response = reinterpret_cast(userp); size_t real_size = size * nmemb; - response->append(reinterpret_cast(ptr), real_size); + response->append(reinterpret_cast(ptr), real_size); return real_size; } @@ -250,7 +250,7 @@ bool LibcurlWrapper::SetFunctionPointers() { SET_AND_CHECK_FUNCTION_POINTER(easy_getinfo_, "curl_easy_getinfo", - CURLcode(*)(CURL *, CURLINFO info, ...)); + CURLcode(*)(CURL*, CURLINFO info, ...)); SET_AND_CHECK_FUNCTION_POINTER(easy_reset_, "curl_easy_reset", diff --git a/src/common/linux/libcurl_wrapper.h b/src/common/linux/libcurl_wrapper.h index 77aa6cbb..823f83c7 100644 --- a/src/common/linux/libcurl_wrapper.h +++ b/src/common/linux/libcurl_wrapper.h @@ -91,27 +91,27 @@ class LibcurlWrapper { // dealing // with CURL. - CURL *curl_; // Pointer for handle for CURL calls. + CURL* curl_; // Pointer for handle for CURL calls. CURL* (*easy_init_)(void); // Stateful pointers for calling into curl_formadd() - struct curl_httppost *formpost_; - struct curl_httppost *lastptr_; - struct curl_slist *headerlist_; + struct curl_httppost* formpost_; + struct curl_httppost* lastptr_; + struct curl_slist* headerlist_; // Function pointers into CURL library - CURLcode (*easy_setopt_)(CURL *, CURLoption, ...); - CURLFORMcode (*formadd_)(struct curl_httppost **, - struct curl_httppost **, ...); - struct curl_slist* (*slist_append_)(struct curl_slist *, const char *); - void (*slist_free_all_)(struct curl_slist *); - CURLcode (*easy_perform_)(CURL *); + CURLcode (*easy_setopt_)(CURL*, CURLoption, ...); + CURLFORMcode (*formadd_)(struct curl_httppost**, + struct curl_httppost**, ...); + struct curl_slist* (*slist_append_)(struct curl_slist*, const char*); + void (*slist_free_all_)(struct curl_slist*); + CURLcode (*easy_perform_)(CURL*); const char* (*easy_strerror_)(CURLcode); - void (*easy_cleanup_)(CURL *); - CURLcode (*easy_getinfo_)(CURL *, CURLINFO info, ...); + void (*easy_cleanup_)(CURL*); + CURLcode (*easy_getinfo_)(CURL*, CURLINFO info, ...); void (*easy_reset_)(CURL*); - void (*formfree_)(struct curl_httppost *); + void (*formfree_)(struct curl_httppost*); }; } diff --git a/src/common/linux/linux_libc_support.cc b/src/common/linux/linux_libc_support.cc index 08b0325e..dd292962 100644 --- a/src/common/linux/linux_libc_support.cc +++ b/src/common/linux/linux_libc_support.cc @@ -190,7 +190,7 @@ const char* my_read_decimal_ptr(uintptr_t* result, const char* s) { } void my_memset(void* ip, char c, size_t len) { - char* p = (char *) ip; + char* p = (char*) ip; while (len--) *p++ = c; } diff --git a/src/common/linux/symbol_upload.cc b/src/common/linux/symbol_upload.cc index 87741a0a..1d5ff719 100644 --- a/src/common/linux/symbol_upload.cc +++ b/src/common/linux/symbol_upload.cc @@ -46,8 +46,8 @@ namespace google_breakpad { namespace sym_upload { -void TokenizeByChar(const string &source_string, int c, - std::vector *results) { +void TokenizeByChar(const string& source_string, int c, + std::vector* results) { assert(results); string::size_type cur_pos = 0, next_pos = 0; while ((next_pos = source_string.find(c, cur_pos)) != string::npos) { @@ -62,8 +62,8 @@ void TokenizeByChar(const string &source_string, int c, //============================================================================= // Parse out the module line which have 5 parts. // MODULE -bool ModuleDataForSymbolFile(const string &file, - std::vector *module_parts) { +bool ModuleDataForSymbolFile(const string& file, + std::vector* module_parts) { assert(module_parts); const size_t kModulePartNumber = 5; FILE* fp = fopen(file.c_str(), "r"); @@ -90,7 +90,7 @@ bool ModuleDataForSymbolFile(const string &file, } //============================================================================= -string CompactIdentifier(const string &uuid) { +string CompactIdentifier(const string& uuid) { std::vector components; TokenizeByChar(uuid, '-', &components); string result; diff --git a/src/common/linux/synth_elf.cc b/src/common/linux/synth_elf.cc index 98e81dab..2ba25e61 100644 --- a/src/common/linux/synth_elf.cc +++ b/src/common/linux/synth_elf.cc @@ -118,7 +118,7 @@ int ELF::AddSection(const string& name, const Section& section, return index; } -void ELF::AppendSection(ElfSection §ion) { +void ELF::AppendSection(ElfSection& section) { // NULL and NOBITS sections have no content, so they // don't need to be written to the file. if (section.type_ == SHT_NULL) { @@ -242,7 +242,7 @@ void SymbolTable::AddSymbol(const string& name, uint64_t value, D64(size); } -void Notes::AddNote(int type, const string &name, const uint8_t* desc_bytes, +void Notes::AddNote(int type, const string& name, const uint8_t* desc_bytes, size_t desc_size) { // Elf32_Nhdr and Elf64_Nhdr are exactly the same. Elf32_Nhdr note_header; diff --git a/src/common/linux/synth_elf.h b/src/common/linux/synth_elf.h index 1d2a20ca..90fa28c0 100644 --- a/src/common/linux/synth_elf.h +++ b/src/common/linux/synth_elf.h @@ -154,7 +154,7 @@ class ELF : public Section { vector sections_; - void AppendSection(ElfSection §ion); + void AppendSection(ElfSection& section); }; // A class to build .symtab or .dynsym sections. @@ -187,7 +187,7 @@ public: } // Add a note. - void AddNote(int type, const string &name, const uint8_t* desc_bytes, + void AddNote(int type, const string& name, const uint8_t* desc_bytes, size_t desc_size); }; diff --git a/src/common/linux/synth_elf_unittest.cc b/src/common/linux/synth_elf_unittest.cc index cd74c286..fb3601e6 100644 --- a/src/common/linux/synth_elf_unittest.cc +++ b/src/common/linux/synth_elf_unittest.cc @@ -381,9 +381,9 @@ TEST_F(ElfNotesTest, Empty) { TEST_F(ElfNotesTest, Notes) { Notes notes(kLittleEndian); - notes.AddNote(1, "Linux", reinterpret_cast("\x42\x02\0\0"), + notes.AddNote(1, "Linux", reinterpret_cast("\x42\x02\0\0"), 4); - notes.AddNote(2, "a", reinterpret_cast("foobar"), + notes.AddNote(2, "a", reinterpret_cast("foobar"), sizeof("foobar") - 1); const uint8_t kExpectedNotesContents[] = { diff --git a/src/common/linux/tests/crash_generator.cc b/src/common/linux/tests/crash_generator.cc index 6896a688..a70df28a 100644 --- a/src/common/linux/tests/crash_generator.cc +++ b/src/common/linux/tests/crash_generator.cc @@ -79,7 +79,7 @@ int tkill(pid_t tid, int sig) { // Core file size limit set to 1 MB, which is big enough for test purposes. const rlim_t kCoreSizeLimit = 1024 * 1024; -void *thread_function(void *data) { +void* thread_function(void* data) { ThreadData* thread_data = reinterpret_cast(data); volatile pid_t thread_id = gettid(); *(thread_data->thread_id_ptr) = thread_id; 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(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(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(GetDataPacket()); + u_int8_t* p = reinterpret_cast(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(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 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(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) { @@ -369,7 +369,7 @@ bool DumpSymbols::CreateEmptyModule(scoped_ptr& 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) { // 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) { 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& ranges_section = + const std::pair& 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 §ion, +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, §ion_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; 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 §ion, + 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(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 §ion, - 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 §ion) { + 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 §ion, - 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 §ion) = 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 §ion, - 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 §ion)); + 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(contents.data()); + fat_bytes = reinterpret_cast(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 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 §ion_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(file_contents.data()); + file_bytes = reinterpret_cast(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 MatchSection( +static inline Matcher MatchSection( Matcher bits_64, - Matcher section_name, - Matcher segment_name, + Matcher section_name, + Matcher segment_name, Matcher address, Matcher alignment, Matcher flags, - Matcher contents) { + Matcher 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 MatchSection( Field(&Section::contents, contents))); } -static inline Matcher MatchSection( +static inline Matcher MatchSection( Matcher bits_64, - Matcher section_name, - Matcher segment_name, + Matcher section_name, + Matcher segment_name, Matcher 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(contents1.start), + string(reinterpret_cast(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(contents2.start), + string(reinterpret_cast(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(offset); result = false; } - memcpy(buffer, static_cast(memory_) + offset, size); + memcpy(buffer, static_cast(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), diff --git a/src/common/md5.cc b/src/common/md5.cc index 4f1ac8ca..b6e710da 100644 --- a/src/common/md5.cc +++ b/src/common/md5.cc @@ -31,7 +31,7 @@ static void byteReverse(unsigned char *buf, unsigned longs) do { t = (u32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | ((unsigned) buf[1] << 8 | buf[0]); - *(u32 *) buf = t; + *(u32*) buf = t; buf += 4; } while (--longs); } @@ -74,7 +74,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, size_t len) /* Handle any leading odd-sized chunks */ if (t) { - unsigned char *p = (unsigned char *) ctx->in + t; + unsigned char *p = (unsigned char*) ctx->in + t; t = 64 - t; if (len < t) { @@ -83,7 +83,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, size_t len) } memcpy(p, buf, t); byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (u32 *) ctx->in); + MD5Transform(ctx->buf, (u32*) ctx->in); buf += t; len -= t; } @@ -92,7 +92,7 @@ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, size_t len) while (len >= 64) { memcpy(ctx->in, buf, 64); byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (u32 *) ctx->in); + MD5Transform(ctx->buf, (u32*) ctx->in); buf += 64; len -= 64; } @@ -127,7 +127,7 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); byteReverse(ctx->in, 16); - MD5Transform(ctx->buf, (u32 *) ctx->in); + MD5Transform(ctx->buf, (u32*) ctx->in); /* Now fill the next block with 56 bytes */ memset(ctx->in, 0, 56); @@ -141,8 +141,8 @@ void MD5Final(unsigned char digest[16], struct MD5Context *ctx) memcpy(&ctx->in[14], &ctx->bits[0], sizeof(u32)); memcpy(&ctx->in[15], &ctx->bits[1], sizeof(u32)); - MD5Transform(ctx->buf, (u32 *) ctx->in); - byteReverse((unsigned char *) ctx->buf, 4); + MD5Transform(ctx->buf, (u32*) ctx->in); + byteReverse((unsigned char*) ctx->buf, 4); memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ } diff --git a/src/common/memory_allocator.h b/src/common/memory_allocator.h index a3159ea4..69055a15 100644 --- a/src/common/memory_allocator.h +++ b/src/common/memory_allocator.h @@ -71,12 +71,12 @@ class PageAllocator { FreeAll(); } - void *Alloc(size_t bytes) { + void* Alloc(size_t bytes) { if (!bytes) return NULL; if (current_page_ && page_size_ - page_offset_ >= bytes) { - uint8_t *const ret = current_page_ + page_offset_; + uint8_t* const ret = current_page_ + page_offset_; page_offset_ += bytes; if (page_offset_ == page_size_) { page_offset_ = 0; @@ -88,7 +88,7 @@ class PageAllocator { const size_t pages = (bytes + sizeof(PageHeader) + page_size_ - 1) / page_size_; - uint8_t *const ret = GetNPages(pages); + uint8_t* const ret = GetNPages(pages); if (!ret) return NULL; @@ -115,8 +115,8 @@ class PageAllocator { unsigned long pages_allocated() { return pages_allocated_; } private: - uint8_t *GetNPages(size_t num_pages) { - void *a = sys_mmap(NULL, page_size_ * num_pages, PROT_READ | PROT_WRITE, + uint8_t* GetNPages(size_t num_pages) { + void* a = sys_mmap(NULL, page_size_ * num_pages, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (a == MAP_FAILED) return NULL; @@ -127,7 +127,7 @@ class PageAllocator { __msan_unpoison(a, page_size_ * num_pages); #endif - struct PageHeader *header = reinterpret_cast(a); + struct PageHeader* header = reinterpret_cast(a); header->next = last_; header->num_pages = num_pages; last_ = header; @@ -138,22 +138,22 @@ class PageAllocator { } void FreeAll() { - PageHeader *next; + PageHeader* next; - for (PageHeader *cur = last_; cur; cur = next) { + for (PageHeader* cur = last_; cur; cur = next) { next = cur->next; sys_munmap(cur, cur->num_pages * page_size_); } } struct PageHeader { - PageHeader *next; // pointer to the start of the next set of pages. + PageHeader* next; // pointer to the start of the next set of pages. size_t num_pages; // the number of pages in this set. }; const size_t page_size_; - PageHeader *last_; - uint8_t *current_page_; + PageHeader* last_; + uint8_t* current_page_; size_t page_offset_; unsigned long pages_allocated_; }; diff --git a/src/common/memory_allocator_unittest.cc b/src/common/memory_allocator_unittest.cc index 43c86314..5803b90d 100644 --- a/src/common/memory_allocator_unittest.cc +++ b/src/common/memory_allocator_unittest.cc @@ -46,7 +46,7 @@ TEST(PageAllocatorTest, SmallObjects) { EXPECT_EQ(0U, allocator.pages_allocated()); for (unsigned i = 1; i < 1024; ++i) { - uint8_t *p = reinterpret_cast(allocator.Alloc(i)); + uint8_t* p = reinterpret_cast(allocator.Alloc(i)); ASSERT_FALSE(p == NULL); memset(p, 0, i); } @@ -56,11 +56,11 @@ TEST(PageAllocatorTest, LargeObject) { PageAllocator allocator; EXPECT_EQ(0U, allocator.pages_allocated()); - uint8_t *p = reinterpret_cast(allocator.Alloc(10000)); + uint8_t* p = reinterpret_cast(allocator.Alloc(10000)); ASSERT_FALSE(p == NULL); EXPECT_EQ(3U, allocator.pages_allocated()); for (unsigned i = 1; i < 10; ++i) { - uint8_t *p = reinterpret_cast(allocator.Alloc(i)); + uint8_t* p = reinterpret_cast(allocator.Alloc(i)); ASSERT_FALSE(p == NULL); memset(p, 0, i); } diff --git a/src/common/module.cc b/src/common/module.cc index aff22127..f70ae203 100644 --- a/src/common/module.cc +++ b/src/common/module.cc @@ -47,9 +47,9 @@ using std::dec; using std::hex; -Module::Module(const string &name, const string &os, - const string &architecture, const string &id, - const string &code_id /* = "" */) : +Module::Module(const string& name, const string& os, + const string& architecture, const string& id, + const string& code_id /* = "" */) : name_(name), os_(os), architecture_(architecture), @@ -64,7 +64,7 @@ Module::~Module() { it != functions_.end(); ++it) { delete *it; } - for (vector::iterator it = stack_frame_entries_.begin(); + for (vector::iterator it = stack_frame_entries_.begin(); it != stack_frame_entries_.end(); ++it) { delete *it; } @@ -80,7 +80,7 @@ void Module::SetAddressRanges(const vector& ranges) { address_ranges_ = ranges; } -void Module::AddFunction(Function *function) { +void Module::AddFunction(Function* function) { // FUNC lines must not hold an empty name, so catch the problem early if // callers try to add one. assert(!function->name.empty()); @@ -124,13 +124,13 @@ void Module::AddFunction(Function *function) { } } -void Module::AddFunctions(vector::iterator begin, - vector::iterator end) { - for (vector::iterator it = begin; it != end; ++it) +void Module::AddFunctions(vector::iterator begin, + vector::iterator end) { + for (vector::iterator it = begin; it != end; ++it) AddFunction(*it); } -void Module::AddStackFrameEntry(StackFrameEntry *stack_frame_entry) { +void Module::AddStackFrameEntry(StackFrameEntry* stack_frame_entry) { if (!AddressIsInModule(stack_frame_entry->address)) { return; } @@ -138,7 +138,7 @@ void Module::AddStackFrameEntry(StackFrameEntry *stack_frame_entry) { stack_frame_entries_.push_back(stack_frame_entry); } -void Module::AddExtern(Extern *ext) { +void Module::AddExtern(Extern* ext) { if (!AddressIsInModule(ext->address)) { return; } @@ -151,17 +151,17 @@ void Module::AddExtern(Extern *ext) { } } -void Module::GetFunctions(vector *vec, - vector::iterator i) { +void Module::GetFunctions(vector* vec, + vector::iterator i) { vec->insert(i, functions_.begin(), functions_.end()); } -void Module::GetExterns(vector *vec, - vector::iterator i) { +void Module::GetExterns(vector* vec, + vector::iterator i) { vec->insert(i, externs_.begin(), externs_.end()); } -Module::File *Module::FindFile(const string &name) { +Module::File* Module::FindFile(const string& name) { // A tricky bit here. The key of each map entry needs to be a // pointer to the entry's File's name string. This means that we // can't do the initial lookup with any operation that would create @@ -175,7 +175,7 @@ Module::File *Module::FindFile(const string &name) { FileByNameMap::iterator destiny = files_.lower_bound(&name); if (destiny == files_.end() || *destiny->first != name) { // Repeated string comparison, boo hoo. - File *file = new File(name); + File* file = new File(name); file->source_id = -1; destiny = files_.insert(destiny, FileByNameMap::value_type(&file->name, file)); @@ -183,23 +183,23 @@ Module::File *Module::FindFile(const string &name) { return destiny->second; } -Module::File *Module::FindFile(const char *name) { +Module::File* Module::FindFile(const char* name) { string name_string = name; return FindFile(name_string); } -Module::File *Module::FindExistingFile(const string &name) { +Module::File* Module::FindExistingFile(const string& name) { FileByNameMap::iterator it = files_.find(&name); return (it == files_.end()) ? NULL : it->second; } -void Module::GetFiles(vector *vec) { +void Module::GetFiles(vector* vec) { vec->clear(); for (FileByNameMap::iterator it = files_.begin(); it != files_.end(); ++it) vec->push_back(it->second); } -void Module::GetStackFrameEntries(vector *vec) const { +void Module::GetStackFrameEntries(vector* vec) const { *vec = stack_frame_entries_; } @@ -214,7 +214,7 @@ void Module::AssignSourceIds() { // info, by setting each one's source id to zero. for (FunctionSet::const_iterator func_it = functions_.begin(); func_it != functions_.end(); ++func_it) { - Function *func = *func_it; + Function* func = *func_it; for (vector::iterator line_it = func->lines.begin(); line_it != func->lines.end(); ++line_it) line_it->file->source_id = 0; @@ -238,7 +238,7 @@ bool Module::ReportError() { return false; } -bool Module::WriteRuleMap(const RuleMap &rule_map, std::ostream &stream) { +bool Module::WriteRuleMap(const RuleMap& rule_map, std::ostream& stream) { for (RuleMap::const_iterator it = rule_map.begin(); it != rule_map.end(); ++it) { if (it != rule_map.begin()) @@ -261,7 +261,7 @@ bool Module::AddressIsInModule(Address address) const { return false; } -bool Module::Write(std::ostream &stream, SymbolData symbol_data) { +bool Module::Write(std::ostream& stream, SymbolData symbol_data) { stream << "MODULE " << os_ << " " << architecture_ << " " << id_ << " " << name_ << "\n"; if (!stream.good()) @@ -277,7 +277,7 @@ bool Module::Write(std::ostream &stream, SymbolData symbol_data) { // Write out files. for (FileByNameMap::iterator file_it = files_.begin(); file_it != files_.end(); ++file_it) { - File *file = file_it->second; + File* file = file_it->second; if (file->source_id >= 0) { stream << "FILE " << file->source_id << " " << file->name << "\n"; if (!stream.good()) @@ -288,7 +288,7 @@ bool Module::Write(std::ostream &stream, SymbolData symbol_data) { // Write out functions and their lines. for (FunctionSet::const_iterator func_it = functions_.begin(); func_it != functions_.end(); ++func_it) { - Function *func = *func_it; + Function* func = *func_it; vector::iterator line_it = func->lines.begin(); for (auto range_it = func->ranges.cbegin(); range_it != func->ranges.cend(); ++range_it) { @@ -322,7 +322,7 @@ bool Module::Write(std::ostream &stream, SymbolData symbol_data) { // Write out 'PUBLIC' records. for (ExternSet::const_iterator extern_it = externs_.begin(); extern_it != externs_.end(); ++extern_it) { - Extern *ext = *extern_it; + Extern* ext = *extern_it; stream << "PUBLIC " << hex << (ext->address - load_address_) << " 0 " << ext->name << dec << "\n"; @@ -331,10 +331,10 @@ bool Module::Write(std::ostream &stream, SymbolData symbol_data) { if (symbol_data != NO_CFI) { // Write out 'STACK CFI INIT' and 'STACK CFI' records. - vector::const_iterator frame_it; + vector::const_iterator frame_it; for (frame_it = stack_frame_entries_.begin(); frame_it != stack_frame_entries_.end(); ++frame_it) { - StackFrameEntry *entry = *frame_it; + StackFrameEntry* entry = *frame_it; stream << "STACK CFI INIT " << hex << (entry->address - load_address_) << " " << entry->size << " " << dec; diff --git a/src/common/module.h b/src/common/module.h index 7309cedd..60bf709b 100644 --- a/src/common/module.h +++ b/src/common/module.h @@ -74,7 +74,7 @@ class Module { // A source file. struct File { - explicit File(const string &name_input) : name(name_input), source_id(0) {} + explicit File(const string& name_input) : name(name_input), source_id(0) {} // The name of the source file. const string name; @@ -96,12 +96,12 @@ class Module { // A function. struct Function { - Function(const string &name_input, const Address &address_input) : + Function(const string& name_input, const Address& address_input) : name(name_input), address(address_input), parameter_size(0) {} // For sorting by address. (Not style-guide compliant, but it's // stupid not to put this in the struct.) - static bool CompareByAddress(const Function *x, const Function *y) { + static bool CompareByAddress(const Function* x, const Function* y) { return x->address < y->address; } @@ -124,18 +124,18 @@ class Module { struct Line { // For sorting by address. (Not style-guide compliant, but it's // stupid not to put this in the struct.) - static bool CompareByAddress(const Module::Line &x, const Module::Line &y) { + static bool CompareByAddress(const Module::Line& x, const Module::Line& y) { return x.address < y.address; } Address address, size; // The address and size of the line's code. - File *file; // The source file. + File* file; // The source file. int number; // The source line number. }; // An exported symbol. struct Extern { - explicit Extern(const Address &address_input) : address(address_input) {} + explicit Extern(const Address& address_input) : address(address_input) {} const Address address; string name; }; @@ -170,8 +170,7 @@ class Module { }; struct FunctionCompare { - bool operator() (const Function *lhs, - const Function *rhs) const { + bool operator() (const Function* lhs, const Function* rhs) const { if (lhs->address == rhs->address) return lhs->name < rhs->name; return lhs->address < rhs->address; @@ -179,16 +178,15 @@ class Module { }; struct ExternCompare { - bool operator() (const Extern *lhs, - const Extern *rhs) const { + bool operator() (const Extern* lhs, const Extern* rhs) const { return lhs->address < rhs->address; } }; // Create a new module with the given name, operating system, // architecture, and ID string. - Module(const string &name, const string &os, const string &architecture, - const string &id, const string &code_id = ""); + Module(const string& name, const string& os, const string& architecture, + const string& id, const string& code_id = ""); ~Module(); // Set the module's load address to LOAD_ADDRESS; addresses given @@ -216,62 +214,62 @@ class Module { // Add FUNCTION to the module. FUNCTION's name must not be empty. // This module owns all Function objects added with this function: // destroying the module destroys them as well. - void AddFunction(Function *function); + void AddFunction(Function* function); // Add all the functions in [BEGIN,END) to the module. // This module owns all Function objects added with this function: // destroying the module destroys them as well. - void AddFunctions(vector::iterator begin, - vector::iterator end); + void AddFunctions(vector::iterator begin, + vector::iterator end); // Add STACK_FRAME_ENTRY to the module. // This module owns all StackFrameEntry objects added with this // function: destroying the module destroys them as well. - void AddStackFrameEntry(StackFrameEntry *stack_frame_entry); + void AddStackFrameEntry(StackFrameEntry* stack_frame_entry); // Add PUBLIC to the module. // This module owns all Extern objects added with this function: // destroying the module destroys them as well. - void AddExtern(Extern *ext); + void AddExtern(Extern* ext); // If this module has a file named NAME, return a pointer to it. If // it has none, then create one and return a pointer to the new // file. This module owns all File objects created using these // functions; destroying the module destroys them as well. - File *FindFile(const string &name); - File *FindFile(const char *name); + File* FindFile(const string& name); + File* FindFile(const char* name); // If this module has a file named NAME, return a pointer to it. // Otherwise, return NULL. - File *FindExistingFile(const string &name); + File* FindExistingFile(const string& name); // Insert pointers to the functions added to this module at I in // VEC. The pointed-to Functions are still owned by this module. // (Since this is effectively a copy of the function list, this is // mostly useful for testing; other uses should probably get a more // appropriate interface.) - void GetFunctions(vector *vec, vector::iterator i); + void GetFunctions(vector* vec, vector::iterator i); // Insert pointers to the externs added to this module at I in // VEC. The pointed-to Externs are still owned by this module. // (Since this is effectively a copy of the extern list, this is // mostly useful for testing; other uses should probably get a more // appropriate interface.) - void GetExterns(vector *vec, vector::iterator i); + void GetExterns(vector* vec, vector::iterator i); // Clear VEC and fill it with pointers to the Files added to this // module, sorted by name. The pointed-to Files are still owned by // this module. (Since this is effectively a copy of the file list, // this is mostly useful for testing; other uses should probably get // a more appropriate interface.) - void GetFiles(vector *vec); + void GetFiles(vector* vec); // Clear VEC and fill it with pointers to the StackFrameEntry // objects that have been added to this module. (Since this is // effectively a copy of the stack frame entry list, this is mostly // useful for testing; other uses should probably get // a more appropriate interface.) - void GetStackFrameEntries(vector *vec) const; + void GetStackFrameEntries(vector* vec) const; // Find those files in this module that are actually referred to by // functions' line number data, and assign them source id numbers. @@ -292,7 +290,7 @@ class Module { // - all CFI records. // Addresses in the output are all relative to the load address // established by SetLoadAddress. - bool Write(std::ostream &stream, SymbolData symbol_data); + bool Write(std::ostream& stream, SymbolData symbol_data); string name() const { return name_; } string os() const { return os_; } @@ -308,7 +306,7 @@ class Module { // Write RULE_MAP to STREAM, in the form appropriate for 'STACK CFI' // records, without a final newline. Return true if all goes well; // if an error occurs, return false, and leave errno set. - static bool WriteRuleMap(const RuleMap &rule_map, std::ostream &stream); + static bool WriteRuleMap(const RuleMap& rule_map, std::ostream& stream); // Returns true of the specified address resides with an specified address // range, or if no ranges have been specified. @@ -329,18 +327,18 @@ class Module { // Relation for maps whose keys are strings shared with some other // structure. struct CompareStringPtrs { - bool operator()(const string *x, const string *y) const { return *x < *y; } + bool operator()(const string* x, const string* y) const { return *x < *y; } }; // A map from filenames to File structures. The map's keys are // pointers to the Files' names. - typedef map FileByNameMap; + typedef map FileByNameMap; // A set containing Function structures, sorted by address. - typedef set FunctionSet; + typedef set FunctionSet; // A set containing Extern structures, sorted by address. - typedef set ExternSet; + typedef set ExternSet; // The module owns all the files and functions that have been added // to it; destroying the module frees the Files and Functions these @@ -350,7 +348,7 @@ class Module { // The module owns all the call frame info entries that have been // added to it. - vector stack_frame_entries_; + vector stack_frame_entries_; // The module owns all the externs that have been added to it; // destroying the module frees the Externs these point to. diff --git a/src/common/module_unittest.cc b/src/common/module_unittest.cc index 37fee5dd..cede09c3 100644 --- a/src/common/module_unittest.cc +++ b/src/common/module_unittest.cc @@ -49,7 +49,7 @@ using std::stringstream; using std::vector; using testing::ContainerEq; -static Module::Function* generate_duplicate_function(const string &name) { +static Module::Function* generate_duplicate_function(const string& name) { const Module::Address DUP_ADDRESS = 0xd35402aac7a7ad5cULL; const Module::Address DUP_SIZE = 0x200b26e605f99071ULL; const Module::Address DUP_PARAMETER_SIZE = 0xf14ac4fed48c4a99ULL; diff --git a/src/common/solaris/dump_symbols.cc b/src/common/solaris/dump_symbols.cc index 168d0b28..9524a18b 100644 --- a/src/common/solaris/dump_symbols.cc +++ b/src/common/solaris/dump_symbols.cc @@ -97,7 +97,7 @@ struct LineInfo { // Information of a function. struct FuncInfo { // Name of the function. - const char *name; + const char* name; // Offset from the base of the loading address. GElf_Off rva_to_base; // Virtual address of the function. @@ -115,7 +115,7 @@ struct FuncInfo { // Information of a source file. struct SourceFileInfo { // Name of the source file. - const char *name; + const char* name; // Starting address of the source file. GElf_Addr addr; // Id of the source file. @@ -125,12 +125,12 @@ struct SourceFileInfo { }; struct CompareString { - bool operator()(const char *s1, const char *s2) const { + bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; } }; -typedef std::map SymbolMap; +typedef std::map SymbolMap; // Information of a symbol table. // This is the root of all types of symbol. @@ -141,16 +141,16 @@ struct SymbolInfo { }; // Stab section name. -const char *kStabName = ".stab"; +const char* kStabName = ".stab"; // Stab str section name. -const char *kStabStrName = ".stabstr"; +const char* kStabStrName = ".stabstr"; // Symtab section name. -const char *kSymtabName = ".symtab"; +const char* kSymtabName = ".symtab"; // Strtab section name. -const char *kStrtabName = ".strtab"; +const char* kStrtabName = ".strtab"; // Default buffer lenght for demangle. const int demangleLen = 20000; @@ -160,11 +160,11 @@ uint64_t stringOffset = 0; // Update the offset to the start of the string index of the next // object module for every N_ENDM stabs. -inline void RecalculateOffset(struct slist* cur_list, char *stabstr) { +inline void RecalculateOffset(struct slist* cur_list, char* stabstr) { while ((--cur_list)->n_strx == 0) ; stringOffset += cur_list->n_strx; - char *temp = stabstr + stringOffset; + char* temp = stabstr + stringOffset; while (*temp != '\0') { ++stringOffset; ++temp; @@ -174,10 +174,10 @@ inline void RecalculateOffset(struct slist* cur_list, char *stabstr) { } // Demangle using demangle library on Solaris. -std::string Demangle(const char *mangled) { +std::string Demangle(const char* mangled) { int status = 0; std::string str(mangled); - char *demangled = (char *)malloc(demangleLen); + char* demangled = (char*)malloc(demangleLen); if (!demangled) { fprintf(stderr, "no enough memory.\n"); @@ -197,7 +197,7 @@ out: return str; } -bool WriteFormat(int fd, const char *fmt, ...) { +bool WriteFormat(int fd, const char* fmt, ...) { va_list list; char buffer[4096]; ssize_t expected, written; @@ -209,27 +209,27 @@ bool WriteFormat(int fd, const char *fmt, ...) { return expected == written; } -bool IsValidElf(const GElf_Ehdr *elf_header) { +bool IsValidElf(const GElf_Ehdr* elf_header) { return memcmp(elf_header, ELFMAG, SELFMAG) == 0; } -static bool FindSectionByName(Elf *elf, const char *name, +static bool FindSectionByName(Elf* elf, const char* name, int shstrndx, - GElf_Shdr *shdr) { + GElf_Shdr* shdr) { assert(name != NULL); if (strlen(name) == 0) return false; - Elf_Scn *scn = NULL; + Elf_Scn* scn = NULL; while ((scn = elf_nextscn(elf, scn)) != NULL) { - if (gelf_getshdr(scn, shdr) == (GElf_Shdr *)0) { + if (gelf_getshdr(scn, shdr) == (GElf_Shdr*)0) { fprintf(stderr, "failed to read section header: %s\n", elf_errmsg(0)); return false; } - const char *section_name = elf_strptr(elf, shstrndx, shdr->sh_name); + const char* section_name = elf_strptr(elf, shstrndx, shdr->sh_name); if (!section_name) { fprintf(stderr, "Section name error: %s\n", elf_errmsg(-1)); continue; @@ -245,10 +245,10 @@ static bool FindSectionByName(Elf *elf, const char *name, // The parameter size is used for FPO-optimized code, and // this is all tied up with the debugging data for Windows x86. // Set it to 0 on Solaris. -int LoadStackParamSize(struct slist *list, - struct slist *list_end, - struct FuncInfo *func_info) { - struct slist *cur_list = list; +int LoadStackParamSize(struct slist* list, + struct slist* list_end, + struct FuncInfo* func_info) { + struct slist* cur_list = list; int step = 1; while (cur_list < list_end && cur_list->n_type == N_PSYM) { ++cur_list; @@ -259,10 +259,10 @@ int LoadStackParamSize(struct slist *list, return step; } -int LoadLineInfo(struct slist *list, - struct slist *list_end, - struct FuncInfo *func_info) { - struct slist *cur_list = list; +int LoadLineInfo(struct slist* list, + struct slist* list_end, + struct FuncInfo* func_info) { + struct slist* cur_list = list; do { // Skip non line information. while (cur_list < list_end && cur_list->n_type != N_SLINE) { @@ -288,12 +288,12 @@ int LoadLineInfo(struct slist *list, return cur_list - list; } -int LoadFuncSymbols(struct slist *list, - struct slist *list_end, - char *stabstr, +int LoadFuncSymbols(struct slist* list, + struct slist* list_end, + char* stabstr, GElf_Word base, - struct SourceFileInfo *source_file_info) { - struct slist *cur_list = list; + struct SourceFileInfo* source_file_info) { + struct slist* cur_list = list; assert(cur_list->n_type == N_SO); ++cur_list; @@ -342,17 +342,17 @@ int LoadFuncSymbols(struct slist *list, } // Compute size and rva information based on symbols loaded from stab section. -bool ComputeSizeAndRVA(struct SymbolInfo *symbols) { - std::vector *sorted_files = +bool ComputeSizeAndRVA(struct SymbolInfo* symbols) { + std::vector* sorted_files = &(symbols->source_file_info); - SymbolMap *symbol_entries = &(symbols->symbol_entries); + SymbolMap* symbol_entries = &(symbols->symbol_entries); for (size_t i = 0; i < sorted_files->size(); ++i) { - struct SourceFileInfo &source_file = (*sorted_files)[i]; - std::vector *sorted_functions = &(source_file.func_info); + struct SourceFileInfo& source_file = (*sorted_files)[i]; + std::vector* sorted_functions = &(source_file.func_info); int func_size = sorted_functions->size(); for (size_t j = 0; j < func_size; ++j) { - struct FuncInfo &func_info = (*sorted_functions)[j]; + struct FuncInfo& func_info = (*sorted_functions)[j]; int line_count = func_info.line_info.size(); // Discard the ending part of the name. @@ -373,13 +373,13 @@ bool ComputeSizeAndRVA(struct SymbolInfo *symbols) { // Compute function and line size. for (size_t k = 0; k < line_count; ++k) { - struct LineInfo &line_info = func_info.line_info[k]; + struct LineInfo& line_info = func_info.line_info[k]; line_info.rva_to_base = line_info.rva_to_func + func_info.rva_to_base; if (k == line_count - 1) { line_info.size = func_info.size - line_info.rva_to_func; } else { - struct LineInfo &next_line = func_info.line_info[k + 1]; + struct LineInfo& next_line = func_info.line_info[k + 1]; line_info.size = next_line.rva_to_func - line_info.rva_to_func; } } // for each line. @@ -392,24 +392,23 @@ bool ComputeSizeAndRVA(struct SymbolInfo *symbols) { return true; } -bool LoadAllSymbols(const GElf_Shdr *stab_section, - const GElf_Shdr *stabstr_section, +bool LoadAllSymbols(const GElf_Shdr* stab_section, + const GElf_Shdr* stabstr_section, GElf_Word base, - struct SymbolInfo *symbols) { + struct SymbolInfo* symbols) { if (stab_section == NULL || stabstr_section == NULL) return false; - char *stabstr = - reinterpret_cast(stabstr_section->sh_offset + base); - struct slist *lists = - reinterpret_cast(stab_section->sh_offset + base); + char* stabstr = reinterpret_cast(stabstr_section->sh_offset + base); + struct slist* lists = + reinterpret_cast(stab_section->sh_offset + base); int nstab = stab_section->sh_size / sizeof(struct slist); int source_id = 0; // First pass, load all symbols from the object file. for (int i = 0; i < nstab; ) { int step = 1; - struct slist *cur_list = lists + i; + struct slist* cur_list = lists + i; if (cur_list->n_type == N_SO) { // FUNC
struct SourceFileInfo source_file_info; @@ -431,12 +430,12 @@ bool LoadAllSymbols(const GElf_Shdr *stab_section, return ComputeSizeAndRVA(symbols); } -bool LoadSymbols(Elf *elf, GElf_Ehdr *elf_header, struct SymbolInfo *symbols, - void *obj_base) { +bool LoadSymbols(Elf* elf, GElf_Ehdr* elf_header, struct SymbolInfo* symbols, + void* obj_base) { GElf_Word base = reinterpret_cast(obj_base); - const GElf_Shdr *sections = - reinterpret_cast(elf_header->e_shoff + base); + const GElf_Shdr* sections = + reinterpret_cast(elf_header->e_shoff + base); GElf_Shdr stab_section; if (!FindSectionByName(elf, kStabName, elf_header->e_shstrndx, &stab_section)) { @@ -462,11 +461,11 @@ bool LoadSymbols(Elf *elf, GElf_Ehdr *elf_header, struct SymbolInfo *symbols, return false; } - Elf_Sym *symbol = (Elf_Sym *)((char *)base + symtab_section.sh_offset); + Elf_Sym* symbol = (Elf_Sym*)((char*)base + symtab_section.sh_offset); for (int i = 0; i < symtab_section.sh_size/symtab_section.sh_entsize; ++i) { - struct SymbolEntry *symbol_entry = - (struct SymbolEntry *)malloc(sizeof(struct SymbolEntry)); - const char *name = reinterpret_cast( + struct SymbolEntry* symbol_entry = + (struct SymbolEntry*)malloc(sizeof(struct SymbolEntry)); + const char* name = reinterpret_cast( strtab_section.sh_offset + (GElf_Word)base + symbol->st_name); symbol_entry->offset = symbol->st_value; symbol_entry->size = symbol->st_size; @@ -479,8 +478,8 @@ bool LoadSymbols(Elf *elf, GElf_Ehdr *elf_header, struct SymbolInfo *symbols, return LoadAllSymbols(&stab_section, &stabstr_section, base, symbols); } -bool WriteModuleInfo(int fd, GElf_Half arch, const std::string &obj_file) { - const char *arch_name = NULL; +bool WriteModuleInfo(int fd, GElf_Half arch, const std::string& obj_file) { + const char* arch_name = NULL; if (arch == EM_386) arch_name = "x86"; else if (arch == EM_X86_64) @@ -508,10 +507,10 @@ bool WriteModuleInfo(int fd, GElf_Half arch, const std::string &obj_file) { return false; } -bool WriteSourceFileInfo(int fd, const struct SymbolInfo &symbols) { +bool WriteSourceFileInfo(int fd, const struct SymbolInfo& symbols) { for (size_t i = 0; i < symbols.source_file_info.size(); ++i) { if (symbols.source_file_info[i].source_id != -1) { - const char *name = symbols.source_file_info[i].name; + const char* name = symbols.source_file_info[i].name; if (!WriteFormat(fd, "FILE %d %s\n", symbols.source_file_info[i].source_id, name)) return false; @@ -521,7 +520,7 @@ bool WriteSourceFileInfo(int fd, const struct SymbolInfo &symbols) { } bool WriteOneFunction(int fd, int source_id, - const struct FuncInfo &func_info){ + const struct FuncInfo& func_info){ // Discard the ending part of the name. std::string func_name(func_info.name); std::string::size_type last_colon = func_name.find_last_of(':'); @@ -539,7 +538,7 @@ bool WriteOneFunction(int fd, int source_id, func_info.stack_param_size, func_name.c_str())) { for (size_t i = 0; i < func_info.line_info.size(); ++i) { - const struct LineInfo &line_info = func_info.line_info[i]; + const struct LineInfo& line_info = func_info.line_info[i]; if (line_info.line_num == 0) return true; if (!WriteFormat(fd, "%llx %x %d %d\n", @@ -554,11 +553,11 @@ bool WriteOneFunction(int fd, int source_id, return false; } -bool WriteFunctionInfo(int fd, const struct SymbolInfo &symbols) { +bool WriteFunctionInfo(int fd, const struct SymbolInfo& symbols) { for (size_t i = 0; i < symbols.source_file_info.size(); ++i) { - const struct SourceFileInfo &file_info = symbols.source_file_info[i]; + const struct SourceFileInfo& file_info = symbols.source_file_info[i]; for (size_t j = 0; j < file_info.func_info.size(); ++j) { - const struct FuncInfo &func_info = file_info.func_info[j]; + const struct FuncInfo& func_info = file_info.func_info[j]; if (!WriteOneFunction(fd, file_info.source_id, func_info)) return false; } @@ -566,7 +565,7 @@ bool WriteFunctionInfo(int fd, const struct SymbolInfo &symbols) { return true; } -bool DumpStabSymbols(int fd, const struct SymbolInfo &symbols) { +bool DumpStabSymbols(int fd, const struct SymbolInfo& symbols) { return WriteSourceFileInfo(fd, symbols) && WriteFunctionInfo(fd, symbols); } @@ -604,13 +603,13 @@ class FDWrapper { // class MmapWrapper { public: - MmapWrapper(void *mapped_address, size_t mapped_size) : + MmapWrapper(void* mapped_address, size_t mapped_size) : base_(mapped_address), size_(mapped_size) { } ~MmapWrapper() { if (base_ != NULL) { assert(size_ > 0); - munmap((char *)base_, size_); + munmap((char*)base_, size_); } } void release() { @@ -619,7 +618,7 @@ class MmapWrapper { } private: - void *base_; + void* base_; size_t size_; }; @@ -629,14 +628,14 @@ namespace google_breakpad { class AutoElfEnder { public: - AutoElfEnder(Elf *elf) : elf_(elf) {} + AutoElfEnder(Elf* elf) : elf_(elf) {} ~AutoElfEnder() { if (elf_) elf_end(elf_); } private: - Elf *elf_; + Elf* elf_; }; -bool DumpSymbols::WriteSymbolFile(const std::string &obj_file, int sym_fd) { +bool DumpSymbols::WriteSymbolFile(const std::string& obj_file, int sym_fd) { if (elf_version(EV_CURRENT) == EV_NONE) { fprintf(stderr, "elf_version() failed: %s\n", elf_errmsg(0)); return false; @@ -649,16 +648,16 @@ bool DumpSymbols::WriteSymbolFile(const std::string &obj_file, int sym_fd) { struct stat st; if (fstat(obj_fd, &st) != 0 && st.st_size <= 0) return false; - void *obj_base = mmap(NULL, st.st_size, + void* obj_base = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, obj_fd, 0); if (obj_base == MAP_FAILED) return false; MmapWrapper map_wrapper(obj_base, st.st_size); GElf_Ehdr elf_header; - Elf *elf = elf_begin(obj_fd, ELF_C_READ, NULL); + Elf* elf = elf_begin(obj_fd, ELF_C_READ, NULL); AutoElfEnder elfEnder(elf); - if (gelf_getehdr(elf, &elf_header) == (GElf_Ehdr *)NULL) { + if (gelf_getehdr(elf, &elf_header) == (GElf_Ehdr*)NULL) { fprintf(stderr, "failed to read elf header: %s\n", elf_errmsg(-1)); return false; } diff --git a/src/common/solaris/dump_symbols.h b/src/common/solaris/dump_symbols.h index 7f4baadc..3bca8a23 100644 --- a/src/common/solaris/dump_symbols.h +++ b/src/common/solaris/dump_symbols.h @@ -40,7 +40,7 @@ namespace google_breakpad { class DumpSymbols { public: - bool WriteSymbolFile(const std::string &obj_file, + bool WriteSymbolFile(const std::string& obj_file, int sym_fd); }; diff --git a/src/common/solaris/file_id.cc b/src/common/solaris/file_id.cc index 643a1462..c32c73bb 100644 --- a/src/common/solaris/file_id.cc +++ b/src/common/solaris/file_id.cc @@ -54,17 +54,17 @@ namespace google_breakpad { class AutoElfEnder { public: - AutoElfEnder(Elf *elf) : elf_(elf) {} + AutoElfEnder(Elf* elf) : elf_(elf) {} ~AutoElfEnder() { if (elf_) elf_end(elf_); } private: - Elf *elf_; + Elf* elf_; }; // Find the text section in elf object file. // Return the section start address and the size. -static bool FindElfTextSection(int fd, const void *elf_base, - const void **text_start, - int *text_size) { +static bool FindElfTextSection(int fd, const void* elf_base, + const void** text_start, + int* text_size) { assert(text_start); assert(text_size); @@ -78,10 +78,10 @@ static bool FindElfTextSection(int fd, const void *elf_base, GElf_Ehdr elf_header; lseek(fd, 0L, 0); - Elf *elf = elf_begin(fd, ELF_C_READ, NULL); + Elf* elf = elf_begin(fd, ELF_C_READ, NULL); AutoElfEnder elfEnder(elf); - if (gelf_getehdr(elf, &elf_header) == (GElf_Ehdr *)NULL) { + if (gelf_getehdr(elf, &elf_header) == (GElf_Ehdr*)NULL) { print_message2(2, "failed to read elf header: %s\n", elf_errmsg(-1)); return false; } @@ -95,18 +95,18 @@ static bool FindElfTextSection(int fd, const void *elf_base, } static const char kTextSectionName[] = ".text"; - const GElf_Shdr *text_section = NULL; - Elf_Scn *scn = NULL; + const GElf_Shdr* text_section = NULL; + Elf_Scn* scn = NULL; GElf_Shdr shdr; while ((scn = elf_nextscn(elf, scn)) != NULL) { - if (gelf_getshdr(scn, &shdr) == (GElf_Shdr *)0) { + if (gelf_getshdr(scn, &shdr) == (GElf_Shdr*)0) { print_message2(2, "failed to read section header: %s\n", elf_errmsg(0)); return false; } if (shdr.sh_type == SHT_PROGBITS) { - const char *section_name = elf_strptr(elf, elf_header.e_shstrndx, + const char* section_name = elf_strptr(elf, elf_header.e_shstrndx, shdr.sh_name); if (!section_name) { print_message2(2, "Section name error: %s\n", elf_errmsg(-1)); @@ -120,7 +120,7 @@ static bool FindElfTextSection(int fd, const void *elf_base, } } if (text_section != NULL && text_section->sh_size > 0) { - *text_start = (char *)elf_base + text_section->sh_offset; + *text_start = (char*)elf_base + text_section->sh_offset; *text_size = text_section->sh_size; return true; } @@ -128,7 +128,7 @@ static bool FindElfTextSection(int fd, const void *elf_base, return false; } -FileID::FileID(const char *path) { +FileID::FileID(const char* path) { strcpy(path_, path); } @@ -150,29 +150,29 @@ bool FileID::ElfFileIdentifier(unsigned char identifier[16]) { if (fstat(fd, &st) != 0 || st.st_size <= 0) return false; - void *base = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + void* base = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (base == MAP_FAILED) return false; bool success = false; - const void *text_section = NULL; + const void* text_section = NULL; int text_size = 0; if (FindElfTextSection(fd, base, &text_section, &text_size)) { MD5Context md5; MD5Init(&md5); - MD5Update(&md5, (const unsigned char *)text_section, text_size); + MD5Update(&md5, (const unsigned char*)text_section, text_size); MD5Final(identifier, &md5); success = true; } - munmap((char *)base, st.st_size); + munmap((char*)base, st.st_size); return success; } // static bool FileID::ConvertIdentifierToString(const unsigned char identifier[16], - char *buffer, int buffer_length) { + char* buffer, int buffer_length) { if (buffer_length < 34) return false; diff --git a/src/common/solaris/guid_creator.cc b/src/common/solaris/guid_creator.cc index e9e6c6f5..17d773e7 100644 --- a/src/common/solaris/guid_creator.cc +++ b/src/common/solaris/guid_creator.cc @@ -74,8 +74,8 @@ bool GUIDToString(const GUID *guid, char *buf, int buf_len) { assert(buf_len > kGUIDStringLength); int num = snprintf(buf, buf_len, kGUIDFormatString, guid->data1, guid->data2, guid->data3, - *reinterpret_cast(&(guid->data4[0])), - *reinterpret_cast(&(guid->data4[4]))); + *reinterpret_cast(&(guid->data4[0])), + *reinterpret_cast(&(guid->data4[4]))); if (num != kGUIDStringLength) return false; diff --git a/src/common/stabs_reader.cc b/src/common/stabs_reader.cc index 6019fc7e..43c40402 100644 --- a/src/common/stabs_reader.cc +++ b/src/common/stabs_reader.cc @@ -45,7 +45,7 @@ using std::vector; namespace google_breakpad { -StabsReader::EntryIterator::EntryIterator(const ByteBuffer *buffer, +StabsReader::EntryIterator::EntryIterator(const ByteBuffer* buffer, bool big_endian, size_t value_size) : value_size_(value_size), cursor_(buffer, big_endian) { // Actually, we could handle weird sizes just fine, but they're @@ -65,10 +65,10 @@ void StabsReader::EntryIterator::Fetch() { entry_.at_end = !cursor_; } -StabsReader::StabsReader(const uint8_t *stab, size_t stab_size, - const uint8_t *stabstr, size_t stabstr_size, +StabsReader::StabsReader(const uint8_t* stab, size_t stab_size, + const uint8_t* stabstr, size_t stabstr_size, bool big_endian, size_t value_size, bool unitized, - StabsHandler *handler) + StabsHandler* handler) : entries_(stab, stab_size), strings_(stabstr, stabstr_size), iterator_(&entries_, big_endian, value_size), @@ -78,7 +78,7 @@ StabsReader::StabsReader(const uint8_t *stab, size_t stab_size, next_cu_string_offset_(0), current_source_file_(NULL) { } -const char *StabsReader::SymbolString() { +const char* StabsReader::SymbolString() { ptrdiff_t offset = string_offset_ + iterator_->name_offset; if (offset < 0 || (size_t) offset >= strings_.Size()) { handler_->Warning("symbol %d: name offset outside the string section\n", @@ -87,7 +87,7 @@ const char *StabsReader::SymbolString() { // taken from the string section. offset = 0; } - return reinterpret_cast(strings_.start + offset); + return reinterpret_cast(strings_.start + offset); } bool StabsReader::Process() { @@ -134,9 +134,9 @@ bool StabsReader::ProcessCompilationUnit() { // There may be an N_SO entry whose name ends with a slash, // indicating the directory in which the compilation occurred. // The build directory defaults to NULL. - const char *build_directory = NULL; + const char* build_directory = NULL; { - const char *name = SymbolString(); + const char* name = SymbolString(); if (name[0] && name[strlen(name) - 1] == '/') { build_directory = name; ++iterator_; @@ -148,7 +148,7 @@ bool StabsReader::ProcessCompilationUnit() { { if (iterator_->at_end || iterator_->type != N_SO) return true; - const char *name = SymbolString(); + const char* name = SymbolString(); if (name[0] == '\0') { // This seems to be a stray end-of-compilation-unit marker; // consume it, but don't report the end, since we didn't see a @@ -203,7 +203,7 @@ bool StabsReader::ProcessCompilationUnit() { uint64_t ending_address = 0; if (!iterator_->at_end) { assert(iterator_->type == N_SO); - const char *name = SymbolString(); + const char* name = SymbolString(); if (name[0] == '\0') { ending_address = iterator_->value; ++iterator_; @@ -225,8 +225,8 @@ bool StabsReader::ProcessFunction() { // The STABS string for an N_FUN entry is the name of the function, // followed by a colon, followed by type information for the // function. We want to pass the name alone to StartFunction. - const char *stab_string = SymbolString(); - const char *name_end = strchr(stab_string, ':'); + const char* stab_string = SymbolString(); + const char* name_end = strchr(stab_string, ':'); if (! name_end) name_end = stab_string + strlen(stab_string); string name(stab_string, name_end - stab_string); @@ -270,7 +270,7 @@ bool StabsReader::ProcessFunction() { if (!iterator_->at_end) { assert(iterator_->type == N_SO || iterator_->type == N_FUN); if (iterator_->type == N_FUN) { - const char *symbol_name = SymbolString(); + const char* symbol_name = SymbolString(); if (symbol_name[0] == '\0') { // An N_FUN entry with no name is a terminator for this function; // its value is the function's size. diff --git a/src/common/stabs_reader.h b/src/common/stabs_reader.h index 98ee2dd5..1e773f45 100644 --- a/src/common/stabs_reader.h +++ b/src/common/stabs_reader.h @@ -92,10 +92,10 @@ class StabsReader { // // Note that, in ELF, the .stabstr section should be found using the // 'sh_link' field of the .stab section header, not by name. - StabsReader(const uint8_t *stab, size_t stab_size, - const uint8_t *stabstr, size_t stabstr_size, + StabsReader(const uint8_t* stab, size_t stab_size, + const uint8_t* stabstr, size_t stabstr_size, bool big_endian, size_t value_size, bool unitized, - StabsHandler *handler); + StabsHandler* handler); // Process the STABS data, calling the handler's member functions to // report what we find. While the handler functions return true, @@ -149,17 +149,17 @@ class StabsReader { // Mac, they are 32 or 64 bits long. Oddly, the section header's entry // size for a Linux ELF .stab section varies according to the ELF class // from 12 to 20 even as the actual entries remain unchanged. - EntryIterator(const ByteBuffer *buffer, bool big_endian, size_t value_size); + EntryIterator(const ByteBuffer* buffer, bool big_endian, size_t value_size); // Move to the next entry. This function's behavior is undefined if // at_end() is true when it is called. - EntryIterator &operator++() { Fetch(); entry_.index++; return *this; } + EntryIterator& operator++() { Fetch(); entry_.index++; return *this; } // Dereferencing this iterator produces a reference to an Entry structure // that holds the current entry's values. The entry is owned by this // EntryIterator, and will be invalidated at the next call to operator++. - const Entry &operator*() const { return entry_; } - const Entry *operator->() const { return &entry_; } + const Entry& operator*() const { return entry_; } + const Entry* operator->() const { return &entry_; } private: // Read the STABS entry at cursor_, and set entry_ appropriately. @@ -178,12 +178,12 @@ class StabsReader { // A source line, saved to be reported later. struct Line { uint64_t address; - const char *filename; + const char* filename; int number; }; // Return the name of the current symbol. - const char *SymbolString(); + const char* SymbolString(); // Process a compilation unit starting at symbol_. Return true // to continue processing, or false to abort. @@ -210,7 +210,7 @@ class StabsReader { // StabsReader::StabsReader. bool unitized_; - StabsHandler *handler_; + StabsHandler* handler_; // The offset of the current compilation unit's strings within stabstr_. size_t string_offset_; @@ -220,7 +220,7 @@ class StabsReader { size_t next_cu_string_offset_; // The current source file name. - const char *current_source_file_; + const char* current_source_file_; // Mac OS X STABS place SLINE records before functions; we accumulate a // vector of these until we see the FUN record, and then report them @@ -261,7 +261,7 @@ class StabsHandler { // FILENAME values are different addresses, they represent different // file names. // - // Thus, it's safe to use (say) std::map, which does + // Thus, it's safe to use (say) std::map, which does // string address comparisons, not string content comparisons. // Since all the strings are in same array of characters --- the // .stabstr section --- comparing their addresses produces @@ -271,8 +271,8 @@ class StabsHandler { // named FILENAME, and whose base address is ADDRESS. If // BUILD_DIRECTORY is non-NULL, it is the name of the build // directory in which the compilation occurred. - virtual bool StartCompilationUnit(const char *filename, uint64_t address, - const char *build_directory) { + virtual bool StartCompilationUnit(const char* filename, uint64_t address, + const char* build_directory) { return true; } @@ -292,7 +292,7 @@ class StabsHandler { // StartFunction is the function name alone. // // In languages that use name mangling, like C++, NAME is mangled. - virtual bool StartFunction(const string &name, uint64_t address) { + virtual bool StartFunction(const string& name, uint64_t address) { return true; } @@ -305,19 +305,19 @@ class StabsHandler { // Report that the code at ADDRESS is attributable to line NUMBER of // the source file named FILENAME. The caller must infer the ending // address of the line. - virtual bool Line(uint64_t address, const char *filename, int number) { + virtual bool Line(uint64_t address, const char* filename, int number) { return true; } // Report that an exported function NAME is present at ADDRESS. // The size of the function is unknown. - virtual bool Extern(const string &name, uint64_t address) { + virtual bool Extern(const string& name, uint64_t address) { return true; } // Report a warning. FORMAT is a printf-like format string, // specifying how to format the subsequent arguments. - virtual void Warning(const char *format, ...) = 0; + virtual void Warning(const char* format, ...) = 0; }; } // namespace google_breakpad diff --git a/src/common/stabs_reader_unittest.cc b/src/common/stabs_reader_unittest.cc index a84da1c4..24f3e1a5 100644 --- a/src/common/stabs_reader_unittest.cc +++ b/src/common/stabs_reader_unittest.cc @@ -75,7 +75,7 @@ class StringAssembler: public Section { // Add the string S to this StringAssembler, and return the string's // offset within this compilation unit's strings. If S has been added // already, this returns the offset of its first instance. - size_t Add(const string &s) { + size_t Add(const string& s) { map::iterator it = added_.find(s); if (it != added_.end()) return it->second; @@ -127,7 +127,7 @@ class StringAssembler: public Section { class StabsAssembler: public Section { public: // Create a StabsAssembler that uses StringAssembler for its strings. - StabsAssembler(StringAssembler *string_assembler) + StabsAssembler(StringAssembler* string_assembler) : Section(string_assembler->endianness()), string_assembler_(string_assembler), value_size_(0), @@ -137,7 +137,7 @@ class StabsAssembler: public Section { // Accessor and setter for value_size_. size_t value_size() const { return value_size_; } - StabsAssembler &set_value_size(size_t value_size) { + StabsAssembler& set_value_size(size_t value_size) { value_size_ = value_size; return *this; } @@ -147,7 +147,7 @@ class StabsAssembler: public Section { // its compilation unit's portion of the .stabstr section; this can be a // value generated by a StringAssembler. Return a reference to this // StabsAssembler. - StabsAssembler &Stab(uint8_t type, uint8_t other, Label descriptor, + StabsAssembler& Stab(uint8_t type, uint8_t other, Label descriptor, Label value, Label name) { D32(name); D8(type); @@ -159,15 +159,15 @@ class StabsAssembler: public Section { } // As above, but automatically add NAME to our StringAssembler. - StabsAssembler &Stab(uint8_t type, uint8_t other, Label descriptor, - Label value, const string &name) { + StabsAssembler& Stab(uint8_t type, uint8_t other, Label descriptor, + Label value, const string& name) { return Stab(type, other, descriptor, value, string_assembler_->Add(name)); } // Start a compilation unit named NAME, with an N_UNDF symbol to start // it, and its own portion of the string section. Return a reference to // this StabsAssembler. - StabsAssembler &StartCU(const string &name) { + StabsAssembler& StartCU(const string& name) { assert(!cu_header_); cu_header_ = new CUHeader; string_assembler_->StartCU(); @@ -180,7 +180,7 @@ class StabsAssembler: public Section { // Close off the current compilation unit. Return a reference to this // StabsAssembler. - StabsAssembler &EndCU() { + StabsAssembler& EndCU() { assert(cu_header_); cu_header_->final_entry_count = entry_count_; cu_header_->final_string_size = string_assembler_->EndCU(); @@ -201,7 +201,7 @@ class StabsAssembler: public Section { }; // The strings for our STABS entries. - StringAssembler *string_assembler_; + StringAssembler* string_assembler_; // The size of the 'value' field of stabs entries in this section. size_t value_size_; @@ -211,20 +211,20 @@ class StabsAssembler: public Section { // Header labels for this compilation unit, if we've started one but not // finished it. - CUHeader *cu_header_; + CUHeader* cu_header_; }; class MockStabsReaderHandler: public StabsHandler { public: MOCK_METHOD3(StartCompilationUnit, - bool(const char *, uint64_t, const char *)); + bool(const char*, uint64_t, const char*)); MOCK_METHOD1(EndCompilationUnit, bool(uint64_t)); - MOCK_METHOD2(StartFunction, bool(const string &, uint64_t)); + MOCK_METHOD2(StartFunction, bool(const string&, uint64_t)); MOCK_METHOD1(EndFunction, bool(uint64_t)); - MOCK_METHOD3(Line, bool(uint64_t, const char *, int)); - MOCK_METHOD2(Extern, bool(const string &, uint64_t)); - void Warning(const char *format, ...) { MockWarning(format); } - MOCK_METHOD1(MockWarning, void(const char *)); + MOCK_METHOD3(Line, bool(uint64_t, const char*, int)); + MOCK_METHOD2(Extern, bool(const string&, uint64_t)); + void Warning(const char* format, ...) { MockWarning(format); } + MOCK_METHOD1(MockWarning, void(const char*)); }; struct StabsFixture { @@ -243,9 +243,9 @@ struct StabsFixture { // Run the parser on the test input, passing whatever we find to HANDLER. StabsReader reader( - reinterpret_cast(stabs_contents.data()), + reinterpret_cast(stabs_contents.data()), stabs_contents.size(), - reinterpret_cast(stabstr_contents.data()), + reinterpret_cast(stabstr_contents.data()), stabstr_contents.size(), stabs.endianness() == kBigEndian, stabs.value_size(), unitized, &mock_handler); diff --git a/src/common/stabs_to_module.cc b/src/common/stabs_to_module.cc index 049a6cc6..05b25a74 100644 --- a/src/common/stabs_to_module.cc +++ b/src/common/stabs_to_module.cc @@ -45,7 +45,7 @@ namespace google_breakpad { // Demangle using abi call. // Older GCC may not support it. -static string Demangle(const string &mangled) { +static string Demangle(const string& mangled) { int status = 0; char *demangled = abi::__cxa_demangle(mangled.c_str(), NULL, NULL, &status); if (status == 0 && demangled != NULL) { @@ -58,7 +58,7 @@ static string Demangle(const string &mangled) { StabsToModule::~StabsToModule() { // Free any functions we've accumulated but not added to the module. - for (vector::const_iterator func_it = functions_.begin(); + for (vector::const_iterator func_it = functions_.begin(); func_it != functions_.end(); func_it++) delete *func_it; // Free any function that we're currently within. @@ -87,7 +87,7 @@ bool StabsToModule::EndCompilationUnit(uint64_t address) { return true; } -bool StabsToModule::StartFunction(const string &name, +bool StabsToModule::StartFunction(const string& name, uint64_t address) { assert(!current_function_); Module::Function *f = new Module::Function(Demangle(name), address); @@ -131,7 +131,7 @@ bool StabsToModule::Line(uint64_t address, const char *name, int number) { return true; } -bool StabsToModule::Extern(const string &name, uint64_t address) { +bool StabsToModule::Extern(const string& name, uint64_t address) { Module::Extern *ext = new Module::Extern(address); // Older libstdc++ demangle implementations can crash on unexpected // input, so be careful about what gets passed in. @@ -160,7 +160,7 @@ void StabsToModule::Finalize() { sort(functions_.begin(), functions_.end(), Module::Function::CompareByAddress); - for (vector::const_iterator func_it = functions_.begin(); + for (vector::const_iterator func_it = functions_.begin(); func_it != functions_.end(); func_it++) { Module::Function *f = *func_it; diff --git a/src/common/stabs_to_module.h b/src/common/stabs_to_module.h index 5e04fa79..6f6e0ed7 100644 --- a/src/common/stabs_to_module.h +++ b/src/common/stabs_to_module.h @@ -76,10 +76,10 @@ class StabsToModule: public google_breakpad::StabsHandler { bool StartCompilationUnit(const char *name, uint64_t address, const char *build_directory); bool EndCompilationUnit(uint64_t address); - bool StartFunction(const string &name, uint64_t address); + bool StartFunction(const string& name, uint64_t address); bool EndFunction(uint64_t address); bool Line(uint64_t address, const char *name, int number); - bool Extern(const string &name, uint64_t address); + bool Extern(const string& name, uint64_t address); void Warning(const char *format, ...); // Do any final processing necessary to make module_ contain all the @@ -107,7 +107,7 @@ class StabsToModule: public google_breakpad::StabsHandler { // We could just stick them in module_ from the outset, but if // module_ already contains data gathered from other debugging // formats, that would complicate the size computation. - vector functions_; + vector functions_; // Boundary addresses. STABS doesn't necessarily supply sizes for // functions and lines, so we need to compute them ourselves by diff --git a/src/common/stabs_to_module_unittest.cc b/src/common/stabs_to_module_unittest.cc index aae00476..9c134e73 100644 --- a/src/common/stabs_to_module_unittest.cc +++ b/src/common/stabs_to_module_unittest.cc @@ -58,7 +58,7 @@ TEST(StabsToModule, SimpleCU) { Module::File *file = m.FindExistingFile("source-file-name"); ASSERT_TRUE(file != NULL); - vector functions; + vector functions; m.GetFunctions(&functions, functions.end()); ASSERT_EQ((size_t) 1, functions.size()); Module::Function *function = functions[0]; @@ -88,7 +88,7 @@ TEST(StabsToModule, Externs) { h.Finalize(); // Now check to see what has been added to the Module. - vector externs; + vector externs; m.GetExterns(&externs, externs.end()); ASSERT_EQ((size_t) 3, externs.size()); Module::Extern *extern1 = externs[0]; @@ -124,7 +124,7 @@ TEST(StabsToModule, DuplicateFunctionNames) { Module::File *file = m.FindExistingFile("compilation-unit"); ASSERT_TRUE(file != NULL); - vector functions; + vector functions; m.GetFunctions(&functions, functions.end()); ASSERT_EQ(1U, functions.size()); @@ -159,7 +159,7 @@ TEST(InferSizes, LineSize) { Module::File *file2 = m.FindExistingFile("source-file-name-2"); ASSERT_TRUE(file2 != NULL); - vector functions; + vector functions; m.GetFunctions(&functions, functions.end()); ASSERT_EQ((size_t) 1, functions.size()); @@ -204,7 +204,7 @@ TEST(FunctionNames, Mangled) { Module::File *file = m.FindExistingFile("compilation-unit"); ASSERT_TRUE(file != NULL); - vector functions; + vector functions; m.GetFunctions(&functions, functions.end()); ASSERT_EQ(1U, functions.size()); diff --git a/src/common/string_conversion.cc b/src/common/string_conversion.cc index 11d60a36..6a78ed7e 100644 --- a/src/common/string_conversion.cc +++ b/src/common/string_conversion.cc @@ -38,15 +38,15 @@ namespace google_breakpad { using std::vector; -void UTF8ToUTF16(const char *in, vector *out) { +void UTF8ToUTF16(const char* in, vector* out) { size_t source_length = strlen(in); - const UTF8 *source_ptr = reinterpret_cast(in); - const UTF8 *source_end_ptr = source_ptr + source_length; + const UTF8* source_ptr = reinterpret_cast(in); + const UTF8* source_end_ptr = source_ptr + source_length; // Erase the contents and zero fill to the expected size out->clear(); out->insert(out->begin(), source_length, 0); - uint16_t *target_ptr = &(*out)[0]; - uint16_t *target_end_ptr = target_ptr + out->capacity(); + uint16_t* target_ptr = &(*out)[0]; + uint16_t* target_end_ptr = target_ptr + out->capacity(); ConversionResult result = ConvertUTF8toUTF16(&source_ptr, source_end_ptr, &target_ptr, target_end_ptr, strictConversion); @@ -55,11 +55,11 @@ void UTF8ToUTF16(const char *in, vector *out) { out->resize(result == conversionOK ? target_ptr - &(*out)[0] + 1: 0); } -int UTF8ToUTF16Char(const char *in, int in_length, uint16_t out[2]) { - const UTF8 *source_ptr = reinterpret_cast(in); - const UTF8 *source_end_ptr = source_ptr + 1; - uint16_t *target_ptr = out; - uint16_t *target_end_ptr = target_ptr + 2; +int UTF8ToUTF16Char(const char* in, int in_length, uint16_t out[2]) { + const UTF8* source_ptr = reinterpret_cast(in); + const UTF8* source_end_ptr = source_ptr + 1; + uint16_t* target_ptr = out; + uint16_t* target_end_ptr = target_ptr + 2; out[0] = out[1] = 0; // Process one character at a time @@ -69,28 +69,28 @@ int UTF8ToUTF16Char(const char *in, int in_length, uint16_t out[2]) { strictConversion); if (result == conversionOK) - return static_cast(source_ptr - reinterpret_cast(in)); + return static_cast(source_ptr - reinterpret_cast(in)); // Add another character to the input stream and try again - source_ptr = reinterpret_cast(in); + source_ptr = reinterpret_cast(in); ++source_end_ptr; - if (source_end_ptr > reinterpret_cast(in) + in_length) + if (source_end_ptr > reinterpret_cast(in) + in_length) break; } return 0; } -void UTF32ToUTF16(const wchar_t *in, vector *out) { +void UTF32ToUTF16(const wchar_t* in, vector* out) { size_t source_length = wcslen(in); - const UTF32 *source_ptr = reinterpret_cast(in); - const UTF32 *source_end_ptr = source_ptr + source_length; + const UTF32* source_ptr = reinterpret_cast(in); + const UTF32* source_end_ptr = source_ptr + source_length; // Erase the contents and zero fill to the expected size out->clear(); out->insert(out->begin(), source_length, 0); - uint16_t *target_ptr = &(*out)[0]; - uint16_t *target_end_ptr = target_ptr + out->capacity(); + uint16_t* target_ptr = &(*out)[0]; + uint16_t* target_end_ptr = target_ptr + out->capacity(); ConversionResult result = ConvertUTF32toUTF16(&source_ptr, source_end_ptr, &target_ptr, target_end_ptr, strictConversion); @@ -100,10 +100,10 @@ void UTF32ToUTF16(const wchar_t *in, vector *out) { } void UTF32ToUTF16Char(wchar_t in, uint16_t out[2]) { - const UTF32 *source_ptr = reinterpret_cast(&in); - const UTF32 *source_end_ptr = source_ptr + 1; - uint16_t *target_ptr = out; - uint16_t *target_end_ptr = target_ptr + 2; + const UTF32* source_ptr = reinterpret_cast(&in); + const UTF32* source_end_ptr = source_ptr + 1; + uint16_t* target_ptr = out; + uint16_t* target_end_ptr = target_ptr + 2; out[0] = out[1] = 0; ConversionResult result = ConvertUTF32toUTF16(&source_ptr, source_end_ptr, &target_ptr, target_end_ptr, @@ -118,15 +118,15 @@ static inline uint16_t Swap(uint16_t value) { return (value >> 8) | static_cast(value << 8); } -string UTF16ToUTF8(const vector &in, bool swap) { - const UTF16 *source_ptr = &in[0]; +string UTF16ToUTF8(const vector& in, bool swap) { + const UTF16* source_ptr = &in[0]; scoped_array source_buffer; // If we're to swap, we need to make a local copy and swap each byte pair if (swap) { int idx = 0; source_buffer.reset(new uint16_t[in.size()]); - UTF16 *source_buffer_ptr = source_buffer.get(); + UTF16* source_buffer_ptr = source_buffer.get(); for (vector::const_iterator it = in.begin(); it != in.end(); ++it, ++idx) source_buffer_ptr[idx] = Swap(*it); @@ -135,17 +135,17 @@ string UTF16ToUTF8(const vector &in, bool swap) { } // The maximum expansion would be 4x the size of the input string. - const UTF16 *source_end_ptr = source_ptr + in.size(); + const UTF16* source_end_ptr = source_ptr + in.size(); size_t target_capacity = in.size() * 4; scoped_array target_buffer(new UTF8[target_capacity]); - UTF8 *target_ptr = target_buffer.get(); - UTF8 *target_end_ptr = target_ptr + target_capacity; + UTF8* target_ptr = target_buffer.get(); + UTF8* target_end_ptr = target_ptr + target_capacity; ConversionResult result = ConvertUTF16toUTF8(&source_ptr, source_end_ptr, &target_ptr, target_end_ptr, strictConversion); if (result == conversionOK) { - const char *targetPtr = reinterpret_cast(target_buffer.get()); + const char* targetPtr = reinterpret_cast(target_buffer.get()); return targetPtr; } diff --git a/src/common/string_conversion.h b/src/common/string_conversion.h index b9ba96a2..02d1486a 100644 --- a/src/common/string_conversion.h +++ b/src/common/string_conversion.h @@ -44,24 +44,24 @@ using std::vector; // Convert |in| to UTF-16 into |out|. Use platform byte ordering. If the // conversion failed, |out| will be zero length. -void UTF8ToUTF16(const char *in, vector *out); +void UTF8ToUTF16(const char* in, vector* out); // Convert at least one character (up to a maximum of |in_length|) from |in| // to UTF-16 into |out|. Return the number of characters consumed from |in|. // Any unused characters in |out| will be initialized to 0. No memory will // be allocated by this routine. -int UTF8ToUTF16Char(const char *in, int in_length, uint16_t out[2]); +int UTF8ToUTF16Char(const char* in, int in_length, uint16_t out[2]); // Convert |in| to UTF-16 into |out|. Use platform byte ordering. If the // conversion failed, |out| will be zero length. -void UTF32ToUTF16(const wchar_t *in, vector *out); +void UTF32ToUTF16(const wchar_t* in, vector* out); // Convert |in| to UTF-16 into |out|. Any unused characters in |out| will be // initialized to 0. No memory will be allocated by this routine. void UTF32ToUTF16Char(wchar_t in, uint16_t out[2]); // Convert |in| to UTF-8. If |swap| is true, swap bytes before converting. -string UTF16ToUTF8(const vector &in, bool swap); +string UTF16ToUTF8(const vector& in, bool swap); } // namespace google_breakpad diff --git a/src/common/test_assembler.cc b/src/common/test_assembler.cc index 1e783b45..8a48bfb0 100644 --- a/src/common/test_assembler.cc +++ b/src/common/test_assembler.cc @@ -46,7 +46,7 @@ using std::back_insert_iterator; Label::Label() : value_(new Binding()) { } Label::Label(uint64_t value) : value_(new Binding(value)) { } -Label::Label(const Label &label) { +Label::Label(const Label& label) { value_ = label.value_; value_->Acquire(); } @@ -54,12 +54,12 @@ Label::~Label() { if (value_->Release()) delete value_; } -Label &Label::operator=(uint64_t value) { +Label& Label::operator=(uint64_t value) { value_->Set(NULL, value); return *this; } -Label &Label::operator=(const Label &label) { +Label& Label::operator=(const Label& label) { value_->Set(label.value_, 0); return *this; } @@ -89,7 +89,7 @@ Label Label::operator-(uint64_t subtrahend) const { #define ALWAYS_EVALUATE_AND_ASSERT(x) assert(x) #endif -uint64_t Label::operator-(const Label &label) const { +uint64_t Label::operator-(const Label& label) const { uint64_t offset; ALWAYS_EVALUATE_AND_ASSERT(IsKnownOffsetFrom(label, &offset)); return offset; @@ -101,8 +101,8 @@ uint64_t Label::Value() const { return v; }; -bool Label::IsKnownConstant(uint64_t *value_p) const { - Binding *base; +bool Label::IsKnownConstant(uint64_t* value_p) const { + Binding* base; uint64_t addend; value_->Get(&base, &addend); if (base != NULL) return false; @@ -110,9 +110,9 @@ bool Label::IsKnownConstant(uint64_t *value_p) const { return true; } -bool Label::IsKnownOffsetFrom(const Label &label, uint64_t *offset_p) const +bool Label::IsKnownOffsetFrom(const Label& label, uint64_t* offset_p) const { - Binding *label_base, *this_base; + Binding* label_base, *this_base; uint64_t label_addend, this_addend; label.value_->Get(&label_base, &label_addend); value_->Get(&this_base, &this_addend); @@ -135,7 +135,7 @@ Label::Binding::~Binding() { delete base_; } -void Label::Binding::Set(Binding *binding, uint64_t addend) { +void Label::Binding::Set(Binding* binding, uint64_t addend) { if (!base_ && !binding) { // We're equating two constants. This could be okay. assert(addend_ == addend); @@ -183,13 +183,13 @@ void Label::Binding::Set(Binding *binding, uint64_t addend) { } } -void Label::Binding::Get(Binding **base, uint64_t *addend) { +void Label::Binding::Get(Binding** base, uint64_t* addend) { if (base_ && base_ != this) { // Recurse to find the end of our reference chain (the root of our // tree), and then rewrite every binding along the chain to refer // to it directly, adjusting addends appropriately. (This is why // this member function isn't this-const.) - Binding *final_base; + Binding* final_base; uint64_t final_addend; base_->Get(&final_base, &final_addend); if (final_base) final_base->Acquire(); @@ -218,14 +218,14 @@ static inline void InsertEndian(test_assembler::Endianness endianness, } } -Section &Section::Append(Endianness endianness, size_t size, uint64_t number) { +Section& Section::Append(Endianness endianness, size_t size, uint64_t number) { InsertEndian(endianness, size, number, back_insert_iterator(contents_)); return *this; } -Section &Section::Append(Endianness endianness, size_t size, - const Label &label) { +Section& Section::Append(Endianness endianness, size_t size, + const Label& label) { // If this label's value is known, there's no reason to waste an // entry in references_ on it. uint64_t value; @@ -246,14 +246,14 @@ Section &Section::Append(Endianness endianness, size_t size, #define ENDIANNESS(e) ENDIANNESS_ ## e #define DEFINE_SHORT_APPEND_NUMBER_ENDIAN(e, bits) \ - Section &Section::e ## bits(uint ## bits ## _t v) { \ + Section& Section::e ## bits(uint ## bits ## _t v) { \ InsertEndian(ENDIANNESS(e), bits / 8, v, \ back_insert_iterator(contents_)); \ return *this; \ } #define DEFINE_SHORT_APPEND_LABEL_ENDIAN(e, bits) \ - Section &Section::e ## bits(const Label &v) { \ + Section& Section::e ## bits(const Label& v) { \ return Append(ENDIANNESS(e), bits / 8, v); \ } @@ -272,13 +272,13 @@ DEFINE_SHORT_APPEND_ENDIAN(B, 32); DEFINE_SHORT_APPEND_ENDIAN(B, 64); #define DEFINE_SHORT_APPEND_NUMBER_DEFAULT(bits) \ - Section &Section::D ## bits(uint ## bits ## _t v) { \ + Section& Section::D ## bits(uint ## bits ## _t v) { \ InsertEndian(endianness_, bits / 8, v, \ back_insert_iterator(contents_)); \ return *this; \ } #define DEFINE_SHORT_APPEND_LABEL_DEFAULT(bits) \ - Section &Section::D ## bits(const Label &v) { \ + Section& Section::D ## bits(const Label& v) { \ return Append(endianness_, bits / 8, v); \ } #define DEFINE_SHORT_APPEND_DEFAULT(bits) \ @@ -290,7 +290,7 @@ DEFINE_SHORT_APPEND_DEFAULT(16); DEFINE_SHORT_APPEND_DEFAULT(32); DEFINE_SHORT_APPEND_DEFAULT(64); -Section &Section::Append(const Section §ion) { +Section& Section::Append(const Section& section) { size_t base = contents_.size(); contents_.append(section.contents_); for (vector::const_iterator it = section.references_.begin(); @@ -300,7 +300,7 @@ Section &Section::Append(const Section §ion) { return *this; } -Section &Section::LEB128(long long value) { +Section& Section::LEB128(long long value) { while (value < -0x40 || 0x3f < value) { contents_ += (value & 0x7f) | 0x80; if (value < 0) @@ -312,7 +312,7 @@ Section &Section::LEB128(long long value) { return *this; } -Section &Section::ULEB128(uint64_t value) { +Section& Section::ULEB128(uint64_t value) { while (value > 0x7f) { contents_ += (value & 0x7f) | 0x80; value = (value >> 7); @@ -321,7 +321,7 @@ Section &Section::ULEB128(uint64_t value) { return *this; } -Section &Section::Align(size_t alignment, uint8_t pad_byte) { +Section& Section::Align(size_t alignment, uint8_t pad_byte) { // ALIGNMENT must be a power of two. assert(((alignment - 1) & alignment) == 0); size_t new_size = (contents_.size() + alignment - 1) & ~(alignment - 1); @@ -335,11 +335,11 @@ void Section::Clear() { references_.clear(); } -bool Section::GetContents(string *contents) { +bool Section::GetContents(string* contents) { // For each label reference, find the label's value, and patch it into // the section's contents. for (size_t i = 0; i < references_.size(); i++) { - Reference &r = references_[i]; + Reference& r = references_[i]; uint64_t value; if (!r.label.IsKnownConstant(&value)) { fprintf(stderr, "Undefined label #%zu at offset 0x%zx\n", i, r.offset); diff --git a/src/common/test_assembler.h b/src/common/test_assembler.h index 373dbeba..125ef450 100644 --- a/src/common/test_assembler.h +++ b/src/common/test_assembler.h @@ -111,7 +111,7 @@ class Label { public: Label(); // An undefined label. Label(uint64_t value); // A label with a fixed value - Label(const Label &value); // A label equal to another. + Label(const Label& value); // A label equal to another. ~Label(); // Return this label's value; it must be known. @@ -124,18 +124,18 @@ class Label { // former could fail if the label is not yet defined and the latter won't. uint64_t Value() const; - Label &operator=(uint64_t value); - Label &operator=(const Label &value); + Label& operator=(uint64_t value); + Label& operator=(const Label& value); Label operator+(uint64_t addend) const; Label operator-(uint64_t subtrahend) const; - uint64_t operator-(const Label &subtrahend) const; + uint64_t operator-(const Label& subtrahend) const; // We could also provide == and != that work on undefined, but // related, labels. // Return true if this label's value is known. If VALUE_P is given, // set *VALUE_P to the known value if returning true. - bool IsKnownConstant(uint64_t *value_p = NULL) const; + bool IsKnownConstant(uint64_t* value_p = NULL) const; // Return true if the offset from LABEL to this label is known. If // OFFSET_P is given, set *OFFSET_P to the offset when returning true. @@ -155,7 +155,7 @@ class Label { // l-m // -10 // m-l // 10 // m.Value() // error: m's value is not known - bool IsKnownOffsetFrom(const Label &label, uint64_t *offset_p = NULL) const; + bool IsKnownOffsetFrom(const Label& label, uint64_t* offset_p = NULL) const; private: // A label's value, or if that is not yet known, how the value is @@ -186,7 +186,7 @@ class Label { // Update every binding on this binding's chain to point directly // to BINDING, or to be a constant, with addends adjusted // appropriately. - void Set(Binding *binding, uint64_t value); + void Set(Binding* binding, uint64_t value); // Return what we know about the value of this binding. // - If this binding's value is a known constant, set BASE to @@ -198,7 +198,7 @@ class Label { // value. // - If this binding is unconstrained, set BASE to this, and leave // ADDEND unchanged. - void Get(Binding **base, uint64_t *addend); + void Get(Binding** base, uint64_t* addend); private: // There are three cases: @@ -220,7 +220,7 @@ class Label { // operations on bindings do path compression: they change every // binding on the chain to point directly to the final value, // adjusting addends as appropriate. - Binding *base_; + Binding* base_; uint64_t addend_; // The number of Labels and Bindings pointing to this binding. @@ -230,10 +230,10 @@ class Label { }; // This label's value. - Binding *value_; + Binding* value_; }; -inline Label operator+(uint64_t a, const Label &l) { return l + a; } +inline Label operator+(uint64_t a, const Label& l) { return l + a; } // Note that int-Label isn't defined, as negating a Label is not an // operation we support. @@ -288,18 +288,18 @@ class Section { // Append the SIZE bytes at DATA or the contents of STRING to the // end of this section. Return a reference to this section. - Section &Append(const uint8_t *data, size_t size) { - contents_.append(reinterpret_cast(data), size); + Section& Append(const uint8_t* data, size_t size) { + contents_.append(reinterpret_cast(data), size); return *this; }; - Section &Append(const string &data) { + Section& Append(const string& data) { contents_.append(data); return *this; }; // Append SIZE copies of BYTE to the end of this section. Return a // reference to this section. - Section &Append(size_t size, uint8_t byte) { + Section& Append(size_t size, uint8_t byte) { contents_.append(size, (char) byte); return *this; } @@ -307,8 +307,8 @@ class Section { // Append NUMBER to this section. ENDIANNESS is the endianness to // use to write the number. SIZE is the length of the number in // bytes. Return a reference to this section. - Section &Append(Endianness endianness, size_t size, uint64_t number); - Section &Append(Endianness endianness, size_t size, const Label &label); + Section& Append(Endianness endianness, size_t size, uint64_t number); + Section& Append(Endianness endianness, size_t size, const Label& label); // Append SECTION to the end of this section. The labels SECTION // refers to need not be defined yet. @@ -317,11 +317,11 @@ class Section { // SECTION. If placing SECTION within 'this' provides new // constraints on existing labels' values, then it's up to the // caller to fiddle with those labels as needed. - Section &Append(const Section §ion); + Section& Append(const Section& section); // Append the contents of DATA as a series of bytes terminated by // a NULL character. - Section &AppendCString(const string &data) { + Section& AppendCString(const string& data) { Append(data); contents_ += '\0'; return *this; @@ -329,7 +329,7 @@ class Section { // Append at most SIZE bytes from DATA; if DATA is less than SIZE bytes // long, pad with '\0' characters. - Section &AppendCString(const string &data, size_t size) { + Section& AppendCString(const string& data, size_t size) { contents_.append(data, 0, size); if (data.size() < size) Append(size - data.size(), 0); @@ -352,18 +352,18 @@ class Section { // the compiler will properly sign-extend a signed value before // passing it to the function, at which point the function's // behavior is the same either way. - Section &L8(uint8_t value) { contents_ += value; return *this; } - Section &B8(uint8_t value) { contents_ += value; return *this; } - Section &D8(uint8_t value) { contents_ += value; return *this; } + Section& L8(uint8_t value) { contents_ += value; return *this; } + Section& B8(uint8_t value) { contents_ += value; return *this; } + Section& D8(uint8_t value) { contents_ += value; return *this; } Section &L16(uint16_t), &L32(uint32_t), &L64(uint64_t), &B16(uint16_t), &B32(uint32_t), &B64(uint64_t), &D16(uint16_t), &D32(uint32_t), &D64(uint64_t); - Section &L8(const Label &label), &L16(const Label &label), - &L32(const Label &label), &L64(const Label &label), - &B8(const Label &label), &B16(const Label &label), - &B32(const Label &label), &B64(const Label &label), - &D8(const Label &label), &D16(const Label &label), - &D32(const Label &label), &D64(const Label &label); + Section &L8(const Label& label), &L16(const Label& label), + &L32(const Label& label), &L64(const Label& label), + &B8(const Label& label), &B16(const Label& label), + &B32(const Label& label), &B64(const Label& label), + &D8(const Label& label), &D16(const Label& label), + &D32(const Label& label), &D64(const Label& label); // Append VALUE in a signed LEB128 (Little-Endian Base 128) form. // @@ -383,7 +383,7 @@ class Section { // // Note that VALUE cannot be a Label (we would have to implement // relaxation). - Section &LEB128(long long value); + Section& LEB128(long long value); // Append VALUE in unsigned LEB128 (Little-Endian Base 128) form. // @@ -399,13 +399,13 @@ class Section { // // Note that VALUE cannot be a Label (we would have to implement // relaxation). - Section &ULEB128(uint64_t value); + Section& ULEB128(uint64_t value); // Jump to the next location aligned on an ALIGNMENT-byte boundary, // relative to the start of the section. Fill the gap with PAD_BYTE. // ALIGNMENT must be a power of two. Return a reference to this // section. - Section &Align(size_t alignment, uint8_t pad_byte = 0); + Section& Align(size_t alignment, uint8_t pad_byte = 0); // Clear the contents of this section. void Clear(); @@ -436,19 +436,19 @@ class Section { Label Here() const { return start_ + Size(); } // Set *LABEL to Here, and return a reference to this section. - Section &Mark(Label *label) { *label = Here(); return *this; } + Section& Mark(Label* label) { *label = Here(); return *this; } // If there are no undefined label references left in this // section, set CONTENTS to the contents of this section, as a // string, and clear this section. Return true on success, or false // if there were still undefined labels. - bool GetContents(string *contents); + bool GetContents(string* contents); private: // Used internally. A reference to a label's value. struct Reference { Reference(size_t set_offset, Endianness set_endianness, size_t set_size, - const Label &set_label) + const Label& set_label) : offset(set_offset), endianness(set_endianness), size(set_size), label(set_label) { } diff --git a/src/common/test_assembler_unittest.cc b/src/common/test_assembler_unittest.cc index 94b5a5ce..bda25ebf 100644 --- a/src/common/test_assembler_unittest.cc +++ b/src/common/test_assembler_unittest.cc @@ -755,7 +755,7 @@ const uint8_t SectionFixture::data[] = { { \ static const uint8_t expected_bytes[] = b; \ ASSERT_EQ(sizeof(expected_bytes), s.size()); \ - ASSERT_TRUE(memcmp(s.data(), (const char *) expected_bytes, \ + ASSERT_TRUE(memcmp(s.data(), (const char*) expected_bytes, \ sizeof(expected_bytes)) == 0); \ } \ while(0) @@ -766,7 +766,7 @@ TEST_F(Append, Bytes) { section.Append(data, sizeof(data)); ASSERT_TRUE(section.GetContents(&contents)); ASSERT_EQ(sizeof(data), contents.size()); - EXPECT_TRUE(0 == memcmp(contents.data(), (const char *) data, sizeof(data))); + EXPECT_TRUE(0 == memcmp(contents.data(), (const char*) data, sizeof(data))); } TEST_F(Append, BytesTwice) { @@ -774,9 +774,9 @@ TEST_F(Append, BytesTwice) { section.Append(data, sizeof(data)); ASSERT_TRUE(section.GetContents(&contents)); ASSERT_EQ(2 * sizeof(data), contents.size()); - ASSERT_TRUE(0 == memcmp(contents.data(), (const char *) data, sizeof(data))); + ASSERT_TRUE(0 == memcmp(contents.data(), (const char*) data, sizeof(data))); ASSERT_TRUE(0 == memcmp(contents.data() + sizeof(data), - (const char *) data, sizeof(data))); + (const char*) data, sizeof(data))); } TEST_F(Append, String) { diff --git a/src/common/windows/http_upload.cc b/src/common/windows/http_upload.cc index b0cc9078..efee0d58 100644 --- a/src/common/windows/http_upload.cc +++ b/src/common/windows/http_upload.cc @@ -65,7 +65,7 @@ namespace { HINTERNET handle_; }; - wstring UTF8ToWide(const string &utf8) { + wstring UTF8ToWide(const string& utf8) { if (utf8.length() == 0) { return wstring(); } @@ -85,7 +85,7 @@ namespace { return result; } - string WideToMBCP(const wstring &wide, unsigned int cp) { + string WideToMBCP(const wstring& wide, unsigned int cp) { if (wide.length() == 0) { return string(); } @@ -107,7 +107,7 @@ namespace { return result; } - bool GetFileContents(const wstring &filename, vector *contents) { + bool GetFileContents(const wstring& filename, vector* contents) { bool rv = false; // The "open" method on pre-MSVC8 ifstream implementations doesn't accept a // wchar_t* filename, so use _wfopen directly in that case. For VC8 and @@ -141,10 +141,10 @@ namespace { return rv; } - bool CheckParameters(const map ¶meters) { + bool CheckParameters(const map& parameters) { for (map::const_iterator pos = parameters.begin(); pos != parameters.end(); ++pos) { - const wstring &str = pos->first; + const wstring& str = pos->first; if (str.size() == 0) { return false; // disallow empty parameter names } @@ -159,7 +159,7 @@ namespace { } // Converts a UTF16 string to UTF8. - string WideToUTF8(const wstring &wide) { + string WideToUTF8(const wstring& wide) { return WideToMBCP(wide, CP_UTF8); } @@ -305,7 +305,7 @@ namespace { } if (!HttpSendRequest(request.get(), NULL, 0, - const_cast(request_body.data()), + const_cast(request_body.data()), static_cast(request_body.size()))) { return false; } @@ -351,7 +351,7 @@ namespace { return wstring(temp); } - wstring GenerateMultipartPostRequestHeader(const wstring &boundary) { + wstring GenerateMultipartPostRequestHeader(const wstring& boundary) { wstring header = L"Content-Type: multipart/form-data; boundary="; header += boundary; return header; @@ -390,9 +390,9 @@ namespace { return true; } - bool GenerateRequestBody(const map ¶meters, - const map &files, - const wstring &boundary, + bool GenerateRequestBody(const map& parameters, + const map& files, + const wstring& boundary, string *request_body) { string boundary_str = WideToUTF8(boundary); if (boundary_str.empty()) { diff --git a/src/common/windows/http_upload.h b/src/common/windows/http_upload.h index 57e526e3..c7d8c6fe 100644 --- a/src/common/windows/http_upload.h +++ b/src/common/windows/http_upload.h @@ -114,8 +114,8 @@ class HTTPUpload { // No instances of this class should be created. // Disallow all constructors, destructors, and operator=. HTTPUpload(); - explicit HTTPUpload(const HTTPUpload &); - void operator=(const HTTPUpload &); + explicit HTTPUpload(const HTTPUpload&); + void operator=(const HTTPUpload&); ~HTTPUpload(); }; diff --git a/src/common/windows/omap.cc b/src/common/windows/omap.cc index ba3ce86b..5a821b64 100644 --- a/src/common/windows/omap.cc +++ b/src/common/windows/omap.cc @@ -449,11 +449,11 @@ void BuildEndpointIndexMap(ImageMap* image_map) { } } -void BuildSubsequentRVAMap(const OmapData &omap_data, - std::map *subsequent) { +void BuildSubsequentRVAMap(const OmapData& omap_data, + std::map* subsequent) { assert(subsequent->empty()); - const OmapFromTable &orig2tran = - reinterpret_cast(omap_data.omap_from); + const OmapFromTable& orig2tran = + reinterpret_cast(omap_data.omap_from); if (orig2tran.empty()) return; diff --git a/src/common/windows/pdb_source_line_writer.cc b/src/common/windows/pdb_source_line_writer.cc index 4030a2e9..0eeb30cc 100644 --- a/src/common/windows/pdb_source_line_writer.cc +++ b/src/common/windows/pdb_source_line_writer.cc @@ -120,7 +120,7 @@ bool SymbolsMatch(IDiaSymbol* a, IDiaSymbol* b) { return a_section == b_section && a_offset == b_offset; } -bool CreateDiaDataSourceInstance(CComPtr &data_source) { +bool CreateDiaDataSourceInstance(CComPtr& data_source) { if (SUCCEEDED(data_source.CoCreateInstance(CLSID_DiaSource))) { return true; } @@ -134,7 +134,7 @@ bool CreateDiaDataSourceInstance(CComPtr &data_source) { // We can try loading the DLL corresponding to the #included DIA SDK, but // the DIA headers don't provide a version. Lets try to figure out which DIA // version we're compiling against by comparing CLSIDs. - const wchar_t *msdia_dll = nullptr; + const wchar_t* msdia_dll = nullptr; if (CLSID_DiaSource == _uuidof(DiaSource100)) { msdia_dll = L"msdia100.dll"; } else if (CLSID_DiaSource == _uuidof(DiaSource110)) { @@ -147,7 +147,7 @@ bool CreateDiaDataSourceInstance(CComPtr &data_source) { if (msdia_dll && SUCCEEDED(NoRegCoCreate(msdia_dll, CLSID_DiaSource, IID_IDiaDataSource, - reinterpret_cast(&data_source)))) { + reinterpret_cast(&data_source)))) { return true; } @@ -163,7 +163,7 @@ PDBSourceLineWriter::~PDBSourceLineWriter() { Close(); } -bool PDBSourceLineWriter::SetCodeFile(const wstring &exe_file) { +bool PDBSourceLineWriter::SetCodeFile(const wstring& exe_file) { if (code_file_.empty()) { code_file_ = exe_file; return true; @@ -173,7 +173,7 @@ bool PDBSourceLineWriter::SetCodeFile(const wstring &exe_file) { return exe_file == code_file_; } -bool PDBSourceLineWriter::Open(const wstring &file, FileFormat format) { +bool PDBSourceLineWriter::Open(const wstring& file, FileFormat format) { Close(); code_file_.clear(); @@ -228,7 +228,7 @@ bool PDBSourceLineWriter::Open(const wstring &file, FileFormat format) { return true; } -bool PDBSourceLineWriter::PrintLines(IDiaEnumLineNumbers *lines) { +bool PDBSourceLineWriter::PrintLines(IDiaEnumLineNumbers* lines) { // The line number format is: // CComPtr line; @@ -272,8 +272,8 @@ bool PDBSourceLineWriter::PrintLines(IDiaEnumLineNumbers *lines) { return true; } -bool PDBSourceLineWriter::PrintFunction(IDiaSymbol *function, - IDiaSymbol *block, +bool PDBSourceLineWriter::PrintFunction(IDiaSymbol* function, + IDiaSymbol* block, bool has_multiple_symbols) { // The function format is: // FUNC
@@ -679,7 +679,7 @@ bool PDBSourceLineWriter::PrintFrameData() { return false; } -bool PDBSourceLineWriter::PrintCodePublicSymbol(IDiaSymbol *symbol, +bool PDBSourceLineWriter::PrintCodePublicSymbol(IDiaSymbol* symbol, bool has_multiple_symbols) { BOOL is_code; if (FAILED(symbol->get_code(&is_code))) { @@ -781,9 +781,9 @@ bool PDBSourceLineWriter::PrintPEInfo() { // and scanf families, which are not as strict about input and in some cases // don't provide a good way for the caller to determine if a conversion was // successful. -static bool wcstol_positive_strict(wchar_t *string, int *result) { +static bool wcstol_positive_strict(wchar_t* string, int* result) { int value = 0; - for (wchar_t *c = string; *c != '\0'; ++c) { + for (wchar_t* c = string; *c != '\0'; ++c) { int last_value = value; value *= 10; // Detect overflow. @@ -821,7 +821,7 @@ bool PDBSourceLineWriter::FindPEFile() { wstring file(symbols_file); // Look for an EXE or DLL file. - const wchar_t *extensions[] = { L"exe", L"dll" }; + const wchar_t* extensions[] = { L"exe", L"dll" }; for (size_t i = 0; i < sizeof(extensions) / sizeof(extensions[0]); i++) { size_t dot_pos = file.find_last_of(L"."); if (dot_pos != wstring::npos) { @@ -839,9 +839,9 @@ bool PDBSourceLineWriter::FindPEFile() { } // static -bool PDBSourceLineWriter::GetSymbolFunctionName(IDiaSymbol *function, - BSTR *name, - int *stack_param_size) { +bool PDBSourceLineWriter::GetSymbolFunctionName(IDiaSymbol* function, + BSTR* name, + int* stack_param_size) { *stack_param_size = -1; const DWORD undecorate_options = UNDNAME_NO_MS_KEYWORDS | UNDNAME_NO_FUNCTION_RETURNS | @@ -882,12 +882,12 @@ bool PDBSourceLineWriter::GetSymbolFunctionName(IDiaSymbol *function, // C++ uses a bogus "void" argument for functions and methods that don't // take any parameters. Take it out of the undecorated name because it's // ugly and unnecessary. - const wchar_t *replace_string = L"(void)"; + const wchar_t* replace_string = L"(void)"; const size_t replace_length = wcslen(replace_string); - const wchar_t *replacement_string = L"()"; + const wchar_t* replacement_string = L"()"; size_t length = wcslen(*name); if (length >= replace_length) { - wchar_t *name_end = *name + length - replace_length; + wchar_t* name_end = *name + length - replace_length; if (wcscmp(name_end, replace_string) == 0) { WindowsStringUtils::safe_wcscpy(name_end, replace_length, replacement_string); @@ -903,7 +903,7 @@ bool PDBSourceLineWriter::GetSymbolFunctionName(IDiaSymbol *function, // whether the undecorated name contains any ':' or '(' characters. if (!wcschr(*name, ':') && !wcschr(*name, '(') && (*name[0] == '_' || *name[0] == '@')) { - wchar_t *last_at = wcsrchr(*name + 1, '@'); + wchar_t* last_at = wcsrchr(*name + 1, '@'); if (last_at && wcstol_positive_strict(last_at + 1, stack_param_size)) { // If this function adheres to the fastcall convention, it accepts up // to the first 8 bytes of parameters in registers (%ecx and %edx). @@ -935,7 +935,7 @@ bool PDBSourceLineWriter::GetSymbolFunctionName(IDiaSymbol *function, } // static -int PDBSourceLineWriter::GetFunctionStackParamSize(IDiaSymbol *function) { +int PDBSourceLineWriter::GetFunctionStackParamSize(IDiaSymbol* function) { // This implementation is highly x86-specific. // Gather the symbols corresponding to data. @@ -1050,7 +1050,7 @@ next_child: return param_size; } -bool PDBSourceLineWriter::WriteSymbols(FILE *symbol_file) { +bool PDBSourceLineWriter::WriteSymbols(FILE* symbol_file) { output_ = symbol_file; // Load the OMAP information, and disable auto-translation of addresses in @@ -1078,7 +1078,7 @@ void PDBSourceLineWriter::Close() { } } -bool PDBSourceLineWriter::GetModuleInfo(PDBModuleInfo *info) { +bool PDBSourceLineWriter::GetModuleInfo(PDBModuleInfo* info) { if (!info) { return false; } @@ -1143,7 +1143,7 @@ bool PDBSourceLineWriter::GetModuleInfo(PDBModuleInfo *info) { return true; } -bool PDBSourceLineWriter::GetPEInfo(PEModuleInfo *info) { +bool PDBSourceLineWriter::GetPEInfo(PEModuleInfo* info) { if (!info) { return false; } @@ -1156,7 +1156,7 @@ bool PDBSourceLineWriter::GetPEInfo(PEModuleInfo *info) { return ReadPEInfo(code_file_, info); } -bool PDBSourceLineWriter::UsesGUID(bool *uses_guid) { +bool PDBSourceLineWriter::UsesGUID(bool* uses_guid) { if (!uses_guid) return false; diff --git a/src/common/windows/pdb_source_line_writer.h b/src/common/windows/pdb_source_line_writer.h index c0adf29f..00f6e592 100644 --- a/src/common/windows/pdb_source_line_writer.h +++ b/src/common/windows/pdb_source_line_writer.h @@ -65,7 +65,7 @@ class PDBSourceLineWriter { // file must be available; Open will be if it is not. // If there is already a pdb file open, it is automatically closed. // Returns true on success. - bool Open(const wstring &file, FileFormat format); + bool Open(const wstring& file, FileFormat format); // Closes the current pdb file and its associated resources. void Close(); @@ -77,7 +77,7 @@ class PDBSourceLineWriter { // file and it must be called after Open() and before WriteMap(). // If Open() was called for an executable file, then it is an error to call // SetCodeFile() with a different file path and it will return false. - bool SetCodeFile(const wstring &exe_file); + bool SetCodeFile(const wstring& exe_file); // Writes a Breakpad symbol file from the current pdb file to |symbol_file|. // Returns true on success. @@ -150,17 +150,17 @@ class PDBSourceLineWriter { // Returns true if this filename has already been seen, // and an ID is stored for it, or false if it has not. - bool FileIDIsCached(const wstring &file) { + bool FileIDIsCached(const wstring& file) { return unique_files_.find(file) != unique_files_.end(); } // Cache this filename and ID for later reuse. - void CacheFileID(const wstring &file, DWORD id) { + void CacheFileID(const wstring& file, DWORD id) { unique_files_[file] = id; } // Store this ID in the cache as a duplicate for this filename. - void StoreDuplicateFileID(const wstring &file, DWORD id) { + void StoreDuplicateFileID(const wstring& file, DWORD id) { unordered_map::iterator iter = unique_files_.find(file); if (iter != unique_files_.end()) { // map this id to the previously seen one diff --git a/src/common/windows/pe_util.cc b/src/common/windows/pe_util.cc index 6fa63fa3..9c94af05 100644 --- a/src/common/windows/pe_util.cc +++ b/src/common/windows/pe_util.cc @@ -285,7 +285,7 @@ bool PrintPEFrameData(const wstring & pe_file, FILE * out_file) unwind_rva = chained_func->UnwindInfoAddress; } - UnwindInfo *unwind_info = static_cast( + UnwindInfo *unwind_info = static_cast( ImageRvaToVa(img->FileHeader, img->MappedAddress, unwind_rva, @@ -351,7 +351,7 @@ bool PrintPEFrameData(const wstring & pe_file, FILE * out_file) (unwind_info->unwind_code + ((unwind_info->count_of_codes + 1) & ~1))); - unwind_info = static_cast( + unwind_info = static_cast( ImageRvaToVa(img->FileHeader, img->MappedAddress, chained_func->UnwindInfoAddress, diff --git a/src/common/windows/string_utils-inl.h b/src/common/windows/string_utils-inl.h index 9b636072..935e19f5 100644 --- a/src/common/windows/string_utils-inl.h +++ b/src/common/windows/string_utils-inl.h @@ -72,26 +72,26 @@ class WindowsStringUtils { // Roughly equivalent to MSVC8's wcscpy_s, except pre-MSVC8, this does // not fail if source is longer than destination_size. The destination // buffer is always 0-terminated. - static void safe_wcscpy(wchar_t *destination, size_t destination_size, - const wchar_t *source); + static void safe_wcscpy(wchar_t* destination, size_t destination_size, + const wchar_t* source); // Roughly equivalent to MSVC8's wcsncpy_s, except that _TRUNCATE cannot // be passed directly, and pre-MSVC8, this will not fail if source or count // are longer than destination_size. The destination buffer is always // 0-terminated. - static void safe_wcsncpy(wchar_t *destination, size_t destination_size, - const wchar_t *source, size_t count); + static void safe_wcsncpy(wchar_t* destination, size_t destination_size, + const wchar_t* source, size_t count); // Performs multi-byte to wide character conversion on C++ strings, using // mbstowcs_s (MSVC8) or mbstowcs (pre-MSVC8). Returns false on failure, // without setting wcs. - static bool safe_mbstowcs(const string &mbs, wstring *wcs); + static bool safe_mbstowcs(const string& mbs, wstring* wcs); // The inverse of safe_mbstowcs. - static bool safe_wcstombs(const wstring &wcs, string *mbs); + static bool safe_wcstombs(const wstring& wcs, string* mbs); // Returns the base name of a file, e.g. strips off the path. - static wstring GetBaseName(const wstring &filename); + static wstring GetBaseName(const wstring& filename); private: // Disallow instantiation and other object-based operations. @@ -102,9 +102,9 @@ class WindowsStringUtils { }; // static -inline void WindowsStringUtils::safe_wcscpy(wchar_t *destination, +inline void WindowsStringUtils::safe_wcscpy(wchar_t* destination, size_t destination_size, - const wchar_t *source) { + const wchar_t* source) { #if _MSC_VER >= 1400 // MSVC 2005/8 wcscpy_s(destination, destination_size, source); #else // _MSC_VER >= 1400 @@ -118,9 +118,9 @@ inline void WindowsStringUtils::safe_wcscpy(wchar_t *destination, } // static -inline void WindowsStringUtils::safe_wcsncpy(wchar_t *destination, +inline void WindowsStringUtils::safe_wcsncpy(wchar_t* destination, size_t destination_size, - const wchar_t *source, + const wchar_t* source, size_t count) { #if _MSC_VER >= 1400 // MSVC 2005/8 wcsncpy_s(destination, destination_size, source, count); diff --git a/src/common/windows/string_utils.cc b/src/common/windows/string_utils.cc index 27280003..90aab038 100644 --- a/src/common/windows/string_utils.cc +++ b/src/common/windows/string_utils.cc @@ -35,7 +35,7 @@ namespace google_breakpad { // static -wstring WindowsStringUtils::GetBaseName(const wstring &filename) { +wstring WindowsStringUtils::GetBaseName(const wstring& filename) { wstring base_name(filename); size_t slash_pos = base_name.find_last_of(L"/\\"); if (slash_pos != wstring::npos) { @@ -45,7 +45,7 @@ wstring WindowsStringUtils::GetBaseName(const wstring &filename) { } // static -bool WindowsStringUtils::safe_mbstowcs(const string &mbs, wstring *wcs) { +bool WindowsStringUtils::safe_mbstowcs(const string& mbs, wstring* wcs) { assert(wcs); // First, determine the length of the destination buffer. @@ -88,7 +88,7 @@ bool WindowsStringUtils::safe_mbstowcs(const string &mbs, wstring *wcs) { } // static -bool WindowsStringUtils::safe_wcstombs(const wstring &wcs, string *mbs) { +bool WindowsStringUtils::safe_wcstombs(const wstring& wcs, string* mbs) { assert(mbs); // First, determine the length of the destination buffer. diff --git a/src/google_breakpad/processor/basic_source_line_resolver.h b/src/google_breakpad/processor/basic_source_line_resolver.h index 91fb7841..1c7bf465 100644 --- a/src/google_breakpad/processor/basic_source_line_resolver.h +++ b/src/google_breakpad/processor/basic_source_line_resolver.h @@ -90,9 +90,9 @@ class SymbolParseHelper { // can't be const. On success, , and are stored in |*index|, // and |*filename|. No allocation is done, |*filename| simply points inside // |file_line|. - static bool ParseFile(char *file_line, // in - long *index, // out - char **filename); // out + static bool ParseFile(char* file_line, // in + long* index, // out + char** filename); // out // Parses a |function_line| declaration. Returns true on success. // Format: FUNC []
. @@ -101,12 +101,12 @@ class SymbolParseHelper { // , and are stored in |*is_multiple|, |*address|, // |*size|, |*stack_param_size|, and |*name|. No allocation is done, |*name| // simply points inside |function_line|. - static bool ParseFunction(char *function_line, // in - bool *is_multiple, // out - uint64_t *address, // out - uint64_t *size, // out - long *stack_param_size, // out - char **name); // out + static bool ParseFunction(char* function_line, // in + bool* is_multiple, // out + uint64_t* address, // out + uint64_t* size, // out + long* stack_param_size, // out + char** name); // out // Parses a |line| declaration. Returns true on success. // Format:
@@ -114,11 +114,11 @@ class SymbolParseHelper { // it can't be const. On success,
, , , and // are stored in |*address|, |*size|, |*line_number|, and // |*source_file|. - static bool ParseLine(char *line_line, // in - uint64_t *address, // out - uint64_t *size, // out - long *line_number, // out - long *source_file); // out + static bool ParseLine(char* line_line, // in + uint64_t* address, // out + uint64_t* size, // out + long* line_number, // out + long* source_file); // out // Parses a |public_line| declaration. Returns true on success. // Format: PUBLIC []
@@ -127,15 +127,15 @@ class SymbolParseHelper { // , are stored in |*is_multiple|, |*address|, // |*stack_param_size|, and |*name|. No allocation is done, |*name| simply // points inside |public_line|. - static bool ParsePublicSymbol(char *public_line, // in - bool *is_multiple, // out - uint64_t *address, // out - long *stack_param_size, // out - char **name); // out + static bool ParsePublicSymbol(char* public_line, // in + bool* is_multiple, // out + uint64_t* address, // out + long* stack_param_size, // out + char** name); // out private: // Used for success checks after strtoull and strtol. - static bool IsValidAfterNumber(char *after_number); + static bool IsValidAfterNumber(char* after_number); // Only allow static methods. SymbolParseHelper(); diff --git a/src/google_breakpad/processor/minidump.h b/src/google_breakpad/processor/minidump.h index d712cb66..1c40a821 100644 --- a/src/google_breakpad/processor/minidump.h +++ b/src/google_breakpad/processor/minidump.h @@ -291,7 +291,7 @@ class MinidumpThread : public MinidumpObject { // so a special getter is provided to retrieve this data from the // MDRawThread structure. Returns false if the thread ID cannot be // determined. - virtual bool GetThreadID(uint32_t *thread_id) const; + virtual bool GetThreadID(uint32_t* thread_id) const; // Print a human-readable representation of the object to stdout. void Print(); @@ -549,9 +549,9 @@ class MinidumpModuleList : public MinidumpStream, static uint32_t max_modules_; // Access to modules using addresses as the key. - RangeMap *range_map_; + RangeMap* range_map_; - MinidumpModules *modules_; + MinidumpModules* modules_; uint32_t module_count_; DISALLOW_COPY_AND_ASSIGN(MinidumpModuleList); @@ -606,16 +606,16 @@ class MinidumpMemoryList : public MinidumpStream { static uint32_t max_regions_; // Access to memory regions using addresses as the key. - RangeMap *range_map_; + RangeMap* range_map_; // The list of descriptors. This is maintained separately from the list // of regions, because MemoryRegion doesn't own its MemoryDescriptor, it // maintains a pointer to it. descriptors_ provides the storage for this // purpose. - MemoryDescriptors *descriptors_; + MemoryDescriptors* descriptors_; // The list of regions. - MemoryRegions *regions_; + MemoryRegions* regions_; uint32_t region_count_; DISALLOW_COPY_AND_ASSIGN(MinidumpMemoryList); @@ -640,7 +640,7 @@ class MinidumpException : public MinidumpStream { // so a special getter is provided to retrieve this data from the // MDRawExceptionStream structure. Returns false if the thread ID cannot // be determined. - bool GetThreadID(uint32_t *thread_id) const; + bool GetThreadID(uint32_t* thread_id) const; MinidumpContext* GetContext(); @@ -862,9 +862,9 @@ class MinidumpUnloadedModuleList : public MinidumpStream, static uint32_t max_modules_; // Access to module indices using addresses as the key. - RangeMap *range_map_; + RangeMap* range_map_; - MinidumpUnloadedModules *unloaded_modules_; + MinidumpUnloadedModules* unloaded_modules_; uint32_t module_count_; DISALLOW_COPY_AND_ASSIGN(MinidumpUnloadedModuleList); @@ -919,8 +919,8 @@ class MinidumpBreakpadInfo : public MinidumpStream { // treatment, so special getters are provided to retrieve this data from // the MDRawBreakpadInfo structure. The getters return false if the thread // IDs cannot be determined. - bool GetDumpThreadID(uint32_t *thread_id) const; - bool GetRequestingThreadID(uint32_t *thread_id) const; + bool GetDumpThreadID(uint32_t* thread_id) const; + bool GetRequestingThreadID(uint32_t* thread_id) const; // Print a human-readable representation of the object to stdout. void Print(); @@ -1003,7 +1003,7 @@ class MinidumpMemoryInfoList : public MinidumpStream { bool Read(uint32_t expected_size) override; // Access to memory info using addresses as the key. - RangeMap *range_map_; + RangeMap* range_map_; MinidumpMemoryInfos* infos_; uint32_t info_count_; @@ -1056,7 +1056,7 @@ class MinidumpLinuxMaps : public MinidumpObject { friend class MinidumpLinuxMapsList; // This caller owns the pointer. - explicit MinidumpLinuxMaps(Minidump *minidump); + explicit MinidumpLinuxMaps(Minidump* minidump); // The memory region struct that this class wraps. MappedMemoryRegion region_; @@ -1075,9 +1075,9 @@ class MinidumpLinuxMapsList : public MinidumpStream { unsigned int get_maps_count() const { return valid_ ? maps_count_ : 0; } // Get mapping at the given memory address. The caller owns the pointer. - const MinidumpLinuxMaps *GetLinuxMapsForAddress(uint64_t address) const; + const MinidumpLinuxMaps* GetLinuxMapsForAddress(uint64_t address) const; // Get mapping at the given index. The caller owns the pointer. - const MinidumpLinuxMaps *GetLinuxMapsAtIndex(unsigned int index) const; + const MinidumpLinuxMaps* GetLinuxMapsAtIndex(unsigned int index) const; // Print the contents of /proc/self/maps to stdout. void Print() const; @@ -1085,12 +1085,12 @@ class MinidumpLinuxMapsList : public MinidumpStream { private: friend class Minidump; - typedef vector MinidumpLinuxMappings; + typedef vector MinidumpLinuxMappings; static const uint32_t kStreamType = MD_LINUX_MAPS; // The caller owns the pointer. - explicit MinidumpLinuxMapsList(Minidump *minidump); + explicit MinidumpLinuxMapsList(Minidump* minidump); // Read and load the contents of the process mapping data. // The stream should have data in the form of /proc/self/maps. @@ -1098,7 +1098,7 @@ class MinidumpLinuxMapsList : public MinidumpStream { bool Read(uint32_t expected_size) override; // The list of individual mappings. - MinidumpLinuxMappings *maps_; + MinidumpLinuxMappings* maps_; // The number of mappings. uint32_t maps_count_; @@ -1200,7 +1200,7 @@ class Minidump { MinidumpCrashpadInfo* GetCrashpadInfo(); // The next method also calls GetStream, but is exclusive for Linux dumps. - virtual MinidumpLinuxMapsList *GetLinuxMapsList(); + virtual MinidumpLinuxMapsList* GetLinuxMapsList(); // The next set of methods are provided for users who wish to access // data in minidump files directly, while leveraging the rest of diff --git a/src/google_breakpad/processor/minidump_processor.h b/src/google_breakpad/processor/minidump_processor.h index 387115ef..414050e9 100644 --- a/src/google_breakpad/processor/minidump_processor.h +++ b/src/google_breakpad/processor/minidump_processor.h @@ -70,7 +70,7 @@ class MinidumpProcessor { ~MinidumpProcessor(); // Processes the minidump file and fills process_state with the result. - ProcessResult Process(const string &minidump_file, + ProcessResult Process(const string& minidump_file, ProcessState* process_state); // Processes the minidump structure and fills process_state with the diff --git a/src/google_breakpad/processor/source_line_resolver_base.h b/src/google_breakpad/processor/source_line_resolver_base.h index c720b0c3..fea1657c 100644 --- a/src/google_breakpad/processor/source_line_resolver_base.h +++ b/src/google_breakpad/processor/source_line_resolver_base.h @@ -64,36 +64,36 @@ class SourceLineResolverBase : public SourceLineResolverInterface { // LoadMap() method. // Place dynamically allocated heap buffer in symbol_data. Caller has the // ownership of the buffer, and should call delete [] to free the buffer. - static bool ReadSymbolFile(const string &file_name, - char **symbol_data, - size_t *symbol_data_size); + static bool ReadSymbolFile(const string& file_name, + char** symbol_data, + size_t* symbol_data_size); protected: // Users are not allowed create SourceLineResolverBase instance directly. - SourceLineResolverBase(ModuleFactory *module_factory); + SourceLineResolverBase(ModuleFactory* module_factory); virtual ~SourceLineResolverBase(); // Virtual methods inherited from SourceLineResolverInterface. - virtual bool LoadModule(const CodeModule *module, const string &map_file); - virtual bool LoadModuleUsingMapBuffer(const CodeModule *module, - const string &map_buffer); - virtual bool LoadModuleUsingMemoryBuffer(const CodeModule *module, - char *memory_buffer, + virtual bool LoadModule(const CodeModule* module, const string& map_file); + virtual bool LoadModuleUsingMapBuffer(const CodeModule* module, + const string& map_buffer); + virtual bool LoadModuleUsingMemoryBuffer(const CodeModule* module, + char* memory_buffer, size_t memory_buffer_size); virtual bool ShouldDeleteMemoryBufferAfterLoadModule(); - virtual void UnloadModule(const CodeModule *module); - virtual bool HasModule(const CodeModule *module); - virtual bool IsModuleCorrupt(const CodeModule *module); - virtual void FillSourceLineInfo(StackFrame *frame); - virtual WindowsFrameInfo *FindWindowsFrameInfo(const StackFrame *frame); - virtual CFIFrameInfo *FindCFIFrameInfo(const StackFrame *frame); + virtual void UnloadModule(const CodeModule* module); + virtual bool HasModule(const CodeModule* module); + virtual bool IsModuleCorrupt(const CodeModule* module); + virtual void FillSourceLineInfo(StackFrame* frame); + virtual WindowsFrameInfo* FindWindowsFrameInfo(const StackFrame* frame); + virtual CFIFrameInfo* FindCFIFrameInfo(const StackFrame* frame); // Nested structs and classes. struct Line; struct Function; struct PublicSymbol; struct CompareString { - bool operator()(const string &s1, const string &s2) const; + bool operator()(const string& s1, const string& s2) const; }; // Module is an interface for an in-memory symbol file. class Module; @@ -101,18 +101,18 @@ class SourceLineResolverBase : public SourceLineResolverInterface { // All of the modules that are loaded. typedef map ModuleMap; - ModuleMap *modules_; + ModuleMap* modules_; // The loaded modules that were detecting to be corrupt during load. typedef set ModuleSet; - ModuleSet *corrupt_modules_; + ModuleSet* corrupt_modules_; // All of heap-allocated buffers that are owned locally by resolver. typedef std::map MemoryMap; - MemoryMap *memory_buffers_; + MemoryMap* memory_buffers_; // Creates a concrete module at run-time. - ModuleFactory *module_factory_; + ModuleFactory* module_factory_; private: // ModuleFactory needs to have access to protected type Module. diff --git a/src/google_breakpad/processor/source_line_resolver_interface.h b/src/google_breakpad/processor/source_line_resolver_interface.h index a694bf2e..99011404 100644 --- a/src/google_breakpad/processor/source_line_resolver_interface.h +++ b/src/google_breakpad/processor/source_line_resolver_interface.h @@ -58,11 +58,11 @@ class SourceLineResolverInterface { // and debug_identifier members populated. // // map_file should contain line/address mappings for this module. - virtual bool LoadModule(const CodeModule *module, - const string &map_file) = 0; + virtual bool LoadModule(const CodeModule* module, + const string& map_file) = 0; // Same as above, but takes the contents of a pre-read map buffer - virtual bool LoadModuleUsingMapBuffer(const CodeModule *module, - const string &map_buffer) = 0; + virtual bool LoadModuleUsingMapBuffer(const CodeModule* module, + const string& map_buffer) = 0; // Add an interface to load symbol using C-String data instead of string. // This is useful in the optimization design for avoiding unnecessary copying @@ -70,8 +70,8 @@ class SourceLineResolverInterface { // LoadModuleUsingMemoryBuffer() does NOT take ownership of memory_buffer. // LoadModuleUsingMemoryBuffer() null terminates the passed in buffer, if // the last character is not a null terminator. - virtual bool LoadModuleUsingMemoryBuffer(const CodeModule *module, - char *memory_buffer, + virtual bool LoadModuleUsingMemoryBuffer(const CodeModule* module, + char* memory_buffer, size_t memory_buffer_size) = 0; // Return true if the memory buffer should be deleted immediately after @@ -81,31 +81,31 @@ class SourceLineResolverInterface { // Request that the specified module be unloaded from this resolver. // A resolver may choose to ignore such a request. - virtual void UnloadModule(const CodeModule *module) = 0; + virtual void UnloadModule(const CodeModule* module) = 0; // Returns true if the module has been loaded. - virtual bool HasModule(const CodeModule *module) = 0; + virtual bool HasModule(const CodeModule* module) = 0; // Returns true if the module has been loaded and it is corrupt. - virtual bool IsModuleCorrupt(const CodeModule *module) = 0; + virtual bool IsModuleCorrupt(const CodeModule* module) = 0; // Fills in the function_base, function_name, source_file_name, // and source_line fields of the StackFrame. The instruction and // module_name fields must already be filled in. - virtual void FillSourceLineInfo(StackFrame *frame) = 0; + virtual void FillSourceLineInfo(StackFrame* frame) = 0; // If Windows stack walking information is available covering // FRAME's instruction address, return a WindowsFrameInfo structure // describing it. If the information is not available, returns NULL. // A NULL return value does not indicate an error. The caller takes // ownership of any returned WindowsFrameInfo object. - virtual WindowsFrameInfo *FindWindowsFrameInfo(const StackFrame *frame) = 0; + virtual WindowsFrameInfo* FindWindowsFrameInfo(const StackFrame* frame) = 0; // If CFI stack walking information is available covering ADDRESS, // return a CFIFrameInfo structure describing it. If the information // is not available, return NULL. The caller takes ownership of any // returned CFIFrameInfo object. - virtual CFIFrameInfo *FindCFIFrameInfo(const StackFrame *frame) = 0; + virtual CFIFrameInfo* FindCFIFrameInfo(const StackFrame* frame) = 0; protected: // SourceLineResolverInterface cannot be instantiated except by subclasses diff --git a/src/google_breakpad/processor/symbol_supplier.h b/src/google_breakpad/processor/symbol_supplier.h index a042081f..6ec01766 100644 --- a/src/google_breakpad/processor/symbol_supplier.h +++ b/src/google_breakpad/processor/symbol_supplier.h @@ -63,35 +63,35 @@ class SymbolSupplier { // to help locate the symbol file. system_info may be NULL or its // fields may be empty if these values are unknown. symbol_file // must be a pointer to a valid string - virtual SymbolResult GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file) = 0; + virtual SymbolResult GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file) = 0; // Same as above, except also places symbol data into symbol_data. // If symbol_data is NULL, the data is not returned. // TODO(nealsid) Once we have symbol data caching behavior implemented // investigate making all symbol suppliers implement all methods, // and make this pure virtual - virtual SymbolResult GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - string *symbol_data) = 0; + virtual SymbolResult GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + string* symbol_data) = 0; // Same as above, except allocates data buffer on heap and then places the // symbol data into the buffer as C-string. // SymbolSupplier is responsible for deleting the data buffer. After the call // to GetCStringSymbolData(), the caller should call FreeSymbolData(const - // Module *module) once the data buffer is no longer needed. + // Module* module) once the data buffer is no longer needed. // If symbol_data is not NULL, symbol supplier won't return FOUND unless it // returns a valid buffer in symbol_data, e.g., returns INTERRUPT on memory // allocation failure. - virtual SymbolResult GetCStringSymbolData(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - char **symbol_data, - size_t *symbol_data_size) = 0; + virtual SymbolResult GetCStringSymbolData(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + char** symbol_data, + size_t* symbol_data_size) = 0; // Frees the data buffer allocated for the module in GetCStringSymbolData. - virtual void FreeSymbolData(const CodeModule *module) = 0; + virtual void FreeSymbolData(const CodeModule* module) = 0; }; } // namespace google_breakpad diff --git a/src/processor/address_map-inl.h b/src/processor/address_map-inl.h index 251c4478..96d955ad 100644 --- a/src/processor/address_map-inl.h +++ b/src/processor/address_map-inl.h @@ -45,8 +45,8 @@ namespace google_breakpad { template -bool AddressMap::Store(const AddressType &address, - const EntryType &entry) { +bool AddressMap::Store(const AddressType& address, + const EntryType& entry) { // Ensure that the specified address doesn't conflict with something already // in the map. if (map_.find(address) != map_.end()) { @@ -61,8 +61,8 @@ bool AddressMap::Store(const AddressType &address, template bool AddressMap::Retrieve( - const AddressType &address, - EntryType *entry, AddressType *entry_address) const { + const AddressType& address, + EntryType* entry, AddressType* entry_address) const { BPLOG_IF(ERROR, !entry) << "AddressMap::Retrieve requires |entry|"; assert(entry); diff --git a/src/processor/address_map.h b/src/processor/address_map.h index 2972cbb9..87321a7f 100644 --- a/src/processor/address_map.h +++ b/src/processor/address_map.h @@ -53,15 +53,15 @@ class AddressMap { // Inserts an entry into the map. Returns false without storing the entry // if an entry is already stored in the map at the same address as specified // by the address argument. - bool Store(const AddressType &address, const EntryType &entry); + bool Store(const AddressType& address, const EntryType& entry); // Locates the entry stored at the highest address less than or equal to // the address argument. If there is no such range, returns false. The // entry is returned in entry, which is a required argument. If // entry_address is not NULL, it will be set to the address that the entry // was stored at. - bool Retrieve(const AddressType &address, - EntryType *entry, AddressType *entry_address) const; + bool Retrieve(const AddressType& address, + EntryType* entry, AddressType* entry_address) const; // Empties the address map, restoring it to the same state as when it was // initially created. diff --git a/src/processor/address_map_unittest.cc b/src/processor/address_map_unittest.cc index 9b4095b1..7c85f5eb 100644 --- a/src/processor/address_map_unittest.cc +++ b/src/processor/address_map_unittest.cc @@ -189,7 +189,7 @@ static bool RunTests() { } // namespace -int main(int argc, char **argv) { +int main(int argc, char** argv) { BPLOG_INIT(&argc, &argv); return RunTests() ? 0 : 1; diff --git a/src/processor/basic_code_module.h b/src/processor/basic_code_module.h index 35d66a60..75272897 100644 --- a/src/processor/basic_code_module.h +++ b/src/processor/basic_code_module.h @@ -66,11 +66,11 @@ class BasicCodeModule : public CodeModule { is_unloaded_(that->is_unloaded()) {} BasicCodeModule(uint64_t base_address, uint64_t size, - const string &code_file, - const string &code_identifier, - const string &debug_file, - const string &debug_identifier, - const string &version, + const string& code_file, + const string& code_identifier, + const string& debug_file, + const string& debug_identifier, + const string& version, const bool is_unloaded = false) : base_address_(base_address), size_(size), @@ -112,8 +112,8 @@ class BasicCodeModule : public CodeModule { bool is_unloaded_; // Disallow copy constructor and assignment operator. - BasicCodeModule(const BasicCodeModule &that); - void operator=(const BasicCodeModule &that); + BasicCodeModule(const BasicCodeModule& that); + void operator=(const BasicCodeModule& that); }; } // namespace google_breakpad diff --git a/src/processor/basic_code_modules.h b/src/processor/basic_code_modules.h index 45ebc53b..8c26abb1 100644 --- a/src/processor/basic_code_modules.h +++ b/src/processor/basic_code_modules.h @@ -88,8 +88,8 @@ class BasicCodeModules : public CodeModules { private: // Disallow copy constructor and assignment operator. - BasicCodeModules(const BasicCodeModules &that); - void operator=(const BasicCodeModules &that); + BasicCodeModules(const BasicCodeModules& that); + void operator=(const BasicCodeModules& that); }; } // namespace google_breakpad diff --git a/src/processor/basic_source_line_resolver.cc b/src/processor/basic_source_line_resolver.cc index c4aa949c..64d40015 100644 --- a/src/processor/basic_source_line_resolver.cc +++ b/src/processor/basic_source_line_resolver.cc @@ -69,11 +69,11 @@ namespace { // field, and max_tokens is the maximum number of tokens including the optional // field. Refer to the documentation for Tokenize for descriptions of the other // arguments. -bool TokenizeWithOptionalField(char *line, - const char *optional_field, - const char *separators, +bool TokenizeWithOptionalField(char* line, + const char* optional_field, + const char* separators, int max_tokens, - vector *tokens) { + vector* tokens) { // First tokenize assuming the optional field is not present. If we then see // the optional field, additionally tokenize the last token into two tokens. if (!Tokenize(line, separators, max_tokens - 1, tokens)) { @@ -98,7 +98,7 @@ bool TokenizeWithOptionalField(char *line, } // namespace -static const char *kWhitespace = " \r\n"; +static const char* kWhitespace = " \r\n"; static const int kMaxErrorsPrinted = 5; static const int kMaxErrorsBeforeBailing = 100; @@ -107,9 +107,9 @@ BasicSourceLineResolver::BasicSourceLineResolver() : // static void BasicSourceLineResolver::Module::LogParseError( - const string &message, + const string& message, int line_number, - int *num_errors) { + int* num_errors) { if (++(*num_errors) <= kMaxErrorsPrinted) { if (line_number > 0) { BPLOG(ERROR) << "Line " << line_number << ": " << message; @@ -120,12 +120,12 @@ void BasicSourceLineResolver::Module::LogParseError( } bool BasicSourceLineResolver::Module::LoadMapFromMemory( - char *memory_buffer, + char* memory_buffer, size_t memory_buffer_size) { linked_ptr cur_func; int line_number = 0; int num_errors = 0; - char *save_ptr; + char* save_ptr; // If the length is 0, we can still pretend we have a symbol file. This is // for scenarios that want to test symbol lookup, but don't necessarily care @@ -160,7 +160,7 @@ bool BasicSourceLineResolver::Module::LoadMapFromMemory( &num_errors); } - char *buffer; + char* buffer; buffer = strtok_r(memory_buffer, "\r\n", &save_ptr); while (buffer != NULL) { @@ -207,7 +207,7 @@ bool BasicSourceLineResolver::Module::LoadMapFromMemory( LogParseError("Found source line data without a function", line_number, &num_errors); } else { - Line *line = ParseLine(buffer); + Line* line = ParseLine(buffer); if (!line) { LogParseError("ParseLine failed", line_number, &num_errors); } else { @@ -225,7 +225,7 @@ bool BasicSourceLineResolver::Module::LoadMapFromMemory( return true; } -void BasicSourceLineResolver::Module::LookupAddress(StackFrame *frame) const { +void BasicSourceLineResolver::Module::LookupAddress(StackFrame* frame) const { MemAddr address = frame->instruction - frame->module->base_address(); // First, look for a FUNC record that covers address. Use @@ -264,8 +264,8 @@ void BasicSourceLineResolver::Module::LookupAddress(StackFrame *frame) const { } } -WindowsFrameInfo *BasicSourceLineResolver::Module::FindWindowsFrameInfo( - const StackFrame *frame) const { +WindowsFrameInfo* BasicSourceLineResolver::Module::FindWindowsFrameInfo( + const StackFrame* frame) const { MemAddr address = frame->instruction - frame->module->base_address(); scoped_ptr result(new WindowsFrameInfo()); @@ -313,8 +313,8 @@ WindowsFrameInfo *BasicSourceLineResolver::Module::FindWindowsFrameInfo( return NULL; } -CFIFrameInfo *BasicSourceLineResolver::Module::FindCFIFrameInfo( - const StackFrame *frame) const { +CFIFrameInfo* BasicSourceLineResolver::Module::FindCFIFrameInfo( + const StackFrame* frame) const { MemAddr address = frame->instruction - frame->module->base_address(); MemAddr initial_base, initial_size; string initial_rules; @@ -347,9 +347,9 @@ CFIFrameInfo *BasicSourceLineResolver::Module::FindCFIFrameInfo( return rules.release(); } -bool BasicSourceLineResolver::Module::ParseFile(char *file_line) { +bool BasicSourceLineResolver::Module::ParseFile(char* file_line) { long index; - char *filename; + char* filename; if (SymbolParseHelper::ParseFile(file_line, &index, &filename)) { files_.insert(make_pair(index, string(filename))); return true; @@ -358,12 +358,12 @@ bool BasicSourceLineResolver::Module::ParseFile(char *file_line) { } BasicSourceLineResolver::Function* -BasicSourceLineResolver::Module::ParseFunction(char *function_line) { +BasicSourceLineResolver::Module::ParseFunction(char* function_line) { bool is_multiple; uint64_t address; uint64_t size; long stack_param_size; - char *name; + char* name; if (SymbolParseHelper::ParseFunction(function_line, &is_multiple, &address, &size, &stack_param_size, &name)) { return new Function(name, address, size, stack_param_size, is_multiple); @@ -372,7 +372,7 @@ BasicSourceLineResolver::Module::ParseFunction(char *function_line) { } BasicSourceLineResolver::Line* BasicSourceLineResolver::Module::ParseLine( - char *line_line) { + char* line_line) { uint64_t address; uint64_t size; long line_number; @@ -385,11 +385,11 @@ BasicSourceLineResolver::Line* BasicSourceLineResolver::Module::ParseLine( return NULL; } -bool BasicSourceLineResolver::Module::ParsePublicSymbol(char *public_line) { +bool BasicSourceLineResolver::Module::ParsePublicSymbol(char* public_line) { bool is_multiple; uint64_t address; long stack_param_size; - char *name; + char* name; if (SymbolParseHelper::ParsePublicSymbol(public_line, &is_multiple, &address, &stack_param_size, &name)) { @@ -411,7 +411,7 @@ bool BasicSourceLineResolver::Module::ParsePublicSymbol(char *public_line) { return false; } -bool BasicSourceLineResolver::Module::ParseStackInfo(char *stack_info_line) { +bool BasicSourceLineResolver::Module::ParseStackInfo(char* stack_info_line) { // Skip "STACK " prefix. stack_info_line += 6; @@ -419,7 +419,7 @@ bool BasicSourceLineResolver::Module::ParseStackInfo(char *stack_info_line) { // information this is. while (*stack_info_line == ' ') stack_info_line++; - const char *platform = stack_info_line; + const char* platform = stack_info_line; while (!strchr(kWhitespace, *stack_info_line)) stack_info_line++; *stack_info_line++ = '\0'; @@ -468,23 +468,23 @@ bool BasicSourceLineResolver::Module::ParseStackInfo(char *stack_info_line) { } bool BasicSourceLineResolver::Module::ParseCFIFrameInfo( - char *stack_info_line) { - char *cursor; + char* stack_info_line) { + char* cursor; // Is this an INIT record or a delta record? - char *init_or_address = strtok_r(stack_info_line, " \r\n", &cursor); + char* init_or_address = strtok_r(stack_info_line, " \r\n", &cursor); if (!init_or_address) return false; if (strcmp(init_or_address, "INIT") == 0) { // This record has the form "STACK INIT
". - char *address_field = strtok_r(NULL, " \r\n", &cursor); + char* address_field = strtok_r(NULL, " \r\n", &cursor); if (!address_field) return false; - char *size_field = strtok_r(NULL, " \r\n", &cursor); + char* size_field = strtok_r(NULL, " \r\n", &cursor); if (!size_field) return false; - char *initial_rules = strtok_r(NULL, "\r\n", &cursor); + char* initial_rules = strtok_r(NULL, "\r\n", &cursor); if (!initial_rules) return false; MemAddr address = strtoul(address_field, NULL, 16); @@ -494,8 +494,8 @@ bool BasicSourceLineResolver::Module::ParseCFIFrameInfo( } // This record has the form "STACK
". - char *address_field = init_or_address; - char *delta_rules = strtok_r(NULL, "\r\n", &cursor); + char* address_field = init_or_address; + char* delta_rules = strtok_r(NULL, "\r\n", &cursor); if (!delta_rules) return false; MemAddr address = strtoul(address_field, NULL, 16); cfi_delta_rules_[address] = delta_rules; @@ -503,8 +503,8 @@ bool BasicSourceLineResolver::Module::ParseCFIFrameInfo( } // static -bool SymbolParseHelper::ParseFile(char *file_line, long *index, - char **filename) { +bool SymbolParseHelper::ParseFile(char* file_line, long* index, + char** filename) { // FILE assert(strncmp(file_line, "FILE ", 5) == 0); file_line += 5; // skip prefix @@ -514,7 +514,7 @@ bool SymbolParseHelper::ParseFile(char *file_line, long *index, return false; } - char *after_number; + char* after_number; *index = strtol(tokens[0], &after_number, 10); if (!IsValidAfterNumber(after_number) || *index < 0 || *index == std::numeric_limits::max()) { @@ -530,9 +530,9 @@ bool SymbolParseHelper::ParseFile(char *file_line, long *index, } // static -bool SymbolParseHelper::ParseFunction(char *function_line, bool *is_multiple, - uint64_t *address, uint64_t *size, - long *stack_param_size, char **name) { +bool SymbolParseHelper::ParseFunction(char* function_line, bool* is_multiple, + uint64_t* address, uint64_t* size, + long* stack_param_size, char** name) { // FUNC []
assert(strncmp(function_line, "FUNC ", 5) == 0); function_line += 5; // skip prefix @@ -545,7 +545,7 @@ bool SymbolParseHelper::ParseFunction(char *function_line, bool *is_multiple, *is_multiple = strcmp(tokens[0], "m") == 0; int next_token = *is_multiple ? 1 : 0; - char *after_number; + char* after_number; *address = strtoull(tokens[next_token++], &after_number, 16); if (!IsValidAfterNumber(after_number) || *address == std::numeric_limits::max()) { @@ -568,16 +568,16 @@ bool SymbolParseHelper::ParseFunction(char *function_line, bool *is_multiple, } // static -bool SymbolParseHelper::ParseLine(char *line_line, uint64_t *address, - uint64_t *size, long *line_number, - long *source_file) { +bool SymbolParseHelper::ParseLine(char* line_line, uint64_t* address, + uint64_t* size, long* line_number, + long* source_file) { //
vector tokens; if (!Tokenize(line_line, kWhitespace, 4, &tokens)) { return false; } - char *after_number; + char* after_number; *address = strtoull(tokens[0], &after_number, 16); if (!IsValidAfterNumber(after_number) || *address == std::numeric_limits::max()) { @@ -613,10 +613,10 @@ bool SymbolParseHelper::ParseLine(char *line_line, uint64_t *address, } // static -bool SymbolParseHelper::ParsePublicSymbol(char *public_line, bool *is_multiple, - uint64_t *address, - long *stack_param_size, - char **name) { +bool SymbolParseHelper::ParsePublicSymbol(char* public_line, bool* is_multiple, + uint64_t* address, + long* stack_param_size, + char** name) { // PUBLIC []
assert(strncmp(public_line, "PUBLIC ", 7) == 0); public_line += 7; // skip prefix @@ -629,7 +629,7 @@ bool SymbolParseHelper::ParsePublicSymbol(char *public_line, bool *is_multiple, *is_multiple = strcmp(tokens[0], "m") == 0; int next_token = *is_multiple ? 1 : 0; - char *after_number; + char* after_number; *address = strtoull(tokens[next_token++], &after_number, 16); if (!IsValidAfterNumber(after_number) || *address == std::numeric_limits::max()) { @@ -647,7 +647,7 @@ bool SymbolParseHelper::ParsePublicSymbol(char *public_line, bool *is_multiple, } // static -bool SymbolParseHelper::IsValidAfterNumber(char *after_number) { +bool SymbolParseHelper::IsValidAfterNumber(char* after_number) { if (after_number != NULL && strchr(kWhitespace, *after_number) != NULL) { return true; } diff --git a/src/processor/basic_source_line_resolver_types.h b/src/processor/basic_source_line_resolver_types.h index 89eb57e8..c103040d 100644 --- a/src/processor/basic_source_line_resolver_types.h +++ b/src/processor/basic_source_line_resolver_types.h @@ -57,7 +57,7 @@ namespace google_breakpad { struct BasicSourceLineResolver::Function : public SourceLineResolverBase::Function { - Function(const string &function_name, + Function(const string& function_name, MemAddr function_address, MemAddr code_size, int set_parameter_size, @@ -75,7 +75,7 @@ BasicSourceLineResolver::Function : public SourceLineResolverBase::Function { class BasicSourceLineResolver::Module : public SourceLineResolverBase::Module { public: - explicit Module(const string &name) : name_(name), is_corrupt_(false) { } + explicit Module(const string& name) : name_(name), is_corrupt_(false) { } virtual ~Module() { } // Loads a map from the given buffer in char* type. @@ -83,7 +83,7 @@ class BasicSourceLineResolver::Module : public SourceLineResolverBase::Module { // The passed in |memory buffer| is of size |memory_buffer_size|. If it is // not null terminated, LoadMapFromMemory() will null terminate it by // modifying the passed in buffer. - virtual bool LoadMapFromMemory(char *memory_buffer, + virtual bool LoadMapFromMemory(char* memory_buffer, size_t memory_buffer_size); // Tells whether the loaded symbol data is corrupt. Return value is @@ -92,20 +92,20 @@ class BasicSourceLineResolver::Module : public SourceLineResolverBase::Module { // Looks up the given relative address, and fills the StackFrame struct // with the result. - virtual void LookupAddress(StackFrame *frame) const; + virtual void LookupAddress(StackFrame* frame) const; // If Windows stack walking information is available covering ADDRESS, // return a WindowsFrameInfo structure describing it. If the information // is not available, returns NULL. A NULL return value does not indicate // an error. The caller takes ownership of any returned WindowsFrameInfo // object. - virtual WindowsFrameInfo *FindWindowsFrameInfo(const StackFrame *frame) const; + virtual WindowsFrameInfo* FindWindowsFrameInfo(const StackFrame* frame) const; // If CFI stack walking information is available covering ADDRESS, // return a CFIFrameInfo structure describing it. If the information // is not available, return NULL. The caller takes ownership of any // returned CFIFrameInfo object. - virtual CFIFrameInfo *FindCFIFrameInfo(const StackFrame *frame) const; + virtual CFIFrameInfo* FindCFIFrameInfo(const StackFrame* frame) const; private: // Friend declarations. @@ -118,29 +118,29 @@ class BasicSourceLineResolver::Module : public SourceLineResolverBase::Module { // Logs parse errors. |*num_errors| is increased every time LogParseError is // called. static void LogParseError( - const string &message, + const string& message, int line_number, - int *num_errors); + int* num_errors); // Parses a file declaration - bool ParseFile(char *file_line); + bool ParseFile(char* file_line); // Parses a function declaration, returning a new Function object. - Function* ParseFunction(char *function_line); + Function* ParseFunction(char* function_line); // Parses a line declaration, returning a new Line object. - Line* ParseLine(char *line_line); + Line* ParseLine(char* line_line); // Parses a PUBLIC symbol declaration, storing it in public_symbols_. // Returns false if an error occurs. - bool ParsePublicSymbol(char *public_line); + bool ParsePublicSymbol(char* public_line); // Parses a STACK WIN or STACK CFI frame info declaration, storing // it in the appropriate table. - bool ParseStackInfo(char *stack_info_line); + bool ParseStackInfo(char* stack_info_line); // Parses a STACK CFI record, storing it in cfi_frame_info_. - bool ParseCFIFrameInfo(char *stack_info_line); + bool ParseCFIFrameInfo(char* stack_info_line); string name_; FileMap files_; diff --git a/src/processor/basic_source_line_resolver_unittest.cc b/src/processor/basic_source_line_resolver_unittest.cc index 90c34172..2cb2967c 100644 --- a/src/processor/basic_source_line_resolver_unittest.cc +++ b/src/processor/basic_source_line_resolver_unittest.cc @@ -83,15 +83,15 @@ class TestCodeModule : public CodeModule { class MockMemoryRegion: public MemoryRegion { uint64_t GetBase() const { return 0x10000; } uint32_t GetSize() const { return 0x01000; } - bool GetMemoryAtAddress(uint64_t address, uint8_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint8_t* value) const { *value = address & 0xff; return true; } - bool GetMemoryAtAddress(uint64_t address, uint16_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint16_t* value) const { *value = address & 0xffff; return true; } - bool GetMemoryAtAddress(uint64_t address, uint32_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint32_t* value) const { switch (address) { case 0x10008: *value = 0x98ecadc3; break; // saved %ebx case 0x1000c: *value = 0x878f7524; break; // saved %esi @@ -102,7 +102,7 @@ class MockMemoryRegion: public MemoryRegion { } return true; } - bool GetMemoryAtAddress(uint64_t address, uint64_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint64_t* value) const { *value = address; return true; } @@ -116,9 +116,9 @@ class MockMemoryRegion: public MemoryRegion { // EXPECTED's.) Also verify that ACTUAL has associations for ".ra" and // ".cfa". static bool VerifyRegisters( - const char *file, int line, - const CFIFrameInfo::RegisterValueMap &expected, - const CFIFrameInfo::RegisterValueMap &actual) { + const char* file, int line, + const CFIFrameInfo::RegisterValueMap& expected, + const CFIFrameInfo::RegisterValueMap& actual) { CFIFrameInfo::RegisterValueMap::const_iterator a; a = actual.find(".cfa"); if (a == actual.end()) @@ -148,7 +148,7 @@ static bool VerifyRegisters( } -static bool VerifyEmpty(const StackFrame &frame) { +static bool VerifyEmpty(const StackFrame& frame) { if (frame.function_name.empty() && frame.source_file_name.empty() && frame.source_line == 0) @@ -156,7 +156,7 @@ static bool VerifyEmpty(const StackFrame &frame) { return false; } -static void ClearSourceLineInfo(StackFrame *frame) { +static void ClearSourceLineInfo(StackFrame* frame) { frame->function_name.clear(); frame->module = NULL; frame->source_file_name.clear(); @@ -417,7 +417,7 @@ TEST_F(TestBasicSourceLineResolver, TestUnload) // FILE TEST(SymbolParseHelper, ParseFileValid) { long index; - char *filename; + char* filename; char kTestLine[] = "FILE 1 file name"; ASSERT_TRUE(SymbolParseHelper::ParseFile(kTestLine, &index, &filename)); @@ -435,7 +435,7 @@ TEST(SymbolParseHelper, ParseFileValid) { // FILE TEST(SymbolParseHelper, ParseFileInvalid) { long index; - char *filename; + char* filename; // Test missing file name. char kTestLine[] = "FILE 1 "; @@ -461,7 +461,7 @@ TEST(SymbolParseHelper, ParseFunctionValid) { uint64_t address; uint64_t size; long stack_param_size; - char *name; + char* name; char kTestLine[] = "FUNC 1 2 3 function name"; ASSERT_TRUE(SymbolParseHelper::ParseFunction(kTestLine, &multiple, &address, @@ -513,7 +513,7 @@ TEST(SymbolParseHelper, ParseFunctionInvalid) { uint64_t address; uint64_t size; long stack_param_size; - char *name; + char* name; // Test missing function name. char kTestLine[] = "FUNC 1 2 3 "; @@ -649,7 +649,7 @@ TEST(SymbolParseHelper, ParsePublicSymbolValid) { bool multiple; uint64_t address; long stack_param_size; - char *name; + char* name; char kTestLine[] = "PUBLIC 1 2 3"; ASSERT_TRUE(SymbolParseHelper::ParsePublicSymbol(kTestLine, &multiple, @@ -697,7 +697,7 @@ TEST(SymbolParseHelper, ParsePublicSymbolInvalid) { bool multiple; uint64_t address; long stack_param_size; - char *name; + char* name; // Test missing source function name. char kTestLine[] = "PUBLIC 1 2 "; @@ -738,7 +738,7 @@ TEST(SymbolParseHelper, ParsePublicSymbolInvalid) { } // namespace -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/src/processor/call_stack.cc b/src/processor/call_stack.cc index 925f0846..f219e843 100644 --- a/src/processor/call_stack.cc +++ b/src/processor/call_stack.cc @@ -43,7 +43,7 @@ CallStack::~CallStack() { } void CallStack::Clear() { - for (vector::const_iterator iterator = frames_.begin(); + for (vector::const_iterator iterator = frames_.begin(); iterator != frames_.end(); ++iterator) { delete *iterator; diff --git a/src/processor/cfi_frame_info-inl.h b/src/processor/cfi_frame_info-inl.h index 7e7af0af..52d2f5fc 100644 --- a/src/processor/cfi_frame_info-inl.h +++ b/src/processor/cfi_frame_info-inl.h @@ -42,12 +42,12 @@ namespace google_breakpad { template bool SimpleCFIWalker::FindCallerRegisters( - const MemoryRegion &memory, - const CFIFrameInfo &cfi_frame_info, - const RawContextType &callee_context, + const MemoryRegion& memory, + const CFIFrameInfo& cfi_frame_info, + const RawContextType& callee_context, int callee_validity, - RawContextType *caller_context, - int *caller_validity) const { + RawContextType* caller_context, + int* caller_validity) const { typedef CFIFrameInfo::RegisterValueMap ValueMap; ValueMap callee_registers; ValueMap caller_registers; @@ -56,7 +56,7 @@ bool SimpleCFIWalker::FindCallerRegisters( // Populate callee_registers with register values from callee_context. for (size_t i = 0; i < map_size_; i++) { - const RegisterSet &r = register_map_[i]; + const RegisterSet& r = register_map_[i]; if (callee_validity & r.validity_flag) callee_registers[r.name] = callee_context.*r.context_member; } @@ -71,7 +71,7 @@ bool SimpleCFIWalker::FindCallerRegisters( memset(caller_context, 0xda, sizeof(*caller_context)); *caller_validity = 0; for (size_t i = 0; i < map_size_; i++) { - const RegisterSet &r = register_map_[i]; + const RegisterSet& r = register_map_[i]; typename ValueMap::const_iterator caller_entry; // Did the rules provide a value for this register by its name? diff --git a/src/processor/cfi_frame_info.cc b/src/processor/cfi_frame_info.cc index 0c4af7ba..280620f2 100644 --- a/src/processor/cfi_frame_info.cc +++ b/src/processor/cfi_frame_info.cc @@ -48,9 +48,9 @@ namespace google_breakpad { #endif template -bool CFIFrameInfo::FindCallerRegs(const RegisterValueMap ®isters, - const MemoryRegion &memory, - RegisterValueMap *caller_registers) const { +bool CFIFrameInfo::FindCallerRegs(const RegisterValueMap& registers, + const MemoryRegion& memory, + RegisterValueMap* caller_registers) const { // If there are not rules for both .ra and .cfa in effect at this address, // don't use this CFI data for stack walking. if (cfa_rule_.empty() || ra_rule_.empty()) @@ -93,13 +93,13 @@ bool CFIFrameInfo::FindCallerRegs(const RegisterValueMap ®isters, // Explicit instantiations for 32-bit and 64-bit architectures. template bool CFIFrameInfo::FindCallerRegs( - const RegisterValueMap ®isters, - const MemoryRegion &memory, - RegisterValueMap *caller_registers) const; + const RegisterValueMap& registers, + const MemoryRegion& memory, + RegisterValueMap* caller_registers) const; template bool CFIFrameInfo::FindCallerRegs( - const RegisterValueMap ®isters, - const MemoryRegion &memory, - RegisterValueMap *caller_registers) const; + const RegisterValueMap& registers, + const MemoryRegion& memory, + RegisterValueMap* caller_registers) const; string CFIFrameInfo::Serialize() const { std::ostringstream stream; @@ -123,7 +123,7 @@ string CFIFrameInfo::Serialize() const { return stream.str(); } -bool CFIRuleParser::Parse(const string &rule_set) { +bool CFIRuleParser::Parse(const string& rule_set) { size_t rule_set_len = rule_set.size(); scoped_array working_copy(new char[rule_set_len + 1]); memcpy(working_copy.get(), rule_set.data(), rule_set_len); @@ -132,9 +132,9 @@ bool CFIRuleParser::Parse(const string &rule_set) { name_.clear(); expression_.clear(); - char *cursor; + char* cursor; static const char token_breaks[] = " \t\r\n"; - char *token = strtok_r(working_copy.get(), token_breaks, &cursor); + char* token = strtok_r(working_copy.get(), token_breaks, &cursor); for (;;) { // End of rule set? @@ -170,16 +170,16 @@ bool CFIRuleParser::Report() { return true; } -void CFIFrameInfoParseHandler::CFARule(const string &expression) { +void CFIFrameInfoParseHandler::CFARule(const string& expression) { frame_info_->SetCFARule(expression); } -void CFIFrameInfoParseHandler::RARule(const string &expression) { +void CFIFrameInfoParseHandler::RARule(const string& expression) { frame_info_->SetRARule(expression); } -void CFIFrameInfoParseHandler::RegisterRule(const string &name, - const string &expression) { +void CFIFrameInfoParseHandler::RegisterRule(const string& name, + const string& expression) { frame_info_->SetRegisterRule(name, expression); } diff --git a/src/processor/cfi_frame_info.h b/src/processor/cfi_frame_info.h index 90a1b3d7..2bc93336 100644 --- a/src/processor/cfi_frame_info.h +++ b/src/processor/cfi_frame_info.h @@ -72,9 +72,9 @@ class CFIFrameInfo { // Set the expression for computing a call frame address, return // address, or register's value. At least the CFA rule and the RA // rule must be set before calling FindCallerRegs. - void SetCFARule(const string &expression) { cfa_rule_ = expression; } - void SetRARule(const string &expression) { ra_rule_ = expression; } - void SetRegisterRule(const string ®ister_name, const string &expression) { + void SetCFARule(const string& expression) { cfa_rule_ = expression; } + void SetRARule(const string& expression) { ra_rule_ = expression; } + void SetRegisterRule(const string& register_name, const string& expression) { register_rules_[register_name] = expression; } @@ -96,9 +96,9 @@ class CFIFrameInfo { // These may be helpful in computing the caller's PC and stack // pointer, if their values are not explicitly specified. template - bool FindCallerRegs(const RegisterValueMap ®isters, - const MemoryRegion &memory, - RegisterValueMap *caller_registers) const; + bool FindCallerRegs(const RegisterValueMap& registers, + const MemoryRegion& memory, + RegisterValueMap* caller_registers) const; // Serialize the rules in this object into a string in the format // of STACK CFI records. @@ -148,28 +148,28 @@ class CFIRuleParser { virtual ~Handler() { } // The input specifies EXPRESSION as the CFA/RA computation rule. - virtual void CFARule(const string &expression) = 0; - virtual void RARule(const string &expression) = 0; + virtual void CFARule(const string& expression) = 0; + virtual void RARule(const string& expression) = 0; // The input specifies EXPRESSION as the recovery rule for register NAME. - virtual void RegisterRule(const string &name, const string &expression) = 0; + virtual void RegisterRule(const string& name, const string& expression) = 0; }; // Construct a parser which feeds its results to HANDLER. - CFIRuleParser(Handler *handler) : handler_(handler) { } + CFIRuleParser(Handler* handler) : handler_(handler) { } // Parse RULE_SET as a set of CFA computation and RA/register // recovery rules, as appearing in STACK CFI records. Report the // results of parsing by making the appropriate calls to handler_. // Return true if parsing was successful, false otherwise. - bool Parse(const string &rule_set); + bool Parse(const string& rule_set); private: // Report any accumulated rule to handler_ bool Report(); // The handler to which the parser reports its findings. - Handler *handler_; + Handler* handler_; // Working data. string name_, expression_; @@ -180,15 +180,15 @@ class CFIRuleParser { class CFIFrameInfoParseHandler: public CFIRuleParser::Handler { public: // Populate FRAME_INFO with the results of parsing. - CFIFrameInfoParseHandler(CFIFrameInfo *frame_info) + CFIFrameInfoParseHandler(CFIFrameInfo* frame_info) : frame_info_(frame_info) { } - void CFARule(const string &expression); - void RARule(const string &expression); - void RegisterRule(const string &name, const string &expression); + void CFARule(const string& expression); + void RARule(const string& expression); + void RegisterRule(const string& name, const string& expression); private: - CFIFrameInfo *frame_info_; + CFIFrameInfo* frame_info_; }; // A utility class template for simple 'STACK CFI'-driven stack walkers. @@ -212,14 +212,14 @@ class SimpleCFIWalker { // A structure describing one architecture register. struct RegisterSet { // The register name, as it appears in STACK CFI rules. - const char *name; + const char* name; // An alternate name that the register's value might be found // under in a register value dictionary, or NULL. When generating // names, prefer NAME to this value. It's common to list ".cfa" as // an alternative name for the stack pointer, and ".ra" as an // alternative name for the instruction pointer. - const char *alternate_name; + const char* alternate_name; // True if the callee is expected to preserve the value of this // register. If this flag is true for some register R, and the STACK @@ -240,7 +240,7 @@ class SimpleCFIWalker { // architecture's register set. REGISTER_MAP is an array of // RegisterSet structures; MAP_SIZE is the number of elements in the // array. - SimpleCFIWalker(const RegisterSet *register_map, size_t map_size) + SimpleCFIWalker(const RegisterSet* register_map, size_t map_size) : register_map_(register_map), map_size_(map_size) { } // Compute the calling frame's raw context given the callee's raw @@ -256,15 +256,15 @@ class SimpleCFIWalker { // fill in CALLER_CONTEXT with the caller's register values, and set // CALLER_VALIDITY to indicate which registers are valid in // CALLER_CONTEXT. Return true on success, or false on failure. - bool FindCallerRegisters(const MemoryRegion &memory, - const CFIFrameInfo &cfi_frame_info, - const RawContextType &callee_context, + bool FindCallerRegisters(const MemoryRegion& memory, + const CFIFrameInfo& cfi_frame_info, + const RawContextType& callee_context, int callee_validity, - RawContextType *caller_context, - int *caller_validity) const; + RawContextType* caller_context, + int* caller_validity) const; private: - const RegisterSet *register_map_; + const RegisterSet* register_map_; size_t map_size_; }; diff --git a/src/processor/cfi_frame_info_unittest.cc b/src/processor/cfi_frame_info_unittest.cc index 542b2849..8111437a 100644 --- a/src/processor/cfi_frame_info_unittest.cc +++ b/src/processor/cfi_frame_info_unittest.cc @@ -56,10 +56,10 @@ class MockMemoryRegion: public MemoryRegion { public: MOCK_CONST_METHOD0(GetBase, uint64_t()); MOCK_CONST_METHOD0(GetSize, uint32_t()); - MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(uint64_t, uint8_t *)); - MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(uint64_t, uint16_t *)); - MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(uint64_t, uint32_t *)); - MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(uint64_t, uint64_t *)); + MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(uint64_t, uint8_t*)); + MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(uint64_t, uint16_t*)); + MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(uint64_t, uint32_t*)); + MOCK_CONST_METHOD2(GetMemoryAtAddress, bool(uint64_t, uint64_t*)); MOCK_CONST_METHOD0(Print, void()); }; @@ -70,10 +70,10 @@ struct CFIFixture { void ExpectNoMemoryReferences() { EXPECT_CALL(memory, GetBase()).Times(0); EXPECT_CALL(memory, GetSize()).Times(0); - EXPECT_CALL(memory, GetMemoryAtAddress(_, A())).Times(0); - EXPECT_CALL(memory, GetMemoryAtAddress(_, A())).Times(0); - EXPECT_CALL(memory, GetMemoryAtAddress(_, A())).Times(0); - EXPECT_CALL(memory, GetMemoryAtAddress(_, A())).Times(0); + EXPECT_CALL(memory, GetMemoryAtAddress(_, A())).Times(0); + EXPECT_CALL(memory, GetMemoryAtAddress(_, A())).Times(0); + EXPECT_CALL(memory, GetMemoryAtAddress(_, A())).Times(0); + EXPECT_CALL(memory, GetMemoryAtAddress(_, A())).Times(0); } CFIFrameInfo cfi; @@ -292,9 +292,9 @@ TEST_F(Scope, SeparateTempsRA) { class MockCFIRuleParserHandler: public CFIRuleParser::Handler { public: - MOCK_METHOD1(CFARule, void(const string &)); - MOCK_METHOD1(RARule, void(const string &)); - MOCK_METHOD2(RegisterRule, void(const string &, const string &)); + MOCK_METHOD1(CFARule, void(const string&)); + MOCK_METHOD1(RARule, void(const string&)); + MOCK_METHOD2(RegisterRule, void(const string&, const string&)); }; // A fixture class for testing CFIRuleParser. @@ -509,12 +509,12 @@ TEST_F(SimpleWalker, Walk) { // Saved r0. EXPECT_CALL(memory, - GetMemoryAtAddress(stack_top, A())) + GetMemoryAtAddress(stack_top, A())) .WillRepeatedly(DoAll(SetArgumentPointee<1>(0xdc1975eba8602302ULL), Return(true))); // Saved return address. EXPECT_CALL(memory, - GetMemoryAtAddress(stack_top + 16, A())) + GetMemoryAtAddress(stack_top + 16, A())) .WillRepeatedly(DoAll(SetArgumentPointee<1>(0xba5ad6d9acce28deULL), Return(true))); diff --git a/src/processor/contained_range_map-inl.h b/src/processor/contained_range_map-inl.h index 4c0ad41f..edd11d7c 100644 --- a/src/processor/contained_range_map-inl.h +++ b/src/processor/contained_range_map-inl.h @@ -55,7 +55,7 @@ ContainedRangeMap::~ContainedRangeMap() { template bool ContainedRangeMap::StoreRange( - const AddressType &base, const AddressType &size, const EntryType &entry) { + const AddressType& base, const AddressType& size, const EntryType& entry) { AddressType high = base + size - 1; // Check for undersize or overflow. @@ -125,7 +125,7 @@ bool ContainedRangeMap::StoreRange( // Optimization: if the iterators are equal, no child ranges would be // moved. Create the new child range with a NULL map to conserve space // in leaf nodes, of which there will be many. - AddressToRangeMap *child_map = NULL; + AddressToRangeMap* child_map = NULL; if (iterator_base != iterator_high) { // The children of this range that are contained by the new range must @@ -149,7 +149,7 @@ bool ContainedRangeMap::StoreRange( template bool ContainedRangeMap::RetrieveRange( - const AddressType &address, EntryType *entry) const { + const AddressType& address, EntryType* entry) const { BPLOG_IF(ERROR, !entry) << "ContainedRangeMap::RetrieveRange requires " "|entry|"; assert(entry); diff --git a/src/processor/contained_range_map.h b/src/processor/contained_range_map.h index 1015ae8c..18d03af7 100644 --- a/src/processor/contained_range_map.h +++ b/src/processor/contained_range_map.h @@ -86,16 +86,16 @@ class ContainedRangeMap { // grandchildren of this ContainedRangeMap. Returns false for a // parameter error, or if the ContainedRangeMap hierarchy guarantees // would be violated. - bool StoreRange(const AddressType &base, - const AddressType &size, - const EntryType &entry); + bool StoreRange(const AddressType& base, + const AddressType& size, + const EntryType& entry); // Retrieves the most specific (smallest) descendant range encompassing // the specified address. This method will only return entries held by // child ranges, and not the entry contained by |this|. This is necessary // to support a sparsely-populated root range. If no descendant range // encompasses the address, returns false. - bool RetrieveRange(const AddressType &address, EntryType *entry) const; + bool RetrieveRange(const AddressType& address, EntryType* entry) const; // Removes all children. Note that Clear only removes descendants, // leaving the node on which it is called intact. Because the only @@ -110,7 +110,7 @@ class ContainedRangeMap { // AddressToRangeMap stores pointers. This makes reparenting simpler in // StoreRange, because it doesn't need to copy entire objects. - typedef std::map AddressToRangeMap; + typedef std::map AddressToRangeMap; typedef typename AddressToRangeMap::const_iterator MapConstIterator; typedef typename AddressToRangeMap::iterator MapIterator; typedef typename AddressToRangeMap::value_type MapValue; @@ -118,8 +118,8 @@ class ContainedRangeMap { // Creates a new ContainedRangeMap with the specified base address, entry, // and initial child map, which may be NULL. This is only used internally // by ContainedRangeMap when it creates a new child. - ContainedRangeMap(const AddressType &base, const EntryType &entry, - AddressToRangeMap *map) + ContainedRangeMap(const AddressType& base, const EntryType& entry, + AddressToRangeMap* map) : base_(base), entry_(entry), map_(map) {} // The base address of this range. The high address does not need to @@ -140,7 +140,7 @@ class ContainedRangeMap { // The map containing child ranges, keyed by each child range's high // address. This is a pointer to avoid allocating map structures for // leaf nodes, where they are not needed. - AddressToRangeMap *map_; + AddressToRangeMap* map_; }; diff --git a/src/processor/contained_range_map_unittest.cc b/src/processor/contained_range_map_unittest.cc index e5910da0..a97c5d0f 100644 --- a/src/processor/contained_range_map_unittest.cc +++ b/src/processor/contained_range_map_unittest.cc @@ -256,7 +256,7 @@ static bool RunTests() { } // namespace -int main(int argc, char **argv) { +int main(int argc, char** argv) { BPLOG_INIT(&argc, &argv); return RunTests() ? 0 : 1; diff --git a/src/processor/disassembler_x86.cc b/src/processor/disassembler_x86.cc index 55902240..01267678 100644 --- a/src/processor/disassembler_x86.cc +++ b/src/processor/disassembler_x86.cc @@ -30,7 +30,7 @@ namespace google_breakpad { -DisassemblerX86::DisassemblerX86(const uint8_t *bytecode, +DisassemblerX86::DisassemblerX86(const uint8_t* bytecode, uint32_t size, uint32_t virtual_address) : bytecode_(bytecode), @@ -62,7 +62,7 @@ uint32_t DisassemblerX86::NextInstruction() { return 0; } uint32_t instr_size = 0; - instr_size = libdis::x86_disasm((unsigned char *)bytecode_, size_, + instr_size = libdis::x86_disasm((unsigned char*)bytecode_, size_, virtual_address_, current_byte_offset_, ¤t_instr_); if (instr_size == 0) { @@ -78,8 +78,8 @@ uint32_t DisassemblerX86::NextInstruction() { if (current_instr_.type == libdis::insn_return) end_of_block_ = true; - libdis::x86_op_t *src = libdis::x86_get_src_operand(¤t_instr_); - libdis::x86_op_t *dest = libdis::x86_get_dest_operand(¤t_instr_); + libdis::x86_op_t* src = libdis::x86_get_src_operand(¤t_instr_); + libdis::x86_op_t* dest = libdis::x86_get_dest_operand(¤t_instr_); if (register_valid_) { switch (current_instr_.group) { @@ -213,7 +213,7 @@ bool DisassemblerX86::setBadRead() { if (!instr_valid_) return false; - libdis::x86_op_t *operand = libdis::x86_get_src_operand(¤t_instr_); + libdis::x86_op_t* operand = libdis::x86_get_src_operand(¤t_instr_); if (!operand || operand->type != libdis::op_expression) return false; @@ -227,7 +227,7 @@ bool DisassemblerX86::setBadWrite() { if (!instr_valid_) return false; - libdis::x86_op_t *operand = libdis::x86_get_dest_operand(¤t_instr_); + libdis::x86_op_t* operand = libdis::x86_get_dest_operand(¤t_instr_); if (!operand || operand->type != libdis::op_expression) return false; diff --git a/src/processor/disassembler_x86.h b/src/processor/disassembler_x86.h index 71069410..ca65b6e8 100644 --- a/src/processor/disassembler_x86.h +++ b/src/processor/disassembler_x86.h @@ -63,7 +63,7 @@ class DisassemblerX86 { // TODO(cdn): Modify this class to take a MemoryRegion instead of just // a raw buffer. This will make it easier to use this on arbitrary // minidumps without first copying out the code segment. - DisassemblerX86(const uint8_t *bytecode, uint32_t, uint32_t); + DisassemblerX86(const uint8_t* bytecode, uint32_t, uint32_t); ~DisassemblerX86(); // This walks to the next instruction in the memory region and @@ -102,7 +102,7 @@ class DisassemblerX86 { bool setBadWrite(); protected: - const uint8_t *bytecode_; + const uint8_t* bytecode_; uint32_t size_; uint32_t virtual_address_; uint32_t current_byte_offset_; diff --git a/src/processor/exploitability_linux.cc b/src/processor/exploitability_linux.cc index ccc9f145..798056df 100644 --- a/src/processor/exploitability_linux.cc +++ b/src/processor/exploitability_linux.cc @@ -77,13 +77,13 @@ const unsigned int MAX_OBJDUMP_BUFFER_LEN = 4096; namespace google_breakpad { -ExploitabilityLinux::ExploitabilityLinux(Minidump *dump, - ProcessState *process_state) +ExploitabilityLinux::ExploitabilityLinux(Minidump* dump, + ProcessState* process_state) : Exploitability(dump, process_state), enable_objdump_(false) { } -ExploitabilityLinux::ExploitabilityLinux(Minidump *dump, - ProcessState *process_state, +ExploitabilityLinux::ExploitabilityLinux(Minidump* dump, + ProcessState* process_state, bool enable_objdump) : Exploitability(dump, process_state), enable_objdump_(enable_objdump) { } @@ -111,12 +111,12 @@ ExploitabilityRating ExploitabilityLinux::CheckPlatformExploitability() { } // Getting exception data. (It should exist for all minidumps.) - MinidumpException *exception = dump_->GetException(); + MinidumpException* exception = dump_->GetException(); if (exception == NULL) { BPLOG(INFO) << "No exception record."; return EXPLOITABILITY_ERR_PROCESSING; } - const MDRawExceptionStream *raw_exception_stream = exception->exception(); + const MDRawExceptionStream* raw_exception_stream = exception->exception(); if (raw_exception_stream == NULL) { BPLOG(INFO) << "No raw exception stream."; return EXPLOITABILITY_ERR_PROCESSING; @@ -132,7 +132,7 @@ ExploitabilityRating ExploitabilityLinux::CheckPlatformExploitability() { uint64_t instruction_ptr = 0; uint64_t stack_ptr = 0; - const MinidumpContext *context = exception->GetContext(); + const MinidumpContext* context = exception->GetContext(); if (context == NULL) { BPLOG(INFO) << "No exception context."; return EXPLOITABILITY_ERR_PROCESSING; @@ -174,8 +174,8 @@ bool ExploitabilityLinux::EndedOnIllegalWrite(uint64_t instruction_ptr) { BPLOG(INFO) << "MinGW does not support fork and exec. Terminating method."; #else // Get memory region containing instruction pointer. - MinidumpMemoryList *memory_list = dump_->GetMemoryList(); - MinidumpMemoryRegion *memory_region = + MinidumpMemoryList* memory_list = dump_->GetMemoryList(); + MinidumpMemoryRegion* memory_region = memory_list ? memory_list->GetMemoryRegionForAddress(instruction_ptr) : NULL; if (!memory_region) { @@ -185,15 +185,15 @@ bool ExploitabilityLinux::EndedOnIllegalWrite(uint64_t instruction_ptr) { // Get exception data to find architecture. string architecture = ""; - MinidumpException *exception = dump_->GetException(); + MinidumpException* exception = dump_->GetException(); // This should never evaluate to true, since this should not be reachable // without checking for exception data earlier. if (!exception) { BPLOG(INFO) << "No exception data."; return false; } - const MDRawExceptionStream *raw_exception_stream = exception->exception(); - const MinidumpContext *context = exception->GetContext(); + const MDRawExceptionStream* raw_exception_stream = exception->exception(); + const MinidumpContext* context = exception->GetContext(); // This should not evaluate to true, for the same reason mentioned above. if (!raw_exception_stream || !context) { BPLOG(INFO) << "No exception or architecture data."; @@ -217,7 +217,7 @@ bool ExploitabilityLinux::EndedOnIllegalWrite(uint64_t instruction_ptr) { // Get memory region around instruction pointer and the number of bytes // before and after the instruction pointer in the memory region. - const uint8_t *raw_memory = memory_region->GetMemory(); + const uint8_t* raw_memory = memory_region->GetMemory(); const uint64_t base = memory_region->GetBase(); if (base > instruction_ptr) { BPLOG(ERROR) << "Memory region base value exceeds instruction pointer."; @@ -275,9 +275,9 @@ bool ExploitabilityLinux::EndedOnIllegalWrite(uint64_t instruction_ptr) { } #ifndef _WIN32 -bool ExploitabilityLinux::CalculateAddress(const string &address_expression, - const DumpContext &context, - uint64_t *write_address) { +bool ExploitabilityLinux::CalculateAddress(const string& address_expression, + const DumpContext& context, + uint64_t* write_address) { // The destination should be the format reg+a or reg-a, where reg // is a register and a is a hexadecimal constant. Although more complex // expressions can make valid instructions, objdump's disassembly outputs @@ -395,8 +395,8 @@ bool ExploitabilityLinux::CalculateAddress(const string &address_expression, // static bool ExploitabilityLinux::GetObjdumpInstructionLine( - const char *objdump_output_buffer, - string *instruction_line) { + const char* objdump_output_buffer, + string* instruction_line) { // Put buffer data into stream to output line-by-line. std::stringstream objdump_stream; objdump_stream.str(string(objdump_output_buffer)); @@ -420,10 +420,10 @@ bool ExploitabilityLinux::GetObjdumpInstructionLine( return true; } -bool ExploitabilityLinux::TokenizeObjdumpInstruction(const string &line, - string *operation, - string *dest, - string *src) { +bool ExploitabilityLinux::TokenizeObjdumpInstruction(const string& line, + string* operation, + string* dest, + string* src) { if (!operation || !dest || !src) { BPLOG(ERROR) << "Null parameters passed."; return false; @@ -483,10 +483,10 @@ bool ExploitabilityLinux::TokenizeObjdumpInstruction(const string &line, return true; } -bool ExploitabilityLinux::DisassembleBytes(const string &architecture, - const uint8_t *raw_bytes, +bool ExploitabilityLinux::DisassembleBytes(const string& architecture, + const uint8_t* raw_bytes, const unsigned int buffer_len, - char *objdump_output_buffer) { + char* objdump_output_buffer) { if (!raw_bytes || !objdump_output_buffer) { BPLOG(ERROR) << "Bad input parameters."; return false; @@ -514,7 +514,7 @@ bool ExploitabilityLinux::DisassembleBytes(const string &architecture, "objdump -D -b binary -M intel -m %s %s", architecture.c_str(), raw_bytes_tmpfile); - FILE *objdump_fp = popen(cmd, "r"); + FILE* objdump_fp = popen(cmd, "r"); if (!objdump_fp) { fclose(objdump_fp); unlink(raw_bytes_tmpfile); @@ -534,12 +534,12 @@ bool ExploitabilityLinux::DisassembleBytes(const string &architecture, #endif // _WIN32 bool ExploitabilityLinux::StackPointerOffStack(uint64_t stack_ptr) { - MinidumpLinuxMapsList *linux_maps_list = dump_->GetLinuxMapsList(); + MinidumpLinuxMapsList* linux_maps_list = dump_->GetLinuxMapsList(); // Inconclusive if there are no mappings available. if (!linux_maps_list) { return false; } - const MinidumpLinuxMaps *linux_maps = + const MinidumpLinuxMaps* linux_maps = linux_maps_list->GetLinuxMapsForAddress(stack_ptr); // Checks if the stack pointer maps to a valid mapping and if the mapping // is not the stack. If the mapping has no name, it is inconclusive whether @@ -550,10 +550,10 @@ bool ExploitabilityLinux::StackPointerOffStack(uint64_t stack_ptr) { } bool ExploitabilityLinux::ExecutableStackOrHeap() { - MinidumpLinuxMapsList *linux_maps_list = dump_->GetLinuxMapsList(); + MinidumpLinuxMapsList* linux_maps_list = dump_->GetLinuxMapsList(); if (linux_maps_list) { for (size_t i = 0; i < linux_maps_list->get_maps_count(); i++) { - const MinidumpLinuxMaps *linux_maps = + const MinidumpLinuxMaps* linux_maps = linux_maps_list->GetLinuxMapsAtIndex(i); // Check for executable stack or heap for each mapping. if (linux_maps && (!linux_maps->GetPathname().compare( @@ -574,15 +574,15 @@ bool ExploitabilityLinux::InstructionPointerInCode(uint64_t instruction_ptr) { // whether it is in a valid code region. If there is no mapping for the // instruction pointer, it is indicative that the instruction pointer is // not within a module, which implies that it is outside a valid area. - MinidumpLinuxMapsList *linux_maps_list = dump_->GetLinuxMapsList(); - const MinidumpLinuxMaps *linux_maps = + MinidumpLinuxMapsList* linux_maps_list = dump_->GetLinuxMapsList(); + const MinidumpLinuxMaps* linux_maps = linux_maps_list ? linux_maps_list->GetLinuxMapsForAddress(instruction_ptr) : NULL; return linux_maps ? linux_maps->IsExecutable() : false; } -bool ExploitabilityLinux::BenignCrashTrigger(const MDRawExceptionStream - *raw_exception_stream) { +bool ExploitabilityLinux::BenignCrashTrigger( + const MDRawExceptionStream* raw_exception_stream) { // Check the cause of crash. // If the exception of the crash is a benign exception, // it is probably not exploitable. diff --git a/src/processor/exploitability_linux.h b/src/processor/exploitability_linux.h index e3ff13b6..36647959 100644 --- a/src/processor/exploitability_linux.h +++ b/src/processor/exploitability_linux.h @@ -44,8 +44,8 @@ namespace google_breakpad { class ExploitabilityLinux : public Exploitability { public: - ExploitabilityLinux(Minidump *dump, - ProcessState *process_state); + ExploitabilityLinux(Minidump* dump, + ProcessState* process_state); // Parameters are the minidump to analyze, the object representing process // state, and whether to enable objdump disassembly. @@ -53,8 +53,8 @@ class ExploitabilityLinux : public Exploitability { // objdump for diassembly. It is used to check the identity of the // instruction that caused the program to crash. If there are any // portability concerns, this should not be enabled. - ExploitabilityLinux(Minidump *dump, - ProcessState *process_state, + ExploitabilityLinux(Minidump* dump, + ProcessState* process_state, bool enable_objdump); virtual ExploitabilityRating CheckPlatformExploitability(); @@ -68,7 +68,7 @@ class ExploitabilityLinux : public Exploitability { // Checks the exception that triggered the creation of the // minidump and reports whether the exception suggests no exploitability. - bool BenignCrashTrigger(const MDRawExceptionStream *raw_exception_stream); + bool BenignCrashTrigger(const MDRawExceptionStream* raw_exception_stream); // This method checks if the crash occurred during a write to read-only or // invalid memory. It does so by checking if the instruction at the @@ -81,34 +81,34 @@ class ExploitabilityLinux : public Exploitability { // buffer, given the desired architecture, the file from which objdump will // read, and the buffer length. The method returns whether the disassembly // was a success, and the caller owns all pointers. - static bool DisassembleBytes(const string &architecture, - const uint8_t *raw_bytes, + static bool DisassembleBytes(const string& architecture, + const uint8_t* raw_bytes, const unsigned int MAX_OBJDUMP_BUFFER_LEN, - char *objdump_output_buffer); + char* objdump_output_buffer); // Parses the objdump output given in |objdump_output_buffer| and extracts // the line of the first instruction into |instruction_line|. Returns true // when the instruction line is successfully extracted. static bool GetObjdumpInstructionLine( - const char *objdump_output_buffer, - string *instruction_line); + const char* objdump_output_buffer, + string* instruction_line); // Tokenizes out the operation and operands from a line of instruction // disassembled by objdump. This method modifies the pointers to match the // tokens of the instruction, and returns if the tokenizing was a success. // The caller owns all pointers. - static bool TokenizeObjdumpInstruction(const string &line, - string *operation, - string *dest, - string *src); + static bool TokenizeObjdumpInstruction(const string& line, + string* operation, + string* dest, + string* src); // Calculates the effective address of an expression in the form reg+a or // reg-a, where 'reg' is a register and 'a' is a constant, and writes the // result in the pointer. The method returns whether the calculation was // a success. The caller owns the pointer. - static bool CalculateAddress(const string &address_expression, - const DumpContext &context, - uint64_t *write_address); + static bool CalculateAddress(const string& address_expression, + const DumpContext& context, + uint64_t* write_address); #endif // _WIN32 // Checks if the stack pointer points to a memory mapping that is not diff --git a/src/processor/exploitability_win.cc b/src/processor/exploitability_win.cc index a1f8703a..b74a7496 100644 --- a/src/processor/exploitability_win.cc +++ b/src/processor/exploitability_win.cc @@ -69,30 +69,30 @@ static const size_t kHugeBump = 90; // The maximum number of bytes to disassemble past the program counter. static const size_t kDisassembleBytesBeyondPC = 2048; -ExploitabilityWin::ExploitabilityWin(Minidump *dump, - ProcessState *process_state) +ExploitabilityWin::ExploitabilityWin(Minidump* dump, + ProcessState* process_state) : Exploitability(dump, process_state) { } ExploitabilityRating ExploitabilityWin::CheckPlatformExploitability() { - MinidumpException *exception = dump_->GetException(); + MinidumpException* exception = dump_->GetException(); if (!exception) { BPLOG(INFO) << "Minidump does not have exception record."; return EXPLOITABILITY_ERR_PROCESSING; } - const MDRawExceptionStream *raw_exception = exception->exception(); + const MDRawExceptionStream* raw_exception = exception->exception(); if (!raw_exception) { BPLOG(INFO) << "Could not obtain raw exception info."; return EXPLOITABILITY_ERR_PROCESSING; } - const MinidumpContext *context = exception->GetContext(); + const MinidumpContext* context = exception->GetContext(); if (!context) { BPLOG(INFO) << "Could not obtain exception context."; return EXPLOITABILITY_ERR_PROCESSING; } - MinidumpMemoryList *memory_list = dump_->GetMemoryList(); + MinidumpMemoryList* memory_list = dump_->GetMemoryList(); bool memory_available = true; if (!memory_list) { BPLOG(INFO) << "Minidump memory segments not available."; @@ -195,7 +195,7 @@ ExploitabilityRating ExploitabilityWin::CheckPlatformExploitability() { return EXPLOITABILITY_ERR_PROCESSING; break; } - MinidumpMemoryRegion *instruction_region = 0; + MinidumpMemoryRegion* instruction_region = 0; if (memory_available) { instruction_region = memory_list->GetMemoryRegionForAddress(instruction_ptr); @@ -211,7 +211,7 @@ ExploitabilityRating ExploitabilityWin::CheckPlatformExploitability() { available_memory = available_memory > kDisassembleBytesBeyondPC ? kDisassembleBytesBeyondPC : available_memory; if (available_memory) { - const uint8_t *raw_memory = + const uint8_t* raw_memory = instruction_region->GetMemory() + memory_offset; DisassemblerX86 disassembler(raw_memory, available_memory, diff --git a/src/processor/fast_source_line_resolver.cc b/src/processor/fast_source_line_resolver.cc index 4a3d0007..3f8ec508 100644 --- a/src/processor/fast_source_line_resolver.cc +++ b/src/processor/fast_source_line_resolver.cc @@ -61,7 +61,7 @@ bool FastSourceLineResolver::ShouldDeleteMemoryBufferAfterLoadModule() { return false; } -void FastSourceLineResolver::Module::LookupAddress(StackFrame *frame) const { +void FastSourceLineResolver::Module::LookupAddress(StackFrame* frame) const { MemAddr address = frame->instruction - frame->module->base_address(); // First, look for a FUNC record that covers address. Use @@ -109,7 +109,7 @@ void FastSourceLineResolver::Module::LookupAddress(StackFrame *frame) const { // WFI: WindowsFrameInfo. // Returns a WFI object reading from a raw memory chunk of data -WindowsFrameInfo FastSourceLineResolver::CopyWFI(const char *raw) { +WindowsFrameInfo FastSourceLineResolver::CopyWFI(const char* raw) { const WindowsFrameInfo::StackInfoTypes type = static_cast( *reinterpret_cast(raw)); @@ -117,7 +117,7 @@ WindowsFrameInfo FastSourceLineResolver::CopyWFI(const char *raw) { // The first 8 bytes of int data are unused. // They correspond to "StackInfoTypes type_;" and "int valid;" // data member of WFI. - const uint32_t *para_uint32 = reinterpret_cast( + const uint32_t* para_uint32 = reinterpret_cast( raw + 2 * sizeof(int32_t)); uint32_t prolog_size = para_uint32[0];; @@ -126,7 +126,7 @@ WindowsFrameInfo FastSourceLineResolver::CopyWFI(const char *raw) { uint32_t saved_register_size = para_uint32[3]; uint32_t local_size = para_uint32[4]; uint32_t max_stack_size = para_uint32[5]; - const char *boolean = reinterpret_cast(para_uint32 + 6); + const char* boolean = reinterpret_cast(para_uint32 + 6); bool allocates_base_pointer = (*boolean != 0); string program_string = boolean + 1; @@ -145,15 +145,15 @@ WindowsFrameInfo FastSourceLineResolver::CopyWFI(const char *raw) { // Does NOT take ownership of mem_buffer. // In addition, treat mem_buffer as const char*. bool FastSourceLineResolver::Module::LoadMapFromMemory( - char *memory_buffer, + char* memory_buffer, size_t memory_buffer_size) { if (!memory_buffer) return false; // Read the "is_corrupt" flag. - const char *mem_buffer = memory_buffer; + const char* mem_buffer = memory_buffer; mem_buffer = SimpleSerializer::Read(mem_buffer, &is_corrupt_); - const uint32_t *map_sizes = reinterpret_cast(mem_buffer); + const uint32_t* map_sizes = reinterpret_cast(mem_buffer); unsigned int header_size = kNumberMaps_ * sizeof(unsigned int); @@ -185,8 +185,8 @@ bool FastSourceLineResolver::Module::LoadMapFromMemory( return true; } -WindowsFrameInfo *FastSourceLineResolver::Module::FindWindowsFrameInfo( - const StackFrame *frame) const { +WindowsFrameInfo* FastSourceLineResolver::Module::FindWindowsFrameInfo( + const StackFrame* frame) const { MemAddr address = frame->instruction - frame->module->base_address(); scoped_ptr result(new WindowsFrameInfo()); @@ -238,8 +238,8 @@ WindowsFrameInfo *FastSourceLineResolver::Module::FindWindowsFrameInfo( return NULL; } -CFIFrameInfo *FastSourceLineResolver::Module::FindCFIFrameInfo( - const StackFrame *frame) const { +CFIFrameInfo* FastSourceLineResolver::Module::FindCFIFrameInfo( + const StackFrame* frame) const { MemAddr address = frame->instruction - frame->module->base_address(); MemAddr initial_base, initial_size; const char* initial_rules = NULL; diff --git a/src/processor/fast_source_line_resolver_types.h b/src/processor/fast_source_line_resolver_types.h index 2c010470..2b2b5827 100644 --- a/src/processor/fast_source_line_resolver_types.h +++ b/src/processor/fast_source_line_resolver_types.h @@ -54,16 +54,16 @@ namespace google_breakpad { struct FastSourceLineResolver::Line : public SourceLineResolverBase::Line { - void CopyFrom(const Line *line_ptr) { - const char *raw = reinterpret_cast(line_ptr); + void CopyFrom(const Line* line_ptr) { + const char* raw = reinterpret_cast(line_ptr); CopyFrom(raw); } // De-serialize the memory data of a Line. - void CopyFrom(const char *raw) { + void CopyFrom(const char* raw) { address = *(reinterpret_cast(raw)); size = *(reinterpret_cast(raw + sizeof(address))); - source_file_id = *(reinterpret_cast( + source_file_id = *(reinterpret_cast( raw + 2 * sizeof(address))); line = *(reinterpret_cast( raw + 2 * sizeof(address) + sizeof(source_file_id))); @@ -72,13 +72,13 @@ struct FastSourceLineResolver::Line : public SourceLineResolverBase::Line { struct FastSourceLineResolver::Function : public SourceLineResolverBase::Function { - void CopyFrom(const Function *func_ptr) { - const char *raw = reinterpret_cast(func_ptr); + void CopyFrom(const Function* func_ptr) { + const char* raw = reinterpret_cast(func_ptr); CopyFrom(raw); } // De-serialize the memory data of a Function. - void CopyFrom(const char *raw) { + void CopyFrom(const char* raw) { size_t name_size = strlen(raw) + 1; name = raw; address = *(reinterpret_cast(raw + name_size)); @@ -95,13 +95,13 @@ public SourceLineResolverBase::Function { struct FastSourceLineResolver::PublicSymbol : public SourceLineResolverBase::PublicSymbol { - void CopyFrom(const PublicSymbol *public_symbol_ptr) { - const char *raw = reinterpret_cast(public_symbol_ptr); + void CopyFrom(const PublicSymbol* public_symbol_ptr) { + const char* raw = reinterpret_cast(public_symbol_ptr); CopyFrom(raw); } // De-serialize the memory data of a PublicSymbol. - void CopyFrom(const char *raw) { + void CopyFrom(const char* raw) { size_t name_size = strlen(raw) + 1; name = raw; address = *(reinterpret_cast(raw + name_size)); @@ -112,15 +112,15 @@ public SourceLineResolverBase::PublicSymbol { class FastSourceLineResolver::Module: public SourceLineResolverBase::Module { public: - explicit Module(const string &name) : name_(name), is_corrupt_(false) { } + explicit Module(const string& name) : name_(name), is_corrupt_(false) { } virtual ~Module() { } // Looks up the given relative address, and fills the StackFrame struct // with the result. - virtual void LookupAddress(StackFrame *frame) const; + virtual void LookupAddress(StackFrame* frame) const; // Loads a map from the given buffer in char* type. - virtual bool LoadMapFromMemory(char *memory_buffer, + virtual bool LoadMapFromMemory(char* memory_buffer, size_t memory_buffer_size); // Tells whether the loaded symbol data is corrupt. Return value is @@ -132,13 +132,13 @@ class FastSourceLineResolver::Module: public SourceLineResolverBase::Module { // is not available, returns NULL. A NULL return value does not indicate // an error. The caller takes ownership of any returned WindowsFrameInfo // object. - virtual WindowsFrameInfo *FindWindowsFrameInfo(const StackFrame *frame) const; + virtual WindowsFrameInfo* FindWindowsFrameInfo(const StackFrame* frame) const; // If CFI stack walking information is available covering ADDRESS, // return a CFIFrameInfo structure describing it. If the information // is not available, return NULL. The caller takes ownership of any // returned CFIFrameInfo object. - virtual CFIFrameInfo *FindCFIFrameInfo(const StackFrame *frame) const; + virtual CFIFrameInfo* FindCFIFrameInfo(const StackFrame* frame) const; // Number of serialized map components of Module. static const int kNumberMaps_ = 5 + WindowsFrameInfo::STACK_INFO_LAST; diff --git a/src/processor/fast_source_line_resolver_unittest.cc b/src/processor/fast_source_line_resolver_unittest.cc index 87b13c52..0ec5f91d 100644 --- a/src/processor/fast_source_line_resolver_unittest.cc +++ b/src/processor/fast_source_line_resolver_unittest.cc @@ -94,15 +94,15 @@ class TestCodeModule : public CodeModule { class MockMemoryRegion: public MemoryRegion { uint64_t GetBase() const { return 0x10000; } uint32_t GetSize() const { return 0x01000; } - bool GetMemoryAtAddress(uint64_t address, uint8_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint8_t* value) const { *value = address & 0xff; return true; } - bool GetMemoryAtAddress(uint64_t address, uint16_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint16_t* value) const { *value = address & 0xffff; return true; } - bool GetMemoryAtAddress(uint64_t address, uint32_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint32_t* value) const { switch (address) { case 0x10008: *value = 0x98ecadc3; break; // saved %ebx case 0x1000c: *value = 0x878f7524; break; // saved %esi @@ -113,7 +113,7 @@ class MockMemoryRegion: public MemoryRegion { } return true; } - bool GetMemoryAtAddress(uint64_t address, uint64_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint64_t* value) const { *value = address; return true; } @@ -127,9 +127,9 @@ class MockMemoryRegion: public MemoryRegion { // EXPECTED's.) Also verify that ACTUAL has associations for ".ra" and // ".cfa". static bool VerifyRegisters( - const char *file, int line, - const CFIFrameInfo::RegisterValueMap &expected, - const CFIFrameInfo::RegisterValueMap &actual) { + const char* file, int line, + const CFIFrameInfo::RegisterValueMap& expected, + const CFIFrameInfo::RegisterValueMap& actual) { CFIFrameInfo::RegisterValueMap::const_iterator a; a = actual.find(".cfa"); if (a == actual.end()) @@ -158,7 +158,7 @@ static bool VerifyRegisters( return true; } -static bool VerifyEmpty(const StackFrame &frame) { +static bool VerifyEmpty(const StackFrame& frame) { if (frame.function_name.empty() && frame.source_file_name.empty() && frame.source_line == 0) @@ -166,7 +166,7 @@ static bool VerifyEmpty(const StackFrame &frame) { return false; } -static void ClearSourceLineInfo(StackFrame *frame) { +static void ClearSourceLineInfo(StackFrame* frame) { frame->function_name.clear(); frame->module = NULL; frame->source_file_name.clear(); @@ -467,7 +467,7 @@ TEST_F(TestFastSourceLineResolver, TestUnload) { } TEST_F(TestFastSourceLineResolver, CompareModule) { - char *symbol_data; + char* symbol_data; size_t symbol_data_size; string symbol_data_string; string filename; @@ -486,7 +486,7 @@ TEST_F(TestFastSourceLineResolver, CompareModule) { } // namespace -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/src/processor/logging.cc b/src/processor/logging.cc index d59175a7..3c5b1616 100644 --- a/src/processor/logging.cc +++ b/src/processor/logging.cc @@ -47,8 +47,8 @@ namespace google_breakpad { -LogStream::LogStream(std::ostream &stream, Severity severity, - const char *file, int line) +LogStream::LogStream(std::ostream& stream, Severity severity, + const char* file, int line) : stream_(stream) { time_t clock; time(&clock); @@ -61,7 +61,7 @@ LogStream::LogStream(std::ostream &stream, Severity severity, char time_string[20]; strftime(time_string, sizeof(time_string), "%Y-%m-%d %H:%M:%S", &tm_struct); - const char *severity_string = "UNKNOWN_SEVERITY"; + const char* severity_string = "UNKNOWN_SEVERITY"; switch (severity) { case SEVERITY_INFO: severity_string = "INFO"; @@ -100,7 +100,7 @@ string HexString(int number) { return string(buffer); } -int ErrnoString(string *error_string) { +int ErrnoString(string* error_string) { assert(error_string); // strerror isn't necessarily thread-safe. strerror_r would be preferrable, diff --git a/src/processor/logging.h b/src/processor/logging.h index 43f3cfc9..e6c6eee2 100644 --- a/src/processor/logging.h +++ b/src/processor/logging.h @@ -89,22 +89,22 @@ class LogStream { // Begin logging a message to the stream identified by |stream|, at the // indicated severity. The file and line parameters should be set so as to // identify the line of source code that is producing a message. - LogStream(std::ostream &stream, Severity severity, - const char *file, int line); + LogStream(std::ostream& stream, Severity severity, + const char* file, int line); // Finish logging by printing a newline and flushing the output stream. ~LogStream(); - template std::ostream& operator<<(const T &t) { + template std::ostream& operator<<(const T& t) { return stream_ << t; } private: - std::ostream &stream_; + std::ostream& stream_; // Disallow copy constructor and assignment operator - explicit LogStream(const LogStream &that); - void operator=(const LogStream &that); + explicit LogStream(const LogStream& that); + void operator=(const LogStream& that); }; // This class is used to explicitly ignore values in the conditional logging @@ -116,7 +116,7 @@ class LogMessageVoidify { // This has to be an operator with a precedence lower than << but higher // than ?: - void operator&(std::ostream &) {} + void operator&(std::ostream&) {} }; // Returns number formatted as a hexadecimal string, such as "0x7b". @@ -127,7 +127,7 @@ string HexString(int number); // Returns the error code as set in the global errno variable, and sets // error_string, a required argument, to a string describing that error // code. -int ErrnoString(string *error_string); +int ErrnoString(string* error_string); } // namespace google_breakpad diff --git a/src/processor/map_serializers-inl.h b/src/processor/map_serializers-inl.h index 61c7bbd7..4933f907 100644 --- a/src/processor/map_serializers-inl.h +++ b/src/processor/map_serializers-inl.h @@ -53,7 +53,7 @@ namespace google_breakpad { template size_t StdMapSerializer::SizeOf( - const std::map &m) const { + const std::map& m) const { size_t size = 0; size_t header_size = (1 + m.size()) * sizeof(uint32_t); size += header_size; @@ -67,22 +67,22 @@ size_t StdMapSerializer::SizeOf( } template -char *StdMapSerializer::Write(const std::map &m, - char *dest) const { +char* StdMapSerializer::Write(const std::map& m, + char* dest) const { if (!dest) { BPLOG(ERROR) << "StdMapSerializer failed: write to NULL address."; return NULL; } - char *start_address = dest; + char* start_address = dest; // Write header: // Number of nodes. dest = SimpleSerializer::Write(m.size(), dest); // Nodes offsets. - uint32_t *offsets = reinterpret_cast(dest); + uint32_t* offsets = reinterpret_cast(dest); dest += sizeof(uint32_t) * m.size(); - char *key_address = dest; + char* key_address = dest; dest += sizeof(Key) * m.size(); // Traverse map. @@ -97,12 +97,12 @@ char *StdMapSerializer::Write(const std::map &m, } template -char *StdMapSerializer::Serialize( - const std::map &m, unsigned int *size) const { +char* StdMapSerializer::Serialize( + const std::map& m, unsigned int* size) const { // Compute size of memory to be allocated. unsigned int size_to_alloc = SizeOf(m); // Allocate memory. - char *serialized_data = new char[size_to_alloc]; + char* serialized_data = new char[size_to_alloc]; if (!serialized_data) { BPLOG(INFO) << "StdMapSerializer memory allocation failed."; if (size) *size = 0; @@ -117,7 +117,7 @@ char *StdMapSerializer::Serialize( template size_t RangeMapSerializer::SizeOf( - const RangeMap &m) const { + const RangeMap& m) const { size_t size = 0; size_t header_size = (1 + m.map_.size()) * sizeof(uint32_t); size += header_size; @@ -135,22 +135,22 @@ size_t RangeMapSerializer::SizeOf( } template -char *RangeMapSerializer::Write( - const RangeMap &m, char *dest) const { +char* RangeMapSerializer::Write( + const RangeMap& m, char* dest) const { if (!dest) { BPLOG(ERROR) << "RangeMapSerializer failed: write to NULL address."; return NULL; } - char *start_address = dest; + char* start_address = dest; // Write header: // Number of nodes. dest = SimpleSerializer::Write(m.map_.size(), dest); // Nodes offsets. - uint32_t *offsets = reinterpret_cast(dest); + uint32_t* offsets = reinterpret_cast(dest); dest += sizeof(uint32_t) * m.map_.size(); - char *key_address = dest; + char* key_address = dest; dest += sizeof(Address) * m.map_.size(); // Traverse map. @@ -166,12 +166,12 @@ char *RangeMapSerializer::Write( } template -char *RangeMapSerializer::Serialize( - const RangeMap &m, unsigned int *size) const { +char* RangeMapSerializer::Serialize( + const RangeMap& m, unsigned int* size) const { // Compute size of memory to be allocated. unsigned int size_to_alloc = SizeOf(m); // Allocate memory. - char *serialized_data = new char[size_to_alloc]; + char* serialized_data = new char[size_to_alloc]; if (!serialized_data) { BPLOG(INFO) << "RangeMapSerializer memory allocation failed."; if (size) *size = 0; @@ -188,7 +188,7 @@ char *RangeMapSerializer::Serialize( template size_t ContainedRangeMapSerializer::SizeOf( - const ContainedRangeMap *m) const { + const ContainedRangeMap* m) const { size_t size = 0; size_t header_size = addr_serializer_.SizeOf(m->base_) + entry_serializer_.SizeOf(m->entry_) @@ -209,8 +209,8 @@ size_t ContainedRangeMapSerializer::SizeOf( } template -char *ContainedRangeMapSerializer::Write( - const ContainedRangeMap *m, char *dest) const { +char* ContainedRangeMapSerializer::Write( + const ContainedRangeMap* m, char* dest) const { if (!dest) { BPLOG(ERROR) << "StdMapSerializer failed: write to NULL address."; return NULL; @@ -221,15 +221,15 @@ char *ContainedRangeMapSerializer::Write( dest = entry_serializer_.Write(m->entry_, dest); // Write map<: - char *map_address = dest; + char* map_address = dest; if (m->map_ == NULL) { dest = SimpleSerializer::Write(0, dest); } else { dest = SimpleSerializer::Write(m->map_->size(), dest); - uint32_t *offsets = reinterpret_cast(dest); + uint32_t* offsets = reinterpret_cast(dest); dest += sizeof(uint32_t) * m->map_->size(); - char *key_address = dest; + char* key_address = dest; dest += sizeof(AddrType) * m->map_->size(); // Traverse map. @@ -246,11 +246,11 @@ char *ContainedRangeMapSerializer::Write( } template -char *ContainedRangeMapSerializer::Serialize( - const ContainedRangeMap *m, unsigned int *size) const { +char* ContainedRangeMapSerializer::Serialize( + const ContainedRangeMap* m, unsigned int* size) const { unsigned int size_to_alloc = SizeOf(m); // Allocating memory. - char *serialized_data = new char[size_to_alloc]; + char* serialized_data = new char[size_to_alloc]; if (!serialized_data) { BPLOG(INFO) << "ContainedRangeMapSerializer memory allocation failed."; if (size) *size = 0; diff --git a/src/processor/map_serializers.h b/src/processor/map_serializers.h index a0b9d3fd..3d504158 100644 --- a/src/processor/map_serializers.h +++ b/src/processor/map_serializers.h @@ -53,20 +53,20 @@ template class StdMapSerializer { public: // Calculate the memory size of serialized data. - size_t SizeOf(const std::map &m) const; + size_t SizeOf(const std::map& m) const; // Writes the serialized data to memory with start address = dest, // and returns the "end" of data, i.e., return the address follow the final // byte of data. // NOTE: caller has to allocate enough memory before invoke Write() method. - char* Write(const std::map &m, char* dest) const; + char* Write(const std::map& m, char* dest) const; // Serializes a std::map object into a chunk of memory data with format // described in "StaticMap.h" comment. // Returns a pointer to the serialized data. If size != NULL, *size is set // to the size of serialized data, i.e., SizeOf(m). // Caller has the ownership of memory allocated as "new char[]". - char* Serialize(const std::map &m, unsigned int *size) const; + char* Serialize(const std::map& m, unsigned int* size) const; private: SimpleSerializer key_serializer_; @@ -79,14 +79,14 @@ template class AddressMapSerializer { public: // Calculate the memory size of serialized data. - size_t SizeOf(const AddressMap &m) const { + size_t SizeOf(const AddressMap& m) const { return std_map_serializer_.SizeOf(m.map_); } // Write the serialized data to specified memory location. Return the "end" // of data, i.e., return the address after the final byte of data. // NOTE: caller has to allocate enough memory before invoke Write() method. - char* Write(const AddressMap &m, char *dest) const { + char* Write(const AddressMap& m, char* dest) const { return std_map_serializer_.Write(m.map_, dest); } @@ -94,7 +94,7 @@ class AddressMapSerializer { // Returns a pointer to the serialized data. If size != NULL, *size is set // to the size of serialized data, i.e., SizeOf(m). // Caller has the ownership of memory allocated as "new char[]". - char* Serialize(const AddressMap &m, unsigned int *size) const { + char* Serialize(const AddressMap& m, unsigned int* size) const { return std_map_serializer_.Serialize(m.map_, size); } @@ -110,18 +110,18 @@ template class RangeMapSerializer { public: // Calculate the memory size of serialized data. - size_t SizeOf(const RangeMap &m) const; + size_t SizeOf(const RangeMap& m) const; // Write the serialized data to specified memory location. Return the "end" // of data, i.e., return the address after the final byte of data. // NOTE: caller has to allocate enough memory before invoke Write() method. - char* Write(const RangeMap &m, char* dest) const; + char* Write(const RangeMap& m, char* dest) const; // Serializes a RangeMap object into a chunk of memory data. // Returns a pointer to the serialized data. If size != NULL, *size is set // to the size of serialized data, i.e., SizeOf(m). // Caller has the ownership of memory allocated as "new char[]". - char* Serialize(const RangeMap &m, unsigned int *size) const; + char* Serialize(const RangeMap& m, unsigned int* size) const; private: // Convenient type name for Range. @@ -139,20 +139,20 @@ template class ContainedRangeMapSerializer { public: // Calculate the memory size of serialized data. - size_t SizeOf(const ContainedRangeMap *m) const; + size_t SizeOf(const ContainedRangeMap* m) const; // Write the serialized data to specified memory location. Return the "end" // of data, i.e., return the address after the final byte of data. // NOTE: caller has to allocate enough memory before invoke Write() method. - char* Write(const ContainedRangeMap *m, + char* Write(const ContainedRangeMap* m, char* dest) const; // Serializes a ContainedRangeMap object into a chunk of memory data. // Returns a pointer to the serialized data. If size != NULL, *size is set // to the size of serialized data, i.e., SizeOf(m). // Caller has the ownership of memory allocated as "new char[]". - char* Serialize(const ContainedRangeMap *m, - unsigned int *size) const; + char* Serialize(const ContainedRangeMap* m, + unsigned int* size) const; private: // Convenient type name for the underlying map type. diff --git a/src/processor/map_serializers_unittest.cc b/src/processor/map_serializers_unittest.cc index 0d872ec2..48b9c4b2 100644 --- a/src/processor/map_serializers_unittest.cc +++ b/src/processor/map_serializers_unittest.cc @@ -63,7 +63,7 @@ class TestStdMapSerializer : public ::testing::Test { std::map std_map_; google_breakpad::StdMapSerializer serializer_; uint32_t serialized_size_; - char *serialized_data_; + char* serialized_data_; }; TEST_F(TestStdMapSerializer, EmptyMapTestCase) { @@ -135,7 +135,7 @@ class TestAddressMapSerializer : public ::testing::Test { google_breakpad::AddressMap address_map_; google_breakpad::AddressMapSerializer serializer_; uint32_t serialized_size_; - char *serialized_data_; + char* serialized_data_; }; TEST_F(TestAddressMapSerializer, EmptyMapTestCase) { @@ -210,7 +210,7 @@ class TestRangeMapSerializer : public ::testing::Test { google_breakpad::RangeMap range_map_; google_breakpad::RangeMapSerializer serializer_; uint32_t serialized_size_; - char *serialized_data_; + char* serialized_data_; }; TEST_F(TestRangeMapSerializer, EmptyMapTestCase) { @@ -283,7 +283,7 @@ class TestContainedRangeMapSerializer : public ::testing::Test { google_breakpad::ContainedRangeMap crm_map_; google_breakpad::ContainedRangeMapSerializer serializer_; uint32_t serialized_size_; - char *serialized_data_; + char* serialized_data_; }; TEST_F(TestContainedRangeMapSerializer, EmptyMapTestCase) { @@ -379,7 +379,7 @@ TEST_F(TestContainedRangeMapSerializer, MapWithTwoLevelsTestCase) { } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/src/processor/microdump_stackwalk.cc b/src/processor/microdump_stackwalk.cc index 220396ed..03fa77e1 100644 --- a/src/processor/microdump_stackwalk.cc +++ b/src/processor/microdump_stackwalk.cc @@ -140,7 +140,7 @@ static void SetupOptions(int argc, const char *argv[], Options* options) { options->machine_readable = false; options->output_stack_contents = false; - while ((ch = getopt(argc, (char * const *)argv, "hms")) != -1) { + while ((ch = getopt(argc, (char * const*)argv, "hms")) != -1) { switch (ch) { case 'h': Usage(argc, argv, false); diff --git a/src/processor/minidump.cc b/src/processor/minidump.cc index f0075eb2..1f479558 100644 --- a/src/processor/minidump.cc +++ b/src/processor/minidump.cc @@ -1611,7 +1611,7 @@ MinidumpContext* MinidumpThread::GetContext() { } -bool MinidumpThread::GetThreadID(uint32_t *thread_id) const { +bool MinidumpThread::GetThreadID(uint32_t* thread_id) const { BPLOG_IF(ERROR, !thread_id) << "MinidumpThread::GetThreadID requires " "|thread_id|"; assert(thread_id); @@ -1973,14 +1973,14 @@ string MinidumpModule::code_identifier() const { if (!has_debug_info_) return ""; - MinidumpSystemInfo *minidump_system_info = minidump_->GetSystemInfo(); + MinidumpSystemInfo* minidump_system_info = minidump_->GetSystemInfo(); if (!minidump_system_info) { BPLOG(ERROR) << "MinidumpModule code_identifier requires " "MinidumpSystemInfo"; return ""; } - const MDRawSystemInfo *raw_system_info = minidump_system_info->system_info(); + const MDRawSystemInfo* raw_system_info = minidump_system_info->system_info(); if (!raw_system_info) { BPLOG(ERROR) << "MinidumpModule code_identifier requires MDRawSystemInfo"; return ""; @@ -2093,7 +2093,7 @@ string MinidumpModule::debug_file() const { // No usable CodeView record. Try the miscellaneous debug record. if (misc_record_) { const MDImageDebugMisc* misc_record = - reinterpret_cast(&(*misc_record_)[0]); + reinterpret_cast(&(*misc_record_)[0]); if (!misc_record->unicode) { // If it's not Unicode, just stuff it into the string. It's unclear // if misc_record->data is 0-terminated, so use an explicit size. @@ -2549,7 +2549,7 @@ void MinidumpModule::Print() { code_identifier().c_str()); uint32_t cv_record_size; - const uint8_t *cv_record = GetCVRecord(&cv_record_size); + const uint8_t* cv_record = GetCVRecord(&cv_record_size); if (cv_record) { if (cv_record_signature_ == MD_CVINFOPDB70_SIGNATURE) { const MDCVInfoPDB70* cv_record_70 = @@ -3215,7 +3215,7 @@ bool MinidumpException::Read(uint32_t expected_size) { } -bool MinidumpException::GetThreadID(uint32_t *thread_id) const { +bool MinidumpException::GetThreadID(uint32_t* thread_id) const { BPLOG_IF(ERROR, !thread_id) << "MinidumpException::GetThreadID requires " "|thread_id|"; assert(thread_id); @@ -3699,14 +3699,14 @@ string MinidumpUnloadedModule::code_identifier() const { return ""; } - MinidumpSystemInfo *minidump_system_info = minidump_->GetSystemInfo(); + MinidumpSystemInfo* minidump_system_info = minidump_->GetSystemInfo(); if (!minidump_system_info) { BPLOG(ERROR) << "MinidumpUnloadedModule code_identifier requires " "MinidumpSystemInfo"; return ""; } - const MDRawSystemInfo *raw_system_info = minidump_system_info->system_info(); + const MDRawSystemInfo* raw_system_info = minidump_system_info->system_info(); if (!raw_system_info) { BPLOG(ERROR) << "MinidumpUnloadedModule code_identifier requires " << "MDRawSystemInfo"; @@ -4356,7 +4356,7 @@ bool MinidumpBreakpadInfo::Read(uint32_t expected_size) { } -bool MinidumpBreakpadInfo::GetDumpThreadID(uint32_t *thread_id) const { +bool MinidumpBreakpadInfo::GetDumpThreadID(uint32_t* thread_id) const { BPLOG_IF(ERROR, !thread_id) << "MinidumpBreakpadInfo::GetDumpThreadID " "requires |thread_id|"; assert(thread_id); @@ -4377,7 +4377,7 @@ bool MinidumpBreakpadInfo::GetDumpThreadID(uint32_t *thread_id) const { } -bool MinidumpBreakpadInfo::GetRequestingThreadID(uint32_t *thread_id) +bool MinidumpBreakpadInfo::GetRequestingThreadID(uint32_t* thread_id) const { BPLOG_IF(ERROR, !thread_id) << "MinidumpBreakpadInfo::GetRequestingThreadID " "requires |thread_id|"; @@ -4695,7 +4695,7 @@ void MinidumpMemoryInfoList::Print() { // MinidumpLinuxMaps // -MinidumpLinuxMaps::MinidumpLinuxMaps(Minidump *minidump) +MinidumpLinuxMaps::MinidumpLinuxMaps(Minidump* minidump) : MinidumpObject(minidump) { } @@ -4711,7 +4711,7 @@ void MinidumpLinuxMaps::Print() const { // MinidumpLinuxMapsList // -MinidumpLinuxMapsList::MinidumpLinuxMapsList(Minidump *minidump) +MinidumpLinuxMapsList::MinidumpLinuxMapsList(Minidump* minidump) : MinidumpStream(minidump), maps_(NULL), maps_count_(0) { @@ -4726,7 +4726,7 @@ MinidumpLinuxMapsList::~MinidumpLinuxMapsList() { } } -const MinidumpLinuxMaps *MinidumpLinuxMapsList::GetLinuxMapsForAddress( +const MinidumpLinuxMaps* MinidumpLinuxMapsList::GetLinuxMapsForAddress( uint64_t address) const { if (!valid_ || (maps_ == NULL)) { BPLOG(ERROR) << "Invalid MinidumpLinuxMapsList for GetLinuxMapsForAddress"; @@ -4748,7 +4748,7 @@ const MinidumpLinuxMaps *MinidumpLinuxMapsList::GetLinuxMapsForAddress( return NULL; } -const MinidumpLinuxMaps *MinidumpLinuxMapsList::GetLinuxMapsAtIndex( +const MinidumpLinuxMaps* MinidumpLinuxMapsList::GetLinuxMapsAtIndex( unsigned int index) const { if (!valid_ || (maps_ == NULL)) { BPLOG(ERROR) << "Invalid MinidumpLinuxMapsList for GetLinuxMapsAtIndex"; @@ -5090,7 +5090,7 @@ bool Minidump::Open() { return true; } -bool Minidump::GetContextCPUFlagsFromSystemInfo(uint32_t *context_cpu_flags) { +bool Minidump::GetContextCPUFlagsFromSystemInfo(uint32_t* context_cpu_flags) { // Initialize output parameters *context_cpu_flags = 0; @@ -5366,8 +5366,8 @@ MinidumpMemoryInfoList* Minidump::GetMemoryInfoList() { return GetStream(&memory_info_list); } -MinidumpLinuxMapsList *Minidump::GetLinuxMapsList() { - MinidumpLinuxMapsList *linux_maps_list; +MinidumpLinuxMapsList* Minidump::GetLinuxMapsList() { + MinidumpLinuxMapsList* linux_maps_list; return GetStream(&linux_maps_list); } diff --git a/src/processor/minidump_dump.cc b/src/processor/minidump_dump.cc index 4716aa08..06802f24 100644 --- a/src/processor/minidump_dump.cc +++ b/src/processor/minidump_dump.cc @@ -91,7 +91,7 @@ static void DumpRawStream(Minidump *minidump, // in compatibility warnings. uint32_t int_remaining = remaining; printf("%.*s", int_remaining, &contents[current_offset]); - char *next_null = reinterpret_cast( + char *next_null = reinterpret_cast( memchr(&contents[current_offset], 0, remaining)); if (next_null == NULL) break; @@ -241,7 +241,7 @@ static void SetupOptions(int argc, char *argv[], Options *options) { int ch; - while ((ch = getopt(argc, (char * const *)argv, "xh")) != -1) { + while ((ch = getopt(argc, (char * const*)argv, "xh")) != -1) { switch (ch) { case 'x': options->hexdump = true; diff --git a/src/processor/minidump_processor.cc b/src/processor/minidump_processor.cc index a90e6188..04b7e129 100644 --- a/src/processor/minidump_processor.cc +++ b/src/processor/minidump_processor.cc @@ -48,16 +48,16 @@ namespace google_breakpad { -MinidumpProcessor::MinidumpProcessor(SymbolSupplier *supplier, - SourceLineResolverInterface *resolver) +MinidumpProcessor::MinidumpProcessor(SymbolSupplier* supplier, + SourceLineResolverInterface* resolver) : frame_symbolizer_(new StackFrameSymbolizer(supplier, resolver)), own_frame_symbolizer_(true), enable_exploitability_(false), enable_objdump_(false) { } -MinidumpProcessor::MinidumpProcessor(SymbolSupplier *supplier, - SourceLineResolverInterface *resolver, +MinidumpProcessor::MinidumpProcessor(SymbolSupplier* supplier, + SourceLineResolverInterface* resolver, bool enable_exploitability) : frame_symbolizer_(new StackFrameSymbolizer(supplier, resolver)), own_frame_symbolizer_(true), @@ -65,7 +65,7 @@ MinidumpProcessor::MinidumpProcessor(SymbolSupplier *supplier, enable_objdump_(false) { } -MinidumpProcessor::MinidumpProcessor(StackFrameSymbolizer *frame_symbolizer, +MinidumpProcessor::MinidumpProcessor(StackFrameSymbolizer* frame_symbolizer, bool enable_exploitability) : frame_symbolizer_(frame_symbolizer), own_frame_symbolizer_(false), @@ -79,13 +79,13 @@ MinidumpProcessor::~MinidumpProcessor() { } ProcessResult MinidumpProcessor::Process( - Minidump *dump, ProcessState *process_state) { + Minidump* dump, ProcessState* process_state) { assert(dump); assert(process_state); process_state->Clear(); - const MDRawHeader *header = dump->header(); + const MDRawHeader* header = dump->header(); if (!header) { BPLOG(ERROR) << "Minidump " << dump->path() << " has no header"; return PROCESS_ERROR_NO_MINIDUMP_HEADER; @@ -103,14 +103,14 @@ ProcessResult MinidumpProcessor::Process( uint32_t requesting_thread_id = 0; bool has_requesting_thread = false; - MinidumpBreakpadInfo *breakpad_info = dump->GetBreakpadInfo(); + MinidumpBreakpadInfo* breakpad_info = dump->GetBreakpadInfo(); if (breakpad_info) { has_dump_thread = breakpad_info->GetDumpThreadID(&dump_thread_id); has_requesting_thread = breakpad_info->GetRequestingThreadID(&requesting_thread_id); } - MinidumpException *exception = dump->GetException(); + MinidumpException* exception = dump->GetException(); if (exception) { process_state->crashed_ = true; has_requesting_thread = exception->GetThreadID(&requesting_thread_id); @@ -143,7 +143,7 @@ ProcessResult MinidumpProcessor::Process( // This will just return an empty string if it doesn't exist. process_state->assertion_ = GetAssertion(dump); - MinidumpModuleList *module_list = dump->GetModuleList(); + MinidumpModuleList* module_list = dump->GetModuleList(); // Put a copy of the module list into ProcessState object. This is not // necessarily a MinidumpModuleList, but it adheres to the CodeModules @@ -163,19 +163,19 @@ ProcessResult MinidumpProcessor::Process( } } - MinidumpUnloadedModuleList *unloaded_module_list = + MinidumpUnloadedModuleList* unloaded_module_list = dump->GetUnloadedModuleList(); if (unloaded_module_list) { process_state->unloaded_modules_ = unloaded_module_list->Copy(); } - MinidumpMemoryList *memory_list = dump->GetMemoryList(); + MinidumpMemoryList* memory_list = dump->GetMemoryList(); if (memory_list) { BPLOG(INFO) << "Found " << memory_list->region_count() << " memory regions."; } - MinidumpThreadList *threads = dump->GetThreadList(); + MinidumpThreadList* threads = dump->GetThreadList(); if (!threads) { BPLOG(ERROR) << "Minidump " << dump->path() << " has no thread list"; return PROCESS_ERROR_NO_THREAD_LIST; @@ -207,7 +207,7 @@ ProcessResult MinidumpProcessor::Process( thread_index, thread_count); string thread_string = dump->path() + ":" + thread_string_buffer; - MinidumpThread *thread = threads->GetThreadAtIndex(thread_index); + MinidumpThread* thread = threads->GetThreadAtIndex(thread_index); if (!thread) { BPLOG(ERROR) << "Could not get thread for " << thread_string; return PROCESS_ERROR_GETTING_THREAD; @@ -230,7 +230,7 @@ ProcessResult MinidumpProcessor::Process( continue; } - MinidumpContext *context = thread->GetContext(); + MinidumpContext* context = thread->GetContext(); if (has_requesting_thread && thread_id == requesting_thread_id) { if (found_requesting_thread) { @@ -257,7 +257,7 @@ ProcessResult MinidumpProcessor::Process( // would not result in the expected stack trace from the time of the // crash. If the exception context is invalid, however, we fall back // on the thread context. - MinidumpContext *ctx = exception->GetContext(); + MinidumpContext* ctx = exception->GetContext(); context = ctx ? ctx : thread->GetContext(); } } @@ -265,7 +265,7 @@ ProcessResult MinidumpProcessor::Process( // If the memory region for the stack cannot be read using the RVA stored // in the memory descriptor inside MINIDUMP_THREAD, try to locate and use // a memory region (containing the stack) from the minidump memory list. - MinidumpMemoryRegion *thread_memory = thread->GetMemory(); + MinidumpMemoryRegion* thread_memory = thread->GetMemory(); if (!thread_memory && memory_list) { uint64_t start_stack_memory_range = thread->GetStartOfStackMemoryRange(); if (start_stack_memory_range) { @@ -350,7 +350,7 @@ ProcessResult MinidumpProcessor::Process( } ProcessResult MinidumpProcessor::Process( - const string &minidump_file, ProcessState *process_state) { + const string& minidump_file, ProcessState* process_state) { BPLOG(INFO) << "Processing minidump in file " << minidump_file; Minidump dump(minidump_file); @@ -365,9 +365,9 @@ ProcessResult MinidumpProcessor::Process( // Returns the MDRawSystemInfo from a minidump, or NULL if system info is // not available from the minidump. If system_info is non-NULL, it is used // to pass back the MinidumpSystemInfo object. -static const MDRawSystemInfo* GetSystemInfo(Minidump *dump, - MinidumpSystemInfo **system_info) { - MinidumpSystemInfo *minidump_system_info = dump->GetSystemInfo(); +static const MDRawSystemInfo* GetSystemInfo(Minidump* dump, + MinidumpSystemInfo** system_info) { + MinidumpSystemInfo* minidump_system_info = dump->GetSystemInfo(); if (!minidump_system_info) return NULL; @@ -520,15 +520,15 @@ static void GetARMCpuInfo(const MDRawSystemInfo* raw_info, } // static -bool MinidumpProcessor::GetCPUInfo(Minidump *dump, SystemInfo *info) { +bool MinidumpProcessor::GetCPUInfo(Minidump* dump, SystemInfo* info) { assert(dump); assert(info); info->cpu.clear(); info->cpu_info.clear(); - MinidumpSystemInfo *system_info; - const MDRawSystemInfo *raw_system_info = GetSystemInfo(dump, &system_info); + MinidumpSystemInfo* system_info; + const MDRawSystemInfo* raw_system_info = GetSystemInfo(dump, &system_info); if (!raw_system_info) return false; @@ -541,7 +541,7 @@ bool MinidumpProcessor::GetCPUInfo(Minidump *dump, SystemInfo *info) { else info->cpu = "amd64"; - const string *cpu_vendor = system_info->GetCPUVendor(); + const string* cpu_vendor = system_info->GetCPUVendor(); if (cpu_vendor) { info->cpu_info = *cpu_vendor; info->cpu_info.append(" "); @@ -608,7 +608,7 @@ bool MinidumpProcessor::GetCPUInfo(Minidump *dump, SystemInfo *info) { } // static -bool MinidumpProcessor::GetOSInfo(Minidump *dump, SystemInfo *info) { +bool MinidumpProcessor::GetOSInfo(Minidump* dump, SystemInfo* info) { assert(dump); assert(info); @@ -616,8 +616,8 @@ bool MinidumpProcessor::GetOSInfo(Minidump *dump, SystemInfo *info) { info->os_short.clear(); info->os_version.clear(); - MinidumpSystemInfo *system_info; - const MDRawSystemInfo *raw_system_info = GetSystemInfo(dump, &system_info); + MinidumpSystemInfo* system_info; + const MDRawSystemInfo* raw_system_info = GetSystemInfo(dump, &system_info); if (!raw_system_info) return false; @@ -691,7 +691,7 @@ bool MinidumpProcessor::GetOSInfo(Minidump *dump, SystemInfo *info) { raw_system_info->build_number); info->os_version = os_version_string; - const string *csd_version = system_info->GetCSDVersion(); + const string* csd_version = system_info->GetCSDVersion(); if (csd_version) { info->os_version.append(" "); info->os_version.append(*csd_version); @@ -727,12 +727,12 @@ bool MinidumpProcessor::GetProcessCreateTime(Minidump* dump, } // static -string MinidumpProcessor::GetCrashReason(Minidump *dump, uint64_t *address) { - MinidumpException *exception = dump->GetException(); +string MinidumpProcessor::GetCrashReason(Minidump* dump, uint64_t* address) { + MinidumpException* exception = dump->GetException(); if (!exception) return ""; - const MDRawExceptionStream *raw_exception = exception->exception(); + const MDRawExceptionStream* raw_exception = exception->exception(); if (!raw_exception) return ""; @@ -752,7 +752,7 @@ string MinidumpProcessor::GetCrashReason(Minidump *dump, uint64_t *address) { flags_string); string reason = reason_string; - const MDRawSystemInfo *raw_system_info = GetSystemInfo(dump, NULL); + const MDRawSystemInfo* raw_system_info = GetSystemInfo(dump, NULL); if (!raw_system_info) return reason; @@ -1743,12 +1743,12 @@ string MinidumpProcessor::GetCrashReason(Minidump *dump, uint64_t *address) { } // static -string MinidumpProcessor::GetAssertion(Minidump *dump) { - MinidumpAssertion *assertion = dump->GetAssertion(); +string MinidumpProcessor::GetAssertion(Minidump* dump) { + MinidumpAssertion* assertion = dump->GetAssertion(); if (!assertion) return ""; - const MDRawAssertionInfo *raw_assertion = assertion->assertion(); + const MDRawAssertionInfo* raw_assertion = assertion->assertion(); if (!raw_assertion) return ""; diff --git a/src/processor/minidump_processor_unittest.cc b/src/processor/minidump_processor_unittest.cc index a4ac3685..306c2f0b 100644 --- a/src/processor/minidump_processor_unittest.cc +++ b/src/processor/minidump_processor_unittest.cc @@ -127,16 +127,16 @@ class MockMinidumpMemoryRegion : public MinidumpMemoryRegion { uint64_t GetBase() const { return region_.GetBase(); } uint32_t GetSize() const { return region_.GetSize(); } - bool GetMemoryAtAddress(uint64_t address, uint8_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint8_t* value) const { return region_.GetMemoryAtAddress(address, value); } - bool GetMemoryAtAddress(uint64_t address, uint16_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint16_t* value) const { return region_.GetMemoryAtAddress(address, value); } - bool GetMemoryAtAddress(uint64_t address, uint32_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint32_t* value) const { return region_.GetMemoryAtAddress(address, value); } - bool GetMemoryAtAddress(uint64_t address, uint64_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint64_t* value) const { return region_.GetMemoryAtAddress(address, value); } @@ -188,11 +188,11 @@ using ::testing::Property; using ::testing::Return; using ::testing::SetArgumentPointee; -static const char *kSystemInfoOS = "Windows NT"; -static const char *kSystemInfoOSShort = "windows"; -static const char *kSystemInfoOSVersion = "5.1.2600 Service Pack 2"; -static const char *kSystemInfoCPU = "x86"; -static const char *kSystemInfoCPUInfo = +static const char* kSystemInfoOS = "Windows NT"; +static const char* kSystemInfoOSShort = "windows"; +static const char* kSystemInfoOSVersion = "5.1.2600 Service Pack 2"; +static const char* kSystemInfoCPU = "x86"; +static const char* kSystemInfoCPUInfo = "GenuineIntel family 6 model 13 stepping 8"; #define ASSERT_TRUE_ABORT(cond) \ @@ -204,7 +204,7 @@ static const char *kSystemInfoCPUInfo = #define ASSERT_EQ_ABORT(e1, e2) ASSERT_TRUE_ABORT((e1) == (e2)) static string GetTestDataPath() { - char *srcdir = getenv("srcdir"); + char* srcdir = getenv("srcdir"); return string(srcdir ? srcdir : ".") + "/src/processor/testdata/"; } @@ -213,35 +213,35 @@ class TestSymbolSupplier : public SymbolSupplier { public: TestSymbolSupplier() : interrupt_(false) {} - virtual SymbolResult GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file); + virtual SymbolResult GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file); - virtual SymbolResult GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - string *symbol_data); + virtual SymbolResult GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + string* symbol_data); - virtual SymbolResult GetCStringSymbolData(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - char **symbol_data, - size_t *symbol_data_size); + virtual SymbolResult GetCStringSymbolData(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + char** symbol_data, + size_t* symbol_data_size); - virtual void FreeSymbolData(const CodeModule *module); + virtual void FreeSymbolData(const CodeModule* module); // When set to true, causes the SymbolSupplier to return INTERRUPT void set_interrupt(bool interrupt) { interrupt_ = interrupt; } private: bool interrupt_; - map memory_buffers_; + map memory_buffers_; }; SymbolSupplier::SymbolResult TestSymbolSupplier::GetSymbolFile( - const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file) { + const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file) { ASSERT_TRUE_ABORT(module); ASSERT_TRUE_ABORT(system_info); ASSERT_EQ_ABORT(system_info->cpu, kSystemInfoCPU); @@ -264,10 +264,10 @@ SymbolSupplier::SymbolResult TestSymbolSupplier::GetSymbolFile( } SymbolSupplier::SymbolResult TestSymbolSupplier::GetSymbolFile( - const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - string *symbol_data) { + const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + string* symbol_data) { SymbolSupplier::SymbolResult s = GetSymbolFile(module, system_info, symbol_file); if (s == FOUND) { @@ -281,11 +281,11 @@ SymbolSupplier::SymbolResult TestSymbolSupplier::GetSymbolFile( } SymbolSupplier::SymbolResult TestSymbolSupplier::GetCStringSymbolData( - const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - char **symbol_data, - size_t *symbol_data_size) { + const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + char** symbol_data, + size_t* symbol_data_size) { string symbol_data_string; SymbolSupplier::SymbolResult s = GetSymbolFile(module, system_info, @@ -307,8 +307,8 @@ SymbolSupplier::SymbolResult TestSymbolSupplier::GetCStringSymbolData( return s; } -void TestSymbolSupplier::FreeSymbolData(const CodeModule *module) { - map::iterator it = memory_buffers_.find(module->code_file()); +void TestSymbolSupplier::FreeSymbolData(const CodeModule* module) { + map::iterator it = memory_buffers_.find(module->code_file()); if (it != memory_buffers_.end()) { delete [] it->second; memory_buffers_.erase(it); @@ -523,7 +523,7 @@ TEST_F(MinidumpProcessorTest, TestBasicProcessing) { EXPECT_EQ(1171480435U, state.time_date_stamp()); EXPECT_EQ(1171480435U, state.process_create_time()); - CallStack *stack = state.threads()->at(0); + CallStack* stack = state.threads()->at(0); ASSERT_TRUE(stack); ASSERT_EQ(stack->frames()->size(), 4U); @@ -763,7 +763,7 @@ TEST_F(MinidumpProcessorTest, Test32BitCrashingAddress) { } // namespace -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/src/processor/minidump_stackwalk.cc b/src/processor/minidump_stackwalk.cc index acf80972..aedd0271 100644 --- a/src/processor/minidump_stackwalk.cc +++ b/src/processor/minidump_stackwalk.cc @@ -138,7 +138,7 @@ static void SetupOptions(int argc, const char *argv[], Options* options) { options->machine_readable = false; options->output_stack_contents = false; - while ((ch = getopt(argc, (char * const *)argv, "hms")) != -1) { + while ((ch = getopt(argc, (char * const*)argv, "hms")) != -1) { switch (ch) { case 'h': Usage(argc, argv, false); diff --git a/src/processor/minidump_unittest.cc b/src/processor/minidump_unittest.cc index 036d03f1..49b007fe 100644 --- a/src/processor/minidump_unittest.cc +++ b/src/processor/minidump_unittest.cc @@ -95,9 +95,9 @@ TEST_F(MinidumpTest, TestMinidumpFromFile) { ASSERT_NE(header, (MDRawHeader*)NULL); ASSERT_EQ(header->signature, uint32_t(MD_HEADER_SIGNATURE)); - MinidumpModuleList *md_module_list = minidump.GetModuleList(); + MinidumpModuleList* md_module_list = minidump.GetModuleList(); ASSERT_TRUE(md_module_list != NULL); - const MinidumpModule *md_module = md_module_list->GetModuleAtIndex(0); + const MinidumpModule* md_module = md_module_list->GetModuleAtIndex(0); ASSERT_TRUE(md_module != NULL); ASSERT_EQ("c:\\test_app.exe", md_module->code_file()); ASSERT_EQ("c:\\test_app.pdb", md_module->debug_file()); @@ -167,7 +167,7 @@ TEST(Dump, OneStream) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(1U, minidump.GetDirectoryEntryCount()); - const MDRawDirectory *dir = minidump.GetDirectoryEntryAtIndex(0); + const MDRawDirectory* dir = minidump.GetDirectoryEntryAtIndex(0); ASSERT_TRUE(dir != NULL); EXPECT_EQ(0xfbb7fa2bU, dir->stream_type); @@ -203,18 +203,18 @@ TEST(Dump, OneMemory) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(1U, minidump.GetDirectoryEntryCount()); - const MDRawDirectory *dir = minidump.GetDirectoryEntryAtIndex(0); + const MDRawDirectory* dir = minidump.GetDirectoryEntryAtIndex(0); ASSERT_TRUE(dir != NULL); EXPECT_EQ((uint32_t) MD_MEMORY_LIST_STREAM, dir->stream_type); - MinidumpMemoryList *memory_list = minidump.GetMemoryList(); + MinidumpMemoryList* memory_list = minidump.GetMemoryList(); ASSERT_TRUE(memory_list != NULL); ASSERT_EQ(1U, memory_list->region_count()); - MinidumpMemoryRegion *region1 = memory_list->GetMemoryRegionAtIndex(0); + MinidumpMemoryRegion* region1 = memory_list->GetMemoryRegionAtIndex(0); ASSERT_EQ(0x309d68010bd21b2cULL, region1->GetBase()); ASSERT_EQ(15U, region1->GetSize()); - const uint8_t *region1_bytes = region1->GetMemory(); + const uint8_t* region1_bytes = region1->GetMemory(); ASSERT_TRUE(memcmp("memory contents", region1_bytes, 15) == 0); } @@ -257,33 +257,33 @@ TEST(Dump, OneThread) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(2U, minidump.GetDirectoryEntryCount()); - MinidumpMemoryList *md_memory_list = minidump.GetMemoryList(); + MinidumpMemoryList* md_memory_list = minidump.GetMemoryList(); ASSERT_TRUE(md_memory_list != NULL); ASSERT_EQ(1U, md_memory_list->region_count()); - MinidumpMemoryRegion *md_region = md_memory_list->GetMemoryRegionAtIndex(0); + MinidumpMemoryRegion* md_region = md_memory_list->GetMemoryRegionAtIndex(0); ASSERT_EQ(0x2326a0faU, md_region->GetBase()); ASSERT_EQ(16U, md_region->GetSize()); - const uint8_t *region_bytes = md_region->GetMemory(); + const uint8_t* region_bytes = md_region->GetMemory(); ASSERT_TRUE(memcmp("stack for thread", region_bytes, 16) == 0); - MinidumpThreadList *thread_list = minidump.GetThreadList(); + MinidumpThreadList* thread_list = minidump.GetThreadList(); ASSERT_TRUE(thread_list != NULL); ASSERT_EQ(1U, thread_list->thread_count()); - MinidumpThread *md_thread = thread_list->GetThreadAtIndex(0); + MinidumpThread* md_thread = thread_list->GetThreadAtIndex(0); ASSERT_TRUE(md_thread != NULL); uint32_t thread_id; ASSERT_TRUE(md_thread->GetThreadID(&thread_id)); ASSERT_EQ(0xa898f11bU, thread_id); - MinidumpMemoryRegion *md_stack = md_thread->GetMemory(); + MinidumpMemoryRegion* md_stack = md_thread->GetMemory(); ASSERT_TRUE(md_stack != NULL); ASSERT_EQ(0x2326a0faU, md_stack->GetBase()); ASSERT_EQ(16U, md_stack->GetSize()); - const uint8_t *md_stack_bytes = md_stack->GetMemory(); + const uint8_t* md_stack_bytes = md_stack->GetMemory(); ASSERT_TRUE(memcmp("stack for thread", md_stack_bytes, 16) == 0); - MinidumpContext *md_context = md_thread->GetContext(); + MinidumpContext* md_context = md_thread->GetContext(); ASSERT_TRUE(md_context != NULL); ASSERT_EQ((uint32_t) MD_CONTEXT_X86, md_context->GetContextCPU()); @@ -291,7 +291,7 @@ TEST(Dump, OneThread) { ASSERT_TRUE(md_context->GetInstructionPointer(&eip)); EXPECT_EQ(kExpectedEIP, eip); - const MDRawContextX86 *md_raw_context = md_context->GetContextX86(); + const MDRawContextX86* md_raw_context = md_context->GetContextX86(); ASSERT_TRUE(md_raw_context != NULL); ASSERT_EQ((uint32_t) (MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL), (md_raw_context->context_flags @@ -425,16 +425,16 @@ TEST(Dump, OneUnloadedModule) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(2U, minidump.GetDirectoryEntryCount()); - const MDRawDirectory *dir = minidump.GetDirectoryEntryAtIndex(1); + const MDRawDirectory* dir = minidump.GetDirectoryEntryAtIndex(1); ASSERT_TRUE(dir != NULL); EXPECT_EQ((uint32_t) MD_UNLOADED_MODULE_LIST_STREAM, dir->stream_type); - MinidumpUnloadedModuleList *md_unloaded_module_list = + MinidumpUnloadedModuleList* md_unloaded_module_list = minidump.GetUnloadedModuleList(); ASSERT_TRUE(md_unloaded_module_list != NULL); ASSERT_EQ(1U, md_unloaded_module_list->module_count()); - const MinidumpUnloadedModule *md_unloaded_module = + const MinidumpUnloadedModule* md_unloaded_module = md_unloaded_module_list->GetModuleAtIndex(0); ASSERT_TRUE(md_unloaded_module != NULL); ASSERT_EQ(0xa90206ca83eb2852ULL, md_unloaded_module->base_address()); @@ -445,7 +445,7 @@ TEST(Dump, OneUnloadedModule) { ASSERT_EQ("B1054D2Aada542bd", md_unloaded_module->code_identifier()); ASSERT_EQ("", md_unloaded_module->debug_identifier()); - const MDRawUnloadedModule *md_raw_unloaded_module = + const MDRawUnloadedModule* md_raw_unloaded_module = md_unloaded_module->module(); ASSERT_TRUE(md_raw_unloaded_module != NULL); ASSERT_EQ(0xb1054d2aU, md_raw_unloaded_module->time_date_stamp); @@ -506,15 +506,15 @@ TEST(Dump, OneModule) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(2U, minidump.GetDirectoryEntryCount()); - const MDRawDirectory *dir = minidump.GetDirectoryEntryAtIndex(1); + const MDRawDirectory* dir = minidump.GetDirectoryEntryAtIndex(1); ASSERT_TRUE(dir != NULL); EXPECT_EQ((uint32_t) MD_MODULE_LIST_STREAM, dir->stream_type); - MinidumpModuleList *md_module_list = minidump.GetModuleList(); + MinidumpModuleList* md_module_list = minidump.GetModuleList(); ASSERT_TRUE(md_module_list != NULL); ASSERT_EQ(1U, md_module_list->module_count()); - const MinidumpModule *md_module = md_module_list->GetModuleAtIndex(0); + const MinidumpModule* md_module = md_module_list->GetModuleAtIndex(0); ASSERT_TRUE(md_module != NULL); ASSERT_EQ(0xa90206ca83eb2852ULL, md_module->base_address()); ASSERT_EQ(0xada542bd, md_module->size()); @@ -524,7 +524,7 @@ TEST(Dump, OneModule) { ASSERT_EQ("B1054D2Aada542bd", md_module->code_identifier()); ASSERT_EQ("ABCD1234F00DBEEF01020304050607081", md_module->debug_identifier()); - const MDRawModule *md_raw_module = md_module->module(); + const MDRawModule* md_raw_module = md_module->module(); ASSERT_TRUE(md_raw_module != NULL); ASSERT_EQ(0xb1054d2aU, md_raw_module->time_date_stamp); ASSERT_EQ(0x34571371U, md_raw_module->checksum); @@ -588,11 +588,11 @@ TEST(Dump, OneModuleCVELF) { Minidump minidump(minidump_stream); ASSERT_TRUE(minidump.Read()); - MinidumpModuleList *md_module_list = minidump.GetModuleList(); + MinidumpModuleList* md_module_list = minidump.GetModuleList(); ASSERT_TRUE(md_module_list != NULL); ASSERT_EQ(1U, md_module_list->module_count()); - const MinidumpModule *md_module = md_module_list->GetModuleAtIndex(0); + const MinidumpModule* md_module = md_module_list->GetModuleAtIndex(0); ASSERT_TRUE(md_module != NULL); ASSERT_EQ(0xa90206ca83eb2852ULL, md_module->base_address()); ASSERT_EQ(0xada542bd, md_module->size()); @@ -606,7 +606,7 @@ TEST(Dump, OneModuleCVELF) { // age appended ASSERT_EQ("B4CDA95F53101BDF86FAB733B4DF37380", md_module->debug_identifier()); - const MDRawModule *md_raw_module = md_module->module(); + const MDRawModule* md_raw_module = md_module->module(); ASSERT_TRUE(md_raw_module != NULL); ASSERT_EQ(0xb1054d2aU, md_raw_module->time_date_stamp); ASSERT_EQ(0x34571371U, md_raw_module->checksum); @@ -670,11 +670,11 @@ TEST(Dump, CVELFShort) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(2U, minidump.GetDirectoryEntryCount()); - MinidumpModuleList *md_module_list = minidump.GetModuleList(); + MinidumpModuleList* md_module_list = minidump.GetModuleList(); ASSERT_TRUE(md_module_list != NULL); ASSERT_EQ(1U, md_module_list->module_count()); - const MinidumpModule *md_module = md_module_list->GetModuleAtIndex(0); + const MinidumpModule* md_module = md_module_list->GetModuleAtIndex(0); ASSERT_TRUE(md_module != NULL); // just the build_id, directly ASSERT_EQ("5fa9cdb4", md_module->code_identifier()); @@ -742,11 +742,11 @@ TEST(Dump, CVELFLong) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(2U, minidump.GetDirectoryEntryCount()); - MinidumpModuleList *md_module_list = minidump.GetModuleList(); + MinidumpModuleList* md_module_list = minidump.GetModuleList(); ASSERT_TRUE(md_module_list != NULL); ASSERT_EQ(1U, md_module_list->module_count()); - const MinidumpModule *md_module = md_module_list->GetModuleAtIndex(0); + const MinidumpModule* md_module = md_module_list->GetModuleAtIndex(0); ASSERT_TRUE(md_module != NULL); // just the build_id, directly ASSERT_EQ( @@ -773,11 +773,11 @@ TEST(Dump, OneSystemInfo) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(1U, minidump.GetDirectoryEntryCount()); - const MDRawDirectory *dir = minidump.GetDirectoryEntryAtIndex(0); + const MDRawDirectory* dir = minidump.GetDirectoryEntryAtIndex(0); ASSERT_TRUE(dir != NULL); EXPECT_EQ((uint32_t) MD_SYSTEM_INFO_STREAM, dir->stream_type); - MinidumpSystemInfo *md_system_info = minidump.GetSystemInfo(); + MinidumpSystemInfo* md_system_info = minidump.GetSystemInfo(); ASSERT_TRUE(md_system_info != NULL); ASSERT_EQ("windows", md_system_info->GetOS()); ASSERT_EQ("x86", md_system_info->GetCPU()); @@ -912,7 +912,7 @@ TEST(Dump, BigDump) { ASSERT_EQ(5U, minidump.GetDirectoryEntryCount()); // Check the threads. - MinidumpThreadList *thread_list = minidump.GetThreadList(); + MinidumpThreadList* thread_list = minidump.GetThreadList(); ASSERT_TRUE(thread_list != NULL); ASSERT_EQ(5U, thread_list->thread_count()); uint32_t thread_id; @@ -957,7 +957,7 @@ TEST(Dump, BigDump) { ->eip); // Check the modules. - MinidumpModuleList *md_module_list = minidump.GetModuleList(); + MinidumpModuleList* md_module_list = minidump.GetModuleList(); ASSERT_TRUE(md_module_list != NULL); ASSERT_EQ(3U, md_module_list->module_count()); EXPECT_EQ(0xeb77da57b5d4cbdaULL, @@ -968,7 +968,7 @@ TEST(Dump, BigDump) { md_module_list->GetModuleAtIndex(2)->base_address()); // Check unloaded modules - MinidumpUnloadedModuleList *md_unloaded_module_list = + MinidumpUnloadedModuleList* md_unloaded_module_list = minidump.GetUnloadedModuleList(); ASSERT_TRUE(md_unloaded_module_list != NULL); ASSERT_EQ(3U, md_unloaded_module_list->module_count()); @@ -979,7 +979,7 @@ TEST(Dump, BigDump) { EXPECT_EQ(umodule3_base, md_unloaded_module_list->GetModuleAtIndex(2)->base_address()); - const MinidumpUnloadedModule *umodule = + const MinidumpUnloadedModule* umodule = md_unloaded_module_list->GetModuleForAddress( umodule1_base + umodule1_size / 2); EXPECT_EQ(umodule1_base, umodule->base_address()); @@ -1025,22 +1025,22 @@ TEST(Dump, OneMemoryInfo) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(1U, minidump.GetDirectoryEntryCount()); - const MDRawDirectory *dir = minidump.GetDirectoryEntryAtIndex(0); + const MDRawDirectory* dir = minidump.GetDirectoryEntryAtIndex(0); ASSERT_TRUE(dir != NULL); EXPECT_EQ((uint32_t) MD_MEMORY_INFO_LIST_STREAM, dir->stream_type); - MinidumpMemoryInfoList *info_list = minidump.GetMemoryInfoList(); + MinidumpMemoryInfoList* info_list = minidump.GetMemoryInfoList(); ASSERT_TRUE(info_list != NULL); ASSERT_EQ(1U, info_list->info_count()); - const MinidumpMemoryInfo *info1 = info_list->GetMemoryInfoAtIndex(0); + const MinidumpMemoryInfo* info1 = info_list->GetMemoryInfoAtIndex(0); ASSERT_EQ(kBaseAddress, info1->GetBase()); ASSERT_EQ(kRegionSize, info1->GetSize()); ASSERT_TRUE(info1->IsExecutable()); ASSERT_TRUE(info1->IsWritable()); // Should get back the same memory region here. - const MinidumpMemoryInfo *info2 = + const MinidumpMemoryInfo* info2 = info_list->GetMemoryInfoForAddress(kBaseAddress + kRegionSize / 2); ASSERT_EQ(kBaseAddress, info2->GetBase()); ASSERT_EQ(kRegionSize, info2->GetSize()); @@ -1083,7 +1083,7 @@ TEST(Dump, OneExceptionX86) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(1U, minidump.GetDirectoryEntryCount()); - MinidumpException *md_exception = minidump.GetException(); + MinidumpException* md_exception = minidump.GetException(); ASSERT_TRUE(md_exception != NULL); uint32_t thread_id; @@ -1097,10 +1097,10 @@ TEST(Dump, OneExceptionX86) { EXPECT_EQ(0x0919a9b9c9d9e9f9ULL, raw_exception->exception_record.exception_address); - MinidumpContext *md_context = md_exception->GetContext(); + MinidumpContext* md_context = md_exception->GetContext(); ASSERT_TRUE(md_context != NULL); ASSERT_EQ((uint32_t) MD_CONTEXT_X86, md_context->GetContextCPU()); - const MDRawContextX86 *md_raw_context = md_context->GetContextX86(); + const MDRawContextX86* md_raw_context = md_context->GetContextX86(); ASSERT_TRUE(md_raw_context != NULL); ASSERT_EQ((uint32_t) (MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL), (md_raw_context->context_flags @@ -1157,7 +1157,7 @@ TEST(Dump, OneExceptionX86XState) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(1U, minidump.GetDirectoryEntryCount()); - MinidumpException *md_exception = minidump.GetException(); + MinidumpException* md_exception = minidump.GetException(); ASSERT_TRUE(md_exception != NULL); uint32_t thread_id; @@ -1171,10 +1171,10 @@ TEST(Dump, OneExceptionX86XState) { EXPECT_EQ(0x0919a9b9c9d9e9f9ULL, raw_exception->exception_record.exception_address); - MinidumpContext *md_context = md_exception->GetContext(); + MinidumpContext* md_context = md_exception->GetContext(); ASSERT_TRUE(md_context != NULL); ASSERT_EQ((uint32_t) MD_CONTEXT_X86, md_context->GetContextCPU()); - const MDRawContextX86 *md_raw_context = md_context->GetContextX86(); + const MDRawContextX86* md_raw_context = md_context->GetContextX86(); ASSERT_TRUE(md_raw_context != NULL); ASSERT_EQ((uint32_t) (MD_CONTEXT_X86_INTEGER | MD_CONTEXT_X86_CONTROL), (md_raw_context->context_flags @@ -1242,7 +1242,7 @@ TEST(Dump, OneExceptionX86NoCPUFlags) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(2U, minidump.GetDirectoryEntryCount()); - MinidumpException *md_exception = minidump.GetException(); + MinidumpException* md_exception = minidump.GetException(); ASSERT_TRUE(md_exception != NULL); uint32_t thread_id; @@ -1256,11 +1256,11 @@ TEST(Dump, OneExceptionX86NoCPUFlags) { EXPECT_EQ(0x0919a9b9c9d9e9f9ULL, raw_exception->exception_record.exception_address); - MinidumpContext *md_context = md_exception->GetContext(); + MinidumpContext* md_context = md_exception->GetContext(); ASSERT_TRUE(md_context != NULL); ASSERT_EQ((uint32_t) MD_CONTEXT_X86, md_context->GetContextCPU()); - const MDRawContextX86 *md_raw_context = md_context->GetContextX86(); + const MDRawContextX86* md_raw_context = md_context->GetContextX86(); ASSERT_TRUE(md_raw_context != NULL); // Even though the CPU flags were missing from the context_flags, the @@ -1324,7 +1324,7 @@ TEST(Dump, OneExceptionX86NoCPUFlagsNoSystemInfo) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(1U, minidump.GetDirectoryEntryCount()); - MinidumpException *md_exception = minidump.GetException(); + MinidumpException* md_exception = minidump.GetException(); ASSERT_TRUE(md_exception != NULL); uint32_t thread_id; @@ -1341,7 +1341,7 @@ TEST(Dump, OneExceptionX86NoCPUFlagsNoSystemInfo) { // The context record of the exception is unusable because the context_flags // don't have CPU type information and at the same time the minidump lacks // system info stream so it is impossible to deduce the CPU type. - MinidumpContext *md_context = md_exception->GetContext(); + MinidumpContext* md_context = md_exception->GetContext(); ASSERT_EQ(NULL, md_context); } @@ -1387,7 +1387,7 @@ TEST(Dump, OneExceptionARM) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(1U, minidump.GetDirectoryEntryCount()); - MinidumpException *md_exception = minidump.GetException(); + MinidumpException* md_exception = minidump.GetException(); ASSERT_TRUE(md_exception != NULL); uint32_t thread_id; @@ -1401,10 +1401,10 @@ TEST(Dump, OneExceptionARM) { EXPECT_EQ(0x0919a9b9c9d9e9f9ULL, raw_exception->exception_record.exception_address); - MinidumpContext *md_context = md_exception->GetContext(); + MinidumpContext* md_context = md_exception->GetContext(); ASSERT_TRUE(md_context != NULL); ASSERT_EQ((uint32_t) MD_CONTEXT_ARM, md_context->GetContextCPU()); - const MDRawContextARM *md_raw_context = md_context->GetContextARM(); + const MDRawContextARM* md_raw_context = md_context->GetContextARM(); ASSERT_TRUE(md_raw_context != NULL); ASSERT_EQ((uint32_t) MD_CONTEXT_ARM_INTEGER, (md_raw_context->context_flags @@ -1471,7 +1471,7 @@ TEST(Dump, OneExceptionARMOldFlags) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(1U, minidump.GetDirectoryEntryCount()); - MinidumpException *md_exception = minidump.GetException(); + MinidumpException* md_exception = minidump.GetException(); ASSERT_TRUE(md_exception != NULL); uint32_t thread_id; @@ -1485,10 +1485,10 @@ TEST(Dump, OneExceptionARMOldFlags) { EXPECT_EQ(0x0919a9b9c9d9e9f9ULL, raw_exception->exception_record.exception_address); - MinidumpContext *md_context = md_exception->GetContext(); + MinidumpContext* md_context = md_exception->GetContext(); ASSERT_TRUE(md_context != NULL); ASSERT_EQ((uint32_t) MD_CONTEXT_ARM, md_context->GetContextCPU()); - const MDRawContextARM *md_raw_context = md_context->GetContextARM(); + const MDRawContextARM* md_raw_context = md_context->GetContextARM(); ASSERT_TRUE(md_raw_context != NULL); ASSERT_EQ((uint32_t) MD_CONTEXT_ARM_INTEGER, (md_raw_context->context_flags @@ -1570,7 +1570,7 @@ TEST(Dump, OneExceptionMIPS) { ASSERT_TRUE(minidump.Read()); ASSERT_EQ(1U, minidump.GetDirectoryEntryCount()); - MinidumpException *md_exception = minidump.GetException(); + MinidumpException* md_exception = minidump.GetException(); ASSERT_TRUE(md_exception != NULL); uint32_t thread_id; diff --git a/src/processor/module_comparer.cc b/src/processor/module_comparer.cc index 025ab883..669f1133 100644 --- a/src/processor/module_comparer.cc +++ b/src/processor/module_comparer.cc @@ -52,7 +52,7 @@ namespace google_breakpad { -bool ModuleComparer::Compare(const string &symbol_data) { +bool ModuleComparer::Compare(const string& symbol_data) { scoped_ptr basic_module(new BasicModule("test_module")); scoped_ptr fast_module(new FastModule("test_module")); @@ -284,7 +284,7 @@ bool ModuleComparer::CompareCRM( while (iter1 != basic_crm->map_->end() && iter2 != fast_crm->map_.end()) { ASSERT_TRUE(iter1->first == iter2.GetKey()); - StaticContainedRangeMap *child = + StaticContainedRangeMap* child = new StaticContainedRangeMap( reinterpret_cast(iter2.GetValuePtr())); ASSERT_TRUE(CompareCRM(iter1->second, child)); diff --git a/src/processor/module_comparer.h b/src/processor/module_comparer.h index fcbd5177..3691081d 100644 --- a/src/processor/module_comparer.h +++ b/src/processor/module_comparer.h @@ -64,7 +64,7 @@ class ModuleComparer { // FastSourceLineResolver loads its module using the serialized memory chunk, // Then, traverse both modules together and compare underlying data // return true if both modules contain exactly same data. - bool Compare(const string &symbol_data); + bool Compare(const string& symbol_data); private: typedef BasicSourceLineResolver::Module BasicModule; diff --git a/src/processor/module_factory.h b/src/processor/module_factory.h index 7aa7caa5..c6465f42 100644 --- a/src/processor/module_factory.h +++ b/src/processor/module_factory.h @@ -46,14 +46,14 @@ class ModuleFactory { public: virtual ~ModuleFactory() { }; virtual SourceLineResolverBase::Module* CreateModule( - const string &name) const = 0; + const string& name) const = 0; }; class BasicModuleFactory : public ModuleFactory { public: virtual ~BasicModuleFactory() { } virtual BasicSourceLineResolver::Module* CreateModule( - const string &name) const { + const string& name) const { return new BasicSourceLineResolver::Module(name); } }; @@ -62,7 +62,7 @@ class FastModuleFactory : public ModuleFactory { public: virtual ~FastModuleFactory() { } virtual FastSourceLineResolver::Module* CreateModule( - const string &name) const { + const string& name) const { return new FastSourceLineResolver::Module(name); } }; diff --git a/src/processor/module_serializer.cc b/src/processor/module_serializer.cc index 6ac60c1f..04cadc80 100644 --- a/src/processor/module_serializer.cc +++ b/src/processor/module_serializer.cc @@ -48,7 +48,7 @@ namespace google_breakpad { RangeMapSerializer< MemAddr, linked_ptr > SimpleSerializer::range_map_serializer_; -size_t ModuleSerializer::SizeOf(const BasicSourceLineResolver::Module &module) { +size_t ModuleSerializer::SizeOf(const BasicSourceLineResolver::Module& module) { size_t total_size_alloc_ = 0; // Size of the "is_corrupt" flag. @@ -80,8 +80,8 @@ size_t ModuleSerializer::SizeOf(const BasicSourceLineResolver::Module &module) { return total_size_alloc_; } -char *ModuleSerializer::Write(const BasicSourceLineResolver::Module &module, - char *dest) { +char* ModuleSerializer::Write(const BasicSourceLineResolver::Module& module, + char* dest) { // Write the is_corrupt flag. dest = SimpleSerializer::Write(module.is_corrupt_, dest); // Write header. @@ -101,12 +101,12 @@ char *ModuleSerializer::Write(const BasicSourceLineResolver::Module &module, } char* ModuleSerializer::Serialize( - const BasicSourceLineResolver::Module &module, unsigned int *size) { + const BasicSourceLineResolver::Module& module, unsigned int* size) { // Compute size of memory to allocate. unsigned int size_to_alloc = SizeOf(module); // Allocate memory for serialized data. - char *serialized_data = new char[size_to_alloc]; + char* serialized_data = new char[size_to_alloc]; if (!serialized_data) { BPLOG(ERROR) << "ModuleSerializer: memory allocation failed, " << "size to alloc: " << size_to_alloc; @@ -115,7 +115,7 @@ char* ModuleSerializer::Serialize( } // Write serialized data to allocated memory chunk. - char *end_address = Write(module, serialized_data); + char* end_address = Write(module, serialized_data); // Verify the allocated memory size is equal to the size of data been written. unsigned int size_written = static_cast(end_address - serialized_data); @@ -131,8 +131,8 @@ char* ModuleSerializer::Serialize( } bool ModuleSerializer::SerializeModuleAndLoadIntoFastResolver( - const BasicSourceLineResolver::ModuleMap::const_iterator &iter, - FastSourceLineResolver *fast_resolver) { + const BasicSourceLineResolver::ModuleMap::const_iterator& iter, + FastSourceLineResolver* fast_resolver) { BPLOG(INFO) << "Converting symbol " << iter->first.c_str(); // Cast SourceLineResolverBase::Module* to BasicSourceLineResolver::Module*. @@ -161,8 +161,8 @@ bool ModuleSerializer::SerializeModuleAndLoadIntoFastResolver( } void ModuleSerializer::ConvertAllModules( - const BasicSourceLineResolver *basic_resolver, - FastSourceLineResolver *fast_resolver) { + const BasicSourceLineResolver* basic_resolver, + FastSourceLineResolver* fast_resolver) { // Check for NULL pointer. if (!basic_resolver || !fast_resolver) return; @@ -175,9 +175,9 @@ void ModuleSerializer::ConvertAllModules( } bool ModuleSerializer::ConvertOneModule( - const string &moduleid, - const BasicSourceLineResolver *basic_resolver, - FastSourceLineResolver *fast_resolver) { + const string& moduleid, + const BasicSourceLineResolver* basic_resolver, + FastSourceLineResolver* fast_resolver) { // Check for NULL pointer. if (!basic_resolver || !fast_resolver) return false; @@ -191,7 +191,7 @@ bool ModuleSerializer::ConvertOneModule( } char* ModuleSerializer::SerializeSymbolFileData( - const string &symbol_data, unsigned int *size) { + const string& symbol_data, unsigned int* size) { scoped_ptr module( new BasicSourceLineResolver::Module("no name")); scoped_array buffer(new char[symbol_data.size() + 1]); diff --git a/src/processor/module_serializer.h b/src/processor/module_serializer.h index effb0091..932ac3d7 100644 --- a/src/processor/module_serializer.h +++ b/src/processor/module_serializer.h @@ -61,38 +61,38 @@ class ModuleSerializer { public: // Compute the size of memory required to serialize a module. Return the // total size needed for serialization. - size_t SizeOf(const BasicSourceLineResolver::Module &module); + size_t SizeOf(const BasicSourceLineResolver::Module& module); // Write a module into an allocated memory chunk with required size. // Return the "end" of data, i.e., the address after the final byte of data. - char* Write(const BasicSourceLineResolver::Module &module, char *dest); + char* Write(const BasicSourceLineResolver::Module& module, char* dest); // Serializes a loaded Module object into a chunk of memory data and returns // the address of memory chunk. If size != NULL, *size is set to the memory // size allocated for the serialized data. // Caller takes the ownership of the memory chunk (allocated on heap), and // owner should call delete [] to free the memory after use. - char* Serialize(const BasicSourceLineResolver::Module &module, - unsigned int *size = NULL); + char* Serialize(const BasicSourceLineResolver::Module& module, + unsigned int* size = NULL); // Given the string format symbol_data, produces a chunk of serialized data. // Caller takes ownership of the serialized data (on heap), and owner should // call delete [] to free the memory after use. - char* SerializeSymbolFileData(const string &symbol_data, - unsigned int *size = NULL); + char* SerializeSymbolFileData(const string& symbol_data, + unsigned int* size = NULL); // Serializes one loaded module with given moduleid in the basic source line // resolver, and loads the serialized data into the fast source line resolver. // Return false if the basic source line doesn't have a module with the given // moduleid. - bool ConvertOneModule(const string &moduleid, - const BasicSourceLineResolver *basic_resolver, - FastSourceLineResolver *fast_resolver); + bool ConvertOneModule(const string& moduleid, + const BasicSourceLineResolver* basic_resolver, + FastSourceLineResolver* fast_resolver); // Serializes all the loaded modules in a basic source line resolver, and // loads the serialized data into a fast source line resolver. - void ConvertAllModules(const BasicSourceLineResolver *basic_resolver, - FastSourceLineResolver *fast_resolver); + void ConvertAllModules(const BasicSourceLineResolver* basic_resolver, + FastSourceLineResolver* fast_resolver); private: // Convenient type names. @@ -102,8 +102,8 @@ class ModuleSerializer { // Internal implementation for ConvertOneModule and ConvertAllModules methods. bool SerializeModuleAndLoadIntoFastResolver( - const BasicSourceLineResolver::ModuleMap::const_iterator &iter, - FastSourceLineResolver *fast_resolver); + const BasicSourceLineResolver::ModuleMap::const_iterator& iter, + FastSourceLineResolver* fast_resolver); // Number of Maps that Module class contains. static const int32_t kNumberMaps_ = diff --git a/src/processor/pathname_stripper.cc b/src/processor/pathname_stripper.cc index 839287bd..c425b46a 100644 --- a/src/processor/pathname_stripper.cc +++ b/src/processor/pathname_stripper.cc @@ -38,7 +38,7 @@ namespace google_breakpad { // static -string PathnameStripper::File(const string &path) { +string PathnameStripper::File(const string& path) { string::size_type slash = path.rfind('/'); string::size_type backslash = path.rfind('\\'); diff --git a/src/processor/pathname_stripper.h b/src/processor/pathname_stripper.h index 423ca0d0..fdf15e03 100644 --- a/src/processor/pathname_stripper.h +++ b/src/processor/pathname_stripper.h @@ -45,7 +45,7 @@ class PathnameStripper { // Given path, a pathname with components separated by slashes (/) or // backslashes (\), returns the trailing component, without any separator. // If path ends in a separator character, returns an empty string. - static string File(const string &path); + static string File(const string& path); }; } // namespace google_breakpad diff --git a/src/processor/pathname_stripper_unittest.cc b/src/processor/pathname_stripper_unittest.cc index 1bff4cb0..61f74fa5 100644 --- a/src/processor/pathname_stripper_unittest.cc +++ b/src/processor/pathname_stripper_unittest.cc @@ -80,7 +80,7 @@ static bool RunTests() { } // namespace -int main(int argc, char **argv) { +int main(int argc, char** argv) { BPLOG_INIT(&argc, &argv); return RunTests() ? 0 : 1; diff --git a/src/processor/postfix_evaluator-inl.h b/src/processor/postfix_evaluator-inl.h index d7dbeac2..f567b1c8 100644 --- a/src/processor/postfix_evaluator-inl.h +++ b/src/processor/postfix_evaluator-inl.h @@ -58,19 +58,19 @@ using std::ostringstream; // before returning failure. class AutoStackClearer { public: - explicit AutoStackClearer(vector *stack) : stack_(stack) {} + explicit AutoStackClearer(vector* stack) : stack_(stack) {} ~AutoStackClearer() { stack_->clear(); } private: - vector *stack_; + vector* stack_; }; template bool PostfixEvaluator::EvaluateToken( - const string &token, - const string &expression, - DictionaryValidityType *assigned) { + const string& token, + const string& expression, + DictionaryValidityType* assigned) { // There are enough binary operations that do exactly the same thing // (other than the specific operation, of course) that it makes sense // to share as much code as possible. @@ -203,8 +203,8 @@ bool PostfixEvaluator::EvaluateToken( template bool PostfixEvaluator::EvaluateInternal( - const string &expression, - DictionaryValidityType *assigned) { + const string& expression, + DictionaryValidityType* assigned) { // Tokenize, splitting on whitespace. istringstream stream(expression); string token; @@ -231,8 +231,8 @@ bool PostfixEvaluator::EvaluateInternal( } template -bool PostfixEvaluator::Evaluate(const string &expression, - DictionaryValidityType *assigned) { +bool PostfixEvaluator::Evaluate(const string& expression, + DictionaryValidityType* assigned) { // Ensure that the stack is cleared before returning. AutoStackClearer clearer(&stack_); @@ -250,8 +250,8 @@ bool PostfixEvaluator::Evaluate(const string &expression, } template -bool PostfixEvaluator::EvaluateForValue(const string &expression, - ValueType *result) { +bool PostfixEvaluator::EvaluateForValue(const string& expression, + ValueType* result) { // Ensure that the stack is cleared before returning. AutoStackClearer clearer(&stack_); @@ -271,7 +271,7 @@ bool PostfixEvaluator::EvaluateForValue(const string &expression, template typename PostfixEvaluator::PopResult PostfixEvaluator::PopValueOrIdentifier( - ValueType *value, string *identifier) { + ValueType* value, string* identifier) { // There needs to be at least one element on the stack to pop. if (!stack_.size()) return POP_RESULT_FAIL; @@ -314,7 +314,7 @@ PostfixEvaluator::PopValueOrIdentifier( template -bool PostfixEvaluator::PopValue(ValueType *value) { +bool PostfixEvaluator::PopValue(ValueType* value) { ValueType literal = ValueType(); string token; PopResult result; @@ -343,14 +343,14 @@ bool PostfixEvaluator::PopValue(ValueType *value) { template -bool PostfixEvaluator::PopValues(ValueType *value1, - ValueType *value2) { +bool PostfixEvaluator::PopValues(ValueType* value1, + ValueType* value2) { return PopValue(value2) && PopValue(value1); } template -void PostfixEvaluator::PushValue(const ValueType &value) { +void PostfixEvaluator::PushValue(const ValueType& value) { ostringstream token_stream; token_stream << value; stack_.push_back(token_stream.str()); diff --git a/src/processor/postfix_evaluator.h b/src/processor/postfix_evaluator.h index 94b66190..d847a9b1 100644 --- a/src/processor/postfix_evaluator.h +++ b/src/processor/postfix_evaluator.h @@ -95,7 +95,7 @@ class PostfixEvaluator { // (^) will not be supported. |dictionary| may be NULL, but evaluation // will fail in that case unless set_dictionary is used before calling // Evaluate. - PostfixEvaluator(DictionaryType *dictionary, const MemoryRegion *memory) + PostfixEvaluator(DictionaryType* dictionary, const MemoryRegion* memory) : dictionary_(dictionary), memory_(memory), stack_() {} // Evaluate the expression, starting with an empty stack. The results of @@ -105,18 +105,18 @@ class PostfixEvaluator { // non-NULL, any keys set in the dictionary as a result of evaluation // will also be set to true in assigned, providing a way to determine if // an expression modifies any of its input variables. - bool Evaluate(const string &expression, DictionaryValidityType *assigned); + bool Evaluate(const string& expression, DictionaryValidityType* assigned); // Like Evaluate, but provides the value left on the stack to the // caller. If evaluation succeeds and leaves exactly one value on // the stack, pop that value, store it in *result, and return true. // Otherwise, return false. - bool EvaluateForValue(const string &expression, ValueType *result); + bool EvaluateForValue(const string& expression, ValueType* result); DictionaryType* dictionary() const { return dictionary_; } // Reset the dictionary. PostfixEvaluator does not take ownership. - void set_dictionary(DictionaryType *dictionary) {dictionary_ = dictionary; } + void set_dictionary(DictionaryType* dictionary) {dictionary_ = dictionary; } private: // Return values for PopValueOrIdentifier @@ -132,40 +132,40 @@ class PostfixEvaluator { // if the topmost entry is a constant or variable identifier, and sets // |identifier| accordingly. Returns POP_RESULT_FAIL on failure, such // as when the stack is empty. - PopResult PopValueOrIdentifier(ValueType *value, string *identifier); + PopResult PopValueOrIdentifier(ValueType* value, string* identifier); // Retrieves the topmost value on the stack. If the topmost entry is // an identifier, the dictionary is queried for the identifier's value. // Returns false on failure, such as when the stack is empty or when // a nonexistent identifier is named. - bool PopValue(ValueType *value); + bool PopValue(ValueType* value); // Retrieves the top two values on the stack, in the style of PopValue. // value2 is popped before value1, so that value1 corresponds to the // entry that was pushed prior to value2. Returns false on failure. - bool PopValues(ValueType *value1, ValueType *value2); + bool PopValues(ValueType* value1, ValueType* value2); // Pushes a new value onto the stack. - void PushValue(const ValueType &value); + void PushValue(const ValueType& value); // Evaluate expression, updating *assigned if it is non-zero. Return // true if evaluation completes successfully. Do not clear the stack // upon successful evaluation. - bool EvaluateInternal(const string &expression, - DictionaryValidityType *assigned); + bool EvaluateInternal(const string& expression, + DictionaryValidityType* assigned); - bool EvaluateToken(const string &token, - const string &expression, - DictionaryValidityType *assigned); + bool EvaluateToken(const string& token, + const string& expression, + DictionaryValidityType* assigned); // The dictionary mapping constant and variable identifiers (strings) to // values. Keys beginning with '$' are treated as variable names, and // PostfixEvaluator is free to create and modify these keys. Weak pointer. - DictionaryType *dictionary_; + DictionaryType* dictionary_; // If non-NULL, the MemoryRegion used for dereference (^) operations. // If NULL, dereferencing is unsupported and will fail. Weak pointer. - const MemoryRegion *memory_; + const MemoryRegion* memory_; // The stack contains state information as execution progresses. Values // are pushed on to it as the expression string is read and as operations diff --git a/src/processor/postfix_evaluator_unittest.cc b/src/processor/postfix_evaluator_unittest.cc index f1189828..5a01584a 100644 --- a/src/processor/postfix_evaluator_unittest.cc +++ b/src/processor/postfix_evaluator_unittest.cc @@ -60,19 +60,19 @@ class FakeMemoryRegion : public MemoryRegion { public: virtual uint64_t GetBase() const { return 0; } virtual uint32_t GetSize() const { return 0; } - virtual bool GetMemoryAtAddress(uint64_t address, uint8_t *value) const { + virtual bool GetMemoryAtAddress(uint64_t address, uint8_t* value) const { *value = address + 1; return true; } - virtual bool GetMemoryAtAddress(uint64_t address, uint16_t *value) const { + virtual bool GetMemoryAtAddress(uint64_t address, uint16_t* value) const { *value = address + 1; return true; } - virtual bool GetMemoryAtAddress(uint64_t address, uint32_t *value) const { + virtual bool GetMemoryAtAddress(uint64_t address, uint32_t* value) const { *value = address + 1; return true; } - virtual bool GetMemoryAtAddress(uint64_t address, uint64_t *value) const { + virtual bool GetMemoryAtAddress(uint64_t address, uint64_t* value) const { *value = address + 1; return true; } @@ -94,17 +94,17 @@ struct EvaluateTest { struct EvaluateTestSet { // The dictionary used for all tests in the set. - PostfixEvaluator::DictionaryType *dictionary; + PostfixEvaluator::DictionaryType* dictionary; // The list of tests. - const EvaluateTest *evaluate_tests; + const EvaluateTest* evaluate_tests; // The number of tests. unsigned int evaluate_test_count; // Identifiers and their expected values upon completion of the Evaluate // tests in the set. - map *validate_data; + map* validate_data; }; @@ -227,9 +227,9 @@ static bool RunTests() { for (unsigned int evaluate_test_set_index = 0; evaluate_test_set_index < evaluate_test_set_count; ++evaluate_test_set_index) { - EvaluateTestSet *evaluate_test_set = + EvaluateTestSet* evaluate_test_set = &evaluate_test_sets[evaluate_test_set_index]; - const EvaluateTest *evaluate_tests = evaluate_test_set->evaluate_tests; + const EvaluateTest* evaluate_tests = evaluate_test_set->evaluate_tests; unsigned int evaluate_test_count = evaluate_test_set->evaluate_test_count; // The same dictionary will be used for each test in the set. Earlier @@ -242,7 +242,7 @@ static bool RunTests() { for (unsigned int evaluate_test_index = 0; evaluate_test_index < evaluate_test_count; ++evaluate_test_index) { - const EvaluateTest *evaluate_test = &evaluate_tests[evaluate_test_index]; + const EvaluateTest* evaluate_test = &evaluate_tests[evaluate_test_index]; // Do the test. bool result = postfix_evaluator.Evaluate(evaluate_test->expression, @@ -344,7 +344,7 @@ static bool RunTests() { postfix_evaluator.set_dictionary(&dictionary_2); for (int i = 0; i < evaluate_for_value_tests_2_size; i++) { - const EvaluateForValueTest *test = &evaluate_for_value_tests_2[i]; + const EvaluateForValueTest* test = &evaluate_for_value_tests_2[i]; unsigned int result; if (postfix_evaluator.EvaluateForValue(test->expression, &result) != test->evaluable) { @@ -396,7 +396,7 @@ static bool RunTests() { } // namespace -int main(int argc, char **argv) { +int main(int argc, char** argv) { BPLOG_INIT(&argc, &argv); return RunTests() ? 0 : 1; diff --git a/src/processor/process_state.cc b/src/processor/process_state.cc index 43c4a4b8..c9269e41 100644 --- a/src/processor/process_state.cc +++ b/src/processor/process_state.cc @@ -51,7 +51,7 @@ void ProcessState::Clear() { crash_address_ = 0; assertion_.clear(); requesting_thread_ = -1; - for (vector::const_iterator iterator = threads_.begin(); + for (vector::const_iterator iterator = threads_.begin(); iterator != threads_.end(); ++iterator) { delete *iterator; diff --git a/src/processor/range_map-inl.h b/src/processor/range_map-inl.h index 4d3b0eb9..6bfc7255 100644 --- a/src/processor/range_map-inl.h +++ b/src/processor/range_map-inl.h @@ -47,16 +47,16 @@ namespace google_breakpad { template -bool RangeMap::StoreRange(const AddressType &base, - const AddressType &size, - const EntryType &entry) { +bool RangeMap::StoreRange(const AddressType& base, + const AddressType& size, + const EntryType& entry) { return StoreRangeInternal(base, 0 /* delta */, size, entry); } template bool RangeMap::StoreRangeInternal( - const AddressType &base, const AddressType &delta, - const AddressType &size, const EntryType &entry) { + const AddressType& base, const AddressType& delta, + const AddressType& size, const EntryType& entry) { AddressType high = base + (size - 1); // Check for undersize or overflow. @@ -181,8 +181,8 @@ bool RangeMap::StoreRangeInternal( template bool RangeMap::RetrieveRange( - const AddressType &address, EntryType *entry, AddressType *entry_base, - AddressType *entry_delta, AddressType *entry_size) const { + const AddressType& address, EntryType* entry, AddressType* entry_base, + AddressType* entry_delta, AddressType* entry_size) const { BPLOG_IF(ERROR, !entry) << "RangeMap::RetrieveRange requires |entry|"; assert(entry); @@ -212,8 +212,8 @@ bool RangeMap::RetrieveRange( template bool RangeMap::RetrieveNearestRange( - const AddressType &address, EntryType *entry, AddressType *entry_base, - AddressType *entry_delta, AddressType *entry_size) const { + const AddressType& address, EntryType* entry, AddressType* entry_base, + AddressType* entry_delta, AddressType* entry_size) const { BPLOG_IF(ERROR, !entry) << "RangeMap::RetrieveNearestRange requires |entry|"; assert(entry); @@ -245,8 +245,8 @@ bool RangeMap::RetrieveNearestRange( template bool RangeMap::RetrieveRangeAtIndex( - int index, EntryType *entry, AddressType *entry_base, - AddressType *entry_delta, AddressType *entry_size) const { + int index, EntryType* entry, AddressType* entry_base, + AddressType* entry_delta, AddressType* entry_size) const { BPLOG_IF(ERROR, !entry) << "RangeMap::RetrieveRangeAtIndex requires |entry|"; assert(entry); diff --git a/src/processor/range_map.h b/src/processor/range_map.h index 33f32973..baea91cf 100644 --- a/src/processor/range_map.h +++ b/src/processor/range_map.h @@ -78,17 +78,17 @@ class RangeMap { // stored in the map. If enable_shrink_down is true and there is an overlap // between the current range and some other range (already in the map), // shrink down the range which ends at a higher address. - bool StoreRange(const AddressType &base, const AddressType &size, - const EntryType &entry); + bool StoreRange(const AddressType& base, const AddressType& size, + const EntryType& entry); // Locates the range encompassing the supplied address. If there is no such // range, returns false. entry_base, entry_delta, and entry_size, if // non-NULL, are set to the base, delta, and size of the entry's range. // A positive entry delta (> 0) indicates that there was an overlap and the // entry was shrunk down (original start address was increased by delta). - bool RetrieveRange(const AddressType &address, EntryType *entry, - AddressType *entry_base, AddressType *entry_delta, - AddressType *entry_size) const; + bool RetrieveRange(const AddressType& address, EntryType* entry, + AddressType* entry_base, AddressType* entry_delta, + AddressType* entry_size) const; // Locates the range encompassing the supplied address, if one exists. // If no range encompasses the supplied address, locates the nearest range @@ -97,9 +97,9 @@ class RangeMap { // if non-NULL, are set to the base, delta, and size of the entry's range. // A positive entry delta (> 0) indicates that there was an overlap and the // entry was shrunk down (original start address was increased by delta). - bool RetrieveNearestRange(const AddressType &address, EntryType *entry, - AddressType *entry_base, AddressType *entry_delta, - AddressType *entry_size) const; + bool RetrieveNearestRange(const AddressType& address, EntryType* entry, + AddressType* entry_base, AddressType* entry_delta, + AddressType* entry_size) const; // Treating all ranges as a list ordered by the address spaces that they // occupy, locates the range at the index specified by index. Returns @@ -110,9 +110,9 @@ class RangeMap { // entry was shrunk down (original start address was increased by delta). // // RetrieveRangeAtIndex is not optimized for speedy operation. - bool RetrieveRangeAtIndex(int index, EntryType *entry, - AddressType *entry_base, AddressType *entry_delta, - AddressType *entry_size) const; + bool RetrieveRangeAtIndex(int index, EntryType* entry, + AddressType* entry_base, AddressType* entry_delta, + AddressType* entry_size) const; // Returns the number of ranges stored in the RangeMap. int GetCount() const; @@ -128,13 +128,13 @@ class RangeMap { // Same a StoreRange() with the only exception that the |delta| can be // passed in. - bool StoreRangeInternal(const AddressType &base, const AddressType &delta, - const AddressType &size, const EntryType &entry); + bool StoreRangeInternal(const AddressType& base, const AddressType& delta, + const AddressType& size, const EntryType& entry); class Range { public: - Range(const AddressType &base, const AddressType &delta, - const EntryType &entry) + Range(const AddressType& base, const AddressType& delta, + const EntryType& entry) : base_(base), delta_(delta), entry_(entry) {} AddressType base() const { return base_; } diff --git a/src/processor/range_map_unittest.cc b/src/processor/range_map_unittest.cc index 31b89e5d..0f1c7131 100644 --- a/src/processor/range_map_unittest.cc +++ b/src/processor/range_map_unittest.cc @@ -92,7 +92,7 @@ struct RangeTest { // sequence on the same RangeMap. struct RangeTestSet { // An array of RangeTests - const RangeTest *range_tests; + const RangeTest* range_tests; // The number of tests in the set unsigned int range_test_count; @@ -102,7 +102,7 @@ struct RangeTestSet { // StoreTest uses the data in a RangeTest and calls StoreRange on the // test RangeMap. It returns true if the expected result occurred, and // false if something else happened. -static bool StoreTest(TestMap *range_map, const RangeTest *range_test) { +static bool StoreTest(TestMap* range_map, const RangeTest* range_test) { linked_ptr object(new CountedObject(range_test->id)); bool stored = range_map->StoreRange(range_test->address, range_test->size, @@ -126,7 +126,7 @@ static bool StoreTest(TestMap *range_map, const RangeTest *range_test) { // map entry at the specified range,) it returns true, otherwise, it returns // false. RetrieveTest will check the values around the base address and // the high address of a range to guard against off-by-one errors. -static bool RetrieveTest(TestMap *range_map, const RangeTest *range_test) { +static bool RetrieveTest(TestMap* range_map, const RangeTest* range_test) { for (unsigned int side = 0; side <= 1; ++side) { // When side == 0, check the low side (base address) of each range. // When side == 1, check the high side (base + size) of each range. @@ -270,9 +270,9 @@ static bool RetrieveTest(TestMap *range_map, const RangeTest *range_test) { // and verifying that each call returns a different object than the previous // call, and that ranges are returned with increasing base addresses. Returns // false if the test fails. -static bool RetrieveIndexTest(TestMap *range_map, int set) { +static bool RetrieveIndexTest(TestMap* range_map, int set) { linked_ptr object; - CountedObject *last_object = NULL; + CountedObject* last_object = NULL; AddressType last_base = 0; int object_count = range_map->GetCount(); @@ -469,7 +469,7 @@ static bool RunTests() { for (unsigned int range_test_set_index = 0; range_test_set_index < range_test_set_count; ++range_test_set_index) { - const RangeTest *range_tests = + const RangeTest* range_tests = range_test_sets[range_test_set_index].range_tests; unsigned int range_test_count = range_test_sets[range_test_set_index].range_test_count; @@ -480,7 +480,7 @@ static bool RunTests() { for (unsigned int range_test_index = 0; range_test_index < range_test_count; ++range_test_index) { - const RangeTest *range_test = &range_tests[range_test_index]; + const RangeTest* range_test = &range_tests[range_test_index]; if (!StoreTest(range_map.get(), range_test)) return false; @@ -512,7 +512,7 @@ static bool RunTests() { for (unsigned int range_test_index = 0; range_test_index < range_test_count; ++range_test_index) { - const RangeTest *range_test = &range_tests[range_test_index]; + const RangeTest* range_test = &range_tests[range_test_index]; if (!RetrieveTest(range_map.get(), range_test)) return false; } @@ -552,7 +552,7 @@ static bool RunTests() { } // namespace -int main(int argc, char **argv) { +int main(int argc, char** argv) { BPLOG_INIT(&argc, &argv); return RunTests() ? 0 : 1; diff --git a/src/processor/simple_serializer-inl.h b/src/processor/simple_serializer-inl.h index 606bb3ce..cb1a0408 100644 --- a/src/processor/simple_serializer-inl.h +++ b/src/processor/simple_serializer-inl.h @@ -56,12 +56,12 @@ class SimpleSerializer { public: static size_t SizeOf(bool boolean) { return 1; } - static char *Write(bool boolean, char *dest) { + static char* Write(bool boolean, char* dest) { *dest = static_cast(boolean? 255 : 0); return ++dest; } - static const char *Read(const char *source, bool *value) { + static const char* Read(const char* source, bool* value) { *value = ((*source) == 0 ? false : true); return ++source; } @@ -71,9 +71,9 @@ class SimpleSerializer { template<> class SimpleSerializer { public: - static size_t SizeOf(const string &str) { return str.size() + 1; } + static size_t SizeOf(const string& str) { return str.size() + 1; } - static char *Write(const string &str, char *dest) { + static char* Write(const string& str, char* dest) { strcpy(dest, str.c_str()); return dest + SizeOf(str); } @@ -83,11 +83,11 @@ class SimpleSerializer { template<> class SimpleSerializer { public: - static size_t SizeOf(const char *cstring) { + static size_t SizeOf(const char* cstring) { return strlen(cstring) + 1; } - static char *Write(const char *cstring, char *dest) { + static char* Write(const char* cstring, char* dest) { strcpy(dest, cstring); return dest + SizeOf(cstring); } @@ -98,13 +98,13 @@ template<> class SimpleSerializer { typedef BasicSourceLineResolver::Line Line; public: - static size_t SizeOf(const Line &line) { + static size_t SizeOf(const Line& line) { return SimpleSerializer::SizeOf(line.address) + SimpleSerializer::SizeOf(line.size) + SimpleSerializer::SizeOf(line.source_file_id) + SimpleSerializer::SizeOf(line.line); } - static char *Write(const Line &line, char *dest) { + static char* Write(const Line& line, char* dest) { dest = SimpleSerializer::Write(line.address, dest); dest = SimpleSerializer::Write(line.size, dest); dest = SimpleSerializer::Write(line.source_file_id, dest); @@ -118,12 +118,12 @@ template<> class SimpleSerializer { typedef BasicSourceLineResolver::PublicSymbol PublicSymbol; public: - static size_t SizeOf(const PublicSymbol &pubsymbol) { + static size_t SizeOf(const PublicSymbol& pubsymbol) { return SimpleSerializer::SizeOf(pubsymbol.name) + SimpleSerializer::SizeOf(pubsymbol.address) + SimpleSerializer::SizeOf(pubsymbol.parameter_size); } - static char *Write(const PublicSymbol &pubsymbol, char *dest) { + static char* Write(const PublicSymbol& pubsymbol, char* dest) { dest = SimpleSerializer::Write(pubsymbol.name, dest); dest = SimpleSerializer::Write(pubsymbol.address, dest); dest = SimpleSerializer::Write(pubsymbol.parameter_size, dest); @@ -135,7 +135,7 @@ class SimpleSerializer { template<> class SimpleSerializer { public: - static size_t SizeOf(const WindowsFrameInfo &wfi) { + static size_t SizeOf(const WindowsFrameInfo& wfi) { unsigned int size = 0; size += sizeof(int32_t); // wfi.type_ size += SimpleSerializer::SizeOf(wfi.valid); @@ -149,7 +149,7 @@ class SimpleSerializer { size += SimpleSerializer::SizeOf(wfi.program_string); return size; } - static char *Write(const WindowsFrameInfo &wfi, char *dest) { + static char* Write(const WindowsFrameInfo& wfi, char* dest) { dest = SimpleSerializer::Write( static_cast(wfi.type_), dest); dest = SimpleSerializer::Write(wfi.valid, dest); @@ -170,11 +170,11 @@ template<> class SimpleSerializer< linked_ptr > { typedef BasicSourceLineResolver::Line Line; public: - static size_t SizeOf(const linked_ptr &lineptr) { + static size_t SizeOf(const linked_ptr& lineptr) { if (lineptr.get() == NULL) return 0; return SimpleSerializer::SizeOf(*(lineptr.get())); } - static char *Write(const linked_ptr &lineptr, char *dest) { + static char* Write(const linked_ptr& lineptr, char* dest) { if (lineptr.get()) dest = SimpleSerializer::Write(*(lineptr.get()), dest); return dest; @@ -187,7 +187,7 @@ class SimpleSerializer { typedef BasicSourceLineResolver::Function Function; typedef BasicSourceLineResolver::Line Line; public: - static size_t SizeOf(const Function &func) { + static size_t SizeOf(const Function& func) { unsigned int size = 0; size += SimpleSerializer::SizeOf(func.name); size += SimpleSerializer::SizeOf(func.address); @@ -197,7 +197,7 @@ class SimpleSerializer { return size; } - static char *Write(const Function &func, char *dest) { + static char* Write(const Function& func, char* dest) { dest = SimpleSerializer::Write(func.name, dest); dest = SimpleSerializer::Write(func.address, dest); dest = SimpleSerializer::Write(func.size, dest); @@ -214,12 +214,12 @@ template<> class SimpleSerializer< linked_ptr > { typedef BasicSourceLineResolver::Function Function; public: - static size_t SizeOf(const linked_ptr &func) { + static size_t SizeOf(const linked_ptr& func) { if (!func.get()) return 0; return SimpleSerializer::SizeOf(*(func.get())); } - static char *Write(const linked_ptr &func, char *dest) { + static char* Write(const linked_ptr& func, char* dest) { if (func.get()) dest = SimpleSerializer::Write(*(func.get()), dest); return dest; @@ -230,11 +230,11 @@ template<> class SimpleSerializer< linked_ptr > { typedef BasicSourceLineResolver::PublicSymbol PublicSymbol; public: - static size_t SizeOf(const linked_ptr &pubsymbol) { + static size_t SizeOf(const linked_ptr& pubsymbol) { if (pubsymbol.get() == NULL) return 0; return SimpleSerializer::SizeOf(*(pubsymbol.get())); } - static char *Write(const linked_ptr &pubsymbol, char *dest) { + static char* Write(const linked_ptr& pubsymbol, char* dest) { if (pubsymbol.get()) dest = SimpleSerializer::Write(*(pubsymbol.get()), dest); return dest; @@ -244,11 +244,11 @@ class SimpleSerializer< linked_ptr > { template<> class SimpleSerializer< linked_ptr > { public: - static size_t SizeOf(const linked_ptr &wfi) { + static size_t SizeOf(const linked_ptr& wfi) { if (wfi.get() == NULL) return 0; return SimpleSerializer::SizeOf(*(wfi.get())); } - static char *Write(const linked_ptr &wfi, char *dest) { + static char* Write(const linked_ptr& wfi, char* dest) { if (wfi.get()) dest = SimpleSerializer::Write(*(wfi.get()), dest); return dest; diff --git a/src/processor/simple_serializer.h b/src/processor/simple_serializer.h index 275f51ce..9e51d806 100644 --- a/src/processor/simple_serializer.h +++ b/src/processor/simple_serializer.h @@ -49,10 +49,10 @@ typedef uint64_t MemAddr; template class SimpleSerializer { public: // Calculate and return the size of the 'item'. - static size_t SizeOf(const Type &item) { return sizeof(item); } + static size_t SizeOf(const Type& item) { return sizeof(item); } // Write 'item' to memory location 'dest', and return to the "end" address of // data written, i.e., the address after the final byte written. - static char *Write(const Type &item, char *dest) { + static char* Write(const Type& item, char* dest) { new (dest) Type(item); return dest + SizeOf(item); } diff --git a/src/processor/simple_symbol_supplier.cc b/src/processor/simple_symbol_supplier.cc index bc5ebb68..cdc3efbf 100644 --- a/src/processor/simple_symbol_supplier.cc +++ b/src/processor/simple_symbol_supplier.cc @@ -52,14 +52,14 @@ namespace google_breakpad { -static bool file_exists(const string &file_name) { +static bool file_exists(const string& file_name) { struct stat sb; return stat(file_name.c_str(), &sb) == 0; } SymbolSupplier::SymbolResult SimpleSymbolSupplier::GetSymbolFile( - const CodeModule *module, const SystemInfo *system_info, - string *symbol_file) { + const CodeModule* module, const SystemInfo* system_info, + string* symbol_file) { BPLOG_IF(ERROR, !symbol_file) << "SimpleSymbolSupplier::GetSymbolFile " "requires |symbol_file|"; assert(symbol_file); @@ -77,10 +77,10 @@ SymbolSupplier::SymbolResult SimpleSymbolSupplier::GetSymbolFile( } SymbolSupplier::SymbolResult SimpleSymbolSupplier::GetSymbolFile( - const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - string *symbol_data) { + const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + string* symbol_data) { assert(symbol_data); symbol_data->clear(); @@ -96,11 +96,11 @@ SymbolSupplier::SymbolResult SimpleSymbolSupplier::GetSymbolFile( } SymbolSupplier::SymbolResult SimpleSymbolSupplier::GetCStringSymbolData( - const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - char **symbol_data, - size_t *symbol_data_size) { + const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + char** symbol_data, + size_t* symbol_data_size) { assert(symbol_data); assert(symbol_data_size); @@ -123,13 +123,13 @@ SymbolSupplier::SymbolResult SimpleSymbolSupplier::GetCStringSymbolData( return s; } -void SimpleSymbolSupplier::FreeSymbolData(const CodeModule *module) { +void SimpleSymbolSupplier::FreeSymbolData(const CodeModule* module) { if (!module) { BPLOG(INFO) << "Cannot free symbol data buffer for NULL module"; return; } - map::iterator it = memory_buffers_.find(module->code_file()); + map::iterator it = memory_buffers_.find(module->code_file()); if (it == memory_buffers_.end()) { BPLOG(INFO) << "Cannot find symbol data buffer for module " << module->code_file(); @@ -140,8 +140,8 @@ void SimpleSymbolSupplier::FreeSymbolData(const CodeModule *module) { } SymbolSupplier::SymbolResult SimpleSymbolSupplier::GetSymbolFileAtPathFromRoot( - const CodeModule *module, const SystemInfo *system_info, - const string &root_path, string *symbol_file) { + const CodeModule* module, const SystemInfo* system_info, + const string& root_path, string* symbol_file) { BPLOG_IF(ERROR, !symbol_file) << "SimpleSymbolSupplier::GetSymbolFileAtPath " "requires |symbol_file|"; assert(symbol_file); diff --git a/src/processor/simple_symbol_supplier.h b/src/processor/simple_symbol_supplier.h index 0cde85cd..3a65c7e6 100644 --- a/src/processor/simple_symbol_supplier.h +++ b/src/processor/simple_symbol_supplier.h @@ -94,44 +94,44 @@ class SimpleSymbolSupplier : public SymbolSupplier { public: // Creates a new SimpleSymbolSupplier, using path as the root path where // symbols are stored. - explicit SimpleSymbolSupplier(const string &path) : paths_(1, path) {} + explicit SimpleSymbolSupplier(const string& path) : paths_(1, path) {} // Creates a new SimpleSymbolSupplier, using paths as a list of root // paths where symbols may be stored. - explicit SimpleSymbolSupplier(const vector &paths) : paths_(paths) {} + explicit SimpleSymbolSupplier(const vector& paths) : paths_(paths) {} virtual ~SimpleSymbolSupplier() {} // Returns the path to the symbol file for the given module. See the // description above. - virtual SymbolResult GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file); + virtual SymbolResult GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file); - virtual SymbolResult GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - string *symbol_data); + virtual SymbolResult GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + string* symbol_data); // Allocates data buffer on heap and writes symbol data into buffer. // Symbol supplier ALWAYS takes ownership of the data buffer. - virtual SymbolResult GetCStringSymbolData(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - char **symbol_data, - size_t *symbol_data_size); + virtual SymbolResult GetCStringSymbolData(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + char** symbol_data, + size_t* symbol_data_size); // Free the data buffer allocated in the above GetCStringSymbolData(); - virtual void FreeSymbolData(const CodeModule *module); + virtual void FreeSymbolData(const CodeModule* module); protected: - SymbolResult GetSymbolFileAtPathFromRoot(const CodeModule *module, - const SystemInfo *system_info, - const string &root_path, - string *symbol_file); + SymbolResult GetSymbolFileAtPathFromRoot(const CodeModule* module, + const SystemInfo* system_info, + const string& root_path, + string* symbol_file); private: - map memory_buffers_; + map memory_buffers_; vector paths_; }; diff --git a/src/processor/source_line_resolver_base.cc b/src/processor/source_line_resolver_base.cc index 6eff1f99..45a06cf3 100644 --- a/src/processor/source_line_resolver_base.cc +++ b/src/processor/source_line_resolver_base.cc @@ -51,7 +51,7 @@ using std::make_pair; namespace google_breakpad { SourceLineResolverBase::SourceLineResolverBase( - ModuleFactory *module_factory) + ModuleFactory* module_factory) : modules_(new ModuleMap), corrupt_modules_(new ModuleSet), memory_buffers_(new MemoryMap), @@ -85,9 +85,9 @@ SourceLineResolverBase::~SourceLineResolverBase() { module_factory_ = NULL; } -bool SourceLineResolverBase::ReadSymbolFile(const string &map_file, - char **symbol_data, - size_t *symbol_data_size) { +bool SourceLineResolverBase::ReadSymbolFile(const string& map_file, + char** symbol_data, + size_t* symbol_data_size) { if (symbol_data == NULL || symbol_data_size == NULL) { BPLOG(ERROR) << "Could not Read file into Null memory pointer"; return false; @@ -117,7 +117,7 @@ bool SourceLineResolverBase::ReadSymbolFile(const string &map_file, BPLOG(INFO) << "Opening " << map_file; - FILE *f = fopen(map_file.c_str(), "rt"); + FILE* f = fopen(map_file.c_str(), "rt"); if (!f) { string error_string; error_code = ErrnoString(&error_string); @@ -148,8 +148,8 @@ bool SourceLineResolverBase::ReadSymbolFile(const string &map_file, return true; } -bool SourceLineResolverBase::LoadModule(const CodeModule *module, - const string &map_file) { +bool SourceLineResolverBase::LoadModule(const CodeModule* module, + const string& map_file) { if (module == NULL) return false; @@ -163,7 +163,7 @@ bool SourceLineResolverBase::LoadModule(const CodeModule *module, BPLOG(INFO) << "Loading symbols for module " << module->code_file() << " from " << map_file; - char *memory_buffer; + char* memory_buffer; size_t memory_buffer_size; if (!ReadSymbolFile(map_file, &memory_buffer, &memory_buffer_size)) return false; @@ -184,7 +184,7 @@ bool SourceLineResolverBase::LoadModule(const CodeModule *module, } bool SourceLineResolverBase::LoadModuleUsingMapBuffer( - const CodeModule *module, const string &map_buffer) { + const CodeModule* module, const string& map_buffer) { if (module == NULL) return false; @@ -196,7 +196,7 @@ bool SourceLineResolverBase::LoadModuleUsingMapBuffer( } size_t memory_buffer_size = map_buffer.size() + 1; - char *memory_buffer = new char[memory_buffer_size]; + char* memory_buffer = new char[memory_buffer_size]; if (memory_buffer == NULL) { BPLOG(ERROR) << "Could not allocate memory for " << module->code_file(); return false; @@ -220,8 +220,8 @@ bool SourceLineResolverBase::LoadModuleUsingMapBuffer( } bool SourceLineResolverBase::LoadModuleUsingMemoryBuffer( - const CodeModule *module, - char *memory_buffer, + const CodeModule* module, + char* memory_buffer, size_t memory_buffer_size) { if (!module) return false; @@ -236,7 +236,7 @@ bool SourceLineResolverBase::LoadModuleUsingMemoryBuffer( BPLOG(INFO) << "Loading symbols for module " << module->code_file() << " from memory buffer"; - Module *basic_module = module_factory_->CreateModule(module->code_file()); + Module* basic_module = module_factory_->CreateModule(module->code_file()); // Ownership of memory is NOT transfered to Module::LoadMapFromMemory(). if (!basic_module->LoadMapFromMemory(memory_buffer, memory_buffer_size)) { @@ -259,13 +259,13 @@ bool SourceLineResolverBase::ShouldDeleteMemoryBufferAfterLoadModule() { return true; } -void SourceLineResolverBase::UnloadModule(const CodeModule *code_module) { +void SourceLineResolverBase::UnloadModule(const CodeModule* code_module) { if (!code_module) return; ModuleMap::iterator mod_iter = modules_->find(code_module->code_file()); if (mod_iter != modules_->end()) { - Module *symbol_module = mod_iter->second; + Module* symbol_module = mod_iter->second; delete symbol_module; corrupt_modules_->erase(mod_iter->first); modules_->erase(mod_iter); @@ -283,19 +283,19 @@ void SourceLineResolverBase::UnloadModule(const CodeModule *code_module) { } } -bool SourceLineResolverBase::HasModule(const CodeModule *module) { +bool SourceLineResolverBase::HasModule(const CodeModule* module) { if (!module) return false; return modules_->find(module->code_file()) != modules_->end(); } -bool SourceLineResolverBase::IsModuleCorrupt(const CodeModule *module) { +bool SourceLineResolverBase::IsModuleCorrupt(const CodeModule* module) { if (!module) return false; return corrupt_modules_->find(module->code_file()) != corrupt_modules_->end(); } -void SourceLineResolverBase::FillSourceLineInfo(StackFrame *frame) { +void SourceLineResolverBase::FillSourceLineInfo(StackFrame* frame) { if (frame->module) { ModuleMap::const_iterator it = modules_->find(frame->module->code_file()); if (it != modules_->end()) { @@ -304,8 +304,8 @@ void SourceLineResolverBase::FillSourceLineInfo(StackFrame *frame) { } } -WindowsFrameInfo *SourceLineResolverBase::FindWindowsFrameInfo( - const StackFrame *frame) { +WindowsFrameInfo* SourceLineResolverBase::FindWindowsFrameInfo( + const StackFrame* frame) { if (frame->module) { ModuleMap::const_iterator it = modules_->find(frame->module->code_file()); if (it != modules_->end()) { @@ -315,8 +315,8 @@ WindowsFrameInfo *SourceLineResolverBase::FindWindowsFrameInfo( return NULL; } -CFIFrameInfo *SourceLineResolverBase::FindCFIFrameInfo( - const StackFrame *frame) { +CFIFrameInfo* SourceLineResolverBase::FindCFIFrameInfo( + const StackFrame* frame) { if (frame->module) { ModuleMap::const_iterator it = modules_->find(frame->module->code_file()); if (it != modules_->end()) { @@ -327,12 +327,12 @@ CFIFrameInfo *SourceLineResolverBase::FindCFIFrameInfo( } bool SourceLineResolverBase::CompareString::operator()( - const string &s1, const string &s2) const { + const string& s1, const string& s2) const { return strcmp(s1.c_str(), s2.c_str()) < 0; } bool SourceLineResolverBase::Module::ParseCFIRuleSet( - const string &rule_set, CFIFrameInfo *frame_info) const { + const string& rule_set, CFIFrameInfo* frame_info) const { CFIFrameInfoParseHandler handler(frame_info); CFIRuleParser parser(&handler); return parser.Parse(rule_set); diff --git a/src/processor/source_line_resolver_base_types.h b/src/processor/source_line_resolver_base_types.h index ca744e00..db9f7b8e 100644 --- a/src/processor/source_line_resolver_base_types.h +++ b/src/processor/source_line_resolver_base_types.h @@ -56,14 +56,14 @@ namespace google_breakpad { class SourceLineResolverBase::AutoFileCloser { public: - explicit AutoFileCloser(FILE *file) : file_(file) {} + explicit AutoFileCloser(FILE* file) : file_(file) {} ~AutoFileCloser() { if (file_) fclose(file_); } private: - FILE *file_; + FILE* file_; }; struct SourceLineResolverBase::Line { @@ -82,7 +82,7 @@ struct SourceLineResolverBase::Line { struct SourceLineResolverBase::Function { Function() { } - Function(const string &function_name, + Function(const string& function_name, MemAddr function_address, MemAddr code_size, int set_parameter_size, @@ -133,7 +133,7 @@ class SourceLineResolverBase::Module { // The passed in |memory buffer| is of size |memory_buffer_size|. If it is // not null terminated, LoadMapFromMemory will null terminate it by modifying // the passed in buffer. - virtual bool LoadMapFromMemory(char *memory_buffer, + virtual bool LoadMapFromMemory(char* memory_buffer, size_t memory_buffer_size) = 0; // Tells whether the loaded symbol data is corrupt. Return value is @@ -142,24 +142,24 @@ class SourceLineResolverBase::Module { // Looks up the given relative address, and fills the StackFrame struct // with the result. - virtual void LookupAddress(StackFrame *frame) const = 0; + virtual void LookupAddress(StackFrame* frame) const = 0; // If Windows stack walking information is available covering ADDRESS, // return a WindowsFrameInfo structure describing it. If the information // is not available, returns NULL. A NULL return value does not indicate // an error. The caller takes ownership of any returned WindowsFrameInfo // object. - virtual WindowsFrameInfo * - FindWindowsFrameInfo(const StackFrame *frame) const = 0; + virtual WindowsFrameInfo* + FindWindowsFrameInfo(const StackFrame* frame) const = 0; // If CFI stack walking information is available covering ADDRESS, // return a CFIFrameInfo structure describing it. If the information // is not available, return NULL. The caller takes ownership of any // returned CFIFrameInfo object. - virtual CFIFrameInfo *FindCFIFrameInfo(const StackFrame *frame) const = 0; + virtual CFIFrameInfo* FindCFIFrameInfo(const StackFrame* frame) const = 0; protected: - virtual bool ParseCFIRuleSet(const string &rule_set, - CFIFrameInfo *frame_info) const; + virtual bool ParseCFIRuleSet(const string& rule_set, + CFIFrameInfo* frame_info) const; }; } // namespace google_breakpad diff --git a/src/processor/stackwalk_common.cc b/src/processor/stackwalk_common.cc index 704039f3..90475720 100644 --- a/src/processor/stackwalk_common.cc +++ b/src/processor/stackwalk_common.cc @@ -69,7 +69,7 @@ static const char kOutputSeparator = '|'; // of registers is completely printed, regardless of the number of calls // to PrintRegister. static const int kMaxWidth = 80; // optimize for an 80-column terminal -static int PrintRegister(const char *name, uint32_t value, int start_col) { +static int PrintRegister(const char* name, uint32_t value, int start_col) { char buffer[64]; snprintf(buffer, sizeof(buffer), " %5s = 0x%08x", name, value); @@ -83,7 +83,7 @@ static int PrintRegister(const char *name, uint32_t value, int start_col) { } // PrintRegister64 does the same thing, but for 64-bit registers. -static int PrintRegister64(const char *name, uint64_t value, int start_col) { +static int PrintRegister64(const char* name, uint64_t value, int start_col) { char buffer[64]; snprintf(buffer, sizeof(buffer), " %5s = 0x%016" PRIx64 , name, value); @@ -98,7 +98,7 @@ static int PrintRegister64(const char *name, uint64_t value, int start_col) { // StripSeparator takes a string |original| and returns a copy // of the string with all occurences of |kOutputSeparator| removed. -static string StripSeparator(const string &original) { +static string StripSeparator(const string& original) { string result = original; string::size_type position = 0; while ((position = result.find(kOutputSeparator, position)) != string::npos) { @@ -112,20 +112,20 @@ static string StripSeparator(const string &original) { } // PrintStackContents prints the stack contents of the current frame to stdout. -static void PrintStackContents(const string &indent, - const StackFrame *frame, - const StackFrame *prev_frame, - const string &cpu, - const MemoryRegion *memory, +static void PrintStackContents(const string& indent, + const StackFrame* frame, + const StackFrame* prev_frame, + const string& cpu, + const MemoryRegion* memory, const CodeModules* modules, - SourceLineResolverInterface *resolver) { + SourceLineResolverInterface* resolver) { // Find stack range. int word_length = 0; uint64_t stack_begin = 0, stack_end = 0; if (cpu == "x86") { word_length = 4; - const StackFrameX86 *frame_x86 = static_cast(frame); - const StackFrameX86 *prev_frame_x86 = + const StackFrameX86* frame_x86 = static_cast(frame); + const StackFrameX86* prev_frame_x86 = static_cast(prev_frame); if ((frame_x86->context_validity & StackFrameX86::CONTEXT_VALID_ESP) && (prev_frame_x86->context_validity & StackFrameX86::CONTEXT_VALID_ESP)) { @@ -134,9 +134,9 @@ static void PrintStackContents(const string &indent, } } else if (cpu == "amd64") { word_length = 8; - const StackFrameAMD64 *frame_amd64 = + const StackFrameAMD64* frame_amd64 = static_cast(frame); - const StackFrameAMD64 *prev_frame_amd64 = + const StackFrameAMD64* prev_frame_amd64 = static_cast(prev_frame); if ((frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_RSP) && (prev_frame_amd64->context_validity & @@ -146,8 +146,8 @@ static void PrintStackContents(const string &indent, } } else if (cpu == "arm") { word_length = 4; - const StackFrameARM *frame_arm = static_cast(frame); - const StackFrameARM *prev_frame_arm = + const StackFrameARM* frame_arm = static_cast(frame); + const StackFrameARM* prev_frame_arm = static_cast(prev_frame); if ((frame_arm->context_validity & StackFrameARM::CONTEXT_VALID_SP) && (prev_frame_arm->context_validity & StackFrameARM::CONTEXT_VALID_SP)) { @@ -156,9 +156,9 @@ static void PrintStackContents(const string &indent, } } else if (cpu == "arm64") { word_length = 8; - const StackFrameARM64 *frame_arm64 = + const StackFrameARM64* frame_arm64 = static_cast(frame); - const StackFrameARM64 *prev_frame_arm64 = + const StackFrameARM64* prev_frame_arm64 = static_cast(prev_frame); if ((frame_arm64->context_validity & StackFrameARM64::CONTEXT_VALID_SP) && (prev_frame_arm64->context_validity & @@ -249,8 +249,8 @@ static void PrintStackContents(const string &indent, // // If |cpu| is a recognized CPU name, relevant register state for each stack // frame printed is also output, if available. -static void PrintStack(const CallStack *stack, - const string &cpu, +static void PrintStack(const CallStack* stack, + const string& cpu, bool output_stack_contents, const MemoryRegion* memory, const CodeModules* modules, @@ -260,7 +260,7 @@ static void PrintStack(const CallStack *stack, printf(" \n"); } for (int frame_index = 0; frame_index < frame_count; ++frame_index) { - const StackFrame *frame = stack->frames()->at(frame_index); + const StackFrame* frame = stack->frames()->at(frame_index); printf("%2d ", frame_index); uint64_t instruction_address = frame->ReturnAddress(); @@ -289,7 +289,7 @@ static void PrintStack(const CallStack *stack, int sequence = 0; if (cpu == "x86") { - const StackFrameX86 *frame_x86 = + const StackFrameX86* frame_x86 = reinterpret_cast(frame); if (frame_x86->context_validity & StackFrameX86::CONTEXT_VALID_EIP) @@ -311,7 +311,7 @@ static void PrintStack(const CallStack *stack, sequence = PrintRegister("efl", frame_x86->context.eflags, sequence); } } else if (cpu == "ppc") { - const StackFramePPC *frame_ppc = + const StackFramePPC* frame_ppc = reinterpret_cast(frame); if (frame_ppc->context_validity & StackFramePPC::CONTEXT_VALID_SRR0) @@ -319,7 +319,7 @@ static void PrintStack(const CallStack *stack, if (frame_ppc->context_validity & StackFramePPC::CONTEXT_VALID_GPR1) sequence = PrintRegister("r1", frame_ppc->context.gpr[1], sequence); } else if (cpu == "amd64") { - const StackFrameAMD64 *frame_amd64 = + const StackFrameAMD64* frame_amd64 = reinterpret_cast(frame); if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_RAX) @@ -357,7 +357,7 @@ static void PrintStack(const CallStack *stack, if (frame_amd64->context_validity & StackFrameAMD64::CONTEXT_VALID_RIP) sequence = PrintRegister64("rip", frame_amd64->context.rip, sequence); } else if (cpu == "sparc") { - const StackFrameSPARC *frame_sparc = + const StackFrameSPARC* frame_sparc = reinterpret_cast(frame); if (frame_sparc->context_validity & StackFrameSPARC::CONTEXT_VALID_SP) @@ -367,7 +367,7 @@ static void PrintStack(const CallStack *stack, if (frame_sparc->context_validity & StackFrameSPARC::CONTEXT_VALID_PC) sequence = PrintRegister("pc", frame_sparc->context.pc, sequence); } else if (cpu == "arm") { - const StackFrameARM *frame_arm = + const StackFrameARM* frame_arm = reinterpret_cast(frame); // Argument registers (caller-saves), which will likely only be valid @@ -409,7 +409,7 @@ static void PrintStack(const CallStack *stack, if (frame_arm->context_validity & StackFrameARM::CONTEXT_VALID_PC) sequence = PrintRegister("pc", frame_arm->context.iregs[15], sequence); } else if (cpu == "arm64") { - const StackFrameARM64 *frame_arm64 = + const StackFrameARM64* frame_arm64 = reinterpret_cast(frame); if (frame_arm64->context_validity & StackFrameARM64::CONTEXT_VALID_X0) { @@ -621,10 +621,10 @@ static void PrintStack(const CallStack *stack, // Module, function, source file, and source line may all be empty // depending on availability. The code offset follows the same rules as // PrintStack above. -static void PrintStackMachineReadable(int thread_num, const CallStack *stack) { +static void PrintStackMachineReadable(int thread_num, const CallStack* stack) { int frame_count = stack->frames()->size(); for (int frame_index = 0; frame_index < frame_count; ++frame_index) { - const StackFrame *frame = stack->frames()->at(frame_index); + const StackFrame* frame = stack->frames()->at(frame_index); printf("%d%c%d%c", thread_num, kOutputSeparator, frame_index, kOutputSeparator); @@ -676,8 +676,8 @@ static void PrintStackMachineReadable(int thread_num, const CallStack *stack) { // ContainsModule checks whether a given |module| is in the vector // |modules_without_symbols|. static bool ContainsModule( - const vector *modules, - const CodeModule *module) { + const vector* modules, + const CodeModule* module) { assert(modules); assert(module); vector::const_iterator iter; @@ -694,9 +694,9 @@ static bool ContainsModule( // |modules_without_symbols| should contain the list of modules that were // confirmed to be missing their symbols during the stack walk. static void PrintModule( - const CodeModule *module, - const vector *modules_without_symbols, - const vector *modules_with_corrupt_symbols, + const CodeModule* module, + const vector* modules_without_symbols, + const vector* modules_with_corrupt_symbols, uint64_t main_address) { string symbol_issues; if (ContainsModule(modules_without_symbols, module)) { @@ -721,9 +721,9 @@ static void PrintModule( // |modules_without_symbols| should contain the list of modules that were // confirmed to be missing their symbols during the stack walk. static void PrintModules( - const CodeModules *modules, - const vector *modules_without_symbols, - const vector *modules_with_corrupt_symbols) { + const CodeModules* modules, + const vector* modules_without_symbols, + const vector* modules_with_corrupt_symbols) { if (!modules) return; @@ -731,7 +731,7 @@ static void PrintModules( printf("Loaded modules:\n"); uint64_t main_address = 0; - const CodeModule *main_module = modules->GetMainModule(); + const CodeModule* main_module = modules->GetMainModule(); if (main_module) { main_address = main_module->base_address(); } @@ -740,7 +740,7 @@ static void PrintModules( for (unsigned int module_sequence = 0; module_sequence < module_count; ++module_sequence) { - const CodeModule *module = modules->GetModuleAtSequence(module_sequence); + const CodeModule* module = modules->GetModuleAtSequence(module_sequence); PrintModule(module, modules_without_symbols, modules_with_corrupt_symbols, main_address); } @@ -751,12 +751,12 @@ static void PrintModules( // text format: // Module|{Module Filename}|{Version}|{Debug Filename}|{Debug Identifier}| // {Base Address}|{Max Address}|{Main} -static void PrintModulesMachineReadable(const CodeModules *modules) { +static void PrintModulesMachineReadable(const CodeModules* modules) { if (!modules) return; uint64_t main_address = 0; - const CodeModule *main_module = modules->GetMainModule(); + const CodeModule* main_module = modules->GetMainModule(); if (main_module) { main_address = main_module->base_address(); } @@ -765,7 +765,7 @@ static void PrintModulesMachineReadable(const CodeModules *modules) { for (unsigned int module_sequence = 0; module_sequence < module_count; ++module_sequence) { - const CodeModule *module = modules->GetModuleAtSequence(module_sequence); + const CodeModule* module = modules->GetModuleAtSequence(module_sequence); uint64_t base_address = module->base_address(); printf("Module%c%s%c%s%c%s%c%s%c0x%08" PRIx64 "%c0x%08" PRIx64 "%c%d\n", kOutputSeparator, diff --git a/src/processor/stackwalker_address_list_unittest.cc b/src/processor/stackwalker_address_list_unittest.cc index ab4e9c08..b09137de 100644 --- a/src/processor/stackwalker_address_list_unittest.cc +++ b/src/processor/stackwalker_address_list_unittest.cc @@ -94,9 +94,9 @@ class StackwalkerAddressListTest : public testing::Test { // Set the Breakpad symbol information that supplier should return for // MODULE to INFO. - void SetModuleSymbols(MockCodeModule *module, const string &info) { + void SetModuleSymbols(MockCodeModule* module, const string& info) { size_t buffer_size; - char *buffer = supplier.CopySymbolDataAndOwnTheCopy(info, &buffer_size); + char* buffer = supplier.CopySymbolDataAndOwnTheCopy(info, &buffer_size); EXPECT_CALL(supplier, GetCStringSymbolData(module, NULL, _, _, _)) .WillRepeatedly(DoAll(SetArgumentPointee<3>(buffer), SetArgumentPointee<4>(buffer_size), diff --git a/src/processor/stackwalker_amd64.cc b/src/processor/stackwalker_amd64.cc index d5ac6c65..f906f20b 100644 --- a/src/processor/stackwalker_amd64.cc +++ b/src/processor/stackwalker_amd64.cc @@ -126,7 +126,7 @@ StackFrame* StackwalkerAMD64::GetContextFrame() { } StackFrameAMD64* StackwalkerAMD64::GetCallerByCFIFrameInfo( - const vector &frames, + const vector& frames, CFIFrameInfo* cfi_frame_info) { StackFrameAMD64* last_frame = static_cast(frames.back()); @@ -217,7 +217,7 @@ StackFrameAMD64* StackwalkerAMD64::GetCallerByFramePointerRecovery( } StackFrameAMD64* StackwalkerAMD64::GetCallerByStackScan( - const vector &frames) { + const vector& frames) { StackFrameAMD64* last_frame = static_cast(frames.back()); uint64_t last_rsp = last_frame->context.rsp; uint64_t caller_rip_address, caller_rip; @@ -273,7 +273,7 @@ StackFrame* StackwalkerAMD64::GetCallerFrame(const CallStack* stack, return NULL; } - const vector &frames = *stack->frames(); + const vector& frames = *stack->frames(); StackFrameAMD64* last_frame = static_cast(frames.back()); scoped_ptr new_frame; diff --git a/src/processor/stackwalker_amd64.h b/src/processor/stackwalker_amd64.h index 8f3dbd52..5e1af6f1 100644 --- a/src/processor/stackwalker_amd64.h +++ b/src/processor/stackwalker_amd64.h @@ -75,7 +75,7 @@ class StackwalkerAMD64 : public Stackwalker { // Use cfi_frame_info (derived from STACK CFI records) to construct // the frame that called frames.back(). The caller takes ownership // of the returned frame. Return NULL on failure. - StackFrameAMD64* GetCallerByCFIFrameInfo(const vector &frames, + StackFrameAMD64* GetCallerByCFIFrameInfo(const vector& frames, CFIFrameInfo* cfi_frame_info); // Assumes a traditional frame layout where the frame pointer has not been @@ -88,7 +88,7 @@ class StackwalkerAMD64 : public Stackwalker { // Scan the stack for plausible return addresses. The caller takes ownership // of the returned frame. Return NULL on failure. - StackFrameAMD64* GetCallerByStackScan(const vector &frames); + StackFrameAMD64* GetCallerByStackScan(const vector& frames); // Stores the CPU context corresponding to the innermost stack frame to // be returned by GetContextFrame. diff --git a/src/processor/stackwalker_amd64_unittest.cc b/src/processor/stackwalker_amd64_unittest.cc index efcd812a..a77015a6 100644 --- a/src/processor/stackwalker_amd64_unittest.cc +++ b/src/processor/stackwalker_amd64_unittest.cc @@ -104,7 +104,7 @@ class StackwalkerAMD64Fixture { // Set the Breakpad symbol information that supplier should return for // MODULE to INFO. - void SetModuleSymbols(MockCodeModule *module, const string &info) { + void SetModuleSymbols(MockCodeModule* module, const string& info) { size_t buffer_size; char *buffer = supplier.CopySymbolDataAndOwnTheCopy(info, &buffer_size); EXPECT_CALL(supplier, GetCStringSymbolData(module, &system_info, _, _, _)) @@ -125,7 +125,7 @@ class StackwalkerAMD64Fixture { void BrandContext(MDRawContextAMD64 *raw_context) { uint8_t x = 173; for (size_t i = 0; i < sizeof(*raw_context); i++) - reinterpret_cast(raw_context)[i] = (x += 17); + reinterpret_cast(raw_context)[i] = (x += 17); } SystemInfo system_info; @@ -138,7 +138,7 @@ class StackwalkerAMD64Fixture { MockSymbolSupplier supplier; BasicSourceLineResolver resolver; CallStack call_stack; - const vector *frames; + const vector* frames; }; class GetContextFrame: public StackwalkerAMD64Fixture, public Test { }; @@ -166,7 +166,7 @@ TEST_F(SanityCheck, NoResolver) { ASSERT_EQ(0U, modules_with_corrupt_symbols.size()); frames = call_stack.frames(); ASSERT_GE(1U, frames->size()); - StackFrameAMD64 *frame = static_cast(frames->at(0)); + StackFrameAMD64 *frame = static_cast(frames->at(0)); // Check that the values from the original raw context made it // through to the context in the stack frame. EXPECT_EQ(0, memcmp(&raw_context, &frame->context, sizeof(raw_context))); @@ -192,7 +192,7 @@ TEST_F(GetContextFrame, Simple) { ASSERT_EQ(0U, modules_with_corrupt_symbols.size()); frames = call_stack.frames(); ASSERT_GE(1U, frames->size()); - StackFrameAMD64 *frame = static_cast(frames->at(0)); + StackFrameAMD64 *frame = static_cast(frames->at(0)); // Check that the values from the original raw context made it // through to the context in the stack frame. EXPECT_EQ(0, memcmp(&raw_context, &frame->context, sizeof(raw_context))); @@ -216,7 +216,7 @@ TEST_F(GetContextFrame, NoStackMemory) { ASSERT_EQ(0U, modules_with_corrupt_symbols.size()); frames = call_stack.frames(); ASSERT_GE(1U, frames->size()); - StackFrameAMD64 *frame = static_cast(frames->at(0)); + StackFrameAMD64 *frame = static_cast(frames->at(0)); // Check that the values from the original raw context made it // through to the context in the stack frame. EXPECT_EQ(0, memcmp(&raw_context, &frame->context, sizeof(raw_context))); @@ -279,12 +279,12 @@ TEST_F(GetCallerFrame, ScanWithoutSymbols) { frames = call_stack.frames(); ASSERT_EQ(3U, frames->size()); - StackFrameAMD64 *frame0 = static_cast(frames->at(0)); + StackFrameAMD64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameAMD64::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); - StackFrameAMD64 *frame1 = static_cast(frames->at(1)); + StackFrameAMD64 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameAMD64::CONTEXT_VALID_RIP | StackFrameAMD64::CONTEXT_VALID_RSP | @@ -294,7 +294,7 @@ TEST_F(GetCallerFrame, ScanWithoutSymbols) { EXPECT_EQ(frame1_sp.Value(), frame1->context.rsp); EXPECT_EQ(frame1_rbp.Value(), frame1->context.rbp); - StackFrameAMD64 *frame2 = static_cast(frames->at(2)); + StackFrameAMD64 *frame2 = static_cast(frames->at(2)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame2->trust); ASSERT_EQ((StackFrameAMD64::CONTEXT_VALID_RIP | StackFrameAMD64::CONTEXT_VALID_RSP), @@ -352,13 +352,13 @@ TEST_F(GetCallerFrame, ScanWithFunctionSymbols) { frames = call_stack.frames(); ASSERT_EQ(2U, frames->size()); - StackFrameAMD64 *frame0 = static_cast(frames->at(0)); + StackFrameAMD64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameAMD64::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ("platypus", frame0->function_name); EXPECT_EQ(0x00007400c0000100ULL, frame0->function_base); - StackFrameAMD64 *frame1 = static_cast(frames->at(1)); + StackFrameAMD64 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameAMD64::CONTEXT_VALID_RIP | StackFrameAMD64::CONTEXT_VALID_RSP | @@ -464,7 +464,7 @@ TEST_F(GetCallerFrame, GetCallerByFramePointerRecovery) { ASSERT_EQ(3U, frames->size()); { // To avoid reusing locals by mistake - StackFrameAMD64 *frame = static_cast(frames->at(0)); + StackFrameAMD64 *frame = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame->trust); ASSERT_EQ(StackFrameAMD64::CONTEXT_VALID_ALL, frame->context_validity); EXPECT_EQ("", frame->function_name); @@ -475,7 +475,7 @@ TEST_F(GetCallerFrame, GetCallerByFramePointerRecovery) { } { // To avoid reusing locals by mistake - StackFrameAMD64 *frame = static_cast(frames->at(1)); + StackFrameAMD64 *frame = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame->trust); ASSERT_EQ((StackFrameAMD64::CONTEXT_VALID_RIP | StackFrameAMD64::CONTEXT_VALID_RSP | @@ -489,7 +489,7 @@ TEST_F(GetCallerFrame, GetCallerByFramePointerRecovery) { } { // To avoid reusing locals by mistake - StackFrameAMD64 *frame = static_cast(frames->at(2)); + StackFrameAMD64 *frame = static_cast(frames->at(2)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame->trust); ASSERT_EQ((StackFrameAMD64::CONTEXT_VALID_RIP | StackFrameAMD64::CONTEXT_VALID_RSP | @@ -540,12 +540,12 @@ TEST_F(GetCallerFrame, FramePointerNotAligned) { frames = call_stack.frames(); ASSERT_EQ(2U, frames->size()); - StackFrameAMD64 *frame0 = static_cast(frames->at(0)); + StackFrameAMD64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameAMD64::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); - StackFrameAMD64 *frame1 = static_cast(frames->at(1)); + StackFrameAMD64 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameAMD64::CONTEXT_VALID_RIP | StackFrameAMD64::CONTEXT_VALID_RSP), @@ -590,12 +590,12 @@ TEST_F(GetCallerFrame, NonCanonicalInstructionPointerFromFramePointer) { frames = call_stack.frames(); ASSERT_EQ(2U, frames->size()); - StackFrameAMD64 *frame0 = static_cast(frames->at(0)); + StackFrameAMD64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameAMD64::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); - StackFrameAMD64 *frame1 = static_cast(frames->at(1)); + StackFrameAMD64 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameAMD64::CONTEXT_VALID_RIP | StackFrameAMD64::CONTEXT_VALID_RSP), @@ -660,7 +660,7 @@ TEST_F(GetCallerFrame, ScanningNotAllowed) { frames = call_stack.frames(); ASSERT_EQ(1U, frames->size()); - StackFrameAMD64 *frame0 = static_cast(frames->at(0)); + StackFrameAMD64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameAMD64::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); @@ -718,14 +718,14 @@ TEST_F(GetCallerFrame, CallerPushedRBP) { frames = call_stack.frames(); ASSERT_EQ(2U, frames->size()); - StackFrameAMD64 *frame0 = static_cast(frames->at(0)); + StackFrameAMD64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameAMD64::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(frame0_rbp.Value(), frame0->context.rbp); EXPECT_EQ("sasquatch", frame0->function_name); EXPECT_EQ(0x00007400c0000100ULL, frame0->function_base); - StackFrameAMD64 *frame1 = static_cast(frames->at(1)); + StackFrameAMD64 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_FP, frame1->trust); ASSERT_EQ((StackFrameAMD64::CONTEXT_VALID_RIP | StackFrameAMD64::CONTEXT_VALID_RSP | @@ -799,13 +799,13 @@ struct CFIFixture: public StackwalkerAMD64Fixture { frames = call_stack.frames(); ASSERT_EQ(2U, frames->size()); - StackFrameAMD64 *frame0 = static_cast(frames->at(0)); + StackFrameAMD64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameAMD64::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ("enchiridion", frame0->function_name); EXPECT_EQ(0x00007400c0004000ULL, frame0->function_base); - StackFrameAMD64 *frame1 = static_cast(frames->at(1)); + StackFrameAMD64 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame1->trust); ASSERT_EQ((StackFrameAMD64::CONTEXT_VALID_RIP | StackFrameAMD64::CONTEXT_VALID_RSP | diff --git a/src/processor/stackwalker_arm.cc b/src/processor/stackwalker_arm.cc index 1313416f..f6f2c9bf 100644 --- a/src/processor/stackwalker_arm.cc +++ b/src/processor/stackwalker_arm.cc @@ -78,7 +78,7 @@ StackFrame* StackwalkerARM::GetContextFrame() { } StackFrameARM* StackwalkerARM::GetCallerByCFIFrameInfo( - const vector &frames, + const vector& frames, CFIFrameInfo* cfi_frame_info) { StackFrameARM* last_frame = static_cast(frames.back()); @@ -162,7 +162,7 @@ StackFrameARM* StackwalkerARM::GetCallerByCFIFrameInfo( } StackFrameARM* StackwalkerARM::GetCallerByStackScan( - const vector &frames) { + const vector& frames) { StackFrameARM* last_frame = static_cast(frames.back()); uint32_t last_sp = last_frame->context.iregs[MD_CONTEXT_ARM_REG_SP]; uint32_t caller_sp, caller_pc; @@ -193,7 +193,7 @@ StackFrameARM* StackwalkerARM::GetCallerByStackScan( } StackFrameARM* StackwalkerARM::GetCallerByFramePointer( - const vector &frames) { + const vector& frames) { StackFrameARM* last_frame = static_cast(frames.back()); if (!(last_frame->context_validity & @@ -245,7 +245,7 @@ StackFrame* StackwalkerARM::GetCallerFrame(const CallStack* stack, return NULL; } - const vector &frames = *stack->frames(); + const vector& frames = *stack->frames(); StackFrameARM* last_frame = static_cast(frames.back()); scoped_ptr frame; diff --git a/src/processor/stackwalker_arm.h b/src/processor/stackwalker_arm.h index 9081a40c..72ddddcc 100644 --- a/src/processor/stackwalker_arm.h +++ b/src/processor/stackwalker_arm.h @@ -75,16 +75,16 @@ class StackwalkerARM : public Stackwalker { // Use cfi_frame_info (derived from STACK CFI records) to construct // the frame that called frames.back(). The caller takes ownership // of the returned frame. Return NULL on failure. - StackFrameARM* GetCallerByCFIFrameInfo(const vector &frames, + StackFrameARM* GetCallerByCFIFrameInfo(const vector& frames, CFIFrameInfo* cfi_frame_info); // Use the frame pointer. The caller takes ownership of the returned frame. // Return NULL on failure. - StackFrameARM* GetCallerByFramePointer(const vector &frames); + StackFrameARM* GetCallerByFramePointer(const vector& frames); // Scan the stack for plausible return addresses. The caller takes ownership // of the returned frame. Return NULL on failure. - StackFrameARM* GetCallerByStackScan(const vector &frames); + StackFrameARM* GetCallerByStackScan(const vector& frames); // Stores the CPU context corresponding to the youngest stack frame, to // be returned by GetContextFrame. diff --git a/src/processor/stackwalker_arm64.cc b/src/processor/stackwalker_arm64.cc index 5bfd2636..9acf8188 100644 --- a/src/processor/stackwalker_arm64.cc +++ b/src/processor/stackwalker_arm64.cc @@ -99,7 +99,7 @@ StackFrame* StackwalkerARM64::GetContextFrame() { } StackFrameARM64* StackwalkerARM64::GetCallerByCFIFrameInfo( - const vector &frames, + const vector& frames, CFIFrameInfo* cfi_frame_info) { StackFrameARM64* last_frame = static_cast(frames.back()); @@ -175,7 +175,7 @@ StackFrameARM64* StackwalkerARM64::GetCallerByCFIFrameInfo( } StackFrameARM64* StackwalkerARM64::GetCallerByStackScan( - const vector &frames) { + const vector& frames) { StackFrameARM64* last_frame = static_cast(frames.back()); uint64_t last_sp = last_frame->context.iregs[MD_CONTEXT_ARM64_REG_SP]; uint64_t caller_sp, caller_pc; @@ -206,7 +206,7 @@ StackFrameARM64* StackwalkerARM64::GetCallerByStackScan( } StackFrameARM64* StackwalkerARM64::GetCallerByFramePointer( - const vector &frames) { + const vector& frames) { StackFrameARM64* last_frame = static_cast(frames.back()); if (!(last_frame->context_validity & StackFrameARM64::CONTEXT_VALID_LR)) { CorrectRegLRByFramePointer(frames, last_frame); @@ -294,7 +294,7 @@ StackFrame* StackwalkerARM64::GetCallerFrame(const CallStack* stack, return NULL; } - const vector &frames = *stack->frames(); + const vector& frames = *stack->frames(); StackFrameARM64* last_frame = static_cast(frames.back()); scoped_ptr frame; diff --git a/src/processor/stackwalker_arm64.h b/src/processor/stackwalker_arm64.h index 39735c67..4c7da3fb 100644 --- a/src/processor/stackwalker_arm64.h +++ b/src/processor/stackwalker_arm64.h @@ -79,16 +79,16 @@ class StackwalkerARM64 : public Stackwalker { // Use cfi_frame_info (derived from STACK CFI records) to construct // the frame that called frames.back(). The caller takes ownership // of the returned frame. Return NULL on failure. - StackFrameARM64* GetCallerByCFIFrameInfo(const vector &frames, + StackFrameARM64* GetCallerByCFIFrameInfo(const vector& frames, CFIFrameInfo* cfi_frame_info); // Use the frame pointer. The caller takes ownership of the returned frame. // Return NULL on failure. - StackFrameARM64* GetCallerByFramePointer(const vector &frames); + StackFrameARM64* GetCallerByFramePointer(const vector& frames); // Scan the stack for plausible return addresses. The caller takes ownership // of the returned frame. Return NULL on failure. - StackFrameARM64* GetCallerByStackScan(const vector &frames); + StackFrameARM64* GetCallerByStackScan(const vector& frames); // GetCallerByFramePointer() depends on the previous frame having recovered // x30($LR) which may not have been done when using CFI. diff --git a/src/processor/stackwalker_arm64_unittest.cc b/src/processor/stackwalker_arm64_unittest.cc index d86fa127..6553e0cd 100644 --- a/src/processor/stackwalker_arm64_unittest.cc +++ b/src/processor/stackwalker_arm64_unittest.cc @@ -105,7 +105,7 @@ class StackwalkerARM64Fixture { // Set the Breakpad symbol information that supplier should return for // MODULE to INFO. - void SetModuleSymbols(MockCodeModule *module, const string &info) { + void SetModuleSymbols(MockCodeModule* module, const string& info) { size_t buffer_size; char *buffer = supplier.CopySymbolDataAndOwnTheCopy(info, &buffer_size); EXPECT_CALL(supplier, GetCStringSymbolData(module, &system_info, _, _, _)) @@ -126,7 +126,7 @@ class StackwalkerARM64Fixture { void BrandContext(MDRawContextARM64 *raw_context) { uint8_t x = 173; for (size_t i = 0; i < sizeof(*raw_context); i++) - reinterpret_cast(raw_context)[i] = (x += 17); + reinterpret_cast(raw_context)[i] = (x += 17); } SystemInfo system_info; @@ -139,7 +139,7 @@ class StackwalkerARM64Fixture { MockSymbolSupplier supplier; BasicSourceLineResolver resolver; CallStack call_stack; - const vector *frames; + const vector* frames; }; class SanityCheck: public StackwalkerARM64Fixture, public Test { }; @@ -159,7 +159,7 @@ TEST_F(SanityCheck, NoResolver) { ASSERT_EQ(0U, modules_with_corrupt_symbols.size()); frames = call_stack.frames(); ASSERT_EQ(1U, frames->size()); - StackFrameARM64 *frame = static_cast(frames->at(0)); + StackFrameARM64 *frame = static_cast(frames->at(0)); // Check that the values from the original raw context made it // through to the context in the stack frame. EXPECT_EQ(0, memcmp(&raw_context, &frame->context, sizeof(raw_context))); @@ -181,7 +181,7 @@ TEST_F(GetContextFrame, NoStackMemory) { ASSERT_EQ(0U, modules_with_corrupt_symbols.size()); frames = call_stack.frames(); ASSERT_EQ(1U, frames->size()); - StackFrameARM64 *frame = static_cast(frames->at(0)); + StackFrameARM64 *frame = static_cast(frames->at(0)); // Check that the values from the original raw context made it // through to the context in the stack frame. EXPECT_EQ(0, memcmp(&raw_context, &frame->context, sizeof(raw_context))); @@ -237,13 +237,13 @@ TEST_F(GetCallerFrame, ScanWithoutSymbols) { frames = call_stack.frames(); ASSERT_EQ(3U, frames->size()); - StackFrameARM64 *frame0 = static_cast(frames->at(0)); + StackFrameARM64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameARM64::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); - StackFrameARM64 *frame1 = static_cast(frames->at(1)); + StackFrameARM64 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameARM64::CONTEXT_VALID_PC | StackFrameARM64::CONTEXT_VALID_SP), @@ -251,7 +251,7 @@ TEST_F(GetCallerFrame, ScanWithoutSymbols) { EXPECT_EQ(return_address1, frame1->context.iregs[MD_CONTEXT_ARM64_REG_PC]); EXPECT_EQ(frame1_sp.Value(), frame1->context.iregs[MD_CONTEXT_ARM64_REG_SP]); - StackFrameARM64 *frame2 = static_cast(frames->at(2)); + StackFrameARM64 *frame2 = static_cast(frames->at(2)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame2->trust); ASSERT_EQ((StackFrameARM64::CONTEXT_VALID_PC | StackFrameARM64::CONTEXT_VALID_SP), @@ -307,7 +307,7 @@ TEST_F(GetCallerFrame, ScanWithFunctionSymbols) { frames = call_stack.frames(); ASSERT_EQ(2U, frames->size()); - StackFrameARM64 *frame0 = static_cast(frames->at(0)); + StackFrameARM64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameARM64::CONTEXT_VALID_ALL, frame0->context_validity); @@ -315,7 +315,7 @@ TEST_F(GetCallerFrame, ScanWithFunctionSymbols) { EXPECT_EQ("monotreme", frame0->function_name); EXPECT_EQ(0x40000100ULL, frame0->function_base); - StackFrameARM64 *frame1 = static_cast(frames->at(1)); + StackFrameARM64 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameARM64::CONTEXT_VALID_PC | StackFrameARM64::CONTEXT_VALID_SP), @@ -376,13 +376,13 @@ TEST_F(GetCallerFrame, ScanFirstFrame) { frames = call_stack.frames(); ASSERT_EQ(2U, frames->size()); - StackFrameARM64 *frame0 = static_cast(frames->at(0)); + StackFrameARM64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameARM64::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); - StackFrameARM64 *frame1 = static_cast(frames->at(1)); + StackFrameARM64 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameARM64::CONTEXT_VALID_PC | StackFrameARM64::CONTEXT_VALID_SP), @@ -440,7 +440,7 @@ TEST_F(GetCallerFrame, ScanningNotAllowed) { frames = call_stack.frames(); ASSERT_EQ(1U, frames->size()); - StackFrameARM64 *frame0 = static_cast(frames->at(0)); + StackFrameARM64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameARM64::CONTEXT_VALID_ALL, frame0->context_validity); @@ -503,13 +503,13 @@ TEST_F(GetFramesByFramePointer, OnlyFramePointer) { frames = call_stack.frames(); ASSERT_EQ(3U, frames->size()); - StackFrameARM64 *frame0 = static_cast(frames->at(0)); + StackFrameARM64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameARM64::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); - StackFrameARM64 *frame1 = static_cast(frames->at(1)); + StackFrameARM64 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_FP, frame1->trust); ASSERT_EQ((StackFrameARM64::CONTEXT_VALID_PC | StackFrameARM64::CONTEXT_VALID_LR | @@ -522,7 +522,7 @@ TEST_F(GetFramesByFramePointer, OnlyFramePointer) { EXPECT_EQ(frame2_fp.Value(), frame1->context.iregs[MD_CONTEXT_ARM64_REG_FP]); - StackFrameARM64 *frame2 = static_cast(frames->at(2)); + StackFrameARM64 *frame2 = static_cast(frames->at(2)); EXPECT_EQ(StackFrame::FRAME_TRUST_FP, frame2->trust); ASSERT_EQ((StackFrameARM64::CONTEXT_VALID_PC | StackFrameARM64::CONTEXT_VALID_LR | @@ -642,13 +642,13 @@ struct CFIFixture: public StackwalkerARM64Fixture { frames = call_stack.frames(); ASSERT_EQ(2U, frames->size()); - StackFrameARM64 *frame0 = static_cast(frames->at(0)); + StackFrameARM64 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(context_frame_validity, frame0->context_validity); EXPECT_EQ("enchiridion", frame0->function_name); EXPECT_EQ(0x0000000040004000UL, frame0->function_base); - StackFrameARM64 *frame1 = static_cast(frames->at(1)); + StackFrameARM64 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame1->trust); ASSERT_EQ(expected_validity, frame1->context_validity); if (expected_validity & StackFrameARM64::CONTEXT_VALID_X1) diff --git a/src/processor/stackwalker_arm_unittest.cc b/src/processor/stackwalker_arm_unittest.cc index 256f7648..046081fa 100644 --- a/src/processor/stackwalker_arm_unittest.cc +++ b/src/processor/stackwalker_arm_unittest.cc @@ -106,7 +106,7 @@ class StackwalkerARMFixture { // Set the Breakpad symbol information that supplier should return for // MODULE to INFO. - void SetModuleSymbols(MockCodeModule *module, const string &info) { + void SetModuleSymbols(MockCodeModule* module, const string& info) { size_t buffer_size; char *buffer = supplier.CopySymbolDataAndOwnTheCopy(info, &buffer_size); EXPECT_CALL(supplier, GetCStringSymbolData(module, &system_info, _, _, _)) @@ -127,7 +127,7 @@ class StackwalkerARMFixture { void BrandContext(MDRawContextARM *raw_context) { uint8_t x = 173; for (size_t i = 0; i < sizeof(*raw_context); i++) - reinterpret_cast(raw_context)[i] = (x += 17); + reinterpret_cast(raw_context)[i] = (x += 17); } SystemInfo system_info; @@ -140,7 +140,7 @@ class StackwalkerARMFixture { MockSymbolSupplier supplier; BasicSourceLineResolver resolver; CallStack call_stack; - const vector *frames; + const vector* frames; }; class SanityCheck: public StackwalkerARMFixture, public Test { }; @@ -161,7 +161,7 @@ TEST_F(SanityCheck, NoResolver) { ASSERT_EQ(0U, modules_with_corrupt_symbols.size()); frames = call_stack.frames(); ASSERT_EQ(1U, frames->size()); - StackFrameARM *frame = static_cast(frames->at(0)); + StackFrameARM *frame = static_cast(frames->at(0)); // Check that the values from the original raw context made it // through to the context in the stack frame. EXPECT_EQ(0, memcmp(&raw_context, &frame->context, sizeof(raw_context))); @@ -184,7 +184,7 @@ TEST_F(GetContextFrame, Simple) { ASSERT_EQ(0U, modules_with_corrupt_symbols.size()); frames = call_stack.frames(); ASSERT_EQ(1U, frames->size()); - StackFrameARM *frame = static_cast(frames->at(0)); + StackFrameARM *frame = static_cast(frames->at(0)); // Check that the values from the original raw context made it // through to the context in the stack frame. EXPECT_EQ(0, memcmp(&raw_context, &frame->context, sizeof(raw_context))); @@ -204,7 +204,7 @@ TEST_F(GetContextFrame, NoStackMemory) { ASSERT_EQ(0U, modules_with_corrupt_symbols.size()); frames = call_stack.frames(); ASSERT_EQ(1U, frames->size()); - StackFrameARM *frame = static_cast(frames->at(0)); + StackFrameARM *frame = static_cast(frames->at(0)); // Check that the values from the original raw context made it // through to the context in the stack frame. EXPECT_EQ(0, memcmp(&raw_context, &frame->context, sizeof(raw_context))); @@ -260,12 +260,12 @@ TEST_F(GetCallerFrame, ScanWithoutSymbols) { frames = call_stack.frames(); ASSERT_EQ(3U, frames->size()); - StackFrameARM *frame0 = static_cast(frames->at(0)); + StackFrameARM *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameARM::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); - StackFrameARM *frame1 = static_cast(frames->at(1)); + StackFrameARM *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameARM::CONTEXT_VALID_PC | StackFrameARM::CONTEXT_VALID_SP), @@ -273,7 +273,7 @@ TEST_F(GetCallerFrame, ScanWithoutSymbols) { EXPECT_EQ(return_address1, frame1->context.iregs[MD_CONTEXT_ARM_REG_PC]); EXPECT_EQ(frame1_sp.Value(), frame1->context.iregs[MD_CONTEXT_ARM_REG_SP]); - StackFrameARM *frame2 = static_cast(frames->at(2)); + StackFrameARM *frame2 = static_cast(frames->at(2)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame2->trust); ASSERT_EQ((StackFrameARM::CONTEXT_VALID_PC | StackFrameARM::CONTEXT_VALID_SP), @@ -329,14 +329,14 @@ TEST_F(GetCallerFrame, ScanWithFunctionSymbols) { frames = call_stack.frames(); ASSERT_EQ(2U, frames->size()); - StackFrameARM *frame0 = static_cast(frames->at(0)); + StackFrameARM *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameARM::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); EXPECT_EQ("monotreme", frame0->function_name); EXPECT_EQ(0x40000100U, frame0->function_base); - StackFrameARM *frame1 = static_cast(frames->at(1)); + StackFrameARM *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameARM::CONTEXT_VALID_PC | StackFrameARM::CONTEXT_VALID_SP), @@ -397,12 +397,12 @@ TEST_F(GetCallerFrame, ScanFirstFrame) { frames = call_stack.frames(); ASSERT_EQ(2U, frames->size()); - StackFrameARM *frame0 = static_cast(frames->at(0)); + StackFrameARM *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameARM::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); - StackFrameARM *frame1 = static_cast(frames->at(1)); + StackFrameARM *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameARM::CONTEXT_VALID_PC | StackFrameARM::CONTEXT_VALID_SP), @@ -460,7 +460,7 @@ TEST_F(GetCallerFrame, ScanningNotAllowed) { frames = call_stack.frames(); ASSERT_EQ(1U, frames->size()); - StackFrameARM *frame0 = static_cast(frames->at(0)); + StackFrameARM *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameARM::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); @@ -565,13 +565,13 @@ struct CFIFixture: public StackwalkerARMFixture { frames = call_stack.frames(); ASSERT_EQ(2U, frames->size()); - StackFrameARM *frame0 = static_cast(frames->at(0)); + StackFrameARM *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(context_frame_validity, frame0->context_validity); EXPECT_EQ("enchiridion", frame0->function_name); EXPECT_EQ(0x40004000U, frame0->function_base); - StackFrameARM *frame1 = static_cast(frames->at(1)); + StackFrameARM *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame1->trust); ASSERT_EQ(expected_validity, frame1->context_validity); if (expected_validity & StackFrameARM::CONTEXT_VALID_R1) @@ -848,12 +848,12 @@ TEST_F(GetFramesByFramePointer, OnlyFramePointer) { frames = call_stack.frames(); ASSERT_EQ(3U, frames->size()); - StackFrameARM *frame0 = static_cast(frames->at(0)); + StackFrameARM *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameARM::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); - StackFrameARM *frame1 = static_cast(frames->at(1)); + StackFrameARM *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_FP, frame1->trust); ASSERT_EQ((StackFrameARM::CONTEXT_VALID_PC | StackFrameARM::CONTEXT_VALID_LR | @@ -866,7 +866,7 @@ TEST_F(GetFramesByFramePointer, OnlyFramePointer) { EXPECT_EQ(frame2_fp.Value(), frame1->context.iregs[MD_CONTEXT_ARM_REG_IOS_FP]); - StackFrameARM *frame2 = static_cast(frames->at(2)); + StackFrameARM *frame2 = static_cast(frames->at(2)); EXPECT_EQ(StackFrame::FRAME_TRUST_FP, frame2->trust); ASSERT_EQ((StackFrameARM::CONTEXT_VALID_PC | StackFrameARM::CONTEXT_VALID_LR | @@ -944,12 +944,12 @@ TEST_F(GetFramesByFramePointer, FramePointerAndCFI) { frames = call_stack.frames(); ASSERT_EQ(3U, frames->size()); - StackFrameARM *frame0 = static_cast(frames->at(0)); + StackFrameARM *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameARM::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0, memcmp(&raw_context, &frame0->context, sizeof(raw_context))); - StackFrameARM *frame1 = static_cast(frames->at(1)); + StackFrameARM *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_FP, frame1->trust); ASSERT_EQ((StackFrameARM::CONTEXT_VALID_PC | StackFrameARM::CONTEXT_VALID_LR | @@ -965,7 +965,7 @@ TEST_F(GetFramesByFramePointer, FramePointerAndCFI) { EXPECT_EQ(0x40004000U, frame1->function_base); - StackFrameARM *frame2 = static_cast(frames->at(2)); + StackFrameARM *frame2 = static_cast(frames->at(2)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame2->trust); ASSERT_EQ((StackFrameARM::CONTEXT_VALID_PC | StackFrameARM::CONTEXT_VALID_LR | diff --git a/src/processor/stackwalker_selftest.cc b/src/processor/stackwalker_selftest.cc index f692d4c4..dcb2df00 100644 --- a/src/processor/stackwalker_selftest.cc +++ b/src/processor/stackwalker_selftest.cc @@ -420,7 +420,7 @@ int main(int argc, char** argv) { // Not i386 or ppc or sparc? We can only test stacks we know how to walk. -int main(int argc, char **argv) { +int main(int argc, char** argv) { BPLOG_INIT(&argc, &argv); // "make check" interprets an exit status of 77 to mean that the test is diff --git a/src/processor/stackwalker_unittest_utils.h b/src/processor/stackwalker_unittest_utils.h index 3a92a5ea..2905ea06 100644 --- a/src/processor/stackwalker_unittest_utils.h +++ b/src/processor/stackwalker_unittest_utils.h @@ -57,7 +57,7 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion { // Set this region's address and contents. If we have placed an // instance of this class in a test fixture class, individual tests // can use this to provide the region's contents. - void Init(uint64_t base_address, const string &contents) { + void Init(uint64_t base_address, const string& contents) { base_address_ = base_address; contents_ = contents; } @@ -65,16 +65,16 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion { uint64_t GetBase() const { return base_address_; } uint32_t GetSize() const { return contents_.size(); } - bool GetMemoryAtAddress(uint64_t address, uint8_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint8_t* value) const { return GetMemoryLittleEndian(address, value); } - bool GetMemoryAtAddress(uint64_t address, uint16_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint16_t* value) const { return GetMemoryLittleEndian(address, value); } - bool GetMemoryAtAddress(uint64_t address, uint32_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint32_t* value) const { return GetMemoryLittleEndian(address, value); } - bool GetMemoryAtAddress(uint64_t address, uint64_t *value) const { + bool GetMemoryAtAddress(uint64_t address, uint64_t* value) const { return GetMemoryLittleEndian(address, value); } void Print() const { @@ -85,7 +85,7 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion { // Fetch a little-endian value from ADDRESS in contents_ whose size // is BYTES, and store it in *VALUE. Return true on success. template - bool GetMemoryLittleEndian(uint64_t address, ValueType *value) const { + bool GetMemoryLittleEndian(uint64_t address, ValueType* value) const { if (address < base_address_ || address - base_address_ + sizeof(ValueType) > contents_.size()) return false; @@ -105,7 +105,7 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion { class MockCodeModule: public google_breakpad::CodeModule { public: MockCodeModule(uint64_t base_address, uint64_t size, - const string &code_file, const string &version) + const string& code_file, const string& version) : base_address_(base_address), size_(size), code_file_(code_file) { } uint64_t base_address() const { return base_address_; } @@ -115,7 +115,7 @@ class MockCodeModule: public google_breakpad::CodeModule { string debug_file() const { return code_file_; } string debug_identifier() const { return code_file_; } string version() const { return version_; } - google_breakpad::CodeModule *Copy() const { + google_breakpad::CodeModule* Copy() const { abort(); // Tests won't use this. } virtual bool is_unloaded() const { return false; } @@ -134,16 +134,16 @@ class MockCodeModules: public google_breakpad::CodeModules { typedef google_breakpad::CodeModule CodeModule; typedef google_breakpad::CodeModules CodeModules; - void Add(const MockCodeModule *module) { + void Add(const MockCodeModule* module) { modules_.push_back(module); } unsigned int module_count() const { return modules_.size(); } - const CodeModule *GetModuleForAddress(uint64_t address) const { + const CodeModule* GetModuleForAddress(uint64_t address) const { for (ModuleVector::const_iterator i = modules_.begin(); i != modules_.end(); i++) { - const MockCodeModule *module = *i; + const MockCodeModule* module = *i; if (module->base_address() <= address && address - module->base_address() < module->size()) return module; @@ -151,17 +151,17 @@ class MockCodeModules: public google_breakpad::CodeModules { return NULL; }; - const CodeModule *GetMainModule() const { return modules_[0]; } + const CodeModule* GetMainModule() const { return modules_[0]; } - const CodeModule *GetModuleAtSequence(unsigned int sequence) const { + const CodeModule* GetModuleAtSequence(unsigned int sequence) const { return modules_.at(sequence); } - const CodeModule *GetModuleAtIndex(unsigned int index) const { + const CodeModule* GetModuleAtIndex(unsigned int index) const { return modules_.at(index); } - CodeModules *Copy() const { abort(); } // Tests won't use this + CodeModules* Copy() const { abort(); } // Tests won't use this virtual std::vector > GetShrunkRangeModules() const { @@ -169,7 +169,7 @@ class MockCodeModules: public google_breakpad::CodeModules { } private: - typedef std::vector ModuleVector; + typedef std::vector ModuleVector; ModuleVector modules_; }; @@ -177,26 +177,26 @@ class MockSymbolSupplier: public google_breakpad::SymbolSupplier { public: typedef google_breakpad::CodeModule CodeModule; typedef google_breakpad::SystemInfo SystemInfo; - MOCK_METHOD3(GetSymbolFile, SymbolResult(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file)); - MOCK_METHOD4(GetSymbolFile, SymbolResult(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - string *symbol_data)); - MOCK_METHOD5(GetCStringSymbolData, SymbolResult(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - char **symbol_data, - size_t *symbol_data_size)); - MOCK_METHOD1(FreeSymbolData, void(const CodeModule *module)); + MOCK_METHOD3(GetSymbolFile, SymbolResult(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file)); + MOCK_METHOD4(GetSymbolFile, SymbolResult(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + string* symbol_data)); + MOCK_METHOD5(GetCStringSymbolData, SymbolResult(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + char** symbol_data, + size_t* symbol_data_size)); + MOCK_METHOD1(FreeSymbolData, void(const CodeModule* module)); // Copies the passed string contents into a newly allocated buffer. // The newly allocated buffer will be freed during destruction. - char* CopySymbolDataAndOwnTheCopy(const string &info, - size_t *symbol_data_size) { + char* CopySymbolDataAndOwnTheCopy(const string& info, + size_t* symbol_data_size) { *symbol_data_size = info.size() + 1; - char *symbol_data = new char[*symbol_data_size]; + char* symbol_data = new char[*symbol_data_size]; memcpy(symbol_data, info.c_str(), info.size()); symbol_data[info.size()] = '\0'; symbol_data_to_free_.push_back(symbol_data); diff --git a/src/processor/stackwalker_x86.cc b/src/processor/stackwalker_x86.cc index ed2b383d..b11e061d 100644 --- a/src/processor/stackwalker_x86.cc +++ b/src/processor/stackwalker_x86.cc @@ -136,7 +136,7 @@ StackFrame* StackwalkerX86::GetContextFrame() { } StackFrameX86* StackwalkerX86::GetCallerByWindowsFrameInfo( - const vector &frames, + const vector& frames, WindowsFrameInfo* last_frame_info, bool stack_scan_allowed) { StackFrame::FrameTrust trust = StackFrame::FRAME_TRUST_NONE; @@ -514,7 +514,7 @@ StackFrameX86* StackwalkerX86::GetCallerByWindowsFrameInfo( } StackFrameX86* StackwalkerX86::GetCallerByCFIFrameInfo( - const vector &frames, + const vector& frames, CFIFrameInfo* cfi_frame_info) { StackFrameX86* last_frame = static_cast(frames.back()); last_frame->cfi_frame_info = cfi_frame_info; @@ -539,7 +539,7 @@ StackFrameX86* StackwalkerX86::GetCallerByCFIFrameInfo( } StackFrameX86* StackwalkerX86::GetCallerByEBPAtBase( - const vector &frames, + const vector& frames, bool stack_scan_allowed) { StackFrame::FrameTrust trust; StackFrameX86* last_frame = static_cast(frames.back()); @@ -632,7 +632,7 @@ StackFrame* StackwalkerX86::GetCallerFrame(const CallStack* stack, return NULL; } - const vector &frames = *stack->frames(); + const vector& frames = *stack->frames(); StackFrameX86* last_frame = static_cast(frames.back()); scoped_ptr new_frame; diff --git a/src/processor/stackwalker_x86.h b/src/processor/stackwalker_x86.h index 0659a13b..1783fda3 100644 --- a/src/processor/stackwalker_x86.h +++ b/src/processor/stackwalker_x86.h @@ -81,14 +81,14 @@ class StackwalkerX86 : public Stackwalker { // to construct the frame that called frames.back(). The caller // takes ownership of the returned frame. Return NULL on failure. StackFrameX86* GetCallerByWindowsFrameInfo( - const vector &frames, + const vector& frames, WindowsFrameInfo* windows_frame_info, bool stack_scan_allowed); // Use cfi_frame_info (derived from STACK CFI records) to construct // the frame that called frames.back(). The caller takes ownership // of the returned frame. Return NULL on failure. - StackFrameX86* GetCallerByCFIFrameInfo(const vector &frames, + StackFrameX86* GetCallerByCFIFrameInfo(const vector& frames, CFIFrameInfo* cfi_frame_info); // Assuming a traditional frame layout --- where the caller's %ebp @@ -96,7 +96,7 @@ class StackwalkerX86 : public Stackwalker { // %ebp points to the saved %ebp --- construct the frame that called // frames.back(). The caller takes ownership of the returned frame. // Return NULL on failure. - StackFrameX86* GetCallerByEBPAtBase(const vector &frames, + StackFrameX86* GetCallerByEBPAtBase(const vector& frames, bool stack_scan_allowed); // Stores the CPU context corresponding to the innermost stack frame to diff --git a/src/processor/stackwalker_x86_unittest.cc b/src/processor/stackwalker_x86_unittest.cc index 359f1c86..b6f14a14 100644 --- a/src/processor/stackwalker_x86_unittest.cc +++ b/src/processor/stackwalker_x86_unittest.cc @@ -113,7 +113,7 @@ class StackwalkerX86Fixture { // Set the Breakpad symbol information that supplier should return for // MODULE to INFO. - void SetModuleSymbols(MockCodeModule *module, const string &info) { + void SetModuleSymbols(MockCodeModule* module, const string& info) { size_t buffer_size; char *buffer = supplier.CopySymbolDataAndOwnTheCopy(info, &buffer_size); EXPECT_CALL(supplier, GetCStringSymbolData(module, &system_info, _, _, _)) @@ -134,7 +134,7 @@ class StackwalkerX86Fixture { void BrandContext(MDRawContextX86 *raw_context) { uint8_t x = 173; for (size_t i = 0; i < sizeof(*raw_context); i++) - reinterpret_cast(raw_context)[i] = (x += 17); + reinterpret_cast(raw_context)[i] = (x += 17); } SystemInfo system_info; @@ -151,7 +151,7 @@ class StackwalkerX86Fixture { MockSymbolSupplier supplier; BasicSourceLineResolver resolver; CallStack call_stack; - const vector *frames; + const vector* frames; }; class SanityCheck: public StackwalkerX86Fixture, public Test { }; @@ -175,7 +175,7 @@ TEST_F(SanityCheck, NoResolver) { ASSERT_EQ("module1", modules_without_symbols[0]->debug_file()); ASSERT_EQ(0U, modules_with_corrupt_symbols.size()); frames = call_stack.frames(); - StackFrameX86 *frame = static_cast(frames->at(0)); + StackFrameX86 *frame = static_cast(frames->at(0)); // Check that the values from the original raw context made it // through to the context in the stack frame. EXPECT_EQ(0, memcmp(&raw_context, &frame->context, sizeof(raw_context))); @@ -201,7 +201,7 @@ TEST_F(GetContextFrame, Simple) { ASSERT_EQ("module1", modules_without_symbols[0]->debug_file()); ASSERT_EQ(0U, modules_with_corrupt_symbols.size()); frames = call_stack.frames(); - StackFrameX86 *frame = static_cast(frames->at(0)); + StackFrameX86 *frame = static_cast(frames->at(0)); // Check that the values from the original raw context made it // through to the context in the stack frame. EXPECT_EQ(0, memcmp(&raw_context, &frame->context, sizeof(raw_context))); @@ -224,7 +224,7 @@ TEST_F(GetContextFrame, NoStackMemory) { ASSERT_EQ("module1", modules_without_symbols[0]->debug_file()); ASSERT_EQ(0U, modules_with_corrupt_symbols.size()); frames = call_stack.frames(); - StackFrameX86 *frame = static_cast(frames->at(0)); + StackFrameX86 *frame = static_cast(frames->at(0)); // Check that the values from the original raw context made it // through to the context in the stack frame. EXPECT_EQ(0, memcmp(&raw_context, &frame->context, sizeof(raw_context))); @@ -269,7 +269,7 @@ TEST_F(GetCallerFrame, Traditional) { ASSERT_EQ(2U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); EXPECT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x4000c7a5U, frame0->instruction); @@ -279,7 +279,7 @@ TEST_F(GetCallerFrame, Traditional) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_FP, frame1->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP @@ -333,7 +333,7 @@ TEST_F(GetCallerFrame, TraditionalScan) { ASSERT_EQ(2U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x4000f49dU, frame0->instruction); @@ -344,7 +344,7 @@ TEST_F(GetCallerFrame, TraditionalScan) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP @@ -399,7 +399,7 @@ TEST_F(GetCallerFrame, TraditionalScanLongWay) { ASSERT_EQ(2U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x4000f49dU, frame0->instruction); @@ -410,7 +410,7 @@ TEST_F(GetCallerFrame, TraditionalScanLongWay) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP @@ -465,7 +465,7 @@ TEST_F(GetCallerFrame, ScanningNotAllowed) { ASSERT_EQ(1U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x4000f49dU, frame0->instruction); @@ -524,7 +524,7 @@ TEST_F(GetCallerFrame, WindowsFrameData) { ASSERT_EQ(2U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x4000aa85U, frame0->instruction); @@ -535,7 +535,7 @@ TEST_F(GetCallerFrame, WindowsFrameData) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame1->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP @@ -605,7 +605,7 @@ TEST_F(GetCallerFrame, WindowsFrameDataAligned) { ASSERT_EQ(2U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x4000aa85U, frame0->instruction); @@ -616,7 +616,7 @@ TEST_F(GetCallerFrame, WindowsFrameDataAligned) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame1->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP @@ -693,7 +693,7 @@ TEST_F(GetCallerFrame, WindowsFrameDataParameterSize) { ASSERT_EQ(3U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x40001004U, frame0->instruction); @@ -714,7 +714,7 @@ TEST_F(GetCallerFrame, WindowsFrameDataParameterSize) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_FP, frame1->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP @@ -737,7 +737,7 @@ TEST_F(GetCallerFrame, WindowsFrameDataParameterSize) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame2 = static_cast(frames->at(2)); + StackFrameX86 *frame2 = static_cast(frames->at(2)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame2->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP @@ -793,7 +793,7 @@ TEST_F(GetCallerFrame, WindowsFrameDataScan) { ASSERT_EQ(2U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x40000c9cU, frame0->instruction); @@ -804,7 +804,7 @@ TEST_F(GetCallerFrame, WindowsFrameDataScan) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); // I'd argue that CONTEXT_VALID_EBP shouldn't be here, since the walker // does not actually fetch the EBP after a scan (forcing the next frame @@ -882,7 +882,7 @@ TEST_F(GetCallerFrame, WindowsFrameDataBadEIPScan) { ASSERT_EQ(2U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x40000700U, frame0->instruction); @@ -893,7 +893,7 @@ TEST_F(GetCallerFrame, WindowsFrameDataBadEIPScan) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI_SCAN, frame1->trust); // I'd argue that CONTEXT_VALID_EBP shouldn't be here, since the // walker does not actually fetch the EBP after a scan (forcing the @@ -955,7 +955,7 @@ TEST_F(GetCallerFrame, WindowsFPOUnchangedEBP) { ASSERT_EQ(2U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x4000e8b8U, frame0->instruction); @@ -976,7 +976,7 @@ TEST_F(GetCallerFrame, WindowsFPOUnchangedEBP) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame1->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP @@ -1039,7 +1039,7 @@ TEST_F(GetCallerFrame, WindowsFPOUsedEBP) { ASSERT_EQ(2U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x40009ab8U, frame0->instruction); @@ -1060,7 +1060,7 @@ TEST_F(GetCallerFrame, WindowsFPOUsedEBP) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame1->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP @@ -1170,8 +1170,8 @@ TEST_F(GetCallerFrame, WindowsFPOReferencesEBX) { StackFrameSymbolizer frame_symbolizer(&supplier, &resolver); StackwalkerX86 walker(&system_info, &raw_context, &stack_region, &modules, &frame_symbolizer); - vector modules_without_symbols; - vector modules_with_corrupt_symbols; + vector modules_without_symbols; + vector modules_with_corrupt_symbols; ASSERT_TRUE(walker.Walk(&call_stack, &modules_without_symbols, &modules_with_corrupt_symbols)); ASSERT_EQ(0U, modules_without_symbols.size()); @@ -1180,31 +1180,31 @@ TEST_F(GetCallerFrame, WindowsFPOReferencesEBX) { ASSERT_EQ(5U, frames->size()); { - const StackFrameX86 &frame = *static_cast(frames->at(0)); + const StackFrameX86& frame = *static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame.trust); EXPECT_EQ(0x77726bf4U, frame.context.eip); EXPECT_EQ("KiFastSystemCallRet", frame.function_name); } { - const StackFrameX86 &frame = *static_cast(frames->at(1)); + const StackFrameX86& frame = *static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame.trust); EXPECT_EQ(0x7772655cU, frame.context.eip); EXPECT_EQ("NtWaitForKeyedEvent", frame.function_name); } { - const StackFrameX86 &frame = *static_cast(frames->at(2)); + const StackFrameX86& frame = *static_cast(frames->at(2)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame.trust); EXPECT_EQ(0x776e4a3fU, frame.context.eip); EXPECT_EQ("RtlSleepConditionVariableSRW", frame.function_name); } { - const StackFrameX86 &frame = *static_cast(frames->at(3)); + const StackFrameX86& frame = *static_cast(frames->at(3)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame.trust); EXPECT_EQ(0x7728219eU, frame.context.eip); EXPECT_EQ("SleepConditionVariableSRW", frame.function_name); } { - const StackFrameX86 &frame = *static_cast(frames->at(4)); + const StackFrameX86& frame = *static_cast(frames->at(4)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame.trust); EXPECT_EQ(0x5ac0486cU, frame.context.eip); EXPECT_EQ("base::ConditionVariable::TimedWait", frame.function_name); @@ -1318,7 +1318,7 @@ TEST_F(GetCallerFrame, WindowsFPOSystemCall) { ASSERT_EQ(4U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x771ef8c1U, frame0->instruction); @@ -1338,7 +1338,7 @@ TEST_F(GetCallerFrame, WindowsFPOSystemCall) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame1->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP @@ -1532,7 +1532,7 @@ TEST_F(GetCallerFrame, ReturnAddressIsNotInKnownModule) { ASSERT_EQ(3U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(0x77c181cdU, frame0->instruction); @@ -1554,7 +1554,7 @@ TEST_F(GetCallerFrame, ReturnAddressIsNotInKnownModule) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI_SCAN, frame1->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP | @@ -1578,7 +1578,7 @@ TEST_F(GetCallerFrame, ReturnAddressIsNotInKnownModule) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame2 = static_cast(frames->at(2)); + StackFrameX86 *frame2 = static_cast(frames->at(2)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame2->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP | @@ -1610,7 +1610,7 @@ TEST_F(GetCallerFrame, HandleAlignmentInProgramString) { MockCodeModule chrome_dll(0x59630000, 0x19e3000, "chrome.dll", "version1"); SetModuleSymbols(&chrome_dll, // chrome.dll "FUNC 56422 50c 8 base::MessageLoop::RunTask" - "(base::PendingTask const &)\n" + "(base::PendingTask const&)\n" "56422 e 458 4589\n" "STACK WIN 4 56422 50c 11 0 8 c ac 0 1 $T1 .raSearch = $T0 " "$T1 4 - 8 @ = $ebp $T1 4 - ^ = $eip $T1 ^ = $esp $T1 4 + = " @@ -1627,7 +1627,7 @@ TEST_F(GetCallerFrame, HandleAlignmentInProgramString) { "$T1 4 - 64 @ = $ebp $T1 4 - ^ = $eip $T1 ^ = $esp $T1 4 + " "= $20 $T0 56 - ^ = $23 $T0 60 - ^ = $24 $T0 64 - ^ =\n" "FUNC 55bf0 49 4 base::MessagePumpWin::Run(base::" - "MessagePump::Delegate *)\n" + "MessagePump::Delegate*)\n" "55bf0 49 48 4724\n" "STACK WIN 4 55bf0 49 c 0 4 0 10 0 1 $T0 $ebp = $eip $T0 4 " "+ ^ = $ebp $T0 ^ = $esp $T0 8 + =\n" @@ -1735,7 +1735,7 @@ TEST_F(GetCallerFrame, HandleAlignmentInProgramString) { ASSERT_EQ(3U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame = static_cast(frames->at(0)); + StackFrameX86 *frame = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame->context_validity); EXPECT_EQ("base::MessagePumpForIO::DoRunLoop()", frame->function_name); @@ -1756,13 +1756,13 @@ TEST_F(GetCallerFrame, HandleAlignmentInProgramString) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame = static_cast(frames->at(1)); + StackFrameX86 *frame = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP | StackFrameX86::CONTEXT_VALID_EBP), frame->context_validity); - EXPECT_EQ("base::MessagePumpWin::Run(base::MessagePump::Delegate *)", + EXPECT_EQ("base::MessagePumpWin::Run(base::MessagePump::Delegate*)", frame->function_name); EXPECT_EQ(1500011566U, frame->instruction + 1); EXPECT_EQ(1500011566U, frame->context.eip); @@ -1779,7 +1779,7 @@ TEST_F(GetCallerFrame, HandleAlignmentInProgramString) { } { // To avoid reusing locals by mistake - StackFrameX86 *frame = static_cast(frames->at(2)); + StackFrameX86 *frame = static_cast(frames->at(2)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP | @@ -1984,7 +1984,7 @@ void GetCallerFrame::IPAddressIsNotInKnownModuleTestImpl( ASSERT_EQ(4U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ(raw_context.eip, frame0->context.eip); @@ -1996,7 +1996,7 @@ void GetCallerFrame::IPAddressIsNotInKnownModuleTestImpl( } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_SCAN, frame1->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP | @@ -2016,7 +2016,7 @@ void GetCallerFrame::IPAddressIsNotInKnownModuleTestImpl( } { // To avoid reusing locals by mistake - StackFrameX86 *frame2 = static_cast(frames->at(2)); + StackFrameX86 *frame2 = static_cast(frames->at(2)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame2->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP | @@ -2036,7 +2036,7 @@ void GetCallerFrame::IPAddressIsNotInKnownModuleTestImpl( } { // To avoid reusing locals by mistake - StackFrameX86 *frame3 = static_cast(frames->at(3)); + StackFrameX86 *frame3 = static_cast(frames->at(3)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame3->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP | @@ -2126,7 +2126,7 @@ struct CFIFixture: public StackwalkerX86Fixture { ASSERT_EQ(2U, frames->size()); { // To avoid reusing locals by mistake - StackFrameX86 *frame0 = static_cast(frames->at(0)); + StackFrameX86 *frame0 = static_cast(frames->at(0)); EXPECT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frame0->trust); ASSERT_EQ(StackFrameX86::CONTEXT_VALID_ALL, frame0->context_validity); EXPECT_EQ("enchiridion", frame0->function_name); @@ -2138,7 +2138,7 @@ struct CFIFixture: public StackwalkerX86Fixture { } { // To avoid reusing locals by mistake - StackFrameX86 *frame1 = static_cast(frames->at(1)); + StackFrameX86 *frame1 = static_cast(frames->at(1)); EXPECT_EQ(StackFrame::FRAME_TRUST_CFI, frame1->trust); ASSERT_EQ((StackFrameX86::CONTEXT_VALID_EIP | StackFrameX86::CONTEXT_VALID_ESP | diff --git a/src/processor/static_address_map-inl.h b/src/processor/static_address_map-inl.h index 67e07976..9d2c1def 100644 --- a/src/processor/static_address_map-inl.h +++ b/src/processor/static_address_map-inl.h @@ -44,8 +44,8 @@ namespace google_breakpad { template bool StaticAddressMap::Retrieve( - const AddressType &address, - const EntryType *&entry, AddressType *entry_address) const { + const AddressType& address, + const EntryType*& entry, AddressType* entry_address) const { // upper_bound gives the first element whose key is greater than address, // but we want the first element whose key is less than or equal to address. diff --git a/src/processor/static_address_map.h b/src/processor/static_address_map.h index 6bafc667..9d1a467b 100644 --- a/src/processor/static_address_map.h +++ b/src/processor/static_address_map.h @@ -52,15 +52,15 @@ template class StaticAddressMap { public: StaticAddressMap(): map_() { } - explicit StaticAddressMap(const char *map_data): map_(map_data) { } + explicit StaticAddressMap(const char* map_data): map_(map_data) { } // Locates the entry stored at the highest address less than or equal to // the address argument. If there is no such range, returns false. The // entry is returned in entry, which is a required argument. If // entry_address is not NULL, it will be set to the address that the entry // was stored at. - bool Retrieve(const AddressType &address, - const EntryType *&entry, AddressType *entry_address) const; + bool Retrieve(const AddressType& address, + const EntryType*& entry, AddressType* entry_address) const; private: friend class ModuleComparer; diff --git a/src/processor/static_address_map_unittest.cc b/src/processor/static_address_map_unittest.cc index 12c735cf..9f1215d6 100644 --- a/src/processor/static_address_map_unittest.cc +++ b/src/processor/static_address_map_unittest.cc @@ -95,7 +95,7 @@ class TestStaticAddressMap : public ::testing::Test { int address_test; string entry; string entry_test; - const char *entry_cstring = NULL; + const char* entry_cstring = NULL; bool found; bool found_test; @@ -143,11 +143,11 @@ class TestStaticAddressMap : public ::testing::Test { // Test data sets: static const int kNumberTestCases = 4; static const int testsize[]; - int *testdata[kNumberTestCases]; + int* testdata[kNumberTestCases]; AddrMap addr_map[kNumberTestCases]; TestMap test_map[kNumberTestCases]; - char *map_data[kNumberTestCases]; + char* map_data[kNumberTestCases]; google_breakpad::AddressMapSerializer serializer; }; @@ -229,7 +229,7 @@ TEST_F(TestStaticAddressMap, Test1000RandomElementsMap) { } } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/src/processor/static_contained_range_map-inl.h b/src/processor/static_contained_range_map-inl.h index 777c7621..87ea6c7f 100644 --- a/src/processor/static_contained_range_map-inl.h +++ b/src/processor/static_contained_range_map-inl.h @@ -47,7 +47,7 @@ StaticContainedRangeMap::StaticContainedRangeMap( const char *base) : base_(*(reinterpret_cast(base))), entry_size_(*(reinterpret_cast(base + sizeof(base_)))), - entry_ptr_(reinterpret_cast( + entry_ptr_(reinterpret_cast( base + sizeof(base_) + sizeof(entry_size_))), map_(base + sizeof(base_) + sizeof(entry_size_) + entry_size_) { if (entry_size_ == 0) @@ -57,7 +57,7 @@ StaticContainedRangeMap::StaticContainedRangeMap( template bool StaticContainedRangeMap::RetrieveRange( - const AddressType &address, const EntryType *&entry) const { + const AddressType& address, const EntryType*& entry) const { // Get an iterator to the child range whose high address is equal to or // greater than the supplied address. If the supplied address is higher diff --git a/src/processor/static_contained_range_map.h b/src/processor/static_contained_range_map.h index 6a9b8b7b..14fa5e95 100644 --- a/src/processor/static_contained_range_map.h +++ b/src/processor/static_contained_range_map.h @@ -57,7 +57,7 @@ class StaticContainedRangeMap { // child ranges, and not the entry contained by |this|. This is necessary // to support a sparsely-populated root range. If no descendant range // encompasses the address, returns false. - bool RetrieveRange(const AddressType &address, const EntryType *&entry) const; + bool RetrieveRange(const AddressType& address, const EntryType*& entry) const; private: friend class ModuleComparer; diff --git a/src/processor/static_map-inl.h b/src/processor/static_map-inl.h index e6aac6ab..75a8a335 100644 --- a/src/processor/static_map-inl.h +++ b/src/processor/static_map-inl.h @@ -59,7 +59,7 @@ StaticMap::StaticMap(const char* raw_data) // find(), lower_bound() and upper_bound() implement binary search algorithm. template StaticMapIterator -StaticMap::find(const Key &key) const { +StaticMap::find(const Key& key) const { int begin = 0; int end = num_nodes_; int middle; @@ -80,7 +80,7 @@ StaticMap::find(const Key &key) const { template StaticMapIterator -StaticMap::lower_bound(const Key &key) const { +StaticMap::lower_bound(const Key& key) const { int begin = 0; int end = num_nodes_; int middle; @@ -101,7 +101,7 @@ StaticMap::lower_bound(const Key &key) const { template StaticMapIterator -StaticMap::upper_bound(const Key &key) const { +StaticMap::upper_bound(const Key& key) const { int begin = 0; int end = num_nodes_; int middle; diff --git a/src/processor/static_map.h b/src/processor/static_map.h index 9723ab2a..e7d8c960 100644 --- a/src/processor/static_map.h +++ b/src/processor/static_map.h @@ -72,7 +72,7 @@ namespace google_breakpad { template class DefaultCompare { public: - int operator()(const Key &k1, const Key &k2) const { + int operator()(const Key& k1, const Key& k2) const { if (k1 < k2) return -1; if (k1 == k2) return 0; return 1; @@ -104,15 +104,15 @@ class StaticMap { } // Lookup operations. - iterator find(const Key &k) const; + iterator find(const Key& k) const; // lower_bound(k) searches in a sorted range for the first element that has a // key not less than the argument k. - iterator lower_bound(const Key &k) const; + iterator lower_bound(const Key& k) const; // upper_bound(k) searches in a sorted range for the first element that has a // key greater than the argument k. - iterator upper_bound(const Key &k) const; + iterator upper_bound(const Key& k) const; // Checks if the underlying memory data conforms to the predefined pattern: // first check the number of nodes is non-negative, diff --git a/src/processor/static_map_iterator-inl.h b/src/processor/static_map_iterator-inl.h index 7a7db5ad..84745842 100644 --- a/src/processor/static_map_iterator-inl.h +++ b/src/processor/static_map_iterator-inl.h @@ -43,7 +43,7 @@ namespace google_breakpad { template StaticMapIterator::StaticMapIterator(const char* base, - const int &index): + const int& index): index_(index), base_(base) { // See static_map.h for documentation on // bytes format of serialized StaticMap data. diff --git a/src/processor/static_map_iterator.h b/src/processor/static_map_iterator.h index 1af8fff4..c49a8b71 100644 --- a/src/processor/static_map_iterator.h +++ b/src/processor/static_map_iterator.h @@ -87,7 +87,7 @@ class StaticMapIterator { friend class StaticMap; // Only StaticMap can call this constructor. - explicit StaticMapIterator(const char* base, const int32_t &index); + explicit StaticMapIterator(const char* base, const int32_t& index); // Index of node that the iterator is pointing to. int32_t index_; diff --git a/src/processor/static_map_unittest.cc b/src/processor/static_map_unittest.cc index 393d43d5..d17153d9 100644 --- a/src/processor/static_map_unittest.cc +++ b/src/processor/static_map_unittest.cc @@ -46,7 +46,7 @@ typedef std::map< KeyType, ValueType > StdMap; template class SimpleMapSerializer { public: - static char* Serialize(const std::map &stdmap, + static char* Serialize(const std::map& stdmap, unsigned int* size = NULL) { unsigned int size_per_node = sizeof(uint32_t) + sizeof(Key) + sizeof(Value); @@ -237,19 +237,19 @@ class TestValidMap : public ::testing::Test { } } - void FindTester(int test_case, const KeyType &key) { + void FindTester(int test_case, const KeyType& key) { iter_test = test_map[test_case].find(key); iter_std = std_map[test_case].find(key); CompareLookupResult(test_case); } - void LowerBoundTester(int test_case, const KeyType &key) { + void LowerBoundTester(int test_case, const KeyType& key) { iter_test = test_map[test_case].lower_bound(key); iter_std = std_map[test_case].lower_bound(key); CompareLookupResult(test_case); } - void UpperBoundTester(int test_case, const KeyType &key) { + void UpperBoundTester(int test_case, const KeyType& key) { iter_test = test_map[test_case].upper_bound(key); iter_std = std_map[test_case].upper_bound(key); CompareLookupResult(test_case); diff --git a/src/processor/static_range_map-inl.h b/src/processor/static_range_map-inl.h index f6cef1a9..37fb6fae 100644 --- a/src/processor/static_range_map-inl.h +++ b/src/processor/static_range_map-inl.h @@ -43,8 +43,8 @@ namespace google_breakpad { template bool StaticRangeMap::RetrieveRange( - const AddressType &address, const EntryType *&entry, - AddressType *entry_base, AddressType *entry_size) const { + const AddressType& address, const EntryType*& entry, + AddressType* entry_base, AddressType* entry_size) const { MapConstIterator iterator = map_.lower_bound(address); if (iterator == map_.end()) return false; @@ -55,7 +55,7 @@ bool StaticRangeMap::RetrieveRange( // be below the range's low address, though. When that happens, address // references something not within any range, so return false. - const Range *range = iterator.GetValuePtr(); + const Range* range = iterator.GetValuePtr(); // Make sure AddressType and EntryType are copyable basic types // e.g.: integer types, pointers etc @@ -74,8 +74,8 @@ bool StaticRangeMap::RetrieveRange( template bool StaticRangeMap::RetrieveNearestRange( - const AddressType &address, const EntryType *&entry, - AddressType *entry_base, AddressType *entry_size) const { + const AddressType& address, const EntryType*& entry, + AddressType* entry_base, AddressType* entry_size) const { // If address is within a range, RetrieveRange can handle it. if (RetrieveRange(address, entry, entry_base, entry_size)) return true; @@ -91,7 +91,7 @@ bool StaticRangeMap::RetrieveNearestRange( return false; --iterator; - const Range *range = iterator.GetValuePtr(); + const Range* range = iterator.GetValuePtr(); entry = range->entryptr(); if (entry_base) *entry_base = range->base(); @@ -103,8 +103,8 @@ bool StaticRangeMap::RetrieveNearestRange( template bool StaticRangeMap::RetrieveRangeAtIndex( - int index, const EntryType *&entry, - AddressType *entry_base, AddressType *entry_size) const { + int index, const EntryType*& entry, + AddressType* entry_base, AddressType* entry_size) const { if (index >= GetCount()) { BPLOG(ERROR) << "Index out of range: " << index << "/" << GetCount(); @@ -113,7 +113,7 @@ bool StaticRangeMap::RetrieveRangeAtIndex( MapConstIterator iterator = map_.IteratorAtIndex(index); - const Range *range = iterator.GetValuePtr(); + const Range* range = iterator.GetValuePtr(); entry = range->entryptr(); if (entry_base) diff --git a/src/processor/static_range_map.h b/src/processor/static_range_map.h index 91aabb03..ea89fae4 100644 --- a/src/processor/static_range_map.h +++ b/src/processor/static_range_map.h @@ -50,21 +50,21 @@ template class StaticRangeMap { public: StaticRangeMap(): map_() { } - explicit StaticRangeMap(const char *memory): map_(memory) { } + explicit StaticRangeMap(const char* memory): map_(memory) { } // Locates the range encompassing the supplied address. If there is // no such range, returns false. entry_base and entry_size, if non-NULL, // are set to the base and size of the entry's range. - bool RetrieveRange(const AddressType &address, const EntryType *&entry, - AddressType *entry_base, AddressType *entry_size) const; + bool RetrieveRange(const AddressType& address, const EntryType*& entry, + AddressType* entry_base, AddressType* entry_size) const; // Locates the range encompassing the supplied address, if one exists. // If no range encompasses the supplied address, locates the nearest range // to the supplied address that is lower than the address. Returns false // if no range meets these criteria. entry_base and entry_size, if // non-NULL, are set to the base and size of the entry's range. - bool RetrieveNearestRange(const AddressType &address, const EntryType *&entry, - AddressType *entry_base, AddressType *entry_size) + bool RetrieveNearestRange(const AddressType& address, const EntryType*& entry, + AddressType* entry_base, AddressType* entry_size) const; // Treating all ranges as a list ordered by the address spaces that they @@ -74,8 +74,8 @@ class StaticRangeMap { // range. // // RetrieveRangeAtIndex is not optimized for speedy operation. - bool RetrieveRangeAtIndex(int index, const EntryType *&entry, - AddressType *entry_base, AddressType *entry_size) + bool RetrieveRangeAtIndex(int index, const EntryType*& entry, + AddressType* entry_base, AddressType* entry_size) const; // Returns the number of ranges stored in the RangeMap. diff --git a/src/processor/static_range_map_unittest.cc b/src/processor/static_range_map_unittest.cc index 28217362..1593ed00 100644 --- a/src/processor/static_range_map_unittest.cc +++ b/src/processor/static_range_map_unittest.cc @@ -414,7 +414,7 @@ TEST_F(TestStaticRangeMap, RunTestCase0Again) { } // namespace google_breakpad -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/src/processor/synth_minidump.cc b/src/processor/synth_minidump.cc index 5e72c161..da61afc4 100644 --- a/src/processor/synth_minidump.cc +++ b/src/processor/synth_minidump.cc @@ -37,7 +37,7 @@ namespace google_breakpad { namespace SynthMinidump { -Section::Section(const Dump &dump) +Section::Section(const Dump& dump) : test_assembler::Section(dump.endianness()) { } void Section::CiteLocationIn(test_assembler::Section *section) const { @@ -49,9 +49,9 @@ void Stream::CiteStreamIn(test_assembler::Section *section) const { CiteLocationIn(section); } -SystemInfo::SystemInfo(const Dump &dump, - const MDRawSystemInfo &system_info, - const String &csd_version) +SystemInfo::SystemInfo(const Dump& dump, + const MDRawSystemInfo& system_info, + const String& csd_version) : Stream(dump, MD_SYSTEM_INFO_STREAM) { D16(system_info.processor_architecture); D16(system_info.processor_level); @@ -108,7 +108,7 @@ const MDRawSystemInfo SystemInfo::windows_x86 = { const string SystemInfo::windows_x86_csd_version = "Service Pack 2"; -String::String(const Dump &dump, const string &contents) : Section(dump) { +String::String(const Dump& dump, const string& contents) : Section(dump) { D32(contents.size() * 2); for (string::const_iterator i = contents.begin(); i != contents.end(); i++) D16(*i); @@ -123,7 +123,7 @@ void Memory::CiteMemoryIn(test_assembler::Section *section) const { CiteLocationIn(section); } -Context::Context(const Dump &dump, const MDRawContextX86 &context) +Context::Context(const Dump& dump, const MDRawContextX86& context) : Section(dump) { // The caller should have properly set the CPU type flag. // The high 24 bits identify the CPU. Note that context records with no CPU @@ -173,7 +173,7 @@ Context::Context(const Dump &dump, const MDRawContextX86 &context) assert(Size() == sizeof(MDRawContextX86)); } -Context::Context(const Dump &dump, const MDRawContextARM &context) +Context::Context(const Dump& dump, const MDRawContextARM& context) : Section(dump) { // The caller should have properly set the CPU type flag. assert((context.context_flags & MD_CONTEXT_ARM) || @@ -192,7 +192,7 @@ Context::Context(const Dump &dump, const MDRawContextARM &context) assert(Size() == sizeof(MDRawContextARM)); } -Context::Context(const Dump &dump, const MDRawContextMIPS &context) +Context::Context(const Dump& dump, const MDRawContextMIPS& context) : Section(dump) { // The caller should have properly set the CPU type flag. assert(context.context_flags & MD_CONTEXT_MIPS); @@ -228,8 +228,8 @@ Context::Context(const Dump &dump, const MDRawContextMIPS &context) assert(Size() == sizeof(MDRawContextMIPS)); } -Thread::Thread(const Dump &dump, - uint32_t thread_id, const Memory &stack, const Context &context, +Thread::Thread(const Dump& dump, + uint32_t thread_id, const Memory& stack, const Context& context, uint32_t suspend_count, uint32_t priority_class, uint32_t priority, uint64_t teb) : Section(dump) { D32(thread_id); @@ -242,13 +242,13 @@ Thread::Thread(const Dump &dump, assert(Size() == sizeof(MDRawThread)); } -Module::Module(const Dump &dump, +Module::Module(const Dump& dump, uint64_t base_of_image, uint32_t size_of_image, - const String &name, + const String& name, uint32_t time_date_stamp, uint32_t checksum, - const MDVSFixedFileInfo &version_info, + const MDVSFixedFileInfo& version_info, const Section *cv_record, const Section *misc_record) : Section(dump) { D64(base_of_image); @@ -297,10 +297,10 @@ const MDVSFixedFileInfo Module::stock_version_info = { 0 // file_date_lo }; -UnloadedModule::UnloadedModule(const Dump &dump, +UnloadedModule::UnloadedModule(const Dump& dump, uint64_t base_of_image, uint32_t size_of_image, - const String &name, + const String& name, uint32_t checksum, uint32_t time_date_stamp) : Section(dump) { D64(base_of_image); @@ -310,15 +310,15 @@ UnloadedModule::UnloadedModule(const Dump &dump, name.CiteStringIn(this); } -UnloadedModuleList::UnloadedModuleList(const Dump &dump, uint32_t type) +UnloadedModuleList::UnloadedModuleList(const Dump& dump, uint32_t type) : List(dump, type, false) { D32(sizeof(MDRawUnloadedModuleList)); D32(sizeof(MDRawUnloadedModule)); D32(count_label_); } -Exception::Exception(const Dump &dump, - const Context &context, +Exception::Exception(const Dump& dump, + const Context& context, uint32_t thread_id, uint32_t exception_code, uint32_t exception_flags, @@ -361,22 +361,22 @@ Dump::Dump(uint64_t flags, assert(Size() == sizeof(MDRawHeader)); } -Dump &Dump::Add(SynthMinidump::Section *section) { +Dump& Dump::Add(SynthMinidump::Section *section) { section->Finish(file_start_ + Size()); Append(*section); return *this; } -Dump &Dump::Add(Stream *stream) { - Add(static_cast(stream)); +Dump& Dump::Add(Stream *stream) { + Add(static_cast(stream)); stream->CiteStreamIn(&stream_directory_); stream_count_++; return *this; } -Dump &Dump::Add(Memory *memory) { +Dump& Dump::Add(Memory *memory) { // Add the memory contents themselves to the file. - Add(static_cast(memory)); + Add(static_cast(memory)); // The memory list is a list of MDMemoryDescriptors, not of actual // memory elements. Produce a descriptor, and add that to the list. @@ -386,17 +386,17 @@ Dump &Dump::Add(Memory *memory) { return *this; } -Dump &Dump::Add(Thread *thread) { +Dump& Dump::Add(Thread *thread) { thread_list_.Add(thread); return *this; } -Dump &Dump::Add(Module *module) { +Dump& Dump::Add(Module *module) { module_list_.Add(module); return *this; } -Dump &Dump::Add(UnloadedModule *unloaded_module) { +Dump& Dump::Add(UnloadedModule *unloaded_module) { unloaded_module_list_.Add(unloaded_module); return *this; } @@ -413,7 +413,7 @@ void Dump::Finish() { // has the stream count and MDRVA. stream_count_label_ = stream_count_; stream_directory_rva_ = file_start_ + Size(); - Append(static_cast(stream_directory_)); + Append(static_cast(stream_directory_)); } } // namespace SynthMinidump diff --git a/src/processor/synth_minidump.h b/src/processor/synth_minidump.h index 8f49cfff..2da4d5fe 100644 --- a/src/processor/synth_minidump.h +++ b/src/processor/synth_minidump.h @@ -135,7 +135,7 @@ class String; // A test_assembler::Section which will be appended to a minidump. class Section: public test_assembler::Section { public: - explicit Section(const Dump &dump); + explicit Section(const Dump& dump); // Append an MDLocationDescriptor referring to this section to SECTION. // If 'this' is NULL, append a descriptor with a zero length and MDRVA. @@ -145,13 +145,13 @@ class Section: public test_assembler::Section { // bad, if such language exists. Having this function handle NULL // 'this' is convenient, but if it causes trouble, it's not hard to // do differently.) - void CiteLocationIn(test_assembler::Section *section) const; + void CiteLocationIn(test_assembler::Section* section) const; // Note that this section's contents are complete, and that it has // been placed in the minidump file at OFFSET. The 'Add' member // functions call the Finish member function of the object being // added for you; if you are 'Add'ing this section, you needn't Finish it. - virtual void Finish(const Label &offset) { + virtual void Finish(const Label& offset) { file_offset_ = offset; size_ = Size(); } @@ -166,10 +166,10 @@ class Stream: public Section { public: // Create a stream of type TYPE. You can append whatever contents // you like to this stream using the test_assembler::Section methods. - Stream(const Dump &dump, uint32_t type) : Section(dump), type_(type) { } + Stream(const Dump& dump, uint32_t type) : Section(dump), type_(type) { } // Append an MDRawDirectory referring to this stream to SECTION. - void CiteStreamIn(test_assembler::Section *section) const; + void CiteStreamIn(test_assembler::Section* section) const; private: // The type of this stream. @@ -186,9 +186,9 @@ class SystemInfo: public Stream { // // Remember that you are still responsible for 'Add'ing CSD_VERSION // to the dump yourself. - SystemInfo(const Dump &dump, - const MDRawSystemInfo &system_info, - const String &csd_version); + SystemInfo(const Dump& dump, + const MDRawSystemInfo& system_info, + const String& csd_version); // Stock MDRawSystemInfo information and associated strings, for // writing tests. @@ -199,10 +199,10 @@ class SystemInfo: public Stream { // An MDString: a string preceded by a 32-bit length. class String: public Section { public: - String(const Dump &dump, const string &value); + String(const Dump& dump, const string& value); // Append an MDRVA referring to this string to SECTION. - void CiteStringIn(test_assembler::Section *section) const; + void CiteStringIn(test_assembler::Section* section) const; }; // A range of memory contents. 'Add'ing a memory range to a minidump @@ -211,11 +211,11 @@ class String: public Section { // to memory addresses. class Memory: public Section { public: - Memory(const Dump &dump, uint64_t address) + Memory(const Dump& dump, uint64_t address) : Section(dump), address_(address) { start() = address; } // Append an MDMemoryDescriptor referring to this memory range to SECTION. - void CiteMemoryIn(test_assembler::Section *section) const; + void CiteMemoryIn(test_assembler::Section* section) const; private: // The process address from which these memory contents were taken. @@ -226,11 +226,11 @@ class Memory: public Section { class Context: public Section { public: // Create a context belonging to DUMP whose contents are a copy of CONTEXT. - Context(const Dump &dump, const MDRawContextX86 &context); - Context(const Dump &dump, const MDRawContextARM &context); - Context(const Dump &dump, const MDRawContextMIPS &context); + Context(const Dump& dump, const MDRawContextX86& context); + Context(const Dump& dump, const MDRawContextARM& context); + Context(const Dump& dump, const MDRawContextMIPS& context); // Add an empty context to the dump. - Context(const Dump &dump) : Section(dump) {} + Context(const Dump& dump) : Section(dump) {} // Add constructors for other architectures here. Remember to byteswap. }; @@ -238,10 +238,10 @@ class Thread: public Section { public: // Create a thread belonging to DUMP with the given values, citing // STACK and CONTEXT (which you must Add to the dump separately). - Thread(const Dump &dump, + Thread(const Dump& dump, uint32_t thread_id, - const Memory &stack, - const Context &context, + const Memory& stack, + const Context& context, uint32_t suspend_count = 0, uint32_t priority_class = 0, uint32_t priority = 0, @@ -253,15 +253,15 @@ class Module: public Section { // Create a module with the given values. Note that CV_RECORD and // MISC_RECORD can be NULL, in which case the corresponding location // descriptior in the minidump will have a length of zero. - Module(const Dump &dump, + Module(const Dump& dump, uint64_t base_of_image, uint32_t size_of_image, - const String &name, + const String& name, uint32_t time_date_stamp = 1262805309, uint32_t checksum = 0, - const MDVSFixedFileInfo &version_info = Module::stock_version_info, - const Section *cv_record = NULL, - const Section *misc_record = NULL); + const MDVSFixedFileInfo& version_info = Module::stock_version_info, + const Section* cv_record = NULL, + const Section* misc_record = NULL); private: // A standard MDVSFixedFileInfo structure to use as a default for @@ -272,18 +272,18 @@ class Module: public Section { class UnloadedModule: public Section { public: - UnloadedModule(const Dump &dump, + UnloadedModule(const Dump& dump, uint64_t base_of_image, uint32_t size_of_image, - const String &name, + const String& name, uint32_t checksum = 0, uint32_t time_date_stamp = 1262805309); }; class Exception : public Stream { public: - Exception(const Dump &dump, - const Context &context, + Exception(const Dump& dump, + const Context& context, uint32_t thread_id = 0, uint32_t exception_code = 0, uint32_t exception_flags = 0, @@ -295,12 +295,12 @@ public: template class List: public Stream { public: - List(const Dump &dump, uint32_t type) : Stream(dump, type), count_(0) { + List(const Dump& dump, uint32_t type) : Stream(dump, type), count_(0) { D32(count_label_); } // Add ELEMENT to this list. - void Add(Element *element) { + void Add(Element* element) { element->Finish(file_offset_ + Size()); Append(*element); count_++; @@ -311,7 +311,7 @@ class List: public Stream { // Finish up the contents of this section, mark it as having been // placed at OFFSET. - virtual void Finish(const Label &offset) { + virtual void Finish(const Label& offset) { Stream::Finish(offset); count_label_ = count_; } @@ -322,14 +322,14 @@ class List: public Stream { protected: // This constructor allows derived lists to specify their own layout // rather than starting with count as specified in the public constructor. - List(const Dump &dump, uint32_t type, bool) : Stream(dump, type), count_(0) {} + List(const Dump& dump, uint32_t type, bool) : Stream(dump, type), count_(0) {} Label count_label_; }; class UnloadedModuleList : public List { public: - UnloadedModuleList(const Dump &dump, uint32_t type); + UnloadedModuleList(const Dump& dump, uint32_t type); }; class Dump: public test_assembler::Section { @@ -349,12 +349,12 @@ class Dump: public test_assembler::Section { // whatever directory or list is appropriate for its type. The // stream directory, memory list, thread list, and module list are // accumulated this way. - Dump &Add(SynthMinidump::Section *object); // simply append data - Dump &Add(Stream *object); // append, record in stream directory - Dump &Add(Memory *object); // append, record in memory list - Dump &Add(Thread *object); // append, record in thread list - Dump &Add(Module *object); // append, record in module list - Dump &Add(UnloadedModule *object); // append, record in unloaded module list + Dump& Add(SynthMinidump::Section* object); // simply append data + Dump& Add(Stream* object); // append, record in stream directory + Dump& Add(Memory* object); // append, record in memory list + Dump& Add(Thread* object); // append, record in thread list + Dump& Add(Module* object); // append, record in module list + Dump& Add(UnloadedModule* object); // append, record in unloaded module list // Complete the construction of the minidump, given the Add calls // we've seen up to this point. After this call, this Dump's @@ -367,26 +367,26 @@ class Dump: public test_assembler::Section { Label file_start_; // The stream directory. We construct this incrementally from - // Add(Stream *) calls. + // Add(Stream*) calls. SynthMinidump::Section stream_directory_; // The directory's contents. size_t stream_count_; // The number of streams so far. Label stream_count_label_; // Cited in file header. Label stream_directory_rva_; // The directory's file offset. // This minidump's thread list. We construct this incrementally from - // Add(Thread *) calls. + // Add(Thread*) calls. List thread_list_; // This minidump's module list. We construct this incrementally from - // Add(Module *) calls. + // Add(Module*) calls. List module_list_; // This minidump's unloaded module list. We construct this incrementally from - // Add(UnloadedModule *) calls. + // Add(UnloadedModule*) calls. UnloadedModuleList unloaded_module_list_; // This minidump's memory list. We construct this incrementally from - // Add(Memory *) calls. This is actually a list of MDMemoryDescriptors, + // Add(Memory*) calls. This is actually a list of MDMemoryDescriptors, // not memory ranges --- thus the odd type. List memory_list_; }; diff --git a/src/processor/testdata/linux_test_app.cc b/src/processor/testdata/linux_test_app.cc index 18f0f62f..9df6dccc 100644 --- a/src/processor/testdata/linux_test_app.cc +++ b/src/processor/testdata/linux_test_app.cc @@ -51,8 +51,8 @@ namespace { // google_breakpad::MinidumpCallback to invoke after minidump generation. -static bool callback(const char *dump_path, const char *id, - void *context, +static bool callback(const char* dump_path, const char* id, + void* context, bool succeeded) { if (succeeded) { printf("dump guid is %s\n", id); @@ -65,13 +65,13 @@ static bool callback(const char *dump_path, const char *id, } static void CrashFunction() { - int *i = reinterpret_cast(0x45); + int* i = reinterpret_cast(0x45); *i = 5; // crash! } } // namespace -int main(int argc, char **argv) { +int main(int argc, char** argv) { google_breakpad::ExceptionHandler eh(".", NULL, callback, NULL, true); if (!eh.WriteMinidump()) { printf("Failed to generate on-demand minidump\n"); diff --git a/src/processor/testdata/test_app.cc b/src/processor/testdata/test_app.cc index 7882a8bd..c744a37a 100644 --- a/src/processor/testdata/test_app.cc +++ b/src/processor/testdata/test_app.cc @@ -38,9 +38,9 @@ namespace { -static bool callback(const wchar_t *dump_path, const wchar_t *id, - void *context, EXCEPTION_POINTERS *exinfo, - MDRawAssertionInfo *assertion, +static bool callback(const wchar_t* dump_path, const wchar_t* id, + void* context, EXCEPTION_POINTERS* exinfo, + MDRawAssertionInfo* assertion, bool succeeded) { if (succeeded) { printf("dump guid is %ws\n", id); @@ -53,13 +53,13 @@ static bool callback(const wchar_t *dump_path, const wchar_t *id, } static void CrashFunction() { - int *i = reinterpret_cast(0x45); + int* i = reinterpret_cast(0x45); *i = 5; // crash! } } // namespace -int main(int argc, char **argv) { +int main(int argc, char** argv) { google_breakpad::ExceptionHandler eh( L".", NULL, callback, NULL, google_breakpad::ExceptionHandler::HANDLER_ALL); diff --git a/src/processor/tokenize.cc b/src/processor/tokenize.cc index 8fce87a2..29e8125a 100644 --- a/src/processor/tokenize.cc +++ b/src/processor/tokenize.cc @@ -42,10 +42,10 @@ namespace google_breakpad { using std::vector; -bool Tokenize(char *line, - const char *separators, - int max_tokens, - vector *tokens) { +bool Tokenize(char* line, + const char* separators, + int max_tokens, + vector* tokens) { tokens->clear(); tokens->reserve(max_tokens); @@ -53,8 +53,8 @@ bool Tokenize(char *line, // Split tokens on the separator character. // strip them out before exhausting max_tokens. - char *save_ptr; - char *token = strtok_r(line, separators, &save_ptr); + char* save_ptr; + char* token = strtok_r(line, separators, &save_ptr); while (token && --remaining > 0) { tokens->push_back(token); if (remaining > 1) @@ -69,10 +69,9 @@ bool Tokenize(char *line, return tokens->size() == static_cast(max_tokens); } -void StringToVector(const string &str, vector &vec) { +void StringToVector(const string& str, vector& vec) { vec.resize(str.length() + 1); - std::copy(str.begin(), str.end(), - vec.begin()); + std::copy(str.begin(), str.end(), vec.begin()); vec[str.length()] = '\0'; } diff --git a/src/processor/tokenize.h b/src/processor/tokenize.h index 9ff571d5..c4480aa8 100644 --- a/src/processor/tokenize.h +++ b/src/processor/tokenize.h @@ -50,13 +50,13 @@ namespace google_breakpad { // Tokenize, but may be treated as a failure if the caller expects an // exact, as opposed to maximum, number of tokens. -bool Tokenize(char *line, - const char *separators, +bool Tokenize(char* line, + const char* separators, int max_tokens, - std::vector *tokens); + std::vector* tokens); // For convenience, since you need a char* to pass to Tokenize. // You can call StringToVector on a string, and use &vec[0]. -void StringToVector(const string &str, std::vector &vec); +void StringToVector(const string& str, std::vector& vec); } // namespace google_breakpad diff --git a/src/processor/windows_frame_info.h b/src/processor/windows_frame_info.h index f96e0a43..993832ad 100644 --- a/src/processor/windows_frame_info.h +++ b/src/processor/windows_frame_info.h @@ -113,9 +113,9 @@ struct WindowsFrameInfo { // otherwise. type, rva and code_size are present in the STACK line, // but not the StackFrameInfo structure, so return them as outparams. static WindowsFrameInfo *ParseFromString(const string string, - int &type, - uint64_t &rva, - uint64_t &code_size) { + int& type, + uint64_t& rva, + uint64_t& code_size) { // The format of a STACK WIN record is documented at: // // https://chromium.googlesource.com/breakpad/breakpad/+/master/docs/symbol_files.md @@ -160,7 +160,7 @@ struct WindowsFrameInfo { } // CopyFrom makes "this" WindowsFrameInfo object identical to "that". - void CopyFrom(const WindowsFrameInfo &that) { + void CopyFrom(const WindowsFrameInfo& that) { type_ = that.type_; valid = that.valid; prolog_size = that.prolog_size; diff --git a/src/tools/linux/dump_syms/dump_syms.cc b/src/tools/linux/dump_syms/dump_syms.cc index ebdf2314..42e582c6 100644 --- a/src/tools/linux/dump_syms/dump_syms.cc +++ b/src/tools/linux/dump_syms/dump_syms.cc @@ -56,7 +56,7 @@ int usage(const char* self) { return 1; } -int main(int argc, char **argv) { +int main(int argc, char** argv) { if (argc < 2) return usage(argv[0]); bool header_only = false; diff --git a/src/tools/linux/md2core/minidump-2-core.cc b/src/tools/linux/md2core/minidump-2-core.cc index a60be323..aade82c9 100644 --- a/src/tools/linux/md2core/minidump-2-core.cc +++ b/src/tools/linux/md2core/minidump-2-core.cc @@ -149,7 +149,7 @@ SetupOptions(int argc, const char* argv[], Options* options) { options->use_filename = false; options->inc_guid = false; - while ((ch = getopt(argc, (char * const *)argv, "fhio:S:v")) != -1) { + while ((ch = getopt(argc, (char * const*)argv, "fhio:S:v")) != -1) { switch (ch) { case 'h': Usage(argc, argv); @@ -224,7 +224,7 @@ writea(int fd, const void* idata, size_t length) { */ static inline int sex() { int probe = 1; - return !*(char *)&probe; + return !*(char*)&probe; } typedef struct elf_timeval { /* Time value with microsecond resolution */ @@ -660,10 +660,10 @@ ParseSystemInfo(const Options& options, CrashedProcess* crashinfo, sysinfo->processor_architecture == MD_CPU_ARCHITECTURE_AMD64) { fputs("Vendor id: ", stderr); const char *nul = - (const char *)memchr(sysinfo->cpu.x86_cpu_info.vendor_id, 0, + (const char*)memchr(sysinfo->cpu.x86_cpu_info.vendor_id, 0, sizeof(sysinfo->cpu.x86_cpu_info.vendor_id)); fwrite(sysinfo->cpu.x86_cpu_info.vendor_id, - nul ? nul - (const char *)&sysinfo->cpu.x86_cpu_info.vendor_id[0] + nul ? nul - (const char*)&sysinfo->cpu.x86_cpu_info.vendor_id[0] : sizeof(sysinfo->cpu.x86_cpu_info.vendor_id), 1, stderr); fputs("\n", stderr); } @@ -759,7 +759,7 @@ ParseEnvironment(const Options& options, CrashedProcess* crashinfo, memcpy(env, range.data(), range.length()); int nul_count = 0; for (char *ptr = env;;) { - ptr = (char *)memchr(ptr, '\000', range.length() - (ptr - env)); + ptr = (char*)memchr(ptr, '\000', range.length() - (ptr - env)); if (!ptr) { break; } @@ -1076,7 +1076,7 @@ AugmentMappings(const Options& options, CrashedProcess* crashinfo, for (unsigned i = 0; i < crashinfo->threads.size(); ++i) { const CrashedProcess::Thread& thread = crashinfo->threads[i]; AddDataToMapping(crashinfo, - string((char *)thread.stack, thread.stack_length), + string((char*)thread.stack, thread.stack_length), thread.stack_addr); } diff --git a/src/tools/linux/symupload/minidump_upload.cc b/src/tools/linux/symupload/minidump_upload.cc index 19f17450..f24e9716 100644 --- a/src/tools/linux/symupload/minidump_upload.cc +++ b/src/tools/linux/symupload/minidump_upload.cc @@ -111,7 +111,7 @@ SetupOptions(int argc, const char *argv[], Options *options) { extern int optind; int ch; - while ((ch = getopt(argc, (char * const *)argv, "p:u:v:x:h?")) != -1) { + while ((ch = getopt(argc, (char * const*)argv, "p:u:v:x:h?")) != -1) { switch (ch) { case 'p': options->product = optarg; diff --git a/src/tools/linux/symupload/sym_upload.cc b/src/tools/linux/symupload/sym_upload.cc index 256f73c5..57df81cf 100644 --- a/src/tools/linux/symupload/sym_upload.cc +++ b/src/tools/linux/symupload/sym_upload.cc @@ -115,7 +115,7 @@ SetupOptions(int argc, const char *argv[], Options *options) { int ch; constexpr char flag_pattern[] = "u:v:x:p:k:t:c:i:hf?"; - while ((ch = getopt(argc, (char * const *)argv, flag_pattern)) != -1) { + while ((ch = getopt(argc, (char * const*)argv, flag_pattern)) != -1) { switch (ch) { case 'h': case '?': diff --git a/src/tools/mac/crash_report/on_demand_symbol_supplier.h b/src/tools/mac/crash_report/on_demand_symbol_supplier.h index 3fbe108e..69b41405 100644 --- a/src/tools/mac/crash_report/on_demand_symbol_supplier.h +++ b/src/tools/mac/crash_report/on_demand_symbol_supplier.h @@ -47,30 +47,30 @@ class OnDemandSymbolSupplier : public SymbolSupplier { public: // |search_dir| is the directory to search for alternative symbols with // the same name as the module in the minidump - OnDemandSymbolSupplier(const string &search_dir, - const string &symbol_search_dir); + OnDemandSymbolSupplier(const string& search_dir, + const string& symbol_search_dir); virtual ~OnDemandSymbolSupplier() {} // Returns the path to the symbol file for the given module. - virtual SymbolResult GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file); + virtual SymbolResult GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file); // Returns the path to the symbol file for the given module. - virtual SymbolResult GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - string *symbol_data); + virtual SymbolResult GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + string* symbol_data); // Allocates data buffer on heap, and takes the ownership of // the data buffer. - virtual SymbolResult GetCStringSymbolData(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - char **symbol_data, - size_t *symbol_data_size); + virtual SymbolResult GetCStringSymbolData(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + char** symbol_data, + size_t* symbol_data_size); // Delete the data buffer allocated for module in GetCStringSymbolData(). - virtual void FreeSymbolData(const CodeModule *module); + virtual void FreeSymbolData(const CodeModule* module); protected: // Search directory @@ -82,28 +82,28 @@ class OnDemandSymbolSupplier : public SymbolSupplier { map module_file_map_; // Map of allocated data buffers, keyed by module->code_file(). - map memory_buffers_; + map memory_buffers_; // Return the name for |module| This will be the value used as the key // to the |module_file_map_|. - string GetNameForModule(const CodeModule *module); + string GetNameForModule(const CodeModule* module); // Find the module on local system. If the module resides in a different // location than the full path in the minidump, this will be the location // used. - string GetLocalModulePath(const CodeModule *module); + string GetLocalModulePath(const CodeModule* module); // Return the full path for |module|. - string GetModulePath(const CodeModule *module); + string GetModulePath(const CodeModule* module); // Return the path to the symbol file for |module|. If an empty string is // returned, then |module| doesn't have a symbol file. - string GetModuleSymbolFile(const CodeModule *module); + string GetModuleSymbolFile(const CodeModule* module); // Generate the breakpad symbol file for |module|. Return true if successful. // File is generated in /tmp. - bool GenerateSymbolFile(const CodeModule *module, - const SystemInfo *system_info); + bool GenerateSymbolFile(const CodeModule* module, + const SystemInfo* system_info); }; } // namespace google_breakpad diff --git a/src/tools/mac/crash_report/on_demand_symbol_supplier.mm b/src/tools/mac/crash_report/on_demand_symbol_supplier.mm index 1955d266..cfcecee8 100644 --- a/src/tools/mac/crash_report/on_demand_symbol_supplier.mm +++ b/src/tools/mac/crash_report/on_demand_symbol_supplier.mm @@ -51,10 +51,10 @@ using google_breakpad::PathnameStripper; using google_breakpad::SymbolSupplier; using google_breakpad::SystemInfo; -OnDemandSymbolSupplier::OnDemandSymbolSupplier(const string &search_dir, - const string &symbol_search_dir) +OnDemandSymbolSupplier::OnDemandSymbolSupplier(const string& search_dir, + const string& symbol_search_dir) : search_dir_(search_dir) { - NSFileManager *mgr = [NSFileManager defaultManager]; + NSFileManager* mgr = [NSFileManager defaultManager]; size_t length = symbol_search_dir.length(); if (length) { // Load all sym files in symbol_search_dir into our module_file_map @@ -62,51 +62,51 @@ OnDemandSymbolSupplier::OnDemandSymbolSupplier(const string &search_dir, // MODULE mac x86 BBF0A8F9BEADDD2048E6464001CA193F0 GoogleDesktopDaemon // or // MODULE mac ppc BBF0A8F9BEADDD2048E6464001CA193F0 GoogleDesktopDaemon - const char *symbolSearchStr = symbol_search_dir.c_str(); - NSString *symbolSearchPath = + const char* symbolSearchStr = symbol_search_dir.c_str(); + NSString* symbolSearchPath = [mgr stringWithFileSystemRepresentation:symbolSearchStr length:strlen(symbolSearchStr)]; - NSDirectoryEnumerator *dirEnum = [mgr enumeratorAtPath:symbolSearchPath]; - NSString *fileName; - NSCharacterSet *hexSet = + NSDirectoryEnumerator* dirEnum = [mgr enumeratorAtPath:symbolSearchPath]; + NSString* fileName; + NSCharacterSet* hexSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789ABCDEF"]; - NSCharacterSet *newlineSet = + NSCharacterSet* newlineSet = [NSCharacterSet characterSetWithCharactersInString:@"\r\n"]; while ((fileName = [dirEnum nextObject])) { // Check to see what type of file we have - NSDictionary *attrib = [dirEnum fileAttributes]; - NSString *fileType = [attrib objectForKey:NSFileType]; + NSDictionary* attrib = [dirEnum fileAttributes]; + NSString* fileType = [attrib objectForKey:NSFileType]; if ([fileType isEqualToString:NSFileTypeDirectory]) { // Skip subdirectories [dirEnum skipDescendents]; } else { - NSString *filePath = [symbolSearchPath stringByAppendingPathComponent:fileName]; - NSString *dataStr = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL]; + NSString* filePath = [symbolSearchPath stringByAppendingPathComponent:fileName]; + NSString* dataStr = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL]; if (dataStr) { // Check file to see if it is of appropriate type, and grab module // name. - NSScanner *scanner = [NSScanner scannerWithString:dataStr]; + NSScanner* scanner = [NSScanner scannerWithString:dataStr]; BOOL goodScan = [scanner scanString:@"MODULE mac " intoString:nil]; if (goodScan) { goodScan = ([scanner scanString:@"x86 " intoString:nil] || [scanner scanString:@"x86_64 " intoString:nil] || [scanner scanString:@"ppc " intoString:nil]); if (goodScan) { - NSString *moduleID; + NSString* moduleID; goodScan = [scanner scanCharactersFromSet:hexSet intoString:&moduleID]; if (goodScan) { // Module IDs are always 33 chars long goodScan = [moduleID length] == 33; if (goodScan) { - NSString *moduleName; + NSString* moduleName; goodScan = [scanner scanUpToCharactersFromSet:newlineSet intoString:&moduleName]; if (goodScan) { goodScan = [moduleName length] > 0; if (goodScan) { - const char *moduleNameStr = [moduleName UTF8String]; - const char *filePathStr = [filePath fileSystemRepresentation]; + const char* moduleNameStr = [moduleName UTF8String]; + const char* filePathStr = [filePath fileSystemRepresentation]; // Map our file module_file_map_[moduleNameStr] = filePathStr; } @@ -122,9 +122,9 @@ OnDemandSymbolSupplier::OnDemandSymbolSupplier(const string &search_dir, } SymbolSupplier::SymbolResult -OnDemandSymbolSupplier::GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file) { +OnDemandSymbolSupplier::GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file) { string path(GetModuleSymbolFile(module)); if (path.empty()) { @@ -142,10 +142,10 @@ OnDemandSymbolSupplier::GetSymbolFile(const CodeModule *module, } SymbolSupplier::SymbolResult -OnDemandSymbolSupplier::GetSymbolFile(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - string *symbol_data) { +OnDemandSymbolSupplier::GetSymbolFile(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + string* symbol_data) { SymbolSupplier::SymbolResult s = GetSymbolFile(module, system_info, symbol_file); @@ -162,11 +162,11 @@ OnDemandSymbolSupplier::GetSymbolFile(const CodeModule *module, } SymbolSupplier::SymbolResult -OnDemandSymbolSupplier::GetCStringSymbolData(const CodeModule *module, - const SystemInfo *system_info, - string *symbol_file, - char **symbol_data, - size_t *symbol_data_size) { +OnDemandSymbolSupplier::GetCStringSymbolData(const CodeModule* module, + const SystemInfo* system_info, + string* symbol_file, + char** symbol_data, + size_t* symbol_data_size) { std::string symbol_data_string; SymbolSupplier::SymbolResult result = GetSymbolFile(module, system_info, @@ -186,21 +186,21 @@ OnDemandSymbolSupplier::GetCStringSymbolData(const CodeModule *module, return result; } -void OnDemandSymbolSupplier::FreeSymbolData(const CodeModule *module) { - map::iterator it = memory_buffers_.find(module->code_file()); +void OnDemandSymbolSupplier::FreeSymbolData(const CodeModule* module) { + map::iterator it = memory_buffers_.find(module->code_file()); if (it != memory_buffers_.end()) { delete [] it->second; memory_buffers_.erase(it); } } -string OnDemandSymbolSupplier::GetLocalModulePath(const CodeModule *module) { - NSFileManager *mgr = [NSFileManager defaultManager]; - const char *moduleStr = module->code_file().c_str(); - NSString *modulePath = +string OnDemandSymbolSupplier::GetLocalModulePath(const CodeModule* module) { + NSFileManager* mgr = [NSFileManager defaultManager]; + const char* moduleStr = module->code_file().c_str(); + NSString* modulePath = [mgr stringWithFileSystemRepresentation:moduleStr length:strlen(moduleStr)]; - const char *searchStr = search_dir_.c_str(); - NSString *searchDir = + const char* searchStr = search_dir_.c_str(); + NSString* searchDir = [mgr stringWithFileSystemRepresentation:searchStr length:strlen(searchStr)]; if ([mgr fileExistsAtPath:modulePath]) @@ -209,9 +209,9 @@ string OnDemandSymbolSupplier::GetLocalModulePath(const CodeModule *module) { // If the module is not found, try to start appending the components to the // search string and stop if a file (not dir) is found or all components // have been appended - NSArray *pathComponents = [modulePath componentsSeparatedByString:@"/"]; + NSArray* pathComponents = [modulePath componentsSeparatedByString:@"/"]; size_t count = [pathComponents count]; - NSMutableString *path = [NSMutableString string]; + NSMutableString* path = [NSMutableString string]; for (size_t i = 0; i < count; ++i) { [path setString:searchDir]; @@ -230,22 +230,22 @@ string OnDemandSymbolSupplier::GetLocalModulePath(const CodeModule *module) { return ""; } -string OnDemandSymbolSupplier::GetModulePath(const CodeModule *module) { +string OnDemandSymbolSupplier::GetModulePath(const CodeModule* module) { return module->code_file(); } -string OnDemandSymbolSupplier::GetNameForModule(const CodeModule *module) { +string OnDemandSymbolSupplier::GetNameForModule(const CodeModule* module) { return PathnameStripper::File(module->code_file()); } -string OnDemandSymbolSupplier::GetModuleSymbolFile(const CodeModule *module) { +string OnDemandSymbolSupplier::GetModuleSymbolFile(const CodeModule* module) { string name(GetNameForModule(module)); map::iterator result = module_file_map_.find(name); return (result == module_file_map_.end()) ? "" : (*result).second; } -static float GetFileModificationTime(const char *path) { +static float GetFileModificationTime(const char* path) { float result = 0; struct stat file_stat; if (stat(path, &file_stat) == 0) @@ -255,12 +255,12 @@ static float GetFileModificationTime(const char *path) { return result; } -bool OnDemandSymbolSupplier::GenerateSymbolFile(const CodeModule *module, - const SystemInfo *system_info) { +bool OnDemandSymbolSupplier::GenerateSymbolFile(const CodeModule* module, + const SystemInfo* system_info) { bool result = true; string name = GetNameForModule(module); string module_path = GetLocalModulePath(module); - NSString *symbol_path = [NSString stringWithFormat:@"/tmp/%s.%s.sym", + NSString* symbol_path = [NSString stringWithFormat:@"/tmp/%s.%s.sym", name.c_str(), system_info->cpu.c_str()]; if (module_path.empty()) diff --git a/src/tools/mac/dump_syms/dump_syms_tool.cc b/src/tools/mac/dump_syms/dump_syms_tool.cc index 6f68457b..8d73f0bd 100644 --- a/src/tools/mac/dump_syms/dump_syms_tool.cc +++ b/src/tools/mac/dump_syms/dump_syms_tool.cc @@ -106,7 +106,7 @@ static void CopyCFIDataBetweenModules(Module* to_module, } } -static bool Start(const Options &options) { +static bool Start(const Options& options) { SymbolData symbol_data = options.cfi ? ALL_SYMBOL_DATA : NO_CFI; DumpSymbols dump_symbols(symbol_data, options.handle_inter_cu_refs); @@ -210,7 +210,7 @@ static void SetupOptions(int argc, const char *argv[], Options *options) { extern int optind; signed char ch; - while ((ch = getopt(argc, (char * const *)argv, "ia:g:chr?")) != -1) { + while ((ch = getopt(argc, (char * const*)argv, "ia:g:chr?")) != -1) { switch (ch) { case 'i': options->header_only = true; diff --git a/src/tools/mac/dump_syms/macho_dump.cc b/src/tools/mac/dump_syms/macho_dump.cc index 6e784ca7..34f82ab1 100644 --- a/src/tools/mac/dump_syms/macho_dump.cc +++ b/src/tools/mac/dump_syms/macho_dump.cc @@ -60,7 +60,7 @@ namespace mach_o = google_breakpad::mach_o; string program_name; -int check_syscall(int result, const char *operation, const char *filename) { +int check_syscall(int result, const char* operation, const char* filename) { if (result < 0) { fprintf(stderr, "%s: %s '%s': %s\n", program_name.c_str(), operation, @@ -73,7 +73,7 @@ int check_syscall(int result, const char *operation, const char *filename) { class DumpSection: public mach_o::Reader::SectionHandler { public: DumpSection() : index_(0) { } - bool HandleSection(const mach_o::Section §ion) { + bool HandleSection(const mach_o::Section& section) { printf(" section %d '%s' in segment '%s'\n" " address: 0x%llx\n" " alignment: 1 << %d B\n" @@ -92,13 +92,13 @@ class DumpSection: public mach_o::Reader::SectionHandler { class DumpCommand: public mach_o::Reader::LoadCommandHandler { public: - DumpCommand(mach_o::Reader *reader) : reader_(reader), index_(0) { } + DumpCommand(mach_o::Reader* reader) : reader_(reader), index_(0) { } bool UnknownCommand(mach_o::LoadCommandType type, - const ByteBuffer &contents) { + const ByteBuffer& contents) { printf(" load command %d: %d", index_++, type); return true; } - bool SegmentCommand(const mach_o::Segment &segment) { + bool SegmentCommand(const mach_o::Segment& segment) { printf(" load command %d: %s-bit segment '%s'\n" " address: 0x%llx\n" " memory size: 0x%llx\n" @@ -115,24 +115,24 @@ class DumpCommand: public mach_o::Reader::LoadCommandHandler { return reader_->WalkSegmentSections(segment, &dump_section); } private: - mach_o::Reader *reader_; + mach_o::Reader* reader_; int index_; }; -void DumpFile(const char *filename) { +void DumpFile(const char* filename) { int fd = check_syscall(open(filename, O_RDONLY), "opening", filename); struct stat attributes; check_syscall(fstat(fd, &attributes), "getting file attributes for", filename); - void *mapping = mmap(NULL, attributes.st_size, PROT_READ, + void* mapping = mmap(NULL, attributes.st_size, PROT_READ, MAP_PRIVATE, fd, 0); close(fd); - check_syscall(mapping == (void *)-1 ? -1 : 0, + check_syscall(mapping == (void*)-1 ? -1 : 0, "mapping contents of", filename); mach_o::FatReader::Reporter fat_reporter(filename); mach_o::FatReader fat_reader(&fat_reporter); - if (!fat_reader.Read(reinterpret_cast(mapping), + if (!fat_reader.Read(reinterpret_cast(mapping), attributes.st_size)) { exit(1); } @@ -140,14 +140,14 @@ void DumpFile(const char *filename) { size_t object_files_size; const SuperFatArch* super_fat_object_files = fat_reader.object_files(&object_files_size); - struct fat_arch *object_files; + struct fat_arch* object_files; if (!super_fat_object_files->ConvertToFatArch(object_files)) { exit(1); } printf(" object file count: %ld\n", object_files_size); for (size_t i = 0; i < object_files_size; i++) { - const struct fat_arch &file = object_files[i]; - const NXArchInfo *fat_arch_info = + const struct fat_arch& file = object_files[i]; + const NXArchInfo* fat_arch_info = google_breakpad::BreakpadGetArchInfoFromCpuType( file.cputype, file.cpusubtype); printf("\n object file %ld:\n" @@ -162,7 +162,7 @@ void DumpFile(const char *filename) { name << filename; if (object_files_size > 1) name << ", object file #" << i; - ByteBuffer file_contents(reinterpret_cast(mapping) + ByteBuffer file_contents(reinterpret_cast(mapping) + file.offset, file.size); mach_o::Reader::Reporter reporter(name.str()); mach_o::Reader reader(&reporter); @@ -170,7 +170,7 @@ void DumpFile(const char *filename) { exit(1); } - const NXArchInfo *macho_arch_info = + const NXArchInfo* macho_arch_info = NXGetArchInfoFromCpuType(reader.cpu_type(), reader.cpu_subtype()); printf(" Mach-O header:\n" @@ -190,7 +190,7 @@ void DumpFile(const char *filename) { } // namespace -int main(int argc, char **argv) { +int main(int argc, char** argv) { program_name = google_breakpad::BaseName(argv[0]); if (argc == 1) { fprintf(stderr, "Usage: %s FILE ...\n" diff --git a/src/tools/solaris/dump_syms/dump_syms.cc b/src/tools/solaris/dump_syms/dump_syms.cc index 54cea57e..ba396e10 100644 --- a/src/tools/solaris/dump_syms/dump_syms.cc +++ b/src/tools/solaris/dump_syms/dump_syms.cc @@ -36,13 +36,13 @@ using namespace google_breakpad; -int main(int argc, char **argv) { +int main(int argc, char** argv) { if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); return 1; } - const char *binary = argv[1]; + const char* binary = argv[1]; DumpSymbols dumper; if (!dumper.WriteSymbolFile(binary, fileno(stdout))) { diff --git a/src/tools/solaris/dump_syms/testdata/dump_syms_regtest.cc b/src/tools/solaris/dump_syms/testdata/dump_syms_regtest.cc index e617a23b..6824ed98 100644 --- a/src/tools/solaris/dump_syms/testdata/dump_syms_regtest.cc +++ b/src/tools/solaris/dump_syms/testdata/dump_syms_regtest.cc @@ -41,7 +41,7 @@ class C { void f() { member_ = g(); } virtual int g() { return 2; } - static char* h(const C &that) { return 0; } + static char* h(const C& that) { return 0; } private: int member_; @@ -53,12 +53,12 @@ static int i() { } // namespace google_breakpad -int main(int argc, char **argv) { +int main(int argc, char** argv) { google_breakpad::C object; object.set_member(google_breakpad::i()); object.f(); int value = object.g(); - char *nothing = object.h(object); + char* nothing = object.h(object); return 0; } diff --git a/src/tools/windows/converter/ms_symbol_server_converter.cc b/src/tools/windows/converter/ms_symbol_server_converter.cc index 2b40faee..102d06fd 100644 --- a/src/tools/windows/converter/ms_symbol_server_converter.cc +++ b/src/tools/windows/converter/ms_symbol_server_converter.cc @@ -92,7 +92,7 @@ namespace google_breakpad { #endif // _MSC_VER >= 1400 bool GUIDOrSignatureIdentifier::InitializeFromString( - const string &identifier) { + const string& identifier) { type_ = TYPE_NONE; size_t length = identifier.length(); @@ -128,7 +128,7 @@ bool GUIDOrSignatureIdentifier::InitializeFromString( #undef SSCANF MSSymbolServerConverter::MSSymbolServerConverter( - const string &local_cache, const vector &symbol_servers) + const string& local_cache, const vector& symbol_servers) : symbol_path_(), fail_dns_(false), fail_timeout_(false), @@ -184,7 +184,7 @@ class AutoSymSrv { } } - bool Initialize(HANDLE process, char *path, bool invade_process) { + bool Initialize(HANDLE process, char* path, bool invade_process) { process_ = process; // TODO(nbilling): Figure out why dbghelp.dll is being loaded from @@ -240,7 +240,7 @@ class AutoSymSrv { // are supported by calling Delete(). class AutoDeleter { public: - explicit AutoDeleter(const string &path) : path_(path) {} + explicit AutoDeleter(const string& path) : path_(path) {} ~AutoDeleter() { int error; @@ -270,10 +270,10 @@ class AutoDeleter { }; MSSymbolServerConverter::LocateResult -MSSymbolServerConverter::LocateFile(const string &debug_or_code_file, - const string &debug_or_code_id, - const string &version, - string *file_name) { +MSSymbolServerConverter::LocateFile(const string& debug_or_code_file, + const string& debug_or_code_id, + const string& version, + string* file_name) { assert(file_name); file_name->clear(); @@ -290,7 +290,7 @@ MSSymbolServerConverter::LocateFile(const string &debug_or_code_file, HANDLE process = GetCurrentProcess(); // CloseHandle is not needed. AutoSymSrv symsrv; if (!symsrv.Initialize(process, - const_cast(symbol_path_.c_str()), + const_cast(symbol_path_.c_str()), false)) { fprintf(stderr, "LocateFile: SymInitialize: error %lu for %s %s %s\n", GetLastError(), @@ -326,8 +326,8 @@ MSSymbolServerConverter::LocateFile(const string &debug_or_code_file, char path[MAX_PATH]; if (!SymFindFileInPath( process, NULL, - const_cast(debug_or_code_file.c_str()), - const_cast(identifier.guid_or_signature_pointer()), + const_cast(debug_or_code_file.c_str()), + const_cast(identifier.guid_or_signature_pointer()), identifier.age(), 0, identifier.type() == GUIDOrSignatureIdentifier::TYPE_GUID ? SSRVOPT_GUIDPTR : SSRVOPT_DWORDPTR, @@ -393,15 +393,15 @@ MSSymbolServerConverter::LocateFile(const string &debug_or_code_file, MSSymbolServerConverter::LocateResult -MSSymbolServerConverter::LocatePEFile(const MissingSymbolInfo &missing, - string *pe_file) { +MSSymbolServerConverter::LocatePEFile(const MissingSymbolInfo& missing, + string* pe_file) { return LocateFile(missing.code_file, missing.code_identifier, missing.version, pe_file); } MSSymbolServerConverter::LocateResult -MSSymbolServerConverter::LocateSymbolFile(const MissingSymbolInfo &missing, - string *symbol_file) { +MSSymbolServerConverter::LocateSymbolFile(const MissingSymbolInfo& missing, + string* symbol_file) { return LocateFile(missing.debug_file, missing.debug_identifier, missing.version, symbol_file); } @@ -412,13 +412,13 @@ BOOL CALLBACK MSSymbolServerConverter::SymCallback(HANDLE process, ULONG action, ULONG64 data, ULONG64 context) { - MSSymbolServerConverter *self = - reinterpret_cast(context); + MSSymbolServerConverter* self = + reinterpret_cast(context); switch (action) { case CBA_EVENT: { - IMAGEHLP_CBA_EVENT *cba_event = - reinterpret_cast(data); + IMAGEHLP_CBA_EVENT* cba_event = + reinterpret_cast(data); // Put the string into a string object to be able to use string::find // for substring matching. This is important because the not-found @@ -429,8 +429,8 @@ BOOL CALLBACK MSSymbolServerConverter::SymCallback(HANDLE process, // desc_action maps strings (in desc) to boolean pointers that are to // be set to true if the string matches. struct desc_action { - const char *desc; // The substring to match. - bool *action; // On match, this pointer will be set to true. + const char* desc; // The substring to match. + bool* action; // On match, this pointer will be set to true. }; static const desc_action desc_actions[] = { @@ -478,7 +478,7 @@ BOOL CALLBACK MSSymbolServerConverter::SymCallback(HANDLE process, // static BOOL CALLBACK MSSymbolServerConverter::SymFindFileInPathCallback( - const char *filename, void *context) { + const char* filename, void* context) { // FALSE ends the search, indicating that the located symbol file is // satisfactory. return FALSE; @@ -486,12 +486,12 @@ BOOL CALLBACK MSSymbolServerConverter::SymFindFileInPathCallback( MSSymbolServerConverter::LocateResult MSSymbolServerConverter::LocateAndConvertSymbolFile( - const MissingSymbolInfo &missing, + const MissingSymbolInfo& missing, bool keep_symbol_file, bool keep_pe_file, - string *converted_symbol_file, - string *symbol_file, - string *out_pe_file) { + string* converted_symbol_file, + string* symbol_file, + string* out_pe_file) { assert(converted_symbol_file); converted_symbol_file->clear(); if (symbol_file) { @@ -580,7 +580,7 @@ MSSymbolServerConverter::LocateAndConvertSymbolFile( *converted_symbol_file = pdb_file.substr(0, pdb_file.length() - 4) + ".sym"; - FILE *converted_output = NULL; + FILE* converted_output = NULL; #if _MSC_VER >= 1400 // MSVC 2005/8 errno_t err; if ((err = fopen_s(&converted_output, converted_symbol_file->c_str(), "w")) @@ -634,10 +634,10 @@ MSSymbolServerConverter::LocateAndConvertSymbolFile( MSSymbolServerConverter::LocateResult MSSymbolServerConverter::LocateAndConvertPEFile( - const MissingSymbolInfo &missing, + const MissingSymbolInfo& missing, bool keep_pe_file, - string *converted_symbol_file, - string *out_pe_file) { + string* converted_symbol_file, + string* out_pe_file) { assert(converted_symbol_file); converted_symbol_file->clear(); @@ -676,7 +676,7 @@ MSSymbolServerConverter::LocateAndConvertPEFile( *converted_symbol_file = pe_file.substr(0, pe_file.length() - 4) + ".sym"; - FILE *converted_output = NULL; + FILE* converted_output = NULL; #if _MSC_VER >= 1400 // MSVC 2005/8 errno_t err; if ((err = fopen_s(&converted_output, converted_symbol_file->c_str(), "w")) diff --git a/src/tools/windows/converter/ms_symbol_server_converter.h b/src/tools/windows/converter/ms_symbol_server_converter.h index 401f7c34..40d65d52 100644 --- a/src/tools/windows/converter/ms_symbol_server_converter.h +++ b/src/tools/windows/converter/ms_symbol_server_converter.h @@ -101,13 +101,13 @@ class GUIDOrSignatureIdentifier { // component fields: either a GUID and age, or signature and age. If // successful, sets the relevant fields in the object, including the type // field, and returns true. On error, returns false. - bool InitializeFromString(const string &identifier); + bool InitializeFromString(const string& identifier); GUIDOrSignatureType type() const { return type_; } GUID guid() const { return guid_; } DWORD signature() const { return signature_; } int age() const { return age_; } - const void *guid_or_signature_pointer() const { return &guid_; } + const void* guid_or_signature_pointer() const { return &guid_; } private: GUIDOrSignatureType type_; @@ -141,23 +141,23 @@ class MSSymbolServerConverter { // store to try. The vector must contain at least one string. None of the // strings passed to this constructor may contain asterisk ('*') or semicolon // (';') characters, as the symbol engine uses these characters as separators. - MSSymbolServerConverter(const string &local_cache, - const vector &symbol_servers); + MSSymbolServerConverter(const string& local_cache, + const vector& symbol_servers); // Locates the PE file (DLL or EXE) specified by the identifying information // in |missing|, by checking the symbol stores identified when the object // was created. When returning LOCATE_SUCCESS, pe_file is set to // the pathname of the decompressed PE file as it is stored in the // local cache. - LocateResult LocatePEFile(const MissingSymbolInfo &missing, string *pe_file); + LocateResult LocatePEFile(const MissingSymbolInfo& missing, string* pe_file); // Locates the symbol file specified by the identifying information in // |missing|, by checking the symbol stores identified when the object // was created. When returning LOCATE_SUCCESS, symbol_file is set to // the pathname of the decompressed symbol file as it is stored in the // local cache. - LocateResult LocateSymbolFile(const MissingSymbolInfo &missing, - string *symbol_file); + LocateResult LocateSymbolFile(const MissingSymbolInfo& missing, + string* symbol_file); // Calls LocateSymbolFile and converts the returned symbol file to the // dumped-symbol format, storing it adjacent to the symbol file. The @@ -170,12 +170,12 @@ class MSSymbolServerConverter { // is desired, set |keep_symbol_file| and |keep_pe_file| to false to indicate // that the original symbol file (pdb) and executable file (exe, dll) should // be deleted after conversion. - LocateResult LocateAndConvertSymbolFile(const MissingSymbolInfo &missing, + LocateResult LocateAndConvertSymbolFile(const MissingSymbolInfo& missing, bool keep_symbol_file, bool keep_pe_file, - string *converted_symbol_file, - string *symbol_file, - string *pe_file); + string* converted_symbol_file, + string* symbol_file, + string* pe_file); // Calls LocatePEFile and converts the returned PE file to the // dumped-symbol format, storing it adjacent to the PE file. The @@ -188,10 +188,10 @@ class MSSymbolServerConverter { // to false to indicate that the executable file (exe, dll) should be deleted // after conversion. // NOTE: Currrently only supports x64 PEs. - LocateResult LocateAndConvertPEFile(const MissingSymbolInfo &missing, - bool keep_pe_file, - string *converted_symbol_file, - string *pe_file); + LocateResult LocateAndConvertPEFile(const MissingSymbolInfo& missing, + bool keep_pe_file, + string* converted_symbol_file, + string* pe_file); private: // Locates the PDB or PE file (DLL or EXE) specified by the identifying @@ -199,9 +199,9 @@ class MSSymbolServerConverter { // the symbol stores identified when the object was created. When // returning LOCATE_SUCCESS, file_name is set to the pathname of the // decompressed PDB or PE file file as it is stored in the local cache. - LocateResult LocateFile(const string &debug_or_code_file, - const string &debug_or_code_id, - const string &version, string *file_name); + LocateResult LocateFile(const string& debug_or_code_file, + const string& debug_or_code_id, + const string& version, string* file_name); // Called by various SymSrv functions to report status as progress is made // and to allow the callback to influence processing. Messages sent to this @@ -215,8 +215,8 @@ class MSSymbolServerConverter { // SymFindFileInPath actually seems to accept NULL for a callback function // and behave properly for our needs in that case, but the documentation // doesn't mention it, so this little callback is provided. - static BOOL CALLBACK SymFindFileInPathCallback(const char *filename, - void *context); + static BOOL CALLBACK SymFindFileInPathCallback(const char* filename, + void* context); // The search path used by SymSrv, built based on the arguments to the // constructor. diff --git a/src/tools/windows/converter_exe/converter.cc b/src/tools/windows/converter_exe/converter.cc index 5b70903a..06bd8ebb 100644 --- a/src/tools/windows/converter_exe/converter.cc +++ b/src/tools/windows/converter_exe/converter.cc @@ -62,14 +62,14 @@ using google_breakpad::MissingSymbolInfo; using google_breakpad::MSSymbolServerConverter; using google_breakpad::WindowsStringUtils; -const char *kMissingStringDelimiters = "|"; -const char *kLocalCachePath = "c:\\symbols"; -const char *kNoExeMSSSServer = "http://msdl.microsoft.com/download/symbols/"; +const char* kMissingStringDelimiters = "|"; +const char* kLocalCachePath = "c:\\symbols"; +const char* kNoExeMSSSServer = "http://msdl.microsoft.com/download/symbols/"; // Windows stdio doesn't do line buffering. Use this function to flush after // writing to stdout and stderr so that a log will be available if the // converter crashes. -static int FprintfFlush(FILE *file, const char *format, ...) { +static int FprintfFlush(FILE* file, const char* format, ...) { va_list arguments; va_start(arguments, format); int retval = vfprintf(file, format, arguments); @@ -86,11 +86,11 @@ static string CurrentDateAndTime() { // localtime_s is safer but is only available in MSVC8. Use localtime // in earlier environments. - struct tm *time_pointer; + struct tm* time_pointer; #if _MSC_VER >= 1400 // MSVC 2005/8 struct tm time_struct; - time_pointer = &time_struct; - if (localtime_s(time_pointer, ¤t_time) != 0) { + time_pointer =& time_struct; + if (localtime_s(time_pointer,& current_time) != 0) { return kUnknownDateAndTime; } #else // _MSC_VER >= 1400 @@ -111,12 +111,12 @@ static string CurrentDateAndTime() { // ParseMissingString turns |missing_string| into a MissingSymbolInfo // structure. It returns true on success, and false if no such conversion // is possible. -static bool ParseMissingString(const string &missing_string, - MissingSymbolInfo *missing_info) { +static bool ParseMissingString(const string& missing_string, + MissingSymbolInfo* missing_info) { assert(missing_info); vector tokens; - Tokenizer::Tokenize(kMissingStringDelimiters, missing_string, &tokens); + Tokenizer::Tokenize(kMissingStringDelimiters, missing_string,& tokens); if (tokens.size() != 5) { return false; } @@ -133,8 +133,8 @@ static bool ParseMissingString(const string &missing_string, // StringMapToWStringMap takes each element in a map that associates // (narrow) strings to strings and converts the keys and values to wstrings. // Returns true on success and false on failure, printing an error message. -static bool StringMapToWStringMap(const map &smap, - map *wsmap) { +static bool StringMapToWStringMap(const map& smap, + map* wsmap) { assert(wsmap); wsmap->clear(); @@ -142,7 +142,7 @@ static bool StringMapToWStringMap(const map &smap, iterator != smap.end(); ++iterator) { wstring key; - if (!WindowsStringUtils::safe_mbstowcs(iterator->first, &key)) { + if (!WindowsStringUtils::safe_mbstowcs(iterator->first,& key)) { FprintfFlush(stderr, "StringMapToWStringMap: safe_mbstowcs failed for key %s\n", iterator->first.c_str()); @@ -150,7 +150,7 @@ static bool StringMapToWStringMap(const map &smap, } wstring value; - if (!WindowsStringUtils::safe_mbstowcs(iterator->second, &value)) { + if (!WindowsStringUtils::safe_mbstowcs(iterator->second,& value)) { FprintfFlush(stderr, "StringMapToWStringMap: safe_mbstowcs failed " "for value %s\n", iterator->second.c_str()); @@ -166,8 +166,8 @@ static bool StringMapToWStringMap(const map &smap, // MissingSymbolInfoToParameters turns a MissingSymbolInfo structure into a // map of parameters suitable for passing to HTTPDownload or HTTPUpload. // Returns true on success and false on failure, printing an error message. -static bool MissingSymbolInfoToParameters(const MissingSymbolInfo &missing_info, - map *wparameters) { +static bool MissingSymbolInfoToParameters(const MissingSymbolInfo& missing_info, + map* wparameters) { assert(wparameters); map parameters; @@ -175,25 +175,25 @@ static bool MissingSymbolInfoToParameters(const MissingSymbolInfo &missing_info, // Indicate the params are encoded. parameters["encoded"] = "true"; // The string value here does not matter. - WebSafeBase64Escape(missing_info.code_file, &encoded_param); + WebSafeBase64Escape(missing_info.code_file,& encoded_param); parameters["code_file"] = encoded_param; - WebSafeBase64Escape(missing_info.code_identifier, &encoded_param); + WebSafeBase64Escape(missing_info.code_identifier,& encoded_param); parameters["code_identifier"] = encoded_param; - WebSafeBase64Escape(missing_info.debug_file, &encoded_param); + WebSafeBase64Escape(missing_info.debug_file,& encoded_param); parameters["debug_file"] = encoded_param; - WebSafeBase64Escape(missing_info.debug_identifier, &encoded_param); + WebSafeBase64Escape(missing_info.debug_identifier,& encoded_param); parameters["debug_identifier"] = encoded_param; if (!missing_info.version.empty()) { // The version is optional. - WebSafeBase64Escape(missing_info.version, &encoded_param); + WebSafeBase64Escape(missing_info.version,& encoded_param); parameters["version"] = encoded_param; } - WebSafeBase64Escape("WinSymConv", &encoded_param); + WebSafeBase64Escape("WinSymConv",& encoded_param); parameters["product"] = encoded_param; if (!StringMapToWStringMap(parameters, wparameters)) { @@ -207,18 +207,18 @@ static bool MissingSymbolInfoToParameters(const MissingSymbolInfo &missing_info, // UploadSymbolFile sends |converted_file| as identified by |missing_info| // to the symbol server rooted at |upload_symbol_url|. Returns true on // success and false on failure, printing an error message. -static bool UploadSymbolFile(const wstring &upload_symbol_url, - const MissingSymbolInfo &missing_info, - const string &converted_file) { +static bool UploadSymbolFile(const wstring& upload_symbol_url, + const MissingSymbolInfo& missing_info, + const string& converted_file) { map parameters; - if (!MissingSymbolInfoToParameters(missing_info, ¶meters)) { + if (!MissingSymbolInfoToParameters(missing_info,& parameters)) { // MissingSymbolInfoToParameters or a callee will have printed an error. return false; } wstring converted_file_w; - if (!WindowsStringUtils::safe_mbstowcs(converted_file, &converted_file_w)) { + if (!WindowsStringUtils::safe_mbstowcs(converted_file,& converted_file_w)) { FprintfFlush(stderr, "UploadSymbolFile: safe_mbstowcs failed for %s\n", converted_file.c_str()); return false; @@ -245,18 +245,18 @@ static bool UploadSymbolFile(const wstring &upload_symbol_url, // |fetch_symbol_failure_url| that the symbol file identified by // |missing_info| could authoritatively not be located. Returns // true on success and false on failure. -static bool SendFetchFailedPing(const wstring &fetch_symbol_failure_url, - const MissingSymbolInfo &missing_info) { +static bool SendFetchFailedPing(const wstring& fetch_symbol_failure_url, + const MissingSymbolInfo& missing_info) { map parameters; - if (!MissingSymbolInfoToParameters(missing_info, ¶meters)) { + if (!MissingSymbolInfoToParameters(missing_info,& parameters)) { // MissingSymbolInfoToParameters or a callee will have printed an error. return false; } string content; if (!HTTPDownload::Download(fetch_symbol_failure_url, - ¶meters, - &content, + & parameters, + & content, NULL)) { FprintfFlush(stderr, "SendFetchFailedPing: HTTPDownload::Download failed " "for %s %s %s\n", @@ -275,7 +275,7 @@ static bool SendFetchFailedPing(const wstring &fetch_symbol_failure_url, // the given blacklist regular expression. // The debug_file name is used from the MissingSymbolInfo struct, // matched against the blacklist_regex. -static bool SafeToMakeExternalRequest(const MissingSymbolInfo &missing_info, +static bool SafeToMakeExternalRequest(const MissingSymbolInfo& missing_info, std::regex blacklist_regex) { string file_name = missing_info.debug_file; // Use regex_search because we want to match substrings. @@ -352,8 +352,8 @@ struct ConverterOptions { // stored at |options.local_cache_path|. Because nothing can be done even in // the event of a failure, this function returns no value, although it // may result in error messages being printed. -static void ConvertMissingSymbolFile(const MissingSymbolInfo &missing_info, - const ConverterOptions &options) { +static void ConvertMissingSymbolFile(const MissingSymbolInfo& missing_info, + const ConverterOptions& options) { string time_string = CurrentDateAndTime(); FprintfFlush(stdout, "converter: %s: attempting %s %s %s\n", time_string.c_str(), @@ -402,7 +402,7 @@ static void ConvertMissingSymbolFile(const MissingSymbolInfo &missing_info, located = converter.LocateAndConvertSymbolFile(missing_info, false, // keep_symbol_file false, // keep_pe_file - &converted_file, + & converted_file, NULL, // symbol_file NULL); // pe_file switch (located) { @@ -476,7 +476,7 @@ static void ConvertMissingSymbolFile(const MissingSymbolInfo &missing_info, missing_info, false, // keep_symbol_file false, // keep_pe_file - &converted_file, + & converted_file, NULL, // symbol_file NULL); // pe_file } else { @@ -561,9 +561,9 @@ static void ConvertMissingSymbolFile(const MissingSymbolInfo &missing_info, // Reads the contents of file |file_name| and populates |contents|. // Returns true on success. -static bool ReadFile(string file_name, string *contents) { +static bool ReadFile(string file_name, string* contents) { char buffer[1024 * 8]; - FILE *fp = fopen(file_name.c_str(), "rt"); + FILE* fp = fopen(file_name.c_str(), "rt"); if (!fp) { return false; } @@ -578,7 +578,7 @@ static bool ReadFile(string file_name, string *contents) { // ConvertMissingSymbolsList obtains a missing symbol list from // |options.missing_symbols_url| or |options.missing_symbols_file| and calls // ConvertMissingSymbolFile for each missing symbol file in the list. -static bool ConvertMissingSymbolsList(const ConverterOptions &options) { +static bool ConvertMissingSymbolsList(const ConverterOptions& options) { // Set param to indicate requesting for encoded response. map parameters; parameters[L"product"] = L"WinSymConv"; @@ -586,17 +586,17 @@ static bool ConvertMissingSymbolsList(const ConverterOptions &options) { // Get the missing symbol list. string missing_symbol_list; if (!options.missing_symbols_file.empty()) { - if (!ReadFile(options.missing_symbols_file, &missing_symbol_list)) { + if (!ReadFile(options.missing_symbols_file,& missing_symbol_list)) { return false; } - } else if (!HTTPDownload::Download(options.missing_symbols_url, ¶meters, - &missing_symbol_list, NULL)) { + } else if (!HTTPDownload::Download(options.missing_symbols_url,& parameters, + & missing_symbol_list, NULL)) { return false; } // Tokenize the content into a vector. vector missing_symbol_lines; - Tokenizer::Tokenize("\n", missing_symbol_list, &missing_symbol_lines); + Tokenizer::Tokenize("\n", missing_symbol_list,& missing_symbol_lines); FprintfFlush(stderr, "Found %d missing symbol files in list.\n", missing_symbol_lines.size() - 1); // last line is empty. @@ -605,14 +605,14 @@ static bool ConvertMissingSymbolsList(const ConverterOptions &options) { iterator != missing_symbol_lines.end(); ++iterator) { // Decode symbol line. - const string &encoded_line = *iterator; + const string& encoded_line = *iterator; // Skip lines that are blank. if (encoded_line.empty()) { continue; } string line; - if (!WebSafeBase64Unescape(encoded_line, &line)) { + if (!WebSafeBase64Unescape(encoded_line,& line)) { // If decoding fails, assume the line is not encoded. // This is helpful when the program connects to a debug server without // encoding. @@ -623,7 +623,7 @@ static bool ConvertMissingSymbolsList(const ConverterOptions &options) { // Turn each element into a MissingSymbolInfo structure. MissingSymbolInfo missing_info; - if (!ParseMissingString(line, &missing_info)) { + if (!ParseMissingString(line,& missing_info)) { FprintfFlush(stderr, "ConvertMissingSymbols: ParseMissingString failed " "for %s from %ws\n", line.c_str(), options.missing_symbols_url.c_str()); @@ -647,7 +647,7 @@ static bool ConvertMissingSymbolsList(const ConverterOptions &options) { // usage prints the usage message. It returns 1 as a convenience, to be used // as a return value from main. -static int usage(const char *program_name) { +static int usage(const char* program_name) { FprintfFlush(stderr, "usage: %s [options]\n" " -f MS servers to ask for all symbols\n" @@ -670,7 +670,7 @@ static int usage(const char *program_name) { // "Internal" servers consist only of those whose names start with // the literal string "\\filer\". -static bool IsInternalServer(const string &server_name) { +static bool IsInternalServer(const string& server_name) { if (server_name.find("\\\\filer\\") == 0) { return true; } @@ -679,9 +679,9 @@ static bool IsInternalServer(const string &server_name) { // Adds a server with the given name to the list of internal or external // servers, as appropriate. -static void AddServer(const string &server_name, - vector *internal_servers, - vector *external_servers) { +static void AddServer(const string& server_name, + vector* internal_servers, + vector* external_servers) { if (IsInternalServer(server_name)) { internal_servers->push_back(server_name); } else { @@ -691,7 +691,7 @@ static void AddServer(const string &server_name, } // namespace -int main(int argc, char **argv) { +int main(int argc, char** argv) { string time_string = CurrentDateAndTime(); FprintfFlush(stdout, "converter: %s: starting\n", time_string.c_str()); @@ -710,12 +710,12 @@ int main(int argc, char **argv) { string value = argv[argi + 1]; if (option == "-f") { - AddServer(value, &options.full_internal_msss_servers, - &options.full_external_msss_servers); + AddServer(value,& options.full_internal_msss_servers, + & options.full_external_msss_servers); have_any_msss_servers = true; } else if (option == "-n") { - AddServer(value, &options.no_exe_internal_msss_servers, - &options.no_exe_external_msss_servers); + AddServer(value,& options.no_exe_internal_msss_servers, + & options.no_exe_external_msss_servers); have_any_msss_servers = true; } else if (option == "-l") { if (!options.local_cache_path.empty()) { @@ -724,14 +724,14 @@ int main(int argc, char **argv) { options.local_cache_path = value; } else if (option == "-s") { if (!WindowsStringUtils::safe_mbstowcs(value, - &options.upload_symbols_url)) { + & options.upload_symbols_url)) { FprintfFlush(stderr, "main: safe_mbstowcs failed for %s\n", value.c_str()); return 1; } } else if (option == "-m") { if (!WindowsStringUtils::safe_mbstowcs(value, - &options.missing_symbols_url)) { + & options.missing_symbols_url)) { FprintfFlush(stderr, "main: safe_mbstowcs failed for %s\n", value.c_str()); return 1; @@ -744,7 +744,7 @@ int main(int argc, char **argv) { } else if (option == "-t") { if (!WindowsStringUtils::safe_mbstowcs( value, - &options.fetch_symbol_failure_url)) { + & options.fetch_symbol_failure_url)) { FprintfFlush(stderr, "main: safe_mbstowcs failed for %s\n", value.c_str()); return 1; @@ -768,8 +768,8 @@ int main(int argc, char **argv) { // Set the defaults. If the user specified any MSSS servers, don't use // any default. if (!have_any_msss_servers) { - AddServer(kNoExeMSSSServer, &options.no_exe_internal_msss_servers, - &options.no_exe_external_msss_servers); + AddServer(kNoExeMSSSServer,& options.no_exe_internal_msss_servers, + & options.no_exe_external_msss_servers); } if (options.local_cache_path.empty()) { diff --git a/src/tools/windows/converter_exe/http_download.cc b/src/tools/windows/converter_exe/http_download.cc index 5afc1ccc..58fcbb3b 100644 --- a/src/tools/windows/converter_exe/http_download.cc +++ b/src/tools/windows/converter_exe/http_download.cc @@ -83,11 +83,11 @@ class AutoPtr { // CheckParameters ensures that the parameters in |parameters| are safe for // use in an HTTP URL. Returns true if they are, false if unsafe characters // are present. -static bool CheckParameters(const map *parameters) { +static bool CheckParameters(const map* parameters) { for (map::const_iterator iterator = parameters->begin(); iterator != parameters->end(); ++iterator) { - const wstring &key = iterator->first; + const wstring& key = iterator->first; if (key.empty()) { // Disallow empty parameter names. return false; @@ -99,7 +99,7 @@ static bool CheckParameters(const map *parameters) { } } - const wstring &value = iterator->second; + const wstring& value = iterator->second; for (unsigned int i = 0; i < value.size(); ++i) { wchar_t c = value[i]; if (c < 32 || c == '"' || c == '?' || c == '&' || c > 127) { @@ -141,8 +141,8 @@ HttpClient* HTTPDownload::CreateHttpClient(const wchar_t* url) { } // static -bool HTTPDownload::Download(const wstring &url, - const map *parameters, +bool HTTPDownload::Download(const wstring& url, + const map* parameters, string *content, int *status_code) { assert(content); AutoPtr http_client(CreateHttpClient(url.c_str())); diff --git a/src/tools/windows/converter_exe/http_download.h b/src/tools/windows/converter_exe/http_download.h index 2d705d5e..cbae11b5 100644 --- a/src/tools/windows/converter_exe/http_download.h +++ b/src/tools/windows/converter_exe/http_download.h @@ -50,8 +50,8 @@ class HTTPDownload { // transaction occurs. If Download fails before a transaction can occur, // |status_code| will be set to 0. Any failures will result in messages // being printed to stderr. - static bool Download(const wstring &url, - const map *parameters, + static bool Download(const wstring& url, + const map* parameters, string *content, int *status_code); private: static HttpClient* CreateHttpClient(const wchar_t*); diff --git a/src/tools/windows/converter_exe/tokenizer.cc b/src/tools/windows/converter_exe/tokenizer.cc index 992694cd..aee39867 100644 --- a/src/tools/windows/converter_exe/tokenizer.cc +++ b/src/tools/windows/converter_exe/tokenizer.cc @@ -33,8 +33,8 @@ namespace crash { // static -void Tokenizer::Tokenize(const string &delimiters, const string &input, - vector *output) { +void Tokenizer::Tokenize(const string& delimiters, const string& input, + vector* output) { assert(output); output->clear(); diff --git a/src/tools/windows/converter_exe/tokenizer.h b/src/tools/windows/converter_exe/tokenizer.h index f4bbcfd0..bfdfa220 100644 --- a/src/tools/windows/converter_exe/tokenizer.h +++ b/src/tools/windows/converter_exe/tokenizer.h @@ -42,8 +42,8 @@ class Tokenizer { // Splits |input| into a series of tokens delimited in the input string by // any of the characters in |delimiters|. The tokens are passed back in the // |output| vector. - static void Tokenize(const string &delimiters, const string &input, - vector *output); + static void Tokenize(const string& delimiters, const string& input, + vector* output); }; } // namespace crash diff --git a/src/tools/windows/converter_exe/winhttp_client.cc b/src/tools/windows/converter_exe/winhttp_client.cc index 8a8ade3b..cc70e53f 100644 --- a/src/tools/windows/converter_exe/winhttp_client.cc +++ b/src/tools/windows/converter_exe/winhttp_client.cc @@ -197,7 +197,7 @@ bool WinHttpClient::GetHttpStatusCode(HttpHandle request_handle, if (!::WinHttpQueryHeaders(ToHINTERNET(request_handle), WINHTTP_QUERY_STATUS_CODE, WINHTTP_HEADER_NAME_BY_INDEX, - static_cast(&http_status_string), + static_cast(&http_status_string), &http_status_string_size, 0)) { return false; } @@ -216,7 +216,7 @@ bool WinHttpClient::GetContentLength(HttpHandle request_handle, if (!::WinHttpQueryHeaders(ToHINTERNET(request_handle), WINHTTP_QUERY_CONTENT_LENGTH, WINHTTP_HEADER_NAME_BY_INDEX, - static_cast(&content_length_string), + static_cast(&content_length_string), &content_length_string_size, 0)) { *content_length = kUnknownContentLength; } else { diff --git a/src/tools/windows/converter_exe/wininet_client.cc b/src/tools/windows/converter_exe/wininet_client.cc index 3e542db2..986a66ff 100644 --- a/src/tools/windows/converter_exe/wininet_client.cc +++ b/src/tools/windows/converter_exe/wininet_client.cc @@ -196,7 +196,7 @@ bool WinInetClient::GetHttpStatusCode(HttpHandle request_handle, DWORD http_status_string_size = sizeof(http_status_string); if (!::HttpQueryInfo(ToHINTERNET(request_handle), HTTP_QUERY_STATUS_CODE, - static_cast(&http_status_string), + static_cast(&http_status_string), &http_status_string_size, 0)) { return false; @@ -215,7 +215,7 @@ bool WinInetClient::GetContentLength(HttpHandle request_handle, DWORD content_length_string_size = sizeof(content_length_string); if (!::HttpQueryInfo(ToHINTERNET(request_handle), HTTP_QUERY_CONTENT_LENGTH, - static_cast(&content_length_string), + static_cast(&content_length_string), &content_length_string_size, 0)) { *content_length = kUnknownContentLength; diff --git a/src/tools/windows/dump_syms/dump_syms.cc b/src/tools/windows/dump_syms/dump_syms.cc index 5b7d1777..1b1797dc 100644 --- a/src/tools/windows/dump_syms/dump_syms.cc +++ b/src/tools/windows/dump_syms/dump_syms.cc @@ -43,7 +43,7 @@ using google_breakpad::PDBSourceLineWriter; using google_breakpad::PESourceLineWriter; using std::unique_ptr; -int wmain(int argc, wchar_t **argv) { +int wmain(int argc, wchar_t** argv) { bool success; if (argc == 2) { PDBSourceLineWriter pdb_writer; diff --git a/src/tools/windows/dump_syms/dump_syms_unittest.cc b/src/tools/windows/dump_syms/dump_syms_unittest.cc index 766e5c09..494b7791 100644 --- a/src/tools/windows/dump_syms/dump_syms_unittest.cc +++ b/src/tools/windows/dump_syms/dump_syms_unittest.cc @@ -166,7 +166,7 @@ void GetFileContents(const std::wstring& path, std::string* content) { } } -class DumpSymsRegressionTest : public testing::TestWithParam { +class DumpSymsRegressionTest : public testing::TestWithParam { public: virtual void SetUp() { std::wstring self_dir; @@ -181,7 +181,7 @@ class DumpSymsRegressionTest : public testing::TestWithParam { std::wstring testdata_dir; }; -class DumpSymsPEOnlyRegressionTest : public testing::TestWithParam { +class DumpSymsPEOnlyRegressionTest : public testing::TestWithParam { public: virtual void SetUp() { std::wstring self_dir; diff --git a/src/tools/windows/dump_syms/testdata/dump_syms_regtest.cc b/src/tools/windows/dump_syms/testdata/dump_syms_regtest.cc index e8efbeb8..de6109fe 100644 --- a/src/tools/windows/dump_syms/testdata/dump_syms_regtest.cc +++ b/src/tools/windows/dump_syms/testdata/dump_syms_regtest.cc @@ -48,7 +48,7 @@ class C { void f() { member_ = g(); } virtual int g() { return 2; } - static char* h(const C &that) { return 0; } + static char* h(const C& that) { return 0; } private: int member_; @@ -60,12 +60,12 @@ static int i() { } // namespace google_breakpad -int main(int argc, char **argv) { +int main(int argc, char** argv) { google_breakpad::C object; object.set_member(google_breakpad::i()); object.f(); int value = object.g(); - char *nothing = object.h(object); + char* nothing = object.h(object); return 0; } diff --git a/src/tools/windows/symupload/symupload.cc b/src/tools/windows/symupload/symupload.cc index 7e302932..e6fa126f 100644 --- a/src/tools/windows/symupload/symupload.cc +++ b/src/tools/windows/symupload/symupload.cc @@ -73,7 +73,7 @@ using google_breakpad::WindowsStringUtils; // Extracts the file version information for the given filename, // as a string, for example, "1.2.3.4". Returns true on success. -static bool GetFileVersionString(const wchar_t *filename, wstring *version) { +static bool GetFileVersionString(const wchar_t* filename, wstring* version) { DWORD handle; DWORD version_size = GetFileVersionInfoSize(filename, &handle); if (version_size < sizeof(VS_FIXEDFILEINFO)) { @@ -85,7 +85,7 @@ static bool GetFileVersionString(const wchar_t *filename, wstring *version) { return false; } - void *file_info_buffer = NULL; + void* file_info_buffer = NULL; unsigned int file_info_length; if (!VerQueryValue(&version_info[0], L"\\", &file_info_buffer, &file_info_length)) { @@ -95,7 +95,7 @@ static bool GetFileVersionString(const wchar_t *filename, wstring *version) { // The maximum value of each version component is 65535 (0xffff), // so the max length is 24, including the terminating null. wchar_t ver_string[24]; - VS_FIXEDFILEINFO *file_info = + VS_FIXEDFILEINFO* file_info = reinterpret_cast(file_info_buffer); swprintf(ver_string, sizeof(ver_string) / sizeof(ver_string[0]), L"%d.%d.%d.%d", @@ -114,9 +114,9 @@ static bool GetFileVersionString(const wchar_t *filename, wstring *version) { // Creates a new temporary file and writes the symbol data from the given // exe/dll file to it. Returns the path to the temp file in temp_file_path // and information about the pdb in pdb_info. -static bool DumpSymbolsToTempFile(const wchar_t *file, - wstring *temp_file_path, - PDBModuleInfo *pdb_info) { +static bool DumpSymbolsToTempFile(const wchar_t* file, + wstring* temp_file_path, + PDBModuleInfo* pdb_info) { google_breakpad::PDBSourceLineWriter writer; // Use EXE_FILE to get information out of the exe/dll in addition to the // pdb. The name and version number of the exe/dll are of value, and @@ -135,7 +135,7 @@ static bool DumpSymbolsToTempFile(const wchar_t *file, return false; } - FILE *temp_file = NULL; + FILE* temp_file = NULL; #if _MSC_VER >= 1400 // MSVC 2005/8 if (_wfopen_s(&temp_file, temp_filename, L"w") != 0) #else // _MSC_VER >= 1400 @@ -270,9 +270,9 @@ __declspec(noreturn) void printUsageAndExit() { exit(0); } -int wmain(int argc, wchar_t *argv[]) { - const wchar_t *module; - const wchar_t *product = nullptr; +int wmain(int argc, wchar_t* argv[]) { + const wchar_t* module; + const wchar_t* product = nullptr; int timeout = -1; int currentarg = 1; bool use_sym_upload_v2 = false; -- cgit v1.2.1