Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Elena Zannoni <ezannoni@redhat.com>
To: David Carlton <carlton@math.stanford.edu>
Cc: Elena Zannoni <ezannoni@redhat.com>,
	gdb-patches@sources.redhat.com, Jim Blandy <jimb@redhat.com>
Subject: Re: [rfa] delete 'force_return' from lookup_symbol_aux_minsyms
Date: Thu, 19 Dec 2002 15:39:00 -0000	[thread overview]
Message-ID: <15874.18989.470549.778392@localhost.redhat.com> (raw)
In-Reply-To: <ro1isxpkd3z.fsf@jackfruit.Stanford.EDU>

David Carlton writes:
 > On Thu, 19 Dec 2002 11:50:36 -0500, Elena Zannoni <ezannoni@redhat.com> said:
 > > David Carlton writes:
 > 
 > >> 'found_misc' also seems to have gone away; 
 > 
 > > Actually it is still there, the code I posted is for
 > > list/search_symbols.
 > 
 > Oh, I apologize, I completely misunderstood what you were saying.  I
 > thought that the code you dug up was an earlier version of
 > lookup_symbol.
 > 
 > Now I understand your point: I was claiming that no callers of
 > lookup_symbol depended on this NULL return that I'm trying to get rid
 > of, but you suspect that search_symbols might be such a caller.  And,
 > indeed, I hadn't considered that particular caller.
 > 
 > Looking into it further, I think you might have reason to worry.
 > Here's the relevant section of search_symbols:
 > 
 >   if (0 == find_pc_symtab (SYMBOL_VALUE_ADDRESS (msymbol)))
 >     {
 >       if (kind == FUNCTIONS_NAMESPACE
 > 	  || lookup_symbol (SYMBOL_NAME (msymbol),
 >                             (struct block *) NULL,
 >                             VAR_NAMESPACE,
 >                             0, (struct symtab **) NULL) == NULL)
 >         found_misc = 1;
 >     }
 > 
 > And here's an (abbreviated) version of all of the uses of force_return
 > in lookup_symbol_aux_minsyms:
 > 
 >   s = find_pc_sect_symtab (SYMBOL_VALUE_ADDRESS (msymbol),
 > 			   SYMBOL_BFD_SECTION (msymbol));
 >   if (s != NULL)
 >     {
 >       <code deleted that might set *force_return to 1>
 >     }
 >   else if (MSYMBOL_TYPE (msymbol) != mst_text
 >            && MSYMBOL_TYPE (msymbol) != mst_file_text
 >            && !STREQ (name, SYMBOL_NAME (msymbol)))
 >     {
 >       /* This is a mangled variable, look it up by its
 >          mangled name.  */
 >       *force_return = 1;
 >       return lookup_symbol_aux (SYMBOL_NAME (msymbol), mangled_name,
 >                                 NULL, namespace, is_a_field_of_this,
 >                                 symtab);
 >     }
 > 
 > These two sections of code are remarkably parallel, for reasons that I
 > don't understand.  And they're clearly trying to investigate the same
 > minimal symbol: the point of that code in search_symbols it to
 > determine whether or not a particular minimal symbol has debugging
 > info, so the question at hand is whether or not lookup_symbol is
 > supposed to terminate when it hits the minimal symbol that
 > search_symbols is interested in.  So I think it's safe to assume that
 > we're only interested in comparing the two pieces of code when
 > 'msymbol' has the same value in both.
 > 

Yes, I agree with this interpretation.

 > In that case, the find_pc_symtab in search_symbols corresponds to the
 > find_pc_sect_symtab in lookup_symbol_aux_minsyms (and should probably
 > be changed to find_pc_sect_symtab, but never mind that for now).
 > We're assuming that that symtab is 0; that means that we're in the
 > else clause of the lookup_symbol_aux_minsyms call.
 > 

