From: Andrew Cagney <cagney@gnu.org>
To: Jason Molenda <jmolenda@apple.com>, Joel Brobecker <brobecker@gnat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: Question about blockframe.c:inside_main_func()
Date: Thu, 29 Apr 2004 15:09:00 -0000 [thread overview]
Message-ID: <40911AA8.9080106@gnu.org> (raw)
In-Reply-To: <9B827536-9972-11D8-9EA7-000A9569836A@apple.com>
> Hi all,
>
> We're bringing up the currentish gdb sources here at Apple and I was debugging a problem with inside_main_func () [*] when I noticed that there seems to be a bit of extra computation that has snuck into the function during the changes since July.
>
> Previously, inside_main_func() would find the "main" function in the "symfile_objfile", find its start and end addresses (if debug symbols were present I guess) and on subsequent invocations, use those cached addresses to determine if the addr in question is contained within the "main" function.
>
> The current inside_main_func() will do
>
> msymbol = lookup_minimal_symbol (main_name (), NULL, symfile_objfile);// every time
>
> if (msymbol != NULL // once
> && symfile_objfile->ei.main_func_lowpc == INVALID_ENTRY_LOWPC
> && symfile_objfile->ei.main_func_highpc == INVALID_ENTRY_HIGHPC)
>
> if (msymbol != NULL && MSYMBOL_TYPE (msymbol) == mst_text) // every time
> {
> [... lots of stuff ...]
> }
>
> I realize this is hardly a performance critical function, but it's still a long shot from the version that existed before July which would find the start/end addresses and then do
>
> if (symfile_objfile->ei.main_func_lowpc == INVALID_ENTRY_LOWPC && // once
> symfile_objfile->ei.main_func_highpc == INVALID_ENTRY_HIGHPC)
> [... lookup symbol ... ]
>
> return (symfile_objfile->ei.main_func_lowpc <= pc
> && symfile_objfile->ei.main_func_highpc > pc);
> Is there some reason why this shortcut has been dropped? Is there a reason not to add a conditional to the top to detect "main"'s bounds being detected and short-circuit the searching we're doing every time.
Per Joel's comments, I'd guess accident.
However, I think the entire function's contents are bogus. It should
look like:
if (symtab_find_function_range_by_name (main_name (), &low_pc, &high_pc))
return pc in [low_pc, high_pc);
else
return 0;
so that the logic is pushed back into the symbol table (an obvious thing
for lookup_function_range_by_name to do is implement a look-aside cache).
This also lets us kill off main_func_lowpc and main_func_highpc (they
need to be killed off anyway as PIE breaks the assumption that the
values are constant across function invocations).
> Jason
>
> [*] We have something called "ZeroLink" where the main executable -- the symfile_objfile -- is a tiny stub that demand-loads each object file (formatted like a shared library) as functions/global variables in those .o's are referenced. So in our case, the symfile_objfile doesn't contain main at all; hence me looking into this function and scratching my head about why it's re-searching for this function every time...
you might want to look at PIE.
Andrew
next prev parent reply other threads:[~2004-04-29 15:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-29 0:17 Jason Molenda
2004-04-29 1:02 ` Joel Brobecker
2004-04-29 1:50 ` Jason Molenda
2004-04-29 15:09 ` Andrew Cagney [this message]
2004-04-30 0:27 ` Jason Molenda
2004-04-30 0:49 ` Andrew Cagney
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=40911AA8.9080106@gnu.org \
--to=cagney@gnu.org \
--cc=brobecker@gnat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=jmolenda@apple.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