diff options
author | Maxim Kalaev <maximk@il.ibm.com> | 2012-06-27 21:28:32 (GMT) |
---|---|---|
committer | Maxim Kalaev <maximk@il.ibm.com> | 2012-06-28 07:14:26 (GMT) |
commit | 6802d5aafbe1c3c524a2c25ef5839bb74865a1b5 (patch) | |
tree | 6e2a71f806d58b861b16198a9fa1d2347dfb1397 | |
parent | b3d63db1facc7ee9d14e211cc738f34b702de833 (diff) | |
download | Ninja-6802d5aafbe1c3c524a2c25ef5839bb74865a1b5.zip Ninja-6802d5aafbe1c3c524a2c25ef5839bb74865a1b5.tar.gz Ninja-6802d5aafbe1c3c524a2c25ef5839bb74865a1b5.tar.bz2 |
Improving Edge::Dump, introducing Node::Dump
- Edge::Dump could crash if called while inputs_ is being extended
- Node::Dump prints Node attributes, in-edge and lists of out-edges
- Dump functions now accept "prefix" parameter, printed along with the object
for easier orientation. For example, edge->Dump("Re-reading deps files").
-rw-r--r-- | src/graph.cc | 29 | ||||
-rw-r--r-- | src/graph.h | 4 |
2 files changed, 27 insertions, 6 deletions
diff --git a/src/graph.cc b/src/graph.cc index 5418ecf..56584e3 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -320,18 +320,37 @@ bool Edge::LoadDepFile(State* state, DiskInterface* disk_interface, return true; } -void Edge::Dump() { - printf("[ "); - for (vector<Node*>::iterator i = inputs_.begin(); i != inputs_.end(); ++i) { +void Edge::Dump(const char* prefix) const { + printf("%s[ ", prefix); + for (vector<Node*>::const_iterator i = inputs_.begin(); + i != inputs_.end() && *i != NULL; ++i) { printf("%s ", (*i)->path().c_str()); } printf("--%s-> ", rule_->name().c_str()); - for (vector<Node*>::iterator i = outputs_.begin(); i != outputs_.end(); ++i) { + for (vector<Node*>::const_iterator i = outputs_.begin(); + i != outputs_.end() && *i != NULL; ++i) { printf("%s ", (*i)->path().c_str()); } - printf("]\n"); + printf("] 0x%p\n", this); } bool Edge::is_phony() const { return rule_ == &State::kPhonyRule; } + +void Node::Dump(const char* prefix) const { + printf("%s <%s 0x%p> mtime: %d%s, (:%s), ", + prefix, path().c_str(), this, + mtime(), mtime()?"":" (:missing)", + dirty()?" dirty":" clean"); + if (in_edge()) { + in_edge()->Dump("in-edge: "); + }else{ + printf("no in-edge\n"); + } + printf(" out edges:\n"); + for (vector<Edge*>::const_iterator e = out_edges().begin(); + e != out_edges().end() && *e != NULL; ++e) { + (*e)->Dump(" +- "); + } +} diff --git a/src/graph.h b/src/graph.h index 32a859d..0ef4f3f 100644 --- a/src/graph.h +++ b/src/graph.h @@ -77,6 +77,8 @@ struct Node { const vector<Edge*>& out_edges() const { return out_edges_; } void AddOutEdge(Edge* edge) { out_edges_.push_back(edge); } + void Dump(const char* prefix="") const; + private: string path_; /// Possible values of mtime_: @@ -173,7 +175,7 @@ struct Edge { bool LoadDepFile(State* state, DiskInterface* disk_interface, string* err); - void Dump(); + void Dump(const char* prefix="") const; const Rule* rule_; vector<Node*> inputs_; |