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
This commit is contained in:
ivan.penkov@gmail.com
2012-06-28 22:46:01 +00:00
parent 93cebf538e
commit 6de969a304
103 changed files with 521 additions and 385 deletions

View File

@@ -43,12 +43,11 @@
#include <string>
#include "common/using_std_string.h"
#include "google_breakpad/processor/code_module.h"
namespace google_breakpad {
using std::string;
class BasicCodeModule : public CodeModule {
public:
// Creates a new BasicCodeModule given any existing CodeModule

View File

@@ -32,6 +32,7 @@
#include <string>
#include "breakpad_googletest_includes.h"
#include "common/using_std_string.h"
#include "google_breakpad/processor/basic_source_line_resolver.h"
#include "google_breakpad/processor/code_module.h"
#include "google_breakpad/processor/stack_frame.h"
@@ -44,7 +45,6 @@
namespace {
using std::string;
using google_breakpad::BasicSourceLineResolver;
using google_breakpad::CFIFrameInfo;
using google_breakpad::CodeModule;

View File

@@ -30,15 +30,16 @@
#include <arpa/inet.h>
#include <limits.h>
#include <string>
#include <vector>
#include "common/using_std_string.h"
#include "processor/binarystream.h"
namespace google_breakpad {
using std::string;
using std::vector;
binarystream &binarystream::operator>>(std::string &str) {
binarystream &binarystream::operator>>(string &str) {
u_int16_t length;
*this >> length;
if (eof())
@@ -83,7 +84,7 @@ binarystream &binarystream::operator>>(u_int64_t &u64) {
return *this;
}
binarystream &binarystream::operator<<(const std::string &str) {
binarystream &binarystream::operator<<(const string &str) {
if (str.length() > USHRT_MAX) {
// truncate to 16-bit length
*this << static_cast<u_int16_t>(USHRT_MAX);

View File

@@ -28,8 +28,8 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// binarystream implements part of the std::iostream interface as a
// wrapper around std::stringstream to allow reading and writing
// std::string and integers of known size.
// wrapper around std::stringstream to allow reading and writing strings
// and integers of known size.
#ifndef GOOGLE_BREAKPAD_PROCESSOR_BINARYSTREAM_H_
#define GOOGLE_BREAKPAD_PROCESSOR_BINARYSTREAM_H_
@@ -37,6 +37,7 @@
#include <sstream>
#include <string>
#include "common/using_std_string.h"
#include "google_breakpad/common/breakpad_types.h"
namespace google_breakpad {
@@ -47,21 +48,21 @@ class binarystream {
public:
explicit binarystream(ios_base::openmode which = ios_base::out|ios_base::in)
: stream_(which) {}
explicit binarystream(const std::string &str,
explicit binarystream(const string &str,
ios_base::openmode which = ios_base::out|ios_base::in)
: stream_(str, which) {}
explicit binarystream(const char *str, size_t size,
ios_base::openmode which = ios_base::out|ios_base::in)
: stream_(std::string(str, size), which) {}
: stream_(string(str, size), which) {}
binarystream &operator>>(std::string &str);
binarystream &operator>>(string &str);
binarystream &operator>>(u_int8_t &u8);
binarystream &operator>>(u_int16_t &u16);
binarystream &operator>>(u_int32_t &u32);
binarystream &operator>>(u_int64_t &u64);
// Note: strings are truncated at 65535 characters
binarystream &operator<<(const std::string &str);
binarystream &operator<<(const string &str);
binarystream &operator<<(u_int8_t u8);
binarystream &operator<<(u_int16_t u16);
binarystream &operator<<(u_int32_t u32);
@@ -70,8 +71,8 @@ class binarystream {
// Forward a few methods directly from the stream object
bool eof() const { return stream_.eof(); }
void clear() { stream_.clear(); }
std::string str() const { return stream_.str(); }
void str(const std::string &s) { stream_.str(s); }
string str() const { return stream_.str(); }
void str(const string &s) { stream_.str(s); }
// Seek both read and write pointers to the beginning of the stream.
void rewind() {

View File

@@ -32,11 +32,11 @@
#include <vector>
#include "breakpad_googletest_includes.h"
#include "common/using_std_string.h"
#include "processor/binarystream.h"
namespace {
using std::ios_base;
using std::string;
using std::vector;
using google_breakpad::binarystream;

View File

@@ -41,12 +41,12 @@
#include <map>
#include <string>
#include "common/using_std_string.h"
#include "google_breakpad/common/breakpad_types.h"
namespace google_breakpad {
using std::map;
using std::string;
class MemoryRegion;

View File

@@ -35,6 +35,7 @@
#include <string.h>
#include "breakpad_googletest_includes.h"
#include "common/using_std_string.h"
#include "processor/cfi_frame_info.h"
#include "google_breakpad/processor/memory_region.h"
@@ -43,7 +44,6 @@ using google_breakpad::CFIFrameInfoParseHandler;
using google_breakpad::CFIRuleParser;
using google_breakpad::MemoryRegion;
using google_breakpad::SimpleCFIWalker;
using std::string;
using testing::_;
using testing::A;
using testing::AtMost;

View File

@@ -43,6 +43,7 @@
#include <string>
#include "breakpad_googletest_includes.h"
#include "common/using_std_string.h"
#include "google_breakpad/processor/basic_source_line_resolver.h"
#include "google_breakpad/processor/call_stack.h"
#include "google_breakpad/processor/code_module.h"
@@ -78,7 +79,6 @@ using google_breakpad::MockMinidump;
using google_breakpad::ProcessState;
using google_breakpad::SymbolSupplier;
using google_breakpad::SystemInfo;
using std::string;
class TestSymbolSupplier : public SymbolSupplier {
public:

View File

@@ -41,8 +41,10 @@
#include "processor/fast_source_line_resolver_types.h"
#include <map>
#include <string>
#include <utility>
#include "common/using_std_string.h"
#include "processor/module_factory.h"
#include "processor/scoped_ptr.h"
@@ -125,7 +127,7 @@ WindowsFrameInfo FastSourceLineResolver::CopyWFI(const char *raw) {
u_int32_t max_stack_size = para_uint32[5];
const char *boolean = reinterpret_cast<const char*>(para_uint32 + 6);
bool allocates_base_pointer = (*boolean != 0);
std::string program_string = boolean + 1;
string program_string = boolean + 1;
return WindowsFrameInfo(type,
prolog_size,

View File

@@ -43,6 +43,7 @@
#include <string>
#include "breakpad_googletest_includes.h"
#include "common/using_std_string.h"
#include "google_breakpad/processor/code_module.h"
#include "google_breakpad/processor/stack_frame.h"
#include "google_breakpad/processor/memory_region.h"
@@ -52,7 +53,6 @@
namespace {
using std::string;
using google_breakpad::SourceLineResolverBase;
using google_breakpad::BasicSourceLineResolver;
using google_breakpad::FastSourceLineResolver;

View File

@@ -39,6 +39,9 @@
#include <string.h>
#include <time.h>
#include <string>
#include "common/using_std_string.h"
#include "processor/logging.h"
#include "processor/pathname_stripper.h"
@@ -80,25 +83,25 @@ LogStream::~LogStream() {
stream_ << std::endl;
}
std::string HexString(u_int32_t number) {
string HexString(u_int32_t number) {
char buffer[11];
snprintf(buffer, sizeof(buffer), "0x%x", number);
return std::string(buffer);
return string(buffer);
}
std::string HexString(u_int64_t number) {
string HexString(u_int64_t number) {
char buffer[19];
snprintf(buffer, sizeof(buffer), "0x%" PRIx64, number);
return std::string(buffer);
return string(buffer);
}
std::string HexString(int number) {
string HexString(int number) {
char buffer[19];
snprintf(buffer, sizeof(buffer), "0x%x", number);
return std::string(buffer);
return string(buffer);
}
int ErrnoString(std::string *error_string) {
int ErrnoString(string *error_string) {
assert(error_string);
// strerror isn't necessarily thread-safe. strerror_r would be preferrable,

View File

@@ -60,6 +60,7 @@
#include <iostream>
#include <string>
#include "common/using_std_string.h"
#include "google_breakpad/common/breakpad_types.h"
#ifdef BP_LOGGING_INCLUDE
@@ -118,14 +119,14 @@ class LogMessageVoidify {
};
// Returns number formatted as a hexadecimal string, such as "0x7b".
std::string HexString(u_int32_t number);
std::string HexString(u_int64_t number);
std::string HexString(int number);
string HexString(u_int32_t number);
string HexString(u_int64_t number);
string HexString(int number);
// Returns the error code as set in the global errno variable, and sets
// error_string, a required argument, to a string describing that error
// code.
int ErrnoString(std::string *error_string);
int ErrnoString(string *error_string);
} // namespace google_breakpad

View File

@@ -3079,13 +3079,13 @@ bool MinidumpSystemInfo::Read(u_int32_t expected_size) {
string MinidumpSystemInfo::GetOS() {
string os;
if (!valid_) {
BPLOG(ERROR) << "Invalid MinidumpSystemInfo for GetOS";
return NULL;
return os;
}
string os;
switch (system_info_.platform_id) {
case MD_OS_WIN32_NT:
case MD_OS_WIN32_WINDOWS:

View File

@@ -39,6 +39,7 @@
#include <utility>
#include "breakpad_googletest_includes.h"
#include "common/using_std_string.h"
#include "google_breakpad/processor/basic_source_line_resolver.h"
#include "google_breakpad/processor/call_stack.h"
#include "google_breakpad/processor/code_module.h"
@@ -79,7 +80,6 @@ using google_breakpad::ProcessState;
using google_breakpad::scoped_ptr;
using google_breakpad::SymbolSupplier;
using google_breakpad::SystemInfo;
using std::string;
using ::testing::_;
using ::testing::Mock;
using ::testing::Ne;
@@ -165,8 +165,8 @@ SymbolSupplier::SymbolResult TestSymbolSupplier::GetSymbolFile(
symbol_file);
if (s == FOUND) {
std::ifstream in(symbol_file->c_str());
std::getline(in, *symbol_data, std::string::traits_type::to_char_type(
std::string::traits_type::eof()));
std::getline(in, *symbol_data, string::traits_type::to_char_type(
string::traits_type::eof()));
in.close();
}

View File

@@ -39,6 +39,7 @@
#include <string>
#include <vector>
#include "common/using_std_string.h"
#include "google_breakpad/processor/basic_source_line_resolver.h"
#include "google_breakpad/processor/call_stack.h"
#include "google_breakpad/processor/code_module.h"
@@ -54,7 +55,6 @@
namespace {
using std::string;
using std::vector;
using google_breakpad::BasicSourceLineResolver;
using google_breakpad::CallStack;
@@ -575,7 +575,7 @@ int main(int argc, char **argv) {
}
// extra arguments are symbol paths
std::vector<std::string> symbol_paths;
std::vector<string> symbol_paths;
if (argc > symbol_path_arg) {
for (int argi = symbol_path_arg; argi < argc; ++argi)
symbol_paths.push_back(argv[argi]);

View File

@@ -36,7 +36,9 @@
#include <stdlib.h>
#include <string>
#include <vector>
#include "breakpad_googletest_includes.h"
#include "common/using_std_string.h"
#include "google_breakpad/common/minidump_format.h"
#include "google_breakpad/processor/minidump.h"
#include "processor/logging.h"
@@ -69,7 +71,6 @@ using google_breakpad::test_assembler::kBigEndian;
using google_breakpad::test_assembler::kLittleEndian;
using std::ifstream;
using std::istringstream;
using std::string;
using std::vector;
using ::testing::Return;

View File

@@ -36,9 +36,9 @@
#include <string>
namespace google_breakpad {
#include "common/using_std_string.h"
using std::string;
namespace google_breakpad {
class PathnameStripper {
public:

View File

@@ -74,10 +74,11 @@
#include <string>
#include <vector>
#include "common/using_std_string.h"
namespace google_breakpad {
using std::map;
using std::string;
using std::vector;
class MemoryRegion;

View File

@@ -38,6 +38,7 @@
#include "processor/postfix_evaluator-inl.h"
#include "common/using_std_string.h"
#include "google_breakpad/common/breakpad_types.h"
#include "google_breakpad/processor/memory_region.h"
#include "processor/logging.h"
@@ -47,7 +48,6 @@ namespace {
using std::map;
using std::string;
using google_breakpad::MemoryRegion;
using google_breakpad::PostfixEvaluator;

View File

@@ -44,6 +44,7 @@
#include <iostream>
#include <fstream>
#include "common/using_std_string.h"
#include "google_breakpad/processor/code_module.h"
#include "google_breakpad/processor/system_info.h"
#include "processor/logging.h"
@@ -87,8 +88,8 @@ SymbolSupplier::SymbolResult SimpleSymbolSupplier::GetSymbolFile(
if (s == FOUND) {
std::ifstream in(symbol_file->c_str());
std::getline(in, *symbol_data, std::string::traits_type::to_char_type(
std::string::traits_type::eof()));
std::getline(in, *symbol_data, string::traits_type::to_char_type(
string::traits_type::eof()));
in.close();
}
return s;

View File

@@ -80,12 +80,12 @@
#include <string>
#include <vector>
#include "common/using_std_string.h"
#include "google_breakpad/processor/symbol_supplier.h"
namespace google_breakpad {
using std::map;
using std::string;
using std::vector;
class CodeModule;

View File

@@ -37,6 +37,7 @@
#include "breakpad_googletest_includes.h"
#include "common/test_assembler.h"
#include "common/using_std_string.h"
#include "google_breakpad/common/minidump_format.h"
#include "google_breakpad/processor/basic_source_line_resolver.h"
#include "google_breakpad/processor/call_stack.h"
@@ -54,7 +55,6 @@ using google_breakpad::SystemInfo;
using google_breakpad::test_assembler::kLittleEndian;
using google_breakpad::test_assembler::Label;
using google_breakpad::test_assembler::Section;
using std::string;
using std::vector;
using testing::_;
using testing::Return;

View File

@@ -37,6 +37,7 @@
#include "breakpad_googletest_includes.h"
#include "common/test_assembler.h"
#include "common/using_std_string.h"
#include "google_breakpad/common/minidump_format.h"
#include "google_breakpad/processor/basic_source_line_resolver.h"
#include "google_breakpad/processor/call_stack.h"
@@ -56,7 +57,6 @@ using google_breakpad::WindowsFrameInfo;
using google_breakpad::test_assembler::kLittleEndian;
using google_breakpad::test_assembler::Label;
using google_breakpad::test_assembler::Section;
using std::string;
using std::vector;
using testing::_;
using testing::Return;

View File

@@ -40,6 +40,7 @@
#include <string>
#include <vector>
#include "common/using_std_string.h"
#include "google_breakpad/common/breakpad_types.h"
#include "google_breakpad/processor/code_module.h"
#include "google_breakpad/processor/code_modules.h"
@@ -54,7 +55,7 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion {
// Set this region's address and contents. If we have placed an
// instance of this class in a test fixture class, individual tests
// can use this to provide the region's contents.
void Init(u_int64_t base_address, const std::string &contents) {
void Init(u_int64_t base_address, const string &contents) {
base_address_ = base_address;
contents_ = contents;
}
@@ -93,22 +94,22 @@ class MockMemoryRegion: public google_breakpad::MemoryRegion {
}
u_int64_t base_address_;
std::string contents_;
string contents_;
};
class MockCodeModule: public google_breakpad::CodeModule {
public:
MockCodeModule(u_int64_t base_address, u_int64_t size,
const std::string &code_file, const std::string &version)
const string &code_file, const string &version)
: base_address_(base_address), size_(size), code_file_(code_file) { }
u_int64_t base_address() const { return base_address_; }
u_int64_t size() const { return size_; }
std::string code_file() const { return code_file_; }
std::string code_identifier() const { return code_file_; }
std::string debug_file() const { return code_file_; }
std::string debug_identifier() const { return code_file_; }
std::string version() const { return version_; }
string code_file() const { return code_file_; }
string code_identifier() const { return code_file_; }
string debug_file() const { return code_file_; }
string debug_identifier() const { return code_file_; }
string version() const { return version_; }
const google_breakpad::CodeModule *Copy() const {
abort(); // Tests won't use this.
}
@@ -116,8 +117,8 @@ class MockCodeModule: public google_breakpad::CodeModule {
private:
u_int64_t base_address_;
u_int64_t size_;
std::string code_file_;
std::string version_;
string code_file_;
string version_;
};
class MockCodeModules: public google_breakpad::CodeModules {
@@ -165,14 +166,14 @@ class MockSymbolSupplier: public google_breakpad::SymbolSupplier {
typedef google_breakpad::SystemInfo SystemInfo;
MOCK_METHOD3(GetSymbolFile, SymbolResult(const CodeModule *module,
const SystemInfo *system_info,
std::string *symbol_file));
string *symbol_file));
MOCK_METHOD4(GetSymbolFile, SymbolResult(const CodeModule *module,
const SystemInfo *system_info,
std::string *symbol_file,
std::string *symbol_data));
string *symbol_file,
string *symbol_data));
MOCK_METHOD4(GetCStringSymbolData, SymbolResult(const CodeModule *module,
const SystemInfo *system_info,
std::string *symbol_file,
string *symbol_file,
char **symbol_data));
MOCK_METHOD1(FreeSymbolData, void(const CodeModule *module));
};

View File

@@ -36,6 +36,7 @@
#include "breakpad_googletest_includes.h"
#include "common/test_assembler.h"
#include "common/using_std_string.h"
#include "google_breakpad/common/minidump_format.h"
#include "google_breakpad/processor/basic_source_line_resolver.h"
#include "google_breakpad/processor/call_stack.h"
@@ -55,7 +56,6 @@ using google_breakpad::WindowsFrameInfo;
using google_breakpad::test_assembler::kLittleEndian;
using google_breakpad::test_assembler::Label;
using google_breakpad::test_assembler::Section;
using std::string;
using std::vector;
using testing::_;
using testing::Return;

View File

@@ -39,13 +39,14 @@
#include <sstream>
#include "breakpad_googletest_includes.h"
#include "common/using_std_string.h"
#include "processor/address_map-inl.h"
#include "processor/static_address_map-inl.h"
#include "processor/simple_serializer-inl.h"
#include "map_serializers-inl.h"
typedef google_breakpad::StaticAddressMap<int, char> TestMap;
typedef google_breakpad::AddressMap<int, std::string> AddrMap;
typedef google_breakpad::AddressMap<int, string> AddrMap;
class TestStaticAddressMap : public ::testing::Test {
protected:
@@ -92,8 +93,8 @@ class TestStaticAddressMap : public ::testing::Test {
void CompareRetrieveResult(int testcase, int target) {
int address;
int address_test;
std::string entry;
std::string entry_test;
string entry;
string entry_test;
const char *entry_cstring = NULL;
bool found;
bool found_test;
@@ -147,7 +148,7 @@ class TestStaticAddressMap : public ::testing::Test {
AddrMap addr_map[kNumberTestCases];
TestMap test_map[kNumberTestCases];
char *map_data[kNumberTestCases];
google_breakpad::AddressMapSerializer<int, std::string> serializer;
google_breakpad::AddressMapSerializer<int, string> serializer;
};
const int TestStaticAddressMap::testsize[] = {0, 1, 6, 1000};

View File

@@ -114,6 +114,7 @@
#include <string>
#include "common/test_assembler.h"
#include "common/using_std_string.h"
#include "google_breakpad/common/breakpad_types.h"
#include "google_breakpad/common/minidump_format.h"
@@ -121,7 +122,6 @@ namespace google_breakpad {
namespace SynthMinidump {
using std::string;
using test_assembler::Endianness;
using test_assembler::kBigEndian;
using test_assembler::kLittleEndian;

View File

@@ -36,6 +36,7 @@
#include <string>
#include "breakpad_googletest_includes.h"
#include "common/using_std_string.h"
#include "google_breakpad/common/minidump_format.h"
#include "processor/synth_minidump.h"
#include "processor/synth_minidump_unittest_data.h"
@@ -54,7 +55,6 @@ using google_breakpad::SynthMinidump::Thread;
using google_breakpad::test_assembler::kBigEndian;
using google_breakpad::test_assembler::kLittleEndian;
using google_breakpad::test_assembler::Label;
using std::string;
TEST(Section, Simple) {
Dump dump(0);

View File

@@ -32,9 +32,10 @@
#include <string>
#include <vector>
#include "common/using_std_string.h"
namespace google_breakpad {
using std::string;
using std::vector;
bool Tokenize(char *line,

View File

@@ -35,6 +35,8 @@
#include <string>
#include <vector>
#include "common/using_std_string.h"
namespace google_breakpad {
// Splits line into at most max_tokens tokens, separated by any of the
@@ -49,12 +51,12 @@ namespace google_breakpad {
// exact, as opposed to maximum, number of tokens.
bool Tokenize(char *line,
const char *separators,
int max_tokens,
std::vector<char*> *tokens);
const char *separators,
int max_tokens,
std::vector<char*> *tokens);
// For convenience, since you need a char* to pass to Tokenize.
// You can call StringToVector on a std::string, and use &vec[0].
void StringToVector(const std::string &str, std::vector<char> &vec);
// You can call StringToVector on a string, and use &vec[0].
void StringToVector(const string &str, std::vector<char> &vec);
} // namespace google_breakpad

View File

@@ -44,6 +44,7 @@
#include <string>
#include <vector>
#include "common/using_std_string.h"
#include "google_breakpad/common/breakpad_types.h"
#include "processor/logging.h"
#include "processor/tokenize.h"
@@ -91,7 +92,7 @@ struct WindowsFrameInfo {
u_int32_t set_local_size,
u_int32_t set_max_stack_size,
int set_allocates_base_pointer,
const std::string set_program_string)
const string set_program_string)
: type_(type),
valid(VALID_ALL),
prolog_size(set_prolog_size),
@@ -107,7 +108,7 @@ struct WindowsFrameInfo {
// a string. Returns NULL if parsing fails, or a new object
// otherwise. type, rva and code_size are present in the STACK line,
// but not the StackFrameInfo structure, so return them as outparams.
static WindowsFrameInfo *ParseFromString(const std::string string,
static WindowsFrameInfo *ParseFromString(const string string,
int &type,
u_int64_t &rva,
u_int64_t &code_size) {
@@ -195,7 +196,7 @@ struct WindowsFrameInfo {
// Only one of allocates_base_pointer or program_string will be valid.
// If program_string is empty, use allocates_base_pointer.
bool allocates_base_pointer;
std::string program_string;
string program_string;
};
} // namespace google_breakpad