From 6de969a3040fa31ba60302c66613d1d2e6f5a730 Mon Sep 17 00:00:00 2001 From: "ivan.penkov@gmail.com" Date: Thu, 28 Jun 2012 22:46:01 +0000 Subject: This change allows compiling the google-breakpad code using a global ::string class instead of std::string. For more details take a look at common/using_std_string.h git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@974 4c0a9323-5329-0410-9bdc-e9ce6186880e --- .../crash_generation/crash_generation_server.cc | 6 +- .../crash_generation/crash_generation_server.h | 10 ++- src/client/linux/handler/exception_handler.cc | 10 +-- src/client/linux/handler/exception_handler.h | 21 ++--- .../linux/handler/exception_handler_unittest.cc | 13 +-- .../minidump_writer/directory_reader_unittest.cc | 3 +- .../minidump_writer/linux_core_dumper_unittest.cc | 4 +- .../linux_ptrace_dumper_unittest.cc | 2 +- .../minidump_writer/minidump_writer_unittest.cc | 13 +-- .../linux/sender/google_crash_report_sender.cc | 4 +- src/common/byte_cursor.h | 6 +- src/common/byte_cursor_unittest.cc | 4 +- src/common/dwarf/bytereader_unittest.cc | 2 +- src/common/dwarf/cfi_assembler.h | 2 +- src/common/dwarf/dwarf2diehandler.cc | 9 ++- src/common/dwarf/dwarf2diehandler.h | 6 +- src/common/dwarf/dwarf2diehandler_unittest.cc | 2 +- src/common/dwarf/dwarf2reader.cc | 18 +++-- src/common/dwarf/dwarf2reader.h | 27 ++++--- src/common/dwarf/dwarf2reader_cfi_unittest.cc | 2 +- src/common/dwarf/dwarf2reader_die_unittest.cc | 4 +- src/common/dwarf/functioninfo.cc | 13 ++- src/common/dwarf/functioninfo.h | 25 +++--- src/common/dwarf_cfi_to_module.h | 2 +- src/common/dwarf_cfi_to_module_unittest.cc | 2 +- src/common/dwarf_cu_to_module.h | 1 + src/common/dwarf_cu_to_module_unittest.cc | 2 +- src/common/dwarf_line_to_module.cc | 19 +++-- src/common/dwarf_line_to_module.h | 9 ++- src/common/language.h | 4 +- src/common/linux/dump_symbols.cc | 71 +++++++++-------- src/common/linux/dump_symbols.h | 6 +- src/common/linux/dump_symbols_unittest.cc | 6 +- src/common/linux/elf_core_dump_unittest.cc | 2 +- src/common/linux/elf_symbols_to_module_unittest.cc | 2 +- src/common/linux/file_id_unittest.cc | 5 +- src/common/linux/google_crashdump_uploader.cc | 70 ++++++++-------- src/common/linux/google_crashdump_uploader.h | 92 +++++++++++----------- src/common/linux/google_crashdump_uploader_test.cc | 17 ++-- src/common/linux/http_upload.cc | 2 +- src/common/linux/http_upload.h | 3 +- src/common/linux/libcurl_wrapper.cc | 21 +++-- src/common/linux/libcurl_wrapper.h | 17 ++-- src/common/linux/memory_mapped_file_unittest.cc | 2 +- src/common/linux/synth_elf.cc | 2 + src/common/linux/synth_elf.h | 3 +- src/common/linux/synth_elf_unittest.cc | 2 +- src/common/linux/tests/crash_generator.cc | 7 +- src/common/linux/tests/crash_generator.h | 5 +- src/common/module.h | 2 +- src/common/module_unittest.cc | 2 +- src/common/stabs_reader.cc | 6 +- src/common/stabs_reader.h | 5 +- src/common/stabs_reader_unittest.cc | 7 +- src/common/stabs_to_module.cc | 3 +- src/common/stabs_to_module.h | 2 +- src/common/string_conversion.cc | 7 +- src/common/string_conversion.h | 4 +- src/common/test_assembler.h | 2 +- src/common/test_assembler_unittest.cc | 2 +- src/common/tests/auto_tempdir.h | 9 ++- src/common/using_std_string.h | 65 +++++++++++++++ .../processor/basic_source_line_resolver.h | 3 +- src/google_breakpad/processor/code_module.h | 4 +- src/google_breakpad/processor/minidump.h | 2 +- src/google_breakpad/processor/minidump_processor.h | 4 +- src/google_breakpad/processor/process_state.h | 3 +- .../processor/source_line_resolver_interface.h | 4 +- src/google_breakpad/processor/stack_frame.h | 4 +- src/google_breakpad/processor/stackwalker.h | 4 +- src/google_breakpad/processor/symbol_supplier.h | 2 +- src/google_breakpad/processor/system_info.h | 4 +- src/processor/basic_code_module.h | 3 +- .../basic_source_line_resolver_unittest.cc | 2 +- src/processor/binarystream.cc | 7 +- src/processor/binarystream.h | 17 ++-- src/processor/binarystream_unittest.cc | 2 +- src/processor/cfi_frame_info.h | 2 +- src/processor/cfi_frame_info_unittest.cc | 2 +- src/processor/exploitability_unittest.cc | 2 +- src/processor/fast_source_line_resolver.cc | 4 +- .../fast_source_line_resolver_unittest.cc | 2 +- src/processor/logging.cc | 17 ++-- src/processor/logging.h | 9 ++- src/processor/minidump.cc | 6 +- src/processor/minidump_processor_unittest.cc | 6 +- src/processor/minidump_stackwalk.cc | 4 +- src/processor/minidump_unittest.cc | 3 +- src/processor/pathname_stripper.h | 4 +- src/processor/postfix_evaluator.h | 3 +- src/processor/postfix_evaluator_unittest.cc | 2 +- src/processor/simple_symbol_supplier.cc | 5 +- src/processor/simple_symbol_supplier.h | 2 +- src/processor/stackwalker_amd64_unittest.cc | 2 +- src/processor/stackwalker_arm_unittest.cc | 2 +- src/processor/stackwalker_unittest_utils.h | 29 +++---- src/processor/stackwalker_x86_unittest.cc | 2 +- src/processor/static_address_map_unittest.cc | 9 ++- src/processor/synth_minidump.h | 2 +- src/processor/synth_minidump_unittest.cc | 2 +- src/processor/tokenize.cc | 3 +- src/processor/tokenize.h | 12 +-- src/processor/windows_frame_info.h | 7 +- 103 files changed, 520 insertions(+), 384 deletions(-) create mode 100644 src/common/using_std_string.h (limited to 'src') diff --git a/src/client/linux/crash_generation/crash_generation_server.cc b/src/client/linux/crash_generation/crash_generation_server.cc index 76c9d9cd..f7e72447 100644 --- a/src/client/linux/crash_generation/crash_generation_server.cc +++ b/src/client/linux/crash_generation/crash_generation_server.cc @@ -170,7 +170,7 @@ CrashGenerationServer::CrashGenerationServer( OnClientExitingCallback exit_callback, void* exit_context, bool generate_dumps, - const std::string* dump_path) : + const string* dump_path) : server_fd_(listen_fd), dump_callback_(dump_callback), dump_context_(dump_context), @@ -384,7 +384,7 @@ CrashGenerationServer::ClientEvent(short revents) return true; } - std::string minidump_filename; + string minidump_filename; if (!MakeMinidumpFilename(minidump_filename)) return true; @@ -440,7 +440,7 @@ CrashGenerationServer::ControlEvent(short revents) } bool -CrashGenerationServer::MakeMinidumpFilename(std::string& outFilename) +CrashGenerationServer::MakeMinidumpFilename(string& outFilename) { GUID guid; char guidString[kGUIDStringLength+1]; diff --git a/src/client/linux/crash_generation/crash_generation_server.h b/src/client/linux/crash_generation/crash_generation_server.h index a9dc1f7f..483fb709 100644 --- a/src/client/linux/crash_generation/crash_generation_server.h +++ b/src/client/linux/crash_generation/crash_generation_server.h @@ -34,6 +34,8 @@ #include +#include "common/using_std_string.h" + namespace google_breakpad { class ClientInfo; @@ -45,7 +47,7 @@ public: // be thread safe. typedef void (*OnClientDumpRequestCallback)(void* context, const ClientInfo* client_info, - const std::string* file_path); + const string* file_path); typedef void (*OnClientExitingCallback)(void* context, const ClientInfo* client_info); @@ -69,7 +71,7 @@ public: OnClientExitingCallback exit_callback, void* exit_context, bool generate_dumps, - const std::string* dump_path); + const string* dump_path); ~CrashGenerationServer(); @@ -100,7 +102,7 @@ private: bool ControlEvent(short revents); // Return a unique filename at which a minidump can be written - bool MakeMinidumpFilename(std::string& outFilename); + bool MakeMinidumpFilename(string& outFilename); // Trampoline to |Run()| static void* ThreadMain(void* arg); @@ -115,7 +117,7 @@ private: bool generate_dumps_; - std::string dump_dir_; + string dump_dir_; bool started_; diff --git a/src/client/linux/handler/exception_handler.cc b/src/client/linux/handler/exception_handler.cc index 4b78424f..f505ff33 100644 --- a/src/client/linux/handler/exception_handler.cc +++ b/src/client/linux/handler/exception_handler.cc @@ -126,7 +126,7 @@ pthread_mutex_t ExceptionHandler::handler_stack_mutex_ = PTHREAD_MUTEX_INITIALIZER; // Runs before crashing: normal context. -ExceptionHandler::ExceptionHandler(const std::string &dump_path, +ExceptionHandler::ExceptionHandler(const string &dump_path, FilterCallback filter, MinidumpCallback callback, void *callback_context, @@ -139,7 +139,7 @@ ExceptionHandler::ExceptionHandler(const std::string &dump_path, Init(dump_path, -1); } -ExceptionHandler::ExceptionHandler(const std::string &dump_path, +ExceptionHandler::ExceptionHandler(const string &dump_path, FilterCallback filter, MinidumpCallback callback, void* callback_context, @@ -158,7 +158,7 @@ ExceptionHandler::~ExceptionHandler() { UninstallHandlers(); } -void ExceptionHandler::Init(const std::string &dump_path, +void ExceptionHandler::Init(const string &dump_path, const int server_fd) { crash_handler_ = NULL; @@ -469,7 +469,7 @@ bool ExceptionHandler::DoDump(pid_t crashing_process, const void* context, } // static -bool ExceptionHandler::WriteMinidump(const std::string &dump_path, +bool ExceptionHandler::WriteMinidump(const string &dump_path, MinidumpCallback callback, void* callback_context) { ExceptionHandler eh(dump_path, NULL, callback, callback_context, false); @@ -497,7 +497,7 @@ bool ExceptionHandler::WriteMinidump() { #endif // !defined(__ARM_EABI__) } -void ExceptionHandler::AddMappingInfo(const std::string& name, +void ExceptionHandler::AddMappingInfo(const string& name, const u_int8_t identifier[sizeof(MDGUID)], uintptr_t start_address, size_t mapping_size, diff --git a/src/client/linux/handler/exception_handler.h b/src/client/linux/handler/exception_handler.h index 94766eba..4bc8ba72 100644 --- a/src/client/linux/handler/exception_handler.h +++ b/src/client/linux/handler/exception_handler.h @@ -43,6 +43,7 @@ #endif #include "client/linux/crash_generation/crash_generation_client.h" #include "client/linux/minidump_writer/minidump_writer.h" +#include "common/using_std_string.h" #include "google_breakpad/common/minidump_format.h" #include "processor/scoped_ptr.h" @@ -127,7 +128,7 @@ 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 std::string &dump_path, + ExceptionHandler(const string &dump_path, FilterCallback filter, MinidumpCallback callback, void *callback_context, bool install_handler); @@ -137,7 +138,7 @@ class ExceptionHandler { // server_fd is invalid, in-process dump generation will be // used. See the above ctor for a description of the other // parameters. - ExceptionHandler(const std::string& dump_path, + ExceptionHandler(const string& dump_path, FilterCallback filter, MinidumpCallback callback, void* callback_context, bool install_handler, @@ -146,8 +147,8 @@ class ExceptionHandler { ~ExceptionHandler(); // Get and set the minidump path. - std::string dump_path() const { return dump_path_; } - void set_dump_path(const std::string &dump_path) { + string dump_path() const { return dump_path_; } + void set_dump_path(const string &dump_path) { dump_path_ = dump_path; dump_path_c_ = dump_path_.c_str(); UpdateNextID(); @@ -163,7 +164,7 @@ class ExceptionHandler { // Convenience form of WriteMinidump which does not require an // ExceptionHandler instance. - static bool WriteMinidump(const std::string &dump_path, + static bool WriteMinidump(const string &dump_path, MinidumpCallback callback, void *callback_context); @@ -187,14 +188,14 @@ class ExceptionHandler { // Add information about a memory mapping. This can be used if // a custom library loader is used that maps things in a way // that the linux dumper can't handle by reading the maps file. - void AddMappingInfo(const std::string& name, + void AddMappingInfo(const string& name, const u_int8_t identifier[sizeof(MDGUID)], uintptr_t start_address, size_t mapping_size, size_t file_offset); private: - void Init(const std::string &dump_path, + void Init(const string &dump_path, const int server_fd); bool InstallHandlers(); void UninstallHandlers(); @@ -216,9 +217,9 @@ class ExceptionHandler { scoped_ptr crash_generation_client_; - std::string dump_path_; - std::string next_minidump_path_; - std::string next_minidump_id_; + string dump_path_; + string next_minidump_path_; + string next_minidump_id_; // Pointers to C-string representations of the above. These are set // when the above are set so we can avoid calling c_str during diff --git a/src/client/linux/handler/exception_handler_unittest.cc b/src/client/linux/handler/exception_handler_unittest.cc index 6fcf251b..f9314729 100644 --- a/src/client/linux/handler/exception_handler_unittest.cc +++ b/src/client/linux/handler/exception_handler_unittest.cc @@ -45,6 +45,7 @@ #include "common/linux/file_id.h" #include "common/linux/linux_libc_support.h" #include "common/tests/auto_tempdir.h" +#include "common/using_std_string.h" #include "third_party/lss/linux_syscall_support.h" #include "google_breakpad/processor/minidump.h" @@ -130,7 +131,7 @@ TEST(ExceptionHandlerTest, ChildCrash) { filename[len] = 0; close(fds[0]); - const std::string minidump_filename = temp_dir.path() + "/" + filename + + const string minidump_filename = temp_dir.path() + "/" + filename + ".dmp"; struct stat st; @@ -204,7 +205,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemory) { filename[len] = 0; close(fds[0]); - const std::string minidump_filename = temp_dir.path() + "/" + filename + + const string minidump_filename = temp_dir.path() + "/" + filename + ".dmp"; struct stat st; @@ -329,7 +330,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryMinBound) { filename[len] = 0; close(fds[0]); - const std::string minidump_filename = temp_dir.path() + "/" + filename + + const string minidump_filename = temp_dir.path() + "/" + filename + ".dmp"; struct stat st; @@ -454,7 +455,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryMaxBound) { filename[len] = 0; close(fds[0]); - const std::string minidump_filename = temp_dir.path() + "/" + filename + + const string minidump_filename = temp_dir.path() + "/" + filename + ".dmp"; struct stat st; @@ -555,7 +556,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryNullPointer) { filename[len] = 0; close(fds[0]); - const std::string minidump_filename = temp_dir.path() + "/" + filename + + const string minidump_filename = temp_dir.path() + "/" + filename + ".dmp"; struct stat st; @@ -767,7 +768,7 @@ TEST(ExceptionHandlerTest, ExternalDumper) { ASSERT_NE(signal_fd, -1); AutoTempDir temp_dir; - std::string templ = temp_dir.path() + "/exception-handler-unittest"; + string templ = temp_dir.path() + "/exception-handler-unittest"; ASSERT_TRUE(WriteMinidump(templ.c_str(), crashing_pid, context, kCrashContextSize)); static const char b = 0; diff --git a/src/client/linux/minidump_writer/directory_reader_unittest.cc b/src/client/linux/minidump_writer/directory_reader_unittest.cc index 3034e619..326f9e36 100644 --- a/src/client/linux/minidump_writer/directory_reader_unittest.cc +++ b/src/client/linux/minidump_writer/directory_reader_unittest.cc @@ -35,6 +35,7 @@ #include #include "client/linux/minidump_writer/directory_reader.h" +#include "common/using_std_string.h" #include "breakpad_googletest_includes.h" using namespace google_breakpad; @@ -44,7 +45,7 @@ typedef testing::Test DirectoryReaderTest; } TEST(DirectoryReaderTest, CompareResults) { - std::set dent_set; + std::set dent_set; DIR *const dir = opendir("/proc/self"); ASSERT_TRUE(dir != NULL); diff --git a/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc b/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc index 1fb26ede..e7af11d4 100644 --- a/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc +++ b/src/client/linux/minidump_writer/linux_core_dumper_unittest.cc @@ -30,11 +30,13 @@ // linux_core_dumper_unittest.cc: // Unit tests for google_breakpad::LinuxCoreDumoer. +#include + #include "breakpad_googletest_includes.h" #include "client/linux/minidump_writer/linux_core_dumper.h" #include "common/linux/tests/crash_generator.h" +#include "common/using_std_string.h" -using std::string; using namespace google_breakpad; TEST(LinuxCoreDumperTest, BuildProcPath) { 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 ef47da9f..5e2b431c 100644 --- a/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc +++ b/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc @@ -51,8 +51,8 @@ #include "common/linux/file_id.h" #include "common/linux/safe_readlink.h" #include "common/memory.h" +#include "common/using_std_string.h" -using std::string; using namespace google_breakpad; namespace { diff --git a/src/client/linux/minidump_writer/minidump_writer_unittest.cc b/src/client/linux/minidump_writer/minidump_writer_unittest.cc index 91aafed7..b751f50a 100644 --- a/src/client/linux/minidump_writer/minidump_writer_unittest.cc +++ b/src/client/linux/minidump_writer/minidump_writer_unittest.cc @@ -44,6 +44,7 @@ #include "common/linux/file_id.h" #include "common/linux/safe_readlink.h" #include "common/tests/auto_tempdir.h" +#include "common/using_std_string.h" #include "google_breakpad/processor/minidump.h" using namespace google_breakpad; @@ -74,7 +75,7 @@ TEST(MinidumpWriterTest, Setup) { memset(&context, 0, sizeof(context)); AutoTempDir temp_dir; - std::string templ = temp_dir.path() + "/minidump-writer-unittest"; + string templ = temp_dir.path() + "/minidump-writer-unittest"; // Set a non-zero tid to avoid tripping asserts. context.tid = 1; ASSERT_TRUE(WriteMinidump(templ.c_str(), child, &context, sizeof(context))); @@ -139,7 +140,7 @@ TEST(MinidumpWriterTest, MappingInfo) { context.tid = 1; AutoTempDir temp_dir; - std::string templ = temp_dir.path() + "/minidump-writer-unittest"; + string templ = temp_dir.path() + "/minidump-writer-unittest"; // Add information about the mapped memory. MappingInfo info; @@ -207,7 +208,7 @@ TEST(MinidumpWriterTest, MappingInfoContained) { // mmap a file AutoTempDir temp_dir; - std::string tempfile = temp_dir.path() + "/minidump-writer-unittest-temp"; + string tempfile = temp_dir.path() + "/minidump-writer-unittest-temp"; int fd = open(tempfile.c_str(), O_RDWR | O_CREAT, 0); ASSERT_NE(-1, fd); unlink(tempfile.c_str()); @@ -242,7 +243,7 @@ TEST(MinidumpWriterTest, MappingInfoContained) { memset(&context, 0, sizeof(context)); context.tid = 1; - std::string dumpfile = temp_dir.path() + "/minidump-writer-unittest"; + string dumpfile = temp_dir.path() + "/minidump-writer-unittest"; // Add information about the mapped memory. Report it as being larger than // it actually is. @@ -303,7 +304,7 @@ TEST(MinidumpWriterTest, DeletedBinary) { // Copy binary to a temp file. AutoTempDir temp_dir; - std::string binpath = temp_dir.path() + "/linux-dumper-unittest-helper"; + string binpath = temp_dir.path() + "/linux-dumper-unittest-helper"; char cmdline[2 * PATH_MAX]; sprintf(cmdline, "/bin/cp \"%s\" \"%s\"", helper_path.c_str(), binpath.c_str()); @@ -349,7 +350,7 @@ TEST(MinidumpWriterTest, DeletedBinary) { ExceptionHandler::CrashContext context; memset(&context, 0, sizeof(context)); - std::string templ = temp_dir.path() + "/minidump-writer-unittest"; + string templ = temp_dir.path() + "/minidump-writer-unittest"; // Set a non-zero tid to avoid tripping asserts. context.tid = 1; ASSERT_TRUE(WriteMinidump(templ.c_str(), child_pid, &context, diff --git a/src/client/linux/sender/google_crash_report_sender.cc b/src/client/linux/sender/google_crash_report_sender.cc index be897adb..0d48cbe6 100644 --- a/src/client/linux/sender/google_crash_report_sender.cc +++ b/src/client/linux/sender/google_crash_report_sender.cc @@ -32,7 +32,7 @@ #include #include -using std::string; +#include "common/using_std_string.h" DEFINE_string(crash_server, "https://clients2.google.com/cr", "The crash server to upload minidumps to."); @@ -59,7 +59,7 @@ DEFINE_string(proxy_userpasswd, "", bool CheckForRequiredFlagsOrDie() { - std::string error_text = ""; + string error_text = ""; if (FLAGS_product_name.empty()) { error_text.append("\nProduct name must be specified."); } diff --git a/src/common/byte_cursor.h b/src/common/byte_cursor.h index 24ffce75..accd54e0 100644 --- a/src/common/byte_cursor.h +++ b/src/common/byte_cursor.h @@ -45,6 +45,8 @@ #include #include +#include "common/using_std_string.h" + namespace google_breakpad { // A buffer holding a series of bytes. @@ -164,7 +166,7 @@ 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(std::string *str) { + ByteCursor &CString(string *str) { const uint8_t *end = static_cast(memchr(here_, '\0', Available())); if (end) { @@ -191,7 +193,7 @@ class ByteCursor { // // - Otherwise, set *STR to a copy of those LIMIT bytes, and advance the // cursor by LIMIT bytes. - ByteCursor &CString(std::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)); diff --git a/src/common/byte_cursor_unittest.cc b/src/common/byte_cursor_unittest.cc index 0ab4770a..06bfd89d 100644 --- a/src/common/byte_cursor_unittest.cc +++ b/src/common/byte_cursor_unittest.cc @@ -36,12 +36,12 @@ #include -#include "common/byte_cursor.h" #include "breakpad_googletest_includes.h" +#include "common/byte_cursor.h" +#include "common/using_std_string.h" using google_breakpad::ByteBuffer; using google_breakpad::ByteCursor; -using std::string; TEST(Buffer, SizeOfNothing) { uint8_t data[1]; diff --git a/src/common/dwarf/bytereader_unittest.cc b/src/common/dwarf/bytereader_unittest.cc index d839dbe7..4311ab6a 100644 --- a/src/common/dwarf/bytereader_unittest.cc +++ b/src/common/dwarf/bytereader_unittest.cc @@ -37,6 +37,7 @@ #include "common/dwarf/bytereader.h" #include "common/dwarf/bytereader-inl.h" #include "common/dwarf/cfi_assembler.h" +#include "common/using_std_string.h" using dwarf2reader::ByteReader; using dwarf2reader::DwarfPointerEncoding; @@ -47,7 +48,6 @@ using google_breakpad::test_assembler::Label; using google_breakpad::test_assembler::kBigEndian; using google_breakpad::test_assembler::kLittleEndian; using google_breakpad::test_assembler::Section; -using std::string; using testing::Test; struct ReaderFixture { diff --git a/src/common/dwarf/cfi_assembler.h b/src/common/dwarf/cfi_assembler.h index 3f305030..00ff6f06 100644 --- a/src/common/dwarf/cfi_assembler.h +++ b/src/common/dwarf/cfi_assembler.h @@ -41,6 +41,7 @@ #include "common/dwarf/dwarf2enums.h" #include "common/test_assembler.h" +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" namespace google_breakpad { @@ -49,7 +50,6 @@ using dwarf2reader::DwarfPointerEncoding; using google_breakpad::test_assembler::Endianness; using google_breakpad::test_assembler::Label; using google_breakpad::test_assembler::Section; -using std::string; class CFISection: public Section { public: diff --git a/src/common/dwarf/dwarf2diehandler.cc b/src/common/dwarf/dwarf2diehandler.cc index 16399547..c741d69f 100644 --- a/src/common/dwarf/dwarf2diehandler.cc +++ b/src/common/dwarf/dwarf2diehandler.cc @@ -31,10 +31,13 @@ // dwarf2diehandler.cc: Implement the dwarf2reader::DieDispatcher class. // See dwarf2diehandler.h for details. -#include "common/dwarf/dwarf2diehandler.h" - #include +#include + +#include "common/dwarf/dwarf2diehandler.h" +#include "common/using_std_string.h" + namespace dwarf2reader { DIEDispatcher::~DIEDispatcher() { @@ -176,7 +179,7 @@ void DIEDispatcher::ProcessAttributeBuffer(uint64 offset, void DIEDispatcher::ProcessAttributeString(uint64 offset, enum DwarfAttribute attr, enum DwarfForm form, - const std::string& data) { + const string& data) { HandlerStack ¤t = die_handlers_.top(); // This had better be an attribute of the DIE we were meant to handle. assert(offset == current.offset_); diff --git a/src/common/dwarf/dwarf2diehandler.h b/src/common/dwarf/dwarf2diehandler.h index 5d899bf8..12b8d3a3 100644 --- a/src/common/dwarf/dwarf2diehandler.h +++ b/src/common/dwarf/dwarf2diehandler.h @@ -157,10 +157,12 @@ #define COMMON_DWARF_DWARF2DIEHANDLER_H__ #include +#include #include "common/dwarf/types.h" #include "common/dwarf/dwarf2enums.h" #include "common/dwarf/dwarf2reader.h" +#include "common/using_std_string.h" namespace dwarf2reader { @@ -208,7 +210,7 @@ class DIEHandler { uint64 len) { } virtual void ProcessAttributeString(enum DwarfAttribute attr, enum DwarfForm form, - const std::string& data) { } + const string& data) { } virtual void ProcessAttributeSignature(enum DwarfAttribute attr, enum DwarfForm form, uint64 signture) { } @@ -316,7 +318,7 @@ class DIEDispatcher: public Dwarf2Handler { void ProcessAttributeString(uint64 offset, enum DwarfAttribute attr, enum DwarfForm form, - const std::string &data); + const string &data); void ProcessAttributeSignature(uint64 offset, enum DwarfAttribute attr, enum DwarfForm form, diff --git a/src/common/dwarf/dwarf2diehandler_unittest.cc b/src/common/dwarf/dwarf2diehandler_unittest.cc index 186b951c..6a731196 100644 --- a/src/common/dwarf/dwarf2diehandler_unittest.cc +++ b/src/common/dwarf/dwarf2diehandler_unittest.cc @@ -38,9 +38,9 @@ #include "breakpad_googletest_includes.h" #include "common/dwarf/dwarf2diehandler.h" +#include "common/using_std_string.h" using std::make_pair; -using std::string; using ::testing::_; using ::testing::ContainerEq; diff --git a/src/common/dwarf/dwarf2reader.cc b/src/common/dwarf/dwarf2reader.cc index 43566467..7c1a29dd 100644 --- a/src/common/dwarf/dwarf2reader.cc +++ b/src/common/dwarf/dwarf2reader.cc @@ -41,11 +41,13 @@ #include #include #include +#include #include #include "common/dwarf/bytereader-inl.h" #include "common/dwarf/bytereader.h" #include "common/dwarf/line_state_machine.h" +#include "common/using_std_string.h" namespace dwarf2reader { @@ -1004,7 +1006,7 @@ 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 std::string &expression) + explicit ExpressionRule(const string &expression) : expression_(expression) { } ~ExpressionRule() { } bool Handle(Handler *handler, uint64 address, int reg) const { @@ -1018,13 +1020,13 @@ class CallFrameInfo::ExpressionRule: public CallFrameInfo::Rule { } Rule *Copy() const { return new ExpressionRule(*this); } private: - std::string expression_; + string expression_; }; // Rule: EXPRESSION evaluates to the address at which the register is saved. class CallFrameInfo::ValExpressionRule: public CallFrameInfo::Rule { public: - explicit ValExpressionRule(const std::string &expression) + explicit ValExpressionRule(const string &expression) : expression_(expression) { } ~ValExpressionRule() { } bool Handle(Handler *handler, uint64 address, int reg) const { @@ -1039,7 +1041,7 @@ class CallFrameInfo::ValExpressionRule: public CallFrameInfo::Rule { } Rule *Copy() const { return new ValExpressionRule(*this); } private: - std::string expression_; + string expression_; }; // A map from register numbers to rules. @@ -1220,7 +1222,7 @@ class CallFrameInfo::State { unsigned register_number; // A register number. uint64 offset; // An offset or address. long signed_offset; // A signed offset. - std::string expression; // A DWARF expression. + string expression; // A DWARF expression. }; // Parse CFI instruction operands from STATE's instruction stream as @@ -1407,7 +1409,7 @@ bool CallFrameInfo::State::ParseOperands(const char *format, if (len > bytes_left || expression_length > bytes_left - len) return ReportIncomplete(); cursor_ += len; - operands->expression = std::string(cursor_, expression_length); + operands->expression = string(cursor_, expression_length); cursor_ += expression_length; break; } @@ -1872,7 +1874,7 @@ bool CallFrameInfo::ReadCIEFields(CIE *cie) { memchr(augmentation_start, '\0', cie->end - augmentation_start); if (! augmentation_end) return ReportIncomplete(cie); cursor = static_cast(augmentation_end); - cie->augmentation = std::string(augmentation_start, + cie->augmentation = string(augmentation_start, cursor - augmentation_start); // Skip the terminating '\0'. cursor++; @@ -2260,7 +2262,7 @@ void CallFrameInfo::Reporter::UnrecognizedVersion(uint64 offset, int version) { } void CallFrameInfo::Reporter::UnrecognizedAugmentation(uint64 offset, - const std::string &aug) { + const string &aug) { fprintf(stderr, "%s: CFI frame description entry at offset 0x%llx in '%s':" " CIE specifies unrecognized augmentation: '%s'\n", diff --git a/src/common/dwarf/dwarf2reader.h b/src/common/dwarf/dwarf2reader.h index cd61fb55..ecf4eb2a 100644 --- a/src/common/dwarf/dwarf2reader.h +++ b/src/common/dwarf/dwarf2reader.h @@ -49,6 +49,7 @@ #include "common/dwarf/bytereader.h" #include "common/dwarf/dwarf2enums.h" #include "common/dwarf/types.h" +#include "common/using_std_string.h" namespace dwarf2reader { struct LineStateMachine; @@ -57,7 +58,7 @@ class LineInfoHandler; // 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; typedef std::list > AttributeList; typedef AttributeList::iterator AttributeIterator; @@ -156,7 +157,7 @@ class LineInfoHandler { // Called when we define a directory. NAME is the directory name, // DIR_NUM is the directory number - virtual void DefineDir(const std::string& name, uint32 dir_num) { } + virtual void DefineDir(const string& name, uint32 dir_num) { } // Called when we define a filename. NAME is the filename, FILE_NUM // is the file number which is -1 if the file index is the next @@ -165,7 +166,7 @@ class LineInfoHandler { // directory index for the directory name of this file, MOD_TIME is // the modification time of the file, and LENGTH is the length of // the file - virtual void DefineFile(const std::string& name, int32 file_num, + virtual void DefineFile(const string& name, int32 file_num, uint32 dir_num, uint64 mod_time, uint64 length) { } @@ -391,7 +392,7 @@ class Dwarf2Handler { virtual void ProcessAttributeString(uint64 offset, enum DwarfAttribute attr, enum DwarfForm form, - const std::string& data) { } + const string& data) { } // Called when we have an attribute whose value is the 64-bit signature // of a type unit in the .debug_types section. OFFSET is the offset of @@ -699,7 +700,7 @@ class CallFrameInfo { // A common information entry (CIE). struct CIE: public Entry { uint8 version; // CFI data version number - std::string augmentation; // vendor format extension markers + string augmentation; // vendor format extension markers uint64 code_alignment_factor; // scale for code address adjustments int data_alignment_factor; // scale for stack pointer adjustments unsigned return_address_register; // which register holds the return addr @@ -833,7 +834,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 address, uint64 length, - uint8 version, const std::string &augmentation, + uint8 version, const string &augmentation, unsigned return_address) = 0; // When the Entry function returns true, the parser calls these @@ -882,13 +883,13 @@ class CallFrameInfo::Handler { // At ADDRESS, the DWARF expression EXPRESSION yields the address at // which REG was saved. virtual bool ExpressionRule(uint64 address, int reg, - const std::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 address, int reg, - const std::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 @@ -965,8 +966,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 std::string &filename, - const std::string §ion = ".debug_frame") + Reporter(const string &filename, + const string §ion = ".debug_frame") : filename_(filename), section_(section) { } virtual ~Reporter() { } @@ -998,7 +999,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 offset, - const std::string &augmentation); + const string &augmentation); // The pointer encoding ENCODING, specified by the CIE at OFFSET, is not // a valid encoding. @@ -1039,10 +1040,10 @@ class CallFrameInfo::Reporter { protected: // The name of the file whose CFI we're reading. - std::string filename_; + string filename_; // The name of the CFI section in that file. - std::string section_; + string section_; }; } // namespace dwarf2reader diff --git a/src/common/dwarf/dwarf2reader_cfi_unittest.cc b/src/common/dwarf/dwarf2reader_cfi_unittest.cc index 271d1b6a..7b794361 100644 --- a/src/common/dwarf/dwarf2reader_cfi_unittest.cc +++ b/src/common/dwarf/dwarf2reader_cfi_unittest.cc @@ -62,6 +62,7 @@ extern "C" { #include "common/dwarf/bytereader-inl.h" #include "common/dwarf/cfi_assembler.h" #include "common/dwarf/dwarf2reader.h" +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" using google_breakpad::CFISection; @@ -76,7 +77,6 @@ using dwarf2reader::ENDIANNESS_LITTLE; using dwarf2reader::ByteReader; using dwarf2reader::CallFrameInfo; -using std::string; using std::vector; using testing::InSequence; using testing::Return; diff --git a/src/common/dwarf/dwarf2reader_die_unittest.cc b/src/common/dwarf/dwarf2reader_die_unittest.cc index e76fcae7..96e95b7d 100644 --- a/src/common/dwarf/dwarf2reader_die_unittest.cc +++ b/src/common/dwarf/dwarf2reader_die_unittest.cc @@ -41,6 +41,7 @@ #include "common/dwarf/bytereader-inl.h" #include "common/dwarf/dwarf2reader_test_common.h" #include "common/dwarf/dwarf2reader.h" +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" using google_breakpad::test_assembler::Endianness; @@ -61,7 +62,6 @@ using dwarf2reader::ENDIANNESS_BIG; using dwarf2reader::ENDIANNESS_LITTLE; using dwarf2reader::SectionMap; -using std::string; using std::vector; using testing::InSequence; using testing::Pointee; @@ -98,7 +98,7 @@ class MockDwarf2Handler: public Dwarf2Handler { MOCK_METHOD4(ProcessAttributeString, void(uint64 offset, enum DwarfAttribute attr, enum DwarfForm form, - const std::string& data)); + const string& data)); MOCK_METHOD4(ProcessAttributeSignature, void(uint64 offset, DwarfAttribute attr, enum DwarfForm form, diff --git a/src/common/dwarf/functioninfo.cc b/src/common/dwarf/functioninfo.cc index 4a080458..c0456224 100644 --- a/src/common/dwarf/functioninfo.cc +++ b/src/common/dwarf/functioninfo.cc @@ -39,14 +39,13 @@ #include #include "common/dwarf/functioninfo.h" - #include "common/dwarf/bytereader.h" - +#include "common/using_std_string.h" namespace dwarf2reader { CULineInfoHandler::CULineInfoHandler(std::vector* files, - std::vector* dirs, + std::vector* dirs, LineMap* linemap):linemap_(linemap), files_(files), dirs_(dirs) { @@ -61,13 +60,13 @@ CULineInfoHandler::CULineInfoHandler(std::vector* files, files->push_back(s); } -void CULineInfoHandler::DefineDir(const std::string& name, uint32 dir_num) { +void CULineInfoHandler::DefineDir(const string& name, uint32 dir_num) { // These should never come out of order, actually assert(dir_num == dirs_->size()); dirs_->push_back(name); } -void CULineInfoHandler::DefineFile(const std::string& name, +void CULineInfoHandler::DefineFile(const string& name, int32 file_num, uint32 dir_num, uint64 mod_time, uint64 length) { assert(dir_num >= 0); @@ -75,7 +74,7 @@ void CULineInfoHandler::DefineFile(const std::string& name, // These should never come out of order, actually. if (file_num == (int32)files_->size() || file_num == -1) { - std::string dir = dirs_->at(dir_num); + string dir = dirs_->at(dir_num); SourceFileInfo s; s.lowpc = ULLONG_MAX; @@ -149,7 +148,7 @@ bool CUFunctionInfoHandler::StartDIE(uint64 offset, enum DwarfTag tag, void CUFunctionInfoHandler::ProcessAttributeString(uint64 offset, enum DwarfAttribute attr, enum DwarfForm form, - const std::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/functioninfo.h b/src/common/dwarf/functioninfo.h index 85a31ff4..f8706369 100644 --- a/src/common/dwarf/functioninfo.h +++ b/src/common/dwarf/functioninfo.h @@ -40,17 +40,18 @@ #include #include "common/dwarf/dwarf2reader.h" +#include "common/using_std_string.h" namespace dwarf2reader { struct FunctionInfo { // Name of the function - std::string name; + string name; // Mangled name of the function - std::string mangled_name; + string mangled_name; // File containing this function - std::string file; + string file; // Line number for start of function. uint32 line; // Beginning address for this function @@ -61,13 +62,13 @@ struct FunctionInfo { struct SourceFileInfo { // Name of the source file name - std::string name; + string name; // Low address of source file name uint64 lowpc; }; typedef std::map FunctionMap; -typedef std::map > LineMap; +typedef std::map > LineMap; // This class is a basic line info handler that fills in the dirs, // file, and linemap passed into it with the data produced from the @@ -77,17 +78,17 @@ class CULineInfoHandler: public LineInfoHandler { // CULineInfoHandler(std::vector* files, - std::vector* dirs, + std::vector* dirs, LineMap* linemap); virtual ~CULineInfoHandler() { } // Called when we define a directory. We just place NAME into dirs_ // at position DIR_NUM. - virtual void DefineDir(const std::string& name, uint32 dir_num); + virtual void DefineDir(const string& name, uint32 dir_num); // Called when we define a filename. We just place // concat(dirs_[DIR_NUM], NAME) into files_ at position FILE_NUM. - virtual void DefineFile(const std::string& name, int32 file_num, + virtual void DefineFile(const string& name, int32 file_num, uint32 dir_num, uint64 mod_time, uint64 length); @@ -103,13 +104,13 @@ class CULineInfoHandler: public LineInfoHandler { private: LineMap* linemap_; std::vector* files_; - std::vector* dirs_; + std::vector* dirs_; }; class CUFunctionInfoHandler: public Dwarf2Handler { public: CUFunctionInfoHandler(std::vector* files, - std::vector* dirs, + std::vector* dirs, LineMap* linemap, FunctionMap* offset_to_funcinfo, FunctionMap* address_to_funcinfo, @@ -163,7 +164,7 @@ class CUFunctionInfoHandler: public Dwarf2Handler { virtual void ProcessAttributeString(uint64 offset, enum DwarfAttribute attr, enum DwarfForm form, - const std::string& data); + const string& data); // Called when finished processing the DIE at OFFSET. // Because DWARF2/3 specifies a tree of DIEs, you may get starts @@ -173,7 +174,7 @@ class CUFunctionInfoHandler: public Dwarf2Handler { private: std::vector* files_; - std::vector* dirs_; + std::vector* dirs_; LineMap* linemap_; FunctionMap* offset_to_funcinfo_; FunctionMap* address_to_funcinfo_; diff --git a/src/common/dwarf_cfi_to_module.h b/src/common/dwarf_cfi_to_module.h index d29a796c..7db552a6 100644 --- a/src/common/dwarf_cfi_to_module.h +++ b/src/common/dwarf_cfi_to_module.h @@ -48,13 +48,13 @@ #include "common/module.h" #include "common/dwarf/dwarf2reader.h" +#include "common/using_std_string.h" namespace google_breakpad { using dwarf2reader::CallFrameInfo; using google_breakpad::Module; using std::set; -using std::string; using std::vector; // A class that accepts parsed call frame information from the DWARF diff --git a/src/common/dwarf_cfi_to_module_unittest.cc b/src/common/dwarf_cfi_to_module_unittest.cc index 3d129490..bf3cf9ab 100644 --- a/src/common/dwarf_cfi_to_module_unittest.cc +++ b/src/common/dwarf_cfi_to_module_unittest.cc @@ -36,8 +36,8 @@ #include "breakpad_googletest_includes.h" #include "common/dwarf_cfi_to_module.h" +#include "common/using_std_string.h" -using std::string; using std::vector; using google_breakpad::Module; diff --git a/src/common/dwarf_cu_to_module.h b/src/common/dwarf_cu_to_module.h index 9ab86a1d..ac62846e 100644 --- a/src/common/dwarf_cu_to_module.h +++ b/src/common/dwarf_cu_to_module.h @@ -46,6 +46,7 @@ #include "common/dwarf/bytereader.h" #include "common/dwarf/dwarf2diehandler.h" #include "common/dwarf/dwarf2reader.h" +#include "common/using_std_string.h" namespace google_breakpad { diff --git a/src/common/dwarf_cu_to_module_unittest.cc b/src/common/dwarf_cu_to_module_unittest.cc index 03b0954e..94259b61 100644 --- a/src/common/dwarf_cu_to_module_unittest.cc +++ b/src/common/dwarf_cu_to_module_unittest.cc @@ -37,9 +37,9 @@ #include "breakpad_googletest_includes.h" #include "common/dwarf_cu_to_module.h" +#include "common/using_std_string.h" using std::make_pair; -using std::string; using std::vector; using dwarf2reader::AttributeList; diff --git a/src/common/dwarf_line_to_module.cc b/src/common/dwarf_line_to_module.cc index d987370b..962848d1 100644 --- a/src/common/dwarf_line_to_module.cc +++ b/src/common/dwarf_line_to_module.cc @@ -32,23 +32,26 @@ // dwarf_line_to_module.cc: Implementation of DwarfLineToModule class. // See dwarf_line_to_module.h for details. -#include "common/dwarf_line_to_module.h" - #include +#include + +#include "common/dwarf_line_to_module.h" +#include "common/using_std_string.h" + // Trying to support Windows paths in a reasonable way adds a lot of // variations to test; it would be better to just put off dealing with // 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 std::string &path) { +static bool PathIsAbsolute(const string &path) { return (path.size() >= 1 && path[0] == '/'); } // 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 std::string ExpandPath(const std::string &path, - const std::string &base) { +static string ExpandPath(const string &path, + const string &base) { if (PathIsAbsolute(path)) return path; return base + "/" + path; @@ -56,14 +59,14 @@ static std::string ExpandPath(const std::string &path, namespace google_breakpad { -void DwarfLineToModule::DefineDir(const std::string &name, uint32 dir_num) { +void DwarfLineToModule::DefineDir(const string &name, uint32 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] = name; } -void DwarfLineToModule::DefineFile(const std::string &name, int32 file_num, +void DwarfLineToModule::DefineFile(const string &name, int32 file_num, uint32 dir_num, uint64 mod_time, uint64 length) { if (file_num == -1) @@ -71,7 +74,7 @@ void DwarfLineToModule::DefineFile(const std::string &name, int32 file_num, else if (file_num > highest_file_number_) highest_file_number_ = file_num; - std::string full_name; + string full_name; if (dir_num != 0) { DirectoryTable::const_iterator directory_it = directories_.find(dir_num); if (directory_it != directories_.end()) { diff --git a/src/common/dwarf_line_to_module.h b/src/common/dwarf_line_to_module.h index 49b3eb35..9382e40d 100644 --- a/src/common/dwarf_line_to_module.h +++ b/src/common/dwarf_line_to_module.h @@ -38,8 +38,11 @@ #ifndef COMMON_LINUX_DWARF_LINE_TO_MODULE_H #define COMMON_LINUX_DWARF_LINE_TO_MODULE_H +#include + #include "common/module.h" #include "common/dwarf/dwarf2reader.h" +#include "common/using_std_string.h" namespace google_breakpad { @@ -127,8 +130,8 @@ class DwarfLineToModule: public dwarf2reader::LineInfoHandler { ~DwarfLineToModule() { } - void DefineDir(const std::string &name, uint32 dir_num); - void DefineFile(const std::string &name, int32 file_num, + void DefineDir(const string &name, uint32 dir_num); + void DefineFile(const string &name, int32 file_num, uint32 dir_num, uint64 mod_time, uint64 length); void AddLine(uint64 address, uint64 length, @@ -136,7 +139,7 @@ class DwarfLineToModule: public dwarf2reader::LineInfoHandler { private: - typedef std::map DirectoryTable; + typedef std::map DirectoryTable; typedef std::map FileTable; // The module we're contributing debugging info to. Owned by our diff --git a/src/common/language.h b/src/common/language.h index 03bdf7f0..4811e7f0 100644 --- a/src/common/language.h +++ b/src/common/language.h @@ -40,9 +40,9 @@ #include -namespace google_breakpad { +#include "common/using_std_string.h" -using std::string; +namespace google_breakpad { // An abstract base class for language-specific operations. We choose // an instance of a subclass of this when we find the CU's language. diff --git a/src/common/linux/dump_symbols.cc b/src/common/linux/dump_symbols.cc index f02503ac..019a3a6c 100644 --- a/src/common/linux/dump_symbols.cc +++ b/src/common/linux/dump_symbols.cc @@ -62,6 +62,7 @@ #include "common/module.h" #include "common/stabs_reader.h" #include "common/stabs_to_module.h" +#include "common/using_std_string.h" // This namespace contains helper functions. namespace { @@ -235,7 +236,7 @@ class DumperLineToModule: public DwarfCUToModule::LineToModuleFunctor { dwarf2reader::ByteReader *byte_reader_; }; -static bool LoadDwarf(const std::string &dwarf_filename, +static bool LoadDwarf(const string &dwarf_filename, const ElfW(Ehdr) *elf_header, const bool big_endian, Module *module) { @@ -253,8 +254,8 @@ static bool LoadDwarf(const std::string &dwarf_filename, const ElfW(Shdr) *section_names = sections + elf_header->e_shstrndx; for (int i = 0; i < num_sections; i++) { const ElfW(Shdr) *section = §ions[i]; - std::string name = reinterpret_cast(section_names->sh_offset + - section->sh_name); + string name = reinterpret_cast(section_names->sh_offset + + section->sh_name); const char *contents = reinterpret_cast(section->sh_offset); uint64 length = section->sh_size; file_context.section_map[name] = std::make_pair(contents, length); @@ -292,7 +293,7 @@ static bool LoadDwarf(const std::string &dwarf_filename, // success, or false if we don't recognize HEADER's machine // architecture. static bool DwarfCFIRegisterNames(const ElfW(Ehdr) *elf_header, - std::vector *register_names) { + std::vector *register_names) { switch (elf_header->e_machine) { case EM_386: *register_names = DwarfCFIToModule::RegisterNames::I386(); @@ -308,7 +309,7 @@ static bool DwarfCFIRegisterNames(const ElfW(Ehdr) *elf_header, } } -static bool LoadDwarfCFI(const std::string &dwarf_filename, +static bool LoadDwarfCFI(const string &dwarf_filename, const ElfW(Ehdr) *elf_header, const char *section_name, const ElfW(Shdr) *section, @@ -319,7 +320,7 @@ static bool LoadDwarfCFI(const std::string &dwarf_filename, Module *module) { // Find the appropriate set of register names for this file's // architecture. - std::vector register_names; + std::vector register_names; if (!DwarfCFIRegisterNames(elf_header, ®ister_names)) { fprintf(stderr, "%s: unrecognized ELF machine architecture '%d';" " cannot convert DWARF call frame information\n", @@ -367,7 +368,7 @@ static bool LoadDwarfCFI(const std::string &dwarf_filename, return true; } -bool LoadELF(const std::string &obj_file, MmapWrapper* map_wrapper, +bool LoadELF(const string &obj_file, MmapWrapper* map_wrapper, ElfW(Ehdr) **elf_header) { int obj_fd = open(obj_file.c_str(), O_RDONLY); if (obj_fd < 0) { @@ -416,9 +417,9 @@ bool ElfEndianness(const ElfW(Ehdr) *elf_header, bool *big_endian) { // Read the .gnu_debuglink and get the debug file name. If anything goes // wrong, return an empty string. -static std::string ReadDebugLink(const ElfW(Shdr) *debuglink_section, - const std::string &obj_file, - const std::string &debug_dir) { +static string ReadDebugLink(const ElfW(Shdr) *debuglink_section, + const string &obj_file, + const string &debug_dir) { char *debuglink = reinterpret_cast(debuglink_section->sh_offset); size_t debuglink_len = strlen(debuglink) + 5; // '\0' + CRC32. debuglink_len = 4 * ((debuglink_len + 3) / 4); // Round to nearest 4 bytes. @@ -430,7 +431,7 @@ static std::string ReadDebugLink(const ElfW(Shdr) *debuglink_section, return ""; } - std::string debuglink_path = debug_dir + "/" + debuglink; + string debuglink_path = debug_dir + "/" + debuglink; int debuglink_fd = open(debuglink_path.c_str(), O_RDONLY); if (debuglink_fd < 0) { fprintf(stderr, "Failed to open debug ELF file '%s' for '%s': %s\n", @@ -453,13 +454,13 @@ static std::string ReadDebugLink(const ElfW(Shdr) *debuglink_section, // class LoadSymbolsInfo { public: - explicit LoadSymbolsInfo(const std::string &dbg_dir) : + explicit LoadSymbolsInfo(const string &dbg_dir) : debug_dir_(dbg_dir), has_loading_addr_(false) {} // Keeps track of which sections have been loaded so we don't accidentally // load it twice from two different files. - void LoadedSection(const std::string §ion) { + void LoadedSection(const string §ion) { if (loaded_sections_.count(section) == 0) { loaded_sections_.insert(section); } else { @@ -470,7 +471,7 @@ class LoadSymbolsInfo { // We expect the ELF file and linked debug file to have the same preferred // loading address. - void set_loading_addr(ElfW(Addr) addr, const std::string &filename) { + void set_loading_addr(ElfW(Addr) addr, const string &filename) { if (!has_loading_addr_) { loading_addr_ = addr; loaded_file_ = filename; @@ -487,35 +488,35 @@ class LoadSymbolsInfo { } // Setters and getters - const std::string &debug_dir() const { + const string &debug_dir() const { return debug_dir_; } - std::string debuglink_file() const { + string debuglink_file() const { return debuglink_file_; } - void set_debuglink_file(std::string file) { + void set_debuglink_file(string file) { debuglink_file_ = file; } private: - const std::string &debug_dir_; // Directory with the debug ELF file. + const string &debug_dir_; // Directory with the debug ELF file. - std::string debuglink_file_; // Full path to the debug ELF file. + string debuglink_file_; // Full path to the debug ELF file. bool has_loading_addr_; // Indicate if LOADING_ADDR_ is valid. ElfW(Addr) loading_addr_; // Saves the preferred loading address from the // first call to LoadSymbols(). - std::string loaded_file_; // Name of the file loaded from the first call to + string loaded_file_; // Name of the file loaded from the first call to // LoadSymbols(). - std::set loaded_sections_; // Tracks the Loaded ELF sections + std::set loaded_sections_; // Tracks the Loaded ELF sections // between calls to LoadSymbols(). }; -static bool LoadSymbols(const std::string &obj_file, +static bool LoadSymbols(const string &obj_file, const bool big_endian, ElfW(Ehdr) *elf_header, const bool read_gnu_debug_link, @@ -615,7 +616,7 @@ static bool LoadSymbols(const std::string &obj_file, elf_header->e_shnum); if (gnu_debuglink_section) { if (!info->debug_dir().empty()) { - std::string debuglink_file = + string debuglink_file = ReadDebugLink(gnu_debuglink_section, obj_file, info->debug_dir()); info->set_debuglink_file(debuglink_file); } else { @@ -690,13 +691,13 @@ const char *ElfArchitecture(const ElfW(Ehdr) *elf_header) { // Format the Elf file identifier in IDENTIFIER as a UUID with the // dashes removed. -std::string FormatIdentifier(unsigned char identifier[16]) { +string FormatIdentifier(unsigned char identifier[16]) { char identifier_str[40]; google_breakpad::FileID::ConvertIdentifierToString( identifier, identifier_str, sizeof(identifier_str)); - std::string id_no_dash; + string id_no_dash; for (int i = 0; identifier_str[i] != '\0'; ++i) if (identifier_str[i] != '-') id_no_dash += identifier_str[i]; @@ -710,10 +711,10 @@ std::string FormatIdentifier(unsigned char identifier[16]) { // Return the non-directory portion of FILENAME: the portion after the // last slash, or the whole filename if there are no slashes. -std::string BaseFileName(const std::string &filename) { +string BaseFileName(const string &filename) { // Lots of copies! basename's behavior is less than ideal. char *c_filename = strdup(filename.c_str()); - std::string base = basename(c_filename); + string base = basename(c_filename); free(c_filename); return base; } @@ -726,8 +727,8 @@ namespace google_breakpad { // Ideally obj_file would be const, but internally this code does write // to some ELF header fields to make its work simpler. bool WriteSymbolFileInternal(uint8_t* obj_file, - const std::string &obj_filename, - const std::string &debug_dir, + const string &obj_filename, + const string &debug_dir, bool cfi, std::ostream &sym_stream) { ElfW(Ehdr) *elf_header = reinterpret_cast(obj_file); @@ -757,15 +758,15 @@ bool WriteSymbolFileInternal(uint8_t* obj_file, if (!ElfEndianness(elf_header, &big_endian)) return false; - std::string name = BaseFileName(obj_filename); - std::string os = "Linux"; - std::string id = FormatIdentifier(identifier); + string name = BaseFileName(obj_filename); + string os = "Linux"; + string id = FormatIdentifier(identifier); LoadSymbolsInfo info(debug_dir); Module module(name, os, architecture, id); if (!LoadSymbols(obj_filename, big_endian, elf_header, !debug_dir.empty(), &info, &module)) { - const std::string debuglink_file = info.debuglink_file(); + const string debuglink_file = info.debuglink_file(); if (debuglink_file.empty()) return false; @@ -810,8 +811,8 @@ bool WriteSymbolFileInternal(uint8_t* obj_file, return true; } -bool WriteSymbolFile(const std::string &obj_file, - const std::string &debug_dir, +bool WriteSymbolFile(const string &obj_file, + const string &debug_dir, bool cfi, std::ostream &sym_stream) { MmapWrapper map_wrapper; diff --git a/src/common/linux/dump_symbols.h b/src/common/linux/dump_symbols.h index 9bf54d37..7b192817 100644 --- a/src/common/linux/dump_symbols.h +++ b/src/common/linux/dump_symbols.h @@ -38,6 +38,8 @@ #include #include +#include "common/using_std_string.h" + namespace google_breakpad { // Find all the debugging information in OBJ_FILE, an ELF executable @@ -46,8 +48,8 @@ namespace google_breakpad { // If OBJ_FILE has been stripped but contains a .gnu_debuglink section, // then look for the debug file in DEBUG_DIR. // If CFI is set to false, then omit the CFI section. -bool WriteSymbolFile(const std::string &obj_file, - const std::string &debug_dir, +bool WriteSymbolFile(const string &obj_file, + const string &debug_dir, bool cfi, std::ostream &sym_stream); diff --git a/src/common/linux/dump_symbols_unittest.cc b/src/common/linux/dump_symbols_unittest.cc index c6d4d2d3..2c4f0e65 100644 --- a/src/common/linux/dump_symbols_unittest.cc +++ b/src/common/linux/dump_symbols_unittest.cc @@ -42,11 +42,12 @@ #include "breakpad_googletest_includes.h" #include "common/linux/synth_elf.h" +#include "common/using_std_string.h" namespace google_breakpad { bool WriteSymbolFileInternal(uint8_t* obj_file, - const std::string &obj_filename, - const std::string &debug_dir, + const string &obj_filename, + const string &debug_dir, bool cfi, std::ostream &sym_stream); } @@ -57,7 +58,6 @@ using google_breakpad::synth_elf::SymbolTable; using google_breakpad::test_assembler::kLittleEndian; using google_breakpad::test_assembler::Section; using google_breakpad::WriteSymbolFileInternal; -using std::string; using std::stringstream; using std::vector; using ::testing::Test; diff --git a/src/common/linux/elf_core_dump_unittest.cc b/src/common/linux/elf_core_dump_unittest.cc index 11920f25..b799d3f0 100644 --- a/src/common/linux/elf_core_dump_unittest.cc +++ b/src/common/linux/elf_core_dump_unittest.cc @@ -39,6 +39,7 @@ #include "common/linux/memory_mapped_file.h" #include "common/tests/file_utils.h" #include "common/linux/tests/crash_generator.h" +#include "common/using_std_string.h" using google_breakpad::AutoTempDir; using google_breakpad::CrashGenerator; @@ -47,7 +48,6 @@ using google_breakpad::MemoryMappedFile; using google_breakpad::MemoryRange; using google_breakpad::WriteFile; using std::set; -using std::string; TEST(ElfCoreDumpTest, DefaultConstructor) { ElfCoreDump core; diff --git a/src/common/linux/elf_symbols_to_module_unittest.cc b/src/common/linux/elf_symbols_to_module_unittest.cc index a3b874f9..8984449a 100644 --- a/src/common/linux/elf_symbols_to_module_unittest.cc +++ b/src/common/linux/elf_symbols_to_module_unittest.cc @@ -42,6 +42,7 @@ #include "common/linux/synth_elf.h" #include "common/module.h" #include "common/test_assembler.h" +#include "common/using_std_string.h" using google_breakpad::Module; using google_breakpad::synth_elf::StringTable; @@ -52,7 +53,6 @@ using google_breakpad::test_assembler::Label; using google_breakpad::test_assembler::Section; using ::testing::Test; using ::testing::TestWithParam; -using std::string; using std::vector; class ELFSymbolsToModuleTestFixture { diff --git a/src/common/linux/file_id_unittest.cc b/src/common/linux/file_id_unittest.cc index 94bc80e4..4c803152 100644 --- a/src/common/linux/file_id_unittest.cc +++ b/src/common/linux/file_id_unittest.cc @@ -32,11 +32,14 @@ #include #include +#include + #include "common/linux/file_id.h" #include "common/linux/safe_readlink.h" #include "common/linux/synth_elf.h" #include "common/test_assembler.h" #include "common/tests/auto_tempdir.h" +#include "common/using_std_string.h" #include "breakpad_googletest_includes.h" using namespace google_breakpad; @@ -67,7 +70,7 @@ TEST(FileIDStripTest, StripSelf) { // copy our binary to a temp file, and strip it AutoTempDir temp_dir; - std::string templ = temp_dir.path() + "/file-id-unittest"; + string templ = temp_dir.path() + "/file-id-unittest"; char cmdline[4096]; sprintf(cmdline, "cp \"%s\" \"%s\"", exe_name, templ.c_str()); ASSERT_EQ(system(cmdline), 0); diff --git a/src/common/linux/google_crashdump_uploader.cc b/src/common/linux/google_crashdump_uploader.cc index b739a6f6..b5f32c69 100644 --- a/src/common/linux/google_crashdump_uploader.cc +++ b/src/common/linux/google_crashdump_uploader.cc @@ -37,21 +37,21 @@ #include -using std::string; +#include "common/using_std_string.h" namespace google_breakpad { -GoogleCrashdumpUploader::GoogleCrashdumpUploader(const std::string& product, - const std::string& version, - const std::string& guid, - const std::string& ptime, - const std::string& ctime, - const std::string& email, - const std::string& comments, - const std::string& minidump_pathname, - const std::string& crash_server, - const std::string& proxy_host, - const std::string& proxy_userpassword) { +GoogleCrashdumpUploader::GoogleCrashdumpUploader(const string& product, + const string& version, + const string& guid, + const string& ptime, + const string& ctime, + const string& email, + const string& comments, + const string& minidump_pathname, + const string& crash_server, + const string& proxy_host, + const string& proxy_userpassword) { LibcurlWrapper* http_layer = new LibcurlWrapper(); Init(product, version, @@ -67,17 +67,17 @@ GoogleCrashdumpUploader::GoogleCrashdumpUploader(const std::string& product, http_layer); } -GoogleCrashdumpUploader::GoogleCrashdumpUploader(const std::string& product, - const std::string& version, - const std::string& guid, - const std::string& ptime, - const std::string& ctime, - const std::string& email, - const std::string& comments, - const std::string& minidump_pathname, - const std::string& crash_server, - const std::string& proxy_host, - const std::string& proxy_userpassword, +GoogleCrashdumpUploader::GoogleCrashdumpUploader(const string& product, + const string& version, + const string& guid, + const string& ptime, + const string& ctime, + const string& email, + const string& comments, + const string& minidump_pathname, + const string& crash_server, + const string& proxy_host, + const string& proxy_userpassword, LibcurlWrapper* http_layer) { Init(product, version, @@ -93,17 +93,17 @@ GoogleCrashdumpUploader::GoogleCrashdumpUploader(const std::string& product, http_layer); } -void GoogleCrashdumpUploader::Init(const std::string& product, - const std::string& version, - const std::string& guid, - const std::string& ptime, - const std::string& ctime, - const std::string& email, - const std::string& comments, - const std::string& minidump_pathname, - const std::string& crash_server, - const std::string& proxy_host, - const std::string& proxy_userpassword, +void GoogleCrashdumpUploader::Init(const string& product, + const string& version, + const string& guid, + const string& ptime, + const string& ctime, + const string& email, + const string& comments, + const string& minidump_pathname, + const string& crash_server, + const string& proxy_host, + const string& proxy_userpassword, LibcurlWrapper* http_layer) { product_ = product; version_ = version; @@ -137,7 +137,7 @@ void GoogleCrashdumpUploader::Init(const std::string& product, } bool GoogleCrashdumpUploader::CheckRequiredParametersArePresent() { - std::string error_text; + string error_text; if (product_.empty()) { error_text.append("\nProduct name must be specified."); } diff --git a/src/common/linux/google_crashdump_uploader.h b/src/common/linux/google_crashdump_uploader.h index 5cea17d9..5eef28b3 100644 --- a/src/common/linux/google_crashdump_uploader.h +++ b/src/common/linux/google_crashdump_uploader.h @@ -31,48 +31,50 @@ #include #include +#include "common/using_std_string.h" + namespace google_breakpad { class LibcurlWrapper; class GoogleCrashdumpUploader { public: - GoogleCrashdumpUploader(const std::string& product, - const std::string& version, - const std::string& guid, - const std::string& ptime, - const std::string& ctime, - const std::string& email, - const std::string& comments, - const std::string& minidump_pathname, - const std::string& crash_server, - const std::string& proxy_host, - const std::string& proxy_userpassword); + GoogleCrashdumpUploader(const string& product, + const string& version, + const string& guid, + const string& ptime, + const string& ctime, + const string& email, + const string& comments, + const string& minidump_pathname, + const string& crash_server, + const string& proxy_host, + const string& proxy_userpassword); - GoogleCrashdumpUploader(const std::string& product, - const std::string& version, - const std::string& guid, - const std::string& ptime, - const std::string& ctime, - const std::string& email, - const std::string& comments, - const std::string& minidump_pathname, - const std::string& crash_server, - const std::string& proxy_host, - const std::string& proxy_userpassword, + GoogleCrashdumpUploader(const string& product, + const string& version, + const string& guid, + const string& ptime, + const string& ctime, + const string& email, + const string& comments, + const string& minidump_pathname, + const string& crash_server, + const string& proxy_host, + const string& proxy_userpassword, LibcurlWrapper* http_layer); - void Init(const std::string& product, - const std::string& version, - const std::string& guid, - const std::string& ptime, - const std::string& ctime, - const std::string& email, - const std::string& comments, - const std::string& minidump_pathname, - const std::string& crash_server, - const std::string& proxy_host, - const std::string& proxy_userpassword, + void Init(const string& product, + const string& version, + const string& guid, + const string& ptime, + const string& ctime, + const string& email, + const string& comments, + const string& minidump_pathname, + const string& crash_server, + const string& proxy_host, + const string& proxy_userpassword, LibcurlWrapper* http_layer); bool Upload(); @@ -80,19 +82,19 @@ class GoogleCrashdumpUploader { bool CheckRequiredParametersArePresent(); LibcurlWrapper* http_layer_; - std::string product_; - std::string version_; - std::string guid_; - std::string ptime_; - std::string ctime_; - std::string email_; - std::string comments_; - std::string minidump_pathname_; + string product_; + string version_; + string guid_; + string ptime_; + string ctime_; + string email_; + string comments_; + string minidump_pathname_; - std::string crash_server_; - std::string proxy_host_; - std::string proxy_userpassword_; + string crash_server_; + string proxy_host_; + string proxy_userpassword_; - std::map parameters_; + std::map parameters_; }; } diff --git a/src/common/linux/google_crashdump_uploader_test.cc b/src/common/linux/google_crashdump_uploader_test.cc index c65355c9..957874ad 100644 --- a/src/common/linux/google_crashdump_uploader_test.cc +++ b/src/common/linux/google_crashdump_uploader_test.cc @@ -29,9 +29,12 @@ // Unit test for crash dump uploader. +#include + #include "common/linux/google_crashdump_uploader.h" #include "common/linux/libcurl_wrapper.h" #include "breakpad_googletest_includes.h" +#include "common/using_std_string.h" namespace google_breakpad { @@ -41,14 +44,14 @@ using ::testing::_; class MockLibcurlWrapper : public LibcurlWrapper { public: MOCK_METHOD0(Init, bool()); - MOCK_METHOD2(SetProxy, bool(const std::string& proxy_host, - const std::string& proxy_userpwd)); - MOCK_METHOD2(AddFile, bool(const std::string& upload_file_path, - const std::string& basename)); + MOCK_METHOD2(SetProxy, bool(const string& proxy_host, + const string& proxy_userpwd)); + MOCK_METHOD2(AddFile, bool(const string& upload_file_path, + const string& basename)); MOCK_METHOD3(SendRequest, - bool(const std::string& url, - const std::map& parameters, - std::string* server_response)); + bool(const string& url, + const std::map& parameters, + string* server_response)); }; class GoogleCrashdumpUploaderTest : public ::testing::Test { diff --git a/src/common/linux/http_upload.cc b/src/common/linux/http_upload.cc index f69237c8..fead76e9 100644 --- a/src/common/linux/http_upload.cc +++ b/src/common/linux/http_upload.cc @@ -41,7 +41,7 @@ static size_t WriteCallback(void *ptr, size_t size, if (!userp) return 0; - std::string *response = reinterpret_cast(userp); + string *response = reinterpret_cast(userp); size_t real_size = size * nmemb; response->append(reinterpret_cast(ptr), real_size); return real_size; diff --git a/src/common/linux/http_upload.h b/src/common/linux/http_upload.h index 22b62960..6dd36ea0 100644 --- a/src/common/linux/http_upload.h +++ b/src/common/linux/http_upload.h @@ -37,9 +37,10 @@ #include #include +#include "common/using_std_string.h" + namespace google_breakpad { -using std::string; using std::map; class HTTPUpload { diff --git a/src/common/linux/libcurl_wrapper.cc b/src/common/linux/libcurl_wrapper.cc index 8b61aa09..08307f02 100644 --- a/src/common/linux/libcurl_wrapper.cc +++ b/src/common/linux/libcurl_wrapper.cc @@ -33,8 +33,7 @@ #include #include "common/linux/libcurl_wrapper.h" - -using std::string; +#include "common/using_std_string.h" namespace google_breakpad { LibcurlWrapper::LibcurlWrapper() @@ -58,8 +57,8 @@ LibcurlWrapper::LibcurlWrapper() return; } -bool LibcurlWrapper::SetProxy(const std::string& proxy_host, - const std::string& proxy_userpwd) { +bool LibcurlWrapper::SetProxy(const string& proxy_host, + const string& proxy_userpwd) { if (!init_ok_) { return false; } @@ -80,8 +79,8 @@ bool LibcurlWrapper::SetProxy(const std::string& proxy_host, return true; } -bool LibcurlWrapper::AddFile(const std::string& upload_file_path, - const std::string& basename) { +bool LibcurlWrapper::AddFile(const string& upload_file_path, + const string& basename) { if (!init_ok_) { return false; } @@ -101,17 +100,17 @@ static size_t WriteCallback(void *ptr, size_t size, if (!userp) return 0; - std::string *response = reinterpret_cast(userp); + string *response = reinterpret_cast(userp); size_t real_size = size * nmemb; response->append(reinterpret_cast(ptr), real_size); return real_size; } -bool LibcurlWrapper::SendRequest(const std::string& url, - const std::map& parameters, - std::string* server_response) { +bool LibcurlWrapper::SendRequest(const string& url, + const std::map& parameters, + string* server_response) { (*easy_setopt_)(curl_, CURLOPT_URL, url.c_str()); - std::map::const_iterator iter = parameters.begin(); + std::map::const_iterator iter = parameters.begin(); for (; iter != parameters.end(); ++iter) (*formadd_)(&formpost_, &lastptr_, CURLFORM_COPYNAME, iter->first.c_str(), diff --git a/src/common/linux/libcurl_wrapper.h b/src/common/linux/libcurl_wrapper.h index 3e53e616..3b72b5e7 100644 --- a/src/common/linux/libcurl_wrapper.h +++ b/src/common/linux/libcurl_wrapper.h @@ -33,6 +33,7 @@ #include #include +#include "common/using_std_string.h" #include "third_party/curl/curl.h" namespace google_breakpad { @@ -40,13 +41,13 @@ class LibcurlWrapper { public: LibcurlWrapper(); virtual bool Init(); - virtual bool SetProxy(const std::string& proxy_host, - const std::string& proxy_userpwd); - virtual bool AddFile(const std::string& upload_file_path, - const std::string& basename); - virtual bool SendRequest(const std::string& url, - const std::map& parameters, - std::string* server_response); + virtual bool SetProxy(const string& proxy_host, + const string& proxy_userpwd); + virtual bool AddFile(const string& upload_file_path, + const string& basename); + virtual bool SendRequest(const string& url, + const std::map& parameters, + string* server_response); private: // This function initializes class state corresponding to function // pointers into the CURL library. @@ -55,7 +56,7 @@ class LibcurlWrapper { bool init_ok_; // Whether init succeeded void* curl_lib_; // Pointer to result of dlopen() on // curl library - std::string last_curl_error_; // The text of the last error when + string last_curl_error_; // The text of the last error when // dealing // with CURL. diff --git a/src/common/linux/memory_mapped_file_unittest.cc b/src/common/linux/memory_mapped_file_unittest.cc index cf89bca9..0c551ac2 100644 --- a/src/common/linux/memory_mapped_file_unittest.cc +++ b/src/common/linux/memory_mapped_file_unittest.cc @@ -41,11 +41,11 @@ #include "common/linux/memory_mapped_file.h" #include "common/tests/auto_tempdir.h" #include "common/tests/file_utils.h" +#include "common/using_std_string.h" using google_breakpad::AutoTempDir; using google_breakpad::MemoryMappedFile; using google_breakpad::WriteFile; -using std::string; namespace { diff --git a/src/common/linux/synth_elf.cc b/src/common/linux/synth_elf.cc index 3e10b691..afaea022 100644 --- a/src/common/linux/synth_elf.cc +++ b/src/common/linux/synth_elf.cc @@ -5,6 +5,8 @@ #include #include +#include "common/using_std_string.h" + namespace google_breakpad { namespace synth_elf { diff --git a/src/common/linux/synth_elf.h b/src/common/linux/synth_elf.h index 90bd8341..1fbe749c 100644 --- a/src/common/linux/synth_elf.h +++ b/src/common/linux/synth_elf.h @@ -43,13 +43,14 @@ #include #include +#include "common/using_std_string.h" + namespace google_breakpad { namespace synth_elf { using std::list; using std::map; using std::pair; -using std::string; using test_assembler::Endianness; using test_assembler::kLittleEndian; using test_assembler::kUnsetEndian; diff --git a/src/common/linux/synth_elf_unittest.cc b/src/common/linux/synth_elf_unittest.cc index 8cc7ad28..0cb7d270 100644 --- a/src/common/linux/synth_elf_unittest.cc +++ b/src/common/linux/synth_elf_unittest.cc @@ -36,6 +36,7 @@ #include "breakpad_googletest_includes.h" #include "common/linux/synth_elf.h" +#include "common/using_std_string.h" using google_breakpad::synth_elf::ELF; using google_breakpad::synth_elf::StringTable; @@ -44,7 +45,6 @@ using google_breakpad::test_assembler::Endianness; using google_breakpad::test_assembler::kBigEndian; using google_breakpad::test_assembler::kLittleEndian; using google_breakpad::test_assembler::Label; -using std::string; using ::testing::Test; class StringTableTest : public Test { diff --git a/src/common/linux/tests/crash_generator.cc b/src/common/linux/tests/crash_generator.cc index 59aced27..c78b793e 100644 --- a/src/common/linux/tests/crash_generator.cc +++ b/src/common/linux/tests/crash_generator.cc @@ -46,6 +46,7 @@ #include "common/linux/eintr_wrapper.h" #include "common/tests/auto_tempdir.h" #include "common/tests/file_utils.h" +#include "common/using_std_string.h" namespace { @@ -97,11 +98,11 @@ bool CrashGenerator::HasDefaultCorePattern() const { buffer_size == 5 && memcmp(buffer, "core", 4) == 0; } -std::string CrashGenerator::GetCoreFilePath() const { +string CrashGenerator::GetCoreFilePath() const { return temp_dir_.path() + "/core"; } -std::string CrashGenerator::GetDirectoryOfProcFilesCopy() const { +string CrashGenerator::GetDirectoryOfProcFilesCopy() const { return temp_dir_.path() + "/proc"; } @@ -170,7 +171,7 @@ bool CrashGenerator::CreateChildCrash( } if (SetCoreFileSizeLimit(kCoreSizeLimit)) { CreateThreadsInChildProcess(num_threads); - std::string proc_dir = GetDirectoryOfProcFilesCopy(); + string proc_dir = GetDirectoryOfProcFilesCopy(); if (mkdir(proc_dir.c_str(), 0755) == -1) { perror("CrashGenerator: Failed to create proc directory"); exit(1); diff --git a/src/common/linux/tests/crash_generator.h b/src/common/linux/tests/crash_generator.h index d05ce73d..7e2fcbf9 100644 --- a/src/common/linux/tests/crash_generator.h +++ b/src/common/linux/tests/crash_generator.h @@ -38,6 +38,7 @@ #include #include "common/tests/auto_tempdir.h" +#include "common/using_std_string.h" namespace google_breakpad { @@ -59,10 +60,10 @@ class CrashGenerator { bool HasDefaultCorePattern() const; // Returns the expected path of the core dump file. - std::string GetCoreFilePath() const; + string GetCoreFilePath() const; // Returns the directory of a copy of proc files of the child process. - std::string GetDirectoryOfProcFilesCopy() const; + string GetDirectoryOfProcFilesCopy() const; // Creates a crash (and a core dump file) by creating a child process with // |num_threads| threads, and the terminating the child process by sending diff --git a/src/common/module.h b/src/common/module.h index 734a1afc..cc89bba5 100644 --- a/src/common/module.h +++ b/src/common/module.h @@ -44,12 +44,12 @@ #include #include +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" namespace google_breakpad { using std::set; -using std::string; using std::vector; using std::map; diff --git a/src/common/module_unittest.cc b/src/common/module_unittest.cc index 85c3b1c6..04dc4041 100644 --- a/src/common/module_unittest.cc +++ b/src/common/module_unittest.cc @@ -42,9 +42,9 @@ #include "breakpad_googletest_includes.h" #include "common/module.h" +#include "common/using_std_string.h" using google_breakpad::Module; -using std::string; using std::stringstream; using std::vector; using testing::ContainerEq; diff --git a/src/common/stabs_reader.cc b/src/common/stabs_reader.cc index 4897361e..6019fc7e 100644 --- a/src/common/stabs_reader.cc +++ b/src/common/stabs_reader.cc @@ -37,6 +37,10 @@ #include #include +#include + +#include "common/using_std_string.h" + using std::vector; namespace google_breakpad { @@ -225,7 +229,7 @@ bool StabsReader::ProcessFunction() { const char *name_end = strchr(stab_string, ':'); if (! name_end) name_end = stab_string + strlen(stab_string); - std::string name(stab_string, name_end - stab_string); + string name(stab_string, name_end - stab_string); if (! handler_->StartFunction(name, function_address)) return false; ++iterator_; diff --git a/src/common/stabs_reader.h b/src/common/stabs_reader.h index b22ebfd3..d89afc00 100644 --- a/src/common/stabs_reader.h +++ b/src/common/stabs_reader.h @@ -64,6 +64,7 @@ #include #include "common/byte_cursor.h" +#include "common/using_std_string.h" namespace google_breakpad { @@ -292,7 +293,7 @@ class StabsHandler { // StartFunction is the function name alone. // // In languages that use name mangling, like C++, NAME is mangled. - virtual bool StartFunction(const std::string &name, uint64_t address) { + virtual bool StartFunction(const string &name, uint64_t address) { return true; } @@ -311,7 +312,7 @@ class StabsHandler { // Report that an exported function NAME is present at ADDRESS. // The size of the function is unknown. - virtual bool Extern(const std::string &name, uint64_t address) { + virtual bool Extern(const string &name, uint64_t address) { return true; } diff --git a/src/common/stabs_reader_unittest.cc b/src/common/stabs_reader_unittest.cc index 2a9b5d41..35d5e6ca 100644 --- a/src/common/stabs_reader_unittest.cc +++ b/src/common/stabs_reader_unittest.cc @@ -43,10 +43,12 @@ #include #include #include +#include #include "breakpad_googletest_includes.h" #include "common/stabs_reader.h" #include "common/test_assembler.h" +#include "common/using_std_string.h" using ::testing::Eq; using ::testing::InSequence; @@ -61,7 +63,6 @@ using google_breakpad::test_assembler::Section; using google_breakpad::test_assembler::kBigEndian; using google_breakpad::test_assembler::kLittleEndian; using std::map; -using std::string; namespace { @@ -218,10 +219,10 @@ class MockStabsReaderHandler: public StabsHandler { MOCK_METHOD3(StartCompilationUnit, bool(const char *, uint64_t, const char *)); MOCK_METHOD1(EndCompilationUnit, bool(uint64_t)); - MOCK_METHOD2(StartFunction, bool(const std::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 std::string &, uint64_t)); + MOCK_METHOD2(Extern, bool(const string &, uint64_t)); void Warning(const char *format, ...) { MockWarning(format); } MOCK_METHOD1(MockWarning, void(const char *)); }; diff --git a/src/common/stabs_to_module.cc b/src/common/stabs_to_module.cc index 67cd13bf..e59aebdb 100644 --- a/src/common/stabs_to_module.cc +++ b/src/common/stabs_to_module.cc @@ -39,11 +39,10 @@ #include #include "common/stabs_to_module.h" +#include "common/using_std_string.h" namespace google_breakpad { -using std::string; - // Demangle using abi call. // Older GCC may not support it. static string Demangle(const string &mangled) { diff --git a/src/common/stabs_to_module.h b/src/common/stabs_to_module.h index 632f4d00..5e04fa79 100644 --- a/src/common/stabs_to_module.h +++ b/src/common/stabs_to_module.h @@ -45,10 +45,10 @@ #include "common/module.h" #include "common/stabs_reader.h" +#include "common/using_std_string.h" namespace google_breakpad { -using std::string; using std::vector; // A StabsToModule is a handler that receives parsed STABS debugging diff --git a/src/common/string_conversion.cc b/src/common/string_conversion.cc index ac4f1da5..27fb8cd9 100644 --- a/src/common/string_conversion.cc +++ b/src/common/string_conversion.cc @@ -27,14 +27,15 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#include + #include "common/convert_UTF.h" -#include "processor/scoped_ptr.h" #include "common/string_conversion.h" -#include +#include "common/using_std_string.h" +#include "processor/scoped_ptr.h" namespace google_breakpad { -using std::string; using std::vector; void UTF8ToUTF16(const char *in, vector *out) { diff --git a/src/common/string_conversion.h b/src/common/string_conversion.h index d51f46bb..eeed4d28 100644 --- a/src/common/string_conversion.h +++ b/src/common/string_conversion.h @@ -34,6 +34,8 @@ #include #include + +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" namespace google_breakpad { @@ -59,7 +61,7 @@ void UTF32ToUTF16(const wchar_t *in, vector *out); void UTF32ToUTF16Char(wchar_t in, u_int16_t out[2]); // Convert |in| to UTF-8. If |swap| is true, swap bytes before converting. -std::string UTF16ToUTF8(const vector &in, bool swap); +string UTF16ToUTF8(const vector &in, bool swap); } // namespace google_breakpad diff --git a/src/common/test_assembler.h b/src/common/test_assembler.h index 5ce6b0c8..401e8528 100644 --- a/src/common/test_assembler.h +++ b/src/common/test_assembler.h @@ -60,12 +60,12 @@ #include #include +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" namespace google_breakpad { using std::list; -using std::string; using std::vector; namespace test_assembler { diff --git a/src/common/test_assembler_unittest.cc b/src/common/test_assembler_unittest.cc index 5db13267..d4e95eff 100644 --- a/src/common/test_assembler_unittest.cc +++ b/src/common/test_assembler_unittest.cc @@ -36,12 +36,12 @@ #include "breakpad_googletest_includes.h" #include "common/test_assembler.h" +#include "common/using_std_string.h" using google_breakpad::test_assembler::Label; using google_breakpad::test_assembler::Section; using google_breakpad::test_assembler::kBigEndian; using google_breakpad::test_assembler::kLittleEndian; -using std::string; using testing::Test; TEST(ConstructLabel, Simple) { diff --git a/src/common/tests/auto_tempdir.h b/src/common/tests/auto_tempdir.h index ccfd81bc..9c84177c 100644 --- a/src/common/tests/auto_tempdir.h +++ b/src/common/tests/auto_tempdir.h @@ -38,6 +38,7 @@ #include #include "breakpad_googletest_includes.h" +#include "common/using_std_string.h" #if !defined(__ANDROID__) #define TEMPDIR "/tmp" @@ -59,12 +60,12 @@ class AutoTempDir { DeleteRecursively(path_); } - const std::string& path() const { + const string& path() const { return path_; } private: - void DeleteRecursively(const std::string& path) { + void DeleteRecursively(const string& path) { // First remove any files in the dir DIR* dir = opendir(path.c_str()); if (!dir) @@ -74,7 +75,7 @@ class AutoTempDir { while ((entry = readdir(dir)) != NULL) { if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue; - std::string entry_path = path + "/" + entry->d_name; + string entry_path = path + "/" + entry->d_name; struct stat stats; EXPECT_TRUE(lstat(entry_path.c_str(), &stats) == 0); if (S_ISDIR(stats.st_mode)) @@ -90,7 +91,7 @@ class AutoTempDir { AutoTempDir(const AutoTempDir&); AutoTempDir& operator=(const AutoTempDir&); - std::string path_; + string path_; }; } // namespace google_breakpad diff --git a/src/common/using_std_string.h b/src/common/using_std_string.h new file mode 100644 index 00000000..13c1da59 --- /dev/null +++ b/src/common/using_std_string.h @@ -0,0 +1,65 @@ +// -*- mode: C++ -*- + +// Copyright (c) 2012, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Original author: Ivan Penkov + +// using_std_string.h: Allows building this code in environments where +// global string (::string) exists. +// +// The problem: +// ------------- +// Let's say you want to build this code in an environment where a global +// string type is defined (i.e. ::string). Now, let's suppose that ::string +// is different that std::string and you'd like to have the option to easily +// choose between the two string types. Ideally you'd like to control which +// string type is chosen by simply #defining an identifier. +// +// The solution: +// ------------- +// #define HAS_GLOBAL_STRING somewhere in a global header file and then +// globally replace std::string with string. Then include this header +// file everywhere where string is used. If you want to revert back to +// using std::string, simply remove the #define (HAS_GLOBAL_STRING). + +#ifndef THIRD_PARTY_BREAKPAD_SRC_COMMON_USING_STD_STRING_H_ +#define THIRD_PARTY_BREAKPAD_SRC_COMMON_USING_STD_STRING_H_ + +#ifdef HAS_GLOBAL_STRING + typedef ::string google_breakpad_string; +#else + using std::string; + typedef std::string google_breakpad_string; +#endif + +// Inicates that type google_breakpad_string is defined +#define HAS_GOOGLE_BREAKPAD_STRING + +#endif // THIRD_PARTY_BREAKPAD_SRC_COMMON_USING_STD_STRING_H_ diff --git a/src/google_breakpad/processor/basic_source_line_resolver.h b/src/google_breakpad/processor/basic_source_line_resolver.h index f77b3bbb..8bda5784 100644 --- a/src/google_breakpad/processor/basic_source_line_resolver.h +++ b/src/google_breakpad/processor/basic_source_line_resolver.h @@ -39,12 +39,13 @@ #define GOOGLE_BREAKPAD_PROCESSOR_BASIC_SOURCE_LINE_RESOLVER_H__ #include +#include +#include "common/using_std_string.h" #include "google_breakpad/processor/source_line_resolver_base.h" namespace google_breakpad { -using std::string; using std::map; class BasicSourceLineResolver : public SourceLineResolverBase { diff --git a/src/google_breakpad/processor/code_module.h b/src/google_breakpad/processor/code_module.h index 38ee956e..24b88fba 100644 --- a/src/google_breakpad/processor/code_module.h +++ b/src/google_breakpad/processor/code_module.h @@ -36,12 +36,12 @@ #define GOOGLE_BREAKPAD_PROCESSOR_CODE_MODULE_H__ #include + +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" namespace google_breakpad { -using std::string; - class CodeModule { public: virtual ~CodeModule() {} diff --git a/src/google_breakpad/processor/minidump.h b/src/google_breakpad/processor/minidump.h index 012a8135..3dfbef2b 100644 --- a/src/google_breakpad/processor/minidump.h +++ b/src/google_breakpad/processor/minidump.h @@ -88,6 +88,7 @@ #include #include +#include "common/using_std_string.h" #include "google_breakpad/common/minidump_format.h" #include "google_breakpad/processor/code_module.h" #include "google_breakpad/processor/code_modules.h" @@ -98,7 +99,6 @@ namespace google_breakpad { using std::map; -using std::string; using std::vector; diff --git a/src/google_breakpad/processor/minidump_processor.h b/src/google_breakpad/processor/minidump_processor.h index 3ed0ebff..216e9728 100644 --- a/src/google_breakpad/processor/minidump_processor.h +++ b/src/google_breakpad/processor/minidump_processor.h @@ -32,12 +32,12 @@ #include #include + +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" namespace google_breakpad { -using std::string; - class Minidump; class ProcessState; class SourceLineResolverInterface; diff --git a/src/google_breakpad/processor/process_state.h b/src/google_breakpad/processor/process_state.h index f3f2ec42..8d71457b 100644 --- a/src/google_breakpad/processor/process_state.h +++ b/src/google_breakpad/processor/process_state.h @@ -36,13 +36,14 @@ #include #include + +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" #include "google_breakpad/processor/system_info.h" #include "google_breakpad/processor/minidump.h" namespace google_breakpad { -using std::string; using std::vector; class CallStack; diff --git a/src/google_breakpad/processor/source_line_resolver_interface.h b/src/google_breakpad/processor/source_line_resolver_interface.h index 9fe7ef4e..4e9dd4b7 100644 --- a/src/google_breakpad/processor/source_line_resolver_interface.h +++ b/src/google_breakpad/processor/source_line_resolver_interface.h @@ -35,13 +35,13 @@ #define GOOGLE_BREAKPAD_PROCESSOR_SOURCE_LINE_RESOLVER_INTERFACE_H__ #include + +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" #include "google_breakpad/processor/code_module.h" namespace google_breakpad { -using std::string; - struct StackFrame; struct WindowsFrameInfo; class CFIFrameInfo; diff --git a/src/google_breakpad/processor/stack_frame.h b/src/google_breakpad/processor/stack_frame.h index c4449938..2f31e5c1 100644 --- a/src/google_breakpad/processor/stack_frame.h +++ b/src/google_breakpad/processor/stack_frame.h @@ -31,14 +31,14 @@ #define GOOGLE_BREAKPAD_PROCESSOR_STACK_FRAME_H__ #include + +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" namespace google_breakpad { class CodeModule; -using std::string; - struct StackFrame { // Indicates how well the instruction pointer derived during // stack walking is trusted. Since the stack walker can resort to diff --git a/src/google_breakpad/processor/stackwalker.h b/src/google_breakpad/processor/stackwalker.h index b184d025..6a0c3e72 100644 --- a/src/google_breakpad/processor/stackwalker.h +++ b/src/google_breakpad/processor/stackwalker.h @@ -43,6 +43,8 @@ #include #include + +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" #include "google_breakpad/processor/code_modules.h" #include "google_breakpad/processor/memory_region.h" @@ -189,7 +191,7 @@ class Stackwalker { // A list of modules that we haven't found symbols for. We track // this in order to avoid repeatedly looking them up again within // one minidump. - set no_symbol_modules_; + set no_symbol_modules_; // The maximum number of frames Stackwalker will walk through. // This defaults to 1024 to prevent infinite loops. diff --git a/src/google_breakpad/processor/symbol_supplier.h b/src/google_breakpad/processor/symbol_supplier.h index 8c4d7f71..dccab509 100644 --- a/src/google_breakpad/processor/symbol_supplier.h +++ b/src/google_breakpad/processor/symbol_supplier.h @@ -34,10 +34,10 @@ #define GOOGLE_BREAKPAD_PROCESSOR_SYMBOL_SUPPLIER_H__ #include +#include "common/using_std_string.h" namespace google_breakpad { -using std::string; class CodeModule; struct SystemInfo; diff --git a/src/google_breakpad/processor/system_info.h b/src/google_breakpad/processor/system_info.h index fdbdbfd6..4a250482 100644 --- a/src/google_breakpad/processor/system_info.h +++ b/src/google_breakpad/processor/system_info.h @@ -37,9 +37,9 @@ #include -namespace google_breakpad { +#include "common/using_std_string.h" -using std::string; +namespace google_breakpad { struct SystemInfo { public: diff --git a/src/processor/basic_code_module.h b/src/processor/basic_code_module.h index e3955d29..635c09a2 100644 --- a/src/processor/basic_code_module.h +++ b/src/processor/basic_code_module.h @@ -43,12 +43,11 @@ #include +#include "common/using_std_string.h" #include "google_breakpad/processor/code_module.h" namespace google_breakpad { -using std::string; - class BasicCodeModule : public CodeModule { public: // Creates a new BasicCodeModule given any existing CodeModule diff --git a/src/processor/basic_source_line_resolver_unittest.cc b/src/processor/basic_source_line_resolver_unittest.cc index 5fda6f5b..2a483e35 100644 --- a/src/processor/basic_source_line_resolver_unittest.cc +++ b/src/processor/basic_source_line_resolver_unittest.cc @@ -32,6 +32,7 @@ #include #include "breakpad_googletest_includes.h" +#include "common/using_std_string.h" #include "google_breakpad/processor/basic_source_line_resolver.h" #include "google_breakpad/processor/code_module.h" #include "google_breakpad/processor/stack_frame.h" @@ -44,7 +45,6 @@ namespace { -using std::string; using google_breakpad::BasicSourceLineResolver; using google_breakpad::CFIFrameInfo; using google_breakpad::CodeModule; diff --git a/src/processor/binarystream.cc b/src/processor/binarystream.cc index c8ee2186..9ed3b702 100644 --- a/src/processor/binarystream.cc +++ b/src/processor/binarystream.cc @@ -30,15 +30,16 @@ #include #include +#include #include +#include "common/using_std_string.h" #include "processor/binarystream.h" namespace google_breakpad { -using std::string; using std::vector; -binarystream &binarystream::operator>>(std::string &str) { +binarystream &binarystream::operator>>(string &str) { u_int16_t length; *this >> length; if (eof()) @@ -83,7 +84,7 @@ binarystream &binarystream::operator>>(u_int64_t &u64) { return *this; } -binarystream &binarystream::operator<<(const std::string &str) { +binarystream &binarystream::operator<<(const string &str) { if (str.length() > USHRT_MAX) { // truncate to 16-bit length *this << static_cast(USHRT_MAX); diff --git a/src/processor/binarystream.h b/src/processor/binarystream.h index 8769c250..04657150 100644 --- a/src/processor/binarystream.h +++ b/src/processor/binarystream.h @@ -28,8 +28,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // binarystream implements part of the std::iostream interface as a -// wrapper around std::stringstream to allow reading and writing -// std::string and integers of known size. +// wrapper around std::stringstream to allow reading and writing strings +// and integers of known size. #ifndef GOOGLE_BREAKPAD_PROCESSOR_BINARYSTREAM_H_ #define GOOGLE_BREAKPAD_PROCESSOR_BINARYSTREAM_H_ @@ -37,6 +37,7 @@ #include #include +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" namespace google_breakpad { @@ -47,21 +48,21 @@ class binarystream { public: explicit binarystream(ios_base::openmode which = ios_base::out|ios_base::in) : stream_(which) {} - explicit binarystream(const std::string &str, + explicit binarystream(const string &str, ios_base::openmode which = ios_base::out|ios_base::in) : stream_(str, which) {} explicit binarystream(const char *str, size_t size, ios_base::openmode which = ios_base::out|ios_base::in) - : stream_(std::string(str, size), which) {} + : stream_(string(str, size), which) {} - binarystream &operator>>(std::string &str); + binarystream &operator>>(string &str); binarystream &operator>>(u_int8_t &u8); binarystream &operator>>(u_int16_t &u16); binarystream &operator>>(u_int32_t &u32); binarystream &operator>>(u_int64_t &u64); // Note: strings are truncated at 65535 characters - binarystream &operator<<(const std::string &str); + binarystream &operator<<(const string &str); binarystream &operator<<(u_int8_t u8); binarystream &operator<<(u_int16_t u16); binarystream &operator<<(u_int32_t u32); @@ -70,8 +71,8 @@ class binarystream { // Forward a few methods directly from the stream object bool eof() const { return stream_.eof(); } void clear() { stream_.clear(); } - std::string str() const { return stream_.str(); } - void str(const std::string &s) { stream_.str(s); } + string str() const { return stream_.str(); } + void str(const string &s) { stream_.str(s); } // Seek both read and write pointers to the beginning of the stream. void rewind() { diff --git a/src/processor/binarystream_unittest.cc b/src/processor/binarystream_unittest.cc index 2ed76e28..2812319c 100644 --- a/src/processor/binarystream_unittest.cc +++ b/src/processor/binarystream_unittest.cc @@ -32,11 +32,11 @@ #include #include "breakpad_googletest_includes.h" +#include "common/using_std_string.h" #include "processor/binarystream.h" namespace { using std::ios_base; -using std::string; using std::vector; using google_breakpad::binarystream; diff --git a/src/processor/cfi_frame_info.h b/src/processor/cfi_frame_info.h index fe06fb4f..4bbbd1ef 100644 --- a/src/processor/cfi_frame_info.h +++ b/src/processor/cfi_frame_info.h @@ -41,12 +41,12 @@ #include #include +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" namespace google_breakpad { using std::map; -using std::string; class MemoryRegion; diff --git a/src/processor/cfi_frame_info_unittest.cc b/src/processor/cfi_frame_info_unittest.cc index 979d4a3b..cd48e16d 100644 --- a/src/processor/cfi_frame_info_unittest.cc +++ b/src/processor/cfi_frame_info_unittest.cc @@ -35,6 +35,7 @@ #include #include "breakpad_googletest_includes.h" +#include "common/using_std_string.h" #include "processor/cfi_frame_info.h" #include "google_breakpad/processor/memory_region.h" @@ -43,7 +44,6 @@ using google_breakpad::CFIFrameInfoParseHandler; using google_breakpad::CFIRuleParser; using google_breakpad::MemoryRegion; using google_breakpad::SimpleCFIWalker; -using std::string; using testing::_; using testing::A; using testing::AtMost; diff --git a/src/processor/exploitability_unittest.cc b/src/processor/exploitability_unittest.cc index 4de6f1d6..ce7a6f72 100644 --- a/src/processor/exploitability_unittest.cc +++ b/src/processor/exploitability_unittest.cc @@ -43,6 +43,7 @@ #include #include "breakpad_googletest_includes.h" +#include "common/using_std_string.h" #include "google_breakpad/processor/basic_source_line_resolver.h" #include "google_breakpad/processor/call_stack.h" #include "google_breakpad/processor/code_module.h" @@ -78,7 +79,6 @@ using google_breakpad::MockMinidump; using google_breakpad::ProcessState; using google_breakpad::SymbolSupplier; using google_breakpad::SystemInfo; -using std::string; class TestSymbolSupplier : public SymbolSupplier { public: diff --git a/src/processor/fast_source_line_resolver.cc b/src/processor/fast_source_line_resolver.cc index 9224ffa2..a7b99331 100644 --- a/src/processor/fast_source_line_resolver.cc +++ b/src/processor/fast_source_line_resolver.cc @@ -41,8 +41,10 @@ #include "processor/fast_source_line_resolver_types.h" #include +#include #include +#include "common/using_std_string.h" #include "processor/module_factory.h" #include "processor/scoped_ptr.h" @@ -125,7 +127,7 @@ WindowsFrameInfo FastSourceLineResolver::CopyWFI(const char *raw) { u_int32_t max_stack_size = para_uint32[5]; const char *boolean = reinterpret_cast(para_uint32 + 6); bool allocates_base_pointer = (*boolean != 0); - std::string program_string = boolean + 1; + string program_string = boolean + 1; return WindowsFrameInfo(type, prolog_size, diff --git a/src/processor/fast_source_line_resolver_unittest.cc b/src/processor/fast_source_line_resolver_unittest.cc index d36d4ba6..d0323cea 100644 --- a/src/processor/fast_source_line_resolver_unittest.cc +++ b/src/processor/fast_source_line_resolver_unittest.cc @@ -43,6 +43,7 @@ #include #include "breakpad_googletest_includes.h" +#include "common/using_std_string.h" #include "google_breakpad/processor/code_module.h" #include "google_breakpad/processor/stack_frame.h" #include "google_breakpad/processor/memory_region.h" @@ -52,7 +53,6 @@ namespace { -using std::string; using google_breakpad::SourceLineResolverBase; using google_breakpad::BasicSourceLineResolver; using google_breakpad::FastSourceLineResolver; diff --git a/src/processor/logging.cc b/src/processor/logging.cc index 70f6958e..a6e15cae 100644 --- a/src/processor/logging.cc +++ b/src/processor/logging.cc @@ -39,6 +39,9 @@ #include #include +#include + +#include "common/using_std_string.h" #include "processor/logging.h" #include "processor/pathname_stripper.h" @@ -80,25 +83,25 @@ LogStream::~LogStream() { stream_ << std::endl; } -std::string HexString(u_int32_t number) { +string HexString(u_int32_t number) { char buffer[11]; snprintf(buffer, sizeof(buffer), "0x%x", number); - return std::string(buffer); + return string(buffer); } -std::string HexString(u_int64_t number) { +string HexString(u_int64_t number) { char buffer[19]; snprintf(buffer, sizeof(buffer), "0x%" PRIx64, number); - return std::string(buffer); + return string(buffer); } -std::string HexString(int number) { +string HexString(int number) { char buffer[19]; snprintf(buffer, sizeof(buffer), "0x%x", number); - return std::string(buffer); + return string(buffer); } -int ErrnoString(std::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 642506d5..6a964f6e 100644 --- a/src/processor/logging.h +++ b/src/processor/logging.h @@ -60,6 +60,7 @@ #include #include +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" #ifdef BP_LOGGING_INCLUDE @@ -118,14 +119,14 @@ class LogMessageVoidify { }; // Returns number formatted as a hexadecimal string, such as "0x7b". -std::string HexString(u_int32_t number); -std::string HexString(u_int64_t number); -std::string HexString(int number); +string HexString(u_int32_t number); +string HexString(u_int64_t number); +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(std::string *error_string); +int ErrnoString(string *error_string); } // namespace google_breakpad diff --git a/src/processor/minidump.cc b/src/processor/minidump.cc index 3ca52ff7..dd7358c0 100644 --- a/src/processor/minidump.cc +++ b/src/processor/minidump.cc @@ -3079,13 +3079,13 @@ bool MinidumpSystemInfo::Read(u_int32_t expected_size) { string MinidumpSystemInfo::GetOS() { + string os; + if (!valid_) { BPLOG(ERROR) << "Invalid MinidumpSystemInfo for GetOS"; - return NULL; + return os; } - string os; - switch (system_info_.platform_id) { case MD_OS_WIN32_NT: case MD_OS_WIN32_WINDOWS: diff --git a/src/processor/minidump_processor_unittest.cc b/src/processor/minidump_processor_unittest.cc index fcac48ff..a8e1208e 100644 --- a/src/processor/minidump_processor_unittest.cc +++ b/src/processor/minidump_processor_unittest.cc @@ -39,6 +39,7 @@ #include #include "breakpad_googletest_includes.h" +#include "common/using_std_string.h" #include "google_breakpad/processor/basic_source_line_resolver.h" #include "google_breakpad/processor/call_stack.h" #include "google_breakpad/processor/code_module.h" @@ -79,7 +80,6 @@ using google_breakpad::ProcessState; using google_breakpad::scoped_ptr; using google_breakpad::SymbolSupplier; using google_breakpad::SystemInfo; -using std::string; using ::testing::_; using ::testing::Mock; using ::testing::Ne; @@ -165,8 +165,8 @@ SymbolSupplier::SymbolResult TestSymbolSupplier::GetSymbolFile( symbol_file); if (s == FOUND) { std::ifstream in(symbol_file->c_str()); - std::getline(in, *symbol_data, std::string::traits_type::to_char_type( - std::string::traits_type::eof())); + std::getline(in, *symbol_data, string::traits_type::to_char_type( + string::traits_type::eof())); in.close(); } diff --git a/src/processor/minidump_stackwalk.cc b/src/processor/minidump_stackwalk.cc index 86f679e9..b37148f4 100644 --- a/src/processor/minidump_stackwalk.cc +++ b/src/processor/minidump_stackwalk.cc @@ -39,6 +39,7 @@ #include #include +#include "common/using_std_string.h" #include "google_breakpad/processor/basic_source_line_resolver.h" #include "google_breakpad/processor/call_stack.h" #include "google_breakpad/processor/code_module.h" @@ -54,7 +55,6 @@ namespace { -using std::string; using std::vector; using google_breakpad::BasicSourceLineResolver; using google_breakpad::CallStack; @@ -575,7 +575,7 @@ int main(int argc, char **argv) { } // extra arguments are symbol paths - std::vector symbol_paths; + std::vector symbol_paths; if (argc > symbol_path_arg) { for (int argi = symbol_path_arg; argi < argc; ++argi) symbol_paths.push_back(argv[argi]); diff --git a/src/processor/minidump_unittest.cc b/src/processor/minidump_unittest.cc index d1c91a88..ce142300 100644 --- a/src/processor/minidump_unittest.cc +++ b/src/processor/minidump_unittest.cc @@ -36,7 +36,9 @@ #include #include #include + #include "breakpad_googletest_includes.h" +#include "common/using_std_string.h" #include "google_breakpad/common/minidump_format.h" #include "google_breakpad/processor/minidump.h" #include "processor/logging.h" @@ -69,7 +71,6 @@ using google_breakpad::test_assembler::kBigEndian; using google_breakpad::test_assembler::kLittleEndian; using std::ifstream; using std::istringstream; -using std::string; using std::vector; using ::testing::Return; diff --git a/src/processor/pathname_stripper.h b/src/processor/pathname_stripper.h index 17db75d6..423ca0d0 100644 --- a/src/processor/pathname_stripper.h +++ b/src/processor/pathname_stripper.h @@ -36,9 +36,9 @@ #include -namespace google_breakpad { +#include "common/using_std_string.h" -using std::string; +namespace google_breakpad { class PathnameStripper { public: diff --git a/src/processor/postfix_evaluator.h b/src/processor/postfix_evaluator.h index eb53b1eb..94b66190 100644 --- a/src/processor/postfix_evaluator.h +++ b/src/processor/postfix_evaluator.h @@ -74,10 +74,11 @@ #include #include +#include "common/using_std_string.h" + namespace google_breakpad { using std::map; -using std::string; using std::vector; class MemoryRegion; diff --git a/src/processor/postfix_evaluator_unittest.cc b/src/processor/postfix_evaluator_unittest.cc index f6cbcf08..00c8fd83 100644 --- a/src/processor/postfix_evaluator_unittest.cc +++ b/src/processor/postfix_evaluator_unittest.cc @@ -38,6 +38,7 @@ #include "processor/postfix_evaluator-inl.h" +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" #include "google_breakpad/processor/memory_region.h" #include "processor/logging.h" @@ -47,7 +48,6 @@ namespace { using std::map; -using std::string; using google_breakpad::MemoryRegion; using google_breakpad::PostfixEvaluator; diff --git a/src/processor/simple_symbol_supplier.cc b/src/processor/simple_symbol_supplier.cc index 76820e12..4a3a1059 100644 --- a/src/processor/simple_symbol_supplier.cc +++ b/src/processor/simple_symbol_supplier.cc @@ -44,6 +44,7 @@ #include #include +#include "common/using_std_string.h" #include "google_breakpad/processor/code_module.h" #include "google_breakpad/processor/system_info.h" #include "processor/logging.h" @@ -87,8 +88,8 @@ SymbolSupplier::SymbolResult SimpleSymbolSupplier::GetSymbolFile( if (s == FOUND) { std::ifstream in(symbol_file->c_str()); - std::getline(in, *symbol_data, std::string::traits_type::to_char_type( - std::string::traits_type::eof())); + std::getline(in, *symbol_data, string::traits_type::to_char_type( + string::traits_type::eof())); in.close(); } return s; diff --git a/src/processor/simple_symbol_supplier.h b/src/processor/simple_symbol_supplier.h index e1c16195..e19b194c 100644 --- a/src/processor/simple_symbol_supplier.h +++ b/src/processor/simple_symbol_supplier.h @@ -80,12 +80,12 @@ #include #include +#include "common/using_std_string.h" #include "google_breakpad/processor/symbol_supplier.h" namespace google_breakpad { using std::map; -using std::string; using std::vector; class CodeModule; diff --git a/src/processor/stackwalker_amd64_unittest.cc b/src/processor/stackwalker_amd64_unittest.cc index a107bee8..26c1a26f 100644 --- a/src/processor/stackwalker_amd64_unittest.cc +++ b/src/processor/stackwalker_amd64_unittest.cc @@ -37,6 +37,7 @@ #include "breakpad_googletest_includes.h" #include "common/test_assembler.h" +#include "common/using_std_string.h" #include "google_breakpad/common/minidump_format.h" #include "google_breakpad/processor/basic_source_line_resolver.h" #include "google_breakpad/processor/call_stack.h" @@ -54,7 +55,6 @@ using google_breakpad::SystemInfo; using google_breakpad::test_assembler::kLittleEndian; using google_breakpad::test_assembler::Label; using google_breakpad::test_assembler::Section; -using std::string; using std::vector; using testing::_; using testing::Return; diff --git a/src/processor/stackwalker_arm_unittest.cc b/src/processor/stackwalker_arm_unittest.cc index 6a623c27..3925dcd8 100644 --- a/src/processor/stackwalker_arm_unittest.cc +++ b/src/processor/stackwalker_arm_unittest.cc @@ -37,6 +37,7 @@ #include "breakpad_googletest_includes.h" #include "common/test_assembler.h" +#include "common/using_std_string.h" #include "google_breakpad/common/minidump_format.h" #include "google_breakpad/processor/basic_source_line_resolver.h" #include "google_breakpad/processor/call_stack.h" @@ -56,7 +57,6 @@ using google_breakpad::WindowsFrameInfo; using google_breakpad::test_assembler::kLittleEndian; using google_breakpad::test_assembler::Label; using google_breakpad::test_assembler::Section; -using std::string; using std::vector; using testing::_; using testing::Return; diff --git a/src/processor/stackwalker_unittest_utils.h b/src/processor/stackwalker_unittest_utils.h index d2e29f72..551d3191 100644 --- a/src/processor/stackwalker_unittest_utils.h +++ b/src/processor/stackwalker_unittest_utils.h @@ -40,6 +40,7 @@ #include #include +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" #include "google_breakpad/processor/code_module.h" #include "google_breakpad/processor/code_modules.h" @@ -54,7 +55,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(u_int64_t base_address, const std::string &contents) { + void Init(u_int64_t base_address, const string &contents) { base_address_ = base_address; contents_ = contents; } @@ -93,22 +94,22 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion { } u_int64_t base_address_; - std::string contents_; + string contents_; }; class MockCodeModule: public google_breakpad::CodeModule { public: MockCodeModule(u_int64_t base_address, u_int64_t size, - const std::string &code_file, const std::string &version) + const string &code_file, const string &version) : base_address_(base_address), size_(size), code_file_(code_file) { } u_int64_t base_address() const { return base_address_; } u_int64_t size() const { return size_; } - std::string code_file() const { return code_file_; } - std::string code_identifier() const { return code_file_; } - std::string debug_file() const { return code_file_; } - std::string debug_identifier() const { return code_file_; } - std::string version() const { return version_; } + string code_file() const { return code_file_; } + string code_identifier() const { return code_file_; } + string debug_file() const { return code_file_; } + string debug_identifier() const { return code_file_; } + string version() const { return version_; } const google_breakpad::CodeModule *Copy() const { abort(); // Tests won't use this. } @@ -116,8 +117,8 @@ class MockCodeModule: public google_breakpad::CodeModule { private: u_int64_t base_address_; u_int64_t size_; - std::string code_file_; - std::string version_; + string code_file_; + string version_; }; class MockCodeModules: public google_breakpad::CodeModules { @@ -165,14 +166,14 @@ class MockSymbolSupplier: public google_breakpad::SymbolSupplier { typedef google_breakpad::SystemInfo SystemInfo; MOCK_METHOD3(GetSymbolFile, SymbolResult(const CodeModule *module, const SystemInfo *system_info, - std::string *symbol_file)); + string *symbol_file)); MOCK_METHOD4(GetSymbolFile, SymbolResult(const CodeModule *module, const SystemInfo *system_info, - std::string *symbol_file, - std::string *symbol_data)); + string *symbol_file, + string *symbol_data)); MOCK_METHOD4(GetCStringSymbolData, SymbolResult(const CodeModule *module, const SystemInfo *system_info, - std::string *symbol_file, + string *symbol_file, char **symbol_data)); MOCK_METHOD1(FreeSymbolData, void(const CodeModule *module)); }; diff --git a/src/processor/stackwalker_x86_unittest.cc b/src/processor/stackwalker_x86_unittest.cc index e57311e8..58dfb6be 100644 --- a/src/processor/stackwalker_x86_unittest.cc +++ b/src/processor/stackwalker_x86_unittest.cc @@ -36,6 +36,7 @@ #include "breakpad_googletest_includes.h" #include "common/test_assembler.h" +#include "common/using_std_string.h" #include "google_breakpad/common/minidump_format.h" #include "google_breakpad/processor/basic_source_line_resolver.h" #include "google_breakpad/processor/call_stack.h" @@ -55,7 +56,6 @@ using google_breakpad::WindowsFrameInfo; using google_breakpad::test_assembler::kLittleEndian; using google_breakpad::test_assembler::Label; using google_breakpad::test_assembler::Section; -using std::string; using std::vector; using testing::_; using testing::Return; diff --git a/src/processor/static_address_map_unittest.cc b/src/processor/static_address_map_unittest.cc index 5ef03455..12c735cf 100644 --- a/src/processor/static_address_map_unittest.cc +++ b/src/processor/static_address_map_unittest.cc @@ -39,13 +39,14 @@ #include #include "breakpad_googletest_includes.h" +#include "common/using_std_string.h" #include "processor/address_map-inl.h" #include "processor/static_address_map-inl.h" #include "processor/simple_serializer-inl.h" #include "map_serializers-inl.h" typedef google_breakpad::StaticAddressMap TestMap; -typedef google_breakpad::AddressMap AddrMap; +typedef google_breakpad::AddressMap AddrMap; class TestStaticAddressMap : public ::testing::Test { protected: @@ -92,8 +93,8 @@ class TestStaticAddressMap : public ::testing::Test { void CompareRetrieveResult(int testcase, int target) { int address; int address_test; - std::string entry; - std::string entry_test; + string entry; + string entry_test; const char *entry_cstring = NULL; bool found; bool found_test; @@ -147,7 +148,7 @@ class TestStaticAddressMap : public ::testing::Test { AddrMap addr_map[kNumberTestCases]; TestMap test_map[kNumberTestCases]; char *map_data[kNumberTestCases]; - google_breakpad::AddressMapSerializer serializer; + google_breakpad::AddressMapSerializer serializer; }; const int TestStaticAddressMap::testsize[] = {0, 1, 6, 1000}; diff --git a/src/processor/synth_minidump.h b/src/processor/synth_minidump.h index 245afe66..531603ad 100644 --- a/src/processor/synth_minidump.h +++ b/src/processor/synth_minidump.h @@ -114,6 +114,7 @@ #include #include "common/test_assembler.h" +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" #include "google_breakpad/common/minidump_format.h" @@ -121,7 +122,6 @@ namespace google_breakpad { namespace SynthMinidump { -using std::string; using test_assembler::Endianness; using test_assembler::kBigEndian; using test_assembler::kLittleEndian; diff --git a/src/processor/synth_minidump_unittest.cc b/src/processor/synth_minidump_unittest.cc index 1ce34ddf..3b905f4b 100644 --- a/src/processor/synth_minidump_unittest.cc +++ b/src/processor/synth_minidump_unittest.cc @@ -36,6 +36,7 @@ #include #include "breakpad_googletest_includes.h" +#include "common/using_std_string.h" #include "google_breakpad/common/minidump_format.h" #include "processor/synth_minidump.h" #include "processor/synth_minidump_unittest_data.h" @@ -54,7 +55,6 @@ using google_breakpad::SynthMinidump::Thread; using google_breakpad::test_assembler::kBigEndian; using google_breakpad::test_assembler::kLittleEndian; using google_breakpad::test_assembler::Label; -using std::string; TEST(Section, Simple) { Dump dump(0); diff --git a/src/processor/tokenize.cc b/src/processor/tokenize.cc index 85f77821..e398c528 100644 --- a/src/processor/tokenize.cc +++ b/src/processor/tokenize.cc @@ -32,9 +32,10 @@ #include #include +#include "common/using_std_string.h" + namespace google_breakpad { -using std::string; using std::vector; bool Tokenize(char *line, diff --git a/src/processor/tokenize.h b/src/processor/tokenize.h index 1562b823..9ff571d5 100644 --- a/src/processor/tokenize.h +++ b/src/processor/tokenize.h @@ -35,6 +35,8 @@ #include #include +#include "common/using_std_string.h" + namespace google_breakpad { // Splits line into at most max_tokens tokens, separated by any of the @@ -49,12 +51,12 @@ namespace google_breakpad { // exact, as opposed to maximum, number of tokens. bool Tokenize(char *line, - const char *separators, - int max_tokens, - std::vector *tokens); + const char *separators, + int max_tokens, + std::vector *tokens); // For convenience, since you need a char* to pass to Tokenize. -// You can call StringToVector on a std::string, and use &vec[0]. -void StringToVector(const std::string &str, std::vector &vec); +// You can call StringToVector on a string, and use &vec[0]. +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 3aa7b3f6..8af4b3f3 100644 --- a/src/processor/windows_frame_info.h +++ b/src/processor/windows_frame_info.h @@ -44,6 +44,7 @@ #include #include +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" #include "processor/logging.h" #include "processor/tokenize.h" @@ -91,7 +92,7 @@ struct WindowsFrameInfo { u_int32_t set_local_size, u_int32_t set_max_stack_size, int set_allocates_base_pointer, - const std::string set_program_string) + const string set_program_string) : type_(type), valid(VALID_ALL), prolog_size(set_prolog_size), @@ -107,7 +108,7 @@ struct WindowsFrameInfo { // a string. Returns NULL if parsing fails, or a new object // 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 std::string string, + static WindowsFrameInfo *ParseFromString(const string string, int &type, u_int64_t &rva, u_int64_t &code_size) { @@ -195,7 +196,7 @@ struct WindowsFrameInfo { // Only one of allocates_base_pointer or program_string will be valid. // If program_string is empty, use allocates_base_pointer. bool allocates_base_pointer; - std::string program_string; + string program_string; }; } // namespace google_breakpad -- cgit v1.2.1