From 6de969a3040fa31ba60302c66613d1d2e6f5a730 Mon Sep 17 00:00:00 2001 From: "ivan.penkov@gmail.com" Date: Thu, 28 Jun 2012 22:46:01 +0000 Subject: 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 --- src/common/dwarf/bytereader_unittest.cc | 2 +- src/common/dwarf/cfi_assembler.h | 2 +- src/common/dwarf/dwarf2diehandler.cc | 9 ++++++--- src/common/dwarf/dwarf2diehandler.h | 6 ++++-- src/common/dwarf/dwarf2diehandler_unittest.cc | 2 +- src/common/dwarf/dwarf2reader.cc | 18 ++++++++++-------- src/common/dwarf/dwarf2reader.h | 27 ++++++++++++++------------- src/common/dwarf/dwarf2reader_cfi_unittest.cc | 2 +- src/common/dwarf/dwarf2reader_die_unittest.cc | 4 ++-- src/common/dwarf/functioninfo.cc | 13 ++++++------- src/common/dwarf/functioninfo.h | 25 +++++++++++++------------ 11 files changed, 59 insertions(+), 51 deletions(-) (limited to 'src/common/dwarf') 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 +#include + +#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_); 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 +#include #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 #include #include +#include #include #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(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 > SectionMap; +typedef std::map > SectionMap; typedef std::list > 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 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 #include "common/dwarf/functioninfo.h" - #include "common/dwarf/bytereader.h" - +#include "common/using_std_string.h" namespace dwarf2reader { CULineInfoHandler::CULineInfoHandler(std::vector* files, - std::vector* dirs, + std::vector* dirs, LineMap* linemap):linemap_(linemap), files_(files), dirs_(dirs) { @@ -61,13 +60,13 @@ CULineInfoHandler::CULineInfoHandler(std::vector* 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 #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 FunctionMap; -typedef std::map > LineMap; +typedef std::map > 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* files, - std::vector* dirs, + std::vector* 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* files_; - std::vector* dirs_; + std::vector* dirs_; }; class CUFunctionInfoHandler: public Dwarf2Handler { public: CUFunctionInfoHandler(std::vector* files, - std::vector* dirs, + std::vector* 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* files_; - std::vector* dirs_; + std::vector* dirs_; LineMap* linemap_; FunctionMap* offset_to_funcinfo_; FunctionMap* address_to_funcinfo_; -- cgit v1.2.1