* add support for dwarf AT_descriptive_type @ 2010-09-02 14:51 Olivier Hainque 2010-09-15 11:21 ` [ping] " Olivier Hainque ` (5 more replies) 0 siblings, 6 replies; 30+ messages in thread From: Olivier Hainque @ 2010-09-02 14:51 UTC (permalink / raw) To: gcc-patches; +Cc: hainque, brobecker, guitton [-- Attachment #1: Type: text/plain, Size: 3933 bytes --] Hello, Ada allows the definition of particularily complex types and we use a parallel type system to let GDB understand them. Roughly, particularities of a complex type T are encoded in the name of fields in a so-called "descriptive" type associated with T. See ada/exp_dbug.ads for details. For a few years now, we have been maintaining local changes to have these descriptive types emitted and easy to find by GDB. This is a proposal to integrate these changes. The immediate benefit is improved support for Ada in the debugger, for example on the following kind of construct: procedure T is procedure Tryblob (X : Integer) is type Blob (Size : integer) is record Value : string (1 .. Size); end record; B : Blob (Size => X); begin B.Value := (others => 'A'); null; -- break here, then query on B end; begin Tryblob (X => 5); end; With today's debug info, gdb 7.1 at the breakpoint yields (gdb) p b $1 = (size => 5, value => "") (gdb) ptype b.value type = array (1 .. 0) of character With the patch we get the following instead, as expected: (gdb) p b $1 = (size => 5, value => "AAAAA") (gdb) ptype b.value type = array (1 .. size) of character For efficiency purposes, we emit a dwarf attribute for a type T to designate its descriptive type when there is one. GDB has fallback strategies if this is not done, but these involve pretty expensive searches making the whole thing unuseable in practice on industrial applications. There are provisions for this in dwarf2.h already: << /* GNAT descriptive type. See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type . */ DW_AT_use_GNAT_descriptive_type = 0x2301, DW_AT_GNAT_descriptive_type = 0x2302, >> The patch introduces a langhook to let dwarf2out query the front-end about a possible descriptive type, and from there generate the corresponding DIE and attribute as needed. The query, the lazy DIE generation and the attribute reference are all factored in a new "add_descriptive_type_attribute" function, called from the few places where the need/existence of a potential descriptive type is expected. In addition, even if only the Ada compiler uses this today, there is no strong reason for the attribute to be explictly GNAT specific, so the patch renames AT_GNAT_descriptive_type into AT_GNU_descriptive_type. We'll take care of updating the wiki page if the change gets approved. I realize that the addition of a langhook is in general not welcome for lto. My understanding is that it remains acceptable for debug info generation purposes. If that is not the case, we'd be happy to discuss alternate possible schemes. The attached patch was bootstrapped and regession tested on x86_64-suse-linux, both for gdb and gcc --languages=all,ada. Thanks much in advance for your feedback, Olivier 2010-09-01 Olivier Hainque <hainque@adacore.com> Nicolas Setton <setton@adacore.com> Eric Botcazou <ebotcazou@adacore.com> include/ * dwarf2.h (dwarf_attribute): Replace the DW_AT_GNAT prefix by DW_AT_GNU in descriptive types attribute names. gcc/ * dwarf2out.c (dwarf_attr_name): Map DW_AT_GNU_descriptive_type. (add_descriptive_type_attribute): New function. (gen_array_type_die): Call it. (gen_enumeration_type_die): Likewise. (gen_struct_or_union_type_die): Likewise. (modified_type_die): Likewise. * langhooks.h (lang_hooks_for_types): New "descriptive_type" hook. * langhooks-def.h (LANG_HOOKS_DESCRIPTIVE_TYPE): Default to NULL_TREE. (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add LANG_HOOKS_DESCRIPTIVE_TYPE. ada/ * gcc-interface/trans.c (gigi): Remove internal call to dwarf2out_set_descriptive_type_func. * gcc-interface/utils.c (get_parallel_type): Move and rename into ... * gcc-interface/misc.c (gnat_descriptive_type): New function. (LANG_HOOKS_DESCRIPTIVE_TYPE): Redefine to gnat_descriptive_type. [-- Attachment #2: dtypes.dif --] [-- Type: text/plain, Size: 9485 bytes --] Index: include/dwarf2.h =================================================================== *** include/dwarf2.h (revision 163722) --- include/dwarf2.h (working copy) *************** enum dwarf_attribute *** 440,450 **** DW_AT_GNU_template_name = 0x2110, /* VMS extensions. */ DW_AT_VMS_rtnbeg_pd_address = 0x2201, ! /* GNAT extensions. */ ! /* GNAT descriptive type. ! See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type . */ ! DW_AT_use_GNAT_descriptive_type = 0x2301, ! DW_AT_GNAT_descriptive_type = 0x2302, /* UPC extension. */ DW_AT_upc_threads_scaled = 0x3210, /* PGI (STMicroelectronics) extensions. */ --- 440,449 ---- DW_AT_GNU_template_name = 0x2110, /* VMS extensions. */ DW_AT_VMS_rtnbeg_pd_address = 0x2201, ! /* Descriptive types. ! See http://gcc.gnu.org/wiki/DW_AT_GNU_descriptive_type . */ ! DW_AT_use_GNU_descriptive_type = 0x2301, ! DW_AT_GNU_descriptive_type = 0x2302, /* UPC extension. */ DW_AT_upc_threads_scaled = 0x3210, /* PGI (STMicroelectronics) extensions. */ Index: dwarf2out.c =================================================================== *** dwarf2out.c (revision 163722) --- dwarf2out.c (working copy) *************** static bool add_location_or_const_value_ *** 6263,6268 **** --- 6263,6269 ---- static bool tree_add_const_value_attribute (dw_die_ref, tree); static bool tree_add_const_value_attribute_for_decl (dw_die_ref, tree); static void add_name_attribute (dw_die_ref, const char *); + static void add_descriptive_type_attribute (dw_die_ref, tree, dw_die_ref); static void add_comp_dir_attribute (dw_die_ref); static void add_bound_info (dw_die_ref, enum dwarf_attribute, tree); static void add_subscript_info (dw_die_ref, tree, bool); *************** dwarf_attr_name (unsigned int attr) *** 6909,6914 **** --- 6910,6917 ---- return "DW_AT_GNU_odr_signature"; case DW_AT_GNU_template_name: return "DW_AT_GNU_template_name"; + case DW_AT_GNU_descriptive_type: + return "DW_AT_GNU_descriptive_type"; case DW_AT_VMS_rtnbeg_pd_address: return "DW_AT_VMS_rtnbeg_pd_address"; *************** modified_type_die (tree type, int is_con *** 12781,12786 **** --- 12784,12790 ---- useful source coordinates anyway. */ name = DECL_NAME (name); add_name_attribute (mod_type_die, IDENTIFIER_POINTER (name)); + add_descriptive_type_attribute (mod_type_die, type, context_die); } /* This probably indicates a bug. */ else if (mod_type_die && mod_type_die->die_tag == DW_TAG_base_type) *************** add_name_attribute (dw_die_ref die, cons *** 16997,17002 **** --- 17001,17032 ---- } } + /* Retrieve the descriptive type for TYPE, if any, make sure it has + a DIE and attach a DW_AT_GNU_descriptive_type to the DIE of TYPE + accordingly. */ + + static void + add_descriptive_type_attribute (dw_die_ref die, tree type, + dw_die_ref context_die) + { + tree dtype; + dw_die_ref dtype_die; + + dtype = lang_hooks.types.descriptive_type (type); + if (!dtype) + return; + + dtype_die = lookup_type_die (dtype); + if (!dtype_die) + { + gen_type_die (dtype, context_die); + dtype_die = lookup_type_die (dtype); + gcc_assert (dtype_die); + } + + add_AT_die_ref (die, DW_AT_GNU_descriptive_type, dtype_die); + } + /* Generate a DW_AT_comp_dir attribute for DIE. */ static void *************** gen_array_type_die (tree type, dw_die_re *** 17863,17868 **** --- 17893,17899 ---- array_die = new_die (DW_TAG_array_type, scope_die, type); add_name_attribute (array_die, type_tag (type)); + add_descriptive_type_attribute (array_die, type, context_die); equate_type_number_to_die (type, array_die); if (TREE_CODE (type) == VECTOR_TYPE) *************** gen_enumeration_type_die (tree type, dw_ *** 18160,18165 **** --- 18191,18197 ---- scope_die_for (type, context_die), type); equate_type_number_to_die (type, type_die); add_name_attribute (type_die, type_tag (type)); + add_descriptive_type_attribute (type_die, type, context_die); if ((dwarf_version >= 4 || !dwarf_strict) && ENUM_IS_SCOPED (type)) add_AT_flag (type_die, DW_AT_enum_class, 1); *************** gen_struct_or_union_type_die (tree type, *** 19684,19690 **** if (old_die) add_AT_specification (type_die, old_die); else ! add_name_attribute (type_die, type_tag (type)); } else remove_AT (type_die, DW_AT_declaration); --- 19716,19725 ---- if (old_die) add_AT_specification (type_die, old_die); else ! { ! add_name_attribute (type_die, type_tag (type)); ! add_descriptive_type_attribute (type_die, type, context_die); ! } } else remove_AT (type_die, DW_AT_declaration); Index: langhooks.h =================================================================== *** langhooks.h (revision 163722) --- langhooks.h (working copy) *************** struct lang_hooks_for_types *** 133,138 **** --- 133,142 ---- /* Fill in information for the debugger about the bounds of TYPE. */ void (*get_subrange_bounds) (const_tree, tree *, tree *); + /* A type descriptive of TYPE complex layout particularities to help the + debugger with e.g. variable length or self referential contructs. */ + tree (*descriptive_type) (const_tree); + /* If we requested a pointer to a vector, build up the pointers that we stripped off while looking for the inner type. Similarly for return values from functions. The argument TYPE is the top of the Index: langhooks-def.h =================================================================== *** langhooks-def.h (revision 163722) --- langhooks-def.h (working copy) *************** extern tree lhd_make_node (enum tree_cod *** 177,182 **** --- 177,183 ---- #define LANG_HOOKS_TYPE_HASH_EQ NULL #define LANG_HOOKS_GET_ARRAY_DESCR_INFO NULL #define LANG_HOOKS_GET_SUBRANGE_BOUNDS NULL + #define LANG_HOOKS_DESCRIPTIVE_TYPE lhd_return_null_const_tree #define LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE reconstruct_complex_type #define LANG_HOOKS_HASH_TYPES true *************** extern tree lhd_make_node (enum tree_cod *** 195,200 **** --- 196,202 ---- LANG_HOOKS_TYPE_HASH_EQ, \ LANG_HOOKS_GET_ARRAY_DESCR_INFO, \ LANG_HOOKS_GET_SUBRANGE_BOUNDS, \ + LANG_HOOKS_DESCRIPTIVE_TYPE, \ LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE, \ LANG_HOOKS_HASH_TYPES \ } Index: ada/gcc-interface/utils.c =================================================================== *** ada/gcc-interface/utils.c (revision 163722) --- ada/gcc-interface/utils.c (working copy) *************** add_parallel_type (tree decl, tree paral *** 952,968 **** SET_DECL_PARALLEL_TYPE (d, parallel_type); } - /* Return the parallel type associated to a type, if any. */ - - tree - get_parallel_type (tree type) - { - if (TYPE_STUB_DECL (type)) - return DECL_PARALLEL_TYPE (TYPE_STUB_DECL (type)); - else - return NULL_TREE; - } - /* Utility function of above to merge LAST_SIZE, the previous size of a record with FIRST_BIT and SIZE that describe a field. SPECIAL is true if this represents a QUAL_UNION_TYPE in which case we must look for COND_EXPRs and --- 952,957 ---- Index: ada/gcc-interface/trans.c =================================================================== *** ada/gcc-interface/trans.c (revision 163722) --- ada/gcc-interface/trans.c (working copy) *************** gigi (Node_Id gnat_root, int max_gnat_no *** 295,301 **** dwarf2out_set_type_encoding_func (extract_encoding); dwarf2out_set_demangle_name_func (decode_name); } - dwarf2out_set_descriptive_type_func (get_parallel_type); #endif /* Enable GNAT stack checking method if needed */ --- 295,300 ---- Index: ada/gcc-interface/misc.c =================================================================== *** ada/gcc-interface/misc.c (revision 163722) --- ada/gcc-interface/misc.c (working copy) *************** static void internal_error_function (dia *** 78,83 **** --- 78,84 ---- const char *, va_list *); static tree gnat_type_max_size (const_tree); static void gnat_get_subrange_bounds (const_tree, tree *, tree *); + static tree gnat_descriptive_type (const_tree); static tree gnat_eh_personality (void); /* Definitions for our language-specific hooks. */ *************** static tree gnat_eh_personality (void); *** 128,133 **** --- 129,136 ---- #define LANG_HOOKS_TYPES_COMPATIBLE_P gnat_types_compatible_p #undef LANG_HOOKS_GET_SUBRANGE_BOUNDS #define LANG_HOOKS_GET_SUBRANGE_BOUNDS gnat_get_subrange_bounds + #undef LANG_HOOKS_DESCRIPTIVE_TYPE + #define LANG_HOOKS_DESCRIPTIVE_TYPE gnat_descriptive_type #undef LANG_HOOKS_ATTRIBUTE_TABLE #define LANG_HOOKS_ATTRIBUTE_TABLE gnat_internal_attribute_table #undef LANG_HOOKS_BUILTIN_FUNCTION *************** gnat_dwarf_name (tree decl, int verbosit *** 584,589 **** --- 587,603 ---- return (const char *) IDENTIFIER_POINTER (DECL_NAME (decl)); } + /* Return the descriptive type associated to TYPE, if any. */ + + static tree + gnat_descriptive_type (const_tree type) + { + if (TYPE_STUB_DECL (type)) + return DECL_PARALLEL_TYPE (TYPE_STUB_DECL (type)); + else + return NULL_TREE; + } + /* Do nothing (return the tree node passed). */ static tree ^ permalink raw reply [flat|nested] 30+ messages in thread
* [ping] add support for dwarf AT_descriptive_type 2010-09-02 14:51 add support for dwarf AT_descriptive_type Olivier Hainque @ 2010-09-15 11:21 ` Olivier Hainque 2010-09-27 15:29 ` [ping*2] add support for dwarf AT_GNU_descriptive_type Olivier Hainque ` (4 subsequent siblings) 5 siblings, 0 replies; 30+ messages in thread From: Olivier Hainque @ 2010-09-15 11:21 UTC (permalink / raw) To: gcc-patches; +Cc: brobecker, guitton, hainque Hello, Ping for http://gcc.gnu.org/ml/gcc-patches/2010-09/msg00148.html << The immediate benefit is improved support for Ada in the debugger >> Thanks in advance, Olivier ^ permalink raw reply [flat|nested] 30+ messages in thread
* [ping*2] add support for dwarf AT_GNU_descriptive_type 2010-09-02 14:51 add support for dwarf AT_descriptive_type Olivier Hainque 2010-09-15 11:21 ` [ping] " Olivier Hainque @ 2010-09-27 15:29 ` Olivier Hainque 2010-10-06 20:44 ` [ping*3] " Olivier Hainque ` (3 subsequent siblings) 5 siblings, 0 replies; 30+ messages in thread From: Olivier Hainque @ 2010-09-27 15:29 UTC (permalink / raw) To: gcc-patches; +Cc: brobecker, guitton, hainque Hello, Ping # 2 for http://gcc.gnu.org/ml/gcc-patches/2010-09/msg00148.html << The immediate benefit is improved support for Ada in the debugger >> Thanks in advance, Olivier ^ permalink raw reply [flat|nested] 30+ messages in thread
* [ping*3] add support for dwarf AT_GNU_descriptive_type 2010-09-02 14:51 add support for dwarf AT_descriptive_type Olivier Hainque 2010-09-15 11:21 ` [ping] " Olivier Hainque 2010-09-27 15:29 ` [ping*2] add support for dwarf AT_GNU_descriptive_type Olivier Hainque @ 2010-10-06 20:44 ` Olivier Hainque 2010-10-18 9:11 ` [PING*4] " Olivier Hainque ` (2 subsequent siblings) 5 siblings, 0 replies; 30+ messages in thread From: Olivier Hainque @ 2010-10-06 20:44 UTC (permalink / raw) To: gcc-patches; +Cc: brobecker, guitton, hainque, jason Hello, Ping # 3 (+ took the liberty to cc maintainer) for http://gcc.gnu.org/ml/gcc-patches/2010-09/msg00148.html << The immediate benefit is improved support for Ada in the debugger >> Thanks much in advance for your feedback, With Kind Regards, Olivier ^ permalink raw reply [flat|nested] 30+ messages in thread
* [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-09-02 14:51 add support for dwarf AT_descriptive_type Olivier Hainque ` (2 preceding siblings ...) 2010-10-06 20:44 ` [ping*3] " Olivier Hainque @ 2010-10-18 9:11 ` Olivier Hainque 2010-10-24 20:50 ` Jason Merrill 2010-10-24 22:57 ` add support for dwarf AT_descriptive_type Michael Eager 2011-02-18 5:29 ` [PING #5] " Joel Brobecker 5 siblings, 1 reply; 30+ messages in thread From: Olivier Hainque @ 2010-10-18 9:11 UTC (permalink / raw) To: gcc-patches; +Cc: brobecker, guitton, hainque, jason Hello, Ping # 4 (+ cc maintainer) for http://gcc.gnu.org/ml/gcc-patches/2010-09/msg00148.html Please ? Thanks much in advance for your feedback, With Kind Regards, Olivier ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-10-18 9:11 ` [PING*4] " Olivier Hainque @ 2010-10-24 20:50 ` Jason Merrill 2010-10-26 11:03 ` Olivier Hainque 0 siblings, 1 reply; 30+ messages in thread From: Jason Merrill @ 2010-10-24 20:50 UTC (permalink / raw) To: Olivier Hainque; +Cc: gcc-patches, brobecker, guitton Sorry for the delay in review. This patch looks reasonable, but I'm not sure why it's necessary. How does the generated debug info change with this patch? Why can't dwarf2out generate the desired debug info based on the primary type? Jason ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-10-24 20:50 ` Jason Merrill @ 2010-10-26 11:03 ` Olivier Hainque 2010-11-09 11:47 ` Olivier Hainque 0 siblings, 1 reply; 30+ messages in thread From: Olivier Hainque @ 2010-10-26 11:03 UTC (permalink / raw) To: Jason Merrill; +Cc: gcc-patches, brobecker, guitton, hainque Jason Merrill wrote: > Sorry for the delay in review. No problem. Thanks for taking the time to get to it. > This patch looks reasonable, but I'm not sure why it's necessary. How > does the generated debug info change with this patch? For a type with complex aspects (more below) we now also get debug info for a "parallel" type with the complex aspects encoded within simple attributes (e.g. in record field names), and an extra attribute is attached to the original type DIE to designate the parallel type. The extra attribute code is AT_GNU_descriptive_type, and the value is the DIE of the parallel type. GDB knows how to navigate and decode all that for Ada. An example of complex aspect is a record field with a length depending on another of the record fields, as in the example I posted with the original patch submission: procedure Tryblob (X : Integer) is type Blob (Size : integer) is record Value : string (1 .. Size); end record; B : Blob (Size => X); Blob is a struct with a Size integer field and a Value string field of length this.Size. Value is an array of characters here, not a pointer. A number of such aspects at least used to be difficult to express in DWARF, if at all possible, and we had to find a way for stabs as well, so we came up with an encoding scheme that only relies on simple attributes, typically field names. In the case above, for example, we get: - .uleb128 0x6 # (DIE (0x62) DW_TAG_structure_type) - .long .LASF7 # DW_AT_name: "t__tryblob__blob" + .uleb128 0x8 # (DIE (0x81) DW_TAG_structure_type) + .long .LASF13 # DW_AT_name: "t__tryblob__blob" + .long 0xb1 # DW_AT_GNU_descriptive_type ... + .uleb128 0x6 # (DIE (0xb1) DW_TAG_structure_type) + .long .LASF7 # DW_AT_name: "t__tryblob__blob___XVE" ... + .uleb128 0x7 # (DIE (0xcb) DW_TAG_member) + .long .LASF8 # DW_AT_name: "value___XVL" ... The full set of parallel types and encodings we use is described in exp_dbug.ads. This is all controlled by the proposed front-end hook so only impacts Ada at this stage. > Why can't dwarf2out generate the desired debug info based on the > primary type? This has been a long term project for us :) Now, there are many cases to account for, some particularily tricky, and this still represents a large amount of work in both the compiler (gigi + probably dwarf2out), and the debugger AFAIK. We have been using the parallel type circuitry for years and decided to propose its inclusion on the grounds that it's introduction is pretty light on the middle-end side and it makes a real immediate difference for Ada as GDB has everything already. Olivier ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-10-26 11:03 ` Olivier Hainque @ 2010-11-09 11:47 ` Olivier Hainque 2010-11-09 17:20 ` Michael Eager 0 siblings, 1 reply; 30+ messages in thread From: Olivier Hainque @ 2010-11-09 11:47 UTC (permalink / raw) To: Jason Merrill; +Cc: gcc-patches, brobecker, guitton, hainque Hi Jason, Any further opinion or question on this topic ? Thanks in advance, Olivier Olivier Hainque wrote: > Jason Merrill wrote: > > Sorry for the delay in review. > > No problem. Thanks for taking the time to get to it. > > > This patch looks reasonable, but I'm not sure why it's necessary. How > > does the generated debug info change with this patch? > > For a type with complex aspects (more below) we now also get debug info for > a "parallel" type with the complex aspects encoded within simple attributes > (e.g. in record field names), and an extra attribute is attached to the > original type DIE to designate the parallel type. > > The extra attribute code is AT_GNU_descriptive_type, and the value > is the DIE of the parallel type. GDB knows how to navigate and decode all > that for Ada. > > An example of complex aspect is a record field with a length > depending on another of the record fields, as in the example I posted > with the original patch submission: > > procedure Tryblob (X : Integer) is > > type Blob (Size : integer) is record > Value : string (1 .. Size); > end record; > > B : Blob (Size => X); > > Blob is a struct with a Size integer field and a Value string field > of length this.Size. Value is an array of characters here, not a pointer. > > A number of such aspects at least used to be difficult to express in DWARF, > if at all possible, and we had to find a way for stabs as well, so we came > up with an encoding scheme that only relies on simple attributes, typically > field names. > > In the case above, for example, we get: > > - .uleb128 0x6 # (DIE (0x62) DW_TAG_structure_type) > - .long .LASF7 # DW_AT_name: "t__tryblob__blob" > + .uleb128 0x8 # (DIE (0x81) DW_TAG_structure_type) > + .long .LASF13 # DW_AT_name: "t__tryblob__blob" > + .long 0xb1 # DW_AT_GNU_descriptive_type > ... > + .uleb128 0x6 # (DIE (0xb1) DW_TAG_structure_type) > + .long .LASF7 # DW_AT_name: "t__tryblob__blob___XVE" > ... > + .uleb128 0x7 # (DIE (0xcb) DW_TAG_member) > + .long .LASF8 # DW_AT_name: "value___XVL" > ... > > The full set of parallel types and encodings we use is described > in exp_dbug.ads. > > This is all controlled by the proposed front-end hook so only > impacts Ada at this stage. > > > Why can't dwarf2out generate the desired debug info based on the > > primary type? > > This has been a long term project for us :) > > Now, there are many cases to account for, some particularily tricky, and > this still represents a large amount of work in both the compiler (gigi + > probably dwarf2out), and the debugger AFAIK. > > We have been using the parallel type circuitry for years and decided to > propose its inclusion on the grounds that it's introduction is pretty light > on the middle-end side and it makes a real immediate difference for Ada as > GDB has everything already. > > Olivier > > > > > ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-11-09 11:47 ` Olivier Hainque @ 2010-11-09 17:20 ` Michael Eager 2010-11-09 19:11 ` Eric Botcazou 0 siblings, 1 reply; 30+ messages in thread From: Michael Eager @ 2010-11-09 17:20 UTC (permalink / raw) To: Olivier Hainque; +Cc: Jason Merrill, gcc-patches, brobecker, guitton Olivier Hainque wrote: > Hi Jason, > > Any further opinion or question on this topic ? Hi Oliver -- I took another look over the thread. I'm not very familiar with Ada, but I don't understand why your example requires a new DWARF type. I'm not familiar with this idea of a "parallel type" or what the "complex aspects" are that you mention. You show a snippet of code which shows printing 'b' at a breakpoint. Are 'B' and 'b' the same object? I would like to see how 'b' is currently described in DWARF and how you would propose changing it, so that I have a better understanding of why a debugger cannot print 'b' in detail. You might also want to discuss this on Dwarf-Discuss@lists.dwarfstd.org. > > Thanks in advance, > > Olivier > > Olivier Hainque wrote: >> Jason Merrill wrote: >>> Sorry for the delay in review. >> No problem. Thanks for taking the time to get to it. >> >>> This patch looks reasonable, but I'm not sure why it's necessary. How >>> does the generated debug info change with this patch? >> For a type with complex aspects (more below) we now also get debug info for >> a "parallel" type with the complex aspects encoded within simple attributes >> (e.g. in record field names), and an extra attribute is attached to the >> original type DIE to designate the parallel type. >> >> The extra attribute code is AT_GNU_descriptive_type, and the value >> is the DIE of the parallel type. GDB knows how to navigate and decode all >> that for Ada. >> >> An example of complex aspect is a record field with a length >> depending on another of the record fields, as in the example I posted >> with the original patch submission: >> >> procedure Tryblob (X : Integer) is >> >> type Blob (Size : integer) is record >> Value : string (1 .. Size); >> end record; >> >> B : Blob (Size => X); >> >> Blob is a struct with a Size integer field and a Value string field >> of length this.Size. Value is an array of characters here, not a pointer. >> >> A number of such aspects at least used to be difficult to express in DWARF, >> if at all possible, and we had to find a way for stabs as well, so we came >> up with an encoding scheme that only relies on simple attributes, typically >> field names. >> >> In the case above, for example, we get: >> >> - .uleb128 0x6 # (DIE (0x62) DW_TAG_structure_type) >> - .long .LASF7 # DW_AT_name: "t__tryblob__blob" >> + .uleb128 0x8 # (DIE (0x81) DW_TAG_structure_type) >> + .long .LASF13 # DW_AT_name: "t__tryblob__blob" >> + .long 0xb1 # DW_AT_GNU_descriptive_type >> ... >> + .uleb128 0x6 # (DIE (0xb1) DW_TAG_structure_type) >> + .long .LASF7 # DW_AT_name: "t__tryblob__blob___XVE" >> ... >> + .uleb128 0x7 # (DIE (0xcb) DW_TAG_member) >> + .long .LASF8 # DW_AT_name: "value___XVL" >> ... >> >> The full set of parallel types and encodings we use is described >> in exp_dbug.ads. >> >> This is all controlled by the proposed front-end hook so only >> impacts Ada at this stage. >> >>> Why can't dwarf2out generate the desired debug info based on the >>> primary type? >> This has been a long term project for us :) >> >> Now, there are many cases to account for, some particularily tricky, and >> this still represents a large amount of work in both the compiler (gigi + >> probably dwarf2out), and the debugger AFAIK. >> >> We have been using the parallel type circuitry for years and decided to >> propose its inclusion on the grounds that it's introduction is pretty light >> on the middle-end side and it makes a real immediate difference for Ada as >> GDB has everything already. >> >> Olivier >> >> >> >> >> > -- Michael Eager eager@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077 ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-11-09 17:20 ` Michael Eager @ 2010-11-09 19:11 ` Eric Botcazou 2010-11-09 21:11 ` Michael Eager 0 siblings, 1 reply; 30+ messages in thread From: Eric Botcazou @ 2010-11-09 19:11 UTC (permalink / raw) To: Michael Eager Cc: gcc-patches, Olivier Hainque, Jason Merrill, brobecker, guitton > I would like to see how 'b' is currently described in DWARF > and how you would propose changing it, so that I have a better > understanding of why a debugger cannot print 'b' in detail. The encoding of debug info generated by GNAT is entirely specified in the file src/gcc/ada/exp_dbug.ads. It's quite complex but the main idea is that, when common[*] features of the debug info format aren't sufficient, the compiler emits additional types that convey the missing info using some encoding; GDB then does the decoding. [*] we still support STABS so the encoding is mostly STABS/DWARF-agnostic. -- Eric Botcazou ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-11-09 19:11 ` Eric Botcazou @ 2010-11-09 21:11 ` Michael Eager 2010-11-09 21:17 ` Eric Botcazou 0 siblings, 1 reply; 30+ messages in thread From: Michael Eager @ 2010-11-09 21:11 UTC (permalink / raw) To: Eric Botcazou Cc: gcc-patches, Olivier Hainque, Jason Merrill, brobecker, guitton Eric Botcazou wrote: >> I would like to see how 'b' is currently described in DWARF >> and how you would propose changing it, so that I have a better >> understanding of why a debugger cannot print 'b' in detail. > > The encoding of debug info generated by GNAT is entirely specified in the file > src/gcc/ada/exp_dbug.ads. It's quite complex but the main idea is that, when > common[*] features of the debug info format aren't sufficient, the compiler > emits additional types that convey the missing info using some encoding; GDB > then does the decoding. I'm interested in seeing the DWARF which is generated for the specific example and what would be generated with the patch. -- Michael Eager eager@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077 ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-11-09 21:11 ` Michael Eager @ 2010-11-09 21:17 ` Eric Botcazou 2010-11-09 21:42 ` Joel Brobecker 2010-11-09 21:53 ` Michael Eager 0 siblings, 2 replies; 30+ messages in thread From: Eric Botcazou @ 2010-11-09 21:17 UTC (permalink / raw) To: Michael Eager Cc: gcc-patches, Olivier Hainque, Jason Merrill, brobecker, guitton > I'm interested in seeing the DWARF which is generated for the specific > example and what would be generated with the patch. You can already see it with unpatched GNAT compilers; the only missing thing is the DW_AT_GNU_descriptive_type that links a type to the additional types generated to encode its debug info. -- Eric Botcazou ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-11-09 21:17 ` Eric Botcazou @ 2010-11-09 21:42 ` Joel Brobecker 2010-11-09 21:53 ` Michael Eager 1 sibling, 0 replies; 30+ messages in thread From: Joel Brobecker @ 2010-11-09 21:42 UTC (permalink / raw) To: Eric Botcazou Cc: Michael Eager, gcc-patches, Olivier Hainque, Jason Merrill, guitton > > I'm interested in seeing the DWARF which is generated for the specific > > example and what would be generated with the patch. > > You can already see it with unpatched GNAT compilers; the only missing thing > is the DW_AT_GNU_descriptive_type that links a type to the additional types > generated to encode its debug info. In other words, it's a performance improvement for the debugger. Instead of performing the lookup by name, we have direct access to it. -- Joel ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-11-09 21:17 ` Eric Botcazou 2010-11-09 21:42 ` Joel Brobecker @ 2010-11-09 21:53 ` Michael Eager 2010-11-09 22:07 ` Joel Brobecker 1 sibling, 1 reply; 30+ messages in thread From: Michael Eager @ 2010-11-09 21:53 UTC (permalink / raw) To: Eric Botcazou Cc: gcc-patches, Olivier Hainque, Jason Merrill, brobecker, guitton Eric Botcazou wrote: >> I'm interested in seeing the DWARF which is generated for the specific >> example and what would be generated with the patch. > > You can already see it with unpatched GNAT compilers; the only missing thing > is the DW_AT_GNU_descriptive_type that links a type to the additional types > generated to encode its debug info. I don't have time (or interest) in building an ada compiler with and without a patch and reproducing some one else's test case. -- Michael Eager eager@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077 ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-11-09 21:53 ` Michael Eager @ 2010-11-09 22:07 ` Joel Brobecker 2010-11-10 0:02 ` Michael Eager 0 siblings, 1 reply; 30+ messages in thread From: Joel Brobecker @ 2010-11-09 22:07 UTC (permalink / raw) To: Michael Eager Cc: Eric Botcazou, gcc-patches, Olivier Hainque, Jason Merrill, guitton Michael, > I don't have time (or interest) in building an ada > compiler with and without a patch and reproducing > some one else's test case. I'm just trying to understand how you're trying to help in this discussion. It sounds to me like you wanted to look at the debugging info generated by the compiler for some of the constructs that trigger these parallel types, and help finding better ways of generating the associated DWARF. If this is what you were trying to do, then that's beside the point of this attribute. We know that the DWARF data generated by the compiler is sub-optimal, and that in theory we should be able to express most of the stuff using standard DWARF. However, in practice, enhancing the compiler to do so is a very large project in itself for which we do not anticipate having much time for. This patch will make things much better for the Ada enthusiasts out there at a small cost in terms of GCC code (one lang hook, IIRC?). -- Joel ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-11-09 22:07 ` Joel Brobecker @ 2010-11-10 0:02 ` Michael Eager 2010-11-10 5:55 ` Joel Brobecker 0 siblings, 1 reply; 30+ messages in thread From: Michael Eager @ 2010-11-10 0:02 UTC (permalink / raw) To: Joel Brobecker Cc: Eric Botcazou, gcc-patches, Olivier Hainque, Jason Merrill, guitton Joel Brobecker wrote: > Michael, > >> I don't have time (or interest) in building an ada >> compiler with and without a patch and reproducing >> some one else's test case. > > I'm just trying to understand how you're trying to help in this > discussion. It sounds to me like you wanted to look at the debugging > info generated by the compiler for some of the constructs that > trigger these parallel types, and help finding better ways of > generating the associated DWARF. Yes. If there is a better way to describe the source using existing DWARF constructs, I'd like to be able to recommend it. If there is a need for an enhancement or extension to describe Ada better, I'm interested. > If this is what you were trying > to do, then that's beside the point of this attribute. We know > that the DWARF data generated by the compiler is sub-optimal, > and that in theory we should be able to express most of the stuff > using standard DWARF. However, in practice, enhancing the compiler > to do so is a very large project in itself for which we do not > anticipate having much time for. This patch will make things > much better for the Ada enthusiasts out there at a small cost > in terms of GCC code (one lang hook, IIRC?). I've seen several cases where a compiler was generating DWARF in a way that was awkward. The compiler writers wanted to add extensions to DWARF to work around the problems they had caused. I don't know whether that is the case here. Extensions tend become de facto standard. Rather than have that happen, I'd like to understand the root problem and fix that rather than patch over it with an extension. -- Michael Eager eager@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077 ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-11-10 0:02 ` Michael Eager @ 2010-11-10 5:55 ` Joel Brobecker 2010-11-10 7:33 ` Michael Eager 2010-11-10 8:34 ` Olivier Hainque 0 siblings, 2 replies; 30+ messages in thread From: Joel Brobecker @ 2010-11-10 5:55 UTC (permalink / raw) To: Michael Eager Cc: Eric Botcazou, gcc-patches, Olivier Hainque, Jason Merrill, guitton > Yes. If there is a better way to describe the source > using existing DWARF constructs, I'd like to be able > to recommend it. If there is a need for an enhancement > or extension to describe Ada better, I'm interested. What we are trying to say, here, is that this patch is not related to that objective. We already know how to properly describe most of the entities used in Ada. We hope to get to that, one day, but it's a big project, and I don't see that happening for a while. So, instead, we're stuck with the GNAT encoding (which is documented in exp_dbug.ads). The GNAT encoding has the good property of working regardless of the debugging format - in other words, it can work even with STABS. Like it or not, we are still stuck with stabs on some platforms. In any case, the GNAT encoding is designed mostly around parallel types - and I will give an example later if that helps understand things. What that means is that the compiler creates artificial types that help us convey semantic information about other types. The downside of this approach is that it requires the debugger to search, by name, for those parallel types. On large applications, this can be expensive. Example: Consider for instance the following array whose upper bound is dynamic: type My_Array is array (1 .. Upper_Bound) of Integer; With STABS, you can't express the value of the upper bound as a dynamic value. So the compiler generates a parallel type, named my_array___XA which helps us determine the bounds. In particular, the XA type will tell us, through a mechanism that I won't bore you with but is documented in exp_dbug.ads that the upper bound is dynamic, and that its value is to be found by getting the value of Upper_Bound. So the issue, when trying to print an object of type My_Array, is to find that ___XA type in order to find the value of the upper bound. With STABS, we're stuck, we have to do the lookup. But with DWARF, we've been using an extension, an attribute, that links type My_Array directly to its associated ___XA type. Getting to the ___XA type becomes instantaneous. That's what we're talking about here: A performance improvement that allows the debugger to quickly find the required parallel type, instead of doing the expensive global lookup. The fact that it is tied to DWARF right now is only an implementation detail. If we could do the same with STABS, we'd no doubt do it too. I realize that this is not ideal. We should be generating perfect DWARF. But we don't. And we won't, at least for a while. In the meantime, let's make it easier for the Ada fans out there, to debug their Ada code. Before I joined AdaCore, I used to depend on their yearly public releases to get improvements. It was 10 years go, but I haven't forgotten about that time. Although I believe the situation is a hundred times better today, particularly in terms of code generation, we still have ways to go in terms of debugging Ada. I hope that convinces helps you understand the context and convince you that this should never affect the DWARF standard. And I hope that this shows that this change will provide immediate positive improvements at virtually no cost to the compiler. -- Joel ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-11-10 5:55 ` Joel Brobecker @ 2010-11-10 7:33 ` Michael Eager 2010-11-10 8:34 ` Olivier Hainque 1 sibling, 0 replies; 30+ messages in thread From: Michael Eager @ 2010-11-10 7:33 UTC (permalink / raw) To: Joel Brobecker Cc: Eric Botcazou, gcc-patches, Olivier Hainque, Jason Merrill, guitton Joel Brobecker wrote: > I hope that convinces helps you understand the context and convince > you that this should never affect the DWARF standard. And I hope > that this shows that this change will provide immediate positive > improvements at virtually no cost to the compiler. Thanks for taking the time to explain. -- Michael Eager eager@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077 ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING*4] add support for dwarf AT_GNU_descriptive_type 2010-11-10 5:55 ` Joel Brobecker 2010-11-10 7:33 ` Michael Eager @ 2010-11-10 8:34 ` Olivier Hainque 1 sibling, 0 replies; 30+ messages in thread From: Olivier Hainque @ 2010-11-10 8:34 UTC (permalink / raw) To: Joel Brobecker Cc: Michael Eager, Eric Botcazou, gcc-patches, Jason Merrill, guitton > That's what we're talking about here: A performance improvement > that allows the debugger to quickly find the required parallel > type, instead of doing the expensive global lookup. Actually, on fsf mainline, the patch also happens to trigger the production of dwarf info for the parallel types, so there is more than just a perf objective. There is no just way to get proper display of many things today, not even slow, and the patch addresses that as well. Olivier ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: add support for dwarf AT_descriptive_type 2010-09-02 14:51 add support for dwarf AT_descriptive_type Olivier Hainque ` (3 preceding siblings ...) 2010-10-18 9:11 ` [PING*4] " Olivier Hainque @ 2010-10-24 22:57 ` Michael Eager 2010-10-26 11:03 ` Olivier Hainque 2011-02-18 5:29 ` [PING #5] " Joel Brobecker 5 siblings, 1 reply; 30+ messages in thread From: Michael Eager @ 2010-10-24 22:57 UTC (permalink / raw) To: Olivier Hainque; +Cc: gcc-patches, brobecker, guitton Olivier Hainque wrote: > For a few years now, we have been maintaining local changes to have > these descriptive types emitted and easy to find by GDB. This is a > proposal to integrate these changes. I suggest that you submit a proposal to add this to the DWARF specification: http://dwarfstd.org/Comment.php -- Michael Eager eager@eagercon.com 1960 Park Blvd., Palo Alto, CA 94306 650-325-8077 ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: add support for dwarf AT_descriptive_type 2010-10-24 22:57 ` add support for dwarf AT_descriptive_type Michael Eager @ 2010-10-26 11:03 ` Olivier Hainque 2010-10-27 18:32 ` Joel Brobecker 0 siblings, 1 reply; 30+ messages in thread From: Olivier Hainque @ 2010-10-26 11:03 UTC (permalink / raw) To: Michael Eager; +Cc: gcc-patches, brobecker, guitton, hainque Michael Eager wrote: > I suggest that you submit a proposal to add this to > the DWARF specification: http://dwarfstd.org/Comment.php Understood. I'll look into it if we get to an agreement on the scheme. Thanks for your feedback, Olivier ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: add support for dwarf AT_descriptive_type 2010-10-26 11:03 ` Olivier Hainque @ 2010-10-27 18:32 ` Joel Brobecker 2010-10-27 18:35 ` Jakub Jelinek 0 siblings, 1 reply; 30+ messages in thread From: Joel Brobecker @ 2010-10-27 18:32 UTC (permalink / raw) To: Olivier Hainque; +Cc: Michael Eager, gcc-patches, guitton > > I suggest that you submit a proposal to add this to > > the DWARF specification: http://dwarfstd.org/Comment.php > > Understood. I'll look into it if we get to an agreement on the scheme. I'm not sure this really makes sense for the DWARF standard. This attribute is really meant as a clutch to stand on until we can get GNAT to produce pure-dwarf info... -- Joel ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: add support for dwarf AT_descriptive_type 2010-10-27 18:32 ` Joel Brobecker @ 2010-10-27 18:35 ` Jakub Jelinek 2010-10-27 18:37 ` Joel Brobecker 0 siblings, 1 reply; 30+ messages in thread From: Jakub Jelinek @ 2010-10-27 18:35 UTC (permalink / raw) To: Joel Brobecker; +Cc: Olivier Hainque, Michael Eager, gcc-patches, guitton On Wed, Oct 27, 2010 at 01:00:55PM -0400, Joel Brobecker wrote: > > > I suggest that you submit a proposal to add this to > > > the DWARF specification: http://dwarfstd.org/Comment.php > > > > Understood. I'll look into it if we get to an agreement on the scheme. > > I'm not sure this really makes sense for the DWARF standard. This > attribute is really meant as a clutch to stand on until we can get > GNAT to produce pure-dwarf info... Could you please use DW_AT_GNU_use_descriptive_type instead of DW_AT_use_GNU_descriptive_type , so that DW_AT_GNU_* is a common prefix for GNU attribute extensions? Jakub ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: add support for dwarf AT_descriptive_type 2010-10-27 18:35 ` Jakub Jelinek @ 2010-10-27 18:37 ` Joel Brobecker 0 siblings, 0 replies; 30+ messages in thread From: Joel Brobecker @ 2010-10-27 18:37 UTC (permalink / raw) To: Jakub Jelinek; +Cc: Olivier Hainque, Michael Eager, gcc-patches, guitton > Could you please use > DW_AT_GNU_use_descriptive_type > instead of > DW_AT_use_GNU_descriptive_type > , so that DW_AT_GNU_* is a common prefix for GNU attribute extensions? Sure, that's a good suggestion, we can make that change. -- Joel ^ permalink raw reply [flat|nested] 30+ messages in thread
* [PING #5] add support for dwarf AT_descriptive_type 2010-09-02 14:51 add support for dwarf AT_descriptive_type Olivier Hainque ` (4 preceding siblings ...) 2010-10-24 22:57 ` add support for dwarf AT_descriptive_type Michael Eager @ 2011-02-18 5:29 ` Joel Brobecker 2011-02-21 5:05 ` Jason Merrill 5 siblings, 1 reply; 30+ messages in thread From: Joel Brobecker @ 2011-02-18 5:29 UTC (permalink / raw) To: Olivier Hainque; +Cc: gcc-patches, guitton Hello GCC Maintainers, I would really appreciate a review of this patch. So far, there was one request to change DW_AT_use_GNU_descriptive_type into DW_AT_GNU_use_descriptive_type, which we can do, but other than that, no real review. Once this is in, we can start contributing other patches that depends on this, and steadily improve the debugging info generated by GCC for Ada code. It really is an important patch for me, because I want the debugging experience for people using the FSF version of the tools to improve. Before I joined AdaCore, I used to depend on these versions. Note: the new DWARF attributes are explained at http://gcc.gnu.org/wiki/DW_AT_GNU_descriptive_type Thank you! On Thu, Sep 02, 2010 at 04:38:49PM +0200, Olivier Hainque wrote: > Hello, > > Ada allows the definition of particularily complex types and we use a parallel > type system to let GDB understand them. > > Roughly, particularities of a complex type T are encoded in the name of fields > in a so-called "descriptive" type associated with T. See ada/exp_dbug.ads for > details. > > For a few years now, we have been maintaining local changes to have > these descriptive types emitted and easy to find by GDB. This is a > proposal to integrate these changes. > > The immediate benefit is improved support for Ada in the debugger, for > example on the following kind of construct: > > procedure T is > procedure Tryblob (X : Integer) is > > type Blob (Size : integer) is record > Value : string (1 .. Size); > end record; > > B : Blob (Size => X); > > begin > B.Value := (others => 'A'); > null; -- break here, then query on B > end; > begin > Tryblob (X => 5); > end; > > With today's debug info, gdb 7.1 at the breakpoint yields > > (gdb) p b > $1 = (size => 5, value => "") > (gdb) ptype b.value > type = array (1 .. 0) of character > > With the patch we get the following instead, as expected: > > (gdb) p b > $1 = (size => 5, value => "AAAAA") > (gdb) ptype b.value > type = array (1 .. size) of character > > For efficiency purposes, we emit a dwarf attribute for a type T to > designate its descriptive type when there is one. GDB has fallback > strategies if this is not done, but these involve pretty expensive > searches making the whole thing unuseable in practice on industrial > applications. > > There are provisions for this in dwarf2.h already: > > << /* GNAT descriptive type. > See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type . */ > DW_AT_use_GNAT_descriptive_type = 0x2301, > DW_AT_GNAT_descriptive_type = 0x2302, > >> > > The patch introduces a langhook to let dwarf2out query the front-end about a > possible descriptive type, and from there generate the corresponding DIE and > attribute as needed. > > The query, the lazy DIE generation and the attribute reference are all > factored in a new "add_descriptive_type_attribute" function, called > from the few places where the need/existence of a potential > descriptive type is expected. > > In addition, even if only the Ada compiler uses this today, there is > no strong reason for the attribute to be explictly GNAT specific, so > the patch renames AT_GNAT_descriptive_type into AT_GNU_descriptive_type. > > We'll take care of updating the wiki page if the change gets approved. > > I realize that the addition of a langhook is in general not welcome for lto. > My understanding is that it remains acceptable for debug info generation > purposes. If that is not the case, we'd be happy to discuss alternate > possible schemes. > > The attached patch was bootstrapped and regession tested on x86_64-suse-linux, > both for gdb and gcc --languages=all,ada. > > Thanks much in advance for your feedback, > > Olivier > > 2010-09-01 Olivier Hainque <hainque@adacore.com> > Nicolas Setton <setton@adacore.com> > Eric Botcazou <ebotcazou@adacore.com> > > include/ > * dwarf2.h (dwarf_attribute): Replace the DW_AT_GNAT prefix by > DW_AT_GNU in descriptive types attribute names. > > gcc/ > * dwarf2out.c (dwarf_attr_name): Map DW_AT_GNU_descriptive_type. > (add_descriptive_type_attribute): New function. > (gen_array_type_die): Call it. > (gen_enumeration_type_die): Likewise. > (gen_struct_or_union_type_die): Likewise. > (modified_type_die): Likewise. > * langhooks.h (lang_hooks_for_types): New "descriptive_type" hook. > * langhooks-def.h (LANG_HOOKS_DESCRIPTIVE_TYPE): Default to NULL_TREE. > (LANG_HOOKS_FOR_TYPES_INITIALIZER): Add LANG_HOOKS_DESCRIPTIVE_TYPE. > > ada/ > * gcc-interface/trans.c (gigi): Remove internal call to > dwarf2out_set_descriptive_type_func. > * gcc-interface/utils.c (get_parallel_type): Move and rename into ... > * gcc-interface/misc.c (gnat_descriptive_type): New function. > (LANG_HOOKS_DESCRIPTIVE_TYPE): Redefine to gnat_descriptive_type. > Index: include/dwarf2.h > =================================================================== > *** include/dwarf2.h (revision 163722) > --- include/dwarf2.h (working copy) > *************** enum dwarf_attribute > *** 440,450 **** > DW_AT_GNU_template_name = 0x2110, > /* VMS extensions. */ > DW_AT_VMS_rtnbeg_pd_address = 0x2201, > ! /* GNAT extensions. */ > ! /* GNAT descriptive type. > ! See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type . */ > ! DW_AT_use_GNAT_descriptive_type = 0x2301, > ! DW_AT_GNAT_descriptive_type = 0x2302, > /* UPC extension. */ > DW_AT_upc_threads_scaled = 0x3210, > /* PGI (STMicroelectronics) extensions. */ > --- 440,449 ---- > DW_AT_GNU_template_name = 0x2110, > /* VMS extensions. */ > DW_AT_VMS_rtnbeg_pd_address = 0x2201, > ! /* Descriptive types. > ! See http://gcc.gnu.org/wiki/DW_AT_GNU_descriptive_type . */ > ! DW_AT_use_GNU_descriptive_type = 0x2301, > ! DW_AT_GNU_descriptive_type = 0x2302, > /* UPC extension. */ > DW_AT_upc_threads_scaled = 0x3210, > /* PGI (STMicroelectronics) extensions. */ > Index: dwarf2out.c > =================================================================== > *** dwarf2out.c (revision 163722) > --- dwarf2out.c (working copy) > *************** static bool add_location_or_const_value_ > *** 6263,6268 **** > --- 6263,6269 ---- > static bool tree_add_const_value_attribute (dw_die_ref, tree); > static bool tree_add_const_value_attribute_for_decl (dw_die_ref, tree); > static void add_name_attribute (dw_die_ref, const char *); > + static void add_descriptive_type_attribute (dw_die_ref, tree, dw_die_ref); > static void add_comp_dir_attribute (dw_die_ref); > static void add_bound_info (dw_die_ref, enum dwarf_attribute, tree); > static void add_subscript_info (dw_die_ref, tree, bool); > *************** dwarf_attr_name (unsigned int attr) > *** 6909,6914 **** > --- 6910,6917 ---- > return "DW_AT_GNU_odr_signature"; > case DW_AT_GNU_template_name: > return "DW_AT_GNU_template_name"; > + case DW_AT_GNU_descriptive_type: > + return "DW_AT_GNU_descriptive_type"; > > case DW_AT_VMS_rtnbeg_pd_address: > return "DW_AT_VMS_rtnbeg_pd_address"; > *************** modified_type_die (tree type, int is_con > *** 12781,12786 **** > --- 12784,12790 ---- > useful source coordinates anyway. */ > name = DECL_NAME (name); > add_name_attribute (mod_type_die, IDENTIFIER_POINTER (name)); > + add_descriptive_type_attribute (mod_type_die, type, context_die); > } > /* This probably indicates a bug. */ > else if (mod_type_die && mod_type_die->die_tag == DW_TAG_base_type) > *************** add_name_attribute (dw_die_ref die, cons > *** 16997,17002 **** > --- 17001,17032 ---- > } > } > > + /* Retrieve the descriptive type for TYPE, if any, make sure it has > + a DIE and attach a DW_AT_GNU_descriptive_type to the DIE of TYPE > + accordingly. */ > + > + static void > + add_descriptive_type_attribute (dw_die_ref die, tree type, > + dw_die_ref context_die) > + { > + tree dtype; > + dw_die_ref dtype_die; > + > + dtype = lang_hooks.types.descriptive_type (type); > + if (!dtype) > + return; > + > + dtype_die = lookup_type_die (dtype); > + if (!dtype_die) > + { > + gen_type_die (dtype, context_die); > + dtype_die = lookup_type_die (dtype); > + gcc_assert (dtype_die); > + } > + > + add_AT_die_ref (die, DW_AT_GNU_descriptive_type, dtype_die); > + } > + > /* Generate a DW_AT_comp_dir attribute for DIE. */ > > static void > *************** gen_array_type_die (tree type, dw_die_re > *** 17863,17868 **** > --- 17893,17899 ---- > > array_die = new_die (DW_TAG_array_type, scope_die, type); > add_name_attribute (array_die, type_tag (type)); > + add_descriptive_type_attribute (array_die, type, context_die); > equate_type_number_to_die (type, array_die); > > if (TREE_CODE (type) == VECTOR_TYPE) > *************** gen_enumeration_type_die (tree type, dw_ > *** 18160,18165 **** > --- 18191,18197 ---- > scope_die_for (type, context_die), type); > equate_type_number_to_die (type, type_die); > add_name_attribute (type_die, type_tag (type)); > + add_descriptive_type_attribute (type_die, type, context_die); > if ((dwarf_version >= 4 || !dwarf_strict) > && ENUM_IS_SCOPED (type)) > add_AT_flag (type_die, DW_AT_enum_class, 1); > *************** gen_struct_or_union_type_die (tree type, > *** 19684,19690 **** > if (old_die) > add_AT_specification (type_die, old_die); > else > ! add_name_attribute (type_die, type_tag (type)); > } > else > remove_AT (type_die, DW_AT_declaration); > --- 19716,19725 ---- > if (old_die) > add_AT_specification (type_die, old_die); > else > ! { > ! add_name_attribute (type_die, type_tag (type)); > ! add_descriptive_type_attribute (type_die, type, context_die); > ! } > } > else > remove_AT (type_die, DW_AT_declaration); > Index: langhooks.h > =================================================================== > *** langhooks.h (revision 163722) > --- langhooks.h (working copy) > *************** struct lang_hooks_for_types > *** 133,138 **** > --- 133,142 ---- > /* Fill in information for the debugger about the bounds of TYPE. */ > void (*get_subrange_bounds) (const_tree, tree *, tree *); > > + /* A type descriptive of TYPE complex layout particularities to help the > + debugger with e.g. variable length or self referential contructs. */ > + tree (*descriptive_type) (const_tree); > + > /* If we requested a pointer to a vector, build up the pointers that > we stripped off while looking for the inner type. Similarly for > return values from functions. The argument TYPE is the top of the > Index: langhooks-def.h > =================================================================== > *** langhooks-def.h (revision 163722) > --- langhooks-def.h (working copy) > *************** extern tree lhd_make_node (enum tree_cod > *** 177,182 **** > --- 177,183 ---- > #define LANG_HOOKS_TYPE_HASH_EQ NULL > #define LANG_HOOKS_GET_ARRAY_DESCR_INFO NULL > #define LANG_HOOKS_GET_SUBRANGE_BOUNDS NULL > + #define LANG_HOOKS_DESCRIPTIVE_TYPE lhd_return_null_const_tree > #define LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE reconstruct_complex_type > #define LANG_HOOKS_HASH_TYPES true > > *************** extern tree lhd_make_node (enum tree_cod > *** 195,200 **** > --- 196,202 ---- > LANG_HOOKS_TYPE_HASH_EQ, \ > LANG_HOOKS_GET_ARRAY_DESCR_INFO, \ > LANG_HOOKS_GET_SUBRANGE_BOUNDS, \ > + LANG_HOOKS_DESCRIPTIVE_TYPE, \ > LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE, \ > LANG_HOOKS_HASH_TYPES \ > } > Index: ada/gcc-interface/utils.c > =================================================================== > *** ada/gcc-interface/utils.c (revision 163722) > --- ada/gcc-interface/utils.c (working copy) > *************** add_parallel_type (tree decl, tree paral > *** 952,968 **** > SET_DECL_PARALLEL_TYPE (d, parallel_type); > } > > - /* Return the parallel type associated to a type, if any. */ > - > - tree > - get_parallel_type (tree type) > - { > - if (TYPE_STUB_DECL (type)) > - return DECL_PARALLEL_TYPE (TYPE_STUB_DECL (type)); > - else > - return NULL_TREE; > - } > - > /* Utility function of above to merge LAST_SIZE, the previous size of a record > with FIRST_BIT and SIZE that describe a field. SPECIAL is true if this > represents a QUAL_UNION_TYPE in which case we must look for COND_EXPRs and > --- 952,957 ---- > Index: ada/gcc-interface/trans.c > =================================================================== > *** ada/gcc-interface/trans.c (revision 163722) > --- ada/gcc-interface/trans.c (working copy) > *************** gigi (Node_Id gnat_root, int max_gnat_no > *** 295,301 **** > dwarf2out_set_type_encoding_func (extract_encoding); > dwarf2out_set_demangle_name_func (decode_name); > } > - dwarf2out_set_descriptive_type_func (get_parallel_type); > #endif > > /* Enable GNAT stack checking method if needed */ > --- 295,300 ---- > Index: ada/gcc-interface/misc.c > =================================================================== > *** ada/gcc-interface/misc.c (revision 163722) > --- ada/gcc-interface/misc.c (working copy) > *************** static void internal_error_function (dia > *** 78,83 **** > --- 78,84 ---- > const char *, va_list *); > static tree gnat_type_max_size (const_tree); > static void gnat_get_subrange_bounds (const_tree, tree *, tree *); > + static tree gnat_descriptive_type (const_tree); > static tree gnat_eh_personality (void); > > /* Definitions for our language-specific hooks. */ > *************** static tree gnat_eh_personality (void); > *** 128,133 **** > --- 129,136 ---- > #define LANG_HOOKS_TYPES_COMPATIBLE_P gnat_types_compatible_p > #undef LANG_HOOKS_GET_SUBRANGE_BOUNDS > #define LANG_HOOKS_GET_SUBRANGE_BOUNDS gnat_get_subrange_bounds > + #undef LANG_HOOKS_DESCRIPTIVE_TYPE > + #define LANG_HOOKS_DESCRIPTIVE_TYPE gnat_descriptive_type > #undef LANG_HOOKS_ATTRIBUTE_TABLE > #define LANG_HOOKS_ATTRIBUTE_TABLE gnat_internal_attribute_table > #undef LANG_HOOKS_BUILTIN_FUNCTION > *************** gnat_dwarf_name (tree decl, int verbosit > *** 584,589 **** > --- 587,603 ---- > return (const char *) IDENTIFIER_POINTER (DECL_NAME (decl)); > } > > + /* Return the descriptive type associated to TYPE, if any. */ > + > + static tree > + gnat_descriptive_type (const_tree type) > + { > + if (TYPE_STUB_DECL (type)) > + return DECL_PARALLEL_TYPE (TYPE_STUB_DECL (type)); > + else > + return NULL_TREE; > + } > + > /* Do nothing (return the tree node passed). */ > > static tree -- Joel ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING #5] add support for dwarf AT_descriptive_type 2011-02-18 5:29 ` [PING #5] " Joel Brobecker @ 2011-02-21 5:05 ` Jason Merrill 2011-02-21 6:56 ` Jason Merrill 2011-02-22 17:44 ` Olivier Hainque 0 siblings, 2 replies; 30+ messages in thread From: Jason Merrill @ 2011-02-21 5:05 UTC (permalink / raw) To: gcc-patches; +Cc: Olivier Hainque, gcc-patches, guitton > On Thu, Sep 02, 2010 at 04:38:49PM +0200, Olivier Hainque wrote: Sorry about the slow review. >> In addition, even if only the Ada compiler uses this today, there is >> no strong reason for the attribute to be explictly GNAT specific, so >> the patch renames AT_GNAT_descriptive_type into AT_GNU_descriptive_type. From the earlier discussion, it sounded like this format isn't actually any more expressive than normal DWARF, this patch just provides better debugging functionality as a transitionary measure until we implement better Ada DWARF support. So giving it a more generic name seems undesirable. >> Index: ada/gcc-interface/trans.c >> =================================================================== >> *** ada/gcc-interface/trans.c (revision 163722) >> --- ada/gcc-interface/trans.c (working copy) >> *************** gigi (Node_Id gnat_root, int max_gnat_no >> *** 295,301 **** >> dwarf2out_set_type_encoding_func (extract_encoding); >> dwarf2out_set_demangle_name_func (decode_name); >> } >> - dwarf2out_set_descriptive_type_func (get_parallel_type); >> #endif This code doesn't seem to be in FSF GCC. How does it work? Jason ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING #5] add support for dwarf AT_descriptive_type 2011-02-21 5:05 ` Jason Merrill @ 2011-02-21 6:56 ` Jason Merrill 2011-02-22 17:44 ` Olivier Hainque 1 sibling, 0 replies; 30+ messages in thread From: Jason Merrill @ 2011-02-21 6:56 UTC (permalink / raw) To: Joel Brobecker; +Cc: Olivier Hainque, gcc-patches, guitton > On Thu, Sep 02, 2010 at 04:38:49PM +0200, Olivier Hainque wrote: Sorry about the slow review. >> In addition, even if only the Ada compiler uses this today, there is >> no strong reason for the attribute to be explictly GNAT specific, so >> the patch renames AT_GNAT_descriptive_type into AT_GNU_descriptive_type. From the earlier discussion, it sounded like this format isn't actually any more expressive than normal DWARF, this patch just provides better debugging functionality as a transitionary measure until we implement better Ada DWARF support. So giving it a more generic name seems undesirable. >> Index: ada/gcc-interface/trans.c >> =================================================================== >> *** ada/gcc-interface/trans.c (revision 163722) >> --- ada/gcc-interface/trans.c (working copy) >> *************** gigi (Node_Id gnat_root, int max_gnat_no >> *** 295,301 **** >> dwarf2out_set_type_encoding_func (extract_encoding); >> dwarf2out_set_demangle_name_func (decode_name); >> } >> - dwarf2out_set_descriptive_type_func (get_parallel_type); >> #endif This code doesn't seem to be in FSF GCC. How does it work? Jason ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING #5] add support for dwarf AT_descriptive_type 2011-02-21 5:05 ` Jason Merrill 2011-02-21 6:56 ` Jason Merrill @ 2011-02-22 17:44 ` Olivier Hainque 2011-02-23 1:49 ` Jason Merrill 1 sibling, 1 reply; 30+ messages in thread From: Olivier Hainque @ 2011-02-22 17:44 UTC (permalink / raw) To: Jason Merrill; +Cc: Joel Brobecker, gcc-patches, guitton Jason Merrill wrote: >> On Thu, Sep 02, 2010 at 04:38:49PM +0200, Olivier Hainque wrote: > > Sorry about the slow review. No problem, thanks for getting back to it Jason. Really appreciated. > From the earlier discussion, it sounded like this format isn't actually > any more expressive than normal DWARF, this patch just provides better > debugging functionality as a transitionary measure until we implement > better Ada DWARF support. Right, which is a big project and will take time. > So giving it a more generic name seems undesirable. This came out as the result of several thoughts in the process of reworking the change for submission. Internally, we used to have a static pointer to function in dwarf2out, that our front-end was setting somehow. That seemed dirty to me, so the first adjustment was to turn this into a regular langhook, and having that generate a GNAT specific attribute looked really awkward. In addition, I really tought that you might not like seing explicitly Ada/GNAT specific bits scattered in dwarf2out functions, and it made some sense to introduce the new attribute as a potentially useful device for any language (allow an additional association of one type with another), that only Ada would happen to leverage. Of course, I'd be happy to adjust the way you prefer. >>> Index: ada/gcc-interface/trans.c >>> =================================================================== >>> *** ada/gcc-interface/trans.c (revision 163722) >>> --- ada/gcc-interface/trans.c (working copy) >>> *************** gigi (Node_Id gnat_root, int max_gnat_no >>> *** 295,301 **** >>> dwarf2out_set_type_encoding_func (extract_encoding); >>> dwarf2out_set_demangle_name_func (decode_name); >>> } >>> - dwarf2out_set_descriptive_type_func (get_parallel_type); >>> #endif > > This code doesn't seem to be in FSF GCC. How does it work? This is part of our internal "set static dwarf2out language hook" scheme I mentioned above. This hunk can be ignored. Thanks for your feedback, Olivier ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING #5] add support for dwarf AT_descriptive_type 2011-02-22 17:44 ` Olivier Hainque @ 2011-02-23 1:49 ` Jason Merrill 2011-02-23 10:56 ` Olivier Hainque 0 siblings, 1 reply; 30+ messages in thread From: Jason Merrill @ 2011-02-23 1:49 UTC (permalink / raw) To: Olivier Hainque; +Cc: Joel Brobecker, gcc-patches, guitton On 02/22/2011 12:24 PM, Olivier Hainque wrote: > Internally, we used to have a static pointer to function in dwarf2out, > that our front-end was setting somehow. That seemed dirty to me, so the > first adjustment was to turn this into a regular langhook, and having > that generate a GNAT specific attribute looked really awkward. Aha. Turning it into a regular langhook is definitely the way to go, but I think I'd prefer to leave it clearly GNAT-specific (and documented as something that ought to be replaced with a better solution). Jason ^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PING #5] add support for dwarf AT_descriptive_type 2011-02-23 1:49 ` Jason Merrill @ 2011-02-23 10:56 ` Olivier Hainque 0 siblings, 0 replies; 30+ messages in thread From: Olivier Hainque @ 2011-02-23 10:56 UTC (permalink / raw) To: Jason Merrill; +Cc: Joel Brobecker, gcc-patches, guitton, hainque Jason Merrill wrote: > Turning it into a regular langhook is definitely the way to go, but I > think I'd prefer to leave it clearly GNAT-specific (and documented as > something that ought to be replaced with a better solution). OK, reworking accordingly. Actually, the langhook doesn't quite generate the attribute, but provides the type that the attribute designates. One possible way to present that is then to revert to an explicitly GNAT specific attribute, leave the langhook name untouched and document that it's only used by the Ada front-end for a GNAT specific attribute support. Would something along those lines work for you ? Olivier ^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2011-02-23 9:12 UTC | newest] Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-09-02 14:51 add support for dwarf AT_descriptive_type Olivier Hainque 2010-09-15 11:21 ` [ping] " Olivier Hainque 2010-09-27 15:29 ` [ping*2] add support for dwarf AT_GNU_descriptive_type Olivier Hainque 2010-10-06 20:44 ` [ping*3] " Olivier Hainque 2010-10-18 9:11 ` [PING*4] " Olivier Hainque 2010-10-24 20:50 ` Jason Merrill 2010-10-26 11:03 ` Olivier Hainque 2010-11-09 11:47 ` Olivier Hainque 2010-11-09 17:20 ` Michael Eager 2010-11-09 19:11 ` Eric Botcazou 2010-11-09 21:11 ` Michael Eager 2010-11-09 21:17 ` Eric Botcazou 2010-11-09 21:42 ` Joel Brobecker 2010-11-09 21:53 ` Michael Eager 2010-11-09 22:07 ` Joel Brobecker 2010-11-10 0:02 ` Michael Eager 2010-11-10 5:55 ` Joel Brobecker 2010-11-10 7:33 ` Michael Eager 2010-11-10 8:34 ` Olivier Hainque 2010-10-24 22:57 ` add support for dwarf AT_descriptive_type Michael Eager 2010-10-26 11:03 ` Olivier Hainque 2010-10-27 18:32 ` Joel Brobecker 2010-10-27 18:35 ` Jakub Jelinek 2010-10-27 18:37 ` Joel Brobecker 2011-02-18 5:29 ` [PING #5] " Joel Brobecker 2011-02-21 5:05 ` Jason Merrill 2011-02-21 6:56 ` Jason Merrill 2011-02-22 17:44 ` Olivier Hainque 2011-02-23 1:49 ` Jason Merrill 2011-02-23 10:56 ` Olivier Hainque
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).