Skip to content

Commit

Permalink
Make Statement's filenames const char* pointing into the string table…
Browse files Browse the repository at this point in the history
…, not just LineInformation's copies of same.
  • Loading branch information
wrwilliams committed Oct 19, 2016
1 parent 3b3d4bb commit bd7ecb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions symtabAPI/h/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,24 @@ class SYMTAB_EXPORT Statement : public AnnotatableSparse, public Serializable

Statement(const char *file, unsigned int line, unsigned int col = 0,
Offset start_addr = (Offset) -1L, Offset end_addr = (Offset) -1L) :
file_(file ? std::string(file) : std::string()),
file_(file),
line_(line),
start_addr_(start_addr),
end_addr_(end_addr),
first(file_.c_str()),
first(file_),
second(line_),
column(col)
{
}

std::string file_; // Maybe this should be module?
const char* file_; // Maybe this should be module?
unsigned int line_;
Offset start_addr_;
Offset end_addr_;

public:
// DEPRECATED. First and second need to die, and column should become an accessor.
// Duplication of data is both bad and stupid, okay?
const char *first;
unsigned int second;
unsigned int column;
Expand All @@ -85,7 +87,7 @@ class SYMTAB_EXPORT Statement : public AnnotatableSparse, public Serializable

Offset startAddr() { return start_addr_;}
Offset endAddr() {return end_addr_;}
const std::string &getFile() { return file_;}
std::string getFile() { return file_;}
unsigned int getLine() {return line_;}
unsigned int getColumn() {return column;}

Expand All @@ -94,7 +96,7 @@ class SYMTAB_EXPORT Statement : public AnnotatableSparse, public Serializable
// Does dyninst really need these?
void setLine(unsigned int l) {line_ = l;}
void setColumn(unsigned int l) {column = l;}
void setFile(const char * l) {file_ = std::string(l); first = file_.c_str();}
void setFile(const char * l) {file_ = l; first = file_;}
void setStartAddr(Offset l) {start_addr_ = l;}
void setEndAddr(Offset l) {end_addr_ = l;}
};
Expand Down
4 changes: 2 additions & 2 deletions symtabAPI/src/LineInformation.C
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void LineInformation::addLineInfo(LineInformation *lineInfo)

for (; iter != lineInfo->end(); iter++)
{
addLine(iter->second.file_.c_str(), iter->second.line_, iter->second.column,
addLine(iter->second.file_, iter->second.line_, iter->second.column,
iter->first.first, iter->first.second);
}
}
Expand Down Expand Up @@ -135,7 +135,7 @@ bool Statement::StatementLess::operator () ( const Statement &lhs, const Stateme
{
// dont bother with ordering by column information yet.

int strcmp_res = strcmp( lhs.file_.c_str(), rhs.file_.c_str());
int strcmp_res = strcmp( lhs.file_, rhs.file_);

if (strcmp_res < 0 )
return true;
Expand Down

0 comments on commit bd7ecb5

Please sign in to comment.