Author: jingham
Date: Fri Feb 12 18:31:47 2016
New Revision: 260772

URL: http://llvm.org/viewvc/llvm-project?rev=260772&view=rev
Log:
Adding an SBThread::StepInto that takes an end-line, also moved the code that 
figures
out the address range for the step to SymbolContext.

Modified:
    lldb/trunk/include/lldb/API/SBThread.h
    lldb/trunk/include/lldb/Symbol/SymbolContext.h
    lldb/trunk/scripts/interface/SBThread.i
    lldb/trunk/source/API/SBThread.cpp
    lldb/trunk/source/Commands/CommandObjectThread.cpp
    lldb/trunk/source/Symbol/SymbolContext.cpp

Modified: lldb/trunk/include/lldb/API/SBThread.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=260772&r1=260771&r2=260772&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBThread.h (original)
+++ lldb/trunk/include/lldb/API/SBThread.h Fri Feb 12 18:31:47 2016
@@ -116,6 +116,12 @@ public:
     StepInto (const char *target_name, lldb::RunMode stop_other_threads = 
lldb::eOnlyDuringStepping);
     
     void
+    StepInto (const char *target_name,
+              uint32_t end_line,
+              SBError &error,
+              lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+    
+    void
     StepOut ();
 
     void

Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=260772&r1=260771&r2=260772&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Fri Feb 12 18:31:47 2016
@@ -244,6 +244,9 @@ public:
                      uint32_t range_idx, 
                      bool use_inline_block_range,
                      AddressRange &range) const;
