[RFAv2 1/3] Use function_name_style to print Ada and C function names

Philippe Waroquiers philippe.waroquiers@skynet.be
Sat Jan 19 12:11:00 GMT 2019


Thanks for the review.

On Thu, 2019-01-17 at 15:21 -0700, Tom Tromey wrote:
> > > > > > "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:
> 
> Philippe> Note that ada-typeprint.c print_func_type is called with
> Philippe> types representing functions and is also called to print
> Philippe> a function NAME and its type.  In such a case, the function
> Philippe> name will be printed using function name style.
> 
> In this particular spot it still isn't clear to me if this will
> sometimes style a type name.  So, I'm going to defer to Joel on the Ada
> bits.

Would be nice to have Joel confirming, but I am quite confident that
this will only style function names and not type names.

If that can help, here is some more detailed investigations:
First, in Ada, after the keywords procedure/function, and before
the arg list (as printed by print_func_type), you must put
a procedure/function name, no type name can be put there,
so GDB would produce real strange/invalid Ada such as:
   procedure Some_Ada_Type_Name (Some_Arg : ...);
This explanation matches the comment of print_func_type:
/* Print function or procedure type TYPE on STREAM.  Make it a header
   for function or procedure NAME if NAME is not null.  */

Also, the type name of an Ada type is accessed via ada_type_name,
that accesses a member of TYPE containing the type name.

To the contrary: the NAME arg of print_func_type is received from
ada_print_type (the single caller of print_func_type),
that passes as NAME its VARSTRING arg.

There are only a few places where ada_print_type is called
with a non null VARSTRING arg, and these are for the names
of fields of record/unchecked unions.

ada_print_type is called (indirectly) by all calls to
print_type (dispatching on the language).
Doing a grep, I found only symtab.c:print_symbol_info
that calls type_print with a non
NULL/non "" VARSTRING arg,
and this piece of code gives "" when the symbol
is a TYPEDEF.

So, I really do not see how that piece of code could style
something else than a function/procedure name.

Thanks

Philippe



More information about the Gdb-patches mailing list