Skip to content

Commit

Permalink
Cleanup to get test suite building and passing locally (including som…
Browse files Browse the repository at this point in the history
…e de-confusing of stream operators).
  • Loading branch information
wrwilliams committed Nov 1, 2016
1 parent 7c398cf commit 42888db
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 64 deletions.
7 changes: 7 additions & 0 deletions common/h/IBSTree-fast.h
Expand Up @@ -178,6 +178,13 @@ namespace Dyninst
void successor(interval_type X, std::set<ITYPE*>& ) const;
ITYPE* successor(interval_type X) const;
void clear();
friend std::ostream& operator<<(std::ostream& stream, const IBSTree_fast<ITYPE>& tree)
{
std::copy(tree.unique_intervals.begin(), tree.unique_intervals.end(),
std::ostream_iterator<typename Dyninst::IBSTree_fast<ITYPE>::interval_set::value_type>(stream, "\n"));
stream << tree.overlapping_intervals;
return stream;
}

};

Expand Down
19 changes: 18 additions & 1 deletion common/h/IBSTree.h
Expand Up @@ -132,6 +132,15 @@ class IBSNode {

interval_type value() const { return val_; };
interval_type operator*() const { return value; }
friend std::ostream& operator<<(std::ostream& stream, const IBSNode<ITYPE>& node)
{
if(node.left) stream << *(node.left);
stream << node.val_ << std::endl;
if(node.right) stream << *(node.right);
return stream;

}


private:
/* The endpoint of an interval range */
Expand Down Expand Up @@ -215,6 +224,10 @@ class IBSTree {
int CountMarks(IBSNode<ITYPE> *R) const;

unsigned MemUse() const;
friend std::ostream& operator<<(std::ostream& stream, const IBSTree<ITYPE>& tree)
{
return stream << *(tree.root);
};

public:

Expand Down Expand Up @@ -888,11 +901,15 @@ void IBSTree<ITYPE>::PrintPreorder(IBSNode<ITYPE> *n)
}
}



template<class ITYPE>
int IBSTree<ITYPE>::CountMarks() const
{
return CountMarks(root);
}
} /* Dyninst */
}/* Dyninst */


#endif

16 changes: 13 additions & 3 deletions dataflowAPI/h/Absloc.h
Expand Up @@ -179,6 +179,11 @@ class Absloc {
}
};

friend std::ostream &operator<<(std::ostream &os, const Absloc &a) {
os << a.format();
return os;
}

private:
Type type_;

