diff options
Diffstat (limited to 'lldb/source/Commands/CommandObjectSource.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectSource.cpp | 75 |
1 files changed, 35 insertions, 40 deletions
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index d534338e..e6b98fa 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -280,18 +280,23 @@ public: } ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); - + Target *target = NULL; + + if (exe_ctx.target) + target = exe_ctx.target; + else + target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + + if (target == NULL) + { + result.AppendError ("invalid target, create a debug target using the 'target create' command"); + result.SetStatus (eReturnStatusFailed); + return false; + } + if (!m_options.symbol_name.empty()) { // Displaying the source for a symbol: - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - if (target == NULL) - { - result.AppendError ("invalid target, create a debug target using the 'target create' command"); - result.SetStatus (eReturnStatusFailed); - return false; - } - SymbolContextList sc_list; ConstString name(m_options.symbol_name.c_str()); bool include_symbols = false; @@ -418,7 +423,7 @@ public: char path_buf[PATH_MAX]; start_file.GetPath(path_buf, sizeof(path_buf)); - if (m_options.show_bp_locs && exe_ctx.target) + if (m_options.show_bp_locs) { const bool show_inlines = true; m_breakpoint_locations.Reset (start_file, 0, show_inlines); @@ -429,14 +434,13 @@ public: m_breakpoint_locations.Clear(); result.AppendMessageWithFormat("File: %s.\n", path_buf); - m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (target, - start_file, - line_no, - 0, - m_options.num_lines, - "", - &result.GetOutputStream(), - GetBreakpointLocations ()); + target->GetSourceManager().DisplaySourceLinesWithLineNumbers (start_file, + line_no, + 0, + m_options.num_lines, + "", + &result.GetOutputStream(), + GetBreakpointLocations ()); result.SetStatus (eReturnStatusSuccessFinishResult); return true; @@ -458,21 +462,21 @@ public: } else { - if (m_options.show_bp_locs && exe_ctx.target) + if (m_options.show_bp_locs) { - SourceManager::FileSP last_file_sp (m_interpreter.GetDebugger().GetSourceManager().GetLastFile ()); + SourceManager::FileSP last_file_sp (target->GetSourceManager().GetLastFile ()); if (last_file_sp) { const bool show_inlines = true; m_breakpoint_locations.Reset (last_file_sp->GetFileSpec(), 0, show_inlines); - SearchFilter target_search_filter (exe_ctx.target->GetSP()); + SearchFilter target_search_filter (target->GetSP()); target_search_filter.Search (m_breakpoint_locations); } } else m_breakpoint_locations.Clear(); - if (m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile( + if (target->GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile( m_options.start_line, // Line to display 0, // Lines before line to display m_options.num_lines, // Lines after line to display @@ -488,14 +492,6 @@ public: else { const char *filename = m_options.file_name.c_str(); - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - if (target == NULL) - { - result.AppendError ("invalid target, create a debug target using the 'target create' command"); - result.SetStatus (eReturnStatusFailed); - return false; - } - bool check_inlines = false; SymbolContextList sc_list; @@ -571,24 +567,23 @@ public: { if (sc.comp_unit) { - if (m_options.show_bp_locs && exe_ctx.target) + if (m_options.show_bp_locs) { const bool show_inlines = true; m_breakpoint_locations.Reset (*sc.comp_unit, 0, show_inlines); - SearchFilter target_search_filter (exe_ctx.target->GetSP()); + SearchFilter target_search_filter (target->GetSP()); target_search_filter.Search (m_breakpoint_locations); } else m_breakpoint_locations.Clear(); - m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (target, - sc.comp_unit, - m_options.start_line, - 0, - m_options.num_lines, - "", - &result.GetOutputStream(), - GetBreakpointLocations ()); + target->GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit, + m_options.start_line, + 0, + m_options.num_lines, + "", + &result.GetOutputStream(), + GetBreakpointLocations ()); result.SetStatus (eReturnStatusSuccessFinishResult); } |