diff options
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/include/lldb/API/SBThread.h | 6 | ||||
-rw-r--r-- | lldb/include/lldb/Symbol/SymbolContext.h | 3 | ||||
-rw-r--r-- | lldb/scripts/interface/SBThread.i | 11 | ||||
-rw-r--r-- | lldb/source/API/SBThread.cpp | 23 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectThread.cpp | 75 | ||||
-rw-r--r-- | lldb/source/Symbol/SymbolContext.cpp | 67 |
6 files changed, 121 insertions, 64 deletions
diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h index 2c45fa8d512..f05febe526b 100644 --- a/lldb/include/lldb/API/SBThread.h +++ b/lldb/include/lldb/API/SBThread.h @@ -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 diff --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h index 9cb709d2401..f0e8e3590a8 100644 --- a/lldb/include/lldb/Symbol/SymbolContext.h +++ b/lldb/include/lldb/Symbol/SymbolContext.h @@ -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, diff --git a/lldb/scripts/interface/SBThread.i b/lldb/scripts/interface/SBThread.i index f2b27565d48..50160590ad5 100644 --- a/lldb/scripts/interface/SBThread.i +++ b/lldb/scripts/interface/SBThread.i @@ -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 (); diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 2f3887ebce3..3d2f15d1f3a 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -774,6 +774,13 @@ SBThread::StepInto (lldb::RunMode stop_other_threads) 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_name, lldb::RunMode stop_other_threads) 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_name, lldb::RunMode stop_other_threads) 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()); } } diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 123ebbb1546..4ff59d3bf96 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -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()) { diff --git a/lldb/source/Symbol/SymbolContext.cpp b/lldb/source/Symbol/SymbolContext.cpp index 54db5e090b8..4a398420737 100644 --- a/lldb/source/Symbol/SymbolContext.cpp +++ b/lldb/source/Symbol/SymbolContext.cpp @@ -857,6 +857,73 @@ SymbolContext::GetFunctionStartLineEntry () const 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 |