[PATCH] Fix DWARFContext::getCompileUnitForOffset().

Frederic Riss friss at apple.com
Mon Sep 15 11:05:20 PDT 2014


================
Comment at: lib/DebugInfo/DWARFContext.cpp:415
@@ -415,2 +414,3 @@
+      std::upper_bound(CUs.begin(), CUs.end(), Offset, OffsetComparator());
   if (CU != CUs.end()) {
     return CU->get();
----------------
samsonov wrote:
> You still need to check that Offset you're looking for is inside the CU.
I don't think so as units in a section are necessarily contiguous. The range of acceptable offsets goes from 0 inclusive to lastUnit->getNextUnitOffset() exclusive. And upper_bound will rightly return CUs.end() if we pass an offset >= the last admissible one.

================
Comment at: lib/DebugInfo/DWARFUnit.h:66
@@ -65,3 +65,3 @@
   UnitType *getUnitForOffset(uint32_t Offset) const {
-    auto *CU = std::lower_bound(this->begin(), this->end(), Offset,
+    auto *CU = std::upper_bound(this->begin(), this->end(), Offset,
                                 UnitOffsetComparator());
----------------
samsonov wrote:
> You still need to check that Offset you're looking for is inside the CU.
I might be wrong, but as I answered last time you told me that, I think this is not true. The admissible offsets go from 0 to lastUnit->getNextUnitOffset() exclusive. There is no hole in the section.

http://reviews.llvm.org/D5262






More information about the llvm-commits mailing list