Expand Down Expand Up @@ -253,6 +258,10 @@ class AbsRegion {
DATAFLOW_EXPORT AST::Ptr generator() const { return generator_; }

DATAFLOW_EXPORT bool isImprecise() const { return type_ != Absloc::Unknown; }
friend std::ostream &operator<<(std::ostream &os, const AbsRegion &a) {
os << a.format();
return os;
}

private:
// Type is for "we're on the stack but we don't know where".
Expand Down Expand Up @@ -349,6 +358,10 @@ class Assignment {
DATAFLOW_EXPORT ParseAPI::Function *func() const { return func_; }

DATAFLOW_EXPORT ParseAPI::Block *block() const { return block_; }
friend std::ostream &operator<<(std::ostream &os, const Assignment::Ptr &a) {
os << a->format();
return os;
}

private:
InstructionAPI::Instruction::Ptr insn_;
Expand Down Expand Up @@ -376,9 +389,6 @@ struct AssignmentPtrValueComp {
};


std::ostream &operator<<(std::ostream &os, const Dyninst::Absloc &a);
std::ostream &operator<<(std::ostream &os, const Dyninst::AbsRegion &a);
std::ostream &operator<<(std::ostream &os, const Dyninst::Assignment::Ptr &a);

#endif

15 changes: 15 additions & 0 deletions dataflowAPI/h/SymEval.h
Expand Up @@ -94,6 +94,11 @@ struct Variable {
ret << ")";
return ret.str();
}
friend std::ostream& operator<<(std::ostream& stream, const Variable& c)
{
stream << c.format() << std::endl;
return stream;
}

AbsRegion reg;
Address addr;
Expand Down Expand Up @@ -122,6 +127,11 @@ struct Constant {
}
return ret.str();
}
friend std::ostream& operator<<(std::ostream& stream, const Constant& c)
{
stream << c.format() << std::endl;
return stream;
}

uint64_t val;
size_t size;
Expand Down Expand Up @@ -278,6 +288,11 @@ DATAFLOW_EXPORT const std::string format() const {
ret << ">";
return ret.str();
};
friend std::ostream& operator<<(std::ostream& stream, const ROSEOperation& c)
{
stream << c.format() << std::endl;
return stream;
}

Op op;
size_t size;
Expand Down
7 changes: 5 additions & 2 deletions dataflowAPI/h/stackanalysis.h
Expand Up @@ -131,6 +131,11 @@ class StackAnalysis {
retVal << height_;
return retVal.str();
}
friend std::ostream& operator<<(std::ostream& stream, const Height& c)
{
stream << c.format() << std::endl;
return stream;
}

bool isBottom() const {
return type_ == BOTTOM && height_ == notUnique;
Expand Down Expand Up @@ -466,8 +471,6 @@ class StackAnalysis {

} // namespace Dyninst

DATAFLOW_EXPORT std::ostream &operator<<(std::ostream &os,
const Dyninst::StackAnalysis::Height &h);

namespace Dyninst {
DEF_AST_LEAF_TYPE(StackAST, Dyninst::StackAnalysis::Height);
Expand Down
13 changes: 0 additions & 13 deletions dataflowAPI/src/Absloc.C
Expand Up @@ -336,20 +336,7 @@ const std::string Assignment::format() const {
return ret.str();
}

std::ostream &operator<<(std::ostream &os, const Absloc &a) {
os << a.format();
return os;
}

std::ostream &operator<<(std::ostream &os, const AbsRegion &a) {
os << a.format();
return os;
}

std::ostream &operator<<(std::ostream &os, const Assignment::Ptr &a) {
os << a->format();
return os;
}

#if 0
bool AbsRegion::equivalent(const AbsRegion &lhs,
Expand Down
55 changes: 31 additions & 24 deletions dyninstAPI/src/Relocation/CodeTracker.C
Expand Up @@ -227,28 +227,35 @@ void CodeTracker::debug() {
cerr << endl;
}

std::ostream &operator<<(std::ostream &os, const Dyninst::Relocation::TrackerElement &e) {
os << "Tracker(" << hex
<< e.orig() << "," << e.reloc()
<< "," << dec << e.size();
switch(e.type()) {
case TrackerElement::original:
os << ",o";
break;
case TrackerElement::emulated:
os << ",e";
break;
case TrackerElement::instrumentation:
os << ",i";
break;
case TrackerElement::padding:
os << ",p";
break;
default:
os << ",?";
break;
}
os << "," << e.block()->start() << "," << (e.func() ? e.func()->name() : "<NOFUNC>");
os << ")" << dec;
return os;
namespace Dyninst
{
namespace Relocation
{
std::ostream &operator<<(std::ostream &os, const Dyninst::Relocation::TrackerElement &e) {
os << "Tracker(" << hex
<< e.orig() << "," << e.reloc()
<< "," << dec << e.size();
switch(e.type()) {
case TrackerElement::original:
os << ",o";
break;
case TrackerElement::emulated:
os << ",e";
break;
case TrackerElement::instrumentation:
os << ",i";
break;
case TrackerElement::padding:
os << ",p";
break;
default:
os << ",?";
break;
}
os << "," << e.block()->start() << "," << (e.func() ? e.func()->name() : "<NOFUNC>");
os << ")" << dec;
return os;
}

}
}
6 changes: 3 additions & 3 deletions dyninstAPI/src/Relocation/CodeTracker.h
Expand Up @@ -84,7 +84,7 @@ class TrackerElement {
void setReloc(Address reloc) { reloc_ = reloc; };
void setSize(unsigned size) { size_ = size; }

virtual bool mergeable() const { return true; }
virtual bool mergeable() const { return true; }

protected:
TrackerElement() { assert(0); };
Expand Down Expand Up @@ -119,6 +119,8 @@ class OriginalTracker : public TrackerElement {

private:
};
std::ostream &
operator<<(std::ostream &os, const Dyninst::Relocation::TrackerElement &e);

class EmulatorTracker : public TrackerElement {
public:
Expand Down Expand Up @@ -276,7 +278,5 @@ class CodeTracker {
};
};

std::ostream &
operator<<(std::ostream &os, const Dyninst::Relocation::TrackerElement &e);

#endif
1 change: 0 additions & 1 deletion symtabAPI/h/Module.h
Expand Up @@ -85,7 +85,6 @@ class SYMTAB_EXPORT Statement : public AddressRange
};

typedef StatementLess LineNoTupleLess;

bool operator==(const Statement &cmp) const;
// bool operator==(const char* file) const {return strcmp(file, first) == 0; }
bool operator==(Offset addr) const {
Expand Down
25 changes: 12 additions & 13 deletions symtabAPI/h/RangeLookup.h
Expand Up @@ -52,19 +52,9 @@ namespace Dyninst {
struct SYMTAB_EXPORT AddressRange : std::pair<Offset, Offset>
{
template <typename T>
AddressRange(T t) {
first = t.startAddr();
second = t.endAddr();
}
template <typename T>
AddressRange(typename boost::shared_ptr<T> t) {
first = t->startAddr();
second = t->endAddr();
}
template <typename T>
AddressRange(T* t) {
first = t->startAddr();
second = t->endAddr();
AddressRange(Dyninst::SimpleInterval<T> i) {
first = i.low();
second = i.high();
}
AddressRange(Offset t)
{
Expand All @@ -76,6 +66,15 @@ namespace Dyninst {
first = start;
second = end;
}
AddressRange(const AddressRange& other) : std::pair<Offset, Offset>(other)
{
}
AddressRange& operator=(const AddressRange& other)
{
first = other.first;
second = other.second;
return *this;
}
AddressRange merge(const AddressRange& other)
{
return AddressRange(std::min(first, other.first), std::max(second, other.second));
Expand Down
8 changes: 6 additions & 2 deletions symtabAPI/src/LineInformation.C
Expand Up @@ -139,8 +139,12 @@ bool LineInformation::getAddressRanges( const char * lineSource,
unsigned int lineNo, vector< AddressRange > & ranges )
{
auto found_statements = equal_range(lineSource, lineNo);
std::copy(found_statements.first, found_statements.second,
std::back_inserter(ranges));
for(auto i = found_statements.first;
i != found_statements.second;
++i)
{
ranges.push_back(AddressRange(**i));
}
return found_statements.first != found_statements.second;
} /* end getAddressRangesFromLine() */

Expand Down
4 changes: 2 additions & 2 deletions symtabAPI/src/Symtab-lookup.C
Expand Up @@ -392,7 +392,7 @@ bool Symtab::findModuleByOffset(Module *&ret, Offset off)
{
ret = (*mods.begin())->id();
}
return mods.empty();
return !mods.empty();
}

bool Symtab::findModuleByOffset(std::set<Module *>&ret, Offset off)
Expand All @@ -406,7 +406,7 @@ bool Symtab::findModuleByOffset(std::set<Module *>&ret, Offset off)
{
ret.insert((*i)->id());
}
return ret.empty();
return !ret.empty();
}

bool Symtab::findModuleByName(Module *&ret, const std::string name)
Expand Down

0 comments on commit 42888db

Please sign in to comment.