mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-01-10 08:28:10 +01:00
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:
parent
93cebf538e
commit
6de969a304
103 changed files with 521 additions and 385 deletions
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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 ¤t = die_handlers_.top();
|
||||
// This had better be an attribute of the DIE we were meant to handle.
|
||||
assert(offset == current.offset_);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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 §ion = ".debug_frame")
|
||||
Reporter(const string &filename,
|
||||
const string §ion = ".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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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_;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 = §ions[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, ®ister_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 §ion) {
|
||||
void LoadedSection(const string §ion) {
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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_;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common/using_std_string.h"
|
||||
|
||||
namespace google_breakpad {
|
||||
namespace synth_elf {
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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_;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 *));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 "common/convert_UTF.h"
|
||||
#include "processor/scoped_ptr.h"
|
||||
#include "common/string_conversion.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "common/convert_UTF.h"
|
||||
#include "common/string_conversion.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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
65
src/common/using_std_string.h
Normal file
65
src/common/using_std_string.h
Normal file
|
|
@ -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_
|
||||
Loading…
Add table
Add a link
Reference in a new issue