This is the mail archive of the gdb-patches@sourceware.org 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: [RFA 1/6] Use std::vector in end_symtab_get_static_block


Pedro Alves wrote:
> On 10/20/2017 04:33 PM, Ulrich Weigand wrote:
> > [Re-sent since the original seems to have gotten lost somehow.]
> > 
> >>>>>>> "Simon" == Simon Marchi <simon.marchi@ericsson.com> writes:
> >>
> >> Simon> That made me doubt for a second, since we're more used to see "<"
> >> Simon> in these functions.  I then saw that block_compar did sort them
> >> Simon> in descending order.  Could you add a comment here to indicate that?
> >>
> >> Done, thanks.
> > 
> > This causes a number of regressions in the gdb.opt/inline-cmds.exp
> > test case for me.  Not sure exactly why, but changing the std::sort
> > to a std::stable_sort like below fixes those regressions for me.
> > Maybe the logic for handling inline function blocks somehow relied
> > on some (undocumented) behavior of qsort for handling elements that
> > compare as equal?
> > 
> 
> Sounds like we should improve the sort predicate to disambiguate
> better, define a total order?  I don't really know which sorting
> is assumed, but e.g., if the block start addresses are the same,
> compare the blocks' end addresses.  If those match as well,
> repeat but with the blocks' superblocks.  And/or sort function
> blocks before non-function blocks.  Etc.

I don't believe we can do this, actually.  At this point in time,
a block's superblock is not yet known -- in fact, the superblock
links are set up afterwards *based on* the order determined here.

We could compare end addresses, but that doesn't fully resolve
the issue, in case an inline function 100% overlaps its caller.

It looks like the only place where have the information which
function is the caller and which the callee is in fact the original
order of blocks in the pending_blocks list, since they were placed
in the correct order by the DWARF reader based on DWARF info.

Now, the reason why we re-sort pending_blocks here is to allow
for object code reordering (hot/cold sections and the like).
But this type of reordering never actually affects inline function
relationships.  So it may be that just using stable_sort here is
actually the *correct* fix ...

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com


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