aboutsummaryrefslogtreecommitdiff
path: root/source/Symbol/LineEntry.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-12-30 11:55:28 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-12-30 11:55:28 +0000
commite81d9d49145e432d917eea3a70d2ae74dcad1d89 (patch)
tree9ed5e1a91f242e2cb5911577356e487a55c01b78 /source/Symbol/LineEntry.cpp
parent85d8ef8f1f0e0e063a8571944302be2d2026f823 (diff)
Notes
Diffstat (limited to 'source/Symbol/LineEntry.cpp')
-rw-r--r--source/Symbol/LineEntry.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/source/Symbol/LineEntry.cpp b/source/Symbol/LineEntry.cpp
index 08a2392e1136..815101368bd1 100644
--- a/source/Symbol/LineEntry.cpp
+++ b/source/Symbol/LineEntry.cpp
@@ -244,3 +244,42 @@ LineEntry::Compare (const LineEntry& a, const LineEntry& b)
return FileSpec::Compare (a.file, b.file, true);
}
+AddressRange
+LineEntry::GetSameLineContiguousAddressRange () const
+{
+ // Add each LineEntry's range to complete_line_range until we find
+ // a different file / line number.
+ AddressRange complete_line_range = range;
+
+ 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);
+
+ if (next_line_sc.line_entry.IsValid()
+ && next_line_sc.line_entry.range.GetByteSize() > 0
+ && file == next_line_sc.line_entry.file)
+ {
+ // 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;
+ }
+ }
+ break;
+ }
+ return complete_line_range;
+}