diff options
author | Greg Clayton <clayborg@gmail.com> | 2019-05-06 20:01:21 +0000 |
---|---|---|
committer | Greg Clayton <clayborg@gmail.com> | 2019-05-06 20:01:21 +0000 |
commit | 8a7779209d93660d2fb68f1f5ebe1d56959495b8 (patch) | |
tree | 8e9fd14b056d174e8093583e3ce71769c159fb3b /lldb/source/Symbol/LineEntry.cpp | |
parent | 364ef5db2b23f0aee6e6aa76b338d2210e54a0d7 (diff) | |
download | bcm5719-llvm-8a7779209d93660d2fb68f1f5ebe1d56959495b8.tar.gz bcm5719-llvm-8a7779209d93660d2fb68f1f5ebe1d56959495b8.zip |
Include inlined functions when figuring out a contiguous address range
Checking this in for Antonio Afonso:
This diff changes the function LineEntry::GetSameLineContiguousAddressRange so that it also includes function calls that were inlined at the same line of code.
My motivation is to decrease the step over time of lines that heavly rely on inlined functions. I have multiple examples in the code base I work that makes a step over stop 20 or mote times internally. This can easly had up to step overs that take >500ms which I was able to lower to 25ms with this new strategy.
The reason the current code is not extending the address range beyond an inlined function is because when we resolve the symbol at the next address of the line entry we will get the entry line corresponding to where the original code for the inline function lives, making us barely extend the range. This then will end up on a step over having to stop multiple times everytime there's an inlined function.
To check if the range is an inlined function at that line I also get the block associated with the next address and check if there is a parent block with a call site at the line we're trying to extend.
To check this I created a new function in Block called GetContainingInlinedBlockWithCallSite that does exactly that. I also added a new function to Declaration for convinence of checking file/line named CompareFileAndLine.
To avoid potential issues when extending an address range I added an Extend function that extends the range by the AddressRange given as an argument. This function returns true to indicate sucess when the rage was agumented, false otherwise (e.g.: the ranges are not connected). The reason I do is to make sure that we're not just blindly extending complete_line_range by whatever GetByteSize() we got. If for some reason the ranges are not connected or overlap, or even 0, this could be an issue.
I also added a unit tests for this change and include the instructions on the test itself on how to generate the yaml file I use for testing.
Differential Revision: https://reviews.llvm.org/D61292
llvm-svn: 360071
Diffstat (limited to 'lldb/source/Symbol/LineEntry.cpp')
-rw-r--r-- | lldb/source/Symbol/LineEntry.cpp | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/lldb/source/Symbol/LineEntry.cpp b/lldb/source/Symbol/LineEntry.cpp index 94887a0f785..959a3274ec9 100644 --- a/lldb/source/Symbol/LineEntry.cpp +++ b/lldb/source/Symbol/LineEntry.cpp @@ -190,40 +190,62 @@ int LineEntry::Compare(const LineEntry &a, const LineEntry &b) { return FileSpec::Compare(a.file, b.file, true); } -AddressRange LineEntry::GetSameLineContiguousAddressRange() const { +AddressRange LineEntry::GetSameLineContiguousAddressRange( + bool include_inlined_functions) const { // Add each LineEntry's range to complete_line_range until we find a // different file / line number. AddressRange complete_line_range = range; + auto symbol_context_scope = lldb::eSymbolContextLineEntry; + Declaration start_call_site(original_file, line); + if (include_inlined_functions) + symbol_context_scope |= lldb::eSymbolContextBlock; while (true) { SymbolContext next_line_sc; Address range_end(complete_line_range.GetBaseAddress()); range_end.Slide(complete_line_range.GetByteSize()); - range_end.CalculateSymbolContext(&next_line_sc, - lldb::eSymbolContextLineEntry); + range_end.CalculateSymbolContext(&next_line_sc, symbol_context_scope); - if (next_line_sc.line_entry.IsValid() && - next_line_sc.line_entry.range.GetByteSize() > 0 && - original_file == next_line_sc.line_entry.original_file) { + if (!next_line_sc.line_entry.IsValid() || + next_line_sc.line_entry.range.GetByteSize() == 0) + break; + + if (original_file == next_line_sc.line_entry.original_file && + (next_line_sc.line_entry.line == 0 || + line == next_line_sc.line_entry.line)) { // Include any line 0 entries - they indicate that this is compiler- // generated code that does not correspond to user source code. - if (next_line_sc.line_entry.line == 0) { - complete_line_range.SetByteSize( - complete_line_range.GetByteSize() + - next_line_sc.line_entry.range.GetByteSize()); - continue; - } - - if (line == next_line_sc.line_entry.line) { - // next_line_sc is the same file & line as this LineEntry, so extend - // our AddressRange by its size and continue to see if there are more - // LineEntries that we can combine. - complete_line_range.SetByteSize( - complete_line_range.GetByteSize() + - next_line_sc.line_entry.range.GetByteSize()); - continue; - } + // next_line_sc is the same file & line as this LineEntry, so extend + // our AddressRange by its size and continue to see if there are more + // LineEntries that we can combine. However, if there was nothing to + // extend we're done. + if (!complete_line_range.Extend(next_line_sc.line_entry.range)) + break; + continue; + } + + if (include_inlined_functions && next_line_sc.block && + next_line_sc.block->GetContainingInlinedBlock() != nullptr) { + // The next_line_sc might be in a different file if it's an inlined + // function. If this is the case then we still want to expand our line + // range to include them if the inlined function is at the same call site + // as this line entry. The current block could represent a nested inline + // function call so we need to need to check up the block tree to see if + // we find one. + auto inlined_parent_block = + next_line_sc.block->GetContainingInlinedBlockWithCallSite( + start_call_site); + if (!inlined_parent_block) + // We didn't find any parent inlined block with a call site at this line + // entry so this inlined function is probably at another line. + break; + // Extend our AddressRange by the size of the inlined block, but if there + // was nothing to add then we're done. + if (!complete_line_range.Extend(next_line_sc.line_entry.range)) + break; + continue; } + break; } return complete_line_range; |