aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectSource.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-09-18 01:14:36 +0000
committerGreg Clayton <gclayton@apple.com>2010-09-18 01:14:36 +0000
commita701509229f658eac7c10bd6aa54cf6ed5b5011d (patch)
treeb38ff5cfb3fd466e5c7f89cea9bd9fa7d89eed16 /lldb/source/Commands/CommandObjectSource.cpp
parent9a587aaaa9e7bed09477c3c8d51d8f44dfd99158 (diff)
downloadllvm-a701509229f658eac7c10bd6aa54cf6ed5b5011d.zip
llvm-a701509229f658eac7c10bd6aa54cf6ed5b5011d.tar.gz
llvm-a701509229f658eac7c10bd6aa54cf6ed5b5011d.tar.bz2
Fixed the way set/show variables were being accessed to being natively
accessed by the objects that own the settings. The previous approach wasn't very usable and made for a lot of unnecessary code just to access variables that were already owned by the objects. While I fixed those things, I saw that CommandObject objects should really have a reference to their command interpreter so they can access the terminal with if they want to output usaage. Fixed up all CommandObjects to take an interpreter and cleaned up the API to not need the interpreter to be passed in. Fixed the disassemble command to output the usage if no options are passed down and arguments are passed (all disassebmle variants take options, there are no "args only"). llvm-svn: 114252
Diffstat (limited to 'lldb/source/Commands/CommandObjectSource.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectSource.cpp61
1 files changed, 31 insertions, 30 deletions
diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp
index 996eb79..0ca222d 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -96,10 +96,11 @@ class CommandObjectSourceInfo : public CommandObject
};
public:
- CommandObjectSourceInfo() :
- CommandObject ("source info",
- "Display information about the source lines from the current executable's debug info.",
- "source info [<cmd-options>]")
+ CommandObjectSourceInfo(CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "source info",
+ "Display information about the source lines from the current executable's debug info.",
+ "source info [<cmd-options>]")
{
}
@@ -118,7 +119,6 @@ public:
bool
Execute
(
- CommandInterpreter &interpreter,
Args& args,
CommandReturnObject &result
)
@@ -227,10 +227,11 @@ class CommandObjectSourceList : public CommandObject
};
public:
- CommandObjectSourceList() :
- CommandObject ("source list",
- "Display source code (as specified) based on the current executable's debug info.",
- "source list [<cmd-options>] [<filename>]")
+ CommandObjectSourceList(CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "source list",
+ "Display source code (as specified) based on the current executable's debug info.",
+ "source list [<cmd-options>] [<filename>]")
{
}
@@ -249,7 +250,6 @@ public:
bool
Execute
(
- CommandInterpreter &interpreter,
Args& args,
CommandReturnObject &result
)
@@ -262,12 +262,12 @@ public:
result.SetStatus (eReturnStatusFailed);
}
- ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext());
+ ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext());
if (!m_options.symbol_name.empty())
{
// Displaying the source for a symbol:
- Target *target = interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target == NULL)
{
result.AppendError ("invalid target, set executable file using 'file' command");
@@ -400,12 +400,12 @@ public:
char path_buf[PATH_MAX+1];
start_file.GetPath(path_buf, PATH_MAX);
result.AppendMessageWithFormat("File: %s.\n", path_buf);
- interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (start_file,
- line_no,
- 0,
- m_options.num_lines,
- "",
- &result.GetOutputStream());
+ m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (start_file,
+ line_no,
+ 0,
+ m_options.num_lines,
+ "",
+ &result.GetOutputStream());
result.SetStatus (eReturnStatusSuccessFinishResult);
return true;
@@ -419,14 +419,14 @@ public:
// more likely because you typed it once, then typed it again
if (m_options.start_line == 0)
{
- if (interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream()))
+ if (m_interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream()))
{
result.SetStatus (eReturnStatusSuccessFinishResult);
}
}
else
{
- if (interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile(
+ if (m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile(
m_options.start_line, // Line to display
0, // Lines before line to display
m_options.num_lines, // Lines after line to display
@@ -441,7 +441,7 @@ public:
else
{
const char *filename = m_options.file_name.c_str();
- Target *target = interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (target == NULL)
{
result.AppendError ("invalid target, set executable file using 'file' command");
@@ -524,12 +524,12 @@ public:
{
if (sc.comp_unit)
{
- interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit,
- m_options.start_line,
- 0,
- m_options.num_lines,
- "",
- &result.GetOutputStream());
+ m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit,
+ m_options.start_line,
+ 0,
+ m_options.num_lines,
+ "",
+ &result.GetOutputStream());
result.SetStatus (eReturnStatusSuccessFinishResult);
}
@@ -574,12 +574,13 @@ CommandObjectSourceList::CommandOptions::g_option_table[] =
//-------------------------------------------------------------------------
CommandObjectMultiwordSource::CommandObjectMultiwordSource (CommandInterpreter &interpreter) :
- CommandObjectMultiword ("source",
+ CommandObjectMultiword (interpreter,
+ "source",
"A set of commands for accessing source file information",
"source <subcommand> [<subcommand-options>]")
{
- LoadSubCommand (interpreter, "info", CommandObjectSP (new CommandObjectSourceInfo ()));
- LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectSourceList ()));
+ LoadSubCommand ("info", CommandObjectSP (new CommandObjectSourceInfo (interpreter)));
+ LoadSubCommand ("list", CommandObjectSP (new CommandObjectSourceList (interpreter)));
}
CommandObjectMultiwordSource::~CommandObjectMultiwordSource ()