[RFA 1/2] Make line tables independent of progspace
Tom Tromey
tom@tromey.com
Wed Mar 28 05:02:00 GMT 2018
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
>> + auto pc_compare = [=](const CORE_ADDR & pc,
>> + const struct linetable_entry & lhs)->bool
>> {
>> - return pc < lhs.pc;
>> + return pc < lhs.address (iter_s);
>> };
Simon> Since we know this will be called many times and address() is substantially
Simon> more costly than just reading a CORE_ADDR field, maybe it would be good to
Simon> save it to a variable before and use that in the lambda.
I am not sure this would work, because LHS is what changes here --
std::upper_bound is searching through the line table looking for a
match.
One idea might be to "unrelocate" PC to do the search. This would make
the search more efficient. I will try this.
Simon> I was also thinking
Simon> the same thing for the various other calls to address() in this function, since
Simon> sometimes the same value is recomputed multiple times.
I suppose most work could be done on the unrelocated form, with the
address computation happening only at the end.
>> + /* Set the members of this object from another linetable_entry. */
>> + void set (const linetable_entry &other)
>> + {
>> + m_line = other.m_line;
>> + m_pc = other.m_pc;
>> + }
Simon> This really looks like an assignment operator (the default one would be
Simon> enough). Is there a reason to have this set overload? Either way works,
Simon> I'm just curious.
I just did it to keep the names consistent, but I will change it to use
the default operator=.
>> - newLineTb->item[newline] = oldLineTb->item[jj];
>> - newLineTb->item[newline].line = oldLineTb->item[jj + 1].line;
>> + newLineTb->item[newline].set (oldLineTb->item[jj].raw_address (),
>> + oldLineTb->item[jj + 1].line ());
Simon> The address and the line are inverted here.
Bleah. Thanks again.
Tom
More information about the Gdb-patches
mailing list