diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h index 2a52351aa411..1e1d0f2cb0bd 100644 --- a/lldb/include/lldb/Interpreter/CommandObject.h +++ b/lldb/include/lldb/Interpreter/CommandObject.h @@ -260,12 +260,13 @@ public: /// The complete current command line. /// /// @return - /// NULL if the command is not to be repeated. - /// Otherwise a pointer to the command to be repeated. + /// NULL if there is no special repeat command - it will use the current command line. + /// Otherwise a pointer to the command to be repeated. + /// If the returned string is the empty string, the command won't be repeated. //------------------------------------------------------------------ - virtual const char *GetRepeatCommand (const char *current_command_line) + virtual const char *GetRepeatCommand (Args ¤t_command_args, uint32_t index) { - return current_command_line; + return NULL; } protected: diff --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h index d32e7f9b9f12..3b8dad00d4e5 100644 --- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h +++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h @@ -67,6 +67,8 @@ public: bool &word_complete, StringList &matches); + virtual const char *GetRepeatCommand (Args ¤t_command_args, uint32_t index); + CommandObject::CommandMap m_subcommand_dict; }; diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 825d59625831..9619cdce4562 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -76,7 +76,6 @@ 26D5B07211B07550009A862E /* Stoppoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1610F1B83100F91463 /* Stoppoint.cpp */; }; 26D5B07311B07550009A862E /* StoppointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1710F1B83100F91463 /* StoppointLocation.cpp */; }; 26D5B07411B07550009A862E /* WatchpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1810F1B83100F91463 /* WatchpointLocation.cpp */; }; - 26D5B07511B07550009A862E /* CommandObjectAlias.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E2A10F1B84700F91463 /* CommandObjectAlias.cpp */; }; 26D5B07611B07550009A862E /* CommandObjectAppend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E2B10F1B84700F91463 /* CommandObjectAppend.cpp */; }; 26D5B07711B07550009A862E /* CommandObjectBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E2D10F1B84700F91463 /* CommandObjectBreakpoint.cpp */; }; 26D5B07811B07550009A862E /* CommandObjectDelete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E2F10F1B84700F91463 /* CommandObjectDelete.cpp */; }; @@ -96,7 +95,6 @@ 26D5B08611B07550009A862E /* CommandObjectSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4010F1B84700F91463 /* CommandObjectSettings.cpp */; }; 26D5B08711B07550009A862E /* CommandObjectShow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4110F1B84700F91463 /* CommandObjectShow.cpp */; }; 26D5B08811B07550009A862E /* CommandObjectSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4210F1B84700F91463 /* CommandObjectSource.cpp */; }; - 26D5B08911B07550009A862E /* CommandObjectSourceFile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4310F1B84700F91463 /* CommandObjectSourceFile.cpp */; }; 26D5B08B11B07550009A862E /* CommandObjectSyntax.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4510F1B84700F91463 /* CommandObjectSyntax.cpp */; }; 26D5B08C11B07550009A862E /* CommandObjectThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4610F1B84700F91463 /* CommandObjectThread.cpp */; }; 26D5B08D11B07550009A862E /* CommandObjectVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4810F1B84700F91463 /* CommandObjectVariable.cpp */; }; @@ -240,7 +238,6 @@ 26D5B11A11B07550009A862E /* SymbolFileDWARFDebugMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89DB10F57C5600BB2B04 /* SymbolFileDWARFDebugMap.cpp */; }; 26D5B11B11B07550009A862E /* SymbolFileSymtab.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89DE10F57C5600BB2B04 /* SymbolFileSymtab.cpp */; }; 26D5B11C11B07550009A862E /* SymbolVendorMacOSX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C89E210F57C5600BB2B04 /* SymbolVendorMacOSX.cpp */; }; - 26D5B11D11B07550009A862E /* CommandObjectUnalias.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A8B4EA310FD516400C68FF2 /* CommandObjectUnalias.cpp */; }; 26D5B11E11B07550009A862E /* ScriptInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */; }; 26D5B11F11B07550009A862E /* BreakpointResolverAddress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5310FE555900271C65 /* BreakpointResolverAddress.cpp */; }; 26D5B12011B07550009A862E /* BreakpointResolverFileLine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D0DD5410FE555900271C65 /* BreakpointResolverFileLine.cpp */; }; @@ -340,6 +337,8 @@ 49F1A74A11B338AE003ED505 /* ClangExpressionDeclMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F1A74911B338AE003ED505 /* ClangExpressionDeclMap.h */; }; 4C08CDE811C81EF8001610A8 /* ThreadSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C08CDE711C81EF8001610A8 /* ThreadSpec.cpp */; }; 4C08CDEC11C81F1E001610A8 /* ThreadSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C08CDEB11C81F1E001610A8 /* ThreadSpec.h */; }; + 4C5DBBC811E3FEC60035160F /* CommandObjectCommands.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */; }; + 4C5DBBC911E3FEC60035160F /* CommandObjectCommands.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */; }; 4CA9637B11B6E99A00780E28 /* CommandObjectApropos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */; }; 9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; }; @@ -594,7 +593,6 @@ 26BC7CFA10F1B71400F91463 /* Stoppoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stoppoint.h; path = include/lldb/Breakpoint/Stoppoint.h; sourceTree = ""; }; 26BC7CFB10F1B71400F91463 /* StoppointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StoppointLocation.h; path = include/lldb/Breakpoint/StoppointLocation.h; sourceTree = ""; }; 26BC7CFC10F1B71400F91463 /* WatchpointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WatchpointLocation.h; path = include/lldb/Breakpoint/WatchpointLocation.h; sourceTree = ""; }; - 26BC7D1110F1B76300F91463 /* CommandObjectAlias.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectAlias.h; path = source/Commands/CommandObjectAlias.h; sourceTree = ""; }; 26BC7D1210F1B76300F91463 /* CommandObjectAppend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectAppend.h; path = source/Commands/CommandObjectAppend.h; sourceTree = ""; }; 26BC7D1410F1B76300F91463 /* CommandObjectBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectBreakpoint.h; path = source/Commands/CommandObjectBreakpoint.h; sourceTree = ""; }; 26BC7D1610F1B76300F91463 /* CommandObjectDelete.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectDelete.h; path = source/Commands/CommandObjectDelete.h; sourceTree = ""; }; @@ -614,7 +612,6 @@ 26BC7D2710F1B76300F91463 /* CommandObjectSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSettings.h; path = source/Commands/CommandObjectSettings.h; sourceTree = ""; }; 26BC7D2810F1B76300F91463 /* CommandObjectShow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectShow.h; path = source/Commands/CommandObjectShow.h; sourceTree = ""; }; 26BC7D2910F1B76300F91463 /* CommandObjectSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSource.h; path = source/Commands/CommandObjectSource.h; sourceTree = ""; }; - 26BC7D2A10F1B76300F91463 /* CommandObjectSourceFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSourceFile.h; path = source/Commands/CommandObjectSourceFile.h; sourceTree = ""; }; 26BC7D2C10F1B76300F91463 /* CommandObjectSyntax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSyntax.h; path = source/Commands/CommandObjectSyntax.h; sourceTree = ""; }; 26BC7D2D10F1B76300F91463 /* CommandObjectThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectThread.h; path = source/Commands/CommandObjectThread.h; sourceTree = ""; }; 26BC7D2F10F1B76300F91463 /* CommandObjectVariable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectVariable.h; path = source/Commands/CommandObjectVariable.h; sourceTree = ""; }; @@ -712,7 +709,6 @@ 26BC7E1610F1B83100F91463 /* Stoppoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Stoppoint.cpp; path = source/Breakpoint/Stoppoint.cpp; sourceTree = ""; }; 26BC7E1710F1B83100F91463 /* StoppointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StoppointLocation.cpp; path = source/Breakpoint/StoppointLocation.cpp; sourceTree = ""; }; 26BC7E1810F1B83100F91463 /* WatchpointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WatchpointLocation.cpp; path = source/Breakpoint/WatchpointLocation.cpp; sourceTree = ""; }; - 26BC7E2A10F1B84700F91463 /* CommandObjectAlias.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectAlias.cpp; path = source/Commands/CommandObjectAlias.cpp; sourceTree = ""; }; 26BC7E2B10F1B84700F91463 /* CommandObjectAppend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectAppend.cpp; path = source/Commands/CommandObjectAppend.cpp; sourceTree = ""; }; 26BC7E2D10F1B84700F91463 /* CommandObjectBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectBreakpoint.cpp; path = source/Commands/CommandObjectBreakpoint.cpp; sourceTree = ""; }; 26BC7E2F10F1B84700F91463 /* CommandObjectDelete.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectDelete.cpp; path = source/Commands/CommandObjectDelete.cpp; sourceTree = ""; }; @@ -732,7 +728,6 @@ 26BC7E4010F1B84700F91463 /* CommandObjectSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSettings.cpp; path = source/Commands/CommandObjectSettings.cpp; sourceTree = ""; }; 26BC7E4110F1B84700F91463 /* CommandObjectShow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectShow.cpp; path = source/Commands/CommandObjectShow.cpp; sourceTree = ""; }; 26BC7E4210F1B84700F91463 /* CommandObjectSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSource.cpp; path = source/Commands/CommandObjectSource.cpp; sourceTree = ""; }; - 26BC7E4310F1B84700F91463 /* CommandObjectSourceFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSourceFile.cpp; path = source/Commands/CommandObjectSourceFile.cpp; sourceTree = ""; }; 26BC7E4510F1B84700F91463 /* CommandObjectSyntax.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSyntax.cpp; path = source/Commands/CommandObjectSyntax.cpp; sourceTree = ""; }; 26BC7E4610F1B84700F91463 /* CommandObjectThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectThread.cpp; path = source/Commands/CommandObjectThread.cpp; sourceTree = ""; }; 26BC7E4810F1B84700F91463 /* CommandObjectVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectVariable.cpp; path = source/Commands/CommandObjectVariable.cpp; sourceTree = ""; }; @@ -930,6 +925,8 @@ 4C43DF8A11069C3200E55CBF /* ThreadPlanStepOverRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanStepOverRange.cpp; path = source/Target/ThreadPlanStepOverRange.cpp; sourceTree = ""; }; 4C51FF1511A4C485007C962F /* ObjCTrampolineHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjCTrampolineHandler.h; sourceTree = ""; }; 4C51FF1611A4C486007C962F /* ObjCTrampolineHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjCTrampolineHandler.cpp; sourceTree = ""; }; + 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectCommands.cpp; path = source/Commands/CommandObjectCommands.cpp; sourceTree = ""; }; + 4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectCommands.h; path = source/Commands/CommandObjectCommands.h; sourceTree = ""; }; 4C98D3DA118FB96F00E575D0 /* ClangFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangFunction.cpp; path = source/Expression/ClangFunction.cpp; sourceTree = ""; }; 4C98D3DB118FB96F00E575D0 /* RecordingMemoryManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecordingMemoryManager.cpp; path = source/Expression/RecordingMemoryManager.cpp; sourceTree = ""; }; 4C98D3E0118FB98F00E575D0 /* ClangFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangFunction.h; path = include/lldb/Expression/ClangFunction.h; sourceTree = ""; }; @@ -991,8 +988,6 @@ 9A633FE7112DCE3C001A7E43 /* SBFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBFrame.cpp; path = source/API/SBFrame.cpp; sourceTree = ""; }; 9A633FE8112DCE3C001A7E43 /* SBFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBFrame.h; path = include/lldb/API/SBFrame.h; sourceTree = ""; }; 9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScriptInterpreter.cpp; path = source/Interpreter/ScriptInterpreter.cpp; sourceTree = ""; }; - 9A8B4EA210FD515000C68FF2 /* CommandObjectUnalias.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectUnalias.h; path = source/Commands/CommandObjectUnalias.h; sourceTree = ""; }; - 9A8B4EA310FD516400C68FF2 /* CommandObjectUnalias.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectUnalias.cpp; path = source/Commands/CommandObjectUnalias.cpp; sourceTree = ""; }; 9A9830F21125FC5800A56CB0 /* SBBroadcaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBBroadcaster.cpp; path = source/API/SBBroadcaster.cpp; sourceTree = ""; }; 9A9830F31125FC5800A56CB0 /* SBBroadcaster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBBroadcaster.h; path = include/lldb/API/SBBroadcaster.h; sourceTree = ""; }; 9A9830F41125FC5800A56CB0 /* SBCommandContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBCommandContext.cpp; path = source/API/SBCommandContext.cpp; sourceTree = ""; }; @@ -1753,8 +1748,6 @@ 26BC7D0D10F1B71D00F91463 /* Commands */ = { isa = PBXGroup; children = ( - 26BC7D1110F1B76300F91463 /* CommandObjectAlias.h */, - 26BC7E2A10F1B84700F91463 /* CommandObjectAlias.cpp */, 26BC7D1210F1B76300F91463 /* CommandObjectAppend.h */, 26BC7E2B10F1B84700F91463 /* CommandObjectAppend.cpp */, 4CA9637A11B6E99A00780E28 /* CommandObjectApropos.h */, @@ -1767,6 +1760,8 @@ 9A42976211861AA600FE05CD /* CommandObjectBreakpointCommand.cpp */, 4C98D3E5118FB9B100E575D0 /* CommandObjectCall.h */, 4C98D3E4118FB9B100E575D0 /* CommandObjectCall.cpp */, + 4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */, + 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */, 26BC7D1610F1B76300F91463 /* CommandObjectDelete.h */, 26BC7E2F10F1B84700F91463 /* CommandObjectDelete.cpp */, 26BC7D1710F1B76300F91463 /* CommandObjectDisassemble.h */, @@ -1805,16 +1800,12 @@ 26BC7E4110F1B84700F91463 /* CommandObjectShow.cpp */, 26BC7D2910F1B76300F91463 /* CommandObjectSource.h */, 26BC7E4210F1B84700F91463 /* CommandObjectSource.cpp */, - 26BC7D2A10F1B76300F91463 /* CommandObjectSourceFile.h */, - 26BC7E4310F1B84700F91463 /* CommandObjectSourceFile.cpp */, 26BC7D2C10F1B76300F91463 /* CommandObjectSyntax.h */, 26BC7E4510F1B84700F91463 /* CommandObjectSyntax.cpp */, 269416AE119A024800FF2715 /* CommandObjectTarget.h */, 269416AD119A024800FF2715 /* CommandObjectTarget.cpp */, 26BC7D2D10F1B76300F91463 /* CommandObjectThread.h */, 26BC7E4610F1B84700F91463 /* CommandObjectThread.cpp */, - 9A8B4EA210FD515000C68FF2 /* CommandObjectUnalias.h */, - 9A8B4EA310FD516400C68FF2 /* CommandObjectUnalias.cpp */, 26BC7D2F10F1B76300F91463 /* CommandObjectVariable.h */, 26BC7E4810F1B84700F91463 /* CommandObjectVariable.cpp */, ); @@ -2198,6 +2189,7 @@ 49A8A3A411D568BF00AD3B68 /* ClangResultSynthesizer.h in Headers */, 49DA743511DE6BB2006AEF7E /* IRToDWARF.h in Headers */, 49307AB211DEA4F20081F992 /* IRForTarget.h in Headers */, + 4C5DBBC911E3FEC60035160F /* CommandObjectCommands.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2380,7 +2372,6 @@ 26D5B07211B07550009A862E /* Stoppoint.cpp in Sources */, 26D5B07311B07550009A862E /* StoppointLocation.cpp in Sources */, 26D5B07411B07550009A862E /* WatchpointLocation.cpp in Sources */, - 26D5B07511B07550009A862E /* CommandObjectAlias.cpp in Sources */, 26D5B07611B07550009A862E /* CommandObjectAppend.cpp in Sources */, 26D5B07711B07550009A862E /* CommandObjectBreakpoint.cpp in Sources */, 26D5B07811B07550009A862E /* CommandObjectDelete.cpp in Sources */, @@ -2400,7 +2391,6 @@ 26D5B08611B07550009A862E /* CommandObjectSettings.cpp in Sources */, 26D5B08711B07550009A862E /* CommandObjectShow.cpp in Sources */, 26D5B08811B07550009A862E /* CommandObjectSource.cpp in Sources */, - 26D5B08911B07550009A862E /* CommandObjectSourceFile.cpp in Sources */, 26D5B08B11B07550009A862E /* CommandObjectSyntax.cpp in Sources */, 26D5B08C11B07550009A862E /* CommandObjectThread.cpp in Sources */, 26D5B08D11B07550009A862E /* CommandObjectVariable.cpp in Sources */, @@ -2544,7 +2534,6 @@ 26D5B11A11B07550009A862E /* SymbolFileDWARFDebugMap.cpp in Sources */, 26D5B11B11B07550009A862E /* SymbolFileSymtab.cpp in Sources */, 26D5B11C11B07550009A862E /* SymbolVendorMacOSX.cpp in Sources */, - 26D5B11D11B07550009A862E /* CommandObjectUnalias.cpp in Sources */, 26D5B11E11B07550009A862E /* ScriptInterpreter.cpp in Sources */, 26D5B11F11B07550009A862E /* BreakpointResolverAddress.cpp in Sources */, 26D5B12011B07550009A862E /* BreakpointResolverFileLine.cpp in Sources */, @@ -2649,6 +2638,7 @@ 49A8A3A011D568A300AD3B68 /* ClangResultSynthesizer.cpp in Sources */, 49DA743011DE6A5A006AEF7E /* IRToDWARF.cpp in Sources */, 49307AAE11DEA4D90081F992 /* IRForTarget.cpp in Sources */, + 4C5DBBC811E3FEC60035160F /* CommandObjectCommands.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/lldb/source/Commands/CommandObjectAlias.cpp b/lldb/source/Commands/CommandObjectAlias.cpp deleted file mode 100644 index 5c09a2aec0b0..000000000000 --- a/lldb/source/Commands/CommandObjectAlias.cpp +++ /dev/null @@ -1,229 +0,0 @@ -//===-- CommandObjectAlias.cpp ----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectAlias.h" - - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObjectMultiword.h" -#include "lldb/Interpreter/Args.h" -#include "lldb/Interpreter/Options.h" -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Interpreter/CommandInterpreter.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectAlias -//------------------------------------------------------------------------- - -CommandObjectAlias::CommandObjectAlias () : - CommandObject ("alias", - "Allows users to define their own debugger command abbreviations.", - "alias []") -{ - SetHelpLong( -"'alias' allows the user to create a short-cut or abbreviation for long \n\ -commands, multi-word commands, and commands that take particular options. \n\ -Below are some simple examples of how one might use the 'alias' command: \n\ -\n 'alias sc script' // Creates the abbreviation 'sc' for the 'script' \n\ - // command. \n\ - 'alias bp breakpoint' // Creates the abbreviation 'bp' for the 'breakpoint' \n\ - // command. Since breakpoint commands are two-word \n\ - // commands, the user will still need to enter the \n\ - // second word after 'bp', e.g. 'bp enable' or \n\ - // 'bp delete'. \n\ - 'alias bpi breakpoint list' // Creates the abbreviation 'bpi' for the \n\ - // two-word command 'breakpoint list'. \n\ -\nAn alias can include some options for the command, with the values either \n\ -filled in at the time the alias is created, or specified as positional \n\ -arguments, to be filled in when the alias is invoked. The following example \n\ -shows how to create aliases with options: \n\ -\n\ - 'alias bfl breakpoint set -f %1 -l %2' \n\ -\nThis creates the abbreviation 'bfl' (for break-file-line), with the -f and -l \n\ -options already part of the alias. So if the user wants to set a breakpoint \n\ -by file and line without explicitly having to use the -f and -l options, the \n\ -user can now use 'bfl' instead. The '%1' and '%2' are positional placeholders \n\ -for the actual arguments that will be passed when the alias command is used. \n\ -The number in the placeholder refers to the position/order the actual value \n\ -occupies when the alias is used. So all the occurrences of '%1' in the alias \n\ -will be replaced with the first argument, all the occurrences of '%2' in the \n\ -alias will be replaced with the second argument, and so on. This also allows \n\ -actual arguments to be used multiple times within an alias (see 'process \n\ -launch' example below). So in the 'bfl' case, the actual file value will be \n\ -filled in with the first argument following 'bfl' and the actual line number \n\ -value will be filled in with the second argument. The user would use this \n\ -alias as follows: \n\ -\n (dbg) alias bfl breakpoint set -f %1 -l %2 \n\ - <... some time later ...> \n\ - (dbg) bfl my-file.c 137 \n\ -\nThis would be the same as if the user had entered \n\ -'breakpoint set -f my-file.c -l 137'. \n\ -\nAnother example: \n\ -\n (dbg) alias pltty process launch -s -o %1 -e %1 \n\ - (dbg) pltty /dev/tty0 \n\ - // becomes 'process launch -s -o /dev/tty0 -e /dev/tty0' \n\ -\nIf the user always wanted to pass the same value to a particular option, the \n\ -alias could be defined with that value directly in the alias as a constant, \n\ -rather than using a positional placeholder: \n\ -\n alias bl3 breakpoint set -f %1 -l 3 // Always sets a breakpoint on line \n\ - // 3 of whatever file is indicated. \n"); - -} - -CommandObjectAlias::~CommandObjectAlias () -{ -} - - -bool -CommandObjectAlias::Execute -( - CommandInterpreter &interpreter, - Args& args, - CommandReturnObject &result -) -{ - const int argc = args.GetArgumentCount(); - - if (argc < 2) - { - result.AppendError ("'alias' requires at least two arguments"); - result.SetStatus (eReturnStatusFailed); - return false; - } - - const std::string alias_command = args.GetArgumentAtIndex(0); - const std::string actual_command = args.GetArgumentAtIndex(1); - - args.Shift(); // Shift the alias command word off the argument vector. - args.Shift(); // Shift the old command word off the argument vector. - - // Verify that the command is alias'able, and get the appropriate command object. - - if (interpreter.CommandExists (alias_command.c_str())) - { - result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n", - alias_command.c_str()); - result.SetStatus (eReturnStatusFailed); - } - else - { - CommandObjectSP command_obj_sp(interpreter.GetCommandSPExact (actual_command.c_str(), true)); - CommandObjectSP subcommand_obj_sp; - bool use_subcommand = false; - if (command_obj_sp.get()) - { - CommandObject *cmd_obj = command_obj_sp.get(); - CommandObject *sub_cmd_obj; - OptionArgVectorSP option_arg_vector_sp = OptionArgVectorSP (new OptionArgVector); - OptionArgVector *option_arg_vector = option_arg_vector_sp.get(); - - if (cmd_obj->IsMultiwordObject()) - { - if (argc >= 3) - { - const std::string sub_command = args.GetArgumentAtIndex(0); - assert (sub_command.length() != 0); - subcommand_obj_sp = - (((CommandObjectMultiword *) cmd_obj)->GetSubcommandSP (sub_command.c_str())); - if (subcommand_obj_sp.get()) - { - sub_cmd_obj = subcommand_obj_sp.get(); - use_subcommand = true; - args.Shift(); // Shift the sub_command word off the argument vector. - } - else - { - result.AppendErrorWithFormat ("Error occurred while attempting to look up command '%s %s'.\n", - alias_command.c_str(), sub_command.c_str()); - result.SetStatus (eReturnStatusFailed); - return false; - } - } - } - - // Verify & handle any options/arguments passed to the alias command - - if (args.GetArgumentCount () > 0) - { - if ((!use_subcommand && (cmd_obj->WantsRawCommandString())) - || (use_subcommand && (sub_cmd_obj->WantsRawCommandString()))) - { - result.AppendErrorWithFormat ("'%s' cannot be aliased with any options or arguments.\n", - (use_subcommand ? sub_cmd_obj->GetCommandName() - : cmd_obj->GetCommandName())); - result.SetStatus (eReturnStatusFailed); - return false; - } - - // options or arguments have been passed to the alias command, and must be verified & processed here. - if ((!use_subcommand && (cmd_obj->GetOptions() != NULL)) - || (use_subcommand && (sub_cmd_obj->GetOptions() != NULL))) - { - Options *options; - if (use_subcommand) - options = sub_cmd_obj->GetOptions(); - else - options = cmd_obj->GetOptions(); - options->ResetOptionValues (); - args.Unshift ("dummy_arg"); - args.ParseAliasOptions (*options, result, option_arg_vector); - args.Shift (); - if (result.Succeeded()) - options->VerifyPartialOptions (result); - if (!result.Succeeded()) - return false; - } - else - { - for (int i = 0; i < args.GetArgumentCount(); ++i) - option_arg_vector->push_back (OptionArgPair ("", - std::string (args.GetArgumentAtIndex (i)))); - } - } - - // Create the alias. - - if (interpreter.AliasExists (alias_command.c_str()) - || interpreter.UserCommandExists (alias_command.c_str())) - { - OptionArgVectorSP tmp_option_arg_sp (interpreter.GetAliasOptions (alias_command.c_str())); - if (tmp_option_arg_sp.get()) - { - if (option_arg_vector->size() == 0) - interpreter.RemoveAliasOptions (alias_command.c_str()); - } - result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", alias_command.c_str()); - } - - if (use_subcommand) - interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp); - else - interpreter.AddAlias (alias_command.c_str(), command_obj_sp); - if (option_arg_vector->size() > 0) - interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - result.AppendErrorWithFormat ("'%s' is not an existing command.\n", actual_command.c_str()); - result.SetStatus (eReturnStatusFailed); - } - } - - return result.Succeeded(); -} - diff --git a/lldb/source/Commands/CommandObjectAlias.h b/lldb/source/Commands/CommandObjectAlias.h deleted file mode 100644 index da3334643de1..000000000000 --- a/lldb/source/Commands/CommandObjectAlias.h +++ /dev/null @@ -1,42 +0,0 @@ -//===-- CommandObjectAlias.h ------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_CommandObjectAlias_h_ -#define liblldb_CommandObjectAlias_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { - -//------------------------------------------------------------------------- -// CommandObjectAlias -//------------------------------------------------------------------------- - -class CommandObjectAlias : public CommandObject -{ -public: - - CommandObjectAlias (); - - virtual - ~CommandObjectAlias (); - - virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result); -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectAlias_h_ diff --git a/lldb/source/Commands/CommandObjectApropos.cpp b/lldb/source/Commands/CommandObjectApropos.cpp index 0f10b3ec780d..3987f452dfbc 100644 --- a/lldb/source/Commands/CommandObjectApropos.cpp +++ b/lldb/source/Commands/CommandObjectApropos.cpp @@ -18,7 +18,6 @@ #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Interpreter/CommandObjectMultiword.h" using namespace lldb; using namespace lldb_private; diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp new file mode 100644 index 000000000000..b2c4ec328087 --- /dev/null +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -0,0 +1,437 @@ +//===-- CommandObjectSource.cpp ---------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "CommandObjectCommands.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Interpreter/Args.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Interpreter/Options.h" + +using namespace lldb; +using namespace lldb_private; + +const char *k_space_characters = "\t\n\v\f\r "; + +//------------------------------------------------------------------------- +// CommandObjectCommandsSource +//------------------------------------------------------------------------- + +class CommandObjectCommandsSource : public CommandObject +{ +public: + CommandObjectCommandsSource() : + CommandObject ("commands source", + "Reads in debugger commands from the file and executes them.", + "command source ") + { + } + + ~CommandObjectCommandsSource () + { + } + + bool + Execute + ( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result + ) + { + const int argc = args.GetArgumentCount(); + if (argc == 1) + { + const char *filename = args.GetArgumentAtIndex(0); + bool success = true; + + result.AppendMessageWithFormat ("Executing commands in '%s'.\n", filename); + + FileSpec cmd_file (filename); + if (cmd_file.Exists()) + { + STLStringArray commands; + success = cmd_file.ReadFileLines (commands); + + STLStringArray::iterator pos = commands.begin(); + + // Trim out any empty lines or lines that start with the comment + // char '#' + while (pos != commands.end()) + { + bool remove_string = false; + size_t non_space = pos->find_first_not_of (k_space_characters); + if (non_space == std::string::npos) + remove_string = true; // Empty line + else if ((*pos)[non_space] == '#') + remove_string = true; // Comment line that starts with '#' + + if (remove_string) + pos = commands.erase(pos); + else + ++pos; + } + + if (commands.size() > 0) + { + const size_t num_commands = commands.size(); + size_t i; + for (i = 0; i []") + { + SetHelpLong( + "'alias' allows the user to create a short-cut or abbreviation for long \n\ + commands, multi-word commands, and commands that take particular options. \n\ + Below are some simple examples of how one might use the 'alias' command: \n\ + \n 'alias sc script' // Creates the abbreviation 'sc' for the 'script' \n\ + // command. \n\ + 'alias bp breakpoint' // Creates the abbreviation 'bp' for the 'breakpoint' \n\ + // command. Since breakpoint commands are two-word \n\ + // commands, the user will still need to enter the \n\ + // second word after 'bp', e.g. 'bp enable' or \n\ + // 'bp delete'. \n\ + 'alias bpi breakpoint list' // Creates the abbreviation 'bpi' for the \n\ + // two-word command 'breakpoint list'. \n\ + \nAn alias can include some options for the command, with the values either \n\ + filled in at the time the alias is created, or specified as positional \n\ + arguments, to be filled in when the alias is invoked. The following example \n\ + shows how to create aliases with options: \n\ + \n\ + 'alias bfl breakpoint set -f %1 -l %2' \n\ + \nThis creates the abbreviation 'bfl' (for break-file-line), with the -f and -l \n\ + options already part of the alias. So if the user wants to set a breakpoint \n\ + by file and line without explicitly having to use the -f and -l options, the \n\ + user can now use 'bfl' instead. The '%1' and '%2' are positional placeholders \n\ + for the actual arguments that will be passed when the alias command is used. \n\ + The number in the placeholder refers to the position/order the actual value \n\ + occupies when the alias is used. So all the occurrences of '%1' in the alias \n\ + will be replaced with the first argument, all the occurrences of '%2' in the \n\ + alias will be replaced with the second argument, and so on. This also allows \n\ + actual arguments to be used multiple times within an alias (see 'process \n\ + launch' example below). So in the 'bfl' case, the actual file value will be \n\ + filled in with the first argument following 'bfl' and the actual line number \n\ + value will be filled in with the second argument. The user would use this \n\ + alias as follows: \n\ + \n (dbg) alias bfl breakpoint set -f %1 -l %2 \n\ + <... some time later ...> \n\ + (dbg) bfl my-file.c 137 \n\ + \nThis would be the same as if the user had entered \n\ + 'breakpoint set -f my-file.c -l 137'. \n\ + \nAnother example: \n\ + \n (dbg) alias pltty process launch -s -o %1 -e %1 \n\ + (dbg) pltty /dev/tty0 \n\ + // becomes 'process launch -s -o /dev/tty0 -e /dev/tty0' \n\ + \nIf the user always wanted to pass the same value to a particular option, the \n\ + alias could be defined with that value directly in the alias as a constant, \n\ + rather than using a positional placeholder: \n\ + \n alias bl3 breakpoint set -f %1 -l 3 // Always sets a breakpoint on line \n\ + // 3 of whatever file is indicated. \n"); + + } + + ~CommandObjectCommandsAlias () + { + } + + + bool + Execute + ( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result + ) + { + const int argc = args.GetArgumentCount(); + + if (argc < 2) + { + result.AppendError ("'alias' requires at least two arguments"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + const std::string alias_command = args.GetArgumentAtIndex(0); + const std::string actual_command = args.GetArgumentAtIndex(1); + + args.Shift(); // Shift the alias command word off the argument vector. + args.Shift(); // Shift the old command word off the argument vector. + + // Verify that the command is alias'able, and get the appropriate command object. + + if (interpreter.CommandExists (alias_command.c_str())) + { + result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n", + alias_command.c_str()); + result.SetStatus (eReturnStatusFailed); + } + else + { + CommandObjectSP command_obj_sp(interpreter.GetCommandSPExact (actual_command.c_str(), true)); + CommandObjectSP subcommand_obj_sp; + bool use_subcommand = false; + if (command_obj_sp.get()) + { + CommandObject *cmd_obj = command_obj_sp.get(); + CommandObject *sub_cmd_obj; + OptionArgVectorSP option_arg_vector_sp = OptionArgVectorSP (new OptionArgVector); + OptionArgVector *option_arg_vector = option_arg_vector_sp.get(); + + if (cmd_obj->IsMultiwordObject()) + { + if (argc >= 3) + { + const std::string sub_command = args.GetArgumentAtIndex(0); + assert (sub_command.length() != 0); + subcommand_obj_sp = + (((CommandObjectMultiword *) cmd_obj)->GetSubcommandSP (sub_command.c_str())); + if (subcommand_obj_sp.get()) + { + sub_cmd_obj = subcommand_obj_sp.get(); + use_subcommand = true; + args.Shift(); // Shift the sub_command word off the argument vector. + } + else + { + result.AppendErrorWithFormat ("Error occurred while attempting to look up command '%s %s'.\n", + alias_command.c_str(), sub_command.c_str()); + result.SetStatus (eReturnStatusFailed); + return false; + } + } + } + + // Verify & handle any options/arguments passed to the alias command + + if (args.GetArgumentCount () > 0) + { + if ((!use_subcommand && (cmd_obj->WantsRawCommandString())) + || (use_subcommand && (sub_cmd_obj->WantsRawCommandString()))) + { + result.AppendErrorWithFormat ("'%s' cannot be aliased with any options or arguments.\n", + (use_subcommand ? sub_cmd_obj->GetCommandName() + : cmd_obj->GetCommandName())); + result.SetStatus (eReturnStatusFailed); + return false; + } + + // options or arguments have been passed to the alias command, and must be + // verified & processed here. + if ((!use_subcommand && (cmd_obj->GetOptions() != NULL)) + || (use_subcommand && (sub_cmd_obj->GetOptions() != NULL))) + { + Options *options; + if (use_subcommand) + options = sub_cmd_obj->GetOptions(); + else + options = cmd_obj->GetOptions(); + options->ResetOptionValues (); + args.Unshift ("dummy_arg"); + args.ParseAliasOptions (*options, result, option_arg_vector); + args.Shift (); + if (result.Succeeded()) + options->VerifyPartialOptions (result); + if (!result.Succeeded()) + return false; + } + else + { + for (int i = 0; i < args.GetArgumentCount(); ++i) + option_arg_vector->push_back (OptionArgPair ("", + std::string (args.GetArgumentAtIndex (i)))); + } + } + + // Create the alias. + + if (interpreter.AliasExists (alias_command.c_str()) + || interpreter.UserCommandExists (alias_command.c_str())) + { + OptionArgVectorSP tmp_option_arg_sp (interpreter.GetAliasOptions (alias_command.c_str())); + if (tmp_option_arg_sp.get()) + { + if (option_arg_vector->size() == 0) + interpreter.RemoveAliasOptions (alias_command.c_str()); + } + result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", + alias_command.c_str()); + } + + if (use_subcommand) + interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp); + else + interpreter.AddAlias (alias_command.c_str(), command_obj_sp); + if (option_arg_vector->size() > 0) + interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + result.AppendErrorWithFormat ("'%s' is not an existing command.\n", actual_command.c_str()); + result.SetStatus (eReturnStatusFailed); + } + } + + return result.Succeeded(); + } +}; + +#pragma mark CommandObjectCommandsUnalias +//------------------------------------------------------------------------- +// CommandObjectCommandsUnalias +//------------------------------------------------------------------------- + +class CommandObjectCommandsUnalias : public CommandObject +{ +public: + CommandObjectCommandsUnalias () : + CommandObject ("commands unalias", + "Allows the user to remove/delete a user-defined command abbreviation.", + "unalias ") + { + } + + ~CommandObjectCommandsUnalias() + { + } + + + bool + Execute + ( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result + ) + { + CommandObject::CommandMap::iterator pos; + CommandObject *cmd_obj; + + if (args.GetArgumentCount() != 0) + { + const char *command_name = args.GetArgumentAtIndex(0); + cmd_obj = interpreter.GetCommandObject(command_name); + if (cmd_obj) + { + if (interpreter.CommandExists (command_name)) + { + result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be removed.\n", + command_name); + result.SetStatus (eReturnStatusFailed); + } + else + { + + if (interpreter.RemoveAlias (command_name) == false) + { + if (interpreter.AliasExists (command_name)) + result.AppendErrorWithFormat ("Error occurred while attempting to unalias '%s'.\n", + command_name); + else + result.AppendErrorWithFormat ("'%s' is not an existing alias.\n", command_name); + result.SetStatus (eReturnStatusFailed); + } + else + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + } + else + { + result.AppendErrorWithFormat ("'%s' is not a known command.\nTry 'help' to see a " + "current list of commands.\n", + command_name); + result.SetStatus (eReturnStatusFailed); + } + } + else + { + result.AppendError ("must call 'unalias' with a valid alias"); + result.SetStatus (eReturnStatusFailed); + } + + return result.Succeeded(); + } +}; + +#pragma mark CommandObjectMultiwordCommands + +//------------------------------------------------------------------------- +// CommandObjectMultiwordCommands +//------------------------------------------------------------------------- + +CommandObjectMultiwordCommands::CommandObjectMultiwordCommands (CommandInterpreter &interpreter) : + CommandObjectMultiword ("commands", + "Commands for managing the command interpreters commands", + "commands []") +{ + LoadSubCommand (interpreter, "source", CommandObjectSP (new CommandObjectCommandsSource ())); + LoadSubCommand (interpreter, "alias", CommandObjectSP (new CommandObjectCommandsAlias ())); +} + +CommandObjectMultiwordCommands::~CommandObjectMultiwordCommands () +{ +} + diff --git a/lldb/source/Commands/CommandObjectUnalias.h b/lldb/source/Commands/CommandObjectCommands.h similarity index 55% rename from lldb/source/Commands/CommandObjectUnalias.h rename to lldb/source/Commands/CommandObjectCommands.h index 29ce9a408a43..8a56e8dae6ff 100644 --- a/lldb/source/Commands/CommandObjectUnalias.h +++ b/lldb/source/Commands/CommandObjectCommands.h @@ -1,4 +1,4 @@ -//===-- CommandObjectUnalias.h ----------------------------------*- C++ -*-===// +//===-- CommandObjectCommands.h -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,37 +7,34 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_CommandObjectUnalias_h_ -#define liblldb_CommandObjectUnalias_h_ +#ifndef liblldb_CommandObjectCommands_h_ +#define liblldb_CommandObjectCommands_h_ // C Includes // C++ Includes // Other libraries and framework includes // Project includes #include "lldb/Interpreter/CommandObject.h" +#include "lldb/Interpreter/CommandObjectMultiword.h" +#include "lldb/Core/STLUtils.h" namespace lldb_private { //------------------------------------------------------------------------- -// CommandObjectUnalias +// CommandObjectMultiwordCommands //------------------------------------------------------------------------- -class CommandObjectUnalias : public CommandObject +class CommandObjectMultiwordCommands : public CommandObjectMultiword { public: - CommandObjectUnalias (); + CommandObjectMultiwordCommands (CommandInterpreter &interpreter); virtual - ~CommandObjectUnalias (); - - virtual bool - Execute (CommandInterpreter &interpreter, - Args& args, - CommandReturnObject &result); + ~CommandObjectMultiwordCommands (); }; } // namespace lldb_private -#endif // liblldb_CommandObjectUnalias_h_ +#endif // liblldb_CommandObjectCommands_h_ diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index 88c3eedb048a..9e02d9eec322 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -287,3 +287,16 @@ CommandObjectMultiword::HandleCompletion } } +const char * +CommandObjectMultiword::GetRepeatCommand (Args ¤t_command_args, uint32_t index) +{ + if (current_command_args.GetArgumentCount() == 0) + return NULL; + index++; + CommandObject *sub_command_object = GetSubcommandObject (current_command_args.GetArgumentAtIndex(index)); + if (sub_command_object == NULL) + return NULL; + else + return sub_command_object->GetRepeatCommand(current_command_args, index); +} + diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 84deb2fc593a..694675116047 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -247,6 +247,12 @@ public: return result.Succeeded(); } + virtual const char *GetRepeatCommand (Args ¤t_command_args, uint32_t index) + { + // No repeat for "process launch"... + return ""; + } + protected: CommandOptions m_options; diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 9be4dccc8d90..2fd0f9c7b284 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -17,110 +17,347 @@ #include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Core/FileSpec.h" #include "lldb/Target/Process.h" +#include "lldb/Core/SourceManager.h" #include "lldb/Target/TargetList.h" +#include "lldb/Interpreter/CommandCompletions.h" +#include "lldb/Interpreter/Options.h" using namespace lldb; using namespace lldb_private; -const char *k_space_characters = "\t\n\v\f\r "; - //------------------------------------------------------------------------- -// CommandObjectSource +// CommandObjectSourceList //------------------------------------------------------------------------- -CommandObjectSource::CommandObjectSource() : - CommandObject ("source", - "Reads in debugger commands from the file and executes them.", - "source ") +class CommandObjectSourceInfo : public CommandObject { -} -CommandObjectSource::~CommandObjectSource () -{ -} - -bool -CommandObjectSource::Execute -( - CommandInterpreter &interpreter, - Args& args, - CommandReturnObject &result -) -{ - const int argc = args.GetArgumentCount(); - if (argc == 1) + class CommandOptions : public Options { - const char *filename = args.GetArgumentAtIndex(0); - bool success = true; - - result.AppendMessageWithFormat ("Executing commands in '%s'.\n", filename); - - FileSpec cmd_file (filename); - if (cmd_file.Exists()) + public: + CommandOptions () : + Options() { - STLStringArray commands; - success = cmd_file.ReadFileLines (commands); + } - STLStringArray::iterator pos = commands.begin(); + ~CommandOptions () + { + } - // Trim out any empty lines or lines that start with the comment - // char '#' - while (pos != commands.end()) + Error + SetOptionValue (int option_idx, const char *option_arg) + { + Error error; + const char short_option = g_option_table[option_idx].short_option; + switch (short_option) { - bool remove_string = false; - size_t non_space = pos->find_first_not_of (k_space_characters); - if (non_space == std::string::npos) - remove_string = true; // Empty line - else if ((*pos)[non_space] == '#') - remove_string = true; // Comment line that starts with '#' + case 'l': + start_line = Args::StringToUInt32 (option_arg, 0); + if (start_line == 0) + error.SetErrorStringWithFormat("Invalid line number: '%s'.\n", option_arg); + break; - if (remove_string) - pos = commands.erase(pos); - else - ++pos; + case 'f': + file_name = option_arg; + break; + + default: + error.SetErrorStringWithFormat("Unrecognized short option '%c'.\n", short_option); + break; } - if (commands.size() > 0) - { - const size_t num_commands = commands.size(); - size_t i; - for (i = 0; i]") + { + } + + ~CommandObjectSourceInfo () + { + } + + + Options * + GetOptions () + { + return &m_options; + } + + + bool + Execute + ( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result + ) + { + result.AppendError ("Not yet implemented"); + result.SetStatus (eReturnStatusFailed); + return false; + } +protected: + CommandOptions m_options; +}; + +lldb::OptionDefinition +CommandObjectSourceInfo::CommandOptions::g_option_table[] = +{ +{ LLDB_OPT_SET_1, false, "line", 'l', required_argument, NULL, 0, "", "The line number at which to start the display source."}, +{ LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "", "The file from which to display source."}, +{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +}; + +#pragma mark CommandObjectSourceList +//------------------------------------------------------------------------- +// CommandObjectSourceList +//------------------------------------------------------------------------- + +class CommandObjectSourceList : public CommandObject +{ + + class CommandOptions : public Options + { + public: + CommandOptions () : + Options() + { + } + + ~CommandOptions () + { + } + + Error + SetOptionValue (int option_idx, const char *option_arg) + { + Error error; + const char short_option = g_option_table[option_idx].short_option; + switch (short_option) + { + case 'l': + start_line = Args::StringToUInt32 (option_arg, 0); + if (start_line == 0) + error.SetErrorStringWithFormat("Invalid line number: '%s'.\n", option_arg); + break; + + case 'n': + num_lines = Args::StringToUInt32 (option_arg, 0); + if (num_lines == 0) + error.SetErrorStringWithFormat("Invalid line count: '%s'.\n", option_arg); + break; + + case 'f': + file_name = option_arg; + break; + + default: + error.SetErrorStringWithFormat("Unrecognized short option '%c'.\n", short_option); + break; + } + + return error; + } + + void + ResetOptionValues () + { + Options::ResetOptionValues(); + + file_spec.Clear(); + file_name.clear(); + start_line = 0; + num_lines = 10; + } + + const lldb::OptionDefinition* + GetDefinitions () + { + return g_option_table; + } + static lldb::OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + FileSpec file_spec; + std::string file_name; + uint32_t start_line; + uint32_t num_lines; + + }; + +public: + CommandObjectSourceList() : + CommandObject ("source list", + "Display source files from the current executable's debug info.", + "source list [] []") + { + } + + ~CommandObjectSourceList () + { + } + + + Options * + GetOptions () + { + return &m_options; + } + + + bool + Execute + ( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result + ) + { + const int argc = args.GetArgumentCount(); + + if (argc != 0) + { + result.AppendErrorWithFormat("'%s' takes no arguments, only flags.\n", GetCommandName()); + result.SetStatus (eReturnStatusFailed); + } + + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + if (m_options.file_name.empty()) + { + // Last valid source manager context, or the current frame if no + // valid last context in source manager. + // One little trick here, if you type the exact same list command twice in a row, it is + // more likely because you typed it once, then typed it again + if (m_options.start_line == 0) + { + if (interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream())) { - result.AppendErrorWithFormat("Aborting source of '%s' after command '%s' failed.\n", filename, commands[i].c_str()); result.SetStatus (eReturnStatusSuccessFinishResult); } - else + } + else + { + if (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 + "", // Don't mark "line" + &result.GetOutputStream())) { - success = true; - result.SetStatus (eReturnStatusFailed); + result.SetStatus (eReturnStatusSuccessFinishResult); } + } } else { - result.AppendErrorWithFormat ("File '%s' does not exist.\n", filename); - result.SetStatus (eReturnStatusFailed); - success = false; + const char *filename = m_options.file_name.c_str(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); + if (target == NULL) + { + result.AppendError ("invalid target, set executable file using 'file' command"); + result.SetStatus (eReturnStatusFailed); + return false; + } + + + bool check_inlines = false; + SymbolContextList sc_list; + size_t num_matches = target->GetImages().ResolveSymbolContextForFilePath (filename, + 0, + check_inlines, + eSymbolContextModule | eSymbolContextCompUnit, + sc_list); + if (num_matches > 0) + { + SymbolContext sc; + if (sc_list.GetContextAtIndex(0, sc)) + { + if (sc.comp_unit) + { + interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit, + m_options.start_line, // Line to display + 0, // Lines before line to display + m_options.num_lines, // Lines after line to display + "", // Don't mark "line" + &result.GetOutputStream()); + + result.SetStatus (eReturnStatusSuccessFinishResult); + + } + } + } } - if (success) - { - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } + return result.Succeeded(); } - else + + virtual const char *GetRepeatCommand (Args ¤t_command_args, uint32_t index) { - result.AppendErrorWithFormat("'%s' takes exactly one executable filename argument.\n", GetCommandName()); - result.SetStatus (eReturnStatusFailed); + return m_cmd_name.c_str(); } - return result.Succeeded(); +protected: + CommandOptions m_options; + +}; + +lldb::OptionDefinition +CommandObjectSourceList::CommandOptions::g_option_table[] = +{ +{ LLDB_OPT_SET_1, false, "line", 'l', required_argument, NULL, 0, "", "The line number at which to start the display source."}, +{ LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "", "The file from which to display source."}, +{ LLDB_OPT_SET_1, false, "count", 'n', required_argument, NULL, 0, "", "The number of source lines to display."}, +{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +}; + +#pragma mark CommandObjectMultiwordSource + +//------------------------------------------------------------------------- +// CommandObjectMultiwordSource +//------------------------------------------------------------------------- + +CommandObjectMultiwordSource::CommandObjectMultiwordSource (CommandInterpreter &interpreter) : + CommandObjectMultiword ("source", + "Commands for accessing source file information", + "source []") +{ + LoadSubCommand (interpreter, "info", CommandObjectSP (new CommandObjectSourceInfo ())); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectSourceList ())); } + +CommandObjectMultiwordSource::~CommandObjectMultiwordSource () +{ +} + diff --git a/lldb/source/Commands/CommandObjectSource.h b/lldb/source/Commands/CommandObjectSource.h index 8bc1ae58b3d0..0daef1385860 100644 --- a/lldb/source/Commands/CommandObjectSource.h +++ b/lldb/source/Commands/CommandObjectSource.h @@ -1,4 +1,4 @@ -//===-- CommandObjectSource.h -----------------------------------*- C++ -*-===// +//===-- CommandObjectSource.h.h -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,33 +15,26 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/CommandObject.h" +#include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Core/STLUtils.h" namespace lldb_private { //------------------------------------------------------------------------- -// CommandObjectSource +// CommandObjectMultiwordSource //------------------------------------------------------------------------- -class CommandObjectSource : public CommandObject +class CommandObjectMultiwordSource : public CommandObjectMultiword { public: - CommandObjectSource (); + CommandObjectMultiwordSource (CommandInterpreter &interpreter); virtual - ~CommandObjectSource (); - - STLStringArray & - GetCommands (); - - virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result); + ~CommandObjectMultiwordSource (); }; } // namespace lldb_private -#endif // liblldb_CommandObjectSource_h_ +#endif // liblldb_CommandObjectSource.h_h_ diff --git a/lldb/source/Commands/CommandObjectSourceFile.cpp b/lldb/source/Commands/CommandObjectSourceFile.cpp deleted file mode 100644 index cfb53e0ad345..000000000000 --- a/lldb/source/Commands/CommandObjectSourceFile.cpp +++ /dev/null @@ -1,205 +0,0 @@ -//===-- CommandObjectSourceFile.cpp -----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectSourceFile.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/Args.h" -#include "lldb/Core/Debugger.h" -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Target/Process.h" -#include "lldb/Core/SourceManager.h" -#include "lldb/Target/TargetList.h" -#include "lldb/Interpreter/CommandCompletions.h" - -using namespace lldb; -using namespace lldb_private; - -CommandObjectSourceFile::CommandOptions::CommandOptions () : - Options() -{ -} - -CommandObjectSourceFile::CommandOptions::~CommandOptions () -{ -} - -Error -CommandObjectSourceFile::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) -{ - Error error; - const char short_option = g_option_table[option_idx].short_option; - switch (short_option) - { - case 'l': - start_line = Args::StringToUInt32 (option_arg, 0); - if (start_line == 0) - error.SetErrorStringWithFormat("Invalid line number: '%s'.\n", option_arg); - break; - - case 'n': - num_lines = Args::StringToUInt32 (option_arg, 0); - if (num_lines == 0) - error.SetErrorStringWithFormat("Invalid line count: '%s'.\n", option_arg); - break; - - case 'f': - file_name = option_arg; - break; - - default: - error.SetErrorStringWithFormat("Unrecognized short option '%c'.\n", short_option); - break; - } - - return error; -} - -void -CommandObjectSourceFile::CommandOptions::ResetOptionValues () -{ - Options::ResetOptionValues(); - - file_spec.Clear(); - file_name.clear(); - start_line = 0; - num_lines = 10; -} - -const lldb::OptionDefinition* -CommandObjectSourceFile::CommandOptions::GetDefinitions () -{ - return g_option_table; -} - -lldb::OptionDefinition -CommandObjectSourceFile::CommandOptions::g_option_table[] = -{ -{ LLDB_OPT_SET_1, false, "line", 'l', required_argument, NULL, 0, "", "The line number at which to start the display source."}, -{ LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "", "The file from which to display source."}, -{ LLDB_OPT_SET_1, false, "count", 'n', required_argument, NULL, 0, "", "The number of source lines to display."}, -{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } -}; - - - -//------------------------------------------------------------------------- -// CommandObjectSourceFile -//------------------------------------------------------------------------- - -CommandObjectSourceFile::CommandObjectSourceFile() : - CommandObject ("source-file", - "Display source files from the current executable's debug info.", - "source-file [] []") -{ -} - -CommandObjectSourceFile::~CommandObjectSourceFile () -{ -} - - -Options * -CommandObjectSourceFile::GetOptions () -{ - return &m_options; -} - - -bool -CommandObjectSourceFile::Execute -( - CommandInterpreter &interpreter, - Args& args, - CommandReturnObject &result -) -{ - const int argc = args.GetArgumentCount(); - - if (argc != 0) - { - result.AppendErrorWithFormat("'%s' takes no arguments, only flags.\n", GetCommandName()); - result.SetStatus (eReturnStatusFailed); - } - - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); - if (m_options.file_name.empty()) - { - // Last valid source manager context, or the current frame if no - // valid last context in source manager. - // One little trick here, if you type the exact same list command twice in a row, it is - // more likely because you typed it once, then typed it again - if (m_options.start_line == 0) - { - if (interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream())) - { - result.SetStatus (eReturnStatusSuccessFinishResult); - } - } - else - { - if (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 - "", // Don't mark "line" - &result.GetOutputStream())) - { - result.SetStatus (eReturnStatusSuccessFinishResult); - } - - } - } - else - { - const char *filename = m_options.file_name.c_str(); - Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); - if (target == NULL) - { - result.AppendError ("invalid target, set executable file using 'file' command"); - result.SetStatus (eReturnStatusFailed); - return false; - } - - - bool check_inlines = false; - SymbolContextList sc_list; - size_t num_matches = target->GetImages().ResolveSymbolContextForFilePath (filename, - 0, - check_inlines, - eSymbolContextModule | eSymbolContextCompUnit, - sc_list); - if (num_matches > 0) - { - SymbolContext sc; - if (sc_list.GetContextAtIndex(0, sc)) - { - if (sc.comp_unit) - { - interpreter.GetDebugger().GetSourceManager ().DisplaySourceLinesWithLineNumbers (sc.comp_unit, - m_options.start_line, // Line to display - 0, // Lines before line to display - m_options.num_lines, // Lines after line to display - "", // Don't mark "line" - &result.GetOutputStream()); - - result.SetStatus (eReturnStatusSuccessFinishResult); - - } - } - } - } - - return result.Succeeded(); -} - diff --git a/lldb/source/Commands/CommandObjectSourceFile.h b/lldb/source/Commands/CommandObjectSourceFile.h deleted file mode 100644 index 1aab05b45d93..000000000000 --- a/lldb/source/Commands/CommandObjectSourceFile.h +++ /dev/null @@ -1,86 +0,0 @@ -//===-- CommandObjectSourceFile.h -------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_CommandObjectSourceFile_h_ -#define liblldb_CommandObjectSourceFile_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" -#include "lldb/Interpreter/Options.h" -#include "lldb/Core/FileSpec.h" - -namespace lldb_private { - -//------------------------------------------------------------------------- -// CommandObjectSourceFile -//------------------------------------------------------------------------- - -class CommandObjectSourceFile : public CommandObject -{ -public: - class CommandOptions : public Options - { - public: - - CommandOptions (); - - virtual - ~CommandOptions (); - - virtual Error - SetOptionValue (int option_idx, const char *option_arg); - - void - ResetOptionValues (); - - const lldb::OptionDefinition* - GetDefinitions (); - - // Options table: Required for subclasses of Options. - - static lldb::OptionDefinition g_option_table[]; - - // Instance variables to hold the values for command options. - FileSpec file_spec; - std::string file_name; - uint32_t start_line; - uint32_t num_lines; - }; - - CommandObjectSourceFile (); - - virtual - ~CommandObjectSourceFile (); - - virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result); - - virtual - Options * - GetOptions (); - - virtual const char *GetRepeatCommand (const char *current_command_line) - { - printf("\nReturning: \"%s\"\n", m_cmd_name.c_str()); - return m_cmd_name.c_str(); - } - - -protected: - CommandOptions m_options; -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectSourceFile_h_ diff --git a/lldb/source/Commands/CommandObjectUnalias.cpp b/lldb/source/Commands/CommandObjectUnalias.cpp deleted file mode 100644 index 253414c43058..000000000000 --- a/lldb/source/Commands/CommandObjectUnalias.cpp +++ /dev/null @@ -1,91 +0,0 @@ -//===-- CommandObjectUnalias.cpp --------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectUnalias.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectUnalias -//------------------------------------------------------------------------- - -CommandObjectUnalias::CommandObjectUnalias () : - CommandObject ("unalias", - "Allows the user to remove/delete a user-defined command abbreviation.", - "unalias ") -{ -} - -CommandObjectUnalias::~CommandObjectUnalias() -{ -} - - -bool -CommandObjectUnalias::Execute -( - CommandInterpreter &interpreter, - Args& args, - CommandReturnObject &result -) -{ - CommandObject::CommandMap::iterator pos; - CommandObject *cmd_obj; - - if (args.GetArgumentCount() != 0) - { - const char *command_name = args.GetArgumentAtIndex(0); - cmd_obj = interpreter.GetCommandObject(command_name); - if (cmd_obj) - { - if (interpreter.CommandExists (command_name)) - { - result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be removed.\n", - command_name); - result.SetStatus (eReturnStatusFailed); - } - else - { - - if (interpreter.RemoveAlias (command_name) == false) - { - if (interpreter.AliasExists (command_name)) - result.AppendErrorWithFormat ("Error occurred while attempting to unalias '%s'.\n", command_name); - else - result.AppendErrorWithFormat ("'%s' is not an existing alias.\n", command_name); - result.SetStatus (eReturnStatusFailed); - } - else - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - } - else - { - result.AppendErrorWithFormat ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command_name); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendError ("must call 'unalias' with a valid alias"); - result.SetStatus (eReturnStatusFailed); - } - - return result.Succeeded(); -} - diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index ea7fde2d2ce2..9305d775733a 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -38,7 +38,7 @@ #include "../Commands/CommandObjectSettings.h" #include "../Commands/CommandObjectShow.h" #include "../Commands/CommandObjectSource.h" -#include "../Commands/CommandObjectSourceFile.h" +#include "../Commands/CommandObjectCommands.h" #include "../Commands/CommandObjectSyntax.h" #include "../Commands/CommandObjectTarget.h" #include "../Commands/CommandObjectThread.h" @@ -84,24 +84,24 @@ CommandInterpreter::Initialize () InitializeVariables (); // Set up some initial aliases. - result.Clear(); HandleCommand ("alias q quit", false, result); - result.Clear(); HandleCommand ("alias run process launch", false, result); - result.Clear(); HandleCommand ("alias r process launch", false, result); - result.Clear(); HandleCommand ("alias c process continue", false, result); - result.Clear(); HandleCommand ("alias continue process continue", false, result); - result.Clear(); HandleCommand ("alias expr expression", false, result); - result.Clear(); HandleCommand ("alias exit quit", false, result); - result.Clear(); HandleCommand ("alias b breakpoint", false, result); - result.Clear(); HandleCommand ("alias bt thread backtrace", false, result); - result.Clear(); HandleCommand ("alias si thread step-inst", false, result); - result.Clear(); HandleCommand ("alias step thread step-in", false, result); - result.Clear(); HandleCommand ("alias s thread step-in", false, result); - result.Clear(); HandleCommand ("alias next thread step-over", false, result); - result.Clear(); HandleCommand ("alias n thread step-over", false, result); - result.Clear(); HandleCommand ("alias finish thread step-out", false, result); - result.Clear(); HandleCommand ("alias x memory read", false, result); - result.Clear(); HandleCommand ("alias l source-file", false, result); - result.Clear(); HandleCommand ("alias list source-file", false, result); + result.Clear(); HandleCommand ("command alias q quit", false, result); + result.Clear(); HandleCommand ("command alias run process launch", false, result); + result.Clear(); HandleCommand ("command alias r process launch", false, result); + result.Clear(); HandleCommand ("command alias c process continue", false, result); + result.Clear(); HandleCommand ("command alias continue process continue", false, result); + result.Clear(); HandleCommand ("command alias expr expression", false, result); + result.Clear(); HandleCommand ("command alias exit quit", false, result); + result.Clear(); HandleCommand ("command alias b breakpoint", false, result); + result.Clear(); HandleCommand ("command alias bt thread backtrace", false, result); + result.Clear(); HandleCommand ("command alias si thread step-inst", false, result); + result.Clear(); HandleCommand ("command alias step thread step-in", false, result); + result.Clear(); HandleCommand ("command alias s thread step-in", false, result); + result.Clear(); HandleCommand ("command alias next thread step-over", false, result); + result.Clear(); HandleCommand ("command alias n thread step-over", false, result); + result.Clear(); HandleCommand ("command alias finish thread step-out", false, result); + result.Clear(); HandleCommand ("command alias x memory read", false, result); + result.Clear(); HandleCommand ("command alias l source list", false, result); + result.Clear(); HandleCommand ("command alias list source list", false, result); } void @@ -206,11 +206,11 @@ CommandInterpreter::LoadCommandDictionary () // Non-CommandObjectCrossref commands can now be created. - m_command_dict["alias"] = CommandObjectSP (new CommandObjectAlias ()); m_command_dict["append"] = CommandObjectSP (new CommandObjectAppend ()); m_command_dict["apropos"] = CommandObjectSP (new CommandObjectApropos ()); m_command_dict["breakpoint"]= CommandObjectSP (new CommandObjectMultiwordBreakpoint (*this)); m_command_dict["call"] = CommandObjectSP (new CommandObjectCall ()); + m_command_dict["commands"] = CommandObjectSP (new CommandObjectMultiwordCommands (*this)); m_command_dict["disassemble"] = CommandObjectSP (new CommandObjectDisassemble ()); m_command_dict["expression"]= CommandObjectSP (new CommandObjectExpression ()); m_command_dict["file"] = CommandObjectSP (new CommandObjectFile ()); @@ -226,11 +226,9 @@ CommandInterpreter::LoadCommandDictionary () m_command_dict["set"] = CommandObjectSP (new CommandObjectSet ()); m_command_dict["settings"] = CommandObjectSP (new CommandObjectSettings ()); m_command_dict["show"] = CommandObjectSP (new CommandObjectShow ()); - m_command_dict["source"] = CommandObjectSP (new CommandObjectSource ()); - m_command_dict["source-file"] = CommandObjectSP (new CommandObjectSourceFile ()); + m_command_dict["source"] = CommandObjectSP (new CommandObjectMultiwordSource (*this)); m_command_dict["target"] = CommandObjectSP (new CommandObjectMultiwordTarget (*this)); m_command_dict["thread"] = CommandObjectSP (new CommandObjectMultiwordThread (*this)); - m_command_dict["unalias"] = CommandObjectSP (new CommandObjectUnalias ()); m_command_dict["variable"] = CommandObjectSP (new CommandObjectVariable (*this)); std::auto_ptr @@ -630,7 +628,7 @@ CommandInterpreter::HandleCommand command_line = m_repeat_command.c_str(); if (m_repeat_command.empty()) { - result.AppendError(""); + result.AppendErrorWithFormat("No auto repeat.\n"); result.SetStatus (eReturnStatusFailed); return false; } @@ -661,11 +659,11 @@ CommandInterpreter::HandleCommand if (add_to_history) { - const char *repeat_command = command_obj->GetRepeatCommand(command_line); - if (repeat_command) + const char *repeat_command = command_obj->GetRepeatCommand(command_args, 0); + if (repeat_command != NULL) m_repeat_command.assign(repeat_command); else - m_repeat_command.clear(); + m_repeat_command.assign(command_line); m_command_history.push_back (command_line); }