diff options
author | Jim Ingham <jingham@apple.com> | 2011-09-08 22:13:49 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2011-09-08 22:13:49 +0000 |
commit | b7f6b2fa3c4a5162223850b28e63b5193159ae6d (patch) | |
tree | f51b13eb1e25bdab179c6b60e4caaf5b104b6136 /lldb/source/Commands/CommandObjectSource.cpp | |
parent | 7db8d697cf094ac586531d5500892e94a49ec537 (diff) | |
download | llvm-b7f6b2fa3c4a5162223850b28e63b5193159ae6d.zip llvm-b7f6b2fa3c4a5162223850b28e63b5193159ae6d.tar.gz llvm-b7f6b2fa3c4a5162223850b28e63b5193159ae6d.tar.bz2 |
Move the SourceManager from the Debugger to the Target. That way it can store the per-Target default Source File & Line.
Set the default Source File & line to main (if it can be found.) at startup. Selecting the current thread & or frame resets
the current source file & line, and "source list" as well as the breakpoint command "break set -l <NUM>" will use the
current source file.
llvm-svn: 139323
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); } |