+    
+    bool
+    GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range, 
Error &error);
 
     void
     GetDescription(Stream *s, 

Modified: lldb/trunk/scripts/interface/SBThread.i
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBThread.i?rev=260772&r1=260771&r2=260772&view=diff
==============================================================================
--- lldb/trunk/scripts/interface/SBThread.i (original)
+++ lldb/trunk/scripts/interface/SBThread.i Fri Feb 12 18:31:47 2016
@@ -206,6 +206,17 @@ public:
     void
     StepInto (const char *target_name, lldb::RunMode stop_other_threads = 
lldb::eOnlyDuringStepping);
 
+    %feature("autodoc", "
+    Step  the current thread from the current source line to the line given by 
end_line, stopping if
+    the thread steps into the function given by target_name.  If target_name 
is None, then stepping will stop
+    in any of the places we would normally stop.
+    ") StepInto;
+    void
+    StepInto (const char *target_name,
+              uint32_t end_line,
+              SBError &error,
+              lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping);
+
     void
     StepOut ();
 

Modified: lldb/trunk/source/API/SBThread.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=260772&r1=260771&r2=260772&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Fri Feb 12 18:31:47 2016
@@ -774,6 +774,13 @@ SBThread::StepInto (lldb::RunMode stop_o
 void
 SBThread::StepInto (const char *target_name, lldb::RunMode stop_other_threads)
 {
+    SBError error;
+    StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
+}
+
+void
+SBThread::StepInto (const char *target_name, uint32_t end_line, SBError 
&error, lldb::RunMode stop_other_threads)
+{
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
 
     Mutex::Locker api_locker;
@@ -795,11 +802,20 @@ SBThread::StepInto (const char *target_n
 
         if (frame_sp && frame_sp->HasDebugInformation ())
         {
+            SymbolContext 
sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
+            AddressRange range;
+            if (end_line == LLDB_INVALID_LINE_NUMBER)
+                range = sc.line_entry.range;
+            else
+            {
+                if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, 
error.ref()))
+                    return;
+            }
+            
             const LazyBool step_out_avoids_code_without_debug_info = 
eLazyBoolCalculate;
             const LazyBool step_in_avoids_code_without_debug_info = 
eLazyBoolCalculate;
-            SymbolContext 
sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
             new_plan_sp = thread->QueueThreadPlanForStepInRange 
(abort_other_plans,
-                                                              sc.line_entry,
+                                                              range,
                                                               sc,
                                                               target_name,
                                                               
stop_other_threads,
@@ -813,8 +829,7 @@ SBThread::StepInto (const char *target_n
                                                                            
stop_other_threads);
         }
 
-        // This returns an error, we should use it!
-        ResumeNewPlan (exe_ctx, new_plan_sp.get());
+        error = ResumeNewPlan (exe_ctx, new_plan_sp.get());
     }
 }
 

Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=260772&r1=260771&r2=260772&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectThread.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectThread.cpp Fri Feb 12 18:31:47 2016
@@ -606,75 +606,30 @@ protected:
 
             if (frame->HasDebugInformation ())
             {
-                AddressRange range = 
frame->GetSymbolContext(eSymbolContextEverything).line_entry.range;
+                AddressRange range;
+                SymbolContext sc = 
frame->GetSymbolContext(eSymbolContextEverything);
                 if (m_options.m_end_line != LLDB_INVALID_LINE_NUMBER)
                 {
-                    SymbolContext sc = 
frame->GetSymbolContext(eSymbolContextEverything);
-                    if (sc.line_entry.line > m_options.m_end_line)
+                    Error error;
+                    if 
(!sc.GetAddressRangeFromHereToEndLine(m_options.m_end_line, range, error))
                     {
-                        result.AppendErrorWithFormat("end line option %d must 
be after the current line: %d",
-                                                     m_options.m_end_line,
-                                                     sc.line_entry.line);
+                        result.AppendErrorWithFormat("invalid end-line option: 
%s.", error.AsCString());
                         result.SetStatus(eReturnStatusFailed);
                         return false;
                     }
-
-                    CompileUnit *cu = sc.comp_unit;
-                    uint32_t line_index = 0;
-                    bool found = false;
-                    while (1)
-                    {
-                        LineEntry this_line;
-                        line_index = cu->FindLineEntry(line_index, 
sc.line_entry.line, nullptr, false, &this_line);
-                        if (line_index == UINT32_MAX)
-                            break;
-                        if (LineEntry::Compare(this_line, sc.line_entry) == 0)
-                        {
-                            found = true;
-                            break;
-                        }
-                    }
-                    LineEntry end_entry;
-                    if (!found)
-                    {
-                        // Can't find the index of the SymbolContext's line 
entry in the SymbolContext's CompUnit.
-                        result.AppendErrorWithFormat("Can't find the current 
line entry in the CompUnit - can't process "
-                                                     "the end-line option");
-                        result.SetStatus(eReturnStatusFailed);
-                        return false;
-                    }
-                    
-                    line_index = cu->FindLineEntry(line_index, 
m_options.m_end_line, nullptr, false, &end_entry);
-                    if (line_index == UINT32_MAX)
-                    {
-                        result.AppendErrorWithFormat("could not find a line 
table entry corresponding "
-                                                     "to end line number %d",
-                                                     m_options.m_end_line);
-                        result.SetStatus(eReturnStatusFailed);
-                        return false;
-                    }
-                    
-                    Block *func_block = sc.GetFunctionBlock();
-                    if (func_block && 
func_block->GetRangeIndexContainingAddress(end_entry.range.GetBaseAddress()) == 
UINT32_MAX)
-                    {
-                        result.AppendErrorWithFormat("end line number %d is 
not contained within the current function.",
-                                                     m_options.m_end_line);
-                        result.SetStatus(eReturnStatusFailed);
-                        return false;
-                    }
-                    
-                    lldb::addr_t range_size = 
end_entry.range.GetBaseAddress().GetFileAddress()
-                                              - 
range.GetBaseAddress().GetFileAddress();
-                    range.SetByteSize(range_size);
+                }
+                else
+                {
+                    range = sc.line_entry.range;
                 }
                 
                 new_plan_sp = thread->QueueThreadPlanForStepInRange 
(abort_other_plans,
-                                                                range,
-                                                                
frame->GetSymbolContext(eSymbolContextEverything),
-                                                                
m_options.m_step_in_target.c_str(),
-                                                                
stop_other_threads,
-                                                                
m_options.m_step_in_avoid_no_debug,
-                                                                
m_options.m_step_out_avoid_no_debug);
+                                                                     range,
+                                                                     
frame->GetSymbolContext(eSymbolContextEverything),
+                                                                     
m_options.m_step_in_target.c_str(),
+                                                                     
stop_other_threads,
+                                                                     
m_options.m_step_in_avoid_no_debug,
+                                                                     
m_options.m_step_out_avoid_no_debug);
                 
                 if (new_plan_sp && !m_options.m_avoid_regexp.empty())
                 {

Modified: lldb/trunk/source/Symbol/SymbolContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=260772&r1=260771&r2=260772&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolContext.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolContext.cpp Fri Feb 12 18:31:47 2016
@@ -857,6 +857,73 @@ SymbolContext::GetFunctionStartLineEntry
     return LineEntry();
 }
 
+bool
+SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line, 
AddressRange &range, Error &error)
+{
+    if (!line_entry.IsValid())
+    {
+        error.SetErrorString("Symbol context has no line table.");
+        return false;
+    }
+    
+    range = line_entry.range;
+    if (line_entry.line > end_line)
+    {
+        error.SetErrorStringWithFormat("end line option %d must be after the 
current line: %d",
+                                     end_line,
+                                     line_entry.line);
+        return false;
+    }
+
+    uint32_t line_index = 0;
+    bool found = false;
+    while (1)
+    {
+        LineEntry this_line;
+        line_index = comp_unit->FindLineEntry(line_index, line_entry.line, 
nullptr, false, &this_line);
+        if (line_index == UINT32_MAX)
+            break;
+        if (LineEntry::Compare(this_line, line_entry) == 0)
+        {
+            found = true;
+            break;
+        }
+    }
+    
+    LineEntry end_entry;
+    if (!found)
+    {
+        // Can't find the index of the SymbolContext's line entry in the 
SymbolContext's CompUnit.
+        error.SetErrorString("Can't find the current line entry in the 
CompUnit - can't process "
+                                     "the end-line option");
+        return false;
+    }
+    
+    line_index = comp_unit->FindLineEntry(line_index, end_line, nullptr, 
false, &end_entry);
+    if (line_index == UINT32_MAX)
+    {
+        error.SetErrorStringWithFormat("could not find a line table entry 
corresponding "
+                                       "to end line number %d",
+                                       end_line);
+        return false;
+    }
+    
+    Block *func_block = GetFunctionBlock();
+    if (func_block && 
func_block->GetRangeIndexContainingAddress(end_entry.range.GetBaseAddress()) == 
UINT32_MAX)
+    {
+        error.SetErrorStringWithFormat("end line number %d is not contained 
within the current function.",
+                                     end_line);
+        return false;
+    }
+    
+    lldb::addr_t range_size = end_entry.range.GetBaseAddress().GetFileAddress()
+                              - range.GetBaseAddress().GetFileAddress();
+    range.SetByteSize(range_size);
+    return true;
+}
+
+
+
 //----------------------------------------------------------------------
 //
 //  SymbolContextSpecifier


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to