Allow line numbers to be shown in multi-line expressions.
llvm-svn: 203185
This commit is contained in:
parent
b9a0265cc1
commit
f6913cd7af
|
@ -380,6 +380,7 @@ namespace lldb_private {
|
||||||
const char *editline_name, // Used for saving history files
|
const char *editline_name, // Used for saving history files
|
||||||
const char *prompt,
|
const char *prompt,
|
||||||
bool multi_line,
|
bool multi_line,
|
||||||
|
uint32_t line_number_start, // If non-zero show line numbers starting at 'line_number_start'
|
||||||
IOHandlerDelegate &delegate);
|
IOHandlerDelegate &delegate);
|
||||||
|
|
||||||
IOHandlerEditline (Debugger &debugger,
|
IOHandlerEditline (Debugger &debugger,
|
||||||
|
@ -390,6 +391,7 @@ namespace lldb_private {
|
||||||
const char *editline_name, // Used for saving history files
|
const char *editline_name, // Used for saving history files
|
||||||
const char *prompt,
|
const char *prompt,
|
||||||
bool multi_line,
|
bool multi_line,
|
||||||
|
uint32_t line_number_start, // If non-zero show line numbers starting at 'line_number_start'
|
||||||
IOHandlerDelegate &delegate);
|
IOHandlerDelegate &delegate);
|
||||||
|
|
||||||
virtual
|
virtual
|
||||||
|
@ -438,6 +440,9 @@ namespace lldb_private {
|
||||||
bool
|
bool
|
||||||
GetLines (StringList &lines);
|
GetLines (StringList &lines);
|
||||||
|
|
||||||
|
void
|
||||||
|
SetBaseLineNumber (uint32_t line);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static LineStatus
|
static LineStatus
|
||||||
LineCompletedCallback (Editline *editline,
|
LineCompletedCallback (Editline *editline,
|
||||||
|
@ -458,6 +463,7 @@ namespace lldb_private {
|
||||||
std::unique_ptr<Editline> m_editline_ap;
|
std::unique_ptr<Editline> m_editline_ap;
|
||||||
IOHandlerDelegate &m_delegate;
|
IOHandlerDelegate &m_delegate;
|
||||||
std::string m_prompt;
|
std::string m_prompt;
|
||||||
|
uint32_t m_base_line_number; // If non-zero, then show line numbers in prompt
|
||||||
bool m_multi_line;
|
bool m_multi_line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,13 @@ public:
|
||||||
void
|
void
|
||||||
SetPrompt (const char *p);
|
SetPrompt (const char *p);
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowLineNumbers (bool enable, uint32_t line_offset)
|
||||||
|
{
|
||||||
|
m_prompt_with_line_numbers = enable;
|
||||||
|
m_line_offset = line_offset;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Error
|
Error
|
||||||
|
@ -193,6 +200,7 @@ private:
|
||||||
LineCompletedCallbackType m_line_complete_callback;
|
LineCompletedCallbackType m_line_complete_callback;
|
||||||
void *m_line_complete_callback_baton;
|
void *m_line_complete_callback_baton;
|
||||||
Command m_lines_command;
|
Command m_lines_command;
|
||||||
|
uint32_t m_line_offset;
|
||||||
uint32_t m_lines_curr_line;
|
uint32_t m_lines_curr_line;
|
||||||
uint32_t m_lines_max_line;
|
uint32_t m_lines_max_line;
|
||||||
bool m_prompt_with_line_numbers;
|
bool m_prompt_with_line_numbers;
|
||||||
|
|
|
@ -1034,9 +1034,10 @@ protected:
|
||||||
Debugger &debugger = m_interpreter.GetDebugger();
|
Debugger &debugger = m_interpreter.GetDebugger();
|
||||||
const bool multiple_lines = true; // Get multiple lines
|
const bool multiple_lines = true; // Get multiple lines
|
||||||
IOHandlerSP io_handler_sp (new IOHandlerEditline (debugger,
|
IOHandlerSP io_handler_sp (new IOHandlerEditline (debugger,
|
||||||
"lldb", // Name of input reader for history
|
"lldb", // Name of input reader for history
|
||||||
"\033[K> ", // Prompt and clear line
|
"\033[K> ", // Prompt and clear line
|
||||||
multiple_lines,
|
multiple_lines,
|
||||||
|
0, // Don't show line numbers
|
||||||
*this));
|
*this));
|
||||||
|
|
||||||
if (io_handler_sp)
|
if (io_handler_sp)
|
||||||
|
|
|
@ -428,6 +428,7 @@ CommandObjectExpression::DoExecute
|
||||||
"lldb-expr", // Name of input reader for history
|
"lldb-expr", // Name of input reader for history
|
||||||
NULL, // No prompt
|
NULL, // No prompt
|
||||||
multiple_lines,
|
multiple_lines,
|
||||||
|
1, // Show line numbers starting at 1
|
||||||
*this));
|
*this));
|
||||||
|
|
||||||
StreamFileSP output_sp(io_handler_sp->GetOutputStreamFile());
|
StreamFileSP output_sp(io_handler_sp->GetOutputStreamFile());
|
||||||
|
|
|
@ -157,6 +157,7 @@ IOHandlerConfirm::IOHandlerConfirm (Debugger &debugger,
|
||||||
NULL, // NULL editline_name means no history loaded/saved
|
NULL, // NULL editline_name means no history loaded/saved
|
||||||
NULL,
|
NULL,
|
||||||
false, // Multi-line
|
false, // Multi-line
|
||||||
|
0,
|
||||||
*this),
|
*this),
|
||||||
m_default_response (default_response),
|
m_default_response (default_response),
|
||||||
m_user_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 *editline_name, // Used for saving history files
|
||||||
const char *prompt,
|
const char *prompt,
|
||||||
bool multi_line,
|
bool multi_line,
|
||||||
|
uint32_t line_number_start,
|
||||||
IOHandlerDelegate &delegate) :
|
IOHandlerDelegate &delegate) :
|
||||||
IOHandlerEditline(debugger,
|
IOHandlerEditline(debugger,
|
||||||
StreamFileSP(), // Inherit input from top input reader
|
StreamFileSP(), // Inherit input from top input reader
|
||||||
|
@ -320,6 +322,7 @@ IOHandlerEditline::IOHandlerEditline (Debugger &debugger,
|
||||||
editline_name, // Used for saving history files
|
editline_name, // Used for saving history files
|
||||||
prompt,
|
prompt,
|
||||||
multi_line,
|
multi_line,
|
||||||
|
line_number_start,
|
||||||
delegate)
|
delegate)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -332,11 +335,13 @@ IOHandlerEditline::IOHandlerEditline (Debugger &debugger,
|
||||||
const char *editline_name, // Used for saving history files
|
const char *editline_name, // Used for saving history files
|
||||||
const char *prompt,
|
const char *prompt,
|
||||||
bool multi_line,
|
bool multi_line,
|
||||||
|
uint32_t line_number_start,
|
||||||
IOHandlerDelegate &delegate) :
|
IOHandlerDelegate &delegate) :
|
||||||
IOHandler (debugger, input_sp, output_sp, error_sp, flags),
|
IOHandler (debugger, input_sp, output_sp, error_sp, flags),
|
||||||
m_editline_ap (),
|
m_editline_ap (),
|
||||||
m_delegate (delegate),
|
m_delegate (delegate),
|
||||||
m_prompt (),
|
m_prompt (),
|
||||||
|
m_base_line_number (line_number_start),
|
||||||
m_multi_line (multi_line)
|
m_multi_line (multi_line)
|
||||||
{
|
{
|
||||||
SetPrompt(prompt);
|
SetPrompt(prompt);
|
||||||
|
@ -356,6 +361,8 @@ IOHandlerEditline::IOHandlerEditline (Debugger &debugger,
|
||||||
GetInputFILE (),
|
GetInputFILE (),
|
||||||
GetOutputFILE (),
|
GetOutputFILE (),
|
||||||
GetErrorFILE ()));
|
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->SetLineCompleteCallback (LineCompletedCallback, this);
|
||||||
m_editline_ap->SetAutoCompleteCallback (AutoCompleteCallback, this);
|
m_editline_ap->SetAutoCompleteCallback (AutoCompleteCallback, this);
|
||||||
}
|
}
|
||||||
|
@ -491,6 +498,14 @@ IOHandlerEditline::SetPrompt (const char *p)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
IOHandlerEditline::SetBaseLineNumber (uint32_t line)
|
||||||
|
{
|
||||||
|
m_base_line_number = line;
|
||||||
|
if (m_editline_ap)
|
||||||
|
m_editline_ap->ShowLineNumbers (true, line);
|
||||||
|
|
||||||
|
}
|
||||||
bool
|
bool
|
||||||
IOHandlerEditline::GetLines (StringList &lines)
|
IOHandlerEditline::GetLines (StringList &lines)
|
||||||
{
|
{
|
||||||
|
@ -506,7 +521,15 @@ IOHandlerEditline::GetLines (StringList &lines)
|
||||||
|
|
||||||
while (lines_status == LineStatus::Success)
|
while (lines_status == LineStatus::Success)
|
||||||
{
|
{
|
||||||
|
// Show line numbers if we are asked to
|
||||||
std::string line;
|
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))
|
if (GetLine(line))
|
||||||
{
|
{
|
||||||
lines.AppendString(line);
|
lines.AppendString(line);
|
||||||
|
|
|
@ -42,6 +42,7 @@ Editline::Editline (const char *prog, // prog can't be NULL
|
||||||
m_line_complete_callback (NULL),
|
m_line_complete_callback (NULL),
|
||||||
m_line_complete_callback_baton (NULL),
|
m_line_complete_callback_baton (NULL),
|
||||||
m_lines_command (Command::None),
|
m_lines_command (Command::None),
|
||||||
|
m_line_offset (0),
|
||||||
m_lines_curr_line (0),
|
m_lines_curr_line (0),
|
||||||
m_lines_max_line (0),
|
m_lines_max_line (0),
|
||||||
m_prompt_with_line_numbers (false),
|
m_prompt_with_line_numbers (false),
|
||||||
|
|
|
@ -2663,6 +2663,7 @@ CommandInterpreter::HandleCommandsFromFile (FileSpec &cmd_file,
|
||||||
NULL, // Pass in NULL for "editline_name" so no history is saved, or written
|
NULL, // Pass in NULL for "editline_name" so no history is saved, or written
|
||||||
debugger.GetPrompt(),
|
debugger.GetPrompt(),
|
||||||
false, // Not multi-line
|
false, // Not multi-line
|
||||||
|
0,
|
||||||
*this));
|
*this));
|
||||||
const bool old_async_execution = debugger.GetAsyncExecution();
|
const bool old_async_execution = debugger.GetAsyncExecution();
|
||||||
|
|
||||||
|
@ -3052,6 +3053,7 @@ CommandInterpreter::GetLLDBCommandsFromIOHandler (const char *prompt,
|
||||||
"lldb", // Name of input reader for history
|
"lldb", // Name of input reader for history
|
||||||
prompt, // Prompt
|
prompt, // Prompt
|
||||||
true, // Get multiple lines
|
true, // Get multiple lines
|
||||||
|
0, // Don't show line numbers
|
||||||
delegate)); // IOHandlerDelegate
|
delegate)); // IOHandlerDelegate
|
||||||
|
|
||||||
if (io_handler_sp)
|
if (io_handler_sp)
|
||||||
|
@ -3077,6 +3079,7 @@ CommandInterpreter::GetPythonCommandsFromIOHandler (const char *prompt,
|
||||||
"lldb-python", // Name of input reader for history
|
"lldb-python", // Name of input reader for history
|
||||||
prompt, // Prompt
|
prompt, // Prompt
|
||||||
true, // Get multiple lines
|
true, // Get multiple lines
|
||||||
|
0, // Don't show line numbers
|
||||||
delegate)); // IOHandlerDelegate
|
delegate)); // IOHandlerDelegate
|
||||||
|
|
||||||
if (io_handler_sp)
|
if (io_handler_sp)
|
||||||
|
@ -3110,6 +3113,7 @@ CommandInterpreter::RunCommandInterpreter(bool auto_handle_events,
|
||||||
"lldb",
|
"lldb",
|
||||||
m_debugger.GetPrompt(),
|
m_debugger.GetPrompt(),
|
||||||
multiple_lines,
|
multiple_lines,
|
||||||
|
0, // Don't show line numbers
|
||||||
*this));
|
*this));
|
||||||
m_debugger.PushIOHandler(m_command_io_handler_sp);
|
m_debugger.PushIOHandler(m_command_io_handler_sp);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue