Re: The 'cold' function attribute and GDB

Kevin Buettner
2019-05-02T15:56:28Z

On Thu, 02 May 2019 18:23:20 +0300
Eli Zaretskii <eliz@gnu.org> wrote:

> > Date: Thu, 2 May 2019 00:38:49 -0700
> > From: Kevin Buettner <kevinb@redhat.com>
> > Cc: gdb-patches@sourceware.org, Simon Marchi <simark@simark.ca>
> >
> > Can you show me what is printed for the following commands?
> >
> > disassemble print_vectorlike
> > x/3i print_vectorlike
> > b print_vectorlike
> >
> > For the disassemble command, I expect both ranges to be displayed.
> > The x and b commands should print insns / set a breakpoint on the entry
> > pc (which should NOT be the cold address) of the function. If one or more
> > of these things aren't happening, then something is going wrong
> > somewhere.
>
> Here:
>
> (gdb) disassemble /m print_vectorlike
> Dump of assembler code for function print_vectorlike:
> Address range 0x11d6521 to 0x11d81d6:
> 1367 {
> 0x011d6521 <+0>: push %ebp
> 0x011d6522 <+1>: mov %esp,%ebp
> 0x011d6524 <+3>: push %edi
> 0x011d6525 <+4>: push %esi
> 0x011d6526 <+5>: push %ebx
> 0x011d6527 <+6>: sub $0x7c,%esp
> [...]
> Address range 0x12e1ce5 to 0x12e1f3b:
> 1824 emacs_abort ();
> 0x012e1f36 <+593>: call 0x12e7b40 <emacs_abort>
>
> End of assembler dump.
>
> (gdb) x/3i print_vectorlike
> 0x11d6521 <print_vectorlike>: push %ebp
> 0x11d6522 <print_vectorlike+1>: mov %esp,%ebp
> 0x11d6524 <print_vectorlike+3>: push %edi
> (gdb) break print_vectorlike
> Breakpoint 1 at 0x11d6521: file print.c, line 1367.
>
> Seems to be according to your expectations.

Yes, this all looks good to me.

> Btw, if I use a source line number whose code is in the 'cold' area,
> then I see this:
>
> (gdb) break print.c:1824
> Breakpoint 1 at 0x12e1f36: file print.c, line 1824.
> (gdb) info line print.c:1824
> Line 1824 of "print.c"
> starts at address 0x12e1f36 <print_vectorlike.cold.65+593>
> and ends at 0x12e1f3b <print_vectorlike.cold.65+598>.

I'm not especially surprised that GDB chose a nearby minimal symbol to
print here. I am surprised at the rather large offsets from that
symbol, however. In the example that I studied last year, I think
that the first offset was 0.

I'll try building emacs...

Kevin