Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sourceware.org, simark@simark.ca
Subject: Re: The 'cold' function attribute and GDB
Date: Sat, 04 May 2019 08:30:00 -0000	[thread overview]
Message-ID: <835zqqmxk9.fsf@gnu.org> (raw)
In-Reply-To: <20190502163015.507e652b@f29-4.lan> (message from Kevin Buettner	on Thu, 2 May 2019 16:30:15 -0700)

> Date: Thu, 2 May 2019 16:30:15 -0700
> From: Kevin Buettner <kevinb@redhat.com>
> Cc: Eli Zaretskii <eliz@gnu.org>, simark@simark.ca
> 
>   #2  0x012e1f3b in print_vectorlike.cold () at print.c:1824 
> 
> This behavior is, apparently, intentional.  The function
> build_address_symbolic in printcmd.c contains the following
> statements; in particular note the second comment:
> 
>   if (msymbol.minsym != NULL)
>     {
>       if (BMSYMBOL_VALUE_ADDRESS (msymbol) > name_location || symbol == NULL)
> 	{
> 	  /* If this is a function (i.e. a code address), strip out any
> 	     non-address bits.  For instance, display a pointer to the
> 	     first instruction of a Thumb function as <function>; the
> 	     second instruction will be <function+2>, even though the
> 	     pointer is <function+3>.  This matches the ISA behavior.  */
> 	  if (MSYMBOL_TYPE (msymbol.minsym) == mst_text
> 	      || MSYMBOL_TYPE (msymbol.minsym) == mst_text_gnu_ifunc
> 	      || MSYMBOL_TYPE (msymbol.minsym) == mst_file_text
> 	      || MSYMBOL_TYPE (msymbol.minsym) == mst_solib_trampoline)
> 	    addr = gdbarch_addr_bits_remove (gdbarch, addr);
> 
> 	  /* The msymbol is closer to the address than the symbol;
> 	     use the msymbol instead.  */
> 	  symbol = 0;
> 	  name_location = BMSYMBOL_VALUE_ADDRESS (msymbol);
> 	  if (do_demangle || asm_demangle)
> 	    name_temp = MSYMBOL_PRINT_NAME (msymbol.minsym);
> 	  else
> 	    name_temp = MSYMBOL_LINKAGE_NAME (msymbol.minsym);
> 	}
>     }
> 
> When I traced it, prior to getting to the outer if statement,
> name_location contained the address of 'print_vectorlike' and
> name_temp was set to "print_vectorlike".  So, if we were to
> *not* execute this code, we wouldn't use the minimal symbol.
> 
> To test this, I disabled the code above via #if 0 ... #endif.  Here's
> what I see when I do this:
> 
> (gdb) x/i 0x12e1f36
>    0x12e1f36 <print_vectorlike+1096213>:	call   0x12e7b40 <emacs_abort>
> 
> I didn't see this behavior on my Linux build of emacs due to the fact
> that the .cold symbol was placed at an address that's lower than that
> of the non-cold symbol.
> 
> With all of that said, I don't think it actually helps with the
> backtrace problem.  It appears that build_address_symbolic is only
> used for disassembly.  After poking around, however, I think the
> equivalent bit of code may be found in find_frame_funname in stack.c.
> The hunk of code which you'll want to disable is:
> 
>       if (msymbol.minsym != NULL
> 	  && (BMSYMBOL_VALUE_ADDRESS (msymbol)
> 	      > BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (func))))
> 	{
> 	  /* We also don't know anything about the function besides
> 	     its address and name.  */
> 	  func = 0;
> 	  funname.reset (xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym)));
> 	  *funlang = MSYMBOL_LANGUAGE (msymbol.minsym);
> 	}
> 
> Doing this sort of thing - preferring the minimal symbol over the
> the symbol might make sense for displaying assembly addresses - but
> I'm not convinced that it makes sense for printing frame functions.
> 
> It would be possible to disable that code only when the frame pc
> is in a block which is in discontiguous block.  If someone thinks
> this is a good idea, I can provide a patch, but someone else will
> need to test it.

Thanks for the analysis.

Do you want me to test some patch?

And why doesn't the GNU/Linux executable have this minimal symbol in
the first place, btw?


  reply	other threads:[~2019-05-04  8:30 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-01 18:59 Eli Zaretskii
2019-05-01 20:17 ` Simon Marchi
2019-05-02  2:51   ` Kevin Buettner
2019-05-02  6:59     ` Eli Zaretskii
2019-05-02  7:26       ` Kevin Buettner
2019-05-02 15:27         ` Eli Zaretskii
2019-05-02 15:59           ` Kevin Buettner
2019-05-02 16:46             ` Eli Zaretskii
2019-05-02 18:08               ` Simon Marchi
2019-05-02 18:47                 ` Eli Zaretskii
2019-05-02 18:55                   ` Kevin Buettner
2019-05-02 19:32                     ` Eli Zaretskii
2019-05-02 19:51                       ` Kevin Buettner
2019-05-02  7:06     ` Eli Zaretskii
2019-05-02  7:38       ` Kevin Buettner
2019-05-02 15:23         ` Eli Zaretskii
2019-05-02 15:56           ` Kevin Buettner
2019-05-02 16:43             ` Eli Zaretskii
2019-05-02 18:25           ` Kevin Buettner
2019-05-02 18:52             ` Eli Zaretskii
2019-05-02 19:13               ` Kevin Buettner
2019-05-02 19:28                 ` Eli Zaretskii
2019-05-02 19:45                   ` Kevin Buettner
2019-05-02 19:56                     ` Eli Zaretskii
2019-05-02 23:30                       ` Kevin Buettner
2019-05-04  8:30                         ` Eli Zaretskii [this message]
2019-05-05 20:04                           ` Kevin Buettner
2019-05-06 15:33                             ` Eli Zaretskii
2019-05-06 16:24                               ` Kevin Buettner
2019-05-02 15:17       ` Eli Zaretskii

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=835zqqmxk9.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=kevinb@redhat.com \
    --cc=simark@simark.ca \
    /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