diff options
author | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-06-05 08:03:45 +0000 |
---|---|---|
committer | nathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-06-05 08:03:45 +0000 |
commit | 364c0b8289357c301c31ac9ef0a03c447189e181 (patch) | |
tree | b6681bcaabfa37891f4e13f70111f31f94d5e53e /gcc/c-dump.c | |
parent | 35c15f51aaef1d494133a35dfb431a2b055cc5ff (diff) | |
download | gcc-364c0b8289357c301c31ac9ef0a03c447189e181.tar.gz |
* c-common.h (flag_dump_translation_unit): Remove.
(enum tree_dump_index): Define.
(TDF_ADDRESS, TDF_SLIM): New #defines.
(dump_node_to_file): Remove.
(dump_node): Make extern. Add flags.
(dump_flag, dump_enabled_p, dump_begin, dump_end,
dump_switch_p): Prototype.
* c-common.c (flag_dump_translation_unit): Remove.
* c-decl.c (c_decode_option): Remove -fdump-translation-unit
logic. Use dump_switch_p.
* c-dump.h (struct dump_info): Add node and user fields.
(dump_pointer): Declare.
* c-dump.c (dump_node): Make extern. Add flags.
(SOL_COLUMN, EOL_COLUMN, COLUMN_ALIGNMENT): New #defines.
(dump_new_line, dump_maybe_newline): Use them.
(dump_pointer): New function.
(dequeue_and_dump): Check TDF_SLIM before dumping a _DECL's
chain or function's body. Dump address, if TDF_ADDRESS set.
(dump_flag): Define.
(dump_node_to_file): Remove.
(struct dump_file_info): New struct.
(dump_files): New array.
(dump_begin, dump_end, dump_enabled_p, dump_switch_p): Define.
* c-lang.c (finish_file): Adjust dumping.
* toplev.h (dump_base_name): Make extern.
* invoke.texi: Document new flags.
cp:
* class.c (maybe_indent_hierarchy): New function.
(dump_class_hierarchy_r): Add flags. Dump extra binfo
information, if enabled. Use maybe_indent_hierarchy. Adjust
output format.
(dump_class_hierarchy): Adjust prototype. Adjust output format.
(dump_array, dump_vtable, dump_vtt): New functions.
(finish_struct_1): Adjust hierarchy dumping.
(initialize_vtable): Call dump_vtable.
(build_vtt): Call dump_vtt.
(build_ctor_vtbl_group): Call dump_vtable.
* decl2.c (flag_dump_class_layout): Remove.
(cxx_decode_option): Remove dump translation unit
and dump class hierarchy check. Call dump_switch_p.
(finish_file): Adjust dumping.
(dump.c): Only dump base classes if not TDF_SLIM.
Only dump namespace members if not TDF_SLIM.
* optimize.c (dump_function): New function.
(optimize_function): Call dump_function.
* semantics.c (expand_body): Use dump_enabled_p.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42896 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-dump.c')
-rw-r--r-- | gcc/c-dump.c | 159 |
1 files changed, 133 insertions, 26 deletions
diff --git a/gcc/c-dump.c b/gcc/c-dump.c index 08f6f02902c..72de67c7479 100644 --- a/gcc/c-dump.c +++ b/gcc/c-dump.c @@ -40,7 +40,6 @@ static void dequeue_and_dump PARAMS ((dump_info_p)); static void dump_new_line PARAMS ((dump_info_p)); static void dump_maybe_newline PARAMS ((dump_info_p)); static void dump_string_field PARAMS ((dump_info_p, const char *, const char *)); -static void dump_node PARAMS ((tree, FILE *)); /* Add T to the end of the queue of nodes to dump. Returns the index assigned to T. */ @@ -139,6 +138,11 @@ queue_and_dump_type (di, t) queue_and_dump_index (di, "type", TREE_TYPE (t), DUMP_NONE); } +/* Dump column control */ +#define SOL_COLUMN 25 /* Start of line column. */ +#define EOL_COLUMN 55 /* End of line column. */ +#define COLUMN_ALIGNMENT 15 /* Alignment. */ + /* Insert a new line in the dump output, and indent to an appropriate place to start printing more fields. */ @@ -146,8 +150,8 @@ static void dump_new_line (di) dump_info_p di; { - fprintf (di->stream, "\n%25s", ""); - di->column = 25; + fprintf (di->stream, "\n%*s", SOL_COLUMN, ""); + di->column = SOL_COLUMN; } /* If necessary, insert a new line. */ @@ -156,18 +160,33 @@ static void dump_maybe_newline (di) dump_info_p di; { + int extra; + /* See if we need a new line. */ - if (di->column > 53) + if (di->column > EOL_COLUMN) dump_new_line (di); /* See if we need any padding. */ - else if ((di->column - 25) % 14 != 0) + else if ((extra = (di->column - SOL_COLUMN) % COLUMN_ALIGNMENT) != 0) { - fprintf (di->stream, "%*s", 14 - ((di->column - 25) % 14), ""); - di->column += 14 - (di->column - 25) % 14; + fprintf (di->stream, "%*s", COLUMN_ALIGNMENT - extra, ""); + di->column += COLUMN_ALIGNMENT - extra; } } -/* Dump I using FIELD to identity it. */ +/* Dump pointer PTR using FIELD to identify it. */ + +void +dump_pointer (di, field, ptr) + dump_info_p di; + const char *field; + void *ptr; +{ + dump_maybe_newline (di); + fprintf (di->stream, "%-4s: %-8lx ", field, (long) ptr); + di->column += 15; +} + +/* Dump integer I using FIELD to identify it. */ void dump_int (di, field, i) @@ -349,7 +368,7 @@ dequeue_and_dump (di) /* And any declaration can be compiler-generated. */ if (DECL_ARTIFICIAL (t)) dump_string (di, "artificial"); - if (TREE_CHAIN (t)) + if (TREE_CHAIN (t) && !dump_flag (di, TDF_SLIM, NULL)) dump_child ("chan", TREE_CHAIN (t)); } else if (code_class == 't') @@ -504,7 +523,7 @@ dequeue_and_dump (di) dump_string (di, "extern"); else dump_string (di, "static"); - if (DECL_LANG_SPECIFIC (t)) + if (DECL_LANG_SPECIFIC (t) && !dump_flag (di, TDF_SLIM, t)) dump_child ("body", DECL_SAVED_TREE (t)); break; @@ -709,15 +728,30 @@ dequeue_and_dump (di) } done: + if (dump_flag (di, TDF_ADDRESS, NULL)) + dump_pointer (di, "addr", (void *)t); + /* Terminate the line. */ fprintf (di->stream, "\n"); } +/* Return non-zero if FLAG has been specified for the dump, and NODE + is not the root node of the dump. */ + +int dump_flag (di, flag, node) + dump_info_p di; + int flag; + tree node; +{ + return (di->flags & flag) && (node != di->node); +} + /* Dump T, and all its children, on STREAM. */ -static void -dump_node (t, stream) +void +dump_node (t, flags, stream) tree t; + int flags; FILE *stream; { struct dump_info di; @@ -731,6 +765,8 @@ dump_node (t, stream) di.queue = 0; di.queue_end = 0; di.free_list = 0; + di.flags = flags; + di.node = t; di.nodes = splay_tree_new (splay_tree_compare_pointers, 0, (splay_tree_delete_value_fn) &free); @@ -750,21 +786,92 @@ dump_node (t, stream) splay_tree_delete (di.nodes); } -/* Dump T, and all its children, to FILE. */ +/* Define a tree dump switch. */ +struct dump_file_info +{ + const char *suffix; /* suffix to give output file. */ + const char *swtch; /* command line switch */ + int flags; /* user flags */ + int state; /* state of play */ +}; + +/* Table of tree dump switches. */ +static struct dump_file_info dump_files[TDI_end] = +{ + {".tu", "dump-translation-unit", 0, 0}, + {".original", "dump-ast-original", 0, 0}, + {".optimized", "dump-ast-optimized", 0, 0}, + {".class", "dump-class-hierarchy", 0, 0}, +}; + +/* Begin a tree dump for PHASE. Stores any user supplied flag in + *FLAG_PTR and returns a stream to write to. If the dump is not + enabled, returns NULL. + Multiple calls will reopen and append to the dump file. */ + +FILE * +dump_begin (phase, flag_ptr) + enum tree_dump_index phase; + int *flag_ptr; +{ + FILE *stream; + char *name; + + if (!dump_files[phase].state) + return NULL; + + name = concat (dump_base_name, dump_files[phase].suffix, NULL); + stream = fopen (name, dump_files[phase].state < 0 ? "w" : "a"); + if (!stream) + error ("could not open dump file `%s'", name); + else + dump_files[phase].state = 1; + free (name); + if (flag_ptr) + *flag_ptr = dump_files[phase].flags; + + return stream; +} -void -dump_node_to_file (t, file) - tree t; - const char *file; +/* Returns non-zero if tree dump PHASE is enabled. */ + +int dump_enabled_p (phase) + enum tree_dump_index phase; { - FILE *f; + return dump_files[phase].state; +} - f = fopen (file, "w"); - if (!f) - error ("could not open dump file `%s'", file); - else - { - dump_node (t, f); - fclose (f); - } +/* Finish a tree dump for PHASE. STREAM is the stream created by + dump_begin. */ + +void dump_end (phase, stream) + enum tree_dump_index phase ATTRIBUTE_UNUSED; + FILE *stream; +{ + fclose (stream); +} + +/* Parse ARG as a dump switch. Return non-zero if it is, and store the + relevant details in the dump_files array. */ + +int dump_switch_p (arg) + const char *arg; +{ + unsigned ix; + const char *option_value; + + for (ix = 0; ix != TDI_end; ix++) + if ((option_value = skip_leading_substring (arg, dump_files[ix].swtch))) + { + dump_files[ix].state = -1; + if (*option_value == '-') + dump_files[ix].flags + = read_integral_parameter (option_value + 1, arg, 0); + else if (*option_value) + warning ("ignoring `%s' at end of `-f%s'", + option_value, dump_files[ix].swtch); + + return 1; + } + return 0; } |