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 <mark@chromium.org>
This commit is contained in:
Ivan Penkov 2016-08-30 14:00:56 -07:00
parent 3fef603b65
commit 704f41ec90
7 changed files with 34 additions and 31 deletions

View file

@ -47,7 +47,8 @@
#include "third_party/musl/include/elf.h"
#include "elf_reader.h"
//#include "using_std_string.h"
#include "common/using_std_string.h"
// EM_AARCH64 is not defined by elf.h of GRTE v3 on x86.
// TODO(dougkwan): Remove this when v17 is retired.
#if !defined(EM_AARCH64)
@ -74,7 +75,6 @@
//DEFINE_bool(elfreader_process_dynsyms, true,
// "Activate PLT function processing");
using std::string;
using std::vector;
namespace {

View file

@ -45,10 +45,9 @@
#include "common/linux/elfutils.h"
#include "common/linux/linux_libc_support.h"
#include "common/linux/memory_mapped_file.h"
#include "common/using_std_string.h"
#include "third_party/lss/linux_syscall_support.h"
using std::string;
namespace google_breakpad {
// Used in a few places for backwards-compatibility.

View file

@ -12,6 +12,7 @@
#include <inttypes.h>
#include <stdio.h>
#include "common/using_std_string.h"
#include "processor/logging.h"
#if defined(OS_ANDROID) && !defined(__LP64__)
@ -25,7 +26,7 @@
namespace google_breakpad {
bool ParseProcMaps(const std::string& input,
bool ParseProcMaps(const string& input,
std::vector<MappedMemoryRegion>* regions_out) {
std::vector<MappedMemoryRegion> regions;
@ -33,8 +34,8 @@ bool ParseProcMaps(const std::string& input,
// this point in time.
// Split the string by newlines.
std::vector<std::string> lines;
std::string l = "";
std::vector<string> lines;
string l = "";
for (size_t i = 0; i < input.size(); i++) {
if (input[i] != '\n' && input[i] != '\r') {
l.push_back(input[i]);

View file

@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "breakpad_googletest_includes.h"
#include "common/using_std_string.h"
#include "google_breakpad/processor/proc_maps_linux.h"
namespace {
@ -227,7 +228,7 @@ TEST(ProcMapsTest, ParseProcMapsEmptyString) {
// - File name has whitespaces.
TEST(ProcMapsTest, ParseProcMapsWeirdCorrectInput) {
std::vector<google_breakpad::MappedMemoryRegion> regions;
const std::string kContents =
const string kContents =
"00400000-0040b000 r-xp 00000000 fc:00 2106562 "
" /bin/cat\r\n"
"7f53b7dad000-7f53b7f62000 r-xp 00000000 fc:00 263011 "

View file

@ -112,10 +112,10 @@ static string StripSeparator(const string &original) {
}
// PrintStackContents prints the stack contents of the current frame to stdout.
static void PrintStackContents(const std::string &indent,
static void PrintStackContents(const string &indent,
const StackFrame *frame,
const StackFrame *prev_frame,
const std::string &cpu,
const string &cpu,
const MemoryRegion *memory,
const CodeModules* modules,
SourceLineResolverInterface *resolver) {
@ -181,7 +181,7 @@ static void PrintStackContents(const std::string &indent,
// Print data in hex.
const int kBytesPerRow = 16;
std::string data_as_string;
string data_as_string;
for (int i = 0; i < kBytesPerRow; ++i, ++address) {
uint8_t value = 0;
if (address < stack_end &&
@ -607,7 +607,7 @@ static void PrintStack(const CallStack *stack,
// Print stack contents.
if (output_stack_contents && frame_index + 1 < frame_count) {
const std::string indent(" ");
const string indent(" ");
PrintStackContents(indent, frame, stack->frames()->at(frame_index + 1),
cpu, memory, modules, resolver);
}

View file

@ -36,14 +36,15 @@
#include <string>
#include "common/stdio_wrapper.h"
#include "common/using_std_string.h"
#include "google_breakpad/common/breakpad_types.h"
#include "google_breakpad/common/minidump_exception_win32.h"
#include "processor/symbolic_constants_win.h"
namespace google_breakpad {
std::string NTStatusToString(uint32_t ntstatus) {
std::string reason;
string NTStatusToString(uint32_t ntstatus) {
string reason;
// The content of this switch was created from ntstatus.h in the 8.1 SDK with
//
// egrep '#define [A-Z_0-9]+\s+\(\(NTSTATUS\)0xC[0-9A-F]+L\)' ntstatus.h

View file

@ -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<sizeof(ElfW(Addr))>::MDRawLinkMap MDRawLinkMap;
static const MDRVA kInvalidMDRVA = static_cast<MDRVA>(-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] <minidump file>\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<uint64_t, Mapping> mappings;
@ -238,9 +239,9 @@ struct CrashedProcess {
prpsinfo prps;
std::map<uintptr_t, std::string> signatures;
std::map<uintptr_t, string> signatures;
std::string dynamic_data;
string dynamic_data;
MDRawDebug debug;
std::vector<MDRawLinkMap> 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<uint64_t, CrashedProcess::Mapping>::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<uintptr_t, std::string>::const_iterator guid =
std::map<uintptr_t, string>::const_iterator guid =
crashinfo->signatures.find((uintptr_t)iter->addr);
if (guid != crashinfo->signatures.end()) {
filename = guid->second;