[Lldb-commits] [lldb] r107729 - /lldb/trunk/source/Symbol/LineTable.cpp

Greg Clayton gclayton at apple.com
Tue Jul 6 16:34:08 PDT 2010


Author: gclayton
Date: Tue Jul  6 18:34:08 2010
New Revision: 107729

URL: http://llvm.org/viewvc/llvm-project?rev=107729&view=rev
Log:
Fixed an issue with looking up line table entries by address where internal
line table entries that were termination entries (ones that define the bounds
of the previous entry) could be found when looking up line table entries.
We now properly skip these termination entries and check the next entry to
try for a match.


Modified:
    lldb/trunk/source/Symbol/LineTable.cpp

Modified: lldb/trunk/source/Symbol/LineTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineTable.cpp?rev=107729&r1=107728&r2=107729&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/LineTable.cpp (original)
+++ lldb/trunk/source/Symbol/LineTable.cpp Tue Jul  6 18:34:08 2010
@@ -194,22 +194,50 @@
                     --pos;
                 else if (pos->sect_offset == search_entry.sect_offset)
                 {
-                    while (pos != begin_pos)
+                    // If this is a termination entry, it should't match since
+                    // entries with the "is_terminal_entry" member set to true 
+                    // are termination entries that define the range for the 
+                    // previous entry.
+                    if (pos->is_terminal_entry)
                     {
-                        entry_collection::const_iterator prev_pos = pos - 1;
-                        if (prev_pos->sect_idx    == search_entry.sect_idx &&
-                            prev_pos->sect_offset == search_entry.sect_offset)
-                            --pos;
-                        else
-                            break;
+                        // The matching entry is a terminal entry, so we skip
+                        // ahead to the next entry to see if there is another
+                        // entry following this one whose section/offset matches.
+                        ++pos;
+                        if (pos != end_pos)
+                        {
+                            if (pos->sect_offset != search_entry.sect_offset)
+                                pos = end_pos;
+                        }
+                    }
+                    
+                    if (pos != end_pos)
+                    {
+                        // While in the same section/offset backup to find the first
+                        // line entry that matches the address in case there are 
+                        // multiple
+                        while (pos != begin_pos)
+                        {
+                            entry_collection::const_iterator prev_pos = pos - 1;
+                            if (prev_pos->sect_idx    == search_entry.sect_idx &&
+                                prev_pos->sect_offset == search_entry.sect_offset &&
+                                prev_pos->is_terminal_entry == false)
+                                --pos;
+                            else
+                                break;
+                        }
                     }
                 }
 
             }
-            uint32_t match_idx = std::distance (begin_pos, pos);
-            success = ConvertEntryAtIndexToLineEntry(match_idx, line_entry);
-            if (index_ptr != NULL && success)
-                *index_ptr = match_idx;
+            
+            if (pos != end_pos)
+            {
+                uint32_t match_idx = std::distance (begin_pos, pos);
+                success = ConvertEntryAtIndexToLineEntry(match_idx, line_entry);
+                if (index_ptr != NULL && success)
+                    *index_ptr = match_idx;
+            }
         }
     }
     return success;





More information about the lldb-commits mailing list