aboutsummaryrefslogtreecommitdiff
path: root/src/common
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
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')
-rw-r--r--src/common/byte_cursor.h6
-rw-r--r--src/common/byte_cursor_unittest.cc4
-rw-r--r--src/common/dwarf/bytereader_unittest.cc2
-rw-r--r--src/common/dwarf/cfi_assembler.h2
-rw-r--r--src/common/dwarf/dwarf2diehandler.cc9
-rw-r--r--src/common/dwarf/dwarf2diehandler.h6
-rw-r--r--src/common/dwarf/dwarf2diehandler_unittest.cc2
-rw-r--r--src/common/dwarf/dwarf2reader.cc18
-rw-r--r--src/common/dwarf/dwarf2reader.h27
-rw-r--r--src/common/dwarf/dwarf2reader_cfi_unittest.cc2
-rw-r--r--src/common/dwarf/dwarf2reader_die_unittest.cc4
-rw-r--r--src/common/dwarf/functioninfo.cc13
-rw-r--r--src/common/dwarf/functioninfo.h25
-rw-r--r--src/common/dwarf_cfi_to_module.h2
-rw-r--r--src/common/dwarf_cfi_to_module_unittest.cc2
-rw-r--r--src/common/dwarf_cu_to_module.h1
-rw-r--r--src/common/dwarf_cu_to_module_unittest.cc2
-rw-r--r--src/common/dwarf_line_to_module.cc19
-rw-r--r--src/common/dwarf_line_to_module.h9
-rw-r--r--src/common/language.h4
-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
-rw-r--r--src/common/module.h2
-rw-r--r--src/common/module_unittest.cc2
-rw-r--r--src/common/stabs_reader.cc6
-rw-r--r--src/common/stabs_reader.h5
-rw-r--r--src/common/stabs_reader_unittest.cc7
-rw-r--r--src/common/stabs_to_module.cc3
-rw-r--r--src/common/stabs_to_module.h2
-rw-r--r--src/common/string_conversion.cc7
-rw-r--r--src/common/string_conversion.h4
-rw-r--r--src/common/test_assembler.h2
-rw-r--r--src/common/test_assembler_unittest.cc2
-rw-r--r--src/common/tests/auto_tempdir.h9
-rw-r--r--src/common/using_std_string.h65
52 files changed, 359 insertions, 251 deletions
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 <string.h>
#include <string>
+#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<const uint8_t *>(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<const uint8_t *>(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 <string.h>
-#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 <assert.h>
+#include <string>
+
+#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 &current = 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 <stack>
+#include <string>
#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 <map>
#include <memory>
#include <stack>
+#include <string>
#include <utility>
#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<const char *>(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<std::string, std::pair<const char*, uint64> > SectionMap;
+typedef std::map<string, std::pair<const char*, uint64> > SectionMap;
typedef std::list<std::pair<enum DwarfAttribute, enum DwarfForm> >
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 &section = ".debug_frame")
+ Reporter(const string &filename,
+ const string &section = ".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 <memory>
#include "common/dwarf/functioninfo.h"
-
#include "common/dwarf/bytereader.h"
-
+#include "common/using_std_string.h"
namespace dwarf2reader {
CULineInfoHandler::CULineInfoHandler(std::vector<SourceFileInfo>* files,
- std::vector<std::string>* dirs,
+ std::vector<string>* dirs,
LineMap* linemap):linemap_(linemap),
files_(files),
dirs_(dirs) {
@@ -61,13 +60,13 @@ CULineInfoHandler::CULineInfoHandler(std::vector<SourceFileInfo>* 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 <vector>
#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<uint64, FunctionInfo*> FunctionMap;
-typedef std::map<uint64, std::pair<std::string, uint32> > LineMap;
+typedef std::map<uint64, std::pair<string, uint32> > 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<SourceFileInfo>* files,
- std::vector<std::string>* dirs,
+ std::vector<string>* 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<SourceFileInfo>* files_;
- std::vector<std::string>* dirs_;
+ std::vector<string>* dirs_;
};
class CUFunctionInfoHandler: public Dwarf2Handler {
public:
CUFunctionInfoHandler(std::vector<SourceFileInfo>* files,
- std::vector<std::string>* dirs,
+ std::vector<string>* 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<SourceFileInfo>* files_;
- std::vector<std::string>* dirs_;
+ std::vector<string>* 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 <stdio.h>
+#include <string>
+
+#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 <string>
+
#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<uint32, std::string> DirectoryTable;
+ typedef std::map<uint32, string> DirectoryTable;
typedef std::map<uint32, Module::File *> 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 <string>
-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 = &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
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 <string>
#include <vector>
+#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 <stab.h>
#include <string.h>
+#include <string>
+
+#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 <vector>
#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 <iostream>
#include <map>
#include <sstream>
+#include <string>
#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 <algorithm>
#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 <string.h>
+
#include "common/convert_UTF.h"
-#include "processor/scoped_ptr.h"
#include "common/string_conversion.h"
-#include <string.h>
+#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<u_int16_t> *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 <string>
#include <vector>
+
+#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<u_int16_t> *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<u_int16_t> &in, bool swap);
+string UTF16ToUTF8(const vector<u_int16_t> &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 <vector>
#include <string>
+#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 <string>
#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_