diff options
author | Greg Clayton <gclayton@apple.com> | 2014-03-07 00:53:24 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2014-03-07 00:53:24 +0000 |
commit | f6913cd7af4c4a3ba6dfb0295f32a66a1413c9e2 (patch) | |
tree | 69741512c24182fbd6d82c0b5768066c44cf4507 /lldb/source | |
parent | b9a0265cc164cd42ce2e5657fd9c57bb3b6bc7d3 (diff) | |
download | bcm5719-llvm-f6913cd7af4c4a3ba6dfb0295f32a66a1413c9e2.tar.gz bcm5719-llvm-f6913cd7af4c4a3ba6dfb0295f32a66a1413c9e2.zip |
Allow line numbers to be shown in multi-line expressions.
llvm-svn: 203185
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/Commands/CommandObjectCommands.cpp | 5 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 1 | ||||
-rw-r--r-- | lldb/source/Core/IOHandler.cpp | 23 | ||||
-rw-r--r-- | lldb/source/Host/common/Editline.cpp | 1 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 4 |
5 files changed, 32 insertions, 2 deletions
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 7bfdec094d6..e3e113aac23 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1034,9 +1034,10 @@ protected: Debugger &debugger = m_interpreter.GetDebugger(); const bool multiple_lines = true; // Get multiple lines IOHandlerSP io_handler_sp (new IOHandlerEditline (debugger, - "lldb", // Name of input reader for history - "\033[K> ", // Prompt and clear line + "lldb", // Name of input reader for history + "\033[K> ", // Prompt and clear line multiple_lines, + 0, // Don't show line numbers *this)); if (io_handler_sp) diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index c772a2e5891..7dacaa73cd1 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -428,6 +428,7 @@ CommandObjectExpression::DoExecute "lldb-expr", // Name of input reader for history NULL, // No prompt multiple_lines, + 1, // Show line numbers starting at 1 *this)); StreamFileSP output_sp(io_handler_sp->GetOutputStreamFile()); diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp index 26039375105..3bedb713c42 100644 --- a/lldb/source/Core/IOHandler.cpp +++ b/lldb/source/Core/IOHandler.cpp @@ -157,6 +157,7 @@ IOHandlerConfirm::IOHandlerConfirm (Debugger &debugger, NULL, // NULL editline_name means no history loaded/saved NULL, false, // Multi-line + 0, *this), m_default_response (default_response), m_user_response (default_response) @@ -311,6 +312,7 @@ IOHandlerEditline::IOHandlerEditline (Debugger &debugger, const char *editline_name, // Used for saving history files const char *prompt, bool multi_line, + uint32_t line_number_start, IOHandlerDelegate &delegate) : IOHandlerEditline(debugger, StreamFileSP(), // Inherit input from top input reader @@ -320,6 +322,7 @@ IOHandlerEditline::IOHandlerEditline (Debugger &debugger, editline_name, // Used for saving history files prompt, multi_line, + line_number_start, delegate) { } @@ -332,11 +335,13 @@ IOHandlerEditline::IOHandlerEditline (Debugger &debugger, const char *editline_name, // Used for saving history files const char *prompt, bool multi_line, + uint32_t line_number_start, IOHandlerDelegate &delegate) : IOHandler (debugger, input_sp, output_sp, error_sp, flags), m_editline_ap (), m_delegate (delegate), m_prompt (), + m_base_line_number (line_number_start), m_multi_line (multi_line) { SetPrompt(prompt); @@ -356,6 +361,8 @@ IOHandlerEditline::IOHandlerEditline (Debugger &debugger, GetInputFILE (), GetOutputFILE (), GetErrorFILE ())); + if (m_base_line_number > 0) + m_editline_ap->ShowLineNumbers(true, m_base_line_number); m_editline_ap->SetLineCompleteCallback (LineCompletedCallback, this); m_editline_ap->SetAutoCompleteCallback (AutoCompleteCallback, this); } @@ -491,6 +498,14 @@ IOHandlerEditline::SetPrompt (const char *p) return true; } +void +IOHandlerEditline::SetBaseLineNumber (uint32_t line) +{ + m_base_line_number = line; + if (m_editline_ap) + m_editline_ap->ShowLineNumbers (true, line); + +} bool IOHandlerEditline::GetLines (StringList &lines) { @@ -506,7 +521,15 @@ IOHandlerEditline::GetLines (StringList &lines) while (lines_status == LineStatus::Success) { + // Show line numbers if we are asked to std::string line; + if (m_base_line_number > 0 && GetIsInteractive()) + { + FILE *out = GetOutputFILE(); + if (out) + ::fprintf(out, "%u", m_base_line_number + (uint32_t)lines.GetSize()); + } + if (GetLine(line)) { lines.AppendString(line); diff --git a/lldb/source/Host/common/Editline.cpp b/lldb/source/Host/common/Editline.cpp index 9f96ce15f00..da08d0e3ee9 100644 --- a/lldb/source/Host/common/Editline.cpp +++ b/lldb/source/Host/common/Editline.cpp @@ -42,6 +42,7 @@ Editline::Editline (const char *prog, // prog can't be NULL m_line_complete_callback (NULL), m_line_complete_callback_baton (NULL), m_lines_command (Command::None), + m_line_offset (0), m_lines_curr_line (0), m_lines_max_line (0), m_prompt_with_line_numbers (false), diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 7a563b7c122..832ccbb06f3 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2663,6 +2663,7 @@ CommandInterpreter::HandleCommandsFromFile (FileSpec &cmd_file, NULL, // Pass in NULL for "editline_name" so no history is saved, or written debugger.GetPrompt(), false, // Not multi-line + 0, *this)); const bool old_async_execution = debugger.GetAsyncExecution(); @@ -3052,6 +3053,7 @@ CommandInterpreter::GetLLDBCommandsFromIOHandler (const char *prompt, "lldb", // Name of input reader for history prompt, // Prompt true, // Get multiple lines + 0, // Don't show line numbers delegate)); // IOHandlerDelegate if (io_handler_sp) @@ -3077,6 +3079,7 @@ CommandInterpreter::GetPythonCommandsFromIOHandler (const char *prompt, "lldb-python", // Name of input reader for history prompt, // Prompt true, // Get multiple lines + 0, // Don't show line numbers delegate)); // IOHandlerDelegate if (io_handler_sp) @@ -3110,6 +3113,7 @@ CommandInterpreter::RunCommandInterpreter(bool auto_handle_events, "lldb", m_debugger.GetPrompt(), multiple_lines, + 0, // Don't show line numbers *this)); m_debugger.PushIOHandler(m_command_io_handler_sp); |