From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 90561 invoked by alias); 2 Aug 2017 13:14:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 86131 invoked by uid 89); 2 Aug 2017 13:14:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_STOCKGEN,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:209.85.223.195, H*RU:209.85.223.195, H*r:sk:static. X-HELO: mail-io0-f195.google.com Received: from mail-io0-f195.google.com (HELO mail-io0-f195.google.com) (209.85.223.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Aug 2017 13:14:38 +0000 Received: by mail-io0-f195.google.com with SMTP id j32so3671123iod.3 for ; Wed, 02 Aug 2017 06:14:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=RXs0UIWAsXTLEPq+m6Pyz2Lq30FJqcVpEWPEKnYNtZE=; b=c4Yb0M6M8UVYUBebi4Q6xGD+4WuI7iEOn/66iUUNr2k/2msSdr7owiFi4xkfAo25rq HPnD9IDCpdboOQepGO+k34mmQPCeWfj8048QKu20Nkq/y6UJYsVT7mOncz2P0pH1kNCy uVjvTkLrxq0NosIMGXJ6ywHL9Knn0qLI/2hAqQMCbG0XxyLh3NGSxW+X13/fEFTRzkLF LDWFnHWF9Q0TTYnlcb/rXDMiES9doBY/qsICPMhP+iuuRoC20fn6n7NdtNkt5i2rd8GF HxMvin7p93kd5Fc0Yqdyc5418jvXxdnhkpz5QRsN/jGtqUY3fQxSSUbKQJqVurgMaWLk JbwQ== X-Gm-Message-State: AIVw1119gCNB5bEH5LOn57pBaVGtuwogGzA+ourrMgfxYCpOZ3ddGfU/ JqsalaZaSlCrLT6f X-Received: by 10.107.168.229 with SMTP id e98mr25155738ioj.332.1501679675842; Wed, 02 Aug 2017 06:14:35 -0700 (PDT) Received: from E107787-LIN (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id m68sm2057487itm.25.2017.08.02.06.14.33 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 02 Aug 2017 06:14:35 -0700 (PDT) From: Yao Qi To: Tim Wiederhake Cc: gdb-patches@sourceware.org, Bernhard Heckel Subject: Re: [PATCH 4/6] Dwarf: Fortran, support DW_TAG_entry_point. References: <1500629040-12972-1-git-send-email-tim.wiederhake@intel.com> <1500629040-12972-5-git-send-email-tim.wiederhake@intel.com> Date: Wed, 02 Aug 2017 13:14:00 -0000 In-Reply-To: <1500629040-12972-5-git-send-email-tim.wiederhake@intel.com> (Tim Wiederhake's message of "Fri, 21 Jul 2017 11:23:58 +0200") Message-ID: <86tw1q2jt3.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00024.txt.bz2 Tim Wiederhake writes: > Fortran provides additional entry-points to an subprogram. Those entry-p= oints > may have only a subset of parameters of the original subprogram as well. > > Add support for parsing DW_TAG_entry_point's for Fortran. Looks gfortran doesn't generate DW_TAG_entry_point now. Could you confirm that this patch fix PR 8043 and PR 9279? > > xxxx-yy-zz Bernhard Heckel > Tim Wiederhake > > gdb/ChangeLog: PR fortran/8043 PR fortran/9279 > * gdb/dwarf2read.c (add_partial_symbol): Handle DW_TAG_entry_point. > (add_partial_entry_point): New function. > (add_partial_subprogram): Search for entry_points. > (process_die): Handle DW_TAG_entry_point. > (dwarf2_get_pc_bounds): Update low pc from DWARF. > (load_partial_dies): Save DW_TAG_entry_point's. > (load_partial_dies): Save DW_TAG_entry_point to hash table. > (load_partial_dies): Look into child's of DW_TAG_sub_program > for fortran. > (new_symbol_full): Process DW_TAG_entry_point. > (read_type_die_1): Handle DW_TAG_entry_point. > > gdb/testsuite/ChangeLog: > * gdb.fortran/entry_point.f90: New file. > * gdb.fortran/entry_point.exp: New file. > > > --- > gdb/dwarf2read.c | 100 ++++++++++++++++++++++++= +++++- > gdb/testsuite/gdb.fortran/entry_point.exp | 70 +++++++++++++++++++++ > gdb/testsuite/gdb.fortran/entry_point.f90 | 48 ++++++++++++++ > 3 files changed, 217 insertions(+), 1 deletion(-) > create mode 100644 gdb/testsuite/gdb.fortran/entry_point.exp > create mode 100644 gdb/testsuite/gdb.fortran/entry_point.f90 > > diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c > index 6d38d70..c3c01a7 100644 > --- a/gdb/dwarf2read.c > +++ b/gdb/dwarf2read.c > @@ -1556,6 +1556,10 @@ static void add_partial_module (struct partial_die= _info *pdi, CORE_ADDR *lowpc, > static void add_partial_enumeration (struct partial_die_info *enum_pdi, > struct dwarf2_cu *cu); >=20=20 > +static void add_partial_entry_point (struct partial_die_info *pdi, > + CORE_ADDR *lowpc, CORE_ADDR *highpc, > + int need_pc, struct dwarf2_cu *cu); > + > static void add_partial_subprogram (struct partial_die_info *pdi, > CORE_ADDR *lowpc, CORE_ADDR *highpc, > int need_pc, struct dwarf2_cu *cu); > @@ -7132,6 +7136,32 @@ add_partial_symbol (struct partial_die_info *pdi, = struct dwarf2_cu *cu) >=20=20 > switch (pdi->tag) > { > + case DW_TAG_entry_point: > + { > + /* Don't know any other language than fortran which is > + using DW_TAG_entry_point. */ > + if (cu->language =3D=3D language_fortran) > + { > + addr =3D gdbarch_adjust_dwarf2_addr (gdbarch, pdi->lowpc + baseaddr= ); > + /* DW_TAG_entry_point provides an additional entry_point to an > + existing sub_program. Therefore, we inherit the "external" > + attribute from the sub_program to which the entry_point > + belongs to. */ > + if (pdi->die_parent->is_external) > + add_psymbol_to_list (actual_name, strlen (actual_name), > + built_actual_name !=3D NULL, > + VAR_DOMAIN, LOC_BLOCK, > + &objfile->global_psymbols, > + addr, cu->language, objfile); > + else > + add_psymbol_to_list (actual_name, strlen (actual_name), > + built_actual_name !=3D NULL, > + VAR_DOMAIN, LOC_BLOCK, > + &objfile->static_psymbols, > + addr, cu->language, objfile); Nit, can you do add_psymbol_to_list (actual_name, strlen (actual_name), built_actual_name !=3D NULL, VAR_DOMAIN, LOC_BLOCK, pdi->die_parent->is_external ? &objfile->global_psymbols : &objfile->static_psym= bols, addr, cu->language, objfile); or auto psymbols =3D pdi->die_parent->is_external ? &objfile->global_psymbols : &objfile->static_psym= bols; add_psymbol_to_list (actual_name, strlen (actual_name), built_actual_name !=3D NULL, VAR_DOMAIN, LOC_BLOCK, psymbols, addr, cu->language, objfile); > + } > + break; > + } > case DW_TAG_subprogram: > addr =3D gdbarch_adjust_dwarf2_addr (gdbarch, pdi->lowpc + baseadd= r); > if (pdi->is_external || cu->language =3D=3D language_ada) > @@ -7332,6 +7362,18 @@ add_partial_module (struct partial_die_info *pdi, = CORE_ADDR *lowpc, > scan_partial_symbols (pdi->die_child, lowpc, highpc, set_addrmap, cu= ); > } >=20=20 > +static void > +add_partial_entry_point (struct partial_die_info *pdi, > + CORE_ADDR *p_lowpc, CORE_ADDR *p_highpc, > + int set_addrmap, struct dwarf2_cu *cu) > +{ > + if (pdi->name =3D=3D NULL) > + complaint (&symfile_complaints, > + _("DW_TAG_entry_point have to have a name")); > + else > + add_partial_symbol (pdi, cu); > +} > + > /* Read a partial die corresponding to a subprogram and create a partial > symbol for that subprogram. When the CU language allows it, this > routine also defines a partial symbol for each nested subprogram > @@ -7402,6 +7444,16 @@ add_partial_subprogram (struct partial_die_info *p= di, > pdi =3D pdi->die_sibling; > } > } > + else if (cu->language =3D=3D language_fortran) > + { > + pdi =3D pdi->die_child; > + while (pdi !=3D NULL) > + { > + if (pdi->tag =3D=3D DW_TAG_entry_point) > + add_partial_entry_point (pdi, lowpc, highpc, set_addrmap, cu); In Fortran, is it possible to define "nested functions" or "contained routines" within an entry point of a subprogram? like, subroutine bar entry foo contains subroutine foo_sub entry foo_sub_entry end subroutine foo_sub entry bar end subroutine can gdb correctly handle these nested functions and nested entry points? My point is that it is better that add_partial_subprogram handles both DW_TAG_subprogram and DW_TAG_entry_point first, and then, recursively call itself to handle DIE children. add_partial_subprogram () { if (pdi->tag =3D=3D DW_TAG_subprogram) {} else if (pdi->tag =3D=3D DW_TAG_entry_point) {} if (! pdi->has_children) return; if (cu->language =3D=3D language_ada || cu->language =3D=3D language_fort= ran) { pdi =3D pdi->die_child; while (pdi !=3D NULL) { fixup_partial_die (pdi, cu); if (pdi->tag =3D=3D DW_TAG_subprogram || pdi->tag =3D=3D DW_TAG_lexical_block || pdi->tag =3D=3D DW_TAG_entry_point) add_partial_subprogram (pdi, lowpc, highpc, set_addrmap, cu); pdi =3D pdi->die_sibling; } } } > + pdi =3D pdi->die_sibling; > + } > + } > } >=20=20 > /* Read a partial die corresponding to an enumeration type. */ > @@ -8508,6 +8560,7 @@ process_die (struct die_info *die, struct dwarf2_cu= *cu) > case DW_TAG_type_unit: > read_type_unit_scope (die, cu); > break; > + case DW_TAG_entry_point: > case DW_TAG_subprogram: > case DW_TAG_inlined_subroutine: > read_func_scope (die, cu); > @@ -12499,6 +12552,27 @@ dwarf2_get_pc_bounds (struct die_info *die, CORE= _ADDR *lowpc, > CORE_ADDR high =3D 0; > enum pc_bounds_kind ret; >=20=20 > + if (die->tag =3D=3D DW_TAG_entry_point) > + { > + /* Entry_point is embedded in an subprogram. Therefore, we can us= e the > + highpc from its enveloping subprogram and get the lowpc from DWARF. */ > + ret =3D dwarf2_get_pc_bounds (die->parent, lowpc, highpc, cu, pst); > + if (ret =3D=3D PC_BOUNDS_NOT_PRESENT || ret =3D=3D PC_BOUNDS_INVAL= ID) > + return ret; > + > + attr =3D dwarf2_attr (die, DW_AT_low_pc, cu); > + if (!attr) > + { > + complaint (&symfile_complaints, > + _("DW_TAG_entry_point is missing DW_AT_low_pc")); > + return PC_BOUNDS_INVALID; > + } > + low =3D attr_value_as_address (attr); > + *lowpc =3D low; > + > + return PC_BOUNDS_HIGH_LOW; Why return PC_BOUNDS_HIGH_LOW, which means both DW_AT_low_pc and DW_AT_high_pc are found. However, DW_TAG_entry_point doesn't have DW_AT_high_pc. The question is why do we call dwarf2_get_pc_bounds for DW_TAG_entry_point. Is it because we call read_func_scope for DW_TAG_entry_point? > + } > + > attr_high =3D dwarf2_attr (die, DW_AT_high_pc, cu); > if (attr_high) > { > @@ -16029,6 +16103,7 @@ load_partial_dies (const struct die_reader_specs = *reader, > && abbrev->tag !=3D DW_TAG_constant > && abbrev->tag !=3D DW_TAG_enumerator > && abbrev->tag !=3D DW_TAG_subprogram > + && abbrev->tag !=3D DW_TAG_entry_point > && abbrev->tag !=3D DW_TAG_lexical_block > && abbrev->tag !=3D DW_TAG_variable > && abbrev->tag !=3D DW_TAG_namespace > @@ -16155,6 +16230,7 @@ load_partial_dies (const struct die_reader_specs = *reader, > if (load_all > || abbrev->tag =3D=3D DW_TAG_constant > || abbrev->tag =3D=3D DW_TAG_subprogram > + || abbrev->tag =3D=3D DW_TAG_entry_point Could you update the comments above this block? > || abbrev->tag =3D=3D DW_TAG_variable > || abbrev->tag =3D=3D DW_TAG_namespace > || part_die->is_declaration) > @@ -16197,7 +16273,9 @@ load_partial_dies (const struct die_reader_specs = *reader, > || last_die->tag =3D=3D DW_TAG_union_type)) > || (cu->language =3D=3D language_ada > && (last_die->tag =3D=3D DW_TAG_subprogram > - || last_die->tag =3D=3D DW_TAG_lexical_block)))) > + || last_die->tag =3D=3D DW_TAG_lexical_block)) > + || (cu->language =3D=3D language_fortran > + && last_die->tag =3D=3D DW_TAG_subprogram))) Likewise, update comments above. Do we need to check both DW_TAG_subprogram and DW_TAG_entry_point? > { > nesting_level++; > parent_die =3D last_die; > @@ -19058,6 +19136,25 @@ new_symbol_full (struct die_info *die, struct ty= pe *type, struct dwarf2_cu *cu, > SYMBOL_ACLASS_INDEX (sym) =3D LOC_LABEL; > add_symbol_to_list (sym, cu->list_in_scope); > break; > + case DW_TAG_entry_point: > + /* Don't know any other language than fortran which is > + using DW_TAG_entry_point. */ > + if (cu->language =3D=3D language_fortran) > + { > + /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by > + finish_block. */ > + SYMBOL_ACLASS_INDEX (sym) =3D LOC_BLOCK; > + /* DW_TAG_entry_point provides an additional entry_point to an > + existing sub_program. Therefore, we inherit the "external" > + attribute from the sub_program to which the entry_point > + belongs to. */ > + attr2 =3D dwarf2_attr (die->parent, DW_AT_external, cu); > + if (attr2 && (DW_UNSND (attr2) !=3D 0)) if (attr2 !=3D NULL && DW_UNSND (attr2) !=3D 0) > + list_to_add =3D &global_symbols; > + else > + list_to_add =3D cu->list_in_scope; > + } > + break; > case DW_TAG_subprogram: Can we merge to case block for DW_TAG_subprogram and DW_TAG_subprogram? They are quite similar. --=20 Yao (=E9=BD=90=E5=B0=A7)