[Lldb-commits] [lldb] r176846 - For file & line breakpoints, if there are subsets of contiguous line table entries for the specified line, set the

Jim Ingham jingham at apple.com
Mon Mar 11 18:25:22 PDT 2013


Author: jingham
Date: Mon Mar 11 20:25:22 2013
New Revision: 176846

URL: http://llvm.org/viewvc/llvm-project?rev=176846&view=rev
Log:
For file & line breakpoints, if there are subsets of contiguous line table entries for the specified line, set the
breakpoint on the first one of each of the contiguous sub-sets of entries, and not all the others.

Modified:
    lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp

Modified: lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp?rev=176846&r1=176845&r2=176846&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp Mon Mar 11 20:25:22 2013
@@ -123,85 +123,101 @@ BreakpointResolverFileLine::SearchCallba
                 current_idx++;
         }
             
-        // Okay, we've found the closest line number match, now throw away all the others, 
+        // Okay, we've found the closest line number match, now throw away all the others:
+        
+        current_idx = 0;
+        while (current_idx < tmp_sc_list.GetSize())
+        {
+            if (tmp_sc_list.GetContextAtIndex(current_idx, sc))
+            {
+                if (sc.line_entry.line != closest_line_number)
+                    tmp_sc_list.RemoveContextAtIndex(current_idx);
+                else
+                    current_idx++;
+            }
+        }
+        
+        // Next go through and see if there are line table entries that are contiguous, and if so keep only the
+        // first of the contiguous range:
+        
+        lldb::addr_t last_end_addr = LLDB_INVALID_ADDRESS;
+        current_idx = 0;
+        while (current_idx < tmp_sc_list.GetSize())
+        {
+            if (tmp_sc_list.GetContextAtIndex(current_idx, sc))
+            {
+                lldb::addr_t start_file_addr = sc.line_entry.range.GetBaseAddress().GetFileAddress();
+                lldb::addr_t end_file_addr   = start_file_addr + sc.line_entry.range.GetByteSize();
+                
+                if (start_file_addr == last_end_addr)
+                    tmp_sc_list.RemoveContextAtIndex(current_idx);
+                else
+                    current_idx++;
+
+                last_end_addr = end_file_addr;
+            }
+        }
+        
         // and make breakpoints out of the closest line number match.
         
         uint32_t tmp_sc_list_size = tmp_sc_list.GetSize();
         
         for (uint32_t i = 0; i < tmp_sc_list_size; i++)
         {
-            SymbolContext sc;
             if (tmp_sc_list.GetContextAtIndex(i, sc))
             {
-                if (sc.line_entry.line == closest_line_number)
+                Address line_start = sc.line_entry.range.GetBaseAddress();
+                if (line_start.IsValid())
                 {
-                    Address line_start = sc.line_entry.range.GetBaseAddress();
-                    if (line_start.IsValid())
+                    if (filter.AddressPasses(line_start))
                     {
-                        if (filter.AddressPasses(line_start))
+                        // If the line number is before the prologue end, move it there...
+                        bool skipped_prologue = false;
+                        if (m_skip_prologue)
                         {
-                            // If the line number is before the prologue end, move it there...
-                            bool skipped_prologue = false;
-                            if (m_skip_prologue)
+                            if (sc.function)
                             {
-                                if (sc.function)
+                                Address prologue_addr(sc.function->GetAddressRange().GetBaseAddress());
+                                if (prologue_addr.IsValid() && (line_start == prologue_addr))
                                 {
-                                    Address prologue_addr(sc.function->GetAddressRange().GetBaseAddress());
-                                    if (prologue_addr.IsValid() && (line_start == prologue_addr))
+                                    const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
+                                    if (prologue_byte_size)
                                     {
-                                        const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
-                                        if (prologue_byte_size)
+                                        prologue_addr.Slide(prologue_byte_size);
+                 
+                                        if (filter.AddressPasses(prologue_addr))
                                         {
-                                            prologue_addr.Slide(prologue_byte_size);
-                     
-                                            if (filter.AddressPasses(prologue_addr))
-                                            {
-                                                skipped_prologue = true;
-                                                line_start = prologue_addr;
-                                            }
+                                            skipped_prologue = true;
+                                            line_start = prologue_addr;
                                         }
                                     }
                                 }
                             }
-                        
-                            BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start));
-                            if (log && bp_loc_sp && !m_breakpoint->IsInternal())
-                            {
-                                StreamString s;
-                                bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose);
-                                log->Printf ("Added location (skipped prologue: %s): %s \n", skipped_prologue ? "yes" : "no", s.GetData());
-                            }
                         }
-                        else if (log)
+                    
+                        BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(line_start));
+                        if (log && bp_loc_sp && !m_breakpoint->IsInternal())
                         {
-                            log->Printf ("Breakpoint at file address 0x%" PRIx64 " for %s:%d didn't pass the filter.\n",
-                                         line_start.GetFileAddress(),
-                                         m_file_spec.GetFilename().AsCString("<Unknown>"),
-                                         m_line_number);
+                            StreamString s;
+                            bp_loc_sp->GetDescription (&s, lldb::eDescriptionLevelVerbose);
+                            log->Printf ("Added location (skipped prologue: %s): %s \n", skipped_prologue ? "yes" : "no", s.GetData());
                         }
                     }
-                    else
+                    else if (log)
                     {
-                        if (log)
-                            log->Printf ("error: Unable to set breakpoint at file address 0x%" PRIx64 " for %s:%d\n",
-                                         line_start.GetFileAddress(),
-                                         m_file_spec.GetFilename().AsCString("<Unknown>"),
-                                         m_line_number);
+                        log->Printf ("Breakpoint at file address 0x%" PRIx64 " for %s:%d didn't pass the filter.\n",
+                                     line_start.GetFileAddress(),
+                                     m_file_spec.GetFilename().AsCString("<Unknown>"),
+                                     m_line_number);
                     }
                 }
                 else
                 {
-        #if 0
-                    s << "error: Breakpoint at '" << pos->c_str() << "' isn't resolved yet: \n";
-                    if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionNameOffset))
-                        s.EOL();
-                    if (sc.line_entry.address.Dump(&s, Address::DumpStyleSectionPointerOffset))
-                        s.EOL();
-                    if (sc.line_entry.address.Dump(&s, Address::DumpStyleFileAddress))
-                        s.EOL();
-                    if (sc.line_entry.address.Dump(&s, Address::DumpStyleLoadAddress))
-                        s.EOL();
-        #endif
+                    if (log)
+                        log->Printf ("error: Unable to set breakpoint at file address 0x%" PRIx64 " for %s:%d\n",
+                                     line_start.GetFileAddress(),
+                                     m_file_spec.GetFilename().AsCString("<Unknown>"),
+                                     m_line_number);
                 }
             }
         }





More information about the lldb-commits mailing list