Remove "using namespace std" from dwarf2reader.h. Using-directives are

forbidden by the style guide, and are bad practice in headers even under
style rules that tolerate this construct.

This fixes warnings such as:

In file included from dwarf2reader.cc:34:
dwarf2reader.h:53:17: warning: using namespace directive in global context in header [-Wheader-hygiene]
Review URL: http://breakpad.appspot.com/312002

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@862 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
mark@chromium.org 2011-10-11 17:59:03 +00:00
parent 29b0d713c9
commit bc582f782b
5 changed files with 41 additions and 40 deletions

View file

@ -176,7 +176,7 @@ void DIEDispatcher::ProcessAttributeBuffer(uint64 offset,
void DIEDispatcher::ProcessAttributeString(uint64 offset, void DIEDispatcher::ProcessAttributeString(uint64 offset,
enum DwarfAttribute attr, enum DwarfAttribute attr,
enum DwarfForm form, enum DwarfForm form,
const string& data) { const std::string& data) {
HandlerStack &current = die_handlers_.top(); HandlerStack &current = die_handlers_.top();
// This had better be an attribute of the DIE we were meant to handle. // This had better be an attribute of the DIE we were meant to handle.
assert(offset == current.offset_); assert(offset == current.offset_);

View file

@ -208,7 +208,7 @@ class DIEHandler {
uint64 len) { } uint64 len) { }
virtual void ProcessAttributeString(enum DwarfAttribute attr, virtual void ProcessAttributeString(enum DwarfAttribute attr,
enum DwarfForm form, enum DwarfForm form,
const string& data) { } const std::string& data) { }
// Once we have reported all the DIE's attributes' values, we call // Once we have reported all the DIE's attributes' values, we call
// this member function. If it returns false, we skip all the DIE's // this member function. If it returns false, we skip all the DIE's
@ -313,7 +313,7 @@ class DIEDispatcher: public Dwarf2Handler {
void ProcessAttributeString(uint64 offset, void ProcessAttributeString(uint64 offset,
enum DwarfAttribute attr, enum DwarfAttribute attr,
enum DwarfForm form, enum DwarfForm form,
const string &data); const std::string &data);
void EndDIE(uint64 offset); void EndDIE(uint64 offset);
private: private:
@ -347,7 +347,7 @@ class DIEDispatcher: public Dwarf2Handler {
// - When we decide to ignore a subtree, we only push an entry on // - When we decide to ignore a subtree, we only push an entry on
// the stack for the root of the tree being ignored, rather than // the stack for the root of the tree being ignored, rather than
// pushing lots of stack entries with handler_ set to NULL. // pushing lots of stack entries with handler_ set to NULL.
stack<HandlerStack> die_handlers_; std::stack<HandlerStack> die_handlers_;
// The root handler. We don't push it on die_handlers_ until we // The root handler. We don't push it on die_handlers_ until we
// actually get the StartDIE call for the root. // actually get the StartDIE call for the root.

View file

@ -74,7 +74,7 @@ void CompilationUnit::ReadAbbrevs() {
iter = sections_.find("__debug_abbrev"); iter = sections_.find("__debug_abbrev");
assert(iter != sections_.end()); assert(iter != sections_.end());
abbrevs_ = new vector<Abbrev>; abbrevs_ = new std::vector<Abbrev>;
abbrevs_->resize(1); abbrevs_->resize(1);
// The only way to check whether we are reading over the end of the // The only way to check whether we are reading over the end of the
@ -121,7 +121,7 @@ void CompilationUnit::ReadAbbrevs() {
const enum DwarfAttribute name = const enum DwarfAttribute name =
static_cast<enum DwarfAttribute>(nametemp); static_cast<enum DwarfAttribute>(nametemp);
const enum DwarfForm form = static_cast<enum DwarfForm>(formtemp); const enum DwarfForm form = static_cast<enum DwarfForm>(formtemp);
abbrev.attributes.push_back(make_pair(name, form)); abbrev.attributes.push_back(std::make_pair(name, form));
} }
assert(abbrev.number == abbrevs_->size()); assert(abbrev.number == abbrevs_->size());
abbrevs_->push_back(abbrev); abbrevs_->push_back(abbrev);
@ -493,7 +493,7 @@ void CompilationUnit::ProcessDIEs() {
else else
lengthstart += 4; lengthstart += 4;
stack<uint64> die_stack; std::stack<uint64> die_stack;
while (dieptr < (lengthstart + header_.length)) { while (dieptr < (lengthstart + header_.length)) {
// We give the user the absolute offset from the beginning of // We give the user the absolute offset from the beginning of
@ -583,7 +583,7 @@ void LineInfo::ReadHeader() {
header_.opcode_base = reader_->ReadOneByte(lineptr); header_.opcode_base = reader_->ReadOneByte(lineptr);
lineptr += 1; lineptr += 1;
header_.std_opcode_lengths = new vector<unsigned char>; header_.std_opcode_lengths = new std::vector<unsigned char>;
header_.std_opcode_lengths->resize(header_.opcode_base + 1); header_.std_opcode_lengths->resize(header_.opcode_base + 1);
(*header_.std_opcode_lengths)[0] = 0; (*header_.std_opcode_lengths)[0] = 0;
for (int i = 1; i < header_.opcode_base; i++) { for (int i = 1; i < header_.opcode_base; i++) {
@ -1024,7 +1024,7 @@ class CallFrameInfo::RegisterRule: public CallFrameInfo::Rule {
// Rule: EXPRESSION evaluates to the address at which the register is saved. // Rule: EXPRESSION evaluates to the address at which the register is saved.
class CallFrameInfo::ExpressionRule: public CallFrameInfo::Rule { class CallFrameInfo::ExpressionRule: public CallFrameInfo::Rule {
public: public:
explicit ExpressionRule(const string &expression) explicit ExpressionRule(const std::string &expression)
: expression_(expression) { } : expression_(expression) { }
~ExpressionRule() { } ~ExpressionRule() { }
bool Handle(Handler *handler, uint64 address, int reg) const { bool Handle(Handler *handler, uint64 address, int reg) const {
@ -1038,13 +1038,13 @@ class CallFrameInfo::ExpressionRule: public CallFrameInfo::Rule {
} }
Rule *Copy() const { return new ExpressionRule(*this); } Rule *Copy() const { return new ExpressionRule(*this); }
private: private:
string expression_; std::string expression_;
}; };
// Rule: EXPRESSION evaluates to the address at which the register is saved. // Rule: EXPRESSION evaluates to the address at which the register is saved.
class CallFrameInfo::ValExpressionRule: public CallFrameInfo::Rule { class CallFrameInfo::ValExpressionRule: public CallFrameInfo::Rule {
public: public:
explicit ValExpressionRule(const string &expression) explicit ValExpressionRule(const std::string &expression)
: expression_(expression) { } : expression_(expression) { }
~ValExpressionRule() { } ~ValExpressionRule() { }
bool Handle(Handler *handler, uint64 address, int reg) const { bool Handle(Handler *handler, uint64 address, int reg) const {
@ -1059,7 +1059,7 @@ class CallFrameInfo::ValExpressionRule: public CallFrameInfo::Rule {
} }
Rule *Copy() const { return new ValExpressionRule(*this); } Rule *Copy() const { return new ValExpressionRule(*this); }
private: private:
string expression_; std::string expression_;
}; };
// A map from register numbers to rules. // A map from register numbers to rules.
@ -1096,7 +1096,7 @@ class CallFrameInfo::RuleMap {
private: private:
// A map from register numbers to Rules. // A map from register numbers to Rules.
typedef map<int, Rule *> RuleByNumber; typedef std::map<int, Rule *> RuleByNumber;
// Remove all register rules and clear cfa_rule_. // Remove all register rules and clear cfa_rule_.
void Clear(); void Clear();
@ -1240,7 +1240,7 @@ class CallFrameInfo::State {
unsigned register_number; // A register number. unsigned register_number; // A register number.
uint64 offset; // An offset or address. uint64 offset; // An offset or address.
long signed_offset; // A signed offset. long signed_offset; // A signed offset.
string expression; // A DWARF expression. std::string expression; // A DWARF expression.
}; };
// Parse CFI instruction operands from STATE's instruction stream as // Parse CFI instruction operands from STATE's instruction stream as
@ -1341,7 +1341,7 @@ class CallFrameInfo::State {
// A stack of saved states, for DW_CFA_remember_state and // A stack of saved states, for DW_CFA_remember_state and
// DW_CFA_restore_state. // DW_CFA_restore_state.
stack<RuleMap> saved_rules_; std::stack<RuleMap> saved_rules_;
}; };
bool CallFrameInfo::State::InterpretCIE(const CIE &cie) { bool CallFrameInfo::State::InterpretCIE(const CIE &cie) {
@ -1427,7 +1427,7 @@ bool CallFrameInfo::State::ParseOperands(const char *format,
if (len > bytes_left || expression_length > bytes_left - len) if (len > bytes_left || expression_length > bytes_left - len)
return ReportIncomplete(); return ReportIncomplete();
cursor_ += len; cursor_ += len;
operands->expression = string(cursor_, expression_length); operands->expression = std::string(cursor_, expression_length);
cursor_ += expression_length; cursor_ += expression_length;
break; break;
} }
@ -1898,7 +1898,8 @@ bool CallFrameInfo::ReadCIEFields(CIE *cie) {
memchr(augmentation_start, '\0', cie->end - augmentation_start); memchr(augmentation_start, '\0', cie->end - augmentation_start);
if (! augmentation_end) return ReportIncomplete(cie); if (! augmentation_end) return ReportIncomplete(cie);
cursor = static_cast<const char *>(augmentation_end); cursor = static_cast<const char *>(augmentation_end);
cie->augmentation = string(augmentation_start, cursor - augmentation_start); cie->augmentation = std::string(augmentation_start,
cursor - augmentation_start);
// Skip the terminating '\0'. // Skip the terminating '\0'.
cursor++; cursor++;
@ -2285,7 +2286,7 @@ void CallFrameInfo::Reporter::UnrecognizedVersion(uint64 offset, int version) {
} }
void CallFrameInfo::Reporter::UnrecognizedAugmentation(uint64 offset, void CallFrameInfo::Reporter::UnrecognizedAugmentation(uint64 offset,
const string &aug) { const std::string &aug) {
fprintf(stderr, fprintf(stderr,
"%s: CFI frame description entry at offset 0x%llx in '%s':" "%s: CFI frame description entry at offset 0x%llx in '%s':"
" CIE specifies unrecognized augmentation: '%s'\n", " CIE specifies unrecognized augmentation: '%s'\n",

View file

@ -50,8 +50,6 @@
#include "common/dwarf/dwarf2enums.h" #include "common/dwarf/dwarf2enums.h"
#include "common/dwarf/types.h" #include "common/dwarf/types.h"
using namespace std;
namespace dwarf2reader { namespace dwarf2reader {
struct LineStateMachine; struct LineStateMachine;
class Dwarf2Handler; class Dwarf2Handler;
@ -59,8 +57,9 @@ class LineInfoHandler;
// This maps from a string naming a section to a pair containing a // This maps from a string naming a section to a pair containing a
// the data for the section, and the size of the section. // the data for the section, and the size of the section.
typedef map<string, pair<const char*, uint64> > SectionMap; typedef std::map<std::string, std::pair<const char*, uint64> > SectionMap;
typedef list<pair<enum DwarfAttribute, enum DwarfForm> > AttributeList; typedef std::list<std::pair<enum DwarfAttribute, enum DwarfForm> >
AttributeList;
typedef AttributeList::iterator AttributeIterator; typedef AttributeList::iterator AttributeIterator;
typedef AttributeList::const_iterator ConstAttributeIterator; typedef AttributeList::const_iterator ConstAttributeIterator;
@ -75,7 +74,7 @@ struct LineInfoHeader {
uint8 opcode_base; uint8 opcode_base;
// Use a pointer so that signalsafe_addr2line is able to use this structure // Use a pointer so that signalsafe_addr2line is able to use this structure
// without heap allocation problem. // without heap allocation problem.
vector<unsigned char> *std_opcode_lengths; std::vector<unsigned char> *std_opcode_lengths;
}; };
class LineInfo { class LineInfo {
@ -157,7 +156,7 @@ class LineInfoHandler {
// Called when we define a directory. NAME is the directory name, // Called when we define a directory. NAME is the directory name,
// DIR_NUM is the directory number // DIR_NUM is the directory number
virtual void DefineDir(const string& name, uint32 dir_num) { } virtual void DefineDir(const std::string& name, uint32 dir_num) { }
// Called when we define a filename. NAME is the filename, FILE_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 // is the file number which is -1 if the file index is the next
@ -166,7 +165,7 @@ class LineInfoHandler {
// directory index for the directory name of this file, MOD_TIME is // 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 modification time of the file, and LENGTH is the length of
// the file // the file
virtual void DefineFile(const string& name, int32 file_num, virtual void DefineFile(const std::string& name, int32 file_num,
uint32 dir_num, uint64 mod_time, uint32 dir_num, uint64 mod_time,
uint64 length) { } uint64 length) { }
@ -313,7 +312,7 @@ class CompilationUnit {
// Set of DWARF2/3 abbreviations for this compilation unit. Indexed // Set of DWARF2/3 abbreviations for this compilation unit. Indexed
// by abbreviation number, which means that abbrevs_[0] is not // by abbreviation number, which means that abbrevs_[0] is not
// valid. // valid.
vector<Abbrev>* abbrevs_; std::vector<Abbrev>* abbrevs_;
// String section buffer and length, if we have a string section. // String section buffer and length, if we have a string section.
// This is here to avoid doing a section lookup for strings in // This is here to avoid doing a section lookup for strings in
@ -392,7 +391,7 @@ class Dwarf2Handler {
virtual void ProcessAttributeString(uint64 offset, virtual void ProcessAttributeString(uint64 offset,
enum DwarfAttribute attr, enum DwarfAttribute attr,
enum DwarfForm form, enum DwarfForm form,
const string& data) { } const std::string& data) { }
// Called when finished processing the DIE at OFFSET. // Called when finished processing the DIE at OFFSET.
// Because DWARF2/3 specifies a tree of DIEs, you may get starts // Because DWARF2/3 specifies a tree of DIEs, you may get starts
@ -691,7 +690,7 @@ class CallFrameInfo {
// A common information entry (CIE). // A common information entry (CIE).
struct CIE: public Entry { struct CIE: public Entry {
uint8 version; // CFI data version number uint8 version; // CFI data version number
string augmentation; // vendor format extension markers std::string augmentation; // vendor format extension markers
uint64 code_alignment_factor; // scale for code address adjustments uint64 code_alignment_factor; // scale for code address adjustments
int data_alignment_factor; // scale for stack pointer adjustments int data_alignment_factor; // scale for stack pointer adjustments
unsigned return_address_register; // which register holds the return addr unsigned return_address_register; // which register holds the return addr
@ -825,7 +824,7 @@ class CallFrameInfo::Handler {
// process a given FDE, the parser reiterates the appropriate CIE's // process a given FDE, the parser reiterates the appropriate CIE's
// contents at the beginning of the FDE's rules. // contents at the beginning of the FDE's rules.
virtual bool Entry(size_t offset, uint64 address, uint64 length, virtual bool Entry(size_t offset, uint64 address, uint64 length,
uint8 version, const string &augmentation, uint8 version, const std::string &augmentation,
unsigned return_address) = 0; unsigned return_address) = 0;
// When the Entry function returns true, the parser calls these // When the Entry function returns true, the parser calls these
@ -874,13 +873,13 @@ class CallFrameInfo::Handler {
// At ADDRESS, the DWARF expression EXPRESSION yields the address at // At ADDRESS, the DWARF expression EXPRESSION yields the address at
// which REG was saved. // which REG was saved.
virtual bool ExpressionRule(uint64 address, int reg, virtual bool ExpressionRule(uint64 address, int reg,
const string &expression) = 0; const std::string &expression) = 0;
// At ADDRESS, the DWARF expression EXPRESSION yields the caller's // At ADDRESS, the DWARF expression EXPRESSION yields the caller's
// value for REG. (This rule doesn't provide an address at which the // value for REG. (This rule doesn't provide an address at which the
// register's value is saved.) // register's value is saved.)
virtual bool ValExpressionRule(uint64 address, int reg, virtual bool ValExpressionRule(uint64 address, int reg,
const string &expression) = 0; const std::string &expression) = 0;
// Indicate that the rules for the address range reported by the // Indicate that the rules for the address range reported by the
// last call to Entry are complete. End should return true if // last call to Entry are complete. End should return true if
@ -957,8 +956,8 @@ class CallFrameInfo::Reporter {
// in a Mach-O section named __debug_frame. If we support // in a Mach-O section named __debug_frame. If we support
// Linux-style exception handling data, we could be reading an // Linux-style exception handling data, we could be reading an
// .eh_frame section. // .eh_frame section.
Reporter(const string &filename, Reporter(const std::string &filename,
const string &section = ".debug_frame") const std::string &section = ".debug_frame")
: filename_(filename), section_(section) { } : filename_(filename), section_(section) { }
virtual ~Reporter() { } virtual ~Reporter() { }
@ -990,7 +989,7 @@ class CallFrameInfo::Reporter {
// which we don't recognize. We cannot parse DWARF CFI if it uses // which we don't recognize. We cannot parse DWARF CFI if it uses
// augmentations we don't recognize. // augmentations we don't recognize.
virtual void UnrecognizedAugmentation(uint64 offset, virtual void UnrecognizedAugmentation(uint64 offset,
const string &augmentation); const std::string &augmentation);
// The pointer encoding ENCODING, specified by the CIE at OFFSET, is not // The pointer encoding ENCODING, specified by the CIE at OFFSET, is not
// a valid encoding. // a valid encoding.
@ -1031,10 +1030,10 @@ class CallFrameInfo::Reporter {
protected: protected:
// The name of the file whose CFI we're reading. // The name of the file whose CFI we're reading.
string filename_; std::string filename_;
// The name of the CFI section in that file. // The name of the CFI section in that file.
string section_; std::string section_;
}; };
} // namespace dwarf2reader } // namespace dwarf2reader

View file

@ -41,13 +41,14 @@
// it until we actually have to deal with DWARF on Windows. // it until we actually have to deal with DWARF on Windows.
// Return true if PATH is an absolute path, false if it is relative. // Return true if PATH is an absolute path, false if it is relative.
static bool PathIsAbsolute(const string &path) { static bool PathIsAbsolute(const std::string &path) {
return (path.size() >= 1 && path[0] == '/'); return (path.size() >= 1 && path[0] == '/');
} }
// If PATH is an absolute path, return PATH. If PATH is a relative path, // 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. // treat it as relative to BASE and return the combined path.
static string ExpandPath(const string &path, const string &base) { static std::string ExpandPath(const std::string &path,
const std::string &base) {
if (PathIsAbsolute(path)) if (PathIsAbsolute(path))
return path; return path;
return base + "/" + path; return base + "/" + path;
@ -55,14 +56,14 @@ static string ExpandPath(const string &path, const string &base) {
namespace google_breakpad { namespace google_breakpad {
void DwarfLineToModule::DefineDir(const string &name, uint32 dir_num) { void DwarfLineToModule::DefineDir(const std::string &name, uint32 dir_num) {
// Directory number zero is reserved to mean the compilation // Directory number zero is reserved to mean the compilation
// directory. Silently ignore attempts to redefine it. // directory. Silently ignore attempts to redefine it.
if (dir_num != 0) if (dir_num != 0)
directories_[dir_num] = name; directories_[dir_num] = name;
} }
void DwarfLineToModule::DefineFile(const string &name, int32 file_num, void DwarfLineToModule::DefineFile(const std::string &name, int32 file_num,
uint32 dir_num, uint64 mod_time, uint32 dir_num, uint64 mod_time,
uint64 length) { uint64 length) {
if (file_num == -1) if (file_num == -1)