diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-08-19 00:18:18 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-08-19 00:18:18 +0000 |
commit | 82f72146967e71693f2d4f6646f35c3c00780602 (patch) | |
tree | 5faef7399b046f2419d8c84d6f16545f6f1e97cc /gcc/final.c | |
parent | f4e46e34a2c517e1c6c3d0802aba82a9637d677d (diff) | |
download | gcc-82f72146967e71693f2d4f6646f35c3c00780602.zip gcc-82f72146967e71693f2d4f6646f35c3c00780602.tar.gz gcc-82f72146967e71693f2d4f6646f35c3c00780602.tar.bz2 |
Add source information to -fverbose-asm
gcc/ChangeLog:
* doc/invoke.texi (fverbose-asm): Note that source code lines
are emitted, and provide an example.
* final.c (asm_show_source): New function.
(final_scan_insn): Call asm_show_source.
From-SVN: r239604
Diffstat (limited to 'gcc/final.c')
-rw-r--r-- | gcc/final.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/gcc/final.c b/gcc/final.c index 5b04311..eccc3d8 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -2140,6 +2140,26 @@ call_from_call_insn (rtx_call_insn *insn) return x; } +/* Print a comment into the asm showing FILENAME, LINENUM, and the + corresponding source line, if available. */ + +static void +asm_show_source (const char *filename, int linenum) +{ + if (!filename) + return; + + int line_size; + const char *line = location_get_source_line (filename, linenum, &line_size); + if (!line) + return; + + fprintf (asm_out_file, "%s %s:%i: ", ASM_COMMENT_START, filename, linenum); + /* "line" is not 0-terminated, so we must use line_size. */ + fwrite (line, 1, line_size, asm_out_file); + fputc ('\n', asm_out_file); +} + /* The final scan for one insn, INSN. Args are same as in `final', except that INSN is the insn being scanned. @@ -2563,8 +2583,12 @@ final_scan_insn (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, note in a row. */ if (!DECL_IGNORED_P (current_function_decl) && notice_source_line (insn, &is_stmt)) - (*debug_hooks->source_line) (last_linenum, last_filename, - last_discriminator, is_stmt); + { + if (flag_verbose_asm) + asm_show_source (last_filename, last_linenum); + (*debug_hooks->source_line) (last_linenum, last_filename, + last_discriminator, is_stmt); + } if (GET_CODE (body) == PARALLEL && GET_CODE (XVECEXP (body, 0, 0)) == ASM_INPUT) |