yes

 > So when does that else clause happens?  It's guarded by a conditional:
 > that tests that the MSYMBOL_TYPE of the msymbol isn't text, and that
 > the name we're searching under isn't the SYMBOL_NAME of the msymbol.
 > 
 > The former condition is true: we're assuming that kind isn't
 > FUNCTIONS_NAMESPACE, so the minimal symbol shouldn't be text.  But
 > we've called lookup_symbol with the 'name' argument equal to
 > SYMBOL_NAME (msymbol).  And, in that case, the test for
 > 
 >   !STREQ (name, SYMBOL_NAME (msymbol)
 > 
 > should fail.
 > 

ok...

 > Except that isn't right, either!  Because SYMBOL_NAME (msymbol) would
 > be the mangled name of 'msymbol', 

yes,

 > and lookup_symbol demangled it, so

ah right, it would become modified_name

 > the 'name' argument to lookup_symbol_aux_minsyms would actually be
 > demangled.  

ok, I think I follow up to here.

 > So, indeed, we might well be in a situation where
 > force_return comes into play.
 > 

I am lost now.

 > Phew.  Assuming that analysis is correct, I have two comments and a
 > suggestion.
 > 
 > Comment #1: This whole logic is hopelessly unclear.  I think I'd
 > rather turn the code into something possibly broken but clearer, and
 > then try to fix any possible breakage, than try to leave it as is.
 > 

tempting

 > Comment #2: Just what is up with the call to lookup_symbol_aux from
 > within lookup_symbol_aux_minsyms, anyways?  It's passing in a mangled
 > name as the first argument; but lookup_symbol_aux normally expects its
 > first argument to be demangled.  I'm not sure what's going on here:
 > that call might be broken, or there might be some part of
 > lookup_symbol_aux that does something with a mangled first argument.
 > If the latter is the case, then there should be comments making this
 > explicit, and the call to lookup_symbol_aux should be replaced by a
 > call to lookup_symbol_aux_<something>.
 > 

I think it's just broken. The call in search_symbols predates the
introduction of lookup_symbol_aux and the demangling logic. So I think
it just wasn't updated to reflect the new behavior.

 > Suggestion: The whole purpose of the call to lookup_symbol from within
 > search_symbols is to try to track down information about one
 > particular minimal symbol: does it have debugging information, or
 > doesn't it?  Given that that's the case, doing that via lookup_symbol
 > is at best overkill and at worst wrong.  This suggests that we might
 > be able to get around the issue by replacing that call to
 > lookup_symbol by a call to lookup_symbol_aux_minsyms.  The only
 > question that I have is whether the first argument should then be the
 > mangled name of 'msymbol' or the demangled name; I'd be happier if we
 > understood the situation with respect to my "Comment #2".
 > 

Yeah, I think it's just a coincidence that lookup_symbol is still
called.  At the time that call was introduced, lookup_symbol was maybe
the only function available for this sort of things.
We could try to call the lookup_symbol_aux_minsyms function.


 > A datum which may or may not be relevant: currently, partial symbols
 > never have their names demangled.  I'd assumed that this was a bug;
 > but I just noticed the following comment in search_symbols:
 > 
 >   This is in particular necessary for demangled variable names,
 >   which are no longer put into the partial symbol tables.
 > 
 > Sigh.  So I have another suggestion:
 > 
 > Suggestion #2: Maybe we should put this particular patch on hold and
 > come to some sort of consensus as to how to deal with
 > mangled/demangled names.  I'll post an RFC for that later today.
 > 

Ok, whatever seems easier for you. Although I think we can try to fix
the parameter problem, at least, and see what breaks.

Elena


 > David Carlton
 > carlton@math.stanford.edu


  reply	other threads:[~2002-12-19 22:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-05 15:44 David Carlton
2002-12-09 13:35 ` Elena Zannoni
2002-12-10 11:28   ` David Carlton
2002-12-10 11:37     ` Daniel Jacobowitz
2002-12-10 11:56       ` Elena Zannoni
2002-12-19  8:54     ` Elena Zannoni
2002-12-19 11:47       ` David Carlton
2002-12-19 15:39         ` Elena Zannoni [this message]
2002-12-19 15:41           ` David Carlton
2002-12-19 16:06             ` Elena Zannoni
2002-12-20 13:02               ` David Carlton
2002-12-21 10:54 Michael Elizabeth Chastain
2002-12-21 11:59 ` Elena Zannoni
2002-12-21 20:20   ` David Carlton
2002-12-23  8:55     ` David Carlton
2002-12-21 22:16 Michael Elizabeth Chastain
2002-12-22 16:01 Michael Elizabeth Chastain
2002-12-23  0:46 Michael Elizabeth Chastain

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=15874.18989.470549.778392@localhost.redhat.com \
    --to=ezannoni@redhat.com \
    --cc=carlton@math.stanford.edu \
    --cc=gdb-patches@sources.redhat.com \
    --cc=jimb@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