2011/9/29 Georg-Johann Lay <a...@gjlay.de>:
> Georg-Johann Lay wrote:
>> 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)]: <function_decl # foo
>>     type <function_type #
>>         type <void_type # void VOID
>> ...
>>
>> Wondering that similar functionality is not provided by GCC itself, I wrote
>> this patch. GCC's diagnostic seems to be overwhelmingly complicated and not
>> intended for the purpose mentioned above.
>>
>> The code is dead code at the moment. No function in the BE uses the new
>> functions. This patch just adds them.
>>
>> Moreover; I don't know if avr port maintainers or global reviewers like such
>> stuff in the compiler... Therefore it's just tentative draft.
>>
>> Supported %-codes are:
>>
>>   r: rtx
>>   t: tree
>>   T: tree (brief)
>>   C: enum rtx_code
>>   m: enum machine_mode
>>   R: enum reg_class
>>   L: insn list
>>   H: location_t
>>
>>   -- no args --
>>   A: call abort()
>>   f: current_function_name()
>>   F: caller (via __FUNCTION__)
>>   P: Pass name and number
>>   ?: Print caller, current function and pass info
>>
>>   -- same as printf --
>>   %: %
>>   c: char
>>   s: string
>>   d: int (decimal)
>>   x: int (hex)
>>
>> These codes cover great deal of BE developers needs and if something is 
>> missing
>> it can be added easily.
>
> Here is now the patch for review.
>
> As Denis proposed in http://gcc.gnu.org/ml/gcc/2011-09/msg00357.html all
> additional functions are put in the new file avr-log.c.
>
> -mdebug= is a new command line option that takes a string argument to filter
> specific log messages.  The purpose of -mdebug=all is to be similar to -mdeb
> and, e.g, -mdebug=rtx_costs,legitimate_address_p is intended to print
> information from respective named hooks.
>
> avr.c:avr_option_override calls avr-log.c:avr__set_avr_debug to parse -mdebug
> and set bitfield avr_debug accordingly, but using the log functions and
> avr_debug is still to come.  This patch just supplies the basis.
>
> I opened PR50566 to collect changes for better logging.
>
> Ok for trunk?

Ok.
Please apply.

Denis

Reply via email to