This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH/RFC] PR other/22313: Hot/cold sections vs. dwarf2 (take 2)

Hi Nicolas,

On Fri, 8 Sep 2006, Nicolas Setton wrote:
> I guess that this patch is incomplete, in that it breaks printing in
> the debugger of variables allocated on the stack and for which the
> dwarf-2 location is calculated relatively to the frame base.
> To exhibit the problem, consider the following code:
>    typedef struct
>    {
>       int a;
>    } thing;
>    int main (void)
>    {
>      thing a;
>      a.a = 7;
>      return a.a;
>    }
> Then try to break in "main" and print variable "a", you'll get the
> following message:
>    Could not find the frame base for "main".
> Further analysis. When compiling the example above with the patch
> included, on x86-linux, the location expression for the frame base
> starts with this:
> .LLST0:
>          .long   .LFB2-.Ltext0   # Location list begin address (*.LLST0)
>          .long   .LFB2-.Ltext0   # Location list end address (*.LLST0)
> The first location expression is a null address range, which is a
> list terminator in dwarf-2.
> I suspect that the problem comes from the current implementation of
> convert_cfa_to_loc_list, which currently expects only
> DW_CFA_advance_loc statements in the CFI instructions; it should be
> enhanced to expect and handle the DW_CFA_set_loc statements as well.
> What do the experts think about this?

Grr.  Indeed you're right that it looks like convert_cfa_to_fb_loc_list
in dwarf2out.c doesn't appear to support set_loc.  The following one
line patch appears to avoid the null range in your testcase on
x86-linux.  I'm not really a dwarf expert, so I wonder if you could
confirm that the debugging information is now correct (and we can now
find "a" in "main").  From the source code, this looks like the correct

Thanks in advance,

2006-09-08  Roger Sayle  <>
	    Nicolas Setton <>

	* dwarf2out.c (convert_cfa_to_fb_loc_list): Handle DW_CFA_set_loc.

Index: dwarf2out.c
*** dwarf2out.c (revision 116509)
--- dwarf2out.c (working copy)
*************** convert_cfa_to_fb_loc_list (HOST_WIDE_IN
*** 10383,10388 ****
--- 10383,10389 ----
    for (cfi = fde->dw_fde_cfi; cfi; cfi = cfi->dw_cfi_next)
      switch (cfi->dw_cfi_opc)
+       case DW_CFA_set_loc:
        case DW_CFA_advance_loc1:
        case DW_CFA_advance_loc2:
        case DW_CFA_advance_loc4:

Roger Sayle,                         E-mail:
OpenEye Scientific Software,         WWW:
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]