From: "H. J. Lu" <hjl@lucon.org>
To: Daniel Berlin <dberlin@dberlin.org>
Cc: Daniel Jacobowitz <drow@false.org>,
gcc@gcc.gnu.org, GDB <gdb@sources.redhat.com>
Subject: Re: Gdb generates location list without DW_AT_frame_base
Date: Fri, 31 Dec 2004 20:11:00 -0000 [thread overview]
Message-ID: <20041231201127.GA4344@lucon.org> (raw)
In-Reply-To: <20041231195734.GA4125@lucon.org>
On Fri, Dec 31, 2004 at 11:57:34AM -0800, H. J. Lu wrote:
> On Thu, Dec 30, 2004 at 07:35:13PM -0500, Daniel Berlin wrote:
> >
> >
> > On Thu, 30 Dec 2004, H. J. Lu wrote:
> >
> > >On Thu, Dec 30, 2004 at 03:56:33PM -0500, Daniel Berlin wrote:
> > >>
> > >>>And what's in the location lists? If it's DW_OP_fbreg, then I presume
> > >>>it's a GCC bug. According to my reading of the DWARF spec, anyway.
> > >>It is.
> > >>
> > >>I added code to tell it when not to use fbreg, but i only told it not to
> > >>use fbreg in the location expression when we were outputting the
> > >>frame_base attribute.
> > >>
> > >>However, it appears we don't output a frame base attribute for external
> > >>procedures, so we need to tell it it can't use if we don't have a frame
> > >>base attribute.
> > >>
> > >>You just need to change when loc_descriptor is called with a second
> > >>parameter of true/1 to fix this.
> > >
> > >Do you have a patch I can try?
> >
> > This may not fix all of them, but it should help.
>
> > Index: dwarf2out.c
> > ===================================================================
> > RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
> > retrieving revision 1.564
> > diff -u -p -r1.564 dwarf2out.c
> > --- dwarf2out.c 24 Dec 2004 05:23:07 -0000 1.564
> > +++ dwarf2out.c 31 Dec 2004 00:34:38 -0000
> > @@ -9980,6 +9980,7 @@ add_location_or_const_value_attribute (d
> > rtx rtl;
> > dw_loc_descr_ref descr;
> > var_loc_list *loc_list;
> > + bool can_use_fb = attr != DW_AT_frame_base && !DECL_EXTERNAL (decl);
> >
> > if (TREE_CODE (decl) == ERROR_MARK)
> > return;
> > @@ -10049,7 +10050,7 @@ add_location_or_const_value_attribute (d
> > varloc = NOTE_VAR_LOCATION (node->var_loc_note);
> > add_loc_descr_to_loc_list (&list,
> > loc_descriptor (varloc,
> > - attr != DW_AT_frame_base),
> > + can_use_fb),
> > node->label, node->next->label, secname);
> > }
> >
> > @@ -10070,7 +10071,7 @@ add_location_or_const_value_attribute (d
> > }
> > add_loc_descr_to_loc_list (&list,
> > loc_descriptor (varloc,
> > - attr != DW_AT_frame_base),
> > + can_use_fb),
> > node->label, endname, secname);
> > }
> >
>
> There are several problems with this patch:
>
> 1. It checks DECL_EXTERNAL. Did you mean TREE_PUBLIC?
> 2. It doesn't cover PARM_DECL nor RESULT_DECL.
> 3. For
>
This patch seems to generate better debug info.
H.J.
--- dwarf2out.c.loc 2004-12-27 12:04:10.000000000 -0800
+++ dwarf2out.c 2004-12-31 12:10:01.400120743 -0800
@@ -3919,8 +3919,8 @@ static int is_based_loc (rtx);
static dw_loc_descr_ref mem_loc_descriptor (rtx, enum machine_mode mode, bool);
static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx);
static dw_loc_descr_ref loc_descriptor (rtx, bool);
-static dw_loc_descr_ref loc_descriptor_from_tree_1 (tree, int);
-static dw_loc_descr_ref loc_descriptor_from_tree (tree);
+static dw_loc_descr_ref loc_descriptor_from_tree_1 (tree, bool, int);
+static dw_loc_descr_ref loc_descriptor_from_tree (tree, bool);
static HOST_WIDE_INT ceiling (HOST_WIDE_INT, unsigned int);
static tree field_type (tree);
static unsigned int simple_type_align_in_bits (tree);
@@ -8815,7 +8815,7 @@ loc_descriptor (rtx rtl, bool can_use_fb
the value of LOC. */
static dw_loc_descr_ref
-loc_descriptor_from_tree_1 (tree loc, int want_address)
+loc_descriptor_from_tree_1 (tree loc, bool can_use_fb, int want_address)
{
dw_loc_descr_ref ret, ret1;
int have_address = 0;
@@ -8854,7 +8854,7 @@ loc_descriptor_from_tree_1 (tree loc, in
return 0;
/* Otherwise, process the argument and look for the address. */
- return loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), 1);
+ return loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), can_use_fb, 1);
case VAR_DECL:
if (DECL_THREAD_LOCAL (loc))
@@ -8895,7 +8895,8 @@ loc_descriptor_from_tree_1 (tree loc, in
case PARM_DECL:
if (DECL_VALUE_EXPR (loc))
- return loc_descriptor_from_tree_1 (DECL_VALUE_EXPR (loc), want_address);
+ return loc_descriptor_from_tree_1 (DECL_VALUE_EXPR (loc), can_use_fb,
+ want_address);
/* FALLTHRU */
case RESULT_DECL:
@@ -8925,7 +8926,7 @@ loc_descriptor_from_tree_1 (tree loc, in
/* Certain constructs can only be represented at top-level. */
if (want_address == 2)
- return loc_descriptor (rtl, true);
+ return loc_descriptor (rtl, can_use_fb);
mode = GET_MODE (rtl);
if (MEM_P (rtl))
@@ -8933,18 +8934,19 @@ loc_descriptor_from_tree_1 (tree loc, in
rtl = XEXP (rtl, 0);
have_address = 1;
}
- ret = mem_loc_descriptor (rtl, mode, true);
+ ret = mem_loc_descriptor (rtl, mode, can_use_fb);
}
}
break;
case INDIRECT_REF:
- ret = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), 0);
+ ret = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), can_use_fb, 0);
have_address = 1;
break;
case COMPOUND_EXPR:
- return loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 1), want_address);
+ return loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 1), can_use_fb,
+ want_address);
case NOP_EXPR:
case CONVERT_EXPR:
@@ -8952,7 +8954,8 @@ loc_descriptor_from_tree_1 (tree loc, in
case VIEW_CONVERT_EXPR:
case SAVE_EXPR:
case MODIFY_EXPR:
- return loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), want_address);
+ return loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), can_use_fb,
+ want_address);
case COMPONENT_REF:
case BIT_FIELD_REF:
@@ -8970,7 +8973,7 @@ loc_descriptor_from_tree_1 (tree loc, in
if (obj == loc)
return 0;
- ret = loc_descriptor_from_tree_1 (obj, 1);
+ ret = loc_descriptor_from_tree_1 (obj, can_use_fb, 1);
if (ret == 0
|| bitpos % BITS_PER_UNIT != 0 || bitsize % BITS_PER_UNIT != 0)
return 0;
@@ -8978,7 +8981,8 @@ loc_descriptor_from_tree_1 (tree loc, in
if (offset != NULL_TREE)
{
/* Variable offset. */
- add_loc_descr (&ret, loc_descriptor_from_tree_1 (offset, 0));
+ add_loc_descr (&ret, loc_descriptor_from_tree_1 (offset, can_use_fb,
+ 0));
add_loc_descr (&ret, new_loc_descr (DW_OP_plus, 0, 0));
}
@@ -9012,7 +9016,7 @@ loc_descriptor_from_tree_1 (tree loc, in
return 0;
mode = GET_MODE (rtl);
rtl = XEXP (rtl, 0);
- ret = mem_loc_descriptor (rtl, mode, true);
+ ret = mem_loc_descriptor (rtl, mode, can_use_fb);
have_address = 1;
break;
}
@@ -9068,7 +9072,7 @@ loc_descriptor_from_tree_1 (tree loc, in
if (TREE_CODE (TREE_OPERAND (loc, 1)) == INTEGER_CST
&& host_integerp (TREE_OPERAND (loc, 1), 0))
{
- ret = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), 0);
+ ret = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), can_use_fb, 0);
if (ret == 0)
return 0;
@@ -9120,8 +9124,8 @@ loc_descriptor_from_tree_1 (tree loc, in
goto do_binop;
do_binop:
- ret = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), 0);
- ret1 = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 1), 0);
+ ret = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), can_use_fb, 0);
+ ret1 = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 1), can_use_fb, 0);
if (ret == 0 || ret1 == 0)
return 0;
@@ -9143,7 +9147,7 @@ loc_descriptor_from_tree_1 (tree loc, in
goto do_unop;
do_unop:
- ret = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), 0);
+ ret = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), can_use_fb, 0);
if (ret == 0)
return 0;
@@ -9167,12 +9171,12 @@ loc_descriptor_from_tree_1 (tree loc, in
case COND_EXPR:
{
dw_loc_descr_ref lhs
- = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 1), 0);
+ = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 1), can_use_fb, 0);
dw_loc_descr_ref rhs
- = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 2), 0);
+ = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 2), can_use_fb, 0);
dw_loc_descr_ref bra_node, jump_node, tmp;
- ret = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), 0);
+ ret = loc_descriptor_from_tree_1 (TREE_OPERAND (loc, 0), can_use_fb, 0);
if (ret == 0 || lhs == 0 || rhs == 0)
return 0;
@@ -9242,9 +9246,9 @@ loc_descriptor_from_tree_1 (tree loc, in
}
static inline dw_loc_descr_ref
-loc_descriptor_from_tree (tree loc)
+loc_descriptor_from_tree (tree loc, bool can_use_fb)
{
- return loc_descriptor_from_tree_1 (loc, 2);
+ return loc_descriptor_from_tree_1 (loc, can_use_fb, 2);
}
/* Given a value, round it up to the lowest multiple of `boundary'
@@ -9980,6 +9984,7 @@ add_location_or_const_value_attribute (d
rtx rtl;
dw_loc_descr_ref descr;
var_loc_list *loc_list;
+ bool can_use_fb;
if (TREE_CODE (decl) == ERROR_MARK)
return;
@@ -9987,6 +9992,17 @@ add_location_or_const_value_attribute (d
gcc_assert (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL
|| TREE_CODE (decl) == RESULT_DECL);
+ switch (TREE_CODE (decl))
+ {
+ default:
+ can_use_fb = attr != DW_AT_frame_base && !TREE_PUBLIC (decl);
+ break;
+ case PARM_DECL:
+ case RESULT_DECL:
+ can_use_fb = attr != DW_AT_frame_base && !TREE_PUBLIC (DECL_CONTEXT (decl));
+ break;
+ }
+
/* See if we possibly have multiple locations for this variable. */
loc_list = lookup_decl_loc (decl);
@@ -10037,7 +10053,7 @@ add_location_or_const_value_attribute (d
node = loc_list->first;
varloc = NOTE_VAR_LOCATION (node->var_loc_note);
- list = new_loc_list (loc_descriptor (varloc, attr != DW_AT_frame_base),
+ list = new_loc_list (loc_descriptor (varloc, can_use_fb),
node->label, node->next->label, secname, 1);
node = node->next;
@@ -10049,7 +10065,7 @@ add_location_or_const_value_attribute (d
varloc = NOTE_VAR_LOCATION (node->var_loc_note);
add_loc_descr_to_loc_list (&list,
loc_descriptor (varloc,
- attr != DW_AT_frame_base),
+ can_use_fb),
node->label, node->next->label, secname);
}
@@ -10070,7 +10086,7 @@ add_location_or_const_value_attribute (d
}
add_loc_descr_to_loc_list (&list,
loc_descriptor (varloc,
- attr != DW_AT_frame_base),
+ can_use_fb),
node->label, endname, secname);
}
@@ -10086,7 +10102,7 @@ add_location_or_const_value_attribute (d
return;
}
- descr = loc_descriptor_from_tree (decl);
+ descr = loc_descriptor_from_tree (decl, can_use_fb);
if (descr)
add_AT_location_description (die, attr, descr);
}
@@ -10205,7 +10221,7 @@ add_bound_info (dw_die_ref subrange_die,
dw_die_ref ctx, decl_die;
dw_loc_descr_ref loc;
- loc = loc_descriptor_from_tree (bound);
+ loc = loc_descriptor_from_tree (bound, false);
if (loc == NULL)
break;
@@ -11331,7 +11347,7 @@ gen_subprogram_die (tree decl, dw_die_re
if (cfun->static_chain_decl)
add_AT_location_description (subr_die, DW_AT_static_link,
- loc_descriptor_from_tree (cfun->static_chain_decl));
+ loc_descriptor_from_tree (cfun->static_chain_decl, false));
}
/* Now output descriptions of the arguments for this function. This gets
next prev parent reply other threads:[~2004-12-31 20:11 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-22 1:16 Is this a gcc, gdb or readelf bug? H. J. Lu
2004-12-22 11:09 ` Nick Clifton
2004-12-22 18:25 ` H. J. Lu
2004-12-23 3:43 ` Daniel Jacobowitz
2004-12-30 19:24 ` GDB 6.3 assumes that DW_AT_frame_base exists H. J. Lu
2004-12-30 19:36 ` H. J. Lu
2004-12-30 19:56 ` H. J. Lu
2004-12-30 20:07 ` Daniel Jacobowitz
2004-12-30 20:23 ` Gdb generates location list without DW_AT_frame_base H. J. Lu
2004-12-30 20:28 ` Daniel Jacobowitz
2004-12-30 20:52 ` Gdb generates DW_OP_fbreg in " H. J. Lu
2004-12-30 20:56 ` Gdb generates " Daniel Berlin
2004-12-30 21:05 ` H. J. Lu
2004-12-31 0:35 ` Daniel Berlin
2004-12-31 19:57 ` H. J. Lu
2004-12-31 20:09 ` Daniel Berlin
2004-12-31 20:11 ` H. J. Lu [this message]
2004-12-31 20:16 ` Daniel Berlin
[not found] ` <20041231163806.GA1335@lucon.org>
[not found] ` <Pine.LNX.4.60.0412311158280.27590@dberlin.org>
[not found] ` <20041231184405.GA2182@lucon.org>
[not found] ` <Pine.LNX.4.60.0412311451060.6844@dberlin.org>
[not found] ` <Pine.LNX.4.60.0412311509360.6844@dberlin.org>
[not found] ` <20041231215010.GA5722@lucon.org>
[not found] ` <20041231215443.GA5853@lucon.org>
[not found] ` <Pine.LNX.4.60.0412311656360.6844@dberlin.org>
[not found] ` <20041231220324.GA5987@lucon.org>
2005-01-01 19:15 ` gcc 4.0 " H. J. Lu
2005-01-01 20:09 ` Daniel Jacobowitz
2005-01-01 20:50 ` Daniel Berlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20041231201127.GA4344@lucon.org \
--to=hjl@lucon.org \
--cc=dberlin@dberlin.org \
--cc=drow@false.org \
--cc=gcc@gcc.gnu.org \
--cc=gdb@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox