aboutsummaryrefslogtreecommitdiff
path: root/src/common/linux
diff options
context:
space:
mode:
authorivan.penkov@gmail.com <ivan.penkov@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2012-06-28 22:46:01 +0000
committerivan.penkov@gmail.com <ivan.penkov@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2012-06-28 22:46:01 +0000
commit6de969a3040fa31ba60302c66613d1d2e6f5a730 (patch)
treeaad9de34e00834709440f01cb0f54e315989490e /src/common/linux
parentFix Android build of client library (diff)
downloadbreakpad-6de969a3040fa31ba60302c66613d1d2e6f5a730.tar.xz
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
Diffstat (limited to 'src/common/linux')
-rw-r--r--src/common/linux/dump_symbols.cc71
-rw-r--r--src/common/linux/dump_symbols.h6
-rw-r--r--src/common/linux/dump_symbols_unittest.cc6
-rw-r--r--src/common/linux/elf_core_dump_unittest.cc2
-rw-r--r--src/common/linux/elf_symbols_to_module_unittest.cc2
-rw-r--r--src/common/linux/file_id_unittest.cc5
-rw-r--r--src/common/linux/google_crashdump_uploader.cc70
-rw-r--r--src/common/linux/google_crashdump_uploader.h92
-rw-r--r--src/common/linux/google_crashdump_uploader_test.cc17
-rw-r--r--src/common/linux/http_upload.cc2
-rw-r--r--src/common/linux/http_upload.h3
-rw-r--r--src/common/linux/libcurl_wrapper.cc21
-rw-r--r--src/common/linux/libcurl_wrapper.h17
-rw-r--r--src/common/linux/memory_mapped_file_unittest.cc2
-rw-r--r--src/common/linux/synth_elf.cc2
-rw-r--r--src/common/linux/synth_elf.h3
-rw-r--r--src/common/linux/synth_elf_unittest.cc2
-rw-r--r--src/common/linux/tests/crash_generator.cc7
-rw-r--r--src/common/linux/tests/crash_generator.h5
19 files changed, 176 insertions, 159 deletions
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 = &sections[i];
- std::string name = reinterpret_cast<const char *>(section_names->sh_offset +
- section->sh_name);
+ string name = reinterpret_cast<const char *>(section_names->sh_offset +
+ section->sh_name);
const char *contents = reinterpret_cast<const char *>(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<std::string> *register_names) {
+ std::vector<string> *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<std::string> register_names;
+ std::vector<string> register_names;
if (!DwarfCFIRegisterNames(elf_header, &register_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<char *>(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 &section) {
+ void LoadedSection(const string &section) {
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<std::string> loaded_sections_; // Tracks the Loaded ELF sections
+ std::set<string> 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<ElfW(Ehdr) *>(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 <iostream>
#include <string>
+#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 <elf.h>
#include <stdlib.h>
+#include <string>
+
#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 <iostream>
-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 <string>
#include <map>
+#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<std::string, std::string> parameters_;
+ std::map<string, string> 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 <string>
+
#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<std::string, std::string>& parameters,
- std::string* server_response));
+ bool(const string& url,
+ const std::map<string, string>& 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<std::string *>(userp);
+ string *response = reinterpret_cast<string *>(userp);
size_t real_size = size * nmemb;
response->append(reinterpret_cast<char *>(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 <map>
#include <string>
+#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 <string>
#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<std::string *>(userp);
+ string *response = reinterpret_cast<string *>(userp);
size_t real_size = size * nmemb;
response->append(reinterpret_cast<char *>(ptr), real_size);
return real_size;
}
-bool LibcurlWrapper::SendRequest(const std::string& url,
- const std::map<std::string, std::string>& parameters,
- std::string* server_response) {
+bool LibcurlWrapper::SendRequest(const string& url,
+ const std::map<string, string>& parameters,
+ string* server_response) {
(*easy_setopt_)(curl_, CURLOPT_URL, url.c_str());
- std::map<std::string, std::string>::const_iterator iter = parameters.begin();
+ std::map<string, string>::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 <string>
#include <map>
+#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<std::string, std::string>& 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<string, string>& 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 <stdio.h>
#include <string.h>
+#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 <string>
#include <utility>
+#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 <string>
#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