[Lldb-commits] [lldb] r131061 - in /lldb/trunk/source: API/SBThread.cpp Commands/CommandObjectThread.cpp

Jim Ingham jingham at apple.com
Sat May 7 17:56:32 PDT 2011


Author: jingham
Date: Sat May  7 19:56:32 2011
New Revision: 131061

URL: http://llvm.org/viewvc/llvm-project?rev=131061&view=rev
Log:
StepUntil should check whether the target of the step until is in the current
function and if not return an error.

Modified:
    lldb/trunk/source/API/SBThread.cpp
    lldb/trunk/source/Commands/CommandObjectThread.cpp

Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=131061&r1=131060&r2=131061&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Sat May  7 19:56:32 2011
@@ -683,14 +683,28 @@
             }
         }
     
+        // Grab the current function, then we will make sure the "until" address is
+        // within the function.  We discard addresses that are out of the current
+        // function, and then if there are no addresses remaining, give an appropriate
+        // error message.
+        
+        bool all_in_function = true;
+        AddressRange fun_range = frame_sc.function->GetAddressRange();
+        
         std::vector<addr_t> step_over_until_addrs;
         const bool abort_other_plans = true;
         const bool stop_other_threads = true;
         const bool check_inlines = true;
         const bool exact = false;
+        Target *target = &m_opaque_sp->GetProcess().GetTarget();
 
         SymbolContextList sc_list;
-        const uint32_t num_matches = frame_sc.comp_unit->ResolveSymbolContext (step_file_spec, line, check_inlines, exact, eSymbolContextLineEntry, sc_list);
+        const uint32_t num_matches = frame_sc.comp_unit->ResolveSymbolContext (step_file_spec, 
+                                                                               line, 
+                                                                               check_inlines, 
+                                                                               exact, 
+                                                                               eSymbolContextLineEntry, 
+                                                                               sc_list);
         if (num_matches > 0)
         {
             SymbolContext sc;
@@ -698,19 +712,27 @@
             {
                 if (sc_list.GetContextAtIndex(i, sc))
                 {
-                    addr_t step_addr = sc.line_entry.range.GetBaseAddress().GetLoadAddress(&m_opaque_sp->GetProcess().GetTarget());
+                    addr_t step_addr = sc.line_entry.range.GetBaseAddress().GetLoadAddress(target);
                     if (step_addr != LLDB_INVALID_ADDRESS)
                     {
-                        step_over_until_addrs.push_back(step_addr);
+                        if (fun_range.ContainsLoadAddress(step_addr, target))
+                            step_over_until_addrs.push_back(step_addr);
+                        else
+                            all_in_function = false;
                     }
                 }
             }
         }
-
+        
         if (step_over_until_addrs.empty())
         {
-            step_file_spec.GetPath (path, sizeof(path));
-            sb_error.SetErrorStringWithFormat("No line entries for %s:u", path, line);
+            if (all_in_function)
+            {
+                step_file_spec.GetPath (path, sizeof(path));
+                sb_error.SetErrorStringWithFormat("No line entries for %s:u", path, line);
+            }
+            else
+                sb_error.SetErrorString ("Step until target not in current function.\n");
         }
         else
         {

Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=131061&r1=131060&r2=131061&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectThread.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectThread.cpp Sat May  7 19:56:32 2011
@@ -937,7 +937,10 @@
             if (thread == NULL)
             {
                 const uint32_t num_threads = process->GetThreadList().GetSize();
-                result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n", m_options.m_thread_idx, 0, num_threads);
+                result.AppendErrorWithFormat ("Thread index %u is out of range (valid values are 0 - %u).\n", 
+                                              m_options.m_thread_idx, 
+                                              0, 
+                                              num_threads);
                 result.SetStatus (eReturnStatusFailed);
                 return false;
             }
@@ -948,7 +951,9 @@
             if (frame == NULL)
             {
 
-                result.AppendErrorWithFormat ("Frame index %u is out of range for thread %u.\n", m_options.m_frame_idx, m_options.m_thread_idx);
+                result.AppendErrorWithFormat ("Frame index %u is out of range for thread %u.\n", 
+                                              m_options.m_frame_idx, 
+                                              m_options.m_thread_idx);
                 result.SetStatus (eReturnStatusFailed);
                 return false;
             }
@@ -980,9 +985,12 @@
                 Address fun_start_addr = fun_addr_range.GetBaseAddress();
                 line_table->FindLineEntryByAddress (fun_start_addr, function_start, &index_ptr);
 
-                Address fun_end_addr(fun_start_addr.GetSection(), fun_start_addr.GetOffset() + fun_addr_range.GetByteSize());
+                Address fun_end_addr(fun_start_addr.GetSection(), 
+                                     fun_start_addr.GetOffset() + fun_addr_range.GetByteSize());
                 line_table->FindLineEntryByAddress (fun_end_addr, function_start, &end_ptr);
 
+                bool all_in_function = true;
+                
                 while (index_ptr <= end_ptr)
                 {
                     LineEntry line_entry;
@@ -992,16 +1000,38 @@
 
                     addr_t address = line_entry.range.GetBaseAddress().GetLoadAddress(target);
                     if (address != LLDB_INVALID_ADDRESS)
-                        address_list.push_back (address);
+                    {
+                        if (fun_addr_range.ContainsLoadAddress (address, target))
+                            address_list.push_back (address);
+                        else
+                            all_in_function = false;
+                    }
                     index_ptr++;
                 }
 
-                new_plan = thread->QueueThreadPlanForStepUntil (abort_other_plans, &address_list.front(), address_list.size(), m_options.m_stop_others, thread->GetSelectedFrameIndex ());
+                if (address_list.size() == 0)
+                {
+                    if (all_in_function)
+                        result.AppendErrorWithFormat ("No line entries matching until target.\n");
+                    else
+                        result.AppendErrorWithFormat ("Until target outside of the current function.\n");
+                        
+                    result.SetStatus (eReturnStatusFailed);
+                    return false;
+                }
+                
+                new_plan = thread->QueueThreadPlanForStepUntil (abort_other_plans, 
+                                                                &address_list.front(), 
+                                                                address_list.size(), 
+                                                                m_options.m_stop_others, 
+                                                                thread->GetSelectedFrameIndex ());
                 new_plan->SetOkayToDiscard(false);
             }
             else
             {
-                result.AppendErrorWithFormat ("Frame index %u of thread %u has no debug information.\n", m_options.m_frame_idx, m_options.m_thread_idx);
+                result.AppendErrorWithFormat ("Frame index %u of thread %u has no debug information.\n", 
+                                              m_options.m_frame_idx, 
+                                              m_options.m_thread_idx);
                 result.SetStatus (eReturnStatusFailed);
                 return false;
 





More information about the lldb-commits mailing list