mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 13:10:34 +00:00
Make dag dumping from gdb easier.
This commit is contained in:
parent
bedde02307
commit
c5f2e3c4ad
2 changed files with 34 additions and 3 deletions
|
@ -93,6 +93,7 @@ typedef struct dag_s {
|
|||
|
||||
const char *daglabel_string (daglabel_t *label);
|
||||
void print_dag (struct dstring_s *dstr, dag_t *dag, const char *label);
|
||||
void dot_dump_dag (void *_dag, const char *filename);
|
||||
|
||||
/** Make a dag for a single basic block.
|
||||
|
||||
|
|
|
@ -140,14 +140,44 @@ void
|
|||
print_dag (dstring_t *dstr, dag_t *dag, const char *label)
|
||||
{
|
||||
int i;
|
||||
dasprintf (dstr, " subgraph cluster_dag_%p {\n", dag);
|
||||
if (label)
|
||||
|
||||
if (label) {
|
||||
dasprintf (dstr, " subgraph cluster_dag_%p {\n", dag);
|
||||
dasprintf (dstr, " label=\"%s\";\n", label);
|
||||
}
|
||||
dasprintf (dstr, " dag_enter_%p [label=\"\", style=invis];\n", dag);
|
||||
print_root_nodes (dstr, dag);
|
||||
print_child_nodes (dstr, dag);
|
||||
for (i = 0; i < dag->num_nodes; i++)
|
||||
print_node (dstr, dag, dag->nodes[i]);
|
||||
dasprintf (dstr, " dag_leave_%p [label=\"\", style=invis];\n", dag);
|
||||
dasprintf (dstr, " }\n");
|
||||
if (label)
|
||||
dasprintf (dstr, " }\n");
|
||||
}
|
||||
|
||||
void
|
||||
dot_dump_dag (void *_dag, const char *filename)
|
||||
{
|
||||
dag_t *dag = _dag;
|
||||
dstring_t *dstr = dstring_newstr();
|
||||
|
||||
dasprintf (dstr, "digraph dag_%p {\n", dag);
|
||||
dasprintf (dstr, " layout=dot;\n");
|
||||
dasprintf (dstr, " clusterrank=local;\n");
|
||||
dasprintf (dstr, " rankdir=TB;\n");
|
||||
dasprintf (dstr, " compound=true;\n");
|
||||
print_dag (dstr, dag, "");
|
||||
|
||||
dasprintf (dstr, "}\n");
|
||||
|
||||
if (filename) {
|
||||
QFile *file;
|
||||
|
||||
file = Qopen (filename, "wt");
|
||||
Qwrite (file, dstr->str, dstr->size - 1);
|
||||
Qclose (file);
|
||||
} else {
|
||||
fputs (dstr->str, stdout);
|
||||
}
|
||||
dstring_delete (dstr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue