Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@mvista.com>
To: Joel Brobecker <brobecker@gnat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFC] lookup problem in blockframe.c:inside_main_func()
Date: Tue, 07 Oct 2003 00:15:00 -0000	[thread overview]
Message-ID: <20031007001543.GA16602@nevyn.them.org> (raw)
In-Reply-To: <20031006233728.GB933@gnat.com>

[First of all, what path takes you through lookup_symbol to that
prompt?  That shouldn't ever happen, unless it's being generated in
Ada-specific code...]

On Mon, Oct 06, 2003 at 04:37:29PM -0700, Joel Brobecker wrote:
> Really, the lookup we intended to do was a simple, plain, symbol lookup
> of "main". In an attempt to reflect this, I have tried the following
> change in inside_main_func(), and it fixes the problem at hand:
> 
> | +      enum language saved_language = current_language->la_language;
> |  
> | +      set_language (language_c);
> |        mainsym = lookup_symbol (main_name (), NULL, VAR_DOMAIN, NULL, NULL);
> | +      set_language (saved_language);
> 
> I would be more than happy to properly contribute this change, with
> comments in the code, and a changelog entry, but I see two problems
> that bother me a bit:
>   
>   1. We rely on a global variable to pass some information to a procedure,
>      and this not very good.
> 
>   2. The current change will fail to restore the saved language in case
>      an exception is raised during the call to lookup_symbol. Not really
>      that big a deal, but not very user-friendly either.
> 
> My current thoughts about each problem:
> 
>   1. It's a bit bothersome, but on the other hand lookup_symbol is
>      used everywhere. Any change in its interface would be a jumbo
>      patch. Nevertheless, I am ready to discuss this option if you
>      feel that we should bite the bullet and avoid global variables
>      as much as we can (remember about the language problems we still
>      have to tackle?). Let me know. For now, since current_language
>      is already so much widely used, I'm inclined to simply wrap
>      the call to lookup_symbol() between calls to set_language().
> 
>   2. This can easily be fixed. I think the cleanest way to do this is
>      by renaming inside_main_func() into inside_main_func_1(), and
>      write a new inside_main_func() that calls inside_main_func_1()
>      via catch_exceptions(). We can then safely wrap it between
>      calls to set_language(). But this is assuming that we decide
>      that we don't mind about concern #1 above. But I find the
>      catch exceptions interface a bit awkward. Mixing the error code
>      returned by catch_exceptions() with the return value of the
>      function called makes me flinch a bit.
> 
> What do you think?

Don't use lookup_symbol?  On David's branch there's a minsym function
for finding the minimal symbol associated with a mangled name.  I
thought it had been merged to mainline but it hasn't.  Something to do
the same for symbols would be reasonable, although rare.  Or you could
just use the minsym version, and then call find_pc_function.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


  reply	other threads:[~2003-10-07  0:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-06 23:37 Joel Brobecker
2003-10-07  0:15 ` Daniel Jacobowitz [this message]
2003-10-07  0:24   ` Joel Brobecker
2003-10-07  1:49     ` Daniel Jacobowitz
2003-10-07  2:14       ` Joel Brobecker
2003-10-07  3:01         ` Daniel Jacobowitz
2003-10-09 14:27         ` Daniel Jacobowitz
2003-10-10 20:57           ` Joel Brobecker

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=20031007001543.GA16602@nevyn.them.org \
    --to=drow@mvista.com \
    --cc=brobecker@gnat.com \
    --cc=gdb-patches@sources.redhat.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