diff options
author | Doug Evans <dje@gnu.org> | 1993-01-26 00:30:34 +0000 |
---|---|---|
committer | Doug Evans <dje@gnu.org> | 1993-01-26 00:30:34 +0000 |
commit | 716f003f91219c1a6997a7fcc960c796ca73a82e (patch) | |
tree | 5fb2668b5b1c11ba45b1066be5167b66af578c24 /gcc/print-rtl.c | |
parent | 8aa9dc6a816f53ad647995fabf183fe033cf95cd (diff) | |
download | gcc-716f003f91219c1a6997a7fcc960c796ca73a82e.zip gcc-716f003f91219c1a6997a7fcc960c796ca73a82e.tar.gz gcc-716f003f91219c1a6997a7fcc960c796ca73a82e.tar.bz2 |
Added debugging utilities debug_rtx_list to print several rtx's and...
Added debugging utilities debug_rtx_list to print several rtx's and
debug_rtx_find to look up an rtx in a list given a uid.
From-SVN: r3343
Diffstat (limited to 'gcc/print-rtl.c')
-rw-r--r-- | gcc/print-rtl.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c index 60e3ca9..651659e 100644 --- a/gcc/print-rtl.c +++ b/gcc/print-rtl.c @@ -230,6 +230,64 @@ debug_rtx (x) fprintf (stderr, "\n"); } +/* Count of rtx's to print with debug_rtx_list. + This global exists because gdb user defined commands have no arguments. */ + +int debug_rtx_count = 0; /* 0 is treated as equivalent to 1 */ + +/* Call this function to print list from X on. + + N is a count of the rtx's to print. Positive values print from the specified + rtx on. Negative values print a window around the rtx. + EG: -5 prints 2 rtx's on either side (in addition to the specified rtx). */ + +void +debug_rtx_list (x, n) + rtx x; + int n; +{ + int i,count; + rtx insn; + + count = n == 0 ? 1 : n < 0 ? -n : n; + + /* If we are printing a window, back up to the start. */ + + if (n < 0) + for (i = count / 2; i > 0; i--) + { + if (PREV_INSN (x) == 0) + break; + x = PREV_INSN (x); + } + + for (i = count, insn = x; i > 0 && insn != 0; i--, insn = NEXT_INSN (insn)) + debug_rtx (insn); +} + +/* Call this function to search an rtx list to find one with insn uid UID, + and then call debug_rtx_list to print it, using DEBUG_RTX_COUNT. + The found insn is returned to enable further debugging analysis. */ + +rtx +debug_rtx_find(x, uid) + rtx x; + int uid; +{ + while (x != 0 && INSN_UID (x) != uid) + x = NEXT_INSN (x); + if (x != 0) + { + debug_rtx_list (x, debug_rtx_count); + return x; + } + else + { + fprintf (stderr, "insn uid %d not found\n", uid); + return 0; + } +} + /* External entry point for printing a chain of insns starting with RTX_FIRST onto file OUTF. A blank line separates insns. |