From 704f41ec901c419f8c321742114b415e6f5ceacc Mon Sep 17 00:00:00 2001 From: Ivan Penkov Date: Tue, 30 Aug 2016 14:00:56 -0700 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 BUG= Change-Id: I11f1ce697be23e13f12ea8f0468bbe02fa63c967 Reviewed-on: https://chromium-review.googlesource.com/378159 Reviewed-by: Mark Mentovai --- src/tools/linux/md2core/minidump-2-core.cc | 35 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'src/tools/linux') diff --git a/src/tools/linux/md2core/minidump-2-core.cc b/src/tools/linux/md2core/minidump-2-core.cc index 322bbad6..6f637845 100644 --- a/src/tools/linux/md2core/minidump-2-core.cc +++ b/src/tools/linux/md2core/minidump-2-core.cc @@ -49,6 +49,7 @@ #include "common/linux/memory_mapped_file.h" #include "common/minidump_type_helper.h" #include "common/scoped_ptr.h" +#include "common/using_std_string.h" #include "google_breakpad/common/breakpad_types.h" #include "google_breakpad/common/minidump_format.h" #include "third_party/lss/linux_syscall_support.h" @@ -97,7 +98,7 @@ typedef MDTypeHelper::MDRawLinkMap MDRawLinkMap; static const MDRVA kInvalidMDRVA = static_cast(-1); static bool verbose; -static std::string g_custom_so_basedir; +static string g_custom_so_basedir; static int usage(const char* argv0) { fprintf(stderr, "Usage: %s [-v] \n", argv0); @@ -203,8 +204,8 @@ struct CrashedProcess { uint32_t permissions; uint64_t start_address, end_address, offset; - std::string filename; - std::string data; + string filename; + string data; }; std::map mappings; @@ -238,9 +239,9 @@ struct CrashedProcess { prpsinfo prps; - std::map signatures; + std::map signatures; - std::string dynamic_data; + string dynamic_data; MDRawDebug debug; std::vector link_map; }; @@ -597,8 +598,8 @@ ParseMaps(CrashedProcess* crashinfo, const MinidumpMemoryRange& range) { ptr < range.data() + range.length();) { const uint8_t* eol = (uint8_t*)memchr(ptr, '\n', range.data() + range.length() - ptr); - std::string line((const char*)ptr, - eol ? eol - ptr : range.data() + range.length() - ptr); + string line((const char*)ptr, + eol ? eol - ptr : range.data() + range.length() - ptr); ptr = eol ? eol + 1 : range.data() + range.length(); unsigned long long start, stop, offset; char* permissions = NULL; @@ -875,17 +876,17 @@ ParseModuleStream(CrashedProcess* crashinfo, const MinidumpMemoryRange& range, record->signature.data4[2], record->signature.data4[3], record->signature.data4[4], record->signature.data4[5], record->signature.data4[6], record->signature.data4[7]); - std::string filename = + string filename = full_file.GetAsciiMDString(rawmodule->module_name_rva); size_t slash = filename.find_last_of('/'); - std::string basename = slash == std::string::npos ? - filename : filename.substr(slash + 1); + string basename = slash == string::npos ? + filename : filename.substr(slash + 1); if (strcmp(guid, "00000000-0000-0000-0000-000000000000")) { - std::string prefix; + string prefix; if (!g_custom_so_basedir.empty()) prefix = g_custom_so_basedir; else - prefix = std::string("/var/lib/breakpad/") + guid + "-" + basename; + prefix = string("/var/lib/breakpad/") + guid + "-" + basename; crashinfo->signatures[rawmodule->base_of_image] = prefix + basename; } @@ -904,7 +905,7 @@ ParseModuleStream(CrashedProcess* crashinfo, const MinidumpMemoryRange& range, } static void -AddDataToMapping(CrashedProcess* crashinfo, const std::string& data, +AddDataToMapping(CrashedProcess* crashinfo, const string& data, uintptr_t addr) { for (std::map::iterator iter = crashinfo->mappings.begin(); @@ -960,7 +961,7 @@ AugmentMappings(CrashedProcess* crashinfo, for (unsigned i = 0; i < crashinfo->threads.size(); ++i) { const CrashedProcess::Thread& thread = crashinfo->threads[i]; AddDataToMapping(crashinfo, - std::string((char *)thread.stack, thread.stack_length), + string((char *)thread.stack, thread.stack_length), thread.stack_addr); } @@ -968,7 +969,7 @@ AugmentMappings(CrashedProcess* crashinfo, // the beginning of the address space, as this area should always be // available. static const uintptr_t start_addr = 4096; - std::string data; + string data; struct r_debug debug = { 0 }; debug.r_version = crashinfo->debug.version; debug.r_brk = (ElfW(Addr))crashinfo->debug.brk; @@ -988,11 +989,11 @@ AugmentMappings(CrashedProcess* crashinfo, link_map.l_ld = (ElfW(Dyn)*)iter->ld; link_map.l_prev = prev; prev = (struct link_map*)(start_addr + data.size()); - std::string filename = full_file.GetAsciiMDString(iter->name); + string filename = full_file.GetAsciiMDString(iter->name); // Look up signature for this filename. If available, change filename // to point to GUID, instead. - std::map::const_iterator guid = + std::map::const_iterator guid = crashinfo->signatures.find((uintptr_t)iter->addr); if (guid != crashinfo->signatures.end()) { filename = guid->second; -- cgit v1.2.1