This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question about blockframe.c:inside_main_func()


> 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.

Indeed, it seems that we could improve a bit this code: It really looks
like we are trying to compute the low/high addresses for function main
twice! Even when main is found within the debug info, we go through the
through the trouble of finding the bounds of function "main" from the
min syms anyway. A missing condition somewhere?

At first glance, I would think something like this ought to work:

  if (lowpc == INVALID && highpc == INVALID)
  {
    msymbol = lookup_minimal_symbol (main_name ()
  
    if (msymbol != NULL)
      {
         /* Try finding the bounds from the debug info.  */
         struct symbol *mainsym = find_pc_function (...);
         if (mainsym != NULL && ...)
           {
             lowpc = BLOCK_START (...);
             highpc = BLOCK_END (...);
           }
         else
           {
             /* Not found in the debug info, use the minsyms...  */
             CORE_ADDR maddr = SYMBOL_VALUE_ADDRESS (msymbol);
             [...]
           }
      }
  }
  
  return (lowpc <= pc && highpc > pc);

Unless Andrew had a reason to believe that recomputing the low/high
PCs was necessary?

See http://sources.redhat.com/ml/gdb-patches/2003-07/msg00144.html,
where the block computing the function bounds from minimal symbols
was introduced.

-- 
Joel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]