The 'cold' function attribute and GDB

Simon Marchi simark@simark.ca
Thu May 2 18:08:00 GMT 2019


On 2019-05-02 12:45 p.m., Eli Zaretskii wrote:
>> Date: Thu, 2 May 2019 08:59:19 -0700
>> From: Kevin Buettner <kevinb@redhat.com>
>> Cc: gdb-patches@sourceware.org, simark@simark.ca
>>
>>> This is with GCC 8.2.0, btw.
>>
>> I'll give this a try.
>>
>> I have GCC 8.3.1 and 9.0.1 readily available.  Do you think it's
>> important to use 8.2.0 ?

I just built gcc from git, and built emacs with it, and I get pretty much the
same ranges as you:

 <1><66a91b>: Abbrev Number: 141 (DW_TAG_subprogram)
    <66a91d>   DW_AT_name        : (indirect string, offset: 0xf3fe3): print_vectorlike
    <66a921>   DW_AT_decl_file   : 1
    <66a922>   DW_AT_decl_line   : 1365
    <66a924>   DW_AT_decl_column : 1
    <66a925>   DW_AT_prototyped  : 1
    <66a925>   DW_AT_type        : <0x65a0ff>
    <66a929>   DW_AT_ranges      : 0x234cf0
    <66a92d>   DW_AT_frame_base  : 1 byte block: 9c     (DW_OP_call_frame_cfa)
    <66a92f>   DW_AT_GNU_all_call_sites: 1
    <66a92f>   DW_AT_sibling     : <0x66cf15>

And the ranges:

    00234cf0 000000000057da80 000000000057e88f
    00234cf0 00000000004173b1 00000000004173b6
    00234cf0 <End of list>

In my case, the second range, the cold one, is one instruction long, just the call to emacs_abort:

00000000004173b1 <print_vectorlike.cold>:
  4173b1:       e8 77 ce ff ff          callq  41422d <emacs_abort>

Can you give the steps to reproduce the bug that leads us there?

In the mean time, I tried to do "start", followed by "set $pc = 0x4173b1", and this is what I get as my
first frame:

#0  0x00000000004173b1 in print_vectorlike (obj=0x1, printcharfun=0x7fffffffdd18, escapeflag=<optimized out>, buf=0xa0 <error: Cannot access memory at address 0xa0>) at /home/smarchi/src/emacs/src/print.c:1824

The parameter values are bogus, and the rest of the frames are corrupted, because I don't have
the stack I would normally have when executing this code.  But we can see that the full symbol
was found: the arguments are printed, and the function name is correct (doesn't include .cold).

So it looks like some debugging of this problem on Windows will be needed :(

Simon



More information about the Gdb-patches mailing list