From patchwork Wed Sep 28 15:10:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georg-Johann Lay X-Patchwork-Id: 116816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 613BF1007D1 for ; Thu, 29 Sep 2011 01:11:30 +1000 (EST) Received: (qmail 2564 invoked by alias); 28 Sep 2011 15:11:25 -0000 Received: (qmail 2259 invoked by uid 22791); 28 Sep 2011 15:11:23 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, TW_TX X-Spam-Check-By: sourceware.org Received: from mo-p00-ob.rzone.de (HELO mo-p00-ob.rzone.de) (81.169.146.161) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 28 Sep 2011 15:11:07 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT2k715jHQaJercGObUOFkj18odoYNahU4Q== X-RZG-CLASS-ID: mo00 Received: from [192.168.0.22] (business-188-111-022-002.static.arcor-ip.net [188.111.22.2]) by smtp.strato.de (fruni mo18) (RZmta 26.8) with ESMTPA id 500035n8SEJYRZ ; Wed, 28 Sep 2011 17:10:46 +0200 (MEST) Message-ID: <4E8338F5.50602@gjlay.de> Date: Wed, 28 Sep 2011 17:10:45 +0200 From: Georg-Johann Lay User-Agent: Thunderbird 2.0.0.24 (X11/20100302) MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: Denis Chertykov , Eric Weddington Subject: [Patch,AVR]: Better log output with -mdeb X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This is a tentative patch for better support of logging information for avr BE developers. There are situations where it is more convenient to let the compiler produce information than to debug into the compiler. One example are -da dumps. This patch proposes a better support to print information by means of a printf-like function via %-codes. The current debug output with avr-gcc's option -mdeb produces bulk of information that is very hard to read because - there is much output - there is no information on current_function_decl - there is no information on current pass name/number - there is no print-like function so the trees, rtxes so that it is tedious to get formatted output. For example, the following call to avr_edump static int avr_OS_main_function_p (tree func) { avr_edump ("%?: %t\n", func); return avr_lookup_function_attribute1 (func, "OS_main"); } prints additional information in a convenient way (foo is function to be compiled): avr_OS_main_function_p[foo:pro_and_epilogue(202)]: "); + else + { + if (stderr == file) + debug_tree (t); + } + break; + } + + case 'T': + print_node_brief (file, "", va_arg (ap, tree), 3); + break; + + case 'd': + fprintf (file, "%d", va_arg (ap, int)); + break; + + case 'x': + fprintf (file, "%x", va_arg (ap, int)); + break; + + case 'c': + fputc (va_arg (ap, int), file); + break; + + case 'r': + print_inline_rtx (file, va_arg (ap, rtx), 0); + break; + + case 'L': + { + rtx insn = va_arg (ap, rtx); + + while (insn) + { + print_inline_rtx (file, insn, 0); + fprintf (file, "\n"); + insn = NEXT_INSN (insn); + } + break; + } + + case 'f': + if (cfun && cfun->decl) + fputs (current_function_name(), file); + break; + + case 's': + { + const char *str = va_arg (ap, char*); + fputs (str ? str : "(null)", file); + } + break; + + case 'm': + fputs (GET_MODE_NAME (va_arg (ap, enum machine_mode)), file); + break; + + case 'C': + fputs (rtx_name[va_arg (ap, enum rtx_code)], file); + break; + + case 'R': + fputs (reg_class_names[va_arg (ap, enum reg_class)], file); + break; + + case 'F': + fputs (avr__caller, file); + break; + + case 'H': + { + location_t loc = va_arg (ap, location_t); + + if (BUILTINS_LOCATION == loc) + fprintf (file, ""); + else + fprintf (file, "%s:%d", + LOCATION_FILE (loc), LOCATION_LINE (loc)); + + break; + } + + case '!': + if (!current_pass) + return; + /* FALLTHRU */ + + case '?': + avr__fdump_f (file, "%F[%f:%P]"); + break; + + case 'P': + if (current_pass) + fprintf (file, "%s(%d)", + current_pass->name, + current_pass->static_pass_number); + else + fprintf (file, "pass=?"); + + break; + + case 'A': + abort(); + + default: + fputc (*(fmt-1), file); + } + break; /* % */ + } + } + + fflush (file); +} #include "gt-avr.h"