From a701509229f658eac7c10bd6aa54cf6ed5b5011d Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Sat, 18 Sep 2010 01:14:36 +0000 Subject: 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 --- lldb/source/Commands/CommandObjectSource.cpp | 61 ++++++++++++++-------------- 1 file changed, 31 insertions(+), 30 deletions(-) (limited to 'lldb/source/Commands/CommandObjectSource.cpp') diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 996eb79fc1c..0ca222d772c 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 []") + CommandObjectSourceInfo(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "source info", + "Display information about the source lines from the current executable's debug info.", + "source info []") { } @@ -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 [] []") + CommandObjectSourceList(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "source list", + "Display source code (as specified) based on the current executable's debug info.", + "source list [] []") { } @@ -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 []") { - 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 () -- cgit v1.2.3