diff options
author | Greg Clayton <gclayton@apple.com> | 2010-06-23 01:19:29 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2010-06-23 01:19:29 +0000 |
commit | 6611103cfe7a8c08554816fc08abef2e2960e799 (patch) | |
tree | b940bb129b59af3cf6923f8d69f095d2d9fc8dca | |
parent | ef5a4383ad679e58743c540c25d6a1bab0c77423 (diff) | |
download | bcm5719-llvm-6611103cfe7a8c08554816fc08abef2e2960e799.tar.gz bcm5719-llvm-6611103cfe7a8c08554816fc08abef2e2960e799.zip |
Very large changes that were needed in order to allow multiple connections
to the debugger from GUI windows. Previously there was one global debugger
instance that could be accessed that had its own command interpreter and
current state (current target/process/thread/frame). When a GUI debugger
was attached, if it opened more than one window that each had a console
window, there were issues where the last one to setup the global debugger
object won and got control of the debugger.
To avoid this we now create instances of the lldb_private::Debugger that each
has its own state:
- target list for targets the debugger instance owns
- current process/thread/frame
- its own command interpreter
- its own input, output and error file handles to avoid conflicts
- its own input reader stack
So now clients should call:
SBDebugger::Initialize(); // (static function)
SBDebugger debugger (SBDebugger::Create());
// Use which ever file handles you wish
debugger.SetErrorFileHandle (stderr, false);
debugger.SetOutputFileHandle (stdout, false);
debugger.SetInputFileHandle (stdin, true);
// main loop
SBDebugger::Terminate(); // (static function)
SBDebugger::Initialize() and SBDebugger::Terminate() are ref counted to
ensure nothing gets destroyed too early when multiple clients might be
attached.
Cleaned up the command interpreter and the CommandObject and all subclasses
to take more appropriate arguments.
llvm-svn: 106615
167 files changed, 2910 insertions, 3613 deletions
diff --git a/lldb/include/lldb/API/SBAddress.h b/lldb/include/lldb/API/SBAddress.h index b717261e05d..31aa68fe0cf 100644 --- a/lldb/include/lldb/API/SBAddress.h +++ b/lldb/include/lldb/API/SBAddress.h @@ -66,7 +66,7 @@ protected: private: - std::auto_ptr<lldb_private::Address> m_lldb_object_ap; + std::auto_ptr<lldb_private::Address> m_opaque_ap; }; diff --git a/lldb/include/lldb/API/SBBlock.h b/lldb/include/lldb/API/SBBlock.h index bf2eb03e808..b6ef1882abf 100644 --- a/lldb/include/lldb/API/SBBlock.h +++ b/lldb/include/lldb/API/SBBlock.h @@ -35,7 +35,7 @@ private: SBBlock (lldb_private::Block *lldb_object_ptr); - lldb_private::Block *m_lldb_object_ptr; + lldb_private::Block *m_opaque_ptr; }; diff --git a/lldb/include/lldb/API/SBBreakpoint.h b/lldb/include/lldb/API/SBBreakpoint.h index 3b9642df4ee..c2ad910fb97 100644 --- a/lldb/include/lldb/API/SBBreakpoint.h +++ b/lldb/include/lldb/API/SBBreakpoint.h @@ -140,7 +140,7 @@ private: lldb::user_id_t break_id, lldb::user_id_t break_loc_id); - lldb::BreakpointSP m_break_sp; + lldb::BreakpointSP m_opaque_sp; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBBreakpointLocation.h b/lldb/include/lldb/API/SBBreakpointLocation.h index e1079775ca5..02cc4093d8d 100644 --- a/lldb/include/lldb/API/SBBreakpointLocation.h +++ b/lldb/include/lldb/API/SBBreakpointLocation.h @@ -82,7 +82,7 @@ private: void SetLocation (const lldb::BreakpointLocationSP &break_loc_sp); - lldb::BreakpointLocationSP m_break_loc_sp; + lldb::BreakpointLocationSP m_opaque_sp; }; diff --git a/lldb/include/lldb/API/SBBroadcaster.h b/lldb/include/lldb/API/SBBroadcaster.h index 21632c73014..0ef408c13ed 100644 --- a/lldb/include/lldb/API/SBBroadcaster.h +++ b/lldb/include/lldb/API/SBBroadcaster.h @@ -66,16 +66,20 @@ protected: SBBroadcaster (lldb_private::Broadcaster *broadcaster, bool owns); +#ifndef SWIG + lldb_private::Broadcaster * - GetLLDBObjectPtr () const; + get () const; void - SetLLDBObjectPtr (lldb_private::Broadcaster *broadcaster, bool owns); + reset (lldb_private::Broadcaster *broadcaster, bool owns); + +#endif private: - lldb_private::Broadcaster *m_lldb_object; - bool m_lldb_object_owned; + lldb_private::Broadcaster *m_opaque; + bool m_opaque_owned; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBCommandContext.h b/lldb/include/lldb/API/SBCommandContext.h index ab910502de0..b844be2ca9a 100644 --- a/lldb/include/lldb/API/SBCommandContext.h +++ b/lldb/include/lldb/API/SBCommandContext.h @@ -19,7 +19,7 @@ class SBCommandContext { public: - SBCommandContext (lldb_private::CommandContext *lldb_object); + SBCommandContext (lldb_private::Debugger *lldb_object); ~SBCommandContext (); @@ -28,7 +28,7 @@ public: private: - lldb_private::CommandContext *m_lldb_object; + lldb_private::Debugger *m_opaque; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBCommandInterpreter.h b/lldb/include/lldb/API/SBCommandInterpreter.h index 965a47ebc7f..5101a4cf1c3 100644 --- a/lldb/include/lldb/API/SBCommandInterpreter.h +++ b/lldb/include/lldb/API/SBCommandInterpreter.h @@ -28,6 +28,9 @@ public: ~SBCommandInterpreter (); bool + IsValid() const; + + bool CommandExists (const char *cmd); bool @@ -86,17 +89,20 @@ public: protected: lldb_private::CommandInterpreter & - GetLLDBObjectRef (); + ref (); lldb_private::CommandInterpreter * - GetLLDBObjectPtr (); + get (); + void + reset (lldb_private::CommandInterpreter *); private: friend class SBDebugger; - SBCommandInterpreter (lldb_private::CommandInterpreter &interpreter_ptr); // Access using SBDebugger::GetSharedInstance().GetCommandInterpreter(); + SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr = NULL); // Access using SBDebugger::GetCommandInterpreter(); - lldb_private::CommandInterpreter &m_interpreter; + + lldb_private::CommandInterpreter *m_opaque_ptr; }; diff --git a/lldb/include/lldb/API/SBCommandReturnObject.h b/lldb/include/lldb/API/SBCommandReturnObject.h index 899f78db91b..6ce8bfbee9e 100644 --- a/lldb/include/lldb/API/SBCommandReturnObject.h +++ b/lldb/include/lldb/API/SBCommandReturnObject.h @@ -62,17 +62,27 @@ protected: friend class SBCommandInterpreter; friend class SBOptions; + +#ifndef SWIG + + lldb_private::CommandReturnObject * + operator->() const; + lldb_private::CommandReturnObject * - GetLLDBObjectPtr(); + get() const; + + lldb_private::CommandReturnObject & + operator*() const; lldb_private::CommandReturnObject & - GetLLDBObjectRef(); + ref() const; +#endif void SetLLDBObjectPtr (lldb_private::CommandReturnObject *ptr); private: - std::auto_ptr<lldb_private::CommandReturnObject> m_return_object_ap; + std::auto_ptr<lldb_private::CommandReturnObject> m_opaque_ap; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBCommunication.h b/lldb/include/lldb/API/SBCommunication.h index 1d7fb7d98f4..0dc494afeaa 100644 --- a/lldb/include/lldb/API/SBCommunication.h +++ b/lldb/include/lldb/API/SBCommunication.h @@ -87,8 +87,8 @@ private: // void // CreateIfNeeded (); - lldb_private::Communication *m_lldb_object; - bool m_lldb_object_owned; + lldb_private::Communication *m_opaque; + bool m_opaque_owned; }; diff --git a/lldb/include/lldb/API/SBCompileUnit.h b/lldb/include/lldb/API/SBCompileUnit.h index 5b45b56886c..43be8192ea3 100644 --- a/lldb/include/lldb/API/SBCompileUnit.h +++ b/lldb/include/lldb/API/SBCompileUnit.h @@ -66,7 +66,7 @@ private: #endif - lldb_private::CompileUnit *m_lldb_object_ptr; + lldb_private::CompileUnit *m_opaque_ptr; }; diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 6446fca8a3d..d55a77edfdf 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -25,95 +25,90 @@ public: static void Terminate(); - static void - SetAsync (bool b); + static SBDebugger + Create(); - static void - SetInputFile (const char *tty_name); // DEPRECATED: will be removed in next submission + ~SBDebugger(); - static void - SetOutputFile (const char *tty_name); // DEPRECATED: will be removed in next submission + bool + IsValid() const; - static void - SetErrorFile (const char *tty_name); // DEPRECATED: will be removed in next submission + void + SetAsync (bool b); - static void + void SetInputFileHandle (FILE *f, bool transfer_ownership); - static void + void SetOutputFileHandle (FILE *f, bool transfer_ownership); - static void + void SetErrorFileHandle (FILE *f, bool transfer_ownership); - static FILE * + FILE * GetInputFileHandle (); - static FILE * + FILE * GetOutputFileHandle (); - static FILE * + FILE * GetErrorFileHandle (); - static lldb::SBCommandInterpreter + lldb::SBCommandInterpreter GetCommandInterpreter (); - static void + void HandleCommand (const char *command); - static lldb::SBListener + lldb::SBListener GetListener (); - static void + void HandleProcessEvent (const lldb::SBProcess &process, const lldb::SBEvent &event, FILE *out, FILE *err); - static lldb::SBTarget + lldb::SBTarget CreateTargetWithFileAndTargetTriple (const char *filename, const char *target_triple); - static lldb::SBTarget + lldb::SBTarget CreateTargetWithFileAndArch (const char *filename, const char *archname); - static lldb::SBTarget + lldb::SBTarget CreateTarget (const char *filename); - static lldb::SBTarget + lldb::SBTarget GetTargetAtIndex (uint32_t idx); - static lldb::SBTarget + lldb::SBTarget FindTargetWithProcessID (pid_t pid); - static lldb::SBTarget + lldb::SBTarget FindTargetWithFileAndArch (const char *filename, const char *arch); - static uint32_t + uint32_t GetNumTargets (); - static lldb::SBTarget + lldb::SBTarget GetCurrentTarget (); - static void + void UpdateCurrentThread (lldb::SBProcess &process); - static void - ReportCurrentLocation (FILE *out = stdout, - FILE *err = stderr); - - static lldb::SBSourceManager & + lldb::SBSourceManager & GetSourceManager (); - static bool + bool GetDefaultArchitecture (char *arch_name, size_t arch_name_len); - static bool + bool SetDefaultArchitecture (const char *arch_name); - static lldb::ScriptLanguage + lldb::ScriptLanguage GetScriptingLanguage (const char *script_language_name); static const char * @@ -128,19 +123,39 @@ public: static bool StateIsStoppedState (lldb::StateType state); - static void + void DispatchInput (void *baton, const void *data, size_t data_len); - static void + void PushInputReader (lldb::SBInputReader &reader); private: + + // Use the static function: SBDebugger::Create(); + SBDebugger(); + #ifndef SWIG - friend class SBProcess; - static lldb::SBTarget + friend class SBInputReader; + friend class SBProcess; + friend class SBTarget; + + lldb::SBTarget FindTargetWithLLDBProcess (const lldb::ProcessSP &processSP); + + void + reset (const lldb::DebuggerSP &debugger_sp); + + lldb_private::Debugger * + get () const; + + lldb_private::Debugger & + ref () const; + #endif + + lldb::DebuggerSP m_opaque_sp; + }; // class SBDebugger diff --git a/lldb/include/lldb/API/SBError.h b/lldb/include/lldb/API/SBError.h index 325f9e9aea5..fcd9a929d13 100644 --- a/lldb/include/lldb/API/SBError.h +++ b/lldb/include/lldb/API/SBError.h @@ -90,7 +90,7 @@ protected: SetError (const lldb_private::Error &lldb_error); private: - std::auto_ptr<lldb_private::Error> m_lldb_object_ap; + std::auto_ptr<lldb_private::Error> m_opaque_ap; void CreateIfNeeded (); diff --git a/lldb/include/lldb/API/SBEvent.h b/lldb/include/lldb/API/SBEvent.h index 8bceb1811aa..cac9fb5edd9 100644 --- a/lldb/include/lldb/API/SBEvent.h +++ b/lldb/include/lldb/API/SBEvent.h @@ -64,25 +64,26 @@ protected: SBEvent (lldb::EventSP &event_sp); +#ifndef SWIG + lldb::EventSP & - GetSharedPtr () const; + GetSP () const; void - SetEventSP (lldb::EventSP &event_sp); + reset (lldb::EventSP &event_sp); void - SetLLDBObjectPtr (lldb_private::Event* event); + reset (lldb_private::Event* event); lldb_private::Event * - GetLLDBObjectPtr (); + get () const; - const lldb_private::Event * - GetLLDBObjectPtr () const; +#endif private: mutable lldb::EventSP m_event_sp; - mutable lldb_private::Event *m_lldb_object; + mutable lldb_private::Event *m_opaque; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBFileSpec.h b/lldb/include/lldb/API/SBFileSpec.h index 826531836b5..770ec5bf01e 100644 --- a/lldb/include/lldb/API/SBFileSpec.h +++ b/lldb/include/lldb/API/SBFileSpec.h @@ -54,6 +54,7 @@ private: friend class SBHostOS; friend class SBModule; friend class SBSourceManager; + friend class SBThread; friend class SBTarget; void @@ -74,7 +75,7 @@ private: #endif - std::auto_ptr <lldb_private::FileSpec> m_lldb_object_ap; + std::auto_ptr <lldb_private::FileSpec> m_opaque_ap; }; diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h index cd22f2d7ed0..f5898d7b242 100644 --- a/lldb/include/lldb/API/SBFrame.h +++ b/lldb/include/lldb/API/SBFrame.h @@ -122,7 +122,7 @@ private: void SetFrame (const lldb::StackFrameSP &lldb_object_sp); - lldb::StackFrameSP m_lldb_object_sp; + lldb::StackFrameSP m_opaque_sp; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBFunction.h b/lldb/include/lldb/API/SBFunction.h index 152a52d7d85..6f4a90a2dcd 100644 --- a/lldb/include/lldb/API/SBFunction.h +++ b/lldb/include/lldb/API/SBFunction.h @@ -46,7 +46,7 @@ private: SBFunction (lldb_private::Function *lldb_object_ptr); - lldb_private::Function *m_lldb_object_ptr; + lldb_private::Function *m_opaque_ptr; }; diff --git a/lldb/include/lldb/API/SBInputReader.h b/lldb/include/lldb/API/SBInputReader.h index a69bf47a564..90dcd704ec4 100644 --- a/lldb/include/lldb/API/SBInputReader.h +++ b/lldb/include/lldb/API/SBInputReader.h @@ -36,7 +36,8 @@ public: SBError - Initialize (Callback callback, + Initialize (SBDebugger &debugger, + Callback callback, void *callback_baton, lldb::InputReaderGranularity granularity, const char *end_token, @@ -76,21 +77,26 @@ protected: const lldb::InputReaderSP & operator *() const; -#endif lldb_private::InputReader * get() const; + lldb_private::InputReader & + ref() const; + +#endif + + private: static size_t PrivateCallback (void *baton, - lldb_private::InputReader *reader, + lldb_private::InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); - lldb::InputReaderSP m_reader_sp; + lldb::InputReaderSP m_opaque_sp; Callback m_callback_function; void *m_callback_baton; }; diff --git a/lldb/include/lldb/API/SBInstruction.h b/lldb/include/lldb/API/SBInstruction.h index ab1e76da503..4d3af965bc1 100644 --- a/lldb/include/lldb/API/SBInstruction.h +++ b/lldb/include/lldb/API/SBInstruction.h @@ -48,7 +48,7 @@ public: private: - //lldb_private::Disassembler::Instruction::SharedPtr m_lldb_object_sp; + //lldb_private::Disassembler::Instruction::SharedPtr m_opaque_sp; }; diff --git a/lldb/include/lldb/API/SBLineEntry.h b/lldb/include/lldb/API/SBLineEntry.h index f0ed6b35f8e..68fba3e19e4 100644 --- a/lldb/include/lldb/API/SBLineEntry.h +++ b/lldb/include/lldb/API/SBLineEntry.h @@ -79,7 +79,7 @@ private: void SetLineEntry (const lldb_private::LineEntry &lldb_object_ref); - std::auto_ptr<lldb_private::LineEntry> m_lldb_object_ap; + std::auto_ptr<lldb_private::LineEntry> m_opaque_ap; }; diff --git a/lldb/include/lldb/API/SBListener.h b/lldb/include/lldb/API/SBListener.h index bb3c34f03a0..68d8a162da0 100644 --- a/lldb/include/lldb/API/SBListener.h +++ b/lldb/include/lldb/API/SBListener.h @@ -106,12 +106,15 @@ private: const lldb_private::Listener & operator *() const; + void + reset(lldb_private::Listener *listener, bool transfer_ownership); + #endif - lldb_private::Listener *m_lldb_object_ptr; - bool m_lldb_object_ptr_owned; + lldb_private::Listener *m_opaque_ptr; + bool m_opaque_ptr_owned; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h index 1c02ec92994..2f353b60696 100644 --- a/lldb/include/lldb/API/SBModule.h +++ b/lldb/include/lldb/API/SBModule.h @@ -70,7 +70,7 @@ private: #endif - lldb::ModuleSP m_lldb_object_sp; + lldb::ModuleSP m_opaque_sp; }; diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index a0958921ec1..98a1841b429 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -106,12 +106,6 @@ public: SBError Destroy (); - void - DisplayThreadsInfo (FILE *out = NULL, FILE *err = NULL, bool only_threads_with_stop_reason = true); - - void - ListThreads (); - bool WaitUntilProcessHasStopped (lldb::SBCommandReturnObject &result); @@ -139,9 +133,6 @@ public: SBError Signal (int signal); - void - Backtrace (bool all_threads = false, uint32_t num_frames = 0); - size_t ReadMemory (addr_t addr, void *buf, size_t size, SBError &error); @@ -188,7 +179,7 @@ protected: void SetProcess (const lldb::ProcessSP &process_sp); - lldb::ProcessSP m_lldb_object_sp; + lldb::ProcessSP m_opaque_sp; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBSourceManager.h b/lldb/include/lldb/API/SBSourceManager.h index 2e188a65385..639c56e9b09 100644 --- a/lldb/include/lldb/API/SBSourceManager.h +++ b/lldb/include/lldb/API/SBSourceManager.h @@ -41,7 +41,7 @@ protected: private: - lldb_private::SourceManager &m_source_manager; + lldb_private::SourceManager &m_opaque_ref; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBStringList.h b/lldb/include/lldb/API/SBStringList.h index 7c8f1861d9b..514ad3b0760 100644 --- a/lldb/include/lldb/API/SBStringList.h +++ b/lldb/include/lldb/API/SBStringList.h @@ -62,7 +62,7 @@ public: private: - std::auto_ptr<lldb_private::StringList> m_lldb_object_ap; + std::auto_ptr<lldb_private::StringList> m_opaque_ap; }; diff --git a/lldb/include/lldb/API/SBSymbol.h b/lldb/include/lldb/API/SBSymbol.h index aada0065fb9..f939bfa4aa7 100644 --- a/lldb/include/lldb/API/SBSymbol.h +++ b/lldb/include/lldb/API/SBSymbol.h @@ -46,7 +46,7 @@ private: SBSymbol (lldb_private::Symbol *lldb_object_ptr); - lldb_private::Symbol *m_lldb_object_ptr; + lldb_private::Symbol *m_opaque_ptr; }; diff --git a/lldb/include/lldb/API/SBSymbolContext.h b/lldb/include/lldb/API/SBSymbolContext.h index 0a57fa1ffe1..b4f9acdc0f7 100644 --- a/lldb/include/lldb/API/SBSymbolContext.h +++ b/lldb/include/lldb/API/SBSymbolContext.h @@ -64,7 +64,7 @@ protected: SetSymbolContext (const lldb_private::SymbolContext *sc_ptr); private: - std::auto_ptr<lldb_private::SymbolContext> m_lldb_object_ap; + std::auto_ptr<lldb_private::SymbolContext> m_opaque_ap; }; diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 9fd007a3d68..12e3195a059 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -70,6 +70,9 @@ public: lldb::SBModule GetModuleAtIndex (uint32_t idx); + lldb::SBDebugger + GetDebugger() const; + lldb::SBModule FindModule (const lldb::SBFileSpec &file_spec); @@ -146,20 +149,20 @@ protected: SBTarget (const lldb::TargetSP& target_sp); void - SetLLBDTarget (const lldb::TargetSP& target_sp); + reset (const lldb::TargetSP& target_sp); lldb_private::Target * - GetLLDBObjectPtr(); + operator ->() const; - const lldb_private::Target * - GetLLDBObjectPtr() const; + lldb_private::Target * + get() const; private: //------------------------------------------------------------------ // For Target only //------------------------------------------------------------------ - lldb::TargetSP m_target_sp; + lldb::TargetSP m_opaque_sp; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBThread.h b/lldb/include/lldb/API/SBThread.h index 0b6f1e02af6..08372a18c4b 100644 --- a/lldb/include/lldb/API/SBThread.h +++ b/lldb/include/lldb/API/SBThread.h @@ -82,9 +82,6 @@ public: void RunToAddress (lldb::addr_t addr); - void - Backtrace (uint32_t num_frames = 0); - uint32_t GetNumFrames (); @@ -146,7 +143,7 @@ private: // Classes that inherit from Thread can see and modify these //------------------------------------------------------------------ - lldb::ThreadSP m_lldb_object_sp; + lldb::ThreadSP m_opaque_sp; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index c0538a6ee1f..068b73fab0c 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -112,11 +112,11 @@ protected: #endif private: - - lldb_private::ExecutionContext - GetCurrentExecutionContext (); - - lldb::ValueObjectSP m_lldb_object_sp; +// +// lldb_private::ExecutionContext +// GetCurrentExecutionContext (); +// + lldb::ValueObjectSP m_opaque_sp; }; } // namespace lldb diff --git a/lldb/include/lldb/API/SBValueList.h b/lldb/include/lldb/API/SBValueList.h index a3227ac557d..6c4b939b457 100644 --- a/lldb/include/lldb/API/SBValueList.h +++ b/lldb/include/lldb/API/SBValueList.h @@ -68,7 +68,7 @@ private: void CreateIfNeeded (); - std::auto_ptr<lldb_private::ValueObjectList> m_lldb_object_ap; + std::auto_ptr<lldb_private::ValueObjectList> m_opaque_ap; }; diff --git a/lldb/include/lldb/Breakpoint/StoppointCallbackContext.h b/lldb/include/lldb/Breakpoint/StoppointCallbackContext.h index f2a6401e748..48384b422c4 100644 --- a/lldb/include/lldb/Breakpoint/StoppointCallbackContext.h +++ b/lldb/include/lldb/Breakpoint/StoppointCallbackContext.h @@ -48,7 +48,7 @@ public: //------------------------------------------------------------------ Event *event; // This is the event, the callback can modify this to indicate // the meaning of the breakpoint hit - ExecutionContext context; // This tells us where we have stopped, what thread. + ExecutionContext exe_ctx; // This tells us where we have stopped, what thread. bool is_synchronous; // Is the callback being executed synchronously with the breakpoint, // or asynchronously as the event is retrieved? }; diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index bfb2bc17e13..503e250bee6 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -17,11 +17,11 @@ #include <stack> -#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Core/Communication.h" #include "lldb/Core/Listener.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/SourceManager.h" +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/TargetList.h" namespace lldb_private { @@ -36,17 +36,23 @@ class Debugger { public: + static lldb::DebuggerSP + CreateInstance (); + + static lldb::TargetSP + FindTargetWithProcessID (lldb::pid_t pid); + static void Initialize (); static void Terminate (); - static Debugger & - GetSharedInstance (); - ~Debugger (); + lldb::DebuggerSP + GetSP (); + bool GetAsyncExecution (); @@ -123,6 +129,16 @@ public: bool PopInputReader (const lldb::InputReaderSP& reader_sp); + ExecutionContext & + GetExecutionContext() + { + return m_exe_ctx; + } + + + void + UpdateExecutionContext (ExecutionContext *override_context); + protected: static void @@ -137,7 +153,6 @@ protected: void DisconnectInput(); - bool m_async_execution; Communication m_input_comm; StreamFile m_input_file; StreamFile m_output_file; @@ -145,21 +160,19 @@ protected: TargetList m_target_list; Listener m_listener; SourceManager m_source_manager; - CommandInterpreter m_command_interpreter; + std::auto_ptr<CommandInterpreter> m_command_interpreter_ap; + ExecutionContext m_exe_ctx; std::stack<lldb::InputReaderSP> m_input_readers; std::string m_input_reader_data; - typedef lldb::SharedPtr<Debugger>::Type DebuggerSP; +private: + + // Use Debugger::CreateInstance() to get a shared pointer to a new + // debugger object + Debugger (); - static DebuggerSP & - GetDebuggerSP(); - - static int g_shared_debugger_refcount; - static bool g_in_terminate; -private: - Debugger (); // Access the single global instance of this class using Debugger::GetSharedInstance(); DISALLOW_COPY_AND_ASSIGN (Debugger); }; diff --git a/lldb/include/lldb/Core/Disassembler.h b/lldb/include/lldb/Core/Disassembler.h index 33d7d561dec..5e831823c25 100644 --- a/lldb/include/lldb/Core/Disassembler.h +++ b/lldb/include/lldb/Core/Disassembler.h @@ -86,7 +86,8 @@ public: FindPlugin (const ArchSpec &arch); static bool - Disassemble (const ArchSpec &arch, + Disassemble (Debugger &debugger, + const ArchSpec &arch, const ExecutionContext &exe_ctx, uint32_t mixed_context_lines, Stream &strm); diff --git a/lldb/include/lldb/Core/InputReader.h b/lldb/include/lldb/Core/InputReader.h index 2d876240c1d..e278eabcf36 100644 --- a/lldb/include/lldb/Core/InputReader.h +++ b/lldb/include/lldb/Core/InputReader.h @@ -24,12 +24,12 @@ class InputReader public: typedef size_t (*Callback) (void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); - InputReader (); + InputReader (Debugger &debugger); virtual ~InputReader (); @@ -71,11 +71,11 @@ public: virtual size_t HandleRawBytes (const char *bytes, size_t bytes_len); - FILE * - GetInputFileHandle (); - - FILE * - GetOutputFileHandle (); + Debugger & + GetDebugger() + { + return m_debugger; + } bool IsActive () const @@ -95,6 +95,7 @@ protected: void Notify (lldb::InputReaderAction notification); + Debugger &m_debugger; Callback m_callback; void *m_callback_baton; std::string m_end_token; diff --git a/lldb/include/lldb/Interpreter/CommandCompletions.h b/lldb/include/lldb/Interpreter/CommandCompletions.h index 22964746959..f870490c79e 100644 --- a/lldb/include/lldb/Interpreter/CommandCompletions.h +++ b/lldb/include/lldb/Interpreter/CommandCompletions.h @@ -29,12 +29,12 @@ public: // This is the command completion callback that is used to complete the argument of the option // it is bound to (in the OptionDefinition table below). Return the total number of matches. //---------------------------------------------------------------------- - typedef int (*CompletionCallback) (const char *completion_str, // This is the argument we are completing - int match_start_point, // This is the point in the list of matches that you should start returning elements - int max_return_elements, // This is the number of matches requested. - lldb_private::CommandInterpreter *interpreter, // The command interpreter running this command. - lldb_private::SearchFilter *searcher, // A search filter to limit the search... - lldb_private::StringList &matches); // The array of matches we return. + typedef int (*CompletionCallback) (CommandInterpreter &interpreter, + const char *completion_str, // This is the argument we are completing + int match_start_point, // This is the point in the list of matches that you should start returning elements + int max_return_elements, // This is the number of matches requested. + lldb_private::SearchFilter *searcher,// A search filter to limit the search... + lldb_private::StringList &matches); // The array of matches we return. typedef enum { eNoCompletion = 0, @@ -54,41 +54,41 @@ public: CompletionCallback callback; }; - static bool InvokeCommonCompletionCallbacks (uint32_t completion_mask, - const char *completion_str, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - StringList &matches); - + static bool InvokeCommonCompletionCallbacks (CommandInterpreter &interpreter, + uint32_t completion_mask, + const char *completion_str, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches); + //---------------------------------------------------------------------- // These are the generic completer functions: //---------------------------------------------------------------------- static int - SourceFiles (const char *partial_file_name, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - SearchFilter *searcher, - StringList &matches); - + SourceFiles (CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches); + static int - Modules (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches); - + Modules (CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + lldb_private::StringList &matches); + static int - Symbols (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches); - + Symbols (CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + lldb_private::StringList &matches); + //---------------------------------------------------------------------- // The Completer class is a convenient base class for building searchers // that go along with the SearchFilter passed to the standard Completer @@ -97,10 +97,10 @@ public: class Completer : public Searcher { public: - Completer (const char *completion_str, + Completer (CommandInterpreter &interpreter, + const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches); virtual ~Completer (); @@ -118,10 +118,10 @@ public: DoCompletion (SearchFilter *filter) = 0; protected: + CommandInterpreter &m_interpreter; std::string m_completion_str; int m_match_start_point; int m_max_return_elements; - CommandInterpreter *m_interpreter; StringList &m_matches; private: DISALLOW_COPY_AND_ASSIGN (Completer); @@ -134,13 +134,13 @@ public: { public: - SourceFileCompleter (bool include_support_files, - const char *completion_str, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches); - + SourceFileCompleter (CommandInterpreter &interpreter, + bool include_support_files, + const char *completion_str, + int match_start_point, + int max_return_elements, + StringList &matches); + virtual Searcher::Depth GetDepth (); virtual Searcher::CallbackReturn @@ -168,12 +168,12 @@ public: { public: - ModuleCompleter (const char *completion_str, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches); - + ModuleCompleter (CommandInterpreter &interpreter, + const char *completion_str, + int match_start_point, + int max_return_elements, + StringList &matches); + virtual Searcher::Depth GetDepth (); virtual Searcher::CallbackReturn @@ -199,12 +199,12 @@ public: { public: - SymbolCompleter (const char *completion_str, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches); - + SymbolCompleter (CommandInterpreter &interpreter, + const char *completion_str, + int match_start_point, + int max_return_elements, + StringList &matches); + virtual Searcher::Depth GetDepth (); virtual Searcher::CallbackReturn @@ -217,15 +217,15 @@ public: DoCompletion (SearchFilter *filter); private: - struct NameCmp { - bool operator() (const ConstString& lhs, const ConstString& rhs) const - { - return lhs < rhs; - } - }; +// struct NameCmp { +// bool operator() (const ConstString& lhs, const ConstString& rhs) const +// { +// return lhs < rhs; +// } +// }; RegularExpression m_regex; - typedef std::set<ConstString, NameCmp> collection; + typedef std::set<ConstString> collection; collection m_match_set; DISALLOW_COPY_AND_ASSIGN (SymbolCompleter); diff --git a/lldb/include/lldb/Interpreter/CommandContext.h b/lldb/include/lldb/Interpreter/CommandContext.h deleted file mode 100644 index 69bd27e2472..00000000000 --- a/lldb/include/lldb/Interpreter/CommandContext.h +++ /dev/null @@ -1,43 +0,0 @@ -//===-- CommandContext.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_CommandContext_h_ -#define liblldb_CommandContext_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Core/ArchSpec.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Core/FileSpec.h" -#include "lldb/Core/ValueObjectList.h" - -namespace lldb_private { - -class CommandContext -{ -public: - CommandContext (); - - ~CommandContext (); - - void - Update (ExecutionContext *override_context = NULL); - - Target * - GetTarget(); - - ExecutionContext & - GetExecutionContext(); - -private: - ExecutionContext m_exe_ctx; -}; - -} // namespace lldb_private - -#endif // liblldb_CommandContext_h_ diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h b/lldb/include/lldb/Interpreter/CommandInterpreter.h index cc11e371682..26ff3abaf44 100644 --- a/lldb/include/lldb/Interpreter/CommandInterpreter.h +++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h @@ -16,8 +16,8 @@ // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/Broadcaster.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Log.h" -#include "lldb/Interpreter/CommandContext.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Interpreter/StateVariable.h" @@ -43,10 +43,9 @@ public: void SourceInitFile (bool in_cwd, CommandReturnObject &result); - CommandInterpreter (lldb::ScriptLanguage script_language, - bool synchronous_execution, - Listener *listener, // In case this is asked to create or attach to a process - SourceManager& source_manager); + CommandInterpreter (Debugger &debugger, + lldb::ScriptLanguage script_language, + bool synchronous_execution); virtual ~CommandInterpreter (); @@ -88,7 +87,9 @@ public: AddOrReplaceAliasOptions (const char *alias_name, OptionArgVectorSP &option_arg_vector_sp); bool - HandleCommand (const char *command_line, bool add_to_history, CommandReturnObject &result, + HandleCommand (const char *command_line, + bool add_to_history, + CommandReturnObject &result, ExecutionContext *override_context = NULL); // This handles command line completion. You are given a pointer to the command string buffer, to the current cursor, @@ -147,8 +148,11 @@ public: void ShowVariableHelp (CommandReturnObject &result); - CommandContext * - Context(); + Debugger & + GetDebugger () + { + return m_debugger; + } const Args * GetProgramArguments (); @@ -159,12 +163,6 @@ public: const char * ProcessEmbeddedScriptCommands (const char *arg); - Listener * - GetListener (); - - SourceManager & - GetSourceManager (); - const char * GetPrompt (); @@ -244,12 +242,9 @@ protected: private: + Debugger &m_debugger; // The debugger session that this interpreter is associated with lldb::ScriptLanguage m_script_language; - CommandContext m_current_context; bool m_synchronous_execution; - Listener *m_listener; - SourceManager& m_source_manager; - CommandObject::CommandMap m_command_dict; // Stores basic built-in commands (they cannot be deleted, removed or overwritten). CommandObject::CommandMap m_alias_dict; // Stores user aliases/abbreviations for commands CommandObject::CommandMap m_user_dict; // Stores user-defined commands diff --git a/lldb/include/lldb/Interpreter/CommandObject.h b/lldb/include/lldb/Interpreter/CommandObject.h index 6238e6a7f2f..24e43cbd3b4 100644 --- a/lldb/include/lldb/Interpreter/CommandObject.h +++ b/lldb/include/lldb/Interpreter/CommandObject.h @@ -83,26 +83,23 @@ public: // Do not override this bool - ExecuteCommandString (const char *command, - CommandContext *context, - CommandInterpreter *interpreter, + ExecuteCommandString (CommandInterpreter &interpreter, + const char *command, CommandReturnObject &result); bool - ParseOptions(Args& args, - CommandInterpreter *interpreter, - CommandReturnObject &result); + ParseOptions (CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result); bool - ExecuteWithOptions (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + ExecuteWithOptions (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool - ExecuteRawCommandString (const char *command, - CommandContext *context, - CommandInterpreter *interpreter, + ExecuteRawCommandString (CommandInterpreter &interpreter, + const char *command, CommandReturnObject &result) { return false; @@ -110,9 +107,8 @@ public: virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) = 0; void @@ -134,12 +130,12 @@ public: // Don't override this method, override HandleArgumentCompletion instead unless // you have special reasons. virtual int - HandleCompletion (Args &input, + HandleCompletion (CommandInterpreter &interpreter, + Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches); // The input array contains a parsed version of the line. The insertion @@ -149,16 +145,18 @@ public: // helpful for the completion. virtual int - HandleArgumentCompletion (Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches); - - + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + StringList &matches) + { + return 0; + } + bool HelpTextContainsWord (const char *search_word); diff --git a/lldb/include/lldb/Interpreter/CommandObjectCrossref.h b/lldb/include/lldb/Interpreter/CommandObjectCrossref.h index 927b8548816..c72b8b8b8b6 100644 --- a/lldb/include/lldb/Interpreter/CommandObjectCrossref.h +++ b/lldb/include/lldb/Interpreter/CommandObjectCrossref.h @@ -37,9 +37,8 @@ public: GenerateHelpText (CommandReturnObject &result); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool diff --git a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h index 90f9fd0b8df..b065a296bfd 100644 --- a/lldb/include/lldb/Interpreter/CommandObjectMultiword.h +++ b/lldb/include/lldb/Interpreter/CommandObjectMultiword.h @@ -28,10 +28,10 @@ class CommandObjectMultiword : public CommandObject { public: CommandObjectMultiword (const char *name, - const char *help = NULL, - const char *syntax = NULL, - uint32_t flags = 0); - + const char *help = NULL, + const char *syntax = NULL, + uint32_t flags = 0); + virtual ~CommandObjectMultiword (); @@ -39,10 +39,12 @@ public: IsMultiwordObject () { return true; } bool - LoadSubCommand (lldb::CommandObjectSP command_obj, const char *cmd_name, CommandInterpreter *interpreter); + LoadSubCommand (CommandInterpreter &interpreter, + const char *cmd_name, + const lldb::CommandObjectSP& command_obj); void - GenerateHelpText (CommandReturnObject &result, CommandInterpreter *interpreter); + GenerateHelpText (CommandInterpreter &interpreter, CommandReturnObject &result); lldb::CommandObjectSP GetSubcommandSP (const char *sub_cmd, StringList *matches = NULL); @@ -51,18 +53,17 @@ public: GetSubcommandObject (const char *sub_cmd, StringList *matches = NULL); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual int - HandleCompletion (Args &input, + HandleCompletion (CommandInterpreter &interpreter, + Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches); CommandObject::CommandMap m_subcommand_dict; diff --git a/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h b/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h index 0c38f5b4fab..7302f08e312 100644 --- a/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h +++ b/lldb/include/lldb/Interpreter/CommandObjectRegexCommand.h @@ -35,18 +35,16 @@ public: ~CommandObjectRegexCommand (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool WantsRawCommandString() { return true; } virtual bool - ExecuteRawCommandString (const char *command, - CommandContext *context, - CommandInterpreter *interpreter, + ExecuteRawCommandString (CommandInterpreter &interpreter, + const char *command, CommandReturnObject &result); diff --git a/lldb/include/lldb/Interpreter/Options.h b/lldb/include/lldb/Interpreter/Options.h index 39931057363..e589e3c3253 100644 --- a/lldb/include/lldb/Interpreter/Options.h +++ b/lldb/include/lldb/Interpreter/Options.h @@ -218,13 +218,13 @@ public: /// \btrue if we were in an option, \bfalse otherwise. //------------------------------------------------------------------ bool - HandleOptionCompletion (Args &input, + HandleOptionCompletion (CommandInterpreter &interpreter, + Args &input, OptionElementVector &option_map, int cursor_index, int char_pos, int match_start_point, int max_return_elements, - lldb_private::CommandInterpreter *interpreter, lldb_private::StringList &matches); //------------------------------------------------------------------ @@ -263,16 +263,16 @@ public: /// \btrue if we were in an option, \bfalse otherwise. //------------------------------------------------------------------ virtual bool - HandleOptionArgumentCompletion (Args &input, - int cursor_index, - int char_pos, - OptionElementVector &opt_element_vector, - int opt_element_index, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches); - + HandleOptionArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int cursor_index, + int char_pos, + OptionElementVector &opt_element_vector, + int opt_element_index, + int match_start_point, + int max_return_elements, + StringList &matches); + protected: // This is a set of options expressed as indexes into the options table for this Option. typedef std::set<char> OptionSet; diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h index 0c64777f11b..afa00a4744f 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h @@ -43,10 +43,10 @@ public: virtual ~ScriptInterpreter (); virtual void - ExecuteOneLine (const std::string&, FILE *, FILE *) = 0; + ExecuteOneLine (CommandInterpreter &interpreter, const char *command) = 0; virtual void - ExecuteInterpreterLoop (FILE *, FILE *) = 0; + ExecuteInterpreterLoop (CommandInterpreter &interpreter) = 0; virtual bool ExecuteOneLineWithReturn (const char *in_string, ReturnType return_type, void *ret_value) diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreterNone.h b/lldb/include/lldb/Interpreter/ScriptInterpreterNone.h index 919e17fa956..8068adb02a9 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreterNone.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreterNone.h @@ -18,15 +18,15 @@ class ScriptInterpreterNone : public ScriptInterpreter { public: - ScriptInterpreterNone (); + ScriptInterpreterNone (CommandInterpreter &interpreter); ~ScriptInterpreterNone (); virtual void - ExecuteOneLine (const std::string &line, FILE *out, FILE *err); + ExecuteOneLine (CommandInterpreter &interpreter, const char *command); virtual void - ExecuteInterpreterLoop (FILE *out, FILE *err); + ExecuteInterpreterLoop (CommandInterpreter &interpreter); }; diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h b/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h index 3343072fdf5..aaff7b43d6a 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreterPython.h @@ -20,15 +20,15 @@ class ScriptInterpreterPython : public ScriptInterpreter { public: - ScriptInterpreterPython (); + ScriptInterpreterPython (CommandInterpreter &interpreter); ~ScriptInterpreterPython (); void - ExecuteOneLine (const std::string &line, FILE *out, FILE *err); + ExecuteOneLine (CommandInterpreter &interpreter, const char *command); void - ExecuteInterpreterLoop (FILE *out, FILE *err); + ExecuteInterpreterLoop (CommandInterpreter &interpreter); bool ExecuteOneLineWithReturn (const char *in_string, @@ -46,7 +46,7 @@ public: static size_t GenerateBreakpointOptionsCommandCallback (void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); @@ -58,7 +58,8 @@ public: lldb::user_id_t break_loc_id); void - CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, + CollectDataForBreakpointCommandCallback (CommandInterpreter &interpreter, + BreakpointOptions *bp_options, CommandReturnObject &result); StringList @@ -68,7 +69,7 @@ private: static size_t InputReaderCallback (void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 0f9fd09b985..6f5f05e2ba7 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -64,7 +64,7 @@ private: /// /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*) //------------------------------------------------------------------ - Target(); + Target(Debugger &debugger); public: ~Target(); @@ -253,6 +253,12 @@ public: ArchSpec GetArchitecture () const; + Debugger & + GetDebugger () + { + return m_debugger; + } + bool GetTargetTriple (ConstString &target_triple); @@ -294,6 +300,7 @@ protected: //------------------------------------------------------------------ // Member variables. //------------------------------------------------------------------ + Debugger & m_debugger; ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded). BreakpointList m_breakpoint_list; BreakpointList m_internal_breakpoint_list; diff --git a/lldb/include/lldb/Target/TargetList.h b/lldb/include/lldb/Target/TargetList.h index 8cd7b7b971d..699be839d37 100644 --- a/lldb/include/lldb/Target/TargetList.h +++ b/lldb/include/lldb/Target/TargetList.h @@ -79,7 +79,8 @@ public: /// A shared pointer to a target object. //------------------------------------------------------------------ Error - CreateTarget (const FileSpec& file_spec, + CreateTarget (Debugger &debugger, + const FileSpec& file_spec, const ArchSpec& arch, const UUID *uuid_ptr, bool get_dependent_files, diff --git a/lldb/include/lldb/lldb-forward-rtti.h b/lldb/include/lldb/lldb-forward-rtti.h index ad4d63bad25..f76de63449c 100644 --- a/lldb/include/lldb/lldb-forward-rtti.h +++ b/lldb/include/lldb/lldb-forward-rtti.h @@ -33,6 +33,7 @@ namespace lldb { typedef SharedPtr<lldb_private::Communication>::Type CommunicationSP; typedef SharedPtr<lldb_private::CompileUnit>::Type CompUnitSP; typedef SharedPtr<lldb_private::DataBuffer>::Type DataBufferSP; + typedef SharedPtr<lldb_private::Debugger>::Type DebuggerSP; typedef SharedPtr<lldb_private::DynamicLoader>::Type DynamicLoaderSP; typedef SharedPtr<lldb_private::Event>::Type EventSP; typedef SharedPtr<lldb_private::Function>::Type FunctionSP; diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index bd294453429..8deb3297778 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -42,7 +42,7 @@ class ClangASTContext; class ClangExpression; class ClangExpressionDeclMap; class ClangExpressionVariableList; -class CommandContext; +class Debugger; class CommandInterpreter; class CommandObject; class CommandReturnObject; diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 781c7f629c0..7f235690ef0 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -160,7 +160,6 @@ 26D5B0C711B07550009A862E /* CFCMutableDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EF310F1B8AD00F91463 /* CFCMutableDictionary.cpp */; }; 26D5B0C811B07550009A862E /* CFCMutableSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EF510F1B8AD00F91463 /* CFCMutableSet.cpp */; }; 26D5B0C911B07550009A862E /* CFCString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EF810F1B8AD00F91463 /* CFCString.cpp */; }; - 26D5B0CA11B07550009A862E /* CommandContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0710F1B8DD00F91463 /* CommandContext.cpp */; }; 26D5B0CB11B07550009A862E /* CommandInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0810F1B8DD00F91463 /* CommandInterpreter.cpp */; }; 26D5B0CC11B07550009A862E /* CommandObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0910F1B8DD00F91463 /* CommandObject.cpp */; }; 26D5B0CD11B07550009A862E /* CommandReturnObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0A10F1B8DD00F91463 /* CommandReturnObject.cpp */; }; @@ -336,7 +335,6 @@ 4C08CDE811C81EF8001610A8 /* ThreadSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C08CDE711C81EF8001610A8 /* ThreadSpec.cpp */; }; 4C08CDEC11C81F1E001610A8 /* ThreadSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C08CDEB11C81F1E001610A8 /* ThreadSpec.h */; }; 4CA9637B11B6E99A00780E28 /* CommandObjectApropos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */; }; - 4CA9637C11B6E99A00780E28 /* CommandObjectApropos.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CA9637A11B6E99A00780E28 /* CommandObjectApropos.h */; }; 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 */; }; 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A357582116CFDEE00E8ED2F /* SBValueList.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -590,7 +588,6 @@ 26BC7CFA10F1B71400F91463 /* Stoppoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stoppoint.h; path = include/lldb/Breakpoint/Stoppoint.h; sourceTree = "<group>"; }; 26BC7CFB10F1B71400F91463 /* StoppointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StoppointLocation.h; path = include/lldb/Breakpoint/StoppointLocation.h; sourceTree = "<group>"; }; 26BC7CFC10F1B71400F91463 /* WatchpointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WatchpointLocation.h; path = include/lldb/Breakpoint/WatchpointLocation.h; sourceTree = "<group>"; }; - 26BC7D1010F1B76300F91463 /* CommandObjectAdd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectAdd.h; path = source/Commands/CommandObjectAdd.h; sourceTree = "<group>"; }; 26BC7D1110F1B76300F91463 /* CommandObjectAlias.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectAlias.h; path = source/Commands/CommandObjectAlias.h; sourceTree = "<group>"; }; 26BC7D1210F1B76300F91463 /* CommandObjectAppend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectAppend.h; path = source/Commands/CommandObjectAppend.h; sourceTree = "<group>"; }; 26BC7D1410F1B76300F91463 /* CommandObjectBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectBreakpoint.h; path = source/Commands/CommandObjectBreakpoint.h; sourceTree = "<group>"; }; @@ -605,7 +602,6 @@ 26BC7D1F10F1B76300F91463 /* CommandObjectProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectProcess.h; path = source/Commands/CommandObjectProcess.h; sourceTree = "<group>"; }; 26BC7D2010F1B76300F91463 /* CommandObjectQuit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectQuit.h; path = source/Commands/CommandObjectQuit.h; sourceTree = "<group>"; }; 26BC7D2210F1B76300F91463 /* CommandObjectRegister.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectRegister.h; path = source/Commands/CommandObjectRegister.h; sourceTree = "<group>"; }; - 26BC7D2310F1B76300F91463 /* CommandObjectRemove.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectRemove.h; path = source/Commands/CommandObjectRemove.h; sourceTree = "<group>"; }; 26BC7D2410F1B76300F91463 /* CommandObjectScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectScript.h; path = source/Interpreter/CommandObjectScript.h; sourceTree = "<group>"; }; 26BC7D2510F1B76300F91463 /* CommandObjectSelect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSelect.h; path = source/Commands/CommandObjectSelect.h; sourceTree = "<group>"; }; 26BC7D2610F1B76300F91463 /* CommandObjectSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSet.h; path = source/Commands/CommandObjectSet.h; sourceTree = "<group>"; }; @@ -615,7 +611,6 @@ 26BC7D2A10F1B76300F91463 /* CommandObjectSourceFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSourceFile.h; path = source/Commands/CommandObjectSourceFile.h; sourceTree = "<group>"; }; 26BC7D2C10F1B76300F91463 /* CommandObjectSyntax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSyntax.h; path = source/Commands/CommandObjectSyntax.h; sourceTree = "<group>"; }; 26BC7D2D10F1B76300F91463 /* CommandObjectThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectThread.h; path = source/Commands/CommandObjectThread.h; sourceTree = "<group>"; }; - 26BC7D2E10F1B76300F91463 /* CommandObjectTranslate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectTranslate.h; path = source/Commands/CommandObjectTranslate.h; sourceTree = "<group>"; }; 26BC7D2F10F1B76300F91463 /* CommandObjectVariable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectVariable.h; path = source/Commands/CommandObjectVariable.h; sourceTree = "<group>"; }; 26BC7D5010F1B77400F91463 /* Address.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Address.h; path = include/lldb/Core/Address.h; sourceTree = "<group>"; }; 26BC7D5110F1B77400F91463 /* AddressRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AddressRange.h; path = include/lldb/Core/AddressRange.h; sourceTree = "<group>"; }; @@ -677,7 +672,6 @@ 26BC7DD410F1B7D500F91463 /* Host.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Host.h; path = include/lldb/Host/Host.h; sourceTree = "<group>"; }; 26BC7DD510F1B7D500F91463 /* Mutex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Mutex.h; path = include/lldb/Host/Mutex.h; sourceTree = "<group>"; }; 26BC7DD610F1B7D500F91463 /* Predicate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Predicate.h; path = include/lldb/Host/Predicate.h; sourceTree = "<group>"; }; - 26BC7DE110F1B7F900F91463 /* CommandContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandContext.h; path = include/lldb/Interpreter/CommandContext.h; sourceTree = "<group>"; }; 26BC7DE210F1B7F900F91463 /* CommandInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandInterpreter.h; path = include/lldb/Interpreter/CommandInterpreter.h; sourceTree = "<group>"; }; 26BC7DE310F1B7F900F91463 /* CommandObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObject.h; path = include/lldb/Interpreter/CommandObject.h; sourceTree = "<group>"; }; 26BC7DE410F1B7F900F91463 /* CommandReturnObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandReturnObject.h; path = include/lldb/Interpreter/CommandReturnObject.h; sourceTree = "<group>"; }; @@ -712,7 +706,6 @@ 26BC7E1610F1B83100F91463 /* Stoppoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Stoppoint.cpp; path = source/Breakpoint/Stoppoint.cpp; sourceTree = "<group>"; }; 26BC7E1710F1B83100F91463 /* StoppointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StoppointLocation.cpp; path = source/Breakpoint/StoppointLocation.cpp; sourceTree = "<group>"; }; 26BC7E1810F1B83100F91463 /* WatchpointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WatchpointLocation.cpp; path = source/Breakpoint/WatchpointLocation.cpp; sourceTree = "<group>"; }; - 26BC7E2910F1B84700F91463 /* CommandObjectAdd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectAdd.cpp; path = source/Commands/CommandObjectAdd.cpp; sourceTree = "<group>"; }; 26BC7E2A10F1B84700F91463 /* CommandObjectAlias.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectAlias.cpp; path = source/Commands/CommandObjectAlias.cpp; sourceTree = "<group>"; }; 26BC7E2B10F1B84700F91463 /* CommandObjectAppend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectAppend.cpp; path = source/Commands/CommandObjectAppend.cpp; sourceTree = "<group>"; }; 26BC7E2D10F1B84700F91463 /* CommandObjectBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectBreakpoint.cpp; path = source/Commands/CommandObjectBreakpoint.cpp; sourceTree = "<group>"; }; @@ -727,7 +720,6 @@ 26BC7E3810F1B84700F91463 /* CommandObjectProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectProcess.cpp; path = source/Commands/CommandObjectProcess.cpp; sourceTree = "<group>"; }; 26BC7E3910F1B84700F91463 /* CommandObjectQuit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectQuit.cpp; path = source/Commands/CommandObjectQuit.cpp; sourceTree = "<group>"; }; 26BC7E3B10F1B84700F91463 /* CommandObjectRegister.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectRegister.cpp; path = source/Commands/CommandObjectRegister.cpp; sourceTree = "<group>"; }; - 26BC7E3C10F1B84700F91463 /* CommandObjectRemove.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectRemove.cpp; path = source/Commands/CommandObjectRemove.cpp; sourceTree = "<group>"; }; 26BC7E3D10F1B84700F91463 /* CommandObjectScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectScript.cpp; path = source/Interpreter/CommandObjectScript.cpp; sourceTree = "<group>"; }; 26BC7E3E10F1B84700F91463 /* CommandObjectSelect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSelect.cpp; path = source/Commands/CommandObjectSelect.cpp; sourceTree = "<group>"; }; 26BC7E3F10F1B84700F91463 /* CommandObjectSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSet.cpp; path = source/Commands/CommandObjectSet.cpp; sourceTree = "<group>"; }; @@ -737,7 +729,6 @@ 26BC7E4310F1B84700F91463 /* CommandObjectSourceFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSourceFile.cpp; path = source/Commands/CommandObjectSourceFile.cpp; sourceTree = "<group>"; }; 26BC7E4510F1B84700F91463 /* CommandObjectSyntax.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSyntax.cpp; path = source/Commands/CommandObjectSyntax.cpp; sourceTree = "<group>"; }; 26BC7E4610F1B84700F91463 /* CommandObjectThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectThread.cpp; path = source/Commands/CommandObjectThread.cpp; sourceTree = "<group>"; }; - 26BC7E4710F1B84700F91463 /* CommandObjectTranslate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectTranslate.cpp; path = source/Commands/CommandObjectTranslate.cpp; sourceTree = "<group>"; }; 26BC7E4810F1B84700F91463 /* CommandObjectVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectVariable.cpp; path = source/Commands/CommandObjectVariable.cpp; sourceTree = "<group>"; }; 26BC7E6910F1B85900F91463 /* Address.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Address.cpp; path = source/Core/Address.cpp; sourceTree = "<group>"; }; 26BC7E6A10F1B85900F91463 /* AddressRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AddressRange.cpp; path = source/Core/AddressRange.cpp; sourceTree = "<group>"; }; @@ -806,7 +797,6 @@ 26BC7EF710F1B8AD00F91463 /* CFCReleaser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFCReleaser.h; path = source/Host/macosx/cfcpp/CFCReleaser.h; sourceTree = "<group>"; }; 26BC7EF810F1B8AD00F91463 /* CFCString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFCString.cpp; path = source/Host/macosx/cfcpp/CFCString.cpp; sourceTree = "<group>"; }; 26BC7EF910F1B8AD00F91463 /* CFCString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFCString.h; path = source/Host/macosx/cfcpp/CFCString.h; sourceTree = "<group>"; }; - 26BC7F0710F1B8DD00F91463 /* CommandContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandContext.cpp; path = source/Interpreter/CommandContext.cpp; sourceTree = "<group>"; }; 26BC7F0810F1B8DD00F91463 /* CommandInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandInterpreter.cpp; path = source/Interpreter/CommandInterpreter.cpp; sourceTree = "<group>"; }; 26BC7F0910F1B8DD00F91463 /* CommandObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObject.cpp; path = source/Interpreter/CommandObject.cpp; sourceTree = "<group>"; }; 26BC7F0A10F1B8DD00F91463 /* CommandReturnObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandReturnObject.cpp; path = source/Interpreter/CommandReturnObject.cpp; sourceTree = "<group>"; }; @@ -1751,8 +1741,6 @@ 26BC7D0D10F1B71D00F91463 /* Commands */ = { isa = PBXGroup; children = ( - 26BC7D1010F1B76300F91463 /* CommandObjectAdd.h */, - 26BC7E2910F1B84700F91463 /* CommandObjectAdd.cpp */, 26BC7D1110F1B76300F91463 /* CommandObjectAlias.h */, 26BC7E2A10F1B84700F91463 /* CommandObjectAlias.cpp */, 26BC7D1210F1B76300F91463 /* CommandObjectAppend.h */, @@ -1793,8 +1781,6 @@ 26BC7E3910F1B84700F91463 /* CommandObjectQuit.cpp */, 26BC7D2210F1B76300F91463 /* CommandObjectRegister.h */, 26BC7E3B10F1B84700F91463 /* CommandObjectRegister.cpp */, - 26BC7D2310F1B76300F91463 /* CommandObjectRemove.h */, - 26BC7E3C10F1B84700F91463 /* CommandObjectRemove.cpp */, 26BC7D2410F1B76300F91463 /* CommandObjectScript.h */, 26BC7E3D10F1B84700F91463 /* CommandObjectScript.cpp */, 26BC7D2510F1B76300F91463 /* CommandObjectSelect.h */, @@ -1815,8 +1801,6 @@ 269416AD119A024800FF2715 /* CommandObjectTarget.cpp */, 26BC7D2D10F1B76300F91463 /* CommandObjectThread.h */, 26BC7E4610F1B84700F91463 /* CommandObjectThread.cpp */, - 26BC7D2E10F1B76300F91463 /* CommandObjectTranslate.h */, - 26BC7E4710F1B84700F91463 /* CommandObjectTranslate.cpp */, 9A8B4EA210FD515000C68FF2 /* CommandObjectUnalias.h */, 9A8B4EA310FD516400C68FF2 /* CommandObjectUnalias.cpp */, 26BC7D2F10F1B76300F91463 /* CommandObjectVariable.h */, @@ -1872,8 +1856,6 @@ 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */, 4C09CB73116BD98B00C7A725 /* CommandCompletions.h */, 4C09CB74116BD98B00C7A725 /* CommandCompletions.cpp */, - 26BC7DE110F1B7F900F91463 /* CommandContext.h */, - 26BC7F0710F1B8DD00F91463 /* CommandContext.cpp */, 26BC7DE210F1B7F900F91463 /* CommandInterpreter.h */, 26BC7F0810F1B8DD00F91463 /* CommandInterpreter.cpp */, 26BC7DE310F1B7F900F91463 /* CommandObject.h */, @@ -2193,7 +2175,6 @@ 9AA69DAF118A023300D753A0 /* SBInputReader.h in Headers */, 49F1A74A11B338AE003ED505 /* ClangExpressionDeclMap.h in Headers */, 49D7072711B5AD03001AD875 /* ClangASTSource.h in Headers */, - 4CA9637C11B6E99A00780E28 /* CommandObjectApropos.h in Headers */, 261B5A5511C3F2AD00AABD0A /* SharingPtr.h in Headers */, 4C08CDEC11C81F1E001610A8 /* ThreadSpec.h in Headers */, ); @@ -2462,7 +2443,6 @@ 26D5B0C711B07550009A862E /* CFCMutableDictionary.cpp in Sources */, 26D5B0C811B07550009A862E /* CFCMutableSet.cpp in Sources */, 26D5B0C911B07550009A862E /* CFCString.cpp in Sources */, - 26D5B0CA11B07550009A862E /* CommandContext.cpp in Sources */, 26D5B0CB11B07550009A862E /* CommandInterpreter.cpp in Sources */, 26D5B0CC11B07550009A862E /* CommandObject.cpp in Sources */, 26D5B0CD11B07550009A862E /* CommandReturnObject.cpp in Sources */, diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp index 482ecec1ce6..c93b46b0335 100644 --- a/lldb/source/API/SBAddress.cpp +++ b/lldb/source/API/SBAddress.cpp @@ -15,22 +15,22 @@ using namespace lldb; SBAddress::SBAddress () : - m_lldb_object_ap () + m_opaque_ap () { } SBAddress::SBAddress (const lldb_private::Address *lldb_object_ptr) : - m_lldb_object_ap () + m_opaque_ap () { if (lldb_object_ptr) - m_lldb_object_ap.reset (new lldb_private::Address(*lldb_object_ptr)); + m_opaque_ap.reset (new lldb_private::Address(*lldb_object_ptr)); } SBAddress::SBAddress (const SBAddress &rhs) : - m_lldb_object_ap () + m_opaque_ap () { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::Address(*rhs.m_lldb_object_ap.get())); + m_opaque_ap.reset (new lldb_private::Address(*rhs.m_opaque_ap.get())); } SBAddress::~SBAddress () @@ -43,7 +43,7 @@ SBAddress::operator = (const SBAddress &rhs) if (this != &rhs) { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::Address(*rhs.m_lldb_object_ap.get())); + m_opaque_ap.reset (new lldb_private::Address(*rhs.m_opaque_ap.get())); } return *this; } @@ -51,7 +51,7 @@ SBAddress::operator = (const SBAddress &rhs) bool SBAddress::IsValid () const { - return m_lldb_object_ap.get() != NULL && m_lldb_object_ap->IsValid(); + return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid(); } void @@ -59,21 +59,21 @@ SBAddress::SetAddress (const lldb_private::Address *lldb_object_ptr) { if (lldb_object_ptr) { - if (m_lldb_object_ap.get()) - *m_lldb_object_ap = *lldb_object_ptr; + if (m_opaque_ap.get()) + *m_opaque_ap = *lldb_object_ptr; else - m_lldb_object_ap.reset (new lldb_private::Address(*lldb_object_ptr)); + m_opaque_ap.reset (new lldb_private::Address(*lldb_object_ptr)); return; } - if (m_lldb_object_ap.get()) - m_lldb_object_ap->Clear(); + if (m_opaque_ap.get()) + m_opaque_ap->Clear(); } lldb::addr_t SBAddress::GetFileAddress () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetFileAddress(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetFileAddress(); else return LLDB_INVALID_ADDRESS; } @@ -81,8 +81,8 @@ SBAddress::GetFileAddress () const lldb::addr_t SBAddress::GetLoadAddress (const SBProcess &process) const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetLoadAddress(process.get()); + if (m_opaque_ap.get()) + return m_opaque_ap->GetLoadAddress(process.get()); else return LLDB_INVALID_ADDRESS; } @@ -90,12 +90,12 @@ SBAddress::GetLoadAddress (const SBProcess &process) const bool SBAddress::OffsetAddress (addr_t offset) { - if (m_lldb_object_ap.get()) + if (m_opaque_ap.get()) { - addr_t addr_offset = m_lldb_object_ap->GetOffset(); + addr_t addr_offset = m_opaque_ap->GetOffset(); if (addr_offset != LLDB_INVALID_ADDRESS) { - m_lldb_object_ap->SetOffset(addr_offset + offset); + m_opaque_ap->SetOffset(addr_offset + offset); return true; } } @@ -106,13 +106,13 @@ SBAddress::OffsetAddress (addr_t offset) const lldb_private::Address * SBAddress::operator->() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } const lldb_private::Address & SBAddress::operator*() const { - return *m_lldb_object_ap; + return *m_opaque_ap; } diff --git a/lldb/source/API/SBBlock.cpp b/lldb/source/API/SBBlock.cpp index 536febd99b7..2ca8e76a478 100644 --- a/lldb/source/API/SBBlock.cpp +++ b/lldb/source/API/SBBlock.cpp @@ -14,24 +14,24 @@ using namespace lldb; SBBlock::SBBlock () : - m_lldb_object_ptr (NULL) + m_opaque_ptr (NULL) { } SBBlock::SBBlock (lldb_private::Block *lldb_object_ptr) : - m_lldb_object_ptr (lldb_object_ptr) + m_opaque_ptr (lldb_object_ptr) { } SBBlock::~SBBlock () { - m_lldb_object_ptr = NULL; + m_opaque_ptr = NULL; } bool SBBlock::IsValid () const { - return m_lldb_object_ptr != NULL; + return m_opaque_ptr != NULL; } void @@ -39,7 +39,7 @@ SBBlock::AppendVariables (bool can_create, bool get_parent_variables, lldb_priva { if (IsValid()) { - m_lldb_object_ptr->AppendVariables (can_create, get_parent_variables, var_list); + m_opaque_ptr->AppendVariables (can_create, get_parent_variables, var_list); } } diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp index ad636f37838..f90d7ad37e6 100644 --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -62,18 +62,18 @@ public: SBBreakpoint::SBBreakpoint () : - m_break_sp () + m_opaque_sp () { } SBBreakpoint::SBBreakpoint (const SBBreakpoint& rhs) : - m_break_sp (rhs.m_break_sp) + m_opaque_sp (rhs.m_opaque_sp) { } SBBreakpoint::SBBreakpoint (const lldb::BreakpointSP &bp_sp) : - m_break_sp (bp_sp) + m_opaque_sp (bp_sp) { } @@ -86,7 +86,7 @@ SBBreakpoint::operator = (const SBBreakpoint& rhs) { if (this != &rhs) { - m_break_sp = rhs.m_break_sp; + m_opaque_sp = rhs.m_opaque_sp; } return *this; } @@ -94,8 +94,8 @@ SBBreakpoint::operator = (const SBBreakpoint& rhs) break_id_t SBBreakpoint::GetID () const { - if (m_break_sp) - return m_break_sp->GetID(); + if (m_opaque_sp) + return m_opaque_sp->GetID(); return LLDB_INVALID_BREAK_ID; } @@ -103,28 +103,24 @@ SBBreakpoint::GetID () const bool SBBreakpoint::IsValid() const { - return m_break_sp; + return m_opaque_sp; } void SBBreakpoint::Dump (FILE *f) { - if (m_break_sp) + if (m_opaque_sp && f) { - if (f == NULL) - f = SBDebugger::GetOutputFileHandle(); - if (f == NULL) - return; lldb_private::StreamFile str (f); - m_break_sp->Dump (&str); + m_opaque_sp->Dump (&str); } } void SBBreakpoint::ClearAllBreakpointSites () { - if (m_break_sp) - m_break_sp->ClearAllBreakpointSites (); + if (m_opaque_sp) + m_opaque_sp->ClearAllBreakpointSites (); } SBBreakpointLocation @@ -132,18 +128,18 @@ SBBreakpoint::FindLocationByAddress (addr_t vm_addr) { SBBreakpointLocation sb_bp_location; - if (m_break_sp) + if (m_opaque_sp) { if (vm_addr != LLDB_INVALID_ADDRESS) { Address address; - Process *sb_process = m_break_sp->GetTarget().GetProcessSP().get(); + Process *sb_process = m_opaque_sp->GetTarget().GetProcessSP().get(); if (sb_process == NULL || sb_process->ResolveLoadAddress (vm_addr, address) == false) { address.SetSection (NULL); address.SetOffset (vm_addr); } - sb_bp_location.SetLocation (m_break_sp->FindLocationByAddress (address)); + sb_bp_location.SetLocation (m_opaque_sp->FindLocationByAddress (address)); } } return sb_bp_location; @@ -154,18 +150,18 @@ SBBreakpoint::FindLocationIDByAddress (addr_t vm_addr) { break_id_t lldb_id = (break_id_t) 0; - if (m_break_sp) + if (m_opaque_sp) { if (vm_addr != LLDB_INVALID_ADDRESS) { Address address; - Process *sb_process = m_break_sp->GetTarget().GetProcessSP().get(); + Process *sb_process = m_opaque_sp->GetTarget().GetProcessSP().get(); if (sb_process == NULL || sb_process->ResolveLoadAddress (vm_addr, address) == false) { address.SetSection (NULL); address.SetOffset (vm_addr); } - lldb_id = m_break_sp->FindLocationIDByAddress (address); + lldb_id = m_opaque_sp->FindLocationIDByAddress (address); } } @@ -177,8 +173,8 @@ SBBreakpoint::FindLocationByID (break_id_t bp_loc_id) { SBBreakpointLocation sb_bp_location; - if (m_break_sp) - sb_bp_location.SetLocation (m_break_sp->FindLocationByID (bp_loc_id)); + if (m_opaque_sp) + sb_bp_location.SetLocation (m_opaque_sp->FindLocationByID (bp_loc_id)); return sb_bp_location; } @@ -188,8 +184,8 @@ SBBreakpoint::GetLocationAtIndex (uint32_t index) { SBBreakpointLocation sb_bp_location; - if (m_break_sp) - sb_bp_location.SetLocation (m_break_sp->GetLocationAtIndex (index)); + if (m_opaque_sp) + sb_bp_location.SetLocation (m_opaque_sp->GetLocationAtIndex (index)); return sb_bp_location; } @@ -197,13 +193,7 @@ SBBreakpoint::GetLocationAtIndex (uint32_t index) void SBBreakpoint::ListLocations (FILE* f, const char *description_level) { - if (f == NULL) - f = SBDebugger::GetOutputFileHandle(); - - if (f == NULL) - return; - - if (m_break_sp) + if (m_opaque_sp && f) { DescriptionLevel level; if (strcmp (description_level, "brief") == 0) @@ -218,10 +208,10 @@ SBBreakpoint::ListLocations (FILE* f, const char *description_level) StreamFile str (f); str.IndentMore(); - int num_locs = m_break_sp->GetNumLocations(); + int num_locs = m_opaque_sp->GetNumLocations(); for (int i = 0; i < num_locs; ++i) { - BreakpointLocation *loc = m_break_sp->GetLocationAtIndex (i).get(); + BreakpointLocation *loc = m_opaque_sp->GetLocationAtIndex (i).get(); loc->GetDescription (&str, level); str.EOL(); } @@ -231,15 +221,15 @@ SBBreakpoint::ListLocations (FILE* f, const char *description_level) void SBBreakpoint::SetEnabled (bool enable) { - if (m_break_sp) - m_break_sp->SetEnabled (enable); + if (m_opaque_sp) + m_opaque_sp->SetEnabled (enable); } bool SBBreakpoint::IsEnabled () { - if (m_break_sp) - return m_break_sp->IsEnabled(); + if (m_opaque_sp) + return m_opaque_sp->IsEnabled(); else return false; } @@ -247,15 +237,15 @@ SBBreakpoint::IsEnabled () void SBBreakpoint::SetIgnoreCount (int32_t count) { - if (m_break_sp) - m_break_sp->SetIgnoreCount (count); + if (m_opaque_sp) + m_opaque_sp->SetIgnoreCount (count); } int32_t SBBreakpoint::GetIgnoreCount () const { - if (m_break_sp) - return m_break_sp->GetIgnoreCount(); + if (m_opaque_sp) + return m_opaque_sp->GetIgnoreCount(); else return 0; } @@ -263,16 +253,16 @@ SBBreakpoint::GetIgnoreCount () const void SBBreakpoint::SetThreadID (tid_t sb_thread_id) { - if (m_break_sp) - m_break_sp->SetThreadID (sb_thread_id); + if (m_opaque_sp) + m_opaque_sp->SetThreadID (sb_thread_id); } tid_t SBBreakpoint::GetThreadID () { tid_t lldb_thread_id = LLDB_INVALID_THREAD_ID; - if (m_break_sp) - lldb_thread_id = m_break_sp->GetThreadID(); + if (m_opaque_sp) + lldb_thread_id = m_opaque_sp->GetThreadID(); return lldb_thread_id; } @@ -280,16 +270,16 @@ SBBreakpoint::GetThreadID () void SBBreakpoint::SetThreadIndex (uint32_t index) { - if (m_break_sp) - m_break_sp->GetOptions()->GetThreadSpec()->SetIndex (index); + if (m_opaque_sp) + m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex (index); } uint32_t SBBreakpoint::GetThreadIndex() const { - if (m_break_sp) + if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_break_sp->GetOptions()->GetThreadSpec(); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); if (thread_spec == NULL) return 0; else @@ -302,16 +292,16 @@ SBBreakpoint::GetThreadIndex() const void SBBreakpoint::SetThreadName (const char *thread_name) { - if (m_break_sp) - m_break_sp->GetOptions()->GetThreadSpec()->SetName (thread_name); + if (m_opaque_sp) + m_opaque_sp->GetOptions()->GetThreadSpec()->SetName (thread_name); } const char * SBBreakpoint::GetThreadName () const { - if (m_break_sp) + if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_break_sp->GetOptions()->GetThreadSpec(); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); if (thread_spec == NULL) return NULL; else @@ -323,16 +313,16 @@ SBBreakpoint::GetThreadName () const void SBBreakpoint::SetQueueName (const char *queue_name) { - if (m_break_sp) - m_break_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name); + if (m_opaque_sp) + m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name); } const char * SBBreakpoint::GetQueueName () const { - if (m_break_sp) + if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_break_sp->GetOptions()->GetThreadSpec(); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); if (thread_spec == NULL) return NULL; else @@ -344,8 +334,8 @@ SBBreakpoint::GetQueueName () const size_t SBBreakpoint::GetNumResolvedLocations() const { - if (m_break_sp) - return m_break_sp->GetNumResolvedLocations(); + if (m_opaque_sp) + return m_opaque_sp->GetNumResolvedLocations(); else return 0; } @@ -353,8 +343,8 @@ SBBreakpoint::GetNumResolvedLocations() const size_t SBBreakpoint::GetNumLocations() const { - if (m_break_sp) - return m_break_sp->GetNumLocations(); + if (m_opaque_sp) + return m_opaque_sp->GetNumLocations(); else return 0; } @@ -365,7 +355,7 @@ SBBreakpoint::GetDescription (FILE *f, const char *description_level, bool descr if (f == NULL) return; - if (m_break_sp) + if (m_opaque_sp) { DescriptionLevel level; if (strcmp (description_level, "brief") == 0) @@ -379,15 +369,15 @@ SBBreakpoint::GetDescription (FILE *f, const char *description_level, bool descr StreamFile str (f); - m_break_sp->GetDescription (&str, level); + m_opaque_sp->GetDescription (&str, level); str.EOL(); if (describe_locations) { //str.IndentMore(); - // int num_locs = m_break_sp->GetNumLocations(); + // int num_locs = m_opaque_sp->GetNumLocations(); // for (int i = 0; i < num_locs; ++i) // { - // BreakpointLocation *loc = m_break_sp->FindLocationByIndex (i); + // BreakpointLocation *loc = m_opaque_sp->FindLocationByIndex (i); // loc->GetDescription (&str, level); // str.EOL(); // } @@ -405,22 +395,22 @@ SBBreakpoint::PrivateBreakpointHitCallback lldb::user_id_t break_loc_id ) { - BreakpointSP bp_sp(ctx->context.target->GetBreakpointList().FindBreakpointByID(break_id)); + BreakpointSP bp_sp(ctx->exe_ctx.target->GetBreakpointList().FindBreakpointByID(break_id)); if (baton && bp_sp) { CallbackData *data = (CallbackData *)baton; lldb_private::Breakpoint *bp = bp_sp.get(); if (bp && data->callback) { - if (ctx->context.process) + if (ctx->exe_ctx.process) { - SBProcess sb_process (ctx->context.process->GetSP()); + SBProcess sb_process (ctx->exe_ctx.process->GetSP()); SBThread sb_thread; SBBreakpointLocation sb_location; assert (bp_sp); sb_location.SetLocation (bp_sp->FindLocationByID (break_loc_id)); - if (ctx->context.thread) - sb_thread.SetThread(ctx->context.thread->GetSP()); + if (ctx->exe_ctx.thread) + sb_thread.SetThread(ctx->exe_ctx.thread->GetSP()); return data->callback (data->callback_baton, sb_process, @@ -435,10 +425,10 @@ SBBreakpoint::PrivateBreakpointHitCallback void SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton) { - if (m_break_sp.get()) + if (m_opaque_sp.get()) { BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton)); - m_break_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false); + m_opaque_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false); } } @@ -446,24 +436,24 @@ SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton) lldb_private::Breakpoint * SBBreakpoint::operator->() const { - return m_break_sp.get(); + return m_opaque_sp.get(); } lldb_private::Breakpoint * SBBreakpoint::get() const { - return m_break_sp.get(); + return m_opaque_sp.get(); } lldb::BreakpointSP & SBBreakpoint::operator *() { - return m_break_sp; + return m_opaque_sp; } const lldb::BreakpointSP & SBBreakpoint::operator *() const { - return m_break_sp; + return m_opaque_sp; } diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp index b5e78596e87..f376f5368b5 100644 --- a/lldb/source/API/SBBreakpointLocation.cpp +++ b/lldb/source/API/SBBreakpointLocation.cpp @@ -31,7 +31,7 @@ SBBreakpointLocation::SBBreakpointLocation () } SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) : - m_break_loc_sp (break_loc_sp) + m_opaque_sp (break_loc_sp) { } @@ -42,7 +42,7 @@ SBBreakpointLocation::~SBBreakpointLocation () bool SBBreakpointLocation::IsValid() const { - return m_break_loc_sp.get() != NULL; + return m_opaque_sp.get() != NULL; } addr_t @@ -50,9 +50,9 @@ SBBreakpointLocation::GetLoadAddress () { addr_t ret_addr = LLDB_INVALID_ADDRESS; - if (m_break_loc_sp) + if (m_opaque_sp) { - ret_addr = m_break_loc_sp->GetLoadAddress(); + ret_addr = m_opaque_sp->GetLoadAddress(); } return ret_addr; @@ -61,17 +61,17 @@ SBBreakpointLocation::GetLoadAddress () void SBBreakpointLocation::SetEnabled (bool enabled) { - if (m_break_loc_sp) + if (m_opaque_sp) { - m_break_loc_sp->SetEnabled (enabled); + m_opaque_sp->SetEnabled (enabled); } } bool SBBreakpointLocation::IsEnabled () { - if (m_break_loc_sp) - return m_break_loc_sp->IsEnabled(); + if (m_opaque_sp) + return m_opaque_sp->IsEnabled(); else return false; } @@ -79,8 +79,8 @@ SBBreakpointLocation::IsEnabled () int32_t SBBreakpointLocation::GetIgnoreCount () { - if (m_break_loc_sp) - return m_break_loc_sp->GetIgnoreCount(); + if (m_opaque_sp) + return m_opaque_sp->GetIgnoreCount(); else return 0; } @@ -88,40 +88,39 @@ SBBreakpointLocation::GetIgnoreCount () void SBBreakpointLocation::SetIgnoreCount (int32_t n) { - if (m_break_loc_sp) - m_break_loc_sp->SetIgnoreCount (n); + if (m_opaque_sp) + m_opaque_sp->SetIgnoreCount (n); } void SBBreakpointLocation::SetThreadID (tid_t thread_id) { - if (m_break_loc_sp) - m_break_loc_sp->SetThreadID (thread_id); + if (m_opaque_sp) + m_opaque_sp->SetThreadID (thread_id); } tid_t SBBreakpointLocation::GetThreadID () { tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID; - if (m_break_loc_sp) - sb_thread_id = m_break_loc_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID(); - + if (m_opaque_sp) + sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID(); return sb_thread_id; } void SBBreakpointLocation::SetThreadIndex (uint32_t index) { - if (m_break_loc_sp) - m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index); + if (m_opaque_sp) + m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index); } uint32_t SBBreakpointLocation::GetThreadIndex() const { - if (m_break_loc_sp) + if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); if (thread_spec == NULL) return 0; else @@ -134,16 +133,16 @@ SBBreakpointLocation::GetThreadIndex() const void SBBreakpointLocation::SetThreadName (const char *thread_name) { - if (m_break_loc_sp) - m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name); + if (m_opaque_sp) + m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name); } const char * SBBreakpointLocation::GetThreadName () const { - if (m_break_loc_sp) + if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); if (thread_spec == NULL) return NULL; else @@ -155,16 +154,16 @@ SBBreakpointLocation::GetThreadName () const void SBBreakpointLocation::SetQueueName (const char *queue_name) { - if (m_break_loc_sp) - m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name); + if (m_opaque_sp) + m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name); } const char * SBBreakpointLocation::GetQueueName () const { - if (m_break_loc_sp) + if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); if (thread_spec == NULL) return NULL; else @@ -176,8 +175,8 @@ SBBreakpointLocation::GetQueueName () const bool SBBreakpointLocation::IsResolved () { - if (m_break_loc_sp) - return m_break_loc_sp->IsResolved(); + if (m_opaque_sp) + return m_opaque_sp->IsResolved(); else return false; } @@ -185,11 +184,11 @@ SBBreakpointLocation::IsResolved () void SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp) { - if (m_break_loc_sp) + if (m_opaque_sp) { // Uninstall the callbacks? } - m_break_loc_sp = break_loc_sp; + m_opaque_sp = break_loc_sp; } void @@ -198,7 +197,7 @@ SBBreakpointLocation::GetDescription (FILE *f, const char *description_level) if (f == NULL) return; - if (m_break_loc_sp) + if (m_opaque_sp) { DescriptionLevel level; if (strcmp (description_level, "brief") == 0) @@ -212,7 +211,7 @@ SBBreakpointLocation::GetDescription (FILE *f, const char *description_level) StreamFile str (f); - m_break_loc_sp->GetDescription (&str, level); + m_opaque_sp->GetDescription (&str, level); str.EOL(); } } @@ -221,8 +220,8 @@ SBBreakpoint SBBreakpointLocation::GetBreakpoint () { SBBreakpoint sb_bp; - if (m_break_loc_sp) - *sb_bp = m_break_loc_sp->GetBreakpoint ().GetSP(); + if (m_opaque_sp) + *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP(); return sb_bp; } diff --git a/lldb/source/API/SBBroadcaster.cpp b/lldb/source/API/SBBroadcaster.cpp index 14c53578e1a..bbad8e2c5d3 100644 --- a/lldb/source/API/SBBroadcaster.cpp +++ b/lldb/source/API/SBBroadcaster.cpp @@ -19,124 +19,124 @@ using namespace lldb_private; SBBroadcaster::SBBroadcaster () : - m_lldb_object (NULL), - m_lldb_object_owned (false) + m_opaque (NULL), + m_opaque_owned (false) { } SBBroadcaster::SBBroadcaster (const char *name) : - m_lldb_object (new Broadcaster (name)), - m_lldb_object_owned (true) + m_opaque (new Broadcaster (name)), + m_opaque_owned (true) { } SBBroadcaster::SBBroadcaster (lldb_private::Broadcaster *broadcaster, bool owns) : - m_lldb_object (broadcaster), - m_lldb_object_owned (owns) + m_opaque (broadcaster), + m_opaque_owned (owns) { } SBBroadcaster::~SBBroadcaster() { - SetLLDBObjectPtr (NULL, false); + reset (NULL, false); } void SBBroadcaster::BroadcastEventByType (uint32_t event_type, bool unique) { - if (m_lldb_object == NULL) + if (m_opaque == NULL) return; if (unique) - m_lldb_object->BroadcastEventIfUnique (event_type); + m_opaque->BroadcastEventIfUnique (event_type); else - m_lldb_object->BroadcastEvent (event_type); + m_opaque->BroadcastEvent (event_type); } void SBBroadcaster::BroadcastEvent (const SBEvent &event, bool unique) { - if (m_lldb_object == NULL) + if (m_opaque == NULL) return; - EventSP event_sp = event.GetSharedPtr (); + EventSP event_sp = event.GetSP (); if (unique) - m_lldb_object->BroadcastEventIfUnique (event_sp); + m_opaque->BroadcastEventIfUnique (event_sp); else - m_lldb_object->BroadcastEvent (event_sp); + m_opaque->BroadcastEvent (event_sp); } void SBBroadcaster::AddInitialEventsToListener (const SBListener &listener, uint32_t requested_events) { - if (m_lldb_object) - m_lldb_object->AddInitialEventsToListener (listener.get(), requested_events); + if (m_opaque) + m_opaque->AddInitialEventsToListener (listener.get(), requested_events); } uint32_t SBBroadcaster::AddListener (const SBListener &listener, uint32_t event_mask) { - if (m_lldb_object) - return m_lldb_object->AddListener (listener.get(), event_mask); + if (m_opaque) + return m_opaque->AddListener (listener.get(), event_mask); return 0; } const char * SBBroadcaster::GetName () { - if (m_lldb_object) - return m_lldb_object->GetBroadcasterName().AsCString(); + if (m_opaque) + return m_opaque->GetBroadcasterName().AsCString(); return NULL; } bool SBBroadcaster::EventTypeHasListeners (uint32_t event_type) { - if (m_lldb_object) - return m_lldb_object->EventTypeHasListeners (event_type); + if (m_opaque) + return m_opaque->EventTypeHasListeners (event_type); return false; } bool SBBroadcaster::RemoveListener (const SBListener &listener, uint32_t event_mask) { - if (m_lldb_object) - return m_lldb_object->RemoveListener (listener.get(), event_mask); + if (m_opaque) + return m_opaque->RemoveListener (listener.get(), event_mask); return false; } Broadcaster * -SBBroadcaster::GetLLDBObjectPtr () const +SBBroadcaster::get () const { - return m_lldb_object; + return m_opaque; } void -SBBroadcaster::SetLLDBObjectPtr (Broadcaster *broadcaster, bool owns) +SBBroadcaster::reset (Broadcaster *broadcaster, bool owns) { - if (m_lldb_object && m_lldb_object_owned) - delete m_lldb_object; - m_lldb_object = broadcaster; - m_lldb_object_owned = owns; + if (m_opaque && m_opaque_owned) + delete m_opaque; + m_opaque = broadcaster; + m_opaque_owned = owns; } bool SBBroadcaster::IsValid () const { - return m_lldb_object != NULL; + return m_opaque != NULL; } bool SBBroadcaster::operator == (const SBBroadcaster &rhs) const { - return m_lldb_object == rhs.m_lldb_object; + return m_opaque == rhs.m_opaque; } bool SBBroadcaster::operator != (const SBBroadcaster &rhs) const { - return m_lldb_object != rhs.m_lldb_object; + return m_opaque != rhs.m_opaque; } diff --git a/lldb/source/API/SBCommandContext.cpp b/lldb/source/API/SBCommandContext.cpp index c022a71082a..35bd6bb7c84 100644 --- a/lldb/source/API/SBCommandContext.cpp +++ b/lldb/source/API/SBCommandContext.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/API/SBCommandContext.h" @@ -17,8 +17,8 @@ using namespace lldb; using namespace lldb_private; -SBCommandContext::SBCommandContext (CommandContext *lldb_object) : - m_lldb_object (lldb_object) +SBCommandContext::SBCommandContext (Debugger *lldb_object) : + m_opaque (lldb_object) { } @@ -29,6 +29,6 @@ SBCommandContext::~SBCommandContext () bool SBCommandContext::IsValid () const { - return m_lldb_object != NULL; + return m_opaque != NULL; } diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index f7c0d521393..27e542c0a3e 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -30,8 +30,8 @@ using namespace lldb; using namespace lldb_private; -SBCommandInterpreter::SBCommandInterpreter (CommandInterpreter &interpreter) : - m_interpreter (interpreter) +SBCommandInterpreter::SBCommandInterpreter (CommandInterpreter *interpreter) : + m_opaque_ptr (interpreter) { } @@ -40,28 +40,49 @@ SBCommandInterpreter::~SBCommandInterpreter () } bool +SBCommandInterpreter::IsValid() const +{ + return m_opaque_ptr != NULL; +} + + +bool SBCommandInterpreter::CommandExists (const char *cmd) { - return m_interpreter.CommandExists (cmd); + if (m_opaque_ptr) + return m_opaque_ptr->CommandExists (cmd); + return false; } bool SBCommandInterpreter::AliasExists (const char *cmd) { - return m_interpreter.AliasExists (cmd); + if (m_opaque_ptr) + return m_opaque_ptr->AliasExists (cmd); + return false; } bool SBCommandInterpreter::UserCommandExists (const char *cmd) { - return m_interpreter.UserCommandExists (cmd); + if (m_opaque_ptr) + return m_opaque_ptr->UserCommandExists (cmd); + return false; } lldb::ReturnStatus SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnObject &result, bool add_to_history) { result.Clear(); - m_interpreter.HandleCommand (command_line, add_to_history, result.GetLLDBObjectRef()); + if (m_opaque_ptr) + { + m_opaque_ptr->HandleCommand (command_line, add_to_history, result.ref()); + } + else + { + result->AppendError ("SBCommandInterpreter is not valid"); + result->SetStatus (eReturnStatusFailed); + } return result.GetStatus(); } @@ -73,64 +94,79 @@ SBCommandInterpreter::HandleCompletion (const char *current_line, int max_return_elements, SBStringList &matches) { - int num_completions; - lldb_private::StringList lldb_matches; - num_completions = m_interpreter.HandleCompletion (current_line, cursor, last_char, match_start_point, - max_return_elements, lldb_matches); - - SBStringList temp_list (&lldb_matches); - matches.AppendList (temp_list); + int num_completions = 0; + if (m_opaque_ptr) + { + lldb_private::StringList lldb_matches; + num_completions = m_opaque_ptr->HandleCompletion (current_line, cursor, last_char, match_start_point, + max_return_elements, lldb_matches); + SBStringList temp_list (&lldb_matches); + matches.AppendList (temp_list); + } return num_completions; } const char ** SBCommandInterpreter::GetEnvironmentVariables () { - const Args *env_vars = m_interpreter.GetEnvironmentVariables(); - if (env_vars) - return env_vars->GetConstArgumentVector (); + if (m_opaque_ptr) + { + const Args *env_vars = m_opaque_ptr->GetEnvironmentVariables(); + if (env_vars) + return env_vars->GetConstArgumentVector (); + } return NULL; } bool SBCommandInterpreter::HasCommands () { - return m_interpreter.HasCommands(); + if (m_opaque_ptr) + return m_opaque_ptr->HasCommands(); + return false; } bool SBCommandInterpreter::HasAliases () { - return m_interpreter.HasAliases(); + if (m_opaque_ptr) + return m_opaque_ptr->HasAliases(); + return false; } bool SBCommandInterpreter::HasUserCommands () { - return m_interpreter.HasUserCommands (); + if (m_opaque_ptr) + return m_opaque_ptr->HasUserCommands (); + return false; } bool SBCommandInterpreter::HasAliasOptions () { - return m_interpreter.HasAliasOptions (); + if (m_opaque_ptr) + return m_opaque_ptr->HasAliasOptions (); + return false; } bool SBCommandInterpreter::HasInterpreterVariables () { - return m_interpreter.HasInterpreterVariables (); + if (m_opaque_ptr) + return m_opaque_ptr->HasInterpreterVariables (); + return false; } SBProcess SBCommandInterpreter::GetProcess () { SBProcess process; - CommandContext *context = m_interpreter.Context(); - if (context) + if (m_opaque_ptr) { - Target *target = context->GetTarget(); + Debugger &debugger = m_opaque_ptr->GetDebugger(); + Target *target = debugger.GetCurrentTarget().get(); if (target) process.SetProcess(target->GetProcessSP()); } @@ -140,7 +176,7 @@ SBCommandInterpreter::GetProcess () ssize_t SBCommandInterpreter::WriteToScriptInterpreter (const char *src) { - if (src) + if (m_opaque_ptr && src && src[0]) return WriteToScriptInterpreter (src, strlen(src)); return 0; } @@ -148,9 +184,9 @@ SBCommandInterpreter::WriteToScriptInterpreter (const char *src) ssize_t SBCommandInterpreter::WriteToScriptInterpreter (const char *src, size_t src_len) { - if (src && src[0]) + if (m_opaque_ptr && src && src[0]) { - ScriptInterpreter *script_interpreter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *script_interpreter = m_opaque_ptr->GetScriptInterpreter(); if (script_interpreter) return ::write (script_interpreter->GetMasterFileDescriptor(), src, src_len); } @@ -159,35 +195,58 @@ SBCommandInterpreter::WriteToScriptInterpreter (const char *src, size_t src_len) CommandInterpreter * -SBCommandInterpreter::GetLLDBObjectPtr () +SBCommandInterpreter::get () { - return &m_interpreter; + return m_opaque_ptr; } CommandInterpreter & -SBCommandInterpreter::GetLLDBObjectRef () +SBCommandInterpreter::ref () { - return m_interpreter; + assert (m_opaque_ptr); + return *m_opaque_ptr; +} + +void +SBCommandInterpreter::reset (lldb_private::CommandInterpreter *interpreter) +{ + m_opaque_ptr = interpreter; } void SBCommandInterpreter::SourceInitFileInHomeDirectory (SBCommandReturnObject &result) { result.Clear(); - m_interpreter.SourceInitFile (false, result.GetLLDBObjectRef()); + if (m_opaque_ptr) + { + m_opaque_ptr->SourceInitFile (false, result.ref()); + } + else + { + result->AppendError ("SBCommandInterpreter is not valid"); + result->SetStatus (eReturnStatusFailed); + } } void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory (SBCommandReturnObject &result) { result.Clear(); - m_interpreter.SourceInitFile (true, result.GetLLDBObjectRef()); + if (m_opaque_ptr) + { + m_opaque_ptr->SourceInitFile (true, result.ref()); + } + else + { + result->AppendError ("SBCommandInterpreter is not valid"); + result->SetStatus (eReturnStatusFailed); + } } SBBroadcaster SBCommandInterpreter::GetBroadcaster () { - SBBroadcaster broadcaster (&m_interpreter, false); + SBBroadcaster broadcaster (m_opaque_ptr, false); return broadcaster; } diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index b345a04cdb6..5742c5c93da 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -12,53 +12,54 @@ #include "lldb/API/SBCommandReturnObject.h" using namespace lldb; +using namespace lldb_private; SBCommandReturnObject::SBCommandReturnObject () : - m_return_object_ap (new lldb_private::CommandReturnObject ()) + m_opaque_ap (new CommandReturnObject ()) { } SBCommandReturnObject::~SBCommandReturnObject () { - // m_return_object_ap will automatically delete any pointer it owns + // m_opaque_ap will automatically delete any pointer it owns } bool SBCommandReturnObject::IsValid() const { - return m_return_object_ap.get() != NULL; + return m_opaque_ap.get() != NULL; } const char * SBCommandReturnObject::GetOutput () { - if (m_return_object_ap.get()) - return m_return_object_ap->GetOutputStream().GetData(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetOutputStream().GetData(); return NULL; } const char * SBCommandReturnObject::GetError () { - if (m_return_object_ap.get()) - return m_return_object_ap->GetErrorStream().GetData(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetErrorStream().GetData(); return NULL; } size_t SBCommandReturnObject::GetOutputSize () { - if (m_return_object_ap.get()) - return m_return_object_ap->GetOutputStream().GetSize(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetOutputStream().GetSize(); return 0; } size_t SBCommandReturnObject::GetErrorSize () { - if (m_return_object_ap.get()) - return m_return_object_ap->GetErrorStream().GetSize(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetErrorStream().GetSize(); return 0; } @@ -89,60 +90,73 @@ SBCommandReturnObject::PutError (FILE *fh) void SBCommandReturnObject::Clear() { - if (m_return_object_ap.get()) - m_return_object_ap->Clear(); + if (m_opaque_ap.get()) + m_opaque_ap->Clear(); } lldb::ReturnStatus SBCommandReturnObject::GetStatus() { - if (m_return_object_ap.get()) - return m_return_object_ap->GetStatus(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetStatus(); return lldb::eReturnStatusInvalid; } bool SBCommandReturnObject::Succeeded () { - if (m_return_object_ap.get()) - return m_return_object_ap->Succeeded(); + if (m_opaque_ap.get()) + return m_opaque_ap->Succeeded(); return false; } bool SBCommandReturnObject::HasResult () { - if (m_return_object_ap.get()) - return m_return_object_ap->HasResult(); + if (m_opaque_ap.get()) + return m_opaque_ap->HasResult(); return false; } void SBCommandReturnObject::AppendMessage (const char *message) { - if (m_return_object_ap.get()) - m_return_object_ap->AppendMessage (message); + if (m_opaque_ap.get()) + m_opaque_ap->AppendMessage (message); } -lldb_private::CommandReturnObject * -SBCommandReturnObject::GetLLDBObjectPtr() +CommandReturnObject * +SBCommandReturnObject::operator ->() const { - return m_return_object_ap.get(); + return m_opaque_ap.get(); +} + +CommandReturnObject * +SBCommandReturnObject::get() const +{ + return m_opaque_ap.get(); +} + +CommandReturnObject & +SBCommandReturnObject::operator *() const +{ + assert(m_opaque_ap.get()); + return *(m_opaque_ap.get()); } -lldb_private::CommandReturnObject & -SBCommandReturnObject::GetLLDBObjectRef() +CommandReturnObject & +SBCommandReturnObject::ref() const { - assert(m_return_object_ap.get()); - return *(m_return_object_ap.get()); + assert(m_opaque_ap.get()); + return *(m_opaque_ap.get()); } void -SBCommandReturnObject::SetLLDBObjectPtr (lldb_private::CommandReturnObject *ptr) +SBCommandReturnObject::SetLLDBObjectPtr (CommandReturnObject *ptr) { - if (m_return_object_ap.get()) - m_return_object_ap.reset (ptr); + if (m_opaque_ap.get()) + m_opaque_ap.reset (ptr); } diff --git a/lldb/source/API/SBCommunication.cpp b/lldb/source/API/SBCommunication.cpp index e2a791750a8..b1ae37b3315 100644 --- a/lldb/source/API/SBCommunication.cpp +++ b/lldb/source/API/SBCommunication.cpp @@ -18,57 +18,57 @@ using namespace lldb_private; SBCommunication::SBCommunication() : - m_lldb_object (NULL), - m_lldb_object_owned (false) + m_opaque (NULL), + m_opaque_owned (false) { } SBCommunication::SBCommunication(const char * broadcaster_name) : - m_lldb_object (new Communication (broadcaster_name)), - m_lldb_object_owned (true) + m_opaque (new Communication (broadcaster_name)), + m_opaque_owned (true) { } SBCommunication::~SBCommunication() { - if (m_lldb_object && m_lldb_object_owned) - delete m_lldb_object; - m_lldb_object = NULL; - m_lldb_object_owned = false; + if (m_opaque && m_opaque_owned) + delete m_opaque; + m_opaque = NULL; + m_opaque_owned = false; } ConnectionStatus SBCommunication::CheckIfBytesAvailable () { - if (m_lldb_object) - return m_lldb_object->BytesAvailable (0, NULL); + if (m_opaque) + return m_opaque->BytesAvailable (0, NULL); return eConnectionStatusNoConnection; } ConnectionStatus SBCommunication::WaitForBytesAvailableInfinite () { - if (m_lldb_object) - return m_lldb_object->BytesAvailable (UINT32_MAX, NULL); + if (m_opaque) + return m_opaque->BytesAvailable (UINT32_MAX, NULL); return eConnectionStatusNoConnection; } ConnectionStatus SBCommunication::WaitForBytesAvailableWithTimeout (uint32_t timeout_usec) { - if (m_lldb_object) - return m_lldb_object->BytesAvailable (timeout_usec, NULL); + if (m_opaque) + return m_opaque->BytesAvailable (timeout_usec, NULL); return eConnectionStatusNoConnection; } ConnectionStatus SBCommunication::Connect (const char *url) { - if (m_lldb_object) + if (m_opaque) { - if (!m_lldb_object->HasConnection ()) - m_lldb_object->SetConnection (new ConnectionFileDescriptor()); - return m_lldb_object->Connect (url, NULL); + if (!m_opaque->HasConnection ()) + m_opaque->SetConnection (new ConnectionFileDescriptor()); + return m_opaque->Connect (url, NULL); } return eConnectionStatusNoConnection; } @@ -76,15 +76,15 @@ SBCommunication::Connect (const char *url) ConnectionStatus SBCommunication::AdoptFileDesriptor (int fd, bool owns_fd) { - if (m_lldb_object) + if (m_opaque) { - if (m_lldb_object->HasConnection ()) + if (m_opaque->HasConnection ()) { - if (m_lldb_object->IsConnected()) - m_lldb_object->Disconnect (); + if (m_opaque->IsConnected()) + m_opaque->Disconnect (); } - m_lldb_object->SetConnection (new ConnectionFileDescriptor (fd, owns_fd)); - if (m_lldb_object->IsConnected()) + m_opaque->SetConnection (new ConnectionFileDescriptor (fd, owns_fd)); + if (m_opaque->IsConnected()) return eConnectionStatusSuccess; else return eConnectionStatusLostConnection; @@ -96,24 +96,24 @@ SBCommunication::AdoptFileDesriptor (int fd, bool owns_fd) ConnectionStatus SBCommunication::Disconnect () { - if (m_lldb_object) - return m_lldb_object->Disconnect (); + if (m_opaque) + return m_opaque->Disconnect (); return eConnectionStatusNoConnection; } bool SBCommunication::IsConnected () const { - if (m_lldb_object) - return m_lldb_object->IsConnected (); + if (m_opaque) + return m_opaque->IsConnected (); return false; } size_t SBCommunication::Read (void *dst, size_t dst_len, uint32_t timeout_usec, ConnectionStatus &status) { - if (m_lldb_object) - return m_lldb_object->Read (dst, dst_len, timeout_usec, status, NULL); + if (m_opaque) + return m_opaque->Read (dst, dst_len, timeout_usec, status, NULL); status = eConnectionStatusNoConnection; return 0; } @@ -122,8 +122,8 @@ SBCommunication::Read (void *dst, size_t dst_len, uint32_t timeout_usec, Connect size_t SBCommunication::Write (const void *src, size_t src_len, ConnectionStatus &status) { - if (m_lldb_object) - return m_lldb_object->Write (src, src_len, status, NULL); + if (m_opaque) + return m_opaque->Write (src, src_len, status, NULL); status = eConnectionStatusNoConnection; return 0; } @@ -131,8 +131,8 @@ SBCommunication::Write (const void *src, size_t src_len, ConnectionStatus &statu bool SBCommunication::ReadThreadStart () { - if (m_lldb_object) - return m_lldb_object->StartReadThread (); + if (m_opaque) + return m_opaque->StartReadThread (); return false; } @@ -140,16 +140,16 @@ SBCommunication::ReadThreadStart () bool SBCommunication::ReadThreadStop () { - if (m_lldb_object) - return m_lldb_object->StopReadThread (); + if (m_opaque) + return m_opaque->StopReadThread (); return false; } bool SBCommunication::ReadThreadIsRunning () { - if (m_lldb_object) - return m_lldb_object->ReadThreadIsRunning (); + if (m_opaque) + return m_opaque->ReadThreadIsRunning (); return false; } @@ -160,9 +160,9 @@ SBCommunication::SetReadThreadBytesReceivedCallback void *callback_baton ) { - if (m_lldb_object) + if (m_opaque) { - m_lldb_object->SetReadThreadBytesReceivedCallback (callback, callback_baton); + m_opaque->SetReadThreadBytesReceivedCallback (callback, callback_baton); return true; } return false; @@ -171,7 +171,7 @@ SBCommunication::SetReadThreadBytesReceivedCallback SBBroadcaster SBCommunication::GetBroadcaster () { - SBBroadcaster broadcaster (m_lldb_object, false); + SBBroadcaster broadcaster (m_opaque, false); return broadcaster; } @@ -180,15 +180,15 @@ SBCommunication::GetBroadcaster () //void //SBCommunication::CreateIfNeeded () //{ -// if (m_lldb_object == NULL) +// if (m_opaque == NULL) // { // static uint32_t g_broadcaster_num; // char broadcaster_name[256]; // ::snprintf (name, broadcaster_name, "%p SBCommunication", this); -// m_lldb_object = new Communication (broadcaster_name); -// m_lldb_object_owned = true; +// m_opaque = new Communication (broadcaster_name); +// m_opaque_owned = true; // } -// assert (m_lldb_object); +// assert (m_opaque); //} // // diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp index a12934a0587..dc873e36535 100644 --- a/lldb/source/API/SBCompileUnit.cpp +++ b/lldb/source/API/SBCompileUnit.cpp @@ -18,35 +18,35 @@ using namespace lldb_private; SBCompileUnit::SBCompileUnit () : - m_lldb_object_ptr (NULL) + m_opaque_ptr (NULL) { } SBCompileUnit::SBCompileUnit (lldb_private::CompileUnit *lldb_object_ptr) : - m_lldb_object_ptr (lldb_object_ptr) + m_opaque_ptr (lldb_object_ptr) { } SBCompileUnit::~SBCompileUnit () { - m_lldb_object_ptr = NULL; + m_opaque_ptr = NULL; } SBFileSpec SBCompileUnit::GetFileSpec () const { SBFileSpec file_spec; - if (m_lldb_object_ptr) - file_spec.SetFileSpec(*m_lldb_object_ptr); + if (m_opaque_ptr) + file_spec.SetFileSpec(*m_opaque_ptr); return file_spec; } uint32_t SBCompileUnit::GetNumLineEntries () const { - if (m_lldb_object_ptr) + if (m_opaque_ptr) { - LineTable *line_table = m_lldb_object_ptr->GetLineTable (); + LineTable *line_table = m_opaque_ptr->GetLineTable (); if (line_table) return line_table->GetSize(); } @@ -57,9 +57,9 @@ SBLineEntry SBCompileUnit::GetLineEntryAtIndex (uint32_t idx) const { SBLineEntry sb_line_entry; - if (m_lldb_object_ptr) + if (m_opaque_ptr) { - LineTable *line_table = m_lldb_object_ptr->GetLineTable (); + LineTable *line_table = m_opaque_ptr->GetLineTable (); if (line_table) { LineEntry line_entry; @@ -73,15 +73,15 @@ SBCompileUnit::GetLineEntryAtIndex (uint32_t idx) const uint32_t SBCompileUnit::FindLineEntryIndex (uint32_t start_idx, uint32_t line, SBFileSpec *inline_file_spec) const { - if (m_lldb_object_ptr) + if (m_opaque_ptr) { FileSpec file_spec; if (inline_file_spec && inline_file_spec->IsValid()) file_spec = inline_file_spec->ref(); else - file_spec = *m_lldb_object_ptr; + file_spec = *m_opaque_ptr; - return m_lldb_object_ptr->FindLineEntry (start_idx, + return m_opaque_ptr->FindLineEntry (start_idx, line, inline_file_spec ? inline_file_spec->get() : NULL, NULL); @@ -92,29 +92,29 @@ SBCompileUnit::FindLineEntryIndex (uint32_t start_idx, uint32_t line, SBFileSpec bool SBCompileUnit::IsValid () const { - return m_lldb_object_ptr != NULL; + return m_opaque_ptr != NULL; } bool SBCompileUnit::operator == (const SBCompileUnit &rhs) const { - return m_lldb_object_ptr == rhs.m_lldb_object_ptr; + return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBCompileUnit::operator != (const SBCompileUnit &rhs) const { - return m_lldb_object_ptr != rhs.m_lldb_object_ptr; + return m_opaque_ptr != rhs.m_opaque_ptr; } const lldb_private::CompileUnit * SBCompileUnit::operator->() const { - return m_lldb_object_ptr; + return m_opaque_ptr; } const lldb_private::CompileUnit & SBCompileUnit::operator*() const { - return *m_lldb_object_ptr; + return *m_opaque_ptr; } diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 72e79077915..d8d0dbbacb7 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -43,112 +43,121 @@ SBDebugger::Terminate () Debugger::Terminate(); } -void -SBDebugger::SetAsync (bool b) +SBDebugger +SBDebugger::Create() { - static bool value_set_once = false; + SBDebugger debugger; + debugger.reset(Debugger::CreateInstance()); + return debugger; +} - if (!value_set_once) - { - value_set_once = true; - Debugger::GetSharedInstance().SetAsyncExecution(b); - } + +SBDebugger::SBDebugger () : + m_opaque_sp () +{ } -void -SBDebugger::SetInputFile (const char *tty_name) +SBDebugger::~SBDebugger () { - // DEPRECATED: will be removed in next submission - FILE *fh = ::fopen (tty_name, "r"); - SetInputFileHandle (fh, true); } -void -SBDebugger::SetOutputFile (const char *tty_name) +bool +SBDebugger::IsValid() const { - // DEPRECATED: will be removed in next submission - FILE *fh = ::fopen (tty_name, "w"); - SetOutputFileHandle (fh, true); - SetErrorFileHandle (fh, false); + return m_opaque_sp.get() != NULL; } + void -SBDebugger::SetErrorFile (const char *tty_name) +SBDebugger::SetAsync (bool b) { - // DEPRECATED: will be removed in next submission + if (m_opaque_sp) + m_opaque_sp->SetAsyncExecution(b); } - // Shouldn't really be settable after initialization as this could cause lots of problems; don't want users // trying to switch modes in the middle of a debugging session. void SBDebugger::SetInputFileHandle (FILE *fh, bool transfer_ownership) { - Debugger::GetSharedInstance().SetInputFileHandle (fh, transfer_ownership); + if (m_opaque_sp) + m_opaque_sp->SetInputFileHandle (fh, transfer_ownership); } void SBDebugger::SetOutputFileHandle (FILE *fh, bool transfer_ownership) { - Debugger::GetSharedInstance().SetOutputFileHandle (fh, transfer_ownership); + if (m_opaque_sp) + m_opaque_sp->SetOutputFileHandle (fh, transfer_ownership); } void SBDebugger::SetErrorFileHandle (FILE *fh, bool transfer_ownership) { - Debugger::GetSharedInstance().SetErrorFileHandle (fh, transfer_ownership); + if (m_opaque_sp) + m_opaque_sp->SetErrorFileHandle (fh, transfer_ownership); } FILE * SBDebugger::GetInputFileHandle () { - return Debugger::GetSharedInstance().GetInputFileHandle(); + if (m_opaque_sp) + return m_opaque_sp->GetInputFileHandle(); + return NULL; } FILE * SBDebugger::GetOutputFileHandle () { - return Debugger::GetSharedInstance().GetOutputFileHandle(); + if (m_opaque_sp) + return m_opaque_sp->GetOutputFileHandle(); + return NULL; } FILE * SBDebugger::GetErrorFileHandle () { - return Debugger::GetSharedInstance().GetErrorFileHandle(); + if (m_opaque_sp) + return m_opaque_sp->GetErrorFileHandle(); + return NULL; } SBCommandInterpreter SBDebugger::GetCommandInterpreter () { - SBCommandInterpreter sb_interpreter(Debugger::GetSharedInstance().GetCommandInterpreter()); + SBCommandInterpreter sb_interpreter; + if (m_opaque_sp) + sb_interpreter.reset (&m_opaque_sp->GetCommandInterpreter()); return sb_interpreter; } void SBDebugger::HandleCommand (const char *command) { - SBProcess process; - SBCommandInterpreter sb_interpreter(Debugger::GetSharedInstance().GetCommandInterpreter()); - SBCommandReturnObject result; + if (m_opaque_sp) + { + SBCommandInterpreter sb_interpreter(GetCommandInterpreter ()); + SBCommandReturnObject result; - sb_interpreter.HandleCommand (command, result, false); + sb_interpreter.HandleCommand (command, result, false); - if (GetErrorFileHandle() != NULL) - result.PutError (GetErrorFileHandle()); - if (GetOutputFileHandle() != NULL) - result.PutOutput (GetOutputFileHandle()); + if (GetErrorFileHandle() != NULL) + result.PutError (GetErrorFileHandle()); + if (GetOutputFileHandle() != NULL) + result.PutOutput (GetOutputFileHandle()); - if (Debugger::GetSharedInstance().GetAsyncExecution() == false) - { - process = GetCommandInterpreter().GetProcess (); - if (process.IsValid()) + if (m_opaque_sp->GetAsyncExecution() == false) { - EventSP event_sp; - Listener &lldb_listener = Debugger::GetSharedInstance().GetListener(); - while (lldb_listener.GetNextEventForBroadcaster (process.get(), event_sp)) + SBProcess process(GetCommandInterpreter().GetProcess ()); + if (process.IsValid()) { - SBEvent event(event_sp); - HandleProcessEvent (process, event, GetOutputFileHandle(), GetErrorFileHandle()); + EventSP event_sp; + Listener &lldb_listener = m_opaque_sp->GetListener(); + while (lldb_listener.GetNextEventForBroadcaster (process.get(), event_sp)) + { + SBEvent event(event_sp); + HandleProcessEvent (process, event, GetOutputFileHandle(), GetErrorFileHandle()); + } } } } @@ -157,7 +166,9 @@ SBDebugger::HandleCommand (const char *command) SBListener SBDebugger::GetListener () { - SBListener sb_listener(Debugger::GetSharedInstance().GetListener()); + SBListener sb_listener; + if (m_opaque_sp) + sb_listener.reset(&m_opaque_sp->GetListener(), false); return sb_listener; } @@ -271,53 +282,6 @@ SBDebugger::UpdateCurrentThread (SBProcess &process) } } -void -SBDebugger::ReportCurrentLocation (FILE *out, FILE *err) -{ - if ((out == NULL) || (err == NULL)) - return; - - SBTarget sb_target (GetCurrentTarget()); - if (!sb_target.IsValid()) - { - fprintf (out, "no target\n"); - return; - } - - SBProcess process = sb_target.GetProcess (); - if (process.IsValid()) - { - StateType state = process.GetState(); - - if (StateIsStoppedState (state)) - { - if (state == eStateExited) - { - int exit_status = process.GetExitStatus(); - const char *exit_description = process.GetExitDescription(); - ::fprintf (out, "Process %d exited with status = %i (0x%8.8x) %s\n", - process.GetProcessID(), - exit_status, - exit_status, - exit_description ? exit_description : ""); - } - else - { - fprintf (out, "Process %d %s\n", process.GetProcessID(), StateAsCString (state)); - SBThread current_thread = process.GetThreadAtIndex (0); - if (current_thread.IsValid()) - { - process.DisplayThreadsInfo (out, err, true); - } - else - fprintf (out, "No valid thread found in current process\n"); - } - } - else - fprintf (out, "No current location or status available\n"); - } -} - SBSourceManager & SBDebugger::GetSourceManager () { @@ -367,38 +331,6 @@ SBDebugger::GetScriptingLanguage (const char *script_language_name) eScriptLanguageDefault, NULL); } -//pid_t -/* -SBDebugger::AttachByName (const char *process_name, const char *filename) -{ - SBTarget *temp_target = GetCurrentTarget(); - SBTarget sb_target; - pid_t return_pid = (pid_t) LLDB_INVALID_PROCESS_ID; - - if (temp_target == NULL) - { - if (filename != NULL) - { - sb_target = CreateWithFile (filename); - sb_target.SetArch (LLDB_ARCH_DEFAULT); - } - } - else - { - sb_target = *temp_target; - } - - if (sb_target.IsValid()) - { - SBProcess process = sb_target.GetProcess (); - if (process.IsValid()) - { - return_pid = process.AttachByName (process_name); - } - } - return return_pid; -} -*/ const char * SBDebugger::GetVersionString () @@ -429,34 +361,77 @@ SBTarget SBDebugger::CreateTargetWithFileAndTargetTriple (const char *filename, const char *target_triple) { - ArchSpec arch; - FileSpec file_spec (filename); - arch.SetArchFromTargetTriple(target_triple); - TargetSP target_sp; - Error error (Debugger::GetSharedInstance().GetTargetList().CreateTarget (file_spec, arch, NULL, true, target_sp)); - SBTarget target(target_sp); + SBTarget target; + if (m_opaque_sp) + { + ArchSpec arch; + FileSpec file_spec (filename); + arch.SetArchFromTargetTriple(target_triple); + TargetSP target_sp; + Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file_spec, arch, NULL, true, target_sp)); + target.reset (target_sp); + } return target; } SBTarget SBDebugger::CreateTargetWithFileAndArch (const char *filename, const char *archname) { - FileSpec file (filename); - ArchSpec arch = lldb_private::GetDefaultArchitecture(); - TargetSP target_sp; - Error error; - - if (archname != NULL) + SBTarget target; + if (m_opaque_sp) { - ArchSpec arch2 (archname); - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file, arch2, NULL, true, target_sp); + FileSpec file (filename); + ArchSpec arch = lldb_private::GetDefaultArchitecture(); + TargetSP target_sp; + Error error; + + if (archname != NULL) + { + ArchSpec arch2 (archname); + error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch2, NULL, true, target_sp); + } + else + { + if (!arch.IsValid()) + arch = LLDB_ARCH_DEFAULT; + + error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp); + + if (error.Fail()) + { + if (arch == LLDB_ARCH_DEFAULT_32BIT) + arch = LLDB_ARCH_DEFAULT_64BIT; + else + arch = LLDB_ARCH_DEFAULT_32BIT; + + error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp); + } + } + + if (error.Success()) + { + m_opaque_sp->GetTargetList().SetCurrentTarget (target_sp.get()); + target.reset(target_sp); + } } - else + return target; +} + +SBTarget +SBDebugger::CreateTarget (const char *filename) +{ + SBTarget target; + if (m_opaque_sp) { + FileSpec file (filename); + ArchSpec arch = lldb_private::GetDefaultArchitecture(); + TargetSP target_sp; + Error error; + if (!arch.IsValid()) arch = LLDB_ARCH_DEFAULT; - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file, arch, NULL, true, target_sp); + error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp); if (error.Fail()) { @@ -465,77 +440,57 @@ SBDebugger::CreateTargetWithFileAndArch (const char *filename, const char *archn else arch = LLDB_ARCH_DEFAULT_32BIT; - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file, arch, NULL, true, target_sp); + error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp); } - } - - if (error.Success()) - Debugger::GetSharedInstance().GetTargetList().SetCurrentTarget (target_sp.get()); - else - target_sp.reset(); - - SBTarget sb_target (target_sp); - return sb_target; -} -SBTarget -SBDebugger::CreateTarget (const char *filename) -{ - FileSpec file (filename); - ArchSpec arch = lldb_private::GetDefaultArchitecture(); - TargetSP target_sp; - Error error; - - if (!arch.IsValid()) - arch = LLDB_ARCH_DEFAULT; - - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file, arch, NULL, true, target_sp); - - if (error.Fail()) - { - if (arch == LLDB_ARCH_DEFAULT_32BIT) - arch = LLDB_ARCH_DEFAULT_64BIT; - else - arch = LLDB_ARCH_DEFAULT_32BIT; - - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file, arch, NULL, true, target_sp); + if (error.Success()) + { + m_opaque_sp->GetTargetList().SetCurrentTarget (target_sp.get()); + target.reset (target_sp); + } } - - if (!error.Fail()) - Debugger::GetSharedInstance().GetTargetList().SetCurrentTarget (target_sp.get()); - - SBTarget sb_target (target_sp); - return sb_target; + return target; } SBTarget SBDebugger::GetTargetAtIndex (uint32_t idx) { - SBTarget sb_target (Debugger::GetSharedInstance().GetTargetList().GetTargetAtIndex (idx)); + SBTarget sb_target; + if (m_opaque_sp) + sb_target.reset(m_opaque_sp->GetTargetList().GetTargetAtIndex (idx)); return sb_target; } SBTarget SBDebugger::FindTargetWithProcessID (pid_t pid) { - SBTarget sb_target(Debugger::GetSharedInstance().GetTargetList().FindTargetWithProcessID (pid)); + SBTarget sb_target; + if (m_opaque_sp) + sb_target.reset(m_opaque_sp->GetTargetList().FindTargetWithProcessID (pid)); return sb_target; } SBTarget SBDebugger::FindTargetWithFileAndArch (const char *filename, const char *arch_name) { - ArchSpec arch; - if (arch_name) - arch.SetArch(arch_name); - return SBTarget (Debugger::GetSharedInstance().GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename), - arch_name ? &arch : NULL)); + SBTarget sb_target; + if (m_opaque_sp && filename && filename[0]) + { + ArchSpec arch; + if (arch_name) + arch.SetArch(arch_name); + TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename), arch_name ? &arch : NULL)); + sb_target.reset(target_sp); + } + return sb_target; } SBTarget SBDebugger::FindTargetWithLLDBProcess (const lldb::ProcessSP &process_sp) { - SBTarget sb_target(Debugger::GetSharedInstance().GetTargetList().FindTargetWithProcess (process_sp.get())); + SBTarget sb_target; + if (m_opaque_sp) + sb_target.reset(m_opaque_sp->GetTargetList().FindTargetWithProcess (process_sp.get())); return sb_target; } @@ -543,27 +498,54 @@ SBDebugger::FindTargetWithLLDBProcess (const lldb::ProcessSP &process_sp) uint32_t SBDebugger::GetNumTargets () { - return Debugger::GetSharedInstance().GetTargetList().GetNumTargets ();} + if (m_opaque_sp) + return m_opaque_sp->GetTargetList().GetNumTargets (); + return 0; +} SBTarget SBDebugger::GetCurrentTarget () { - SBTarget sb_target(Debugger::GetSharedInstance().GetTargetList().GetCurrentTarget ()); + SBTarget sb_target; + if (m_opaque_sp) + sb_target.reset(m_opaque_sp->GetTargetList().GetCurrentTarget ()); return sb_target; } void SBDebugger::DispatchInput (void *baton, const void *data, size_t data_len) { - Debugger::GetSharedInstance().DispatchInput ((const char *) data, data_len); + if (m_opaque_sp) + m_opaque_sp->DispatchInput ((const char *) data, data_len); } void SBDebugger::PushInputReader (SBInputReader &reader) { - if (reader.IsValid()) + if (m_opaque_sp && reader.IsValid()) { InputReaderSP reader_sp(*reader); - Debugger::GetSharedInstance().PushInputReader (reader_sp); + m_opaque_sp->PushInputReader (reader_sp); } } + +void +SBDebugger::reset (const lldb::DebuggerSP &debugger_sp) +{ + m_opaque_sp = debugger_sp; +} + +Debugger * +SBDebugger::get () const +{ + return m_opaque_sp.get(); +} + +Debugger & +SBDebugger::ref () const +{ + assert (m_opaque_sp.get()); + return *m_opaque_sp; +} + + diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp index 0e00d581bd5..e91c94d2c8f 100644 --- a/lldb/source/API/SBError.cpp +++ b/lldb/source/API/SBError.cpp @@ -16,15 +16,15 @@ using namespace lldb_private; SBError::SBError () : - m_lldb_object_ap () + m_opaque_ap () { } SBError::SBError (const SBError &rhs) : - m_lldb_object_ap () + m_opaque_ap () { if (rhs.IsValid()) - m_lldb_object_ap.reset (new Error(*rhs)); + m_opaque_ap.reset (new Error(*rhs)); } @@ -37,14 +37,14 @@ SBError::operator = (const SBError &rhs) { if (rhs.IsValid()) { - if (m_lldb_object_ap.get()) - *m_lldb_object_ap = *rhs; + if (m_opaque_ap.get()) + *m_opaque_ap = *rhs; else - m_lldb_object_ap.reset (new Error(*rhs)); + m_opaque_ap.reset (new Error(*rhs)); } else { - m_lldb_object_ap.reset(); + m_opaque_ap.reset(); } return *this; } @@ -53,47 +53,47 @@ SBError::operator = (const SBError &rhs) const char * SBError::GetCString () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->AsCString(); + if (m_opaque_ap.get()) + return m_opaque_ap->AsCString(); return NULL; } void SBError::Clear () { - if (m_lldb_object_ap.get()) - m_lldb_object_ap->Clear(); + if (m_opaque_ap.get()) + m_opaque_ap->Clear(); } bool SBError::Fail () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->Fail(); + if (m_opaque_ap.get()) + return m_opaque_ap->Fail(); return false; } bool SBError::Success () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->Success(); + if (m_opaque_ap.get()) + return m_opaque_ap->Success(); return false; } uint32_t SBError::GetError () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetError(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetError(); return true; } ErrorType SBError::GetType () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetType(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetType(); return eErrorTypeInvalid; } @@ -101,14 +101,14 @@ void SBError::SetError (uint32_t err, ErrorType type) { CreateIfNeeded (); - m_lldb_object_ap->SetError (err, type); + m_opaque_ap->SetError (err, type); } void SBError::SetError (const Error &lldb_error) { CreateIfNeeded (); - *m_lldb_object_ap = lldb_error; + *m_opaque_ap = lldb_error; } @@ -116,21 +116,21 @@ void SBError::SetErrorToErrno () { CreateIfNeeded (); - m_lldb_object_ap->SetErrorToErrno (); + m_opaque_ap->SetErrorToErrno (); } void SBError::SetErrorToGenericError () { CreateIfNeeded (); - m_lldb_object_ap->SetErrorToErrno (); + m_opaque_ap->SetErrorToErrno (); } void SBError::SetErrorString (const char *err_str) { CreateIfNeeded (); - m_lldb_object_ap->SetErrorString (err_str); + m_opaque_ap->SetErrorString (err_str); } int @@ -139,7 +139,7 @@ SBError::SetErrorStringWithFormat (const char *format, ...) CreateIfNeeded (); va_list args; va_start (args, format); - int num_chars = m_lldb_object_ap->SetErrorStringWithVarArg (format, args); + int num_chars = m_opaque_ap->SetErrorStringWithVarArg (format, args); va_end (args); return num_chars; } @@ -147,27 +147,27 @@ SBError::SetErrorStringWithFormat (const char *format, ...) bool SBError::IsValid () const { - return m_lldb_object_ap.get() != NULL; + return m_opaque_ap.get() != NULL; } void SBError::CreateIfNeeded () { - if (m_lldb_object_ap.get() == NULL) - m_lldb_object_ap.reset(new Error ()); + if (m_opaque_ap.get() == NULL) + m_opaque_ap.reset(new Error ()); } lldb_private::Error * SBError::operator->() { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } lldb_private::Error * SBError::get() { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } @@ -175,6 +175,6 @@ const lldb_private::Error & SBError::operator*() const { // Be sure to call "IsValid()" before calling this function or it will crash - return *m_lldb_object_ap; + return *m_opaque_ap; } diff --git a/lldb/source/API/SBEvent.cpp b/lldb/source/API/SBEvent.cpp index c082863bb2f..c04ee72d889 100644 --- a/lldb/source/API/SBEvent.cpp +++ b/lldb/source/API/SBEvent.cpp @@ -24,19 +24,19 @@ using namespace lldb_private; SBEvent::SBEvent () : m_event_sp (), - m_lldb_object (NULL) + m_opaque (NULL) { } SBEvent::SBEvent (uint32_t event_type, const char *cstr, uint32_t cstr_len) : m_event_sp (new Event (event_type, new EventDataBytes (cstr, cstr_len))), - m_lldb_object (m_event_sp.get()) + m_opaque (m_event_sp.get()) { } SBEvent::SBEvent (EventSP &event_sp) : m_event_sp (event_sp), - m_lldb_object (event_sp.get()) + m_opaque (event_sp.get()) { } @@ -47,7 +47,7 @@ SBEvent::~SBEvent() void SBEvent::Dump (FILE *f) const { - const Event *lldb_event = GetLLDBObjectPtr(); + const Event *lldb_event = get(); if (lldb_event) { StreamFile str(f); @@ -58,7 +58,7 @@ SBEvent::Dump (FILE *f) const const char * SBEvent::GetDataFlavor () { - Event *lldb_event = SBEvent::GetLLDBObjectPtr(); + Event *lldb_event = get(); if (lldb_event) return lldb_event->GetData()->GetFlavor().AsCString(); return NULL; @@ -67,7 +67,7 @@ SBEvent::GetDataFlavor () uint32_t SBEvent::GetType () const { - const Event *lldb_event = SBEvent::GetLLDBObjectPtr(); + const Event *lldb_event = get(); if (lldb_event) return lldb_event->GetType(); return 0; @@ -77,9 +77,9 @@ SBBroadcaster SBEvent::GetBroadcaster () const { SBBroadcaster broadcaster; - const Event *lldb_event = SBEvent::GetLLDBObjectPtr(); + const Event *lldb_event = get(); if (lldb_event) - broadcaster.SetLLDBObjectPtr (lldb_event->GetBroadcaster(), false); + broadcaster.reset (lldb_event->GetBroadcaster(), false); return broadcaster; } @@ -88,9 +88,9 @@ SBEvent::BroadcasterMatchesPtr (const SBBroadcaster *broadcaster) { if (broadcaster) { - Event *lldb_event = SBEvent::GetLLDBObjectPtr(); + Event *lldb_event = get(); if (lldb_event) - return lldb_event->BroadcasterIs (broadcaster->GetLLDBObjectPtr ()); + return lldb_event->BroadcasterIs (broadcaster->get()); } return false; } @@ -98,79 +98,66 @@ SBEvent::BroadcasterMatchesPtr (const SBBroadcaster *broadcaster) bool SBEvent::BroadcasterMatchesRef (const SBBroadcaster &broadcaster) { - Event *lldb_event = SBEvent::GetLLDBObjectPtr(); + Event *lldb_event = get(); if (lldb_event) - return lldb_event->BroadcasterIs (broadcaster.GetLLDBObjectPtr ()); + return lldb_event->BroadcasterIs (broadcaster.get()); return false; } void SBEvent::Clear() { - Event *lldb_event = SBEvent::GetLLDBObjectPtr(); + Event *lldb_event = get(); if (lldb_event) lldb_event->Clear(); } EventSP & -SBEvent::GetSharedPtr () const +SBEvent::GetSP () const { return m_event_sp; } Event * -SBEvent::GetLLDBObjectPtr () +SBEvent::get() const { // There is a dangerous accessor call GetSharedPtr which can be used, so if // we have anything valid in m_event_sp, we must use that since if it gets // used by a function that puts something in there, then it won't update - // m_lldb_object... + // m_opaque... if (m_event_sp) - m_lldb_object = m_event_sp.get(); + m_opaque = m_event_sp.get(); - return m_lldb_object; -} - -const Event * -SBEvent::GetLLDBObjectPtr () const -{ - // There is a dangerous accessor call GetSharedPtr which can be used, so if - // we have anything valid in m_event_sp, we must use that since if it gets - // used by a function that puts something in there, then it won't update - // m_lldb_object... - if (m_event_sp) - m_lldb_object = m_event_sp.get(); - - return m_lldb_object; + return m_opaque; } void -SBEvent::SetEventSP (EventSP &event_sp) +SBEvent::reset (EventSP &event_sp) { m_event_sp = event_sp; - m_lldb_object = m_event_sp.get(); + m_opaque = m_event_sp.get(); } void -SBEvent::SetLLDBObjectPtr (Event* event_ptr) +SBEvent::reset (Event* event_ptr) { - m_lldb_object = event_ptr; + m_opaque = event_ptr; m_event_sp.reset(); } bool SBEvent::IsValid() const { - // Do NOT use m_lldb_object directly!!! Must use the SBEvent::GetLLDBObjectPtr() - // accessor. See comments in SBEvent::GetLLDBObjectPtr().... - return SBEvent::GetLLDBObjectPtr() != NULL; + // Do NOT use m_opaque directly!!! Must use the SBEvent::get() + // accessor. See comments in SBEvent::get().... + return SBEvent::get() != NULL; } const char * SBEvent::GetCStringFromEvent (const SBEvent &event) { - return reinterpret_cast<const char *>(EventDataBytes::GetBytesFromEvent (event.GetLLDBObjectPtr())); + return reinterpret_cast<const char *>(EventDataBytes::GetBytesFromEvent (event.get())); } diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp index 48c751177c0..308e60975e5 100644 --- a/lldb/source/API/SBFileSpec.cpp +++ b/lldb/source/API/SBFileSpec.cpp @@ -16,19 +16,19 @@ using namespace lldb_private; SBFileSpec::SBFileSpec () : - m_lldb_object_ap() + m_opaque_ap() { } SBFileSpec::SBFileSpec (const SBFileSpec &rhs) : - m_lldb_object_ap() + m_opaque_ap() { - if (rhs.m_lldb_object_ap.get()) - m_lldb_object_ap.reset (new FileSpec (*m_lldb_object_ap)); + if (rhs.m_opaque_ap.get()) + m_opaque_ap.reset (new FileSpec (*m_opaque_ap)); } SBFileSpec::SBFileSpec (const char *path) : - m_lldb_object_ap(new FileSpec (path)) + m_opaque_ap(new FileSpec (path)) { } @@ -42,7 +42,7 @@ SBFileSpec::operator = (const SBFileSpec &rhs) if (this != &rhs) { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::FileSpec(*rhs.m_lldb_object_ap.get())); + m_opaque_ap.reset (new lldb_private::FileSpec(*rhs.m_opaque_ap.get())); } return *this; } @@ -50,14 +50,14 @@ SBFileSpec::operator = (const SBFileSpec &rhs) bool SBFileSpec::IsValid() const { - return m_lldb_object_ap.get() != NULL; + return m_opaque_ap.get() != NULL; } bool SBFileSpec::Exists () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->Exists(); + if (m_opaque_ap.get()) + return m_opaque_ap->Exists(); return false; } @@ -71,24 +71,24 @@ SBFileSpec::ResolvePath (const char *src_path, char *dst_path, size_t dst_len) const char * SBFileSpec::GetFileName() const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetFilename().AsCString(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetFilename().AsCString(); return NULL; } const char * SBFileSpec::GetDirectory() const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetDirectory().AsCString(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetDirectory().AsCString(); return NULL; } uint32_t SBFileSpec::GetPath (char *dst_path, size_t dst_len) const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetPath (dst_path, dst_len); + if (m_opaque_ap.get()) + return m_opaque_ap->GetPath (dst_path, dst_len); if (dst_path && dst_len) *dst_path = '\0'; @@ -99,35 +99,35 @@ SBFileSpec::GetPath (char *dst_path, size_t dst_len) const const lldb_private::FileSpec * SBFileSpec::operator->() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } const lldb_private::FileSpec * SBFileSpec::get() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } const lldb_private::FileSpec & SBFileSpec::operator*() const { - return *m_lldb_object_ap.get(); + return *m_opaque_ap.get(); } const lldb_private::FileSpec & SBFileSpec::ref() const { - return *m_lldb_object_ap.get(); + return *m_opaque_ap.get(); } void SBFileSpec::SetFileSpec (const lldb_private::FileSpec& fs) { - if (m_lldb_object_ap.get()) - *m_lldb_object_ap = fs; + if (m_opaque_ap.get()) + *m_opaque_ap = fs; else - m_lldb_object_ap.reset (new FileSpec (fs)); + m_opaque_ap.reset (new FileSpec (fs)); } diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index c3795325d9e..cd9b4cd7b4f 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -41,12 +41,12 @@ using namespace lldb; using namespace lldb_private; SBFrame::SBFrame () : - m_lldb_object_sp () + m_opaque_sp () { } SBFrame::SBFrame (const lldb::StackFrameSP &lldb_object_sp) : - m_lldb_object_sp (lldb_object_sp) + m_opaque_sp (lldb_object_sp) { } @@ -58,65 +58,65 @@ SBFrame::~SBFrame() void SBFrame::SetFrame (const lldb::StackFrameSP &lldb_object_sp) { - m_lldb_object_sp = lldb_object_sp; + m_opaque_sp = lldb_object_sp; } bool SBFrame::IsValid() const { - return (m_lldb_object_sp.get() != NULL); + return (m_opaque_sp.get() != NULL); } SBSymbolContext SBFrame::GetSymbolContext (uint32_t resolve_scope) const { SBSymbolContext sb_sym_ctx; - if (m_lldb_object_sp) - sb_sym_ctx.SetSymbolContext(&m_lldb_object_sp->GetSymbolContext (resolve_scope)); + if (m_opaque_sp) + sb_sym_ctx.SetSymbolContext(&m_opaque_sp->GetSymbolContext (resolve_scope)); return sb_sym_ctx; } SBModule SBFrame::GetModule () const { - SBModule sb_module (m_lldb_object_sp->GetSymbolContext (eSymbolContextModule).module_sp); + SBModule sb_module (m_opaque_sp->GetSymbolContext (eSymbolContextModule).module_sp); return sb_module; } SBCompileUnit SBFrame::GetCompileUnit () const { - SBCompileUnit sb_comp_unit(m_lldb_object_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit); + SBCompileUnit sb_comp_unit(m_opaque_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit); return sb_comp_unit; } SBFunction SBFrame::GetFunction () const { - SBFunction sb_function(m_lldb_object_sp->GetSymbolContext (eSymbolContextFunction).function); + SBFunction sb_function(m_opaque_sp->GetSymbolContext (eSymbolContextFunction).function); return sb_function; } SBBlock SBFrame::GetBlock () const { - SBBlock sb_block(m_lldb_object_sp->GetSymbolContext (eSymbolContextBlock).block); + SBBlock sb_block(m_opaque_sp->GetSymbolContext (eSymbolContextBlock).block); return sb_block; } SBLineEntry SBFrame::GetLineEntry () const { - SBLineEntry sb_line_entry(&m_lldb_object_sp->GetSymbolContext (eSymbolContextLineEntry).line_entry); + SBLineEntry sb_line_entry(&m_opaque_sp->GetSymbolContext (eSymbolContextLineEntry).line_entry); return sb_line_entry; } uint32_t SBFrame::GetFrameID () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetID(); + if (m_opaque_sp) + return m_opaque_sp->GetID(); else return UINT32_MAX; } @@ -125,24 +125,24 @@ SBFrame::GetFrameID () const lldb::addr_t SBFrame::GetPC () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetPC().GetLoadAddress (&m_lldb_object_sp->GetThread().GetProcess()); + if (m_opaque_sp) + return m_opaque_sp->GetPC().GetLoadAddress (&m_opaque_sp->GetThread().GetProcess()); return LLDB_INVALID_ADDRESS; } bool SBFrame::SetPC (lldb::addr_t new_pc) { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetRegisterContext()->SetPC (new_pc); + if (m_opaque_sp) + return m_opaque_sp->GetRegisterContext()->SetPC (new_pc); return false; } lldb::addr_t SBFrame::GetSP () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetRegisterContext()->GetSP(); + if (m_opaque_sp) + return m_opaque_sp->GetRegisterContext()->GetSP(); return LLDB_INVALID_ADDRESS; } @@ -150,8 +150,8 @@ SBFrame::GetSP () const lldb::addr_t SBFrame::GetFP () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetRegisterContext()->GetFP(); + if (m_opaque_sp) + return m_opaque_sp->GetRegisterContext()->GetFP(); return LLDB_INVALID_ADDRESS; } @@ -160,15 +160,15 @@ SBAddress SBFrame::GetPCAddress () const { SBAddress sb_addr; - if (m_lldb_object_sp) - sb_addr.SetAddress (&m_lldb_object_sp->GetPC()); + if (m_opaque_sp) + sb_addr.SetAddress (&m_opaque_sp->GetPC()); return sb_addr; } void SBFrame::Clear() { - m_lldb_object_sp.reset(); + m_opaque_sp.reset(); } SBValue @@ -250,40 +250,40 @@ SBFrame::LookupVarInScope (const char *var_name, const char *scope) bool SBFrame::operator == (const SBFrame &rhs) const { - return m_lldb_object_sp.get() == rhs.m_lldb_object_sp.get(); + return m_opaque_sp.get() == rhs.m_opaque_sp.get(); } bool SBFrame::operator != (const SBFrame &rhs) const { - return m_lldb_object_sp.get() != rhs.m_lldb_object_sp.get(); + return m_opaque_sp.get() != rhs.m_opaque_sp.get(); } lldb_private::StackFrame * SBFrame::operator->() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } lldb_private::StackFrame * SBFrame::get() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } SBThread SBFrame::GetThread () const { - SBThread sb_thread (m_lldb_object_sp->GetThread().GetSP()); + SBThread sb_thread (m_opaque_sp->GetThread().GetSP()); return sb_thread; } const char * SBFrame::Disassemble () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->Disassemble(); + if (m_opaque_sp) + return m_opaque_sp->Disassemble(); return NULL; } @@ -292,7 +292,7 @@ SBFrame::Disassemble () const lldb_private::StackFrame * SBFrame::GetLLDBObjectPtr () { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } SBValueList @@ -302,10 +302,10 @@ SBFrame::GetVariables (bool arguments, bool in_scope_only) { SBValueList value_list; - if (m_lldb_object_sp) + if (m_opaque_sp) { size_t i; - VariableList *variable_list = m_lldb_object_sp->GetVariableList(); + VariableList *variable_list = m_opaque_sp->GetVariableList(); if (variable_list) { const size_t num_variables = variable_list->GetSize(); @@ -334,7 +334,7 @@ SBFrame::GetVariables (bool arguments, } if (add_variable) { - if (in_scope_only && !variable_sp->IsInScope(m_lldb_object_sp.get())) + if (in_scope_only && !variable_sp->IsInScope(m_opaque_sp.get())) continue; value_list.Append(ValueObjectSP (new ValueObjectVariable (variable_sp))); @@ -346,7 +346,7 @@ SBFrame::GetVariables (bool arguments, if (statics) { - CompileUnit *frame_comp_unit = m_lldb_object_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit; + CompileUnit *frame_comp_unit = m_opaque_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit; if (frame_comp_unit) { @@ -377,9 +377,9 @@ lldb::SBValueList SBFrame::GetRegisters () { SBValueList value_list; - if (m_lldb_object_sp) + if (m_opaque_sp) { - RegisterContext *reg_ctx = m_lldb_object_sp->GetRegisterContext(); + RegisterContext *reg_ctx = m_opaque_sp->GetRegisterContext(); if (reg_ctx) { const uint32_t num_sets = reg_ctx->GetRegisterSetCount(); diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp index 010a5ec17df..c4beff1a14e 100644 --- a/lldb/source/API/SBFunction.cpp +++ b/lldb/source/API/SBFunction.cpp @@ -15,50 +15,50 @@ using namespace lldb; SBFunction::SBFunction () : - m_lldb_object_ptr (NULL) + m_opaque_ptr (NULL) { } SBFunction::SBFunction (lldb_private::Function *lldb_object_ptr) : - m_lldb_object_ptr (lldb_object_ptr) + m_opaque_ptr (lldb_object_ptr) { } SBFunction::~SBFunction () { - m_lldb_object_ptr = NULL; + m_opaque_ptr = NULL; } bool SBFunction::IsValid () const { - return m_lldb_object_ptr != NULL; + return m_opaque_ptr != NULL; } const char * SBFunction::GetName() const { - if (m_lldb_object_ptr) - return m_lldb_object_ptr->GetMangled().GetName().AsCString(); + if (m_opaque_ptr) + return m_opaque_ptr->GetMangled().GetName().AsCString(); return NULL; } const char * SBFunction::GetMangledName () const { - if (m_lldb_object_ptr) - return m_lldb_object_ptr->GetMangled().GetMangledName().AsCString(); + if (m_opaque_ptr) + return m_opaque_ptr->GetMangled().GetMangledName().AsCString(); return NULL; } bool SBFunction::operator == (const SBFunction &rhs) const { - return m_lldb_object_ptr == rhs.m_lldb_object_ptr; + return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBFunction::operator != (const SBFunction &rhs) const { - return m_lldb_object_ptr != rhs.m_lldb_object_ptr; + return m_opaque_ptr != rhs.m_opaque_ptr; } diff --git a/lldb/source/API/SBInputReader.cpp b/lldb/source/API/SBInputReader.cpp index 022d73207ad..4d1c7b91e8e 100644 --- a/lldb/source/API/SBInputReader.cpp +++ b/lldb/source/API/SBInputReader.cpp @@ -10,8 +10,9 @@ #include "lldb/lldb-enumerations.h" -#include "lldb/API/SBInputReader.h" +#include "lldb/API/SBDebugger.h" #include "lldb/API/SBError.h" +#include "lldb/API/SBInputReader.h" #include "lldb/API/SBStringList.h" #include "lldb/Core/InputReader.h" @@ -20,7 +21,7 @@ using namespace lldb; using namespace lldb_private; SBInputReader::SBInputReader () : - m_reader_sp (), + m_opaque_sp (), m_callback_function (NULL), m_callback_baton (NULL) @@ -28,12 +29,12 @@ SBInputReader::SBInputReader () : } SBInputReader::SBInputReader (const lldb::InputReaderSP &reader_sp) : - m_reader_sp (reader_sp) + m_opaque_sp (reader_sp) { } SBInputReader::SBInputReader (const SBInputReader &rhs) : - m_reader_sp (rhs.m_reader_sp) + m_opaque_sp (rhs.m_opaque_sp) { } @@ -45,7 +46,7 @@ size_t SBInputReader::PrivateCallback ( void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len @@ -62,6 +63,7 @@ SBInputReader::PrivateCallback SBError SBInputReader::Initialize ( + SBDebugger &debugger, Callback callback_function, void *callback_baton, lldb::InputReaderGranularity granularity, @@ -71,14 +73,14 @@ SBInputReader::Initialize ) { SBError sb_error; - m_reader_sp.reset (new InputReader ()); + m_opaque_sp.reset (new InputReader (debugger.ref())); m_callback_function = callback_function; m_callback_baton = callback_baton; - if (m_reader_sp) + if (m_opaque_sp) { - sb_error.SetError (m_reader_sp->Initialize (SBInputReader::PrivateCallback, + sb_error.SetError (m_opaque_sp->Initialize (SBInputReader::PrivateCallback, this, granularity, end_token, @@ -88,7 +90,7 @@ SBInputReader::Initialize if (sb_error.Fail()) { - m_reader_sp.reset (); + m_opaque_sp.reset (); m_callback_function = NULL; m_callback_baton = NULL; } @@ -99,46 +101,53 @@ SBInputReader::Initialize bool SBInputReader::IsValid () const { - return (m_reader_sp.get() != NULL); + return (m_opaque_sp.get() != NULL); } const SBInputReader & SBInputReader::operator = (const SBInputReader &rhs) { if (this != &rhs) - m_reader_sp = rhs.m_reader_sp; + m_opaque_sp = rhs.m_opaque_sp; return *this; } -lldb_private::InputReader * +InputReader * SBInputReader::operator->() const { - return m_reader_sp.get(); + return m_opaque_sp.get(); } lldb::InputReaderSP & SBInputReader::operator *() { - return m_reader_sp; + return m_opaque_sp; } const lldb::InputReaderSP & SBInputReader::operator *() const { - return m_reader_sp; + return m_opaque_sp; } -lldb_private::InputReader * +InputReader * SBInputReader::get() const { - return m_reader_sp.get(); + return m_opaque_sp.get(); +} + +InputReader & +SBInputReader::ref() const +{ + assert (m_opaque_sp.get()); + return *m_opaque_sp; } bool SBInputReader::IsDone () const { - if (m_reader_sp) - return m_reader_sp->IsDone(); + if (m_opaque_sp) + return m_opaque_sp->IsDone(); else return true; } @@ -146,15 +155,15 @@ SBInputReader::IsDone () const void SBInputReader::SetIsDone (bool value) { - if (m_reader_sp) - m_reader_sp->SetIsDone (value); + if (m_opaque_sp) + m_opaque_sp->SetIsDone (value); } bool SBInputReader::IsActive () const { - if (m_reader_sp) - return m_reader_sp->IsActive(); + if (m_opaque_sp) + return m_opaque_sp->IsActive(); else return false; } @@ -162,8 +171,8 @@ SBInputReader::IsActive () const InputReaderGranularity SBInputReader::GetGranularity () { - if (m_reader_sp) - return m_reader_sp->GetGranularity(); + if (m_opaque_sp) + return m_opaque_sp->GetGranularity(); else return eInputReaderGranularityInvalid; } diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp index 564fda0b8cb..181b6b0c5e9 100644 --- a/lldb/source/API/SBInstruction.cpp +++ b/lldb/source/API/SBInstruction.cpp @@ -15,7 +15,7 @@ using namespace lldb; using namespace lldb_private; //SBInstruction::SBInstruction (lldb_private::Disassembler::Instruction *lldb_insn) : -// m_lldb_object_sp (lldb_insn); +// m_opaque_sp (lldb_insn); //{ //} @@ -30,7 +30,7 @@ SBInstruction::~SBInstruction () //bool //SBInstruction::IsValid() //{ -// return (m_lldb_object_sp.get() != NULL); +// return (m_opaque_sp.get() != NULL); //} //size_t @@ -38,7 +38,7 @@ SBInstruction::~SBInstruction () //{ // if (IsValid()) // { -// return m_lldb_object_sp->GetByteSize(); +// return m_opaque_sp->GetByteSize(); // } // return 0; //} @@ -48,7 +48,7 @@ SBInstruction::~SBInstruction () //{ // if (IsValid ()) // { -// m_lldb_object_sp->SetByteSize (byte_size); +// m_opaque_sp->SetByteSize (byte_size); // } //} @@ -57,7 +57,7 @@ SBInstruction::~SBInstruction () //{ // if (IsValid ()) // { -// return m_lldb_object_sp->DoesBranch (); +// return m_opaque_sp->DoesBranch (); // } // return false; //} @@ -70,5 +70,5 @@ SBInstruction::Print (FILE *out) //StreamFile out_strem (out); - //m_lldb_object_sp->Dump (out, LLDB_INVALID_ADDRESS, NULL, 0); + //m_opaque_sp->Dump (out, LLDB_INVALID_ADDRESS, NULL, 0); } diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp index 483540050a3..a35f94a8b54 100644 --- a/lldb/source/API/SBLineEntry.cpp +++ b/lldb/source/API/SBLineEntry.cpp @@ -14,26 +14,26 @@ using namespace lldb; SBLineEntry::SBLineEntry () : - m_lldb_object_ap () + m_opaque_ap () { } SBLineEntry::SBLineEntry (const SBLineEntry &rhs) : - m_lldb_object_ap () + m_opaque_ap () { if (rhs.IsValid()) { - m_lldb_object_ap.reset (new lldb_private::LineEntry (*rhs)); + m_opaque_ap.reset (new lldb_private::LineEntry (*rhs)); } } SBLineEntry::SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr) : - m_lldb_object_ap () + m_opaque_ap () { if (lldb_object_ptr) - m_lldb_object_ap.reset (new lldb_private::LineEntry(*lldb_object_ptr)); + m_opaque_ap.reset (new lldb_private::LineEntry(*lldb_object_ptr)); } const SBLineEntry & @@ -42,7 +42,7 @@ SBLineEntry::operator = (const SBLineEntry &rhs) if (this != &rhs) { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::LineEntry(*rhs)); + m_opaque_ap.reset (new lldb_private::LineEntry(*rhs)); } return *this; } @@ -50,10 +50,10 @@ SBLineEntry::operator = (const SBLineEntry &rhs) void SBLineEntry::SetLineEntry (const lldb_private::LineEntry &lldb_object_ref) { - if (m_lldb_object_ap.get()) - (*m_lldb_object_ap.get()) = lldb_object_ref; + if (m_opaque_ap.get()) + (*m_opaque_ap.get()) = lldb_object_ref; else - m_lldb_object_ap.reset (new lldb_private::LineEntry (lldb_object_ref)); + m_opaque_ap.reset (new lldb_private::LineEntry (lldb_object_ref)); } @@ -66,8 +66,8 @@ SBAddress SBLineEntry::GetStartAddress () const { SBAddress sb_address; - if (m_lldb_object_ap.get()) - sb_address.SetAddress(&m_lldb_object_ap->range.GetBaseAddress()); + if (m_opaque_ap.get()) + sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress()); return sb_address; } @@ -75,10 +75,10 @@ SBAddress SBLineEntry::GetEndAddress () const { SBAddress sb_address; - if (m_lldb_object_ap.get()) + if (m_opaque_ap.get()) { - sb_address.SetAddress(&m_lldb_object_ap->range.GetBaseAddress()); - sb_address.OffsetAddress(m_lldb_object_ap->range.GetByteSize()); + sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress()); + sb_address.OffsetAddress(m_opaque_ap->range.GetByteSize()); } return sb_address; } @@ -86,7 +86,7 @@ SBLineEntry::GetEndAddress () const bool SBLineEntry::IsValid () const { - return m_lldb_object_ap.get() != NULL; + return m_opaque_ap.get() != NULL; } @@ -94,16 +94,16 @@ SBFileSpec SBLineEntry::GetFileSpec () const { SBFileSpec sb_file_spec; - if (m_lldb_object_ap.get() && m_lldb_object_ap->file) - sb_file_spec.SetFileSpec(m_lldb_object_ap->file); + if (m_opaque_ap.get() && m_opaque_ap->file) + sb_file_spec.SetFileSpec(m_opaque_ap->file); return sb_file_spec; } uint32_t SBLineEntry::GetLine () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->line; + if (m_opaque_ap.get()) + return m_opaque_ap->line; return 0; } @@ -111,16 +111,16 @@ SBLineEntry::GetLine () const uint32_t SBLineEntry::GetColumn () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->column; + if (m_opaque_ap.get()) + return m_opaque_ap->column; return 0; } bool SBLineEntry::operator == (const SBLineEntry &rhs) const { - lldb_private::LineEntry *lhs_ptr = m_lldb_object_ap.get(); - lldb_private::LineEntry *rhs_ptr = rhs.m_lldb_object_ap.get(); + lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get(); + lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get(); if (lhs_ptr && rhs_ptr) return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) == 0; @@ -131,8 +131,8 @@ SBLineEntry::operator == (const SBLineEntry &rhs) const bool SBLineEntry::operator != (const SBLineEntry &rhs) const { - lldb_private::LineEntry *lhs_ptr = m_lldb_object_ap.get(); - lldb_private::LineEntry *rhs_ptr = rhs.m_lldb_object_ap.get(); + lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get(); + lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get(); if (lhs_ptr && rhs_ptr) return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) != 0; @@ -143,13 +143,13 @@ SBLineEntry::operator != (const SBLineEntry &rhs) const const lldb_private::LineEntry * SBLineEntry::operator->() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } const lldb_private::LineEntry & SBLineEntry::operator*() const { - return *m_lldb_object_ap; + return *m_opaque_ap; } diff --git a/lldb/source/API/SBListener.cpp b/lldb/source/API/SBListener.cpp index 06526106cfb..3e2f2122bdd 100644 --- a/lldb/source/API/SBListener.cpp +++ b/lldb/source/API/SBListener.cpp @@ -19,30 +19,32 @@ using namespace lldb; using namespace lldb_private; -SBListener::SBListener () +SBListener::SBListener () : + m_opaque_ptr (NULL), + m_opaque_ptr_owned (false) { } SBListener::SBListener (const char *name) : - m_lldb_object_ptr (new Listener (name)), - m_lldb_object_ptr_owned (true) + m_opaque_ptr (new Listener (name)), + m_opaque_ptr_owned (true) { } SBListener::SBListener (Listener &listener) : - m_lldb_object_ptr (&listener), - m_lldb_object_ptr_owned (false) + m_opaque_ptr (&listener), + m_opaque_ptr_owned (false) { } SBListener::~SBListener () { - if (m_lldb_object_ptr_owned) + if (m_opaque_ptr_owned) { - if (m_lldb_object_ptr) + if (m_opaque_ptr) { - delete m_lldb_object_ptr; - m_lldb_object_ptr = NULL; + delete m_opaque_ptr; + m_opaque_ptr = NULL; } } } @@ -50,30 +52,30 @@ SBListener::~SBListener () bool SBListener::IsValid() const { - return m_lldb_object_ptr != NULL; + return m_opaque_ptr != NULL; } void SBListener::AddEvent (const SBEvent &event) { - EventSP &event_sp = event.GetSharedPtr (); + EventSP &event_sp = event.GetSP (); if (event_sp) - m_lldb_object_ptr->AddEvent (event_sp); + m_opaque_ptr->AddEvent (event_sp); } void SBListener::Clear () { - if (IsValid()) - m_lldb_object_ptr->Clear (); + if (m_opaque_ptr) + m_opaque_ptr->Clear (); } uint32_t SBListener::StartListeningForEvents (const SBBroadcaster& broadcaster, uint32_t event_mask) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { - return m_lldb_object_ptr->StartListeningForEvents (broadcaster.GetLLDBObjectPtr (), event_mask); + return m_opaque_ptr->StartListeningForEvents (broadcaster.get(), event_mask); } return false; } @@ -81,9 +83,9 @@ SBListener::StartListeningForEvents (const SBBroadcaster& broadcaster, uint32_t bool SBListener::StopListeningForEvents (const SBBroadcaster& broadcaster, uint32_t event_mask) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { - return m_lldb_object_ptr->StopListeningForEvents (broadcaster.GetLLDBObjectPtr (), event_mask); + return m_opaque_ptr->StopListeningForEvents (broadcaster.get(), event_mask); } return false; } @@ -91,7 +93,7 @@ SBListener::StopListeningForEvents (const SBBroadcaster& broadcaster, uint32_t e bool SBListener::WaitForEvent (uint32_t num_seconds, SBEvent &event) { - if (IsValid()) + if (m_opaque_ptr) { TimeValue time_value; if (num_seconds != UINT32_MAX) @@ -101,13 +103,13 @@ SBListener::WaitForEvent (uint32_t num_seconds, SBEvent &event) time_value.OffsetWithSeconds (num_seconds); } EventSP event_sp; - if (m_lldb_object_ptr->WaitForEvent (time_value.IsValid() ? &time_value : NULL, event_sp)) + if (m_opaque_ptr->WaitForEvent (time_value.IsValid() ? &time_value : NULL, event_sp)) { - event.SetEventSP (event_sp); + event.reset (event_sp); return true; } } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } @@ -119,7 +121,7 @@ SBListener::WaitForEventForBroadcaster SBEvent &event ) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { TimeValue time_value; if (num_seconds != UINT32_MAX) @@ -128,16 +130,16 @@ SBListener::WaitForEventForBroadcaster time_value.OffsetWithSeconds (num_seconds); } EventSP event_sp; - if (m_lldb_object_ptr->WaitForEventForBroadcaster (time_value.IsValid() ? &time_value : NULL, - broadcaster.GetLLDBObjectPtr (), + if (m_opaque_ptr->WaitForEventForBroadcaster (time_value.IsValid() ? &time_value : NULL, + broadcaster.get(), event_sp)) { - event.SetEventSP (event_sp); + event.reset (event_sp); return true; } } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } @@ -150,7 +152,7 @@ SBListener::WaitForEventForBroadcasterWithType SBEvent &event ) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { TimeValue time_value; if (num_seconds != UINT32_MAX) @@ -159,40 +161,40 @@ SBListener::WaitForEventForBroadcasterWithType time_value.OffsetWithSeconds (num_seconds); } EventSP event_sp; - if (m_lldb_object_ptr->WaitForEventForBroadcasterWithType (time_value.IsValid() ? &time_value : NULL, - broadcaster.GetLLDBObjectPtr (), - event_type_mask, - event_sp)) + if (m_opaque_ptr->WaitForEventForBroadcasterWithType (time_value.IsValid() ? &time_value : NULL, + broadcaster.get(), + event_type_mask, + event_sp)) { - event.SetEventSP (event_sp); + event.reset (event_sp); return true; } } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } bool SBListener::PeekAtNextEvent (SBEvent &event) { - if (m_lldb_object_ptr) + if (m_opaque_ptr) { - event.SetLLDBObjectPtr (m_lldb_object_ptr->PeekAtNextEvent ()); + event.reset (m_opaque_ptr->PeekAtNextEvent ()); return event.IsValid(); } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } bool SBListener::PeekAtNextEventForBroadcaster (const SBBroadcaster &broadcaster, SBEvent &event) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { - event.SetLLDBObjectPtr (m_lldb_object_ptr->PeekAtNextEventForBroadcaster (broadcaster.GetLLDBObjectPtr ())); + event.reset (m_opaque_ptr->PeekAtNextEventForBroadcaster (broadcaster.get())); return event.IsValid(); } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } @@ -200,44 +202,44 @@ bool SBListener::PeekAtNextEventForBroadcasterWithType (const SBBroadcaster &broadcaster, uint32_t event_type_mask, SBEvent &event) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { - event.SetLLDBObjectPtr(m_lldb_object_ptr->PeekAtNextEventForBroadcasterWithType (broadcaster.GetLLDBObjectPtr (), event_type_mask)); + event.reset(m_opaque_ptr->PeekAtNextEventForBroadcasterWithType (broadcaster.get(), event_type_mask)); return event.IsValid(); } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } bool SBListener::GetNextEvent (SBEvent &event) { - if (m_lldb_object_ptr) + if (m_opaque_ptr) { EventSP event_sp; - if (m_lldb_object_ptr->GetNextEvent (event_sp)) + if (m_opaque_ptr->GetNextEvent (event_sp)) { - event.SetEventSP (event_sp); + event.reset (event_sp); return true; } } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } bool SBListener::GetNextEventForBroadcaster (const SBBroadcaster &broadcaster, SBEvent &event) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { EventSP event_sp; - if (m_lldb_object_ptr->GetNextEventForBroadcaster (broadcaster.GetLLDBObjectPtr (), event_sp)) + if (m_opaque_ptr->GetNextEventForBroadcaster (broadcaster.get(), event_sp)) { - event.SetEventSP (event_sp); + event.reset (event_sp); return true; } } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } @@ -249,51 +251,61 @@ SBListener::GetNextEventForBroadcasterWithType SBEvent &event ) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { EventSP event_sp; - if (m_lldb_object_ptr->GetNextEventForBroadcasterWithType (broadcaster.GetLLDBObjectPtr (), - event_type_mask, - event_sp)) + if (m_opaque_ptr->GetNextEventForBroadcasterWithType (broadcaster.get(), + event_type_mask, + event_sp)) { - event.SetEventSP (event_sp); + event.reset (event_sp); return true; } } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } bool SBListener::HandleBroadcastEvent (const SBEvent &event) { - if (m_lldb_object_ptr) - return m_lldb_object_ptr->HandleBroadcastEvent (event.GetSharedPtr()); + if (m_opaque_ptr) + return m_opaque_ptr->HandleBroadcastEvent (event.GetSP()); return false; } -lldb_private::Listener * +Listener * SBListener::operator->() const { - return m_lldb_object_ptr; + return m_opaque_ptr; } -lldb_private::Listener * +Listener * SBListener::get() const { - return m_lldb_object_ptr; + return m_opaque_ptr; } -lldb_private::Listener & +void +SBListener::reset(Listener *listener, bool transfer_ownership) +{ + if (m_opaque_ptr_owned && m_opaque_ptr) + delete m_opaque_ptr; + m_opaque_ptr_owned = transfer_ownership; + m_opaque_ptr = listener; +} + + +Listener & SBListener::operator *() { - return *m_lldb_object_ptr; + return *m_opaque_ptr; } -const lldb_private::Listener & +const Listener & SBListener::operator *() const { - return *m_lldb_object_ptr; + return *m_opaque_ptr; } diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 6a54c2177bf..011197ad7cd 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -15,12 +15,12 @@ using namespace lldb; SBModule::SBModule () : - m_lldb_object_sp () + m_opaque_sp () { } SBModule::SBModule (const lldb::ModuleSP& module_sp) : - m_lldb_object_sp (module_sp) + m_opaque_sp (module_sp) { } @@ -31,23 +31,23 @@ SBModule::~SBModule () bool SBModule::IsValid () const { - return m_lldb_object_sp.get() != NULL; + return m_opaque_sp.get() != NULL; } SBFileSpec SBModule::GetFileSpec () const { SBFileSpec file_spec; - if (m_lldb_object_sp) - file_spec.SetFileSpec(m_lldb_object_sp->GetFileSpec()); + if (m_opaque_sp) + file_spec.SetFileSpec(m_opaque_sp->GetFileSpec()); return file_spec; } const uint8_t * SBModule::GetUUIDBytes () const { - if (m_lldb_object_sp) - return (const uint8_t *)m_lldb_object_sp->GetUUID().GetBytes(); + if (m_opaque_sp) + return (const uint8_t *)m_opaque_sp->GetUUID().GetBytes(); return NULL; } @@ -55,53 +55,53 @@ SBModule::GetUUIDBytes () const bool SBModule::operator == (const SBModule &rhs) const { - if (m_lldb_object_sp) - return m_lldb_object_sp.get() == rhs.m_lldb_object_sp.get(); + if (m_opaque_sp) + return m_opaque_sp.get() == rhs.m_opaque_sp.get(); return false; } bool SBModule::operator != (const SBModule &rhs) const { - if (m_lldb_object_sp) - return m_lldb_object_sp.get() != rhs.m_lldb_object_sp.get(); + if (m_opaque_sp) + return m_opaque_sp.get() != rhs.m_opaque_sp.get(); return false; } lldb::ModuleSP & SBModule::operator *() { - return m_lldb_object_sp; + return m_opaque_sp; } lldb_private::Module * SBModule::operator ->() { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } const lldb_private::Module * SBModule::operator ->() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } lldb_private::Module * SBModule::get() { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } const lldb_private::Module * SBModule::get() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } void SBModule::SetModule (const lldb::ModuleSP& module_sp) { - m_lldb_object_sp = module_sp; + m_opaque_sp = module_sp; } diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index a646e4b30f7..7db55916999 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -19,8 +19,9 @@ #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" #include "lldb/Target/Process.h" -#include "lldb/Target/Thread.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" // Project includes @@ -37,7 +38,7 @@ using namespace lldb_private; SBProcess::SBProcess () : - m_lldb_object_sp() + m_opaque_sp() { } @@ -47,13 +48,13 @@ SBProcess::SBProcess () : //---------------------------------------------------------------------- SBProcess::SBProcess (const SBProcess& rhs) : - m_lldb_object_sp (rhs.m_lldb_object_sp) + m_opaque_sp (rhs.m_opaque_sp) { } SBProcess::SBProcess (const lldb::ProcessSP &process_sp) : - m_lldb_object_sp (process_sp) + m_opaque_sp (process_sp) { } @@ -67,30 +68,30 @@ SBProcess::~SBProcess() void SBProcess::SetProcess (const ProcessSP &process_sp) { - m_lldb_object_sp = process_sp; + m_opaque_sp = process_sp; } void SBProcess::Clear () { - m_lldb_object_sp.reset(); + m_opaque_sp.reset(); } bool SBProcess::IsValid() const { - return m_lldb_object_sp.get() != NULL; + return m_opaque_sp.get() != NULL; } uint32_t SBProcess::GetNumThreads () { - if (m_lldb_object_sp) + if (m_opaque_sp) { const bool can_update = true; - return m_lldb_object_sp->GetThreadList().GetSize(can_update); + return m_opaque_sp->GetThreadList().GetSize(can_update); } return 0; } @@ -99,8 +100,8 @@ SBThread SBProcess::GetCurrentThread () const { SBThread sb_thread; - if (m_lldb_object_sp) - sb_thread.SetThread (m_lldb_object_sp->GetThreadList().GetCurrentThread()); + if (m_opaque_sp) + sb_thread.SetThread (m_opaque_sp->GetThreadList().GetCurrentThread()); return sb_thread; } @@ -108,8 +109,8 @@ SBTarget SBProcess::GetTarget() const { SBTarget sb_target; - if (m_lldb_object_sp) - sb_target = SBDebugger::FindTargetWithLLDBProcess (m_lldb_object_sp); + if (m_opaque_sp) + sb_target = m_opaque_sp->GetTarget().GetSP(); return sb_target; } @@ -117,10 +118,10 @@ SBProcess::GetTarget() const size_t SBProcess::PutSTDIN (const char *src, size_t src_len) { - if (m_lldb_object_sp != NULL) + if (m_opaque_sp != NULL) { Error error; - return m_lldb_object_sp->PutSTDIN (src, src_len, error); + return m_opaque_sp->PutSTDIN (src, src_len, error); } else return 0; @@ -129,10 +130,10 @@ SBProcess::PutSTDIN (const char *src, size_t src_len) size_t SBProcess::GetSTDOUT (char *dst, size_t dst_len) const { - if (m_lldb_object_sp != NULL) + if (m_opaque_sp != NULL) { Error error; - return m_lldb_object_sp->GetSTDOUT (dst, dst_len, error); + return m_opaque_sp->GetSTDOUT (dst, dst_len, error); } else return 0; @@ -141,10 +142,10 @@ SBProcess::GetSTDOUT (char *dst, size_t dst_len) const size_t SBProcess::GetSTDERR (char *dst, size_t dst_len) const { - if (m_lldb_object_sp != NULL) + if (m_opaque_sp != NULL) { Error error; - return m_lldb_object_sp->GetSTDERR (dst, dst_len, error); + return m_opaque_sp->GetSTDERR (dst, dst_len, error); } else return 0; @@ -156,14 +157,14 @@ SBProcess::ReportCurrentState (const SBEvent &event, FILE *out) const if (out == NULL) return; - if (m_lldb_object_sp != NULL) + if (m_opaque_sp != NULL) { const StateType event_state = SBProcess::GetStateFromEvent (event); char message[1024]; int message_len = ::snprintf (message, sizeof (message), "Process %d %s\n", - m_lldb_object_sp->GetID(), + m_opaque_sp->GetID(), SBDebugger::StateAsCString (event_state)); if (message_len > 0) @@ -174,14 +175,14 @@ SBProcess::ReportCurrentState (const SBEvent &event, FILE *out) const void SBProcess::AppendCurrentStateReport (const SBEvent &event, SBCommandReturnObject &result) { - if (m_lldb_object_sp != NULL) + if (m_opaque_sp != NULL) { const StateType event_state = SBProcess::GetStateFromEvent (event); char message[1024]; ::snprintf (message, sizeof (message), "Process %d %s\n", - m_lldb_object_sp->GetID(), + m_opaque_sp->GetID(), SBDebugger::StateAsCString (event_state)); result.AppendMessage (message); @@ -191,16 +192,16 @@ SBProcess::AppendCurrentStateReport (const SBEvent &event, SBCommandReturnObject bool SBProcess::SetCurrentThread (const SBThread &thread) { - if (m_lldb_object_sp != NULL) - return m_lldb_object_sp->GetThreadList().SetCurrentThreadByID (thread.GetThreadID()); + if (m_opaque_sp != NULL) + return m_opaque_sp->GetThreadList().SetCurrentThreadByID (thread.GetThreadID()); return false; } bool SBProcess::SetCurrentThreadByID (uint32_t tid) { - if (m_lldb_object_sp != NULL) - return m_lldb_object_sp->GetThreadList().SetCurrentThreadByID (tid); + if (m_opaque_sp != NULL) + return m_opaque_sp->GetThreadList().SetCurrentThreadByID (tid); return false; } @@ -208,16 +209,16 @@ SBThread SBProcess::GetThreadAtIndex (size_t index) { SBThread thread; - if (m_lldb_object_sp) - thread.SetThread (m_lldb_object_sp->GetThreadList().GetThreadAtIndex(index)); + if (m_opaque_sp) + thread.SetThread (m_opaque_sp->GetThreadList().GetThreadAtIndex(index)); return thread; } StateType SBProcess::GetState () { - if (m_lldb_object_sp != NULL) - return m_lldb_object_sp->GetState(); + if (m_opaque_sp != NULL) + return m_opaque_sp->GetState(); else return eStateInvalid; } @@ -226,8 +227,8 @@ SBProcess::GetState () int SBProcess::GetExitStatus () { - if (m_lldb_object_sp != NULL) - return m_lldb_object_sp->GetExitStatus (); + if (m_opaque_sp != NULL) + return m_opaque_sp->GetExitStatus (); else return 0; } @@ -235,8 +236,8 @@ SBProcess::GetExitStatus () const char * SBProcess::GetExitDescription () { - if (m_lldb_object_sp != NULL) - return m_lldb_object_sp->GetExitDescription (); + if (m_opaque_sp != NULL) + return m_opaque_sp->GetExitDescription (); else return NULL; } @@ -244,8 +245,8 @@ SBProcess::GetExitDescription () lldb::pid_t SBProcess::GetProcessID () { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetID(); + if (m_opaque_sp) + return m_opaque_sp->GetID(); else return LLDB_INVALID_PROCESS_ID; } @@ -253,85 +254,12 @@ SBProcess::GetProcessID () uint32_t SBProcess::GetAddressByteSize () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetAddressByteSize(); + if (m_opaque_sp) + return m_opaque_sp->GetAddressByteSize(); else return 0; } - -void -SBProcess::DisplayThreadsInfo (FILE *out, FILE *err, bool only_threads_with_stop_reason) -{ - if (m_lldb_object_sp != NULL) - { - size_t num_thread_infos_dumped = 0; - size_t num_threads = GetNumThreads(); - - if (out == NULL) - out = SBDebugger::GetOutputFileHandle(); - - if (err == NULL) - err = SBDebugger::GetErrorFileHandle(); - - if ((out == NULL) ||(err == NULL)) - return; - - if (num_threads > 0) - { - Thread::StopInfo thread_stop_info; - SBThread curr_thread (m_lldb_object_sp->GetThreadList().GetCurrentThread()); - for (int i = 0; i < num_threads; ++i) - { - SBThread thread (m_lldb_object_sp->GetThreadList().GetThreadAtIndex(i)); - if (thread.IsValid()) - { - bool is_current_thread = false; - StreamFile str (out); - if (thread == curr_thread) - is_current_thread = true; - StopReason thread_stop_reason = eStopReasonNone; - if (thread->GetStopInfo (&thread_stop_info)) - { - thread_stop_reason = thread_stop_info.GetStopReason(); - if (thread_stop_reason == eStopReasonNone) - { - if (only_threads_with_stop_reason && !is_current_thread) - continue; - } - } - ++num_thread_infos_dumped; - fprintf (out, " %c thread #%u: tid = 0x%4.4x, pc = 0x%16.16llx", - (is_current_thread ? '*' : ' '), - thread->GetIndexID(), thread->GetID(), thread->GetRegisterContext()->GetPC()); - - StackFrameSP frame_sp(thread->GetStackFrameAtIndex (0)); - if (frame_sp) - { - SymbolContext sc (frame_sp->GetSymbolContext (eSymbolContextEverything)); - fprintf (out, ", where = "); - sc.DumpStopContext (&str, m_lldb_object_sp.get(), frame_sp->GetPC ()); - } - - if (thread_stop_reason != eStopReasonNone) - { - fprintf (out, ", stop reason = "); - thread_stop_info.Dump (&str); - } - - const char *thread_name = thread->GetName(); - if (thread_name && thread_name[0]) - fprintf (out, ", thread_name = '%s'", thread_name); - - fprintf (out, "\n"); - - SBThread sb_thread (thread); - sb_thread.DisplayFramesForCurrentContext (out, err, 0, 1, false, 1); - } - } - } - } -} bool SBProcess::WaitUntilProcessHasStopped (SBCommandReturnObject &result) { @@ -340,11 +268,11 @@ SBProcess::WaitUntilProcessHasStopped (SBCommandReturnObject &result) if (IsValid()) { EventSP event_sp; - StateType state = m_lldb_object_sp->WaitForStateChangedEvents (NULL, event_sp); + StateType state = m_opaque_sp->WaitForStateChangedEvents (NULL, event_sp); while (StateIsStoppedState (state)) { - state = m_lldb_object_sp->WaitForStateChangedEvents (NULL, event_sp); + state = m_opaque_sp->WaitForStateChangedEvents (NULL, event_sp); SBEvent event (event_sp); AppendCurrentStateReport (event, result); state_changed = true; @@ -358,7 +286,7 @@ SBProcess::Continue () { SBError sb_error; if (IsValid()) - sb_error.SetError(m_lldb_object_sp->Resume()); + sb_error.SetError(m_opaque_sp->Resume()); else sb_error.SetErrorString ("SBProcess is invalid"); @@ -370,8 +298,8 @@ SBError SBProcess::Destroy () { SBError sb_error; - if (m_lldb_object_sp) - sb_error.SetError(m_lldb_object_sp->Destroy()); + if (m_opaque_sp) + sb_error.SetError(m_opaque_sp->Destroy()); else sb_error.SetErrorString ("SBProcess is invalid"); @@ -384,7 +312,7 @@ SBProcess::Stop () { SBError sb_error; if (IsValid()) - sb_error.SetError (m_lldb_object_sp->Halt()); + sb_error.SetError (m_opaque_sp->Halt()); else sb_error.SetErrorString ("SBProcess is invalid"); return sb_error; @@ -394,8 +322,8 @@ SBError SBProcess::Kill () { SBError sb_error; - if (m_lldb_object_sp) - sb_error.SetError (m_lldb_object_sp->Destroy()); + if (m_opaque_sp) + sb_error.SetError (m_opaque_sp->Destroy()); else sb_error.SetErrorString ("SBProcess is invalid"); return sb_error; @@ -406,8 +334,8 @@ SBError SBProcess::AttachByName (const char *name, bool wait_for_launch) { SBError sb_error; - if (m_lldb_object_sp) - sb_error.SetError (m_lldb_object_sp->Attach (name, wait_for_launch)); + if (m_opaque_sp) + sb_error.SetError (m_opaque_sp->Attach (name, wait_for_launch)); else sb_error.SetErrorString ("SBProcess is invalid"); return sb_error; @@ -425,8 +353,8 @@ SBError SBProcess::Attach (lldb::pid_t attach_pid) { SBError sb_error; - if (m_lldb_object_sp) - sb_error.SetError (m_lldb_object_sp->Attach (attach_pid)); + if (m_opaque_sp) + sb_error.SetError (m_opaque_sp->Attach (attach_pid)); else sb_error.SetErrorString ("SBProcess is invalid"); return sb_error; @@ -436,8 +364,8 @@ SBError SBProcess::Detach () { SBError sb_error; - if (m_lldb_object_sp) - sb_error.SetError (m_lldb_object_sp->Detach()); + if (m_opaque_sp) + sb_error.SetError (m_opaque_sp->Detach()); else sb_error.SetErrorString ("SBProcess is invalid"); @@ -448,102 +376,38 @@ SBError SBProcess::Signal (int signal) { SBError sb_error; - if (m_lldb_object_sp) - sb_error.SetError (m_lldb_object_sp->Signal (signal)); + if (m_opaque_sp) + sb_error.SetError (m_opaque_sp->Signal (signal)); else sb_error.SetErrorString ("SBProcess is invalid"); return sb_error; } -void -SBProcess::ListThreads () -{ - FILE *out = SBDebugger::GetOutputFileHandle(); - if (out == NULL) - return; - - if (m_lldb_object_sp) - { - size_t num_threads = GetNumThreads (); - if (num_threads > 0) - { - Thread *cur_thread = m_lldb_object_sp->GetThreadList().GetCurrentThread().get(); - for (int i = 0; i < num_threads; ++i) - { - Thread *thread = m_lldb_object_sp->GetThreadList().GetThreadAtIndex(i).get(); - if (thread) - { - bool is_current_thread = false; - if (thread == cur_thread) - is_current_thread = true; - fprintf (out, " [%u] %c tid = 0x%4.4x, pc = 0x%16.16llx", - i, - (is_current_thread ? '*' : ' '), - thread->GetID(), - thread->GetRegisterContext()->GetPC()); - const char *thread_name = thread->GetName(); - if (thread_name && thread_name[0]) - fprintf (out, ", name = %s", thread_name); - const char *queue_name = thread->GetQueueName(); - if (queue_name && queue_name[0]) - fprintf (out, ", queue = %s", queue_name); - fprintf (out, "\n"); - } - } - } - } -} - SBThread SBProcess::GetThreadByID (tid_t sb_thread_id) { SBThread thread; - if (m_lldb_object_sp) - thread.SetThread (m_lldb_object_sp->GetThreadList().FindThreadByID ((tid_t) sb_thread_id)); + if (m_opaque_sp) + thread.SetThread (m_opaque_sp->GetThreadList().FindThreadByID ((tid_t) sb_thread_id)); return thread; } -void -SBProcess::Backtrace (bool all_threads, uint32_t num_frames) -{ - if (m_lldb_object_sp) - { - if (!all_threads) - { - SBDebugger::UpdateCurrentThread (*this); - SBThread cur_thread = GetCurrentThread(); - if (cur_thread.IsValid()) - cur_thread.Backtrace (num_frames); - } - else - { - int num_threads = GetNumThreads (); - for (int i = 0; i < num_threads; ++i) - { - SBThread sb_thread = GetThreadAtIndex (i); - sb_thread.Backtrace (num_frames); - } - } - } -} - StateType SBProcess::GetStateFromEvent (const SBEvent &event) { - return Process::ProcessEventData::GetStateFromEvent (event.GetLLDBObjectPtr()); + return Process::ProcessEventData::GetStateFromEvent (event.get()); } - bool SBProcess::GetRestartedFromEvent (const SBEvent &event) { - return Process::ProcessEventData::GetRestartedFromEvent (event.GetLLDBObjectPtr()); + return Process::ProcessEventData::GetRestartedFromEvent (event.get()); } SBProcess SBProcess::GetProcessFromEvent (const SBEvent &event) { - SBProcess process(Process::ProcessEventData::GetProcessFromEvent (event.GetLLDBObjectPtr())); + SBProcess process(Process::ProcessEventData::GetProcessFromEvent (event.get())); return process; } @@ -551,14 +415,14 @@ SBProcess::GetProcessFromEvent (const SBEvent &event) SBBroadcaster SBProcess::GetBroadcaster () const { - SBBroadcaster broadcaster(m_lldb_object_sp.get(), false); + SBBroadcaster broadcaster(m_opaque_sp.get(), false); return broadcaster; } lldb_private::Process * SBProcess::operator->() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } size_t @@ -569,7 +433,7 @@ SBProcess::ReadMemory (addr_t addr, void *dst, size_t dst_len, SBError &sb_error if (IsValid()) { Error error; - bytes_read = m_lldb_object_sp->ReadMemory (addr, dst, dst_len, error); + bytes_read = m_opaque_sp->ReadMemory (addr, dst, dst_len, error); sb_error.SetError (error); } else @@ -588,7 +452,7 @@ SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &s if (IsValid()) { Error error; - bytes_written = m_lldb_object_sp->WriteMemory (addr, src, src_len, error); + bytes_written = m_opaque_sp->WriteMemory (addr, src, src_len, error); sb_error.SetError (error); } @@ -599,6 +463,6 @@ SBProcess::WriteMemory (addr_t addr, const void *src, size_t src_len, SBError &s lldb_private::Process * SBProcess::get() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } diff --git a/lldb/source/API/SBSourceManager.cpp b/lldb/source/API/SBSourceManager.cpp index c8a0874c7e3..701665edb46 100644 --- a/lldb/source/API/SBSourceManager.cpp +++ b/lldb/source/API/SBSourceManager.cpp @@ -21,7 +21,7 @@ using namespace lldb_private; SBSourceManager::SBSourceManager (SourceManager& source_manager) : - m_source_manager (source_manager) + m_opaque_ref (source_manager) { } @@ -48,12 +48,12 @@ SBSourceManager::DisplaySourceLinesWithLineNumbers StreamFile str (f); - return m_source_manager.DisplaySourceLinesWithLineNumbers (*file, - line, - context_before, - context_after, - current_line_cstr, - &str); + return m_opaque_ref.DisplaySourceLinesWithLineNumbers (*file, + line, + context_before, + context_after, + current_line_cstr, + &str); } return 0; } @@ -61,5 +61,5 @@ SBSourceManager::DisplaySourceLinesWithLineNumbers SourceManager & SBSourceManager::GetLLDBManager () { - return m_source_manager; + return m_opaque_ref; } diff --git a/lldb/source/API/SBStringList.cpp b/lldb/source/API/SBStringList.cpp index b4cfb9b0c75..f15200061f6 100644 --- a/lldb/source/API/SBStringList.cpp +++ b/lldb/source/API/SBStringList.cpp @@ -15,22 +15,22 @@ using namespace lldb; using namespace lldb_private; SBStringList::SBStringList () : - m_lldb_object_ap () + m_opaque_ap () { } SBStringList::SBStringList (const lldb_private::StringList *lldb_strings_ptr) : - m_lldb_object_ap () + m_opaque_ap () { if (lldb_strings_ptr) - m_lldb_object_ap.reset (new lldb_private::StringList (*lldb_strings_ptr)); + m_opaque_ap.reset (new lldb_private::StringList (*lldb_strings_ptr)); } SBStringList::SBStringList (const SBStringList &rhs) : - m_lldb_object_ap () + m_opaque_ap () { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::StringList(*rhs)); + m_opaque_ap.reset (new lldb_private::StringList(*rhs)); } @@ -44,7 +44,7 @@ const SBStringList & SBStringList::operator = (const SBStringList &rhs) { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::StringList(*rhs)); + m_opaque_ap.reset (new lldb_private::StringList(*rhs)); return *this; } @@ -52,19 +52,19 @@ SBStringList::operator = (const SBStringList &rhs) const lldb_private::StringList * SBStringList::operator->() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } const lldb_private::StringList & SBStringList::operator*() const { - return *m_lldb_object_ap; + return *m_opaque_ap; } bool SBStringList::IsValid() const { - return (m_lldb_object_ap.get() != NULL); + return (m_opaque_ap.get() != NULL); } void @@ -73,9 +73,9 @@ SBStringList::AppendString (const char *str) if (str != NULL) { if (IsValid()) - m_lldb_object_ap->AppendString (str); + m_opaque_ap->AppendString (str); else - m_lldb_object_ap.reset (new lldb_private::StringList (str)); + m_opaque_ap.reset (new lldb_private::StringList (str)); } } @@ -87,9 +87,9 @@ SBStringList::AppendList (const char **strv, int strc) && (strc > 0)) { if (IsValid()) - m_lldb_object_ap->AppendList (strv, strc); + m_opaque_ap->AppendList (strv, strc); else - m_lldb_object_ap.reset (new lldb_private::StringList (strv, strc)); + m_opaque_ap.reset (new lldb_private::StringList (strv, strc)); } } @@ -99,8 +99,8 @@ SBStringList::AppendList (SBStringList strings) if (strings.IsValid()) { if (! IsValid()) - m_lldb_object_ap.reset (new lldb_private::StringList()); - m_lldb_object_ap->AppendList (*(strings.m_lldb_object_ap)); + m_opaque_ap.reset (new lldb_private::StringList()); + m_opaque_ap->AppendList (*(strings.m_opaque_ap)); } } @@ -109,7 +109,7 @@ SBStringList::GetSize () const { if (IsValid()) { - return m_lldb_object_ap->GetSize(); + return m_opaque_ap->GetSize(); } return 0; } @@ -119,7 +119,7 @@ SBStringList::GetStringAtIndex (size_t idx) { if (IsValid()) { - return m_lldb_object_ap->GetStringAtIndex (idx); + return m_opaque_ap->GetStringAtIndex (idx); } return NULL; } @@ -129,6 +129,6 @@ SBStringList::Clear () { if (IsValid()) { - m_lldb_object_ap->Clear(); + m_opaque_ap->Clear(); } } diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp index 8500c8bd8a6..502efaa09dc 100644 --- a/lldb/source/API/SBSymbol.cpp +++ b/lldb/source/API/SBSymbol.cpp @@ -14,39 +14,39 @@ using namespace lldb; SBSymbol::SBSymbol () : - m_lldb_object_ptr (NULL) + m_opaque_ptr (NULL) { } SBSymbol::SBSymbol (lldb_private::Symbol *lldb_object_ptr) : - m_lldb_object_ptr (lldb_object_ptr) + m_opaque_ptr (lldb_object_ptr) { } SBSymbol::~SBSymbol () { - m_lldb_object_ptr = NULL; + m_opaque_ptr = NULL; } bool SBSymbol::IsValid () const { - return m_lldb_object_ptr != NULL; + return m_opaque_ptr != NULL; } const char * SBSymbol::GetName() const { - if (m_lldb_object_ptr) - return m_lldb_object_ptr->GetMangled().GetName().AsCString(); + if (m_opaque_ptr) + return m_opaque_ptr->GetMangled().GetName().AsCString(); return NULL; } const char * SBSymbol::GetMangledName () const { - if (m_lldb_object_ptr) - return m_lldb_object_ptr->GetMangled().GetMangledName().AsCString(); + if (m_opaque_ptr) + return m_opaque_ptr->GetMangled().GetMangledName().AsCString(); return NULL; } @@ -54,11 +54,11 @@ SBSymbol::GetMangledName () const bool SBSymbol::operator == (const SBSymbol &rhs) const { - return m_lldb_object_ptr == rhs.m_lldb_object_ptr; + return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBSymbol::operator != (const SBSymbol &rhs) const { - return m_lldb_object_ptr != rhs.m_lldb_object_ptr; + return m_opaque_ptr != rhs.m_opaque_ptr; } diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp index dec85295213..d19256928e6 100644 --- a/lldb/source/API/SBSymbolContext.cpp +++ b/lldb/source/API/SBSymbolContext.cpp @@ -16,22 +16,22 @@ using namespace lldb_private; SBSymbolContext::SBSymbolContext () : - m_lldb_object_ap () + m_opaque_ap () { } SBSymbolContext::SBSymbolContext (const SymbolContext *sc_ptr) : - m_lldb_object_ap () + m_opaque_ap () { if (sc_ptr) - m_lldb_object_ap.reset (new SymbolContext (*sc_ptr)); + m_opaque_ap.reset (new SymbolContext (*sc_ptr)); } SBSymbolContext::SBSymbolContext (const SBSymbolContext& rhs) : - m_lldb_object_ap () + m_opaque_ap () { if (rhs.IsValid()) - *m_lldb_object_ap = *rhs.m_lldb_object_ap; + *m_opaque_ap = *rhs.m_opaque_ap; } SBSymbolContext::~SBSymbolContext () @@ -44,7 +44,7 @@ SBSymbolContext::operator = (const SBSymbolContext &rhs) if (this != &rhs) { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::SymbolContext(*rhs.m_lldb_object_ap.get())); + m_opaque_ap.reset (new lldb_private::SymbolContext(*rhs.m_opaque_ap.get())); } return *this; } @@ -54,22 +54,22 @@ SBSymbolContext::SetSymbolContext (const SymbolContext *sc_ptr) { if (sc_ptr) { - if (m_lldb_object_ap.get()) - *m_lldb_object_ap = *sc_ptr; + if (m_opaque_ap.get()) + *m_opaque_ap = *sc_ptr; else - m_lldb_object_ap.reset (new SymbolContext (*sc_ptr)); + m_opaque_ap.reset (new SymbolContext (*sc_ptr)); } else { - if (m_lldb_object_ap.get()) - m_lldb_object_ap->Clear(); + if (m_opaque_ap.get()) + m_opaque_ap->Clear(); } } bool SBSymbolContext::IsValid () const { - return m_lldb_object_ap.get() != NULL; + return m_opaque_ap.get() != NULL; } @@ -78,35 +78,35 @@ SBModule SBSymbolContext::GetModule () { SBModule sb_module; - if (m_lldb_object_ap.get()) - sb_module.SetModule(m_lldb_object_ap->module_sp); + if (m_opaque_ap.get()) + sb_module.SetModule(m_opaque_ap->module_sp); return sb_module; } SBCompileUnit SBSymbolContext::GetCompileUnit () { - return SBCompileUnit (m_lldb_object_ap.get() ? m_lldb_object_ap->comp_unit : NULL); + return SBCompileUnit (m_opaque_ap.get() ? m_opaque_ap->comp_unit : NULL); } SBFunction SBSymbolContext::GetFunction () { - return SBFunction (m_lldb_object_ap.get() ? m_lldb_object_ap->function : NULL); + return SBFunction (m_opaque_ap.get() ? m_opaque_ap->function : NULL); } SBBlock SBSymbolContext::GetBlock () { - return SBBlock (m_lldb_object_ap.get() ? m_lldb_object_ap->block : NULL); + return SBBlock (m_opaque_ap.get() ? m_opaque_ap->block : NULL); } SBLineEntry SBSymbolContext::GetLineEntry () { SBLineEntry sb_line_entry; - if (m_lldb_object_ap.get()) - sb_line_entry.SetLineEntry (m_lldb_object_ap->line_entry); + if (m_opaque_ap.get()) + sb_line_entry.SetLineEntry (m_opaque_ap->line_entry); return sb_line_entry; } @@ -114,19 +114,19 @@ SBSymbolContext::GetLineEntry () SBSymbol SBSymbolContext::GetSymbol () { - return SBSymbol (m_lldb_object_ap.get() ? m_lldb_object_ap->symbol : NULL); + return SBSymbol (m_opaque_ap.get() ? m_opaque_ap->symbol : NULL); } lldb_private::SymbolContext* SBSymbolContext::operator->() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } lldb_private::SymbolContext * SBSymbolContext::GetLLDBObjectPtr() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 3fba69e307f..ff08689acd9 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -53,12 +53,12 @@ SBTarget::SBTarget () } SBTarget::SBTarget (const SBTarget& rhs) : - m_target_sp (rhs.m_target_sp) + m_opaque_sp (rhs.m_opaque_sp) { } SBTarget::SBTarget(const TargetSP& target_sp) : - m_target_sp (target_sp) + m_opaque_sp (target_sp) { } @@ -67,7 +67,7 @@ SBTarget::Assign (const SBTarget& rhs) { if (this != &rhs) { - m_target_sp = rhs.m_target_sp; + m_opaque_sp = rhs.m_opaque_sp; } return *this; } @@ -83,28 +83,37 @@ SBTarget::~SBTarget() bool SBTarget::IsValid () const { - return m_target_sp.get() != NULL; + return m_opaque_sp.get() != NULL; } SBProcess SBTarget::GetProcess () { SBProcess sb_process; - if (IsValid()) - sb_process.SetProcess (m_target_sp->GetProcessSP()); + if (m_opaque_sp) + sb_process.SetProcess (m_opaque_sp->GetProcessSP()); return sb_process; } +SBDebugger +SBTarget::GetDebugger () const +{ + SBDebugger debugger; + if (m_opaque_sp) + debugger.reset (m_opaque_sp->GetDebugger().GetSP()); + return debugger; +} + SBProcess SBTarget::CreateProcess () { SBProcess sb_process; - if (IsValid()) + if (m_opaque_sp) { - SBListener sb_listener = SBDebugger::GetListener(); + SBListener sb_listener (m_opaque_sp->GetDebugger().GetListener()); if (sb_listener.IsValid()) - sb_process.SetProcess (m_target_sp->CreateProcess (*sb_listener)); + sb_process.SetProcess (m_opaque_sp->CreateProcess (*sb_listener)); } return sb_process; } @@ -141,9 +150,9 @@ SBFileSpec SBTarget::GetExecutable () { SBFileSpec exe_file_spec; - if (IsValid()) + if (m_opaque_sp) { - ModuleSP exe_module_sp (m_target_sp->GetExecutableModule ()); + ModuleSP exe_module_sp (m_opaque_sp->GetExecutableModule ()); if (exe_module_sp) exe_file_spec.SetFileSpec (exe_module_sp->GetFileSpec()); } @@ -154,8 +163,8 @@ SBTarget::GetExecutable () bool SBTarget::DeleteTargetFromList (TargetList *list) { - if (IsValid()) - return list->DeleteTarget (m_target_sp); + if (m_opaque_sp) + return list->DeleteTarget (m_opaque_sp); else return false; } @@ -163,9 +172,9 @@ SBTarget::DeleteTargetFromList (TargetList *list) bool SBTarget::MakeCurrentTarget () { - if (IsValid()) + if (m_opaque_sp) { - Debugger::GetSharedInstance().GetTargetList().SetCurrentTarget (m_target_sp.get()); + m_opaque_sp->GetDebugger().GetTargetList().SetCurrentTarget (m_opaque_sp.get()); return true; } return false; @@ -174,24 +183,31 @@ SBTarget::MakeCurrentTarget () bool SBTarget::operator == (const SBTarget &rhs) const { - return m_target_sp.get() == rhs.m_target_sp.get(); + return m_opaque_sp.get() == rhs.m_opaque_sp.get(); } bool SBTarget::operator != (const SBTarget &rhs) const { - return m_target_sp.get() != rhs.m_target_sp.get(); + return m_opaque_sp.get() != rhs.m_opaque_sp.get(); } lldb_private::Target * -SBTarget::GetLLDBObjectPtr() +SBTarget::operator ->() const { - return m_target_sp.get(); + return m_opaque_sp.get(); } -const lldb_private::Target * -SBTarget::GetLLDBObjectPtr() const + +lldb_private::Target * +SBTarget::get() const +{ + return m_opaque_sp.get(); +} + +void +SBTarget::reset (const lldb::TargetSP& target_sp) { - return m_target_sp.get(); + m_opaque_sp = target_sp; } SBBreakpoint @@ -207,8 +223,8 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t line) { SBBreakpoint sb_bp; - if (m_target_sp.get() && line != 0) - *sb_bp = m_target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, true, false); + if (m_opaque_sp.get() && line != 0) + *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, *sb_file_spec, line, true, false); return sb_bp; } @@ -216,16 +232,16 @@ SBBreakpoint SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_name) { SBBreakpoint sb_bp; - if (m_target_sp.get() && symbol_name && symbol_name[0]) + if (m_opaque_sp.get() && symbol_name && symbol_name[0]) { if (module_name && module_name[0]) { FileSpec module_file_spec(module_name); - *sb_bp = m_target_sp->CreateBreakpoint (&module_file_spec, symbol_name, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, symbol_name, false); } else { - *sb_bp = m_target_sp->CreateBreakpoint (NULL, symbol_name, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, symbol_name, false); } } return sb_bp; @@ -235,7 +251,7 @@ SBBreakpoint SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name) { SBBreakpoint sb_bp; - if (m_target_sp.get() && symbol_name_regex && symbol_name_regex[0]) + if (m_opaque_sp.get() && symbol_name_regex && symbol_name_regex[0]) { RegularExpression regexp(symbol_name_regex); @@ -243,11 +259,11 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *mo { FileSpec module_file_spec(module_name); - *sb_bp = m_target_sp->CreateBreakpoint (&module_file_spec, regexp, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, regexp, false); } else { - *sb_bp = m_target_sp->CreateBreakpoint (NULL, regexp, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, regexp, false); } } return sb_bp; @@ -259,22 +275,22 @@ SBBreakpoint SBTarget::BreakpointCreateByAddress (addr_t address) { SBBreakpoint sb_bp; - if (m_target_sp.get()) - *sb_bp = m_target_sp->CreateBreakpoint (address, false); + if (m_opaque_sp.get()) + *sb_bp = m_opaque_sp->CreateBreakpoint (address, false); return sb_bp; } void SBTarget::ListAllBreakpoints () { - FILE *out_file = SBDebugger::GetOutputFileHandle(); + FILE *out_file = m_opaque_sp->GetDebugger().GetOutputFileHandle(); if (out_file == NULL) return; - if (IsValid()) + if (m_opaque_sp) { - const BreakpointList &bp_list = m_target_sp->GetBreakpointList(); + const BreakpointList &bp_list = m_opaque_sp->GetBreakpointList(); size_t num_bps = bp_list.GetSize(); for (int i = 0; i < num_bps; ++i) { @@ -288,8 +304,8 @@ SBBreakpoint SBTarget::FindBreakpointByID (break_id_t bp_id) { SBBreakpoint sb_breakpoint; - if (m_target_sp && bp_id != LLDB_INVALID_BREAK_ID) - *sb_breakpoint = m_target_sp->GetBreakpointByID (bp_id); + if (m_opaque_sp && bp_id != LLDB_INVALID_BREAK_ID) + *sb_breakpoint = m_opaque_sp->GetBreakpointByID (bp_id); return sb_breakpoint; } @@ -297,17 +313,17 @@ SBTarget::FindBreakpointByID (break_id_t bp_id) bool SBTarget::BreakpointDelete (break_id_t bp_id) { - if (m_target_sp) - return m_target_sp->RemoveBreakpointByID (bp_id); + if (m_opaque_sp) + return m_opaque_sp->RemoveBreakpointByID (bp_id); return false; } bool SBTarget::EnableAllBreakpoints () { - if (m_target_sp) + if (m_opaque_sp) { - m_target_sp->EnableAllBreakpoints (); + m_opaque_sp->EnableAllBreakpoints (); return true; } return false; @@ -316,9 +332,9 @@ SBTarget::EnableAllBreakpoints () bool SBTarget::DisableAllBreakpoints () { - if (m_target_sp) + if (m_opaque_sp) { - m_target_sp->DisableAllBreakpoints (); + m_opaque_sp->DisableAllBreakpoints (); return true; } return false; @@ -327,9 +343,9 @@ SBTarget::DisableAllBreakpoints () bool SBTarget::DeleteAllBreakpoints () { - if (m_target_sp) + if (m_opaque_sp) { - m_target_sp->RemoveAllBreakpoints (); + m_opaque_sp->RemoveAllBreakpoints (); return true; } return false; @@ -339,8 +355,8 @@ SBTarget::DeleteAllBreakpoints () uint32_t SBTarget::GetNumModules () const { - if (m_target_sp) - return m_target_sp->GetImages().GetSize(); + if (m_opaque_sp) + return m_opaque_sp->GetImages().GetSize(); return 0; } @@ -348,8 +364,8 @@ SBModule SBTarget::FindModule (const SBFileSpec &sb_file_spec) { SBModule sb_module; - if (m_target_sp && sb_file_spec.IsValid()) - sb_module.SetModule (m_target_sp->GetImages().FindFirstModuleForFileSpec (*sb_file_spec, NULL)); + if (m_opaque_sp && sb_file_spec.IsValid()) + sb_module.SetModule (m_opaque_sp->GetImages().FindFirstModuleForFileSpec (*sb_file_spec, NULL)); return sb_module; } @@ -357,8 +373,8 @@ SBModule SBTarget::GetModuleAtIndex (uint32_t idx) { SBModule sb_module; - if (m_target_sp) - sb_module.SetModule(m_target_sp->GetImages().GetModuleAtIndex(idx)); + if (m_opaque_sp) + sb_module.SetModule(m_opaque_sp->GetImages().GetModuleAtIndex(idx)); return sb_module; } @@ -366,7 +382,7 @@ SBTarget::GetModuleAtIndex (uint32_t idx) SBBroadcaster SBTarget::GetBroadcaster () const { - SBBroadcaster broadcaster(m_target_sp.get(), false); + SBBroadcaster broadcaster(m_opaque_sp.get(), false); return broadcaster; } @@ -376,11 +392,11 @@ SBTarget::Disassemble (lldb::addr_t file_address_start, lldb::addr_t file_addres if (file_address_start == LLDB_INVALID_ADDRESS) return; - FILE *out = SBDebugger::GetOutputFileHandle(); + FILE *out = m_opaque_sp->GetDebugger().GetOutputFileHandle(); if (out == NULL) return; - if (IsValid()) + if (m_opaque_sp) { SBModule module; if (module_name != NULL) @@ -388,7 +404,7 @@ SBTarget::Disassemble (lldb::addr_t file_address_start, lldb::addr_t file_addres SBFileSpec file_spec (module_name); module = FindModule (file_spec); } - ArchSpec arch (m_target_sp->GetArchitecture()); + ArchSpec arch (m_opaque_sp->GetArchitecture()); if (!arch.IsValid()) return; Disassembler *disassembler = Disassembler::FindPlugin (arch); @@ -446,11 +462,11 @@ SBTarget::Disassemble (const char *function_name, const char *module_name) if (function_name == NULL) return; - FILE *out = SBDebugger::GetOutputFileHandle(); + FILE *out = m_opaque_sp->GetDebugger().GetOutputFileHandle(); if (out == NULL) return; - if (IsValid()) + if (m_opaque_sp) { SBModule module; @@ -460,7 +476,7 @@ SBTarget::Disassemble (const char *function_name, const char *module_name) module = FindModule (file_spec); } - ArchSpec arch (m_target_sp->GetArchitecture()); + ArchSpec arch (m_opaque_sp->GetArchitecture()); if (!arch.IsValid()) return; @@ -486,7 +502,7 @@ SBTarget::Disassemble (const char *function_name, const char *module_name) if (module_name != NULL) containing_module = new FileSpec (module_name); - SearchFilterSP filter_sp (m_target_sp->GetSearchFilterForModule (containing_module)); + SearchFilterSP filter_sp (m_opaque_sp->GetSearchFilterForModule (containing_module)); AddressResolverSP resolver_sp (new AddressResolverName (function_name)); resolver_sp->ResolveAddress (*filter_sp); diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 7a86999c797..24e5484c9cf 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -11,8 +11,10 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Process.h" #include "lldb/Symbol/SymbolContext.h" @@ -35,7 +37,7 @@ using namespace lldb; using namespace lldb_private; SBThread::SBThread () : - m_lldb_object_sp () + m_opaque_sp () { } @@ -43,13 +45,13 @@ SBThread::SBThread () : // Thread constructor //---------------------------------------------------------------------- SBThread::SBThread (const ThreadSP& lldb_object_sp) : - m_lldb_object_sp (lldb_object_sp) + m_opaque_sp (lldb_object_sp) { } SBThread::SBThread (const SBThread &rhs) { - m_lldb_object_sp = rhs.m_lldb_object_sp; + m_opaque_sp = rhs.m_opaque_sp; } //---------------------------------------------------------------------- @@ -62,16 +64,16 @@ SBThread::~SBThread() bool SBThread::IsValid() const { - return m_lldb_object_sp != NULL; + return m_opaque_sp != NULL; } StopReason SBThread::GetStopReason() { - if (m_lldb_object_sp) + if (m_opaque_sp) { lldb_private::Thread::StopInfo thread_stop_info; - if (m_lldb_object_sp->GetStopInfo(&thread_stop_info)) + if (m_opaque_sp->GetStopInfo(&thread_stop_info)) return thread_stop_info.GetStopReason(); } return eStopReasonInvalid; @@ -80,10 +82,10 @@ SBThread::GetStopReason() size_t SBThread::GetStopDescription (char *dst, size_t dst_len) { - if (m_lldb_object_sp) + if (m_opaque_sp) { lldb_private::Thread::StopInfo thread_stop_info; - if (m_lldb_object_sp->GetStopInfo(&thread_stop_info)) + if (m_opaque_sp->GetStopInfo(&thread_stop_info)) { const char *stop_desc = thread_stop_info.GetStopDescription(); if (stop_desc) @@ -129,7 +131,7 @@ SBThread::GetStopDescription (char *dst, size_t dst_len) case eStopReasonSignal: { - stop_desc = m_lldb_object_sp->GetProcess().GetUnixSignals ().GetSignalAsCString (thread_stop_info.GetSignal()); + stop_desc = m_opaque_sp->GetProcess().GetUnixSignals ().GetSignalAsCString (thread_stop_info.GetSignal()); if (stop_desc == NULL || stop_desc[0] == '\0') { static char signal_desc[] = "signal"; @@ -169,15 +171,15 @@ SBThread::GetStopDescription (char *dst, size_t dst_len) void SBThread::SetThread (const ThreadSP& lldb_object_sp) { - m_lldb_object_sp = lldb_object_sp; + m_opaque_sp = lldb_object_sp; } lldb::tid_t SBThread::GetThreadID () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetID(); + if (m_opaque_sp) + return m_opaque_sp->GetID(); else return LLDB_INVALID_THREAD_ID; } @@ -185,23 +187,23 @@ SBThread::GetThreadID () const uint32_t SBThread::GetIndexID () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetIndexID(); + if (m_opaque_sp) + return m_opaque_sp->GetIndexID(); return LLDB_INVALID_INDEX32; } const char * SBThread::GetName () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetName(); + if (m_opaque_sp) + return m_opaque_sp->GetName(); return NULL; } const char * SBThread::GetQueueName () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetQueueName(); + if (m_opaque_sp) + return m_opaque_sp->GetQueueName(); return NULL; } @@ -219,9 +221,9 @@ SBThread::DisplayFramesForCurrentContext (FILE *out, if ((out == NULL) || (err == NULL)) return; - if (m_lldb_object_sp) + if (m_opaque_sp) { - uint32_t num_stack_frames = m_lldb_object_sp->GetStackFrameCount (); + uint32_t num_stack_frames = m_opaque_sp->GetStackFrameCount (); StackFrameSP frame_sp; int frame_idx = 0; @@ -230,7 +232,7 @@ SBThread::DisplayFramesForCurrentContext (FILE *out, if (frame_idx >= num_stack_frames) break; - frame_sp = m_lldb_object_sp->GetStackFrameAtIndex (frame_idx); + frame_sp = m_opaque_sp->GetStackFrameAtIndex (frame_idx); if (!frame_sp) break; @@ -257,17 +259,16 @@ SBThread::DisplaySingleFrameForCurrentContext (FILE *out, uint32_t source_lines_before) { bool success = false; - - if ((out == NULL) || (err == NULL)) + + if ((out == NULL) || (err == NULL)) return false; - - if (m_lldb_object_sp && frame.IsValid()) + + if (m_opaque_sp && frame.IsValid()) { - StreamFile str (out); - + SBSymbolContext sc(frame.GetSymbolContext(eSymbolContextEverything)); - + if (show_frame_info && sc.IsValid()) { user_id_t frame_idx = (user_id_t) frame.GetFrameID(); @@ -277,28 +278,28 @@ SBThread::DisplaySingleFrameForCurrentContext (FILE *out, frame_idx, GetThreadID(), pc); - sc->DumpStopContext (&str, &m_lldb_object_sp->GetProcess(), *frame.GetPCAddress()); + sc->DumpStopContext (&str, &m_opaque_sp->GetProcess(), *frame.GetPCAddress()); fprintf (out, "\n"); success = true; } - + SBCompileUnit comp_unit(sc.GetCompileUnit()); if (show_source && comp_unit.IsValid()) { - success = false; + success = false; SBLineEntry line_entry; if (line_entry.IsValid()) { - SBSourceManager& source_manager = SBDebugger::GetSourceManager(); - SBFileSpec line_entry_file_spec = line_entry.GetFileSpec(); - + SourceManager& source_manager = m_opaque_sp->GetProcess().GetTarget().GetDebugger().GetSourceManager(); + SBFileSpec line_entry_file_spec (line_entry.GetFileSpec()); + if (line_entry_file_spec.IsValid()) { - source_manager.DisplaySourceLinesWithLineNumbers (line_entry_file_spec, + source_manager.DisplaySourceLinesWithLineNumbers (line_entry_file_spec.ref(), line_entry.GetLine(), source_lines_after, source_lines_before, "->", - out); + &str); success = true; } } @@ -310,17 +311,17 @@ SBThread::DisplaySingleFrameForCurrentContext (FILE *out, void SBThread::StepOver (lldb::RunMode stop_other_threads) { - if (m_lldb_object_sp) + if (m_opaque_sp) { bool abort_other_plans = true; - StackFrameSP frame_sp(m_lldb_object_sp->GetStackFrameAtIndex (0)); + StackFrameSP frame_sp(m_opaque_sp->GetStackFrameAtIndex (0)); if (frame_sp) { if (frame_sp->HasDebugInformation ()) { SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); - m_lldb_object_sp->QueueThreadPlanForStepRange (abort_other_plans, + m_opaque_sp->QueueThreadPlanForStepRange (abort_other_plans, eStepTypeOver, sc.line_entry.range, sc, @@ -330,15 +331,15 @@ SBThread::StepOver (lldb::RunMode stop_other_threads) } else { - m_lldb_object_sp->QueueThreadPlanForStepSingleInstruction (true, + m_opaque_sp->QueueThreadPlanForStepSingleInstruction (true, abort_other_plans, stop_other_threads); } } - Process &process = m_lldb_object_sp->GetProcess(); + Process &process = m_opaque_sp->GetProcess(); // Why do we need to set the current thread by ID here??? - process.GetThreadList().SetCurrentThreadByID (m_lldb_object_sp->GetID()); + process.GetThreadList().SetCurrentThreadByID (m_opaque_sp->GetID()); process.Resume(); } } @@ -346,17 +347,17 @@ SBThread::StepOver (lldb::RunMode stop_other_threads) void SBThread::StepInto (lldb::RunMode stop_other_threads) { - if (m_lldb_object_sp) + if (m_opaque_sp) { bool abort_other_plans = true; - StackFrameSP frame_sp(m_lldb_object_sp->GetStackFrameAtIndex (0)); + StackFrameSP frame_sp(m_opaque_sp->GetStackFrameAtIndex (0)); if (frame_sp && frame_sp->HasDebugInformation ()) { bool avoid_code_without_debug_info = true; SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); - m_lldb_object_sp->QueueThreadPlanForStepRange (abort_other_plans, + m_opaque_sp->QueueThreadPlanForStepRange (abort_other_plans, eStepTypeInto, sc.line_entry.range, sc, @@ -365,14 +366,14 @@ SBThread::StepInto (lldb::RunMode stop_other_threads) } else { - m_lldb_object_sp->QueueThreadPlanForStepSingleInstruction (false, + m_opaque_sp->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, stop_other_threads); } - Process &process = m_lldb_object_sp->GetProcess(); + Process &process = m_opaque_sp->GetProcess(); // Why do we need to set the current thread by ID here??? - process.GetThreadList().SetCurrentThreadByID (m_lldb_object_sp->GetID()); + process.GetThreadList().SetCurrentThreadByID (m_opaque_sp->GetID()); process.Resume(); } @@ -381,15 +382,15 @@ SBThread::StepInto (lldb::RunMode stop_other_threads) void SBThread::StepOut () { - if (m_lldb_object_sp) + if (m_opaque_sp) { bool abort_other_plans = true; bool stop_other_threads = true; - m_lldb_object_sp->QueueThreadPlanForStepOut (abort_other_plans, NULL, false, stop_other_threads, eVoteYes, eVoteNoOpinion); + m_opaque_sp->QueueThreadPlanForStepOut (abort_other_plans, NULL, false, stop_other_threads, eVoteYes, eVoteNoOpinion); - Process &process = m_lldb_object_sp->GetProcess(); - process.GetThreadList().SetCurrentThreadByID (m_lldb_object_sp->GetID()); + Process &process = m_opaque_sp->GetProcess(); + process.GetThreadList().SetCurrentThreadByID (m_opaque_sp->GetID()); process.Resume(); } } @@ -397,11 +398,11 @@ SBThread::StepOut () void SBThread::StepInstruction (bool step_over) { - if (m_lldb_object_sp) + if (m_opaque_sp) { - m_lldb_object_sp->QueueThreadPlanForStepSingleInstruction (step_over, true, true); - Process &process = m_lldb_object_sp->GetProcess(); - process.GetThreadList().SetCurrentThreadByID (m_lldb_object_sp->GetID()); + m_opaque_sp->QueueThreadPlanForStepSingleInstruction (step_over, true, true); + Process &process = m_opaque_sp->GetProcess(); + process.GetThreadList().SetCurrentThreadByID (m_opaque_sp->GetID()); process.Resume(); } } @@ -409,67 +410,29 @@ SBThread::StepInstruction (bool step_over) void SBThread::RunToAddress (lldb::addr_t addr) { - if (m_lldb_object_sp) + if (m_opaque_sp) { bool abort_other_plans = true; bool stop_other_threads = true; Address target_addr (NULL, addr); - m_lldb_object_sp->QueueThreadPlanForRunToAddress (abort_other_plans, target_addr, stop_other_threads); - Process &process = m_lldb_object_sp->GetProcess(); - process.GetThreadList().SetCurrentThreadByID (m_lldb_object_sp->GetID()); + m_opaque_sp->QueueThreadPlanForRunToAddress (abort_other_plans, target_addr, stop_other_threads); + Process &process = m_opaque_sp->GetProcess(); + process.GetThreadList().SetCurrentThreadByID (m_opaque_sp->GetID()); process.Resume(); } } -void -SBThread::Backtrace (uint32_t num_frames) -{ - bool all_frames = false; - if (num_frames < 1) - all_frames = true; - - FILE *out = SBDebugger::GetOutputFileHandle(); - FILE *err = SBDebugger::GetErrorFileHandle(); - - if ((out == NULL) || (err == NULL)) - return; - - if (m_lldb_object_sp) - { - if (out && err) - { - int max_num_frames = m_lldb_object_sp->GetStackFrameCount(); - int last_frame = max_num_frames; - - if (!all_frames && (num_frames < last_frame)) - last_frame = num_frames; - - StackFrameSP frame_sp; - for (int i = 0; i < last_frame; ++i) - { - frame_sp = m_lldb_object_sp->GetStackFrameAtIndex (i); - if (!frame_sp) - break; - - SBFrame sb_frame (frame_sp); - if (DisplaySingleFrameForCurrentContext ((FILE *) out, (FILE *) err, sb_frame, true, false, 0, 0) == false) - break; - } - } - } -} - SBProcess SBThread::GetProcess () { SBProcess process; - if (m_lldb_object_sp) + if (m_opaque_sp) { // Have to go up to the target so we can get a shared pointer to our process... - process.SetProcess(m_lldb_object_sp->GetProcess().GetTarget().GetProcessSP()); + process.SetProcess(m_opaque_sp->GetProcess().GetTarget().GetProcessSP()); } return process; } @@ -477,8 +440,8 @@ SBThread::GetProcess () uint32_t SBThread::GetNumFrames () { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetStackFrameCount(); + if (m_opaque_sp) + return m_opaque_sp->GetStackFrameCount(); return 0; } @@ -486,56 +449,56 @@ SBFrame SBThread::GetFrameAtIndex (uint32_t idx) { SBFrame sb_frame; - if (m_lldb_object_sp) - sb_frame.SetFrame (m_lldb_object_sp->GetStackFrameAtIndex (idx)); + if (m_opaque_sp) + sb_frame.SetFrame (m_opaque_sp->GetStackFrameAtIndex (idx)); return sb_frame; } const lldb::SBThread & SBThread::operator = (const lldb::SBThread &rhs) { - m_lldb_object_sp = rhs.m_lldb_object_sp; + m_opaque_sp = rhs.m_opaque_sp; return *this; } bool SBThread::operator == (const SBThread &rhs) const { - return m_lldb_object_sp.get() == rhs.m_lldb_object_sp.get(); + return m_opaque_sp.get() == rhs.m_opaque_sp.get(); } bool SBThread::operator != (const SBThread &rhs) const { - return m_lldb_object_sp.get() != rhs.m_lldb_object_sp.get(); + return m_opaque_sp.get() != rhs.m_opaque_sp.get(); } lldb_private::Thread * SBThread::GetLLDBObjectPtr () { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } const lldb_private::Thread * SBThread::operator->() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } const lldb_private::Thread & SBThread::operator*() const { - return *m_lldb_object_sp; + return *m_opaque_sp; } lldb_private::Thread * SBThread::operator->() { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } lldb_private::Thread & SBThread::operator*() { - return *m_lldb_object_sp; + return *m_opaque_sp; } diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index ab622c7e7e8..e381246174b 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -33,12 +33,12 @@ using namespace lldb; using namespace lldb_private; SBValue::SBValue () : - m_lldb_object_sp () + m_opaque_sp () { } SBValue::SBValue (const lldb::ValueObjectSP &value_sp) : - m_lldb_object_sp (value_sp) + m_opaque_sp (value_sp) { } @@ -49,7 +49,7 @@ SBValue::~SBValue() bool SBValue::IsValid () const { - return (m_lldb_object_sp.get() != NULL); + return (m_opaque_sp.get() != NULL); } void @@ -72,25 +72,25 @@ SBValue::Print (FILE *out_file, SBFrame *frame, bool print_type, bool print_valu lldb_private::StreamFile out_stream (out_file); - out_stream.Printf ("%s ", m_lldb_object_sp->GetName().AsCString (NULL)); - if (! m_lldb_object_sp->IsInScope (lldb_frame)) + out_stream.Printf ("%s ", m_opaque_sp->GetName().AsCString (NULL)); + if (! m_opaque_sp->IsInScope (lldb_frame)) out_stream.Printf ("[out-of-scope] "); if (print_type) { - out_stream.Printf ("(%s) ", m_lldb_object_sp->GetTypeName().AsCString ("<unknown-type>")); + out_stream.Printf ("(%s) ", m_opaque_sp->GetTypeName().AsCString ("<unknown-type>")); } if (print_value) { ExecutionContextScope *exe_scope = frame->get(); - const char *val_cstr = m_lldb_object_sp->GetValueAsCString(exe_scope); - const char *err_cstr = m_lldb_object_sp->GetError().AsCString(); + const char *val_cstr = m_opaque_sp->GetValueAsCString(exe_scope); + const char *err_cstr = m_opaque_sp->GetError().AsCString(); if (!err_cstr) { - const char *sum_cstr = m_lldb_object_sp->GetSummaryAsCString(exe_scope); + const char *sum_cstr = m_opaque_sp->GetSummaryAsCString(exe_scope); const bool is_aggregate = - ClangASTContext::IsAggregateType (m_lldb_object_sp->GetOpaqueClangQualType()); + ClangASTContext::IsAggregateType (m_opaque_sp->GetOpaqueClangQualType()); if (val_cstr) out_stream.Printf ("= %s ", val_cstr); @@ -100,13 +100,13 @@ SBValue::Print (FILE *out_file, SBFrame *frame, bool print_type, bool print_valu if (is_aggregate) { out_stream.PutChar ('{'); - const uint32_t num_children = m_lldb_object_sp->GetNumChildren(); + const uint32_t num_children = m_opaque_sp->GetNumChildren(); if (num_children) { out_stream.IndentMore(); for (uint32_t idx = 0; idx < num_children; ++idx) { - lldb::ValueObjectSP child_sp (m_lldb_object_sp->GetChildAtIndex (idx, true)); + lldb::ValueObjectSP child_sp (m_opaque_sp->GetChildAtIndex (idx, true)); if (child_sp.get()) { out_stream.EOL(); @@ -131,7 +131,7 @@ const char * SBValue::GetName() { if (IsValid()) - return m_lldb_object_sp->GetName().AsCString(); + return m_opaque_sp->GetName().AsCString(); else return NULL; } @@ -140,7 +140,7 @@ const char * SBValue::GetTypeName () { if (IsValid()) - return m_lldb_object_sp->GetTypeName().AsCString(); + return m_opaque_sp->GetTypeName().AsCString(); else return NULL; } @@ -151,7 +151,7 @@ SBValue::GetByteSize () size_t result = 0; if (IsValid()) - result = m_lldb_object_sp->GetByteSize(); + result = m_opaque_sp->GetByteSize(); return result; } @@ -162,7 +162,7 @@ SBValue::IsInScope (const SBFrame &frame) bool result = false; if (IsValid()) - result = m_lldb_object_sp->IsInScope (frame.get()); + result = m_opaque_sp->IsInScope (frame.get()); return result; } @@ -171,8 +171,8 @@ const char * SBValue::GetValue (const SBFrame &frame) { const char *value_string = NULL; - if ( m_lldb_object_sp) - value_string = m_lldb_object_sp->GetValueAsCString(frame.get()); + if ( m_opaque_sp) + value_string = m_opaque_sp->GetValueAsCString(frame.get()); return value_string; } @@ -180,7 +180,7 @@ bool SBValue::GetValueDidChange () { if (IsValid()) - return m_lldb_object_sp->GetValueDidChange(); + return m_opaque_sp->GetValueDidChange(); return false; } @@ -188,8 +188,8 @@ const char * SBValue::GetSummary (const SBFrame &frame) { const char *value_string = NULL; - if ( m_lldb_object_sp) - value_string = m_lldb_object_sp->GetSummaryAsCString(frame.get()); + if ( m_opaque_sp) + value_string = m_opaque_sp->GetSummaryAsCString(frame.get()); return value_string; } @@ -198,7 +198,7 @@ SBValue::GetLocation (const SBFrame &frame) { const char *value_string = NULL; if (IsValid()) - value_string = m_lldb_object_sp->GetLocationAsCString(frame.get()); + value_string = m_opaque_sp->GetLocationAsCString(frame.get()); return value_string; } @@ -207,7 +207,7 @@ SBValue::SetValueFromCString (const SBFrame &frame, const char *value_str) { bool success = false; if (IsValid()) - success = m_lldb_object_sp->SetValueFromCString (frame.get(), value_str); + success = m_opaque_sp->SetValueFromCString (frame.get(), value_str); return success; } @@ -218,7 +218,7 @@ SBValue::GetChildAtIndex (uint32_t idx) if (IsValid()) { - child_sp = m_lldb_object_sp->GetChildAtIndex (idx, true); + child_sp = m_opaque_sp->GetChildAtIndex (idx, true); } SBValue sb_value (child_sp); @@ -229,7 +229,7 @@ uint32_t SBValue::GetIndexOfChildWithName (const char *name) { if (IsValid()) - return m_lldb_object_sp->GetIndexOfChildWithName (ConstString(name)); + return m_opaque_sp->GetIndexOfChildWithName (ConstString(name)); return UINT32_MAX; } @@ -241,7 +241,7 @@ SBValue::GetChildMemberWithName (const char *name) if (IsValid()) { - child_sp = m_lldb_object_sp->GetChildMemberWithName (str_name, true); + child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true); } SBValue sb_value (child_sp); @@ -256,7 +256,7 @@ SBValue::GetNumChildren () if (IsValid()) { - num_children = m_lldb_object_sp->GetNumChildren(); + num_children = m_opaque_sp->GetNumChildren(); } return num_children; @@ -269,7 +269,7 @@ SBValue::ValueIsStale () if (IsValid()) { - result = m_lldb_object_sp->GetValueIsValid(); + result = m_opaque_sp->GetValueIsValid(); } return result; @@ -281,7 +281,7 @@ SBValue::Dereference () { if (IsValid()) { - if (m_lldb_object_sp->IsPointerType()) + if (m_opaque_sp->IsPointerType()) { return GetChildAtIndex(0); } @@ -296,53 +296,53 @@ SBValue::TypeIsPtrType () if (IsValid()) { - is_ptr_type = m_lldb_object_sp->IsPointerType(); + is_ptr_type = m_opaque_sp->IsPointerType(); } return is_ptr_type; } -lldb_private::ExecutionContext -SBValue::GetCurrentExecutionContext () -{ - lldb_private::Process *process = NULL; - lldb_private::Thread *thread = NULL; - lldb_private::StackFrame *frame = NULL; - - SBTarget sb_target = SBDebugger::GetCurrentTarget(); - if (sb_target.IsValid()) - { - SBProcess sb_process = sb_target.GetProcess(); - if (sb_process.IsValid()) - { - process = sb_process.get(); - SBThread sb_thread = sb_process.GetCurrentThread(); - if (sb_thread.IsValid()) - { - thread = sb_thread.GetLLDBObjectPtr(); - frame = thread->GetStackFrameAtIndex(0).get(); - lldb_private::ExecutionContext exe_context (process, thread, frame); - return exe_context; - } - else - { - lldb_private::ExecutionContext exe_context (process, NULL, NULL); - return exe_context; - } - } - } - - lldb_private::ExecutionContext exe_context (NULL, NULL, NULL); - return exe_context; -} - - +//lldb_private::ExecutionContext +//SBValue::GetCurrentExecutionContext () +//{ +// lldb_private::Process *process = NULL; +// lldb_private::Thread *thread = NULL; +// lldb_private::StackFrame *frame = NULL; +// +// SBTarget sb_target = SBDebugger::GetCurrentTarget(); +// if (sb_target.IsValid()) +// { +// SBProcess sb_process = sb_target.GetProcess(); +// if (sb_process.IsValid()) +// { +// process = sb_process.get(); +// SBThread sb_thread = sb_process.GetCurrentThread(); +// if (sb_thread.IsValid()) +// { +// thread = sb_thread.GetLLDBObjectPtr(); +// frame = thread->GetStackFrameAtIndex(0).get(); +// lldb_private::ExecutionContext exe_context (process, thread, frame); +// return exe_context; +// } +// else +// { +// lldb_private::ExecutionContext exe_context (process, NULL, NULL); +// return exe_context; +// } +// } +// } +// +// lldb_private::ExecutionContext exe_context (NULL, NULL, NULL); +// return exe_context; +//} +// +// void * SBValue::GetOpaqueType() { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetOpaqueClangQualType(); + if (m_opaque_sp) + return m_opaque_sp->GetOpaqueClangQualType(); return NULL; } @@ -350,23 +350,23 @@ SBValue::GetOpaqueType() lldb_private::ValueObject * SBValue::get() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } lldb_private::ValueObject * SBValue::operator->() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } lldb::ValueObjectSP & SBValue::operator*() { - return m_lldb_object_sp; + return m_opaque_sp; } const lldb::ValueObjectSP & SBValue::operator*() const { - return m_lldb_object_sp; + return m_opaque_sp; } diff --git a/lldb/source/API/SBValueList.cpp b/lldb/source/API/SBValueList.cpp index e7cbfad5308..4223fadb388 100644 --- a/lldb/source/API/SBValueList.cpp +++ b/lldb/source/API/SBValueList.cpp @@ -17,22 +17,22 @@ using namespace lldb; using namespace lldb_private; SBValueList::SBValueList () : - m_lldb_object_ap () + m_opaque_ap () { } SBValueList::SBValueList (const SBValueList &rhs) : - m_lldb_object_ap () + m_opaque_ap () { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::ValueObjectList (*rhs)); + m_opaque_ap.reset (new lldb_private::ValueObjectList (*rhs)); } SBValueList::SBValueList (const lldb_private::ValueObjectList *lldb_object_ptr) : - m_lldb_object_ap () + m_opaque_ap () { if (lldb_object_ptr) - m_lldb_object_ap.reset (new lldb_private::ValueObjectList (*lldb_object_ptr)); + m_opaque_ap.reset (new lldb_private::ValueObjectList (*lldb_object_ptr)); } SBValueList::~SBValueList () @@ -42,7 +42,7 @@ SBValueList::~SBValueList () bool SBValueList::IsValid () const { - return (m_lldb_object_ap.get() != NULL); + return (m_opaque_ap.get() != NULL); } const SBValueList & @@ -51,9 +51,9 @@ SBValueList::operator = (const SBValueList &rhs) if (this != &rhs) { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::ValueObjectList (*rhs)); + m_opaque_ap.reset (new lldb_private::ValueObjectList (*rhs)); else - m_lldb_object_ap.reset (); + m_opaque_ap.reset (); } return *this; } @@ -61,25 +61,25 @@ SBValueList::operator = (const SBValueList &rhs) lldb_private::ValueObjectList * SBValueList::operator->() { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } lldb_private::ValueObjectList & SBValueList::operator*() { - return *m_lldb_object_ap; + return *m_opaque_ap; } const lldb_private::ValueObjectList * SBValueList::operator->() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } const lldb_private::ValueObjectList & SBValueList::operator*() const { - return *m_lldb_object_ap; + return *m_opaque_ap; } void @@ -88,7 +88,7 @@ SBValueList::Append (const SBValue &val_obj) if (val_obj.get()) { CreateIfNeeded (); - m_lldb_object_ap->Append (*val_obj); + m_opaque_ap->Append (*val_obj); } } @@ -98,7 +98,7 @@ SBValueList::Append (lldb::ValueObjectSP& val_obj_sp) if (val_obj_sp) { CreateIfNeeded (); - m_lldb_object_ap->Append (val_obj_sp); + m_opaque_ap->Append (val_obj_sp); } } @@ -107,8 +107,8 @@ SBValue SBValueList::GetValueAtIndex (uint32_t idx) const { SBValue sb_value; - if (m_lldb_object_ap.get()) - *sb_value = m_lldb_object_ap->GetValueObjectAtIndex (idx); + if (m_opaque_ap.get()) + *sb_value = m_opaque_ap->GetValueObjectAtIndex (idx); return sb_value; } @@ -116,16 +116,16 @@ uint32_t SBValueList::GetSize () const { uint32_t size = 0; - if (m_lldb_object_ap.get()) - size = m_lldb_object_ap->GetSize(); + if (m_opaque_ap.get()) + size = m_opaque_ap->GetSize(); return size; } void SBValueList::CreateIfNeeded () { - if (m_lldb_object_ap.get() == NULL) - m_lldb_object_ap.reset (new ValueObjectList()); + if (m_opaque_ap.get() == NULL) + m_opaque_ap.reset (new ValueObjectList()); } @@ -133,8 +133,8 @@ SBValue SBValueList::FindValueObjectByUID (lldb::user_id_t uid) { SBValue sb_value; - if ( m_lldb_object_ap.get()) - *sb_value = m_lldb_object_ap->FindValueObjectByUID (uid); + if ( m_opaque_ap.get()) + *sb_value = m_opaque_ap->FindValueObjectByUID (uid); return sb_value; } diff --git a/lldb/source/Breakpoint/StoppointCallbackContext.cpp b/lldb/source/Breakpoint/StoppointCallbackContext.cpp index 86620621c76..da4d9e3cc5a 100644 --- a/lldb/source/Breakpoint/StoppointCallbackContext.cpp +++ b/lldb/source/Breakpoint/StoppointCallbackContext.cpp @@ -18,13 +18,13 @@ using namespace lldb_private; StoppointCallbackContext::StoppointCallbackContext() : event (NULL), - context() + exe_ctx() { } StoppointCallbackContext::StoppointCallbackContext(Event *e, Process* p, Thread *t, StackFrame *f, bool synchronously) : event (e), - context (p, t, f), + exe_ctx (p, t, f), is_synchronous(synchronously) { } @@ -33,6 +33,6 @@ void StoppointCallbackContext::Clear() { event = NULL; - context.Clear(); + exe_ctx.Clear(); is_synchronous = false; } diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index f2bf7da63aa..5d42229917b 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -33,13 +33,16 @@ CommandCompletions::g_common_completions[] = }; bool -CommandCompletions::InvokeCommonCompletionCallbacks (uint32_t completion_mask, - const char *completion_str, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches) +CommandCompletions::InvokeCommonCompletionCallbacks +( + CommandInterpreter &interpreter, + uint32_t completion_mask, + const char *completion_str, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches +) { bool handled = false; @@ -54,10 +57,10 @@ CommandCompletions::InvokeCommonCompletionCallbacks (uint32_t completion_mask, && g_common_completions[i].callback != NULL) { handled = true; - g_common_completions[i].callback (completion_str, + g_common_completions[i].callback (interpreter, + completion_str, match_start_point, max_return_elements, - interpreter, searcher, matches); } @@ -66,20 +69,27 @@ CommandCompletions::InvokeCommonCompletionCallbacks (uint32_t completion_mask, } int -CommandCompletions::SourceFiles (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches) +CommandCompletions::SourceFiles +( + CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches +) { // Find some way to switch "include support files..." - SourceFileCompleter completer (false, partial_file_name, match_start_point, max_return_elements, interpreter, + SourceFileCompleter completer (interpreter, + false, + partial_file_name, + match_start_point, + max_return_elements, matches); if (searcher == NULL) { - lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP(); + lldb::TargetSP target_sp = interpreter.GetDebugger().GetCurrentTarget(); SearchFilter null_searcher (target_sp); completer.DoCompletion (&null_searcher); } @@ -91,18 +101,25 @@ CommandCompletions::SourceFiles (const char *partial_file_name, } int -CommandCompletions::Modules (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches) +CommandCompletions::Modules +( + CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches +) { - ModuleCompleter completer(partial_file_name, match_start_point, max_return_elements, interpreter, matches); - + ModuleCompleter completer (interpreter, + partial_file_name, + match_start_point, + max_return_elements, + matches); + if (searcher == NULL) { - lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP(); + lldb::TargetSP target_sp = interpreter.GetDebugger().GetCurrentTarget(); SearchFilter null_searcher (target_sp); completer.DoCompletion (&null_searcher); } @@ -114,18 +131,24 @@ CommandCompletions::Modules (const char *partial_file_name, } int -CommandCompletions::Symbols (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches) +CommandCompletions::Symbols +( + CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches) { - SymbolCompleter completer(partial_file_name, match_start_point, max_return_elements, interpreter, matches); + SymbolCompleter completer (interpreter, + partial_file_name, + match_start_point, + max_return_elements, + matches); if (searcher == NULL) { - lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP(); + lldb::TargetSP target_sp = interpreter.GetDebugger().GetCurrentTarget(); SearchFilter null_searcher (target_sp); completer.DoCompletion (&null_searcher); } @@ -136,17 +159,18 @@ CommandCompletions::Symbols (const char *partial_file_name, return matches.GetSize(); } -CommandCompletions::Completer::Completer ( +CommandCompletions::Completer::Completer +( + CommandInterpreter &interpreter, const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) : + m_interpreter (interpreter), m_completion_str (completion_str), m_match_start_point (match_start_point), m_max_return_elements (max_return_elements), - m_interpreter (interpreter), m_matches (matches) { } @@ -160,15 +184,16 @@ CommandCompletions::Completer::~Completer () // SourceFileCompleter //---------------------------------------------------------------------- -CommandCompletions::SourceFileCompleter::SourceFileCompleter ( +CommandCompletions::SourceFileCompleter::SourceFileCompleter +( + CommandInterpreter &interpreter, bool include_support_files, const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) : - CommandCompletions::Completer (completion_str, match_start_point, max_return_elements, interpreter, matches), + CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches), m_include_support_files (include_support_files), m_matching_files() { @@ -264,14 +289,15 @@ regex_chars (const char comp) else return false; } -CommandCompletions::SymbolCompleter::SymbolCompleter ( +CommandCompletions::SymbolCompleter::SymbolCompleter +( + CommandInterpreter &interpreter, const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) : - CommandCompletions::Completer (completion_str, match_start_point, max_return_elements, interpreter, matches) + CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches) { std::string regex_str ("^"); regex_str.append(completion_str); @@ -353,14 +379,15 @@ CommandCompletions::SymbolCompleter::DoCompletion (SearchFilter *filter) //---------------------------------------------------------------------- // ModuleCompleter //---------------------------------------------------------------------- -CommandCompletions::ModuleCompleter::ModuleCompleter ( +CommandCompletions::ModuleCompleter::ModuleCompleter +( + CommandInterpreter &interpreter, const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) : - CommandCompletions::Completer (completion_str, match_start_point, max_return_elements, interpreter, matches) + CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches) { FileSpec partial_spec (m_completion_str.c_str()); m_file_name = partial_spec.GetFilename().GetCString(); diff --git a/lldb/source/Commands/CommandObjectAdd.cpp b/lldb/source/Commands/CommandObjectAdd.cpp deleted file mode 100644 index 1bd5fe4518d..00000000000 --- a/lldb/source/Commands/CommandObjectAdd.cpp +++ /dev/null @@ -1,51 +0,0 @@ -//===-- CommandObjectAdd.cpp ------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectAdd.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/Options.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectAdd -//------------------------------------------------------------------------- - -CommandObjectAdd::CommandObjectAdd () : - CommandObject ("add", - "Allows the user to add a new command/function pair to the debugger's dictionary.", - "add <new-command-name> <script-function-name>") -{ -} - -CommandObjectAdd::~CommandObjectAdd() -{ -} - - -bool -CommandObjectAdd::Execute -( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result -) -{ - result.AppendMessage ("This function has not been implemented yet."); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - return result.Succeeded(); -} diff --git a/lldb/source/Commands/CommandObjectAdd.h b/lldb/source/Commands/CommandObjectAdd.h deleted file mode 100644 index 9aa59b61a7a..00000000000 --- a/lldb/source/Commands/CommandObjectAdd.h +++ /dev/null @@ -1,43 +0,0 @@ -//===-- CommandObjectAdd.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_CommandObjectAdd_h_ -#define liblldb_CommandObjectAdd_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { -//------------------------------------------------------------------------- -// CommandObjectAdd -//------------------------------------------------------------------------- - -class CommandObjectAdd : public CommandObject -{ -public: - - CommandObjectAdd (); - - virtual - ~CommandObjectAdd (); - - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectAdd_h_ diff --git a/lldb/source/Commands/CommandObjectAlias.cpp b/lldb/source/Commands/CommandObjectAlias.cpp index 5ab7db62bb8..62ffbf4915e 100644 --- a/lldb/source/Commands/CommandObjectAlias.cpp +++ b/lldb/source/Commands/CommandObjectAlias.cpp @@ -89,8 +89,12 @@ CommandObjectAlias::~CommandObjectAlias () bool -CommandObjectAlias::Execute (Args& args, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectAlias::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { const int argc = args.GetArgumentCount(); @@ -109,7 +113,7 @@ CommandObjectAlias::Execute (Args& args, CommandContext *context, CommandInterpr // Verify that the command is alias'able, and get the appropriate command object. - if (interpreter->CommandExists (alias_command.c_str())) + if (interpreter.CommandExists (alias_command.c_str())) { result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n", alias_command.c_str()); @@ -117,7 +121,7 @@ CommandObjectAlias::Execute (Args& args, CommandContext *context, CommandInterpr } else { - CommandObjectSP command_obj_sp(interpreter->GetCommandSP (actual_command.c_str())); + CommandObjectSP command_obj_sp(interpreter.GetCommandSP (actual_command.c_str())); CommandObjectSP subcommand_obj_sp; bool use_subcommand = false; if (command_obj_sp.get()) @@ -193,24 +197,24 @@ CommandObjectAlias::Execute (Args& args, CommandContext *context, CommandInterpr // Create the alias. - if (interpreter->AliasExists (alias_command.c_str()) - || interpreter->UserCommandExists (alias_command.c_str())) + if (interpreter.AliasExists (alias_command.c_str()) + || interpreter.UserCommandExists (alias_command.c_str())) { - OptionArgVectorSP tmp_option_arg_sp (interpreter->GetAliasOptions (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()); + 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); + interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp); else - interpreter->AddAlias (alias_command.c_str(), command_obj_sp); + 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); + interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else diff --git a/lldb/source/Commands/CommandObjectAlias.h b/lldb/source/Commands/CommandObjectAlias.h index 859b7cea049..da3334643de 100644 --- a/lldb/source/Commands/CommandObjectAlias.h +++ b/lldb/source/Commands/CommandObjectAlias.h @@ -32,9 +32,8 @@ public: ~CommandObjectAlias (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectAppend.cpp b/lldb/source/Commands/CommandObjectAppend.cpp index 613b85b4be9..6bdbc36572e 100644 --- a/lldb/source/Commands/CommandObjectAppend.cpp +++ b/lldb/source/Commands/CommandObjectAppend.cpp @@ -37,9 +37,8 @@ CommandObjectAppend::~CommandObjectAppend () bool CommandObjectAppend::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -64,7 +63,7 @@ CommandObjectAppend::Execute } else { - StateVariable *var = interpreter->GetStateVariable(var_name); + StateVariable *var = interpreter.GetStateVariable(var_name); if (var == NULL) { result.AppendErrorWithFormat ("'%s' is not a settable internal variable.\n", var_name); diff --git a/lldb/source/Commands/CommandObjectAppend.h b/lldb/source/Commands/CommandObjectAppend.h index 436283730fb..6b2ab9d3888 100644 --- a/lldb/source/Commands/CommandObjectAppend.h +++ b/lldb/source/Commands/CommandObjectAppend.h @@ -30,9 +30,8 @@ public: ~CommandObjectAppend (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); diff --git a/lldb/source/Commands/CommandObjectApropos.cpp b/lldb/source/Commands/CommandObjectApropos.cpp index bdb70df1a32..0f10b3ec780 100644 --- a/lldb/source/Commands/CommandObjectApropos.cpp +++ b/lldb/source/Commands/CommandObjectApropos.cpp @@ -40,14 +40,18 @@ CommandObjectApropos::~CommandObjectApropos() bool -CommandObjectApropos::Execute (Args &command, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectApropos::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { - const int argc = command.GetArgumentCount (); + const int argc = args.GetArgumentCount (); if (argc == 1) { - const char *search_word = command.GetArgumentAtIndex(0); + const char *search_word = args.GetArgumentAtIndex(0); if ((search_word != NULL) && (strlen (search_word) > 0)) { @@ -55,7 +59,7 @@ CommandObjectApropos::Execute (Args &command, CommandContext *context, CommandIn // is private. StringList commands_found; StringList commands_help; - interpreter->FindCommandsForApropos (search_word, commands_found, commands_help); + interpreter.FindCommandsForApropos (search_word, commands_found, commands_help); if (commands_found.GetSize() == 0) { result.AppendMessageWithFormat ("No commands found pertaining to '%s'.", search_word); @@ -74,8 +78,11 @@ CommandObjectApropos::Execute (Args &command, CommandContext *context, CommandIn } for (int i = 0; i < commands_found.GetSize(); ++i) - interpreter->OutputFormattedHelpText (result.GetOutputStream(), commands_found.GetStringAtIndex(i), - "--", commands_help.GetStringAtIndex(i), max_len); + interpreter.OutputFormattedHelpText (result.GetOutputStream(), + commands_found.GetStringAtIndex(i), + "--", commands_help. + GetStringAtIndex(i), + max_len); } result.SetStatus (eReturnStatusSuccessFinishNoResult); diff --git a/lldb/source/Commands/CommandObjectApropos.h b/lldb/source/Commands/CommandObjectApropos.h index a079a3fc4ac..cf5cabe3ade 100644 --- a/lldb/source/Commands/CommandObjectApropos.h +++ b/lldb/source/Commands/CommandObjectApropos.h @@ -32,9 +32,8 @@ public: ~CommandObjectApropos (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); diff --git a/lldb/source/Commands/CommandObjectArgs.cpp b/lldb/source/Commands/CommandObjectArgs.cpp index e1cb9825c88..74a7d2b04de 100644 --- a/lldb/source/Commands/CommandObjectArgs.cpp +++ b/lldb/source/Commands/CommandObjectArgs.cpp @@ -20,7 +20,7 @@ #include "lldb/Expression/ClangFunction.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" @@ -95,14 +95,17 @@ CommandObjectArgs::GetOptions () } bool -CommandObjectArgs::Execute(Args &command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectArgs::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { ConstString target_triple; - Process *process = context->GetExecutionContext().process; + + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (!process) { result.AppendError ("Args found no process."); @@ -118,7 +121,7 @@ CommandObjectArgs::Execute(Args &command, return false; } - int num_args = command.GetArgumentCount (); + int num_args = args.GetArgumentCount (); int arg_index; if (!num_args) @@ -128,7 +131,7 @@ CommandObjectArgs::Execute(Args &command, return false; } - Thread *thread = context->GetExecutionContext ().thread; + Thread *thread = interpreter.GetDebugger().GetExecutionContext ().thread; if (!thread) { @@ -167,7 +170,7 @@ CommandObjectArgs::Execute(Args &command, for (arg_index = 0; arg_index < num_args; ++arg_index) { - const char *arg_type_cstr = command.GetArgumentAtIndex(arg_index); + const char *arg_type_cstr = args.GetArgumentAtIndex(arg_index); Value value; value.SetValueType(Value::eValueTypeScalar); void *type; @@ -262,7 +265,7 @@ CommandObjectArgs::Execute(Args &command, for (arg_index = 0; arg_index < num_args; ++arg_index) { - result.GetOutputStream ().Printf ("%d (%s): ", arg_index, command.GetArgumentAtIndex (arg_index)); + result.GetOutputStream ().Printf ("%d (%s): ", arg_index, args.GetArgumentAtIndex (arg_index)); value_list.GetValueAtIndex (arg_index)->Dump (&result.GetOutputStream ()); result.GetOutputStream ().Printf("\n"); } diff --git a/lldb/source/Commands/CommandObjectArgs.h b/lldb/source/Commands/CommandObjectArgs.h index 997d289c1d3..5a73460e361 100644 --- a/lldb/source/Commands/CommandObjectArgs.h +++ b/lldb/source/Commands/CommandObjectArgs.h @@ -58,9 +58,8 @@ namespace lldb_private { virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index 044ff40c74b..01d29fbd81b 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -32,7 +32,7 @@ using namespace lldb; using namespace lldb_private; static void -AddBreakpointDescription (CommandContext *context, StreamString *s, Breakpoint *bp, lldb::DescriptionLevel level) +AddBreakpointDescription (StreamString *s, Breakpoint *bp, lldb::DescriptionLevel level) { s->IndentMore(); bp->GetDescription (s, level, true); @@ -240,13 +240,12 @@ CommandObjectBreakpointSet::GetOptions () bool CommandObjectBreakpointSet::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -287,7 +286,7 @@ CommandObjectBreakpointSet::Execute FileSpec file; if (m_options.m_filename.empty()) { - StackFrame *cur_frame = context->GetExecutionContext().frame; + StackFrame *cur_frame = interpreter.GetDebugger().GetExecutionContext().frame; if (cur_frame == NULL) { result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); @@ -458,7 +457,7 @@ CommandObjectBreakpointSet::Execute //------------------------------------------------------------------------- #pragma mark MultiwordBreakpoint -CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter *interpreter) : +CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : CommandObjectMultiword ("breakpoint", "A set of commands for operating on breakpoints.", "breakpoint <command> [<command-options>]") @@ -480,13 +479,13 @@ CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInter modify_command_object->SetCommandName ("breakpoint modify"); set_command_object->SetCommandName("breakpoint set"); - status = LoadSubCommand (list_command_object, "list", interpreter); - status = LoadSubCommand (enable_command_object, "enable", interpreter); - status = LoadSubCommand (disable_command_object, "disable", interpreter); - status = LoadSubCommand (delete_command_object, "delete", interpreter); - status = LoadSubCommand (set_command_object, "set", interpreter); - status = LoadSubCommand (command_command_object, "command", interpreter); - status = LoadSubCommand (modify_command_object, "modify", interpreter); + status = LoadSubCommand (interpreter, "list", list_command_object); + status = LoadSubCommand (interpreter, "enable", enable_command_object); + status = LoadSubCommand (interpreter, "disable", disable_command_object); + status = LoadSubCommand (interpreter, "delete", delete_command_object); + status = LoadSubCommand (interpreter, "set", set_command_object); + status = LoadSubCommand (interpreter, "command", command_command_object); + status = LoadSubCommand (interpreter, "modify", modify_command_object); } CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint () @@ -653,13 +652,12 @@ CommandObjectBreakpointList::GetOptions () bool CommandObjectBreakpointList::Execute ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -689,7 +687,7 @@ CommandObjectBreakpointList::Execute for (int i = 0; i < num_breakpoints; ++i) { Breakpoint *breakpoint = breakpoints.GetBreakpointByIndex (i).get(); - AddBreakpointDescription (context, &output_stream, breakpoint, m_options.m_level); + AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); } result.SetStatus (eReturnStatusSuccessFinishNoResult); } @@ -705,7 +703,7 @@ CommandObjectBreakpointList::Execute { BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); - AddBreakpointDescription (context, &output_stream, breakpoint, m_options.m_level); + AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); } result.SetStatus (eReturnStatusSuccessFinishNoResult); } @@ -743,10 +741,14 @@ CommandObjectBreakpointEnable::~CommandObjectBreakpointEnable () bool -CommandObjectBreakpointEnable::Execute (Args& args, CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result) +CommandObjectBreakpointEnable::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -838,10 +840,14 @@ CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable () } bool -CommandObjectBreakpointDisable::Execute (Args& args, CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result) +CommandObjectBreakpointDisable::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -929,10 +935,14 @@ CommandObjectBreakpointDelete::~CommandObjectBreakpointDelete () } bool -CommandObjectBreakpointDelete::Execute (Args& args, CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result) +CommandObjectBreakpointDelete::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -1163,9 +1173,8 @@ CommandObjectBreakpointModify::GetOptions () bool CommandObjectBreakpointModify::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -1176,7 +1185,7 @@ CommandObjectBreakpointModify::Execute return false; } - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); diff --git a/lldb/source/Commands/CommandObjectBreakpoint.h b/lldb/source/Commands/CommandObjectBreakpoint.h index 053e036c0c8..92bea698847 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.h +++ b/lldb/source/Commands/CommandObjectBreakpoint.h @@ -32,7 +32,7 @@ namespace lldb_private { class CommandObjectMultiwordBreakpoint : public CommandObjectMultiword { public: - CommandObjectMultiwordBreakpoint (CommandInterpreter *interpreter); + CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordBreakpoint (); @@ -66,9 +66,8 @@ public: ~CommandObjectBreakpointSet (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * @@ -133,9 +132,8 @@ public: ~CommandObjectBreakpointModify (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * @@ -194,9 +192,8 @@ public: ~CommandObjectBreakpointEnable (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: @@ -215,9 +212,8 @@ public: ~CommandObjectBreakpointDisable (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: @@ -236,9 +232,8 @@ public: ~CommandObjectBreakpointList (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * @@ -290,9 +285,8 @@ public: ~CommandObjectBreakpointDelete (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp index e080450710d..547192dc68a 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -208,13 +208,12 @@ CommandObjectBreakpointCommandAdd::~CommandObjectBreakpointCommandAdd () bool CommandObjectBreakpointCommandAdd::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { @@ -258,12 +257,12 @@ CommandObjectBreakpointCommandAdd::Execute { if (m_options.m_use_script_language) { - interpreter->GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp_loc_sp->GetLocationOptions(), + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp_loc_sp->GetLocationOptions(), result); } else { - CollectDataForBreakpointCommandCallback (bp_loc_sp->GetLocationOptions(), result); + CollectDataForBreakpointCommandCallback (interpreter, bp_loc_sp->GetLocationOptions(), result); } } } @@ -271,12 +270,12 @@ CommandObjectBreakpointCommandAdd::Execute { if (m_options.m_use_script_language) { - interpreter->GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp->GetOptions(), + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp->GetOptions(), result); } else { - CollectDataForBreakpointCommandCallback (bp->GetOptions(), result); + CollectDataForBreakpointCommandCallback (interpreter, bp->GetOptions(), result); } } } @@ -297,11 +296,12 @@ const char *g_reader_instructions = "Enter your debugger command(s). Type 'DONE void CommandObjectBreakpointCommandAdd::CollectDataForBreakpointCommandCallback ( + CommandInterpreter &interpreter, BreakpointOptions *bp_options, CommandReturnObject &result ) { - InputReaderSP reader_sp (new InputReader()); + InputReaderSP reader_sp (new InputReader(interpreter.GetDebugger())); std::auto_ptr<BreakpointOptions::CommandData> data_ap(new BreakpointOptions::CommandData()); if (reader_sp && data_ap.get()) { @@ -316,7 +316,7 @@ CommandObjectBreakpointCommandAdd::CollectDataForBreakpointCommandCallback true)); // echo input if (err.Success()) { - Debugger::GetSharedInstance().PushInputReader (reader_sp); + interpreter.GetDebugger().PushInputReader (reader_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -337,13 +337,13 @@ size_t CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback ( void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len ) { - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); + FILE *out_fh = reader.GetDebugger().GetOutputFileHandle(); switch (notification) { @@ -351,8 +351,8 @@ CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback if (out_fh) { ::fprintf (out_fh, "%s\n", g_reader_instructions); - if (reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); } break; @@ -360,8 +360,8 @@ CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback break; case eInputReaderReactivate: - if (out_fh && reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (out_fh && reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); break; case eInputReaderGotToken: @@ -375,8 +375,8 @@ CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback ((BreakpointOptions::CommandData *)bp_options_baton->m_data)->user_source.AppendString (bytes, bytes_len); } } - if (out_fh && !reader->IsDone() && reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (out_fh && !reader.IsDone() && reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); break; case eInputReaderDone: @@ -403,12 +403,14 @@ CommandObjectBreakpointCommandRemove::~CommandObjectBreakpointCommandRemove () } bool -CommandObjectBreakpointCommandRemove::Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectBreakpointCommandRemove::Execute +( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result +) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { @@ -486,12 +488,14 @@ CommandObjectBreakpointCommandList::~CommandObjectBreakpointCommandList () } bool -CommandObjectBreakpointCommandList::Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectBreakpointCommandList::Execute +( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result +) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { @@ -587,7 +591,7 @@ CommandObjectBreakpointCommandList::Execute (Args& command, // CommandObjectBreakpointCommand //------------------------------------------------------------------------- -CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpreter *interpreter) : +CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpreter &interpreter) : CommandObjectMultiword ("command", "A set of commands for adding, removing and examining bits of code to be executed when the breakpoint is hit (breakpoint 'commmands').", "command <sub-command> [<sub-command-options>] <breakpoint-id>") @@ -601,9 +605,9 @@ CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpret remove_command_object->SetCommandName ("breakpoint command remove"); list_command_object->SetCommandName ("breakpoint command list"); - status = LoadSubCommand (add_command_object, "add", interpreter); - status = LoadSubCommand (remove_command_object, "remove", interpreter); - status = LoadSubCommand (list_command_object, "list", interpreter); + status = LoadSubCommand (interpreter, "add", add_command_object); + status = LoadSubCommand (interpreter, "remove", remove_command_object); + status = LoadSubCommand (interpreter, "list", list_command_object); } @@ -631,63 +635,61 @@ CommandObjectBreakpointCommand::BreakpointOptionsCallbackFunction if (commands.GetSize() > 0) { uint32_t num_commands = commands.GetSize(); - CommandInterpreter &interpreter = Debugger::GetSharedInstance().GetCommandInterpreter(); CommandReturnObject result; - ExecutionContext exe_ctx = context->context; - - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - FILE *err_fh = Debugger::GetSharedInstance().GetErrorFileHandle(); - - - uint32_t i; - for (i = 0; i < num_commands; ++i) + if (context->exe_ctx.target) { - - // First time through we use the context from the stoppoint, after that we use whatever - // has been set by the previous command. - - if (!interpreter.HandleCommand (commands.GetStringAtIndex(i), false, result, &exe_ctx)) - break; + + Debugger &debugger = context->exe_ctx.target->GetDebugger(); + CommandInterpreter &interpreter = debugger.GetCommandInterpreter(); + + FILE *out_fh = debugger.GetOutputFileHandle(); + FILE *err_fh = debugger.GetErrorFileHandle(); - // FIXME: This isn't really the right way to do this. We should be able to peek at the public - // to see if there is any new events, but that is racey, since the internal process thread has to run and - // deliver the event to the public queue before a run will show up. So for now we check - // the internal thread state. - - lldb::StateType internal_state = exe_ctx.process->GetPrivateState(); - if (internal_state != eStateStopped) + uint32_t i; + for (i = 0; i < num_commands; ++i) { - if (i < num_commands - 1) + + // First time through we use the context from the stoppoint, after that we use whatever + // has been set by the previous command. + + if (!interpreter.HandleCommand (commands.GetStringAtIndex(i), false, result, &context->exe_ctx)) + break; + + // FIXME: This isn't really the right way to do this. We should be able to peek at the public + // to see if there is any new events, but that is racey, since the internal process thread has to run and + // deliver the event to the public queue before a run will show up. So for now we check + // the internal thread state. + + lldb::StateType internal_state = context->exe_ctx.process->GetPrivateState(); + if (internal_state != eStateStopped) { - if (out_fh) - ::fprintf (out_fh, "Short-circuiting command execution because target state changed to %s." - " last command: \"%s\"\n", StateAsCString(internal_state), - commands.GetStringAtIndex(i)); + if (i < num_commands - 1) + { + if (out_fh) + ::fprintf (out_fh, "Short-circuiting command execution because target state changed to %s." + " last command: \"%s\"\n", StateAsCString(internal_state), + commands.GetStringAtIndex(i)); + } + break; } - break; + + if (out_fh) + ::fprintf (out_fh, "%s", result.GetErrorStream().GetData()); + if (err_fh) + ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); + result.Clear(); + result.SetStatus (eReturnStatusSuccessFinishNoResult); } - - // First time through we use the context from the stoppoint, after that we use whatever - // has been set by the previous command. - exe_ctx = Debugger::GetSharedInstance().GetCurrentExecutionContext(); - + if (err_fh && !result.Succeeded() && i < num_commands) + ::fprintf (err_fh, "Attempt to execute '%s' failed.\n", commands.GetStringAtIndex(i)); + if (out_fh) ::fprintf (out_fh, "%s", result.GetErrorStream().GetData()); + if (err_fh) - ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); - result.Clear(); - result.SetStatus (eReturnStatusSuccessFinishNoResult); + ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); } - - if (err_fh && !result.Succeeded() && i < num_commands) - ::fprintf (err_fh, "Attempt to execute '%s' failed.\n", commands.GetStringAtIndex(i)); - - if (out_fh) - ::fprintf (out_fh, "%s", result.GetErrorStream().GetData()); - - if (err_fh) - ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); } return ret_value; } diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.h b/lldb/source/Commands/CommandObjectBreakpointCommand.h index 344eccea2ef..fc59c7714da 100644 --- a/lldb/source/Commands/CommandObjectBreakpointCommand.h +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.h @@ -34,7 +34,7 @@ namespace lldb_private { class CommandObjectBreakpointCommand : public CommandObjectMultiword { public: - CommandObjectBreakpointCommand (CommandInterpreter *interpreter); + CommandObjectBreakpointCommand (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointCommand (); @@ -62,21 +62,21 @@ public: ~CommandObjectBreakpointCommandAdd (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * GetOptions (); void - CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, + CollectDataForBreakpointCommandCallback (CommandInterpreter &interpreter, + BreakpointOptions *bp_options, CommandReturnObject &result); static size_t GenerateBreakpointCommandCallback (void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); @@ -134,9 +134,8 @@ public: ~CommandObjectBreakpointCommandRemove (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: @@ -155,9 +154,8 @@ public: ~CommandObjectBreakpointCommandList (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: diff --git a/lldb/source/Commands/CommandObjectCall.cpp b/lldb/source/Commands/CommandObjectCall.cpp index 516ea036806..a2cbc05ce13 100644 --- a/lldb/source/Commands/CommandObjectCall.cpp +++ b/lldb/source/Commands/CommandObjectCall.cpp @@ -20,7 +20,7 @@ #include "lldb/Expression/ClangFunction.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" @@ -128,23 +128,21 @@ CommandObjectCall::GetOptions () bool CommandObjectCall::Execute ( + CommandInterpreter &interpreter, Args &command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { ConstString target_triple; int num_args = command.GetArgumentCount(); - Target *target = context->GetTarget (); - if (target) - target->GetTargetTriple(target_triple); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + if (exe_ctx.target) + exe_ctx.target->GetTargetTriple(target_triple); if (!target_triple) target_triple = Host::GetTargetTriple (); - ExecutionContext exe_ctx(context->GetExecutionContext()); if (exe_ctx.thread == NULL || exe_ctx.frame == NULL) { result.AppendError ("No currently selected thread and frame."); @@ -215,7 +213,7 @@ CommandObjectCall::Execute val.SetValueType (Value::eValueTypeHostAddress); - void *cstr_type = target->GetScratchClangASTContext()->GetCStringType(true); + void *cstr_type = exe_ctx.target->GetScratchClangASTContext()->GetCStringType(true); val.SetContext (Value::eContextTypeOpaqueClangQualType, cstr_type); value_list.PushValue(val); @@ -233,7 +231,7 @@ CommandObjectCall::Execute // run it: StreamString errors; - ClangFunction clang_fun (target_triple.GetCString(), *target_fn, target->GetScratchClangASTContext(), value_list); + ClangFunction clang_fun (target_triple.GetCString(), *target_fn, exe_ctx.target->GetScratchClangASTContext(), value_list); if (m_options.noexecute) { // Now write down the argument values for this call. diff --git a/lldb/source/Commands/CommandObjectCall.h b/lldb/source/Commands/CommandObjectCall.h index 6cd09c4465e..1a5ae1db1e2 100644 --- a/lldb/source/Commands/CommandObjectCall.h +++ b/lldb/source/Commands/CommandObjectCall.h @@ -66,9 +66,8 @@ public: virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool diff --git a/lldb/source/Commands/CommandObjectCrossref.cpp b/lldb/source/Commands/CommandObjectCrossref.cpp index 27b66379e87..0d11369c6e7 100644 --- a/lldb/source/Commands/CommandObjectCrossref.cpp +++ b/lldb/source/Commands/CommandObjectCrossref.cpp @@ -40,9 +40,8 @@ CommandObjectCrossref::~CommandObjectCrossref () bool CommandObjectCrossref::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { diff --git a/lldb/source/Commands/CommandObjectDisassemble.cpp b/lldb/source/Commands/CommandObjectDisassemble.cpp index 0716ff30778..c2abeee702c 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.cpp +++ b/lldb/source/Commands/CommandObjectDisassemble.cpp @@ -155,8 +155,7 @@ CommandObjectDisassemble::~CommandObjectDisassemble() void CommandObjectDisassemble::Disassemble ( - CommandContext *context, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, CommandReturnObject &result, Disassembler *disassembler, const SymbolContextList &sc_list @@ -171,11 +170,11 @@ CommandObjectDisassemble::Disassemble break; if (sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, range)) { - lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(context->GetExecutionContext().process); + lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(interpreter.GetDebugger().GetExecutionContext().process); if (addr != LLDB_INVALID_ADDRESS) { lldb::addr_t end_addr = addr + range.GetByteSize(); - Disassemble (context, interpreter, result, disassembler, addr, end_addr); + Disassemble (interpreter, result, disassembler, addr, end_addr); } } } @@ -184,8 +183,7 @@ CommandObjectDisassemble::Disassemble void CommandObjectDisassemble::Disassemble ( - CommandContext *context, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, CommandReturnObject &result, Disassembler *disassembler, lldb::addr_t addr, @@ -198,7 +196,7 @@ CommandObjectDisassemble::Disassemble if (end_addr == LLDB_INVALID_ADDRESS || addr >= end_addr) end_addr = addr + DEFAULT_DISASM_BYTE_SIZE; - ExecutionContext exe_ctx (context->GetExecutionContext()); + ExecutionContext exe_ctx (interpreter.GetDebugger().GetExecutionContext()); DataExtractor data; size_t bytes_disassembled = disassembler->ParseInstructions (&exe_ctx, eAddressTypeLoad, addr, end_addr - addr, data); if (bytes_disassembled == 0) @@ -225,7 +223,7 @@ CommandObjectDisassemble::Disassemble lldb::addr_t curr_addr = addr + offset; if (m_options.show_mixed) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (!sc_range.ContainsLoadAddress (curr_addr, process)) { prev_sc = sc; @@ -248,7 +246,7 @@ CommandObjectDisassemble::Disassemble output_stream.EOL(); if (sc.comp_unit && sc.line_entry.IsValid()) { - interpreter->GetSourceManager().DisplaySourceLinesWithLineNumbers ( + interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers ( sc.line_entry.file, sc.line_entry.line, m_options.num_lines_context, @@ -286,13 +284,12 @@ CommandObjectDisassemble::Disassemble bool CommandObjectDisassemble::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -353,7 +350,7 @@ CommandObjectDisassemble::Execute } else { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame) { SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); @@ -394,11 +391,11 @@ CommandObjectDisassemble::Execute if (target->GetImages().FindFunctions(name, sc_list)) { - Disassemble (context, interpreter, result, disassembler, sc_list); + Disassemble (interpreter, result, disassembler, sc_list); } else if (target->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list)) { - Disassemble (context, interpreter, result, disassembler, sc_list); + Disassemble (interpreter, result, disassembler, sc_list); } else { @@ -409,7 +406,7 @@ CommandObjectDisassemble::Execute } else { - Disassemble (context, interpreter, result, disassembler, addr, end_addr); + Disassemble (interpreter, result, disassembler, addr, end_addr); } return result.Succeeded(); diff --git a/lldb/source/Commands/CommandObjectDisassemble.h b/lldb/source/Commands/CommandObjectDisassemble.h index 6fca74824e1..830b102017e 100644 --- a/lldb/source/Commands/CommandObjectDisassemble.h +++ b/lldb/source/Commands/CommandObjectDisassemble.h @@ -67,25 +67,22 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); protected: CommandOptions m_options; void - Disassemble (CommandContext *context, - CommandInterpreter *interpreter, + Disassemble (CommandInterpreter &interpreter, CommandReturnObject &result, Disassembler *disassembler, lldb::addr_t addr, lldb::addr_t end_addr); void - Disassemble (CommandContext *context, - CommandInterpreter *interpreter, + Disassemble (CommandInterpreter &interpreter, CommandReturnObject &result, Disassembler *disassembler, const SymbolContextList &sc_list); diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 6e4efbf1cef..38534f03730 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -21,7 +21,8 @@ #include "lldb/Expression/ClangExpressionVariable.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Host/Host.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" @@ -124,9 +125,8 @@ CommandObjectExpression::GetOptions () bool CommandObjectExpression::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -138,24 +138,22 @@ size_t CommandObjectExpression::MultiLineExpressionCallback ( void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len ) { - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); CommandObjectExpression *cmd_object_expr = (CommandObjectExpression *) baton; switch (notification) { case eInputReaderActivate: - if (out_fh) - ::fprintf (out_fh, "%s\n", "Enter expressions, then terminate with an empty line to evaluate:"); + reader.GetDebugger().GetOutputStream().Printf("%s\n", "Enter expressions, then terminate with an empty line to evaluate:"); // Fall through case eInputReaderReactivate: //if (out_fh) - // ::fprintf (out_fh, "%3u: ", cmd_object_expr->m_expr_line_count); + // reader.GetDebugger().GetOutputStream().Printf ("%3u: ", cmd_object_expr->m_expr_line_count); break; case eInputReaderDeactivate: @@ -169,20 +167,18 @@ CommandObjectExpression::MultiLineExpressionCallback } if (bytes_len == 0) - reader->SetIsDone(true); + reader.SetIsDone(true); //else if (out_fh && !reader->IsDone()) // ::fprintf (out_fh, "%3u: ", cmd_object_expr->m_expr_line_count); break; case eInputReaderDone: { - StreamFile out_stream(Debugger::GetSharedInstance().GetOutputFileHandle()); - StreamFile err_stream(Debugger::GetSharedInstance().GetErrorFileHandle()); bool bare = false; cmd_object_expr->EvaluateExpression (cmd_object_expr->m_expr_lines.c_str(), bare, - out_stream, - err_stream); + reader.GetDebugger().GetOutputStream(), + reader.GetDebugger().GetErrorStream()); } break; } @@ -329,21 +325,20 @@ CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream bool CommandObjectExpression::ExecuteRawCommandString ( + CommandInterpreter &interpreter, const char *command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { ConstString target_triple; - Target *target = context->GetTarget (); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) target->GetTargetTriple(target_triple); if (!target_triple) target_triple = Host::GetTargetTriple (); - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); Stream &output_stream = result.GetOutputStream(); @@ -356,18 +351,18 @@ CommandObjectExpression::ExecuteRawCommandString m_expr_lines.clear(); m_expr_line_count = 0; - InputReaderSP reader_sp (new InputReader()); + InputReaderSP reader_sp (new InputReader(interpreter.GetDebugger())); if (reader_sp) { Error err (reader_sp->Initialize (CommandObjectExpression::MultiLineExpressionCallback, this, // baton eInputReaderGranularityLine, // token size, to pass to callback function - NULL, // end token + NULL, // end token NULL, // prompt true)); // echo input if (err.Success()) { - Debugger::GetSharedInstance().PushInputReader (reader_sp); + interpreter.GetDebugger().PushInputReader (reader_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -408,8 +403,8 @@ CommandObjectExpression::ExecuteRawCommandString if (end_options) { - Args args(command, end_options - command); - if (!ParseOptions(args, interpreter, result)) + Args args (command, end_options - command); + if (!ParseOptions (interpreter, args, result)) return false; } } diff --git a/lldb/source/Commands/CommandObjectExpression.h b/lldb/source/Commands/CommandObjectExpression.h index 084a87b2cdb..1959ecbc1e8 100644 --- a/lldb/source/Commands/CommandObjectExpression.h +++ b/lldb/source/Commands/CommandObjectExpression.h @@ -65,25 +65,23 @@ public: virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool WantsRawCommandString() { return true; } virtual bool - ExecuteRawCommandString (const char *command, - CommandContext *context, - CommandInterpreter *interpreter, + ExecuteRawCommandString (CommandInterpreter &interpreter, + const char *command, CommandReturnObject &result); protected: static size_t MultiLineExpressionCallback (void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); diff --git a/lldb/source/Commands/CommandObjectFile.cpp b/lldb/source/Commands/CommandObjectFile.cpp index af7e2fed943..bdaf67cc814 100644 --- a/lldb/source/Commands/CommandObjectFile.cpp +++ b/lldb/source/Commands/CommandObjectFile.cpp @@ -16,7 +16,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Timer.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Process.h" @@ -104,9 +104,8 @@ CommandObjectFile::GetOptions () bool CommandObjectFile::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -135,8 +134,8 @@ CommandObjectFile::Execute if (!arch.IsValid()) arch = LLDB_ARCH_DEFAULT; } - - Error error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file_spec, arch, NULL, true, target_sp); + Debugger &debugger = interpreter.GetDebugger(); + Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, arch, NULL, true, target_sp); if (error.Fail() && !m_options.m_arch.IsValid()) { @@ -144,12 +143,12 @@ CommandObjectFile::Execute arch = LLDB_ARCH_DEFAULT_64BIT; else arch = LLDB_ARCH_DEFAULT_32BIT; - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file_spec, arch, NULL, true, target_sp); + error = debugger.GetTargetList().CreateTarget (debugger, file_spec, arch, NULL, true, target_sp); } if (target_sp) { - Debugger::GetSharedInstance().GetTargetList().SetCurrentTarget(target_sp.get()); + debugger.GetTargetList().SetCurrentTarget(target_sp.get()); result.AppendMessageWithFormat ("Current executable set to '%s' (%s).\n", file_path, arch.AsCString()); result.SetStatus (eReturnStatusSuccessFinishNoResult); } diff --git a/lldb/source/Commands/CommandObjectFile.h b/lldb/source/Commands/CommandObjectFile.h index 527dc2112ee..23f4761983d 100644 --- a/lldb/source/Commands/CommandObjectFile.h +++ b/lldb/source/Commands/CommandObjectFile.h @@ -34,9 +34,8 @@ public: ~CommandObjectFile (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 7eab3fe3a68..e2c52a61d59 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -16,7 +16,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Timer.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Process.h" @@ -51,12 +51,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame) { exe_ctx.frame->Dump (&result.GetOutputStream(), true); @@ -95,12 +94,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx (context->GetExecutionContext()); + ExecutionContext exe_ctx (interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.thread) { if (command.GetArgumentCount() == 1) @@ -156,13 +154,13 @@ public: // CommandObjectMultiwordFrame //------------------------------------------------------------------------- -CommandObjectMultiwordFrame::CommandObjectMultiwordFrame (CommandInterpreter *interpreter) : +CommandObjectMultiwordFrame::CommandObjectMultiwordFrame (CommandInterpreter &interpreter) : CommandObjectMultiword ("frame", "A set of commands for operating on the current thread's frames.", "frame <subcommand> [<subcommand-options>]") { - LoadSubCommand (CommandObjectSP (new CommandObjectFrameInfo ()), "info", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectFrameSelect ()), "select", interpreter); + LoadSubCommand (interpreter, "info", CommandObjectSP (new CommandObjectFrameInfo ())); + LoadSubCommand (interpreter, "select", CommandObjectSP (new CommandObjectFrameSelect ())); } CommandObjectMultiwordFrame::~CommandObjectMultiwordFrame () diff --git a/lldb/source/Commands/CommandObjectFrame.h b/lldb/source/Commands/CommandObjectFrame.h index f7077af4ac0..ea7c808e84b 100644 --- a/lldb/source/Commands/CommandObjectFrame.h +++ b/lldb/source/Commands/CommandObjectFrame.h @@ -28,7 +28,7 @@ class CommandObjectMultiwordFrame : public CommandObjectMultiword { public: - CommandObjectMultiwordFrame (CommandInterpreter *interpreter); + CommandObjectMultiwordFrame (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordFrame (); diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp index ac1046e1e93..8a037e94816 100644 --- a/lldb/source/Commands/CommandObjectHelp.cpp +++ b/lldb/source/Commands/CommandObjectHelp.cpp @@ -38,133 +38,29 @@ CommandObjectHelp::~CommandObjectHelp() bool -CommandObjectHelp::OldExecute -( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result -) -{ - CommandObject::CommandMap::iterator pos; - CommandObject *cmd_obj; - - const int argc = command.GetArgumentCount(); - if (argc > 0) - { - cmd_obj = interpreter->GetCommandObject (command.GetArgumentAtIndex(0), false, false); - if (cmd_obj == NULL) - { - cmd_obj = interpreter->GetCommandObject (command.GetArgumentAtIndex(0), true, false); - if (cmd_obj != NULL) - { - StreamString alias_help_str; - interpreter->GetAliasHelp (command.GetArgumentAtIndex(0), cmd_obj->GetCommandName(), alias_help_str); - result.AppendMessageWithFormat ("'%s' is an alias for %s.\n", command.GetArgumentAtIndex (0), - alias_help_str.GetData()); - } - } - - if (cmd_obj) - { - Stream &output_strm = result.GetOutputStream(); - if (cmd_obj->GetOptions() != NULL) - { - const char * long_help = cmd_obj->GetHelpLong(); - if ((long_help!= NULL) - && strlen (long_help) > 0) - output_strm.Printf ("\n%s", cmd_obj->GetHelpLong()); - else - output_strm.Printf ("\n%s\n", cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", cmd_obj->GetSyntax()); - cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, cmd_obj); - } - else if (cmd_obj->IsMultiwordObject()) - { - bool done = false; - if (argc > 1) - { - CommandObject::CommandMap::iterator pos; - std::string sub_command = command.GetArgumentAtIndex(1); - pos = ((CommandObjectMultiword *) cmd_obj)->m_subcommand_dict.find(sub_command); - if (pos != ((CommandObjectMultiword *) cmd_obj)->m_subcommand_dict.end()) - { - CommandObject *sub_cmd_obj = pos->second.get(); - if (sub_cmd_obj->GetOptions() != NULL) - { - output_strm.Printf ("\n%s\n", sub_cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); - sub_cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, sub_cmd_obj); - done = true; - } - else - { - output_strm.Printf ("\n%s\n", sub_cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); - done = true; - } - } - } - if (!done) - { - output_strm.Printf ("%s\n", cmd_obj->GetHelp()); - ((CommandObjectMultiword *) cmd_obj)->GenerateHelpText (result, interpreter); - } - } - else - { - const char *long_help = cmd_obj->GetHelpLong(); - if ((long_help != NULL) - && (strlen (long_help) > 0)) - output_strm.Printf ("\n%s", cmd_obj->GetHelpLong()); - else - output_strm.Printf ("\n%s\n", cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", cmd_obj->GetSyntax()); - } - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command.GetArgumentAtIndex(0)); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.SetStatus (eReturnStatusSuccessFinishNoResult); - interpreter->GetHelp(result); - } - return result.Succeeded(); -} - -bool -CommandObjectHelp::Execute (Args &command, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, CommandReturnObject &result) { CommandObject::CommandMap::iterator pos; CommandObject *cmd_obj; const int argc = command.GetArgumentCount (); - + // 'help' doesn't take any options or arguments, other than command names. If argc is 0, we show the user // all commands and aliases. Otherwise every argument must be the name of a command or a sub-command. - if (argc == 0) { result.SetStatus (eReturnStatusSuccessFinishNoResult); - interpreter->GetHelp (result); // General help, for ALL commands. + interpreter.GetHelp (result); // General help, for ALL commands. } else { // Get command object for the first command argument. Only search built-in command dictionary. - cmd_obj = interpreter->GetCommandObject (command.GetArgumentAtIndex (0), false, false); + cmd_obj = interpreter.GetCommandObject (command.GetArgumentAtIndex (0), false, false); if (cmd_obj == NULL) - { + { // That failed, so now search in the aliases dictionary, too. - cmd_obj = interpreter->GetCommandObject (command.GetArgumentAtIndex (0), true, false); - } - + cmd_obj = interpreter.GetCommandObject (command.GetArgumentAtIndex (0), true, false); + } + if (cmd_obj != NULL) { bool all_okay = true; @@ -182,19 +78,19 @@ CommandObjectHelp::Execute (Args &command, CommandContext *context, CommandInter { pos = ((CommandObjectMultiword *) sub_cmd_obj)->m_subcommand_dict.find (sub_command); if (pos != ((CommandObjectMultiword *) sub_cmd_obj)->m_subcommand_dict.end()) - sub_cmd_obj = pos->second.get(); + sub_cmd_obj = pos->second.get(); else - all_okay = false; + all_okay = false; } } - + if (!all_okay || (sub_cmd_obj == NULL)) { std::string cmd_string; command.GetCommandString (cmd_string); result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - cmd_string.c_str()); + ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", + cmd_string.c_str()); result.SetStatus (eReturnStatusFailed); } else @@ -208,59 +104,59 @@ CommandObjectHelp::Execute (Args &command, CommandContext *context, CommandInter const char *long_help = sub_cmd_obj->GetHelpLong(); if ((long_help != NULL) && (strlen (long_help) > 0)) - output_strm.Printf ("\n%s", long_help); + output_strm.Printf ("\n%s", long_help); } else if (sub_cmd_obj->IsMultiwordObject()) { output_strm.Printf ("%s\n", sub_cmd_obj->GetHelp()); - ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (result, interpreter); + ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (interpreter, result); } else { - const char *long_help = sub_cmd_obj->GetHelpLong(); - if ((long_help != NULL) - && (strlen (long_help) > 0)) - output_strm.Printf ("%s", long_help); - else - output_strm.Printf ("%s\n", sub_cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); + const char *long_help = sub_cmd_obj->GetHelpLong(); + if ((long_help != NULL) + && (strlen (long_help) > 0)) + output_strm.Printf ("%s", long_help); + else + output_strm.Printf ("%s\n", sub_cmd_obj->GetHelp()); + output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); } } } else { result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command.GetArgumentAtIndex(0)); + ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", + command.GetArgumentAtIndex(0)); result.SetStatus (eReturnStatusFailed); } } - + return result.Succeeded(); } int CommandObjectHelp::HandleCompletion ( + CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) { // Return the completions of the commands in the help system: if (cursor_index == 0) { - return interpreter->HandleCompletionMatches(input, cursor_index, cursor_char_position, match_start_point, max_return_elements, matches); + return interpreter.HandleCompletionMatches(input, cursor_index, cursor_char_position, match_start_point, max_return_elements, matches); } else { - CommandObject *cmd_obj = interpreter->GetCommandObject (input.GetArgumentAtIndex(0), true, false); + CommandObject *cmd_obj = interpreter.GetCommandObject (input.GetArgumentAtIndex(0), true, false); input.Shift(); cursor_index--; - return cmd_obj->HandleCompletion (input, cursor_index, cursor_char_position, match_start_point, max_return_elements, interpreter, matches); + return cmd_obj->HandleCompletion (interpreter, input, cursor_index, cursor_char_position, match_start_point, max_return_elements, matches); } } diff --git a/lldb/source/Commands/CommandObjectHelp.h b/lldb/source/Commands/CommandObjectHelp.h index a8084aa704d..881b67d7141 100644 --- a/lldb/source/Commands/CommandObjectHelp.h +++ b/lldb/source/Commands/CommandObjectHelp.h @@ -31,25 +31,18 @@ public: virtual ~CommandObjectHelp (); - bool - OldExecute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual int - HandleCompletion (Args &input, + HandleCompletion (CommandInterpreter &interpreter, + Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches); }; diff --git a/lldb/source/Commands/CommandObjectImage.cpp b/lldb/source/Commands/CommandObjectImage.cpp index d9c40e5b67a..38a04ecf5f0 100644 --- a/lldb/source/Commands/CommandObjectImage.cpp +++ b/lldb/source/Commands/CommandObjectImage.cpp @@ -13,21 +13,22 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Debugger.h" +#include "lldb/Core/FileSpec.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/RegularExpression.h" +#include "lldb/Core/Stream.h" #include "lldb/Interpreter/Args.h" -#include "lldb/Interpreter/CommandContext.h" #include "lldb/Interpreter/Options.h" +#include "lldb/Interpreter/CommandCompletions.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Core/FileSpec.h" #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/ObjectFile.h" -#include "lldb/Core/RegularExpression.h" -#include "lldb/Core/Stream.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolVendor.h" -#include "lldb/Core/Module.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Interpreter/CommandCompletions.h" using namespace lldb; using namespace lldb_private; @@ -56,7 +57,7 @@ DumpModuleUUID (Stream &strm, Module *module) static uint32_t DumpCompileUnitLineTable ( - CommandContext *context, + CommandInterpreter &interpreter, Stream &strm, Module *module, const FileSpec &file_spec, @@ -85,7 +86,9 @@ DumpCompileUnitLineTable << module->GetFileSpec().GetFilename() << "\n"; LineTable *line_table = sc.comp_unit->GetLineTable(); if (line_table) - line_table->GetDescription (&strm, context->GetExecutionContext().process, lldb::eDescriptionLevelBrief); + line_table->GetDescription (&strm, + interpreter.GetDebugger().GetExecutionContext().process, + lldb::eDescriptionLevelBrief); else strm << "No line table"; } @@ -153,7 +156,7 @@ DumpBasename (Stream &strm, const FileSpec *file_spec_ptr, uint32_t width) static void -DumpModuleSymtab (CommandContext *context, Stream &strm, Module *module) +DumpModuleSymtab (CommandInterpreter &interpreter, Stream &strm, Module *module) { if (module) { @@ -162,13 +165,13 @@ DumpModuleSymtab (CommandContext *context, Stream &strm, Module *module) { Symtab *symtab = objfile->GetSymtab(); if (symtab) - symtab->Dump(&strm, context->GetExecutionContext().process); + symtab->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().process); } } } static void -DumpModuleSections (CommandContext *context, Stream &strm, Module *module) +DumpModuleSections (CommandInterpreter &interpreter, Stream &strm, Module *module) { if (module) { @@ -177,7 +180,7 @@ DumpModuleSections (CommandContext *context, Stream &strm, Module *module) { SectionList *section_list = objfile->GetSectionList(); if (section_list) - section_list->Dump(&strm, context->GetExecutionContext().process, true); + section_list->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().process, true); } } } @@ -198,14 +201,14 @@ DumpModuleSymbolVendor (Stream &strm, Module *module) } static bool -LookupAddressInModule (CommandContext *context, Stream &strm, Module *module, uint32_t resolve_mask, lldb::addr_t raw_addr, lldb::addr_t offset) +LookupAddressInModule (CommandInterpreter &interpreter, Stream &strm, Module *module, uint32_t resolve_mask, lldb::addr_t raw_addr, lldb::addr_t offset) { if (module) { lldb::addr_t addr = raw_addr - offset; Address so_addr; SymbolContext sc; - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process && process->IsAlive()) { if (!process->ResolveLoadAddress (addr, so_addr)) @@ -223,7 +226,7 @@ LookupAddressInModule (CommandContext *context, Stream &strm, Module *module, ui if (offset) strm.Printf("0x%llx: ", addr); - ExecutionContextScope *exe_scope = context->GetExecutionContext().GetBestExecutionContextScope(); + ExecutionContextScope *exe_scope = interpreter.GetDebugger().GetExecutionContext().GetBestExecutionContextScope(); if (so_addr.Dump (&strm, exe_scope, Address::DumpStyleSectionNameOffset)) strm.PutCString(": "); so_addr.Dump (&strm, exe_scope, Address::DumpStyleResolvedDescription); @@ -234,7 +237,7 @@ LookupAddressInModule (CommandContext *context, Stream &strm, Module *module, ui } static uint32_t -LookupSymbolInModule (CommandContext *context, Stream &strm, Module *module, const char *name, bool name_is_regex) +LookupSymbolInModule (CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name, bool name_is_regex) { if (module) { @@ -275,7 +278,7 @@ LookupSymbolInModule (CommandContext *context, Stream &strm, Module *module, con { Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]); strm.Indent (); - symbol->Dump (&strm, context->GetExecutionContext().process, i); + symbol->Dump (&strm, interpreter.GetDebugger().GetExecutionContext().process, i); } strm.IndentLess (); return num_matches; @@ -288,7 +291,7 @@ LookupSymbolInModule (CommandContext *context, Stream &strm, Module *module, con static void -DumpSymbolContextList (CommandContext *context, Stream &strm, SymbolContextList &sc_list, bool prepend_addr) +DumpSymbolContextList (CommandInterpreter &interpreter, Stream &strm, SymbolContextList &sc_list, bool prepend_addr) { strm.IndentMore (); uint32_t i; @@ -305,9 +308,9 @@ DumpSymbolContextList (CommandContext *context, Stream &strm, SymbolContextList if (sc.line_entry.range.GetBaseAddress().IsValid()) { lldb::addr_t vm_addr = - sc.line_entry.range.GetBaseAddress().GetLoadAddress(context->GetExecutionContext().process); + sc.line_entry.range.GetBaseAddress().GetLoadAddress(interpreter.GetDebugger().GetExecutionContext().process); int addr_size = sizeof (addr_t); - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process) addr_size = process->GetAddressByteSize(); if (vm_addr != LLDB_INVALID_ADDRESS) @@ -318,14 +321,14 @@ DumpSymbolContextList (CommandContext *context, Stream &strm, SymbolContextList strm.PutCString(" in "); } } - sc.DumpStopContext(&strm, context->GetExecutionContext().process, sc.line_entry.range.GetBaseAddress()); + sc.DumpStopContext(&strm, interpreter.GetDebugger().GetExecutionContext().process, sc.line_entry.range.GetBaseAddress()); } } strm.IndentLess (); } static uint32_t -LookupFunctionInModule (CommandContext *context, Stream &strm, Module *module, const char *name, bool name_is_regex) +LookupFunctionInModule (CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name, bool name_is_regex) { if (module && name && name[0]) { @@ -353,7 +356,7 @@ LookupFunctionInModule (CommandContext *context, Stream &strm, Module *module, c strm.Printf("%u match%s found in ", num_matches, num_matches > 1 ? "es" : ""); DumpFullpath (strm, &module->GetFileSpec(), 0); strm.PutCString(":\n"); - DumpSymbolContextList (context, strm, sc_list, true); + DumpSymbolContextList (interpreter, strm, sc_list, true); } return num_matches; } @@ -362,7 +365,7 @@ LookupFunctionInModule (CommandContext *context, Stream &strm, Module *module, c } static uint32_t -LookupFileAndLineInModule (CommandContext *context, Stream &strm, Module *module, const FileSpec &file_spec, uint32_t line, bool check_inlines) +LookupFileAndLineInModule (CommandInterpreter &interpreter, Stream &strm, Module *module, const FileSpec &file_spec, uint32_t line, bool check_inlines) { if (module && file_spec) { @@ -379,7 +382,7 @@ LookupFileAndLineInModule (CommandContext *context, Stream &strm, Module *module strm << " in "; DumpFullpath (strm, &module->GetFileSpec(), 0); strm.PutCString(":\n"); - DumpSymbolContextList (context, strm, sc_list, true); + DumpSymbolContextList (interpreter, strm, sc_list, true); return num_matches; } } @@ -397,8 +400,8 @@ class CommandObjectImageDumpModuleList : public CommandObject public: CommandObjectImageDumpModuleList (const char *name, - const char *help, - const char *syntax) : + const char *help, + const char *syntax) : CommandObject (name, help, syntax) { } @@ -409,26 +412,26 @@ public: } virtual int - HandleArgumentCompletion (Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches) + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + StringList &matches) { // Arguments are the standard module completer. std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (CommandCompletions::eModuleCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - interpreter, - NULL, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eModuleCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + matches); return matches.GetSize(); } }; @@ -438,8 +441,8 @@ class CommandObjectImageDumpSourceFileList : public CommandObject public: CommandObjectImageDumpSourceFileList (const char *name, - const char *help, - const char *syntax) : + const char *help, + const char *syntax) : CommandObject (name, help, syntax) { } @@ -450,26 +453,26 @@ public: } virtual int - HandleArgumentCompletion (Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches) + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + StringList &matches) { // Arguments are the standard source file completer. std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (CommandCompletions::eSourceFileCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - interpreter, - NULL, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eSourceFileCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + matches); return matches.GetSize(); } }; @@ -491,12 +494,11 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -521,7 +523,7 @@ public: for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx) { num_dumped++; - DumpModuleSymtab (context, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); + DumpModuleSymtab (interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); } } else @@ -549,7 +551,7 @@ public: if (image_module) { num_dumped++; - DumpModuleSymtab (context, result.GetOutputStream(), image_module); + DumpModuleSymtab (interpreter, result.GetOutputStream(), image_module); } } } @@ -578,10 +580,9 @@ class CommandObjectImageDumpSections : public CommandObjectImageDumpModuleList { public: CommandObjectImageDumpSections () : - CommandObjectImageDumpModuleList ( - "image dump sections", - "Dump the sections from one or more executable images.", - "image dump sections [<file1> ...]") + CommandObjectImageDumpModuleList ("image dump sections", + "Dump the sections from one or more executable images.", + "image dump sections [<file1> ...]") { } @@ -591,12 +592,11 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -621,7 +621,7 @@ public: for (uint32_t image_idx = 0; image_idx<num_modules; ++image_idx) { num_dumped++; - DumpModuleSections (context, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); + DumpModuleSections (interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); } } else @@ -649,7 +649,7 @@ public: if (image_module) { num_dumped++; - DumpModuleSections (context, result.GetOutputStream(), image_module); + DumpModuleSections (interpreter, result.GetOutputStream(), image_module); } } } @@ -689,12 +689,11 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -787,12 +786,11 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -801,7 +799,7 @@ public: } else { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); uint32_t total_num_dumped = 0; uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); @@ -826,7 +824,7 @@ public: uint32_t num_dumped = 0; for (uint32_t i = 0; i<num_modules; ++i) { - if (DumpCompileUnitLineTable (context, + if (DumpCompileUnitLineTable (interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(i), file_spec, @@ -863,15 +861,15 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectImageDump(CommandInterpreter *interpreter) : + CommandObjectImageDump(CommandInterpreter &interpreter) : CommandObjectMultiword ("image dump", - "Dumps information in one or more executable images; 'line-table' expects a source file name", - "image dump [symtab|sections|symfile|line-table] [<file1> <file2> ...]") + "Dumps information in one or more executable images; 'line-table' expects a source file name", + "image dump [symtab|sections|symfile|line-table] [<file1> <file2> ...]") { - LoadSubCommand (CommandObjectSP (new CommandObjectImageDumpSymtab ()), "symtab", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageDumpSections ()), "sections", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageDumpSymfile ()), "symfile", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageDumpLineTable ()), "line-table", interpreter); + LoadSubCommand (interpreter, "symtab", CommandObjectSP (new CommandObjectImageDumpSymtab ())); + LoadSubCommand (interpreter, "sections", CommandObjectSP (new CommandObjectImageDumpSections ())); + LoadSubCommand (interpreter, "symfile", CommandObjectSP (new CommandObjectImageDumpSymfile ())); + LoadSubCommand (interpreter, "line-table", CommandObjectSP (new CommandObjectImageDumpLineTable ())); } virtual @@ -957,12 +955,11 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -1223,14 +1220,14 @@ public: bool - LookupInModule (CommandContext *context, Module *module, CommandReturnObject &result, bool &syntax_error) + LookupInModule (CommandInterpreter &interpreter, Module *module, CommandReturnObject &result, bool &syntax_error) { switch (m_options.m_type) { case eLookupTypeAddress: if (m_options.m_addr != LLDB_INVALID_ADDRESS) { - if (LookupAddressInModule (context, result.GetOutputStream(), module, eSymbolContextEverything, m_options.m_addr, m_options.m_offset)) + if (LookupAddressInModule (interpreter, result.GetOutputStream(), module, eSymbolContextEverything, m_options.m_addr, m_options.m_offset)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; @@ -1241,7 +1238,7 @@ public: case eLookupTypeSymbol: if (!m_options.m_str.empty()) { - if (LookupSymbolInModule (context, result.GetOutputStream(), module, m_options.m_str.c_str(), m_options.m_use_regex)) + if (LookupSymbolInModule (interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), m_options.m_use_regex)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; @@ -1253,7 +1250,7 @@ public: if (m_options.m_file) { - if (LookupFileAndLineInModule (context, + if (LookupFileAndLineInModule (interpreter, result.GetOutputStream(), module, m_options.m_file, @@ -1269,7 +1266,7 @@ public: case eLookupTypeFunction: if (!m_options.m_str.empty()) { - if (LookupFunctionInModule (context, + if (LookupFunctionInModule (interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), @@ -1292,12 +1289,11 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -1322,7 +1318,7 @@ public: { for (i = 0; i<num_modules && syntax_error == false; ++i) { - if (LookupInModule (context, target->GetImages().GetModulePointerAtIndex(i), result, syntax_error)) + if (LookupInModule (interpreter, target->GetImages().GetModulePointerAtIndex(i), result, syntax_error)) { result.GetOutputStream().EOL(); num_successful_lookups++; @@ -1353,7 +1349,7 @@ public: Module * image_module = matching_modules.GetModulePointerAtIndex(i); if (image_module) { - if (LookupInModule (context, image_module, result, syntax_error)) + if (LookupInModule (interpreter, image_module, result, syntax_error)) { result.GetOutputStream().EOL(); num_successful_lookups++; @@ -1399,14 +1395,14 @@ CommandObjectImageLookup::CommandOptions::g_option_table[] = //---------------------------------------------------------------------- // CommandObjectImage constructor //---------------------------------------------------------------------- -CommandObjectImage::CommandObjectImage(CommandInterpreter *interpreter) : +CommandObjectImage::CommandObjectImage(CommandInterpreter &interpreter) : CommandObjectMultiword ("image", - "Access information for one or more executable images.", - "image [dump|list] ...") + "Access information for one or more executable images.", + "image [dump|list] ...") { - LoadSubCommand (CommandObjectSP (new CommandObjectImageDump (interpreter)), "dump", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageList ()), "list", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageLookup ()), "lookup", interpreter); + LoadSubCommand (interpreter, "dump", CommandObjectSP (new CommandObjectImageDump (interpreter))); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectImageList ())); + LoadSubCommand (interpreter, "lookup", CommandObjectSP (new CommandObjectImageLookup ())); } //---------------------------------------------------------------------- diff --git a/lldb/source/Commands/CommandObjectImage.h b/lldb/source/Commands/CommandObjectImage.h index 8863a3649a3..9394aeb10d1 100644 --- a/lldb/source/Commands/CommandObjectImage.h +++ b/lldb/source/Commands/CommandObjectImage.h @@ -28,7 +28,8 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectImage(CommandInterpreter *interpreter); + CommandObjectImage(CommandInterpreter &interpreter); + virtual ~CommandObjectImage(); diff --git a/lldb/source/Commands/CommandObjectLog.cpp b/lldb/source/Commands/CommandObjectLog.cpp index c68ecce3d73..5616fb1a064 100644 --- a/lldb/source/Commands/CommandObjectLog.cpp +++ b/lldb/source/Commands/CommandObjectLog.cpp @@ -26,7 +26,7 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/Timer.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/LineTable.h" @@ -76,9 +76,8 @@ public: } virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result) { if (args.GetArgumentCount() < 1) @@ -256,9 +255,8 @@ public: } virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -318,9 +316,8 @@ public: } virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -382,9 +379,8 @@ public: } virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -429,15 +425,15 @@ public: //---------------------------------------------------------------------- // CommandObjectLog constructor //---------------------------------------------------------------------- -CommandObjectLog::CommandObjectLog(CommandInterpreter *interpreter) : +CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter) : CommandObjectMultiword ("log", "A set of commands for operating on logs.", "log <command> [<command-options>]") { - LoadSubCommand (CommandObjectSP (new CommandObjectLogEnable), "enable", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectLogDisable), "disable", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectLogList), "list", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectLogTimer), "timers", interpreter); + LoadSubCommand (interpreter, "enable", CommandObjectSP (new CommandObjectLogEnable)); + LoadSubCommand (interpreter, "disable", CommandObjectSP (new CommandObjectLogDisable)); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectLogList)); + LoadSubCommand (interpreter, "timers", CommandObjectSP (new CommandObjectLogTimer)); } //---------------------------------------------------------------------- diff --git a/lldb/source/Commands/CommandObjectLog.h b/lldb/source/Commands/CommandObjectLog.h index a1ba258ea33..3e731fa1d18 100644 --- a/lldb/source/Commands/CommandObjectLog.h +++ b/lldb/source/Commands/CommandObjectLog.h @@ -31,7 +31,7 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectLog(CommandInterpreter *interpreter); + CommandObjectLog(CommandInterpreter &interpreter); virtual ~CommandObjectLog(); diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index da845f0d155..9400200070a 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -13,13 +13,14 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/Args.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" -#include "lldb/Interpreter/Options.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/StreamString.h" +#include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/Options.h" #include "lldb/Target/Process.h" using namespace lldb; @@ -195,12 +196,11 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError("need a process to read memory"); @@ -441,12 +441,11 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError("need a process to read memory"); @@ -666,13 +665,13 @@ CommandObjectMemoryWrite::CommandOptions::g_option_table[] = // CommandObjectMemory //------------------------------------------------------------------------- -CommandObjectMemory::CommandObjectMemory (CommandInterpreter *interpreter) : +CommandObjectMemory::CommandObjectMemory (CommandInterpreter &interpreter) : CommandObjectMultiword ("memory", "A set of commands for operating on a memory.", "memory <subcommand> [<subcommand-options>]") { - LoadSubCommand (CommandObjectSP (new CommandObjectMemoryRead ()), "read", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectMemoryWrite ()), "write", interpreter); + LoadSubCommand (interpreter, "read", CommandObjectSP (new CommandObjectMemoryRead ())); + LoadSubCommand (interpreter, "write", CommandObjectSP (new CommandObjectMemoryWrite ())); } CommandObjectMemory::~CommandObjectMemory () diff --git a/lldb/source/Commands/CommandObjectMemory.h b/lldb/source/Commands/CommandObjectMemory.h index a4665401510..b044921ae07 100644 --- a/lldb/source/Commands/CommandObjectMemory.h +++ b/lldb/source/Commands/CommandObjectMemory.h @@ -21,7 +21,7 @@ namespace lldb_private { class CommandObjectMemory : public CommandObjectMultiword { public: - CommandObjectMemory (CommandInterpreter *interpreter); + CommandObjectMemory (CommandInterpreter &interpreter); virtual ~CommandObjectMemory (); diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index b5553d65b80..d8e8f546a53 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -12,7 +12,7 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -80,8 +80,12 @@ CommandObjectMultiword::GetSubcommandObject (const char *sub_cmd, StringList *ma } bool -CommandObjectMultiword::LoadSubCommand (CommandObjectSP cmd_obj, const char *name, - CommandInterpreter *interpreter) +CommandObjectMultiword::LoadSubCommand +( + CommandInterpreter &interpreter, + const char *name, + const CommandObjectSP& cmd_obj +) { CommandMap::iterator pos; bool success = true; @@ -90,7 +94,7 @@ CommandObjectMultiword::LoadSubCommand (CommandObjectSP cmd_obj, const char *nam if (pos == m_subcommand_dict.end()) { m_subcommand_dict[name] = cmd_obj; - interpreter->CrossRegisterCommand (name, GetCommandName()); + interpreter.CrossRegisterCommand (name, GetCommandName()); } else success = false; @@ -101,16 +105,15 @@ CommandObjectMultiword::LoadSubCommand (CommandObjectSP cmd_obj, const char *nam bool CommandObjectMultiword::Execute ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { const size_t argc = args.GetArgumentCount(); if (argc == 0) { - GenerateHelpText (result, interpreter); + GenerateHelpText (interpreter, result); } else { @@ -120,7 +123,7 @@ CommandObjectMultiword::Execute { if (::strcasecmp (sub_command, "help") == 0) { - GenerateHelpText (result, interpreter); + GenerateHelpText (interpreter, result); } else if (!m_subcommand_dict.empty()) { @@ -133,7 +136,7 @@ CommandObjectMultiword::Execute args.Shift(); - sub_cmd_obj->ExecuteWithOptions (args, context, interpreter, result); + sub_cmd_obj->ExecuteWithOptions (interpreter, args, result); } else { @@ -176,7 +179,7 @@ CommandObjectMultiword::Execute } void -CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result, CommandInterpreter *interpreter) +CommandObjectMultiword::GenerateHelpText (CommandInterpreter &interpreter, CommandReturnObject &result) { // First time through here, generate the help text for the object and // push it to the return result object as well @@ -185,7 +188,7 @@ CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result, CommandIn output_stream.PutCString ("The following subcommands are supported:\n\n"); CommandMap::iterator pos; - std::string longest_word = interpreter->FindLongestCommandWord (m_subcommand_dict); + std::string longest_word = interpreter.FindLongestCommandWord (m_subcommand_dict); uint32_t max_len = 0; if (! longest_word.empty()) @@ -195,8 +198,11 @@ CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result, CommandIn { std::string indented_command (" "); indented_command.append (pos->first); - interpreter->OutputFormattedHelpText (result.GetOutputStream(), indented_command.c_str(), "--", - pos->second->GetHelp(), max_len); + interpreter.OutputFormattedHelpText (result.GetOutputStream(), + indented_command.c_str(), + "--", + pos->second->GetHelp(), + max_len); } output_stream.PutCString ("\nFor more help on any particular subcommand, type 'help <command> <subcommand>'.\n"); @@ -207,33 +213,40 @@ CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result, CommandIn int CommandObjectMultiword::HandleCompletion ( + CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) { if (cursor_index == 0) { - CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, input.GetArgumentAtIndex(0), matches); + CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, + input.GetArgumentAtIndex(0), + matches); if (matches.GetSize() == 1 && matches.GetStringAtIndex(0) != NULL && strcmp (input.GetArgumentAtIndex(0), matches.GetStringAtIndex(0)) == 0) { StringList temp_matches; - CommandObject *cmd_obj = GetSubcommandObject (input.GetArgumentAtIndex(0), &temp_matches); + CommandObject *cmd_obj = GetSubcommandObject (input.GetArgumentAtIndex(0), + &temp_matches); if (cmd_obj != NULL) { matches.DeleteStringAtIndex (0); input.Shift(); cursor_char_position = 0; input.AppendArgument (""); - return cmd_obj->HandleCompletion (input, cursor_index, cursor_char_position, match_start_point, - max_return_elements, interpreter, matches); + return cmd_obj->HandleCompletion (interpreter, + input, cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + matches); } else return matches.GetSize(); @@ -243,7 +256,8 @@ CommandObjectMultiword::HandleCompletion } else { - CommandObject *sub_command_object = GetSubcommandObject (input.GetArgumentAtIndex(0), &matches); + CommandObject *sub_command_object = GetSubcommandObject (input.GetArgumentAtIndex(0), + &matches); if (sub_command_object == NULL) { return matches.GetSize(); @@ -254,8 +268,13 @@ CommandObjectMultiword::HandleCompletion matches.DeleteStringAtIndex(0); input.Shift(); cursor_index--; - return sub_command_object->HandleCompletion (input, cursor_index, cursor_char_position, match_start_point, - max_return_elements, interpreter, matches); + return sub_command_object->HandleCompletion (interpreter, + input, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + matches); } } diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 0a8487155d3..84deb2fc593 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -120,13 +120,12 @@ public: } bool - Execute (Args& launch_args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& launch_args, CommandReturnObject &result) { - Target *target = context->GetTarget(); - bool synchronous_execution = interpreter->GetSynchronous (); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); + bool synchronous_execution = interpreter.GetSynchronous (); // bool launched = false; // bool stopped_after_launch = false; @@ -138,19 +137,11 @@ public: } // If our listener is NULL, users aren't allows to launch - Listener *listener = interpreter->GetListener(); - if (listener == NULL) - { - result.AppendError ("operation not allowed through the command interpreter"); - result.SetStatus (eReturnStatusFailed); - return false; - } - char filename[PATH_MAX]; Module *exe_module = target->GetExecutableModule().get(); exe_module->GetFileSpec().GetPath(filename, sizeof(filename)); - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process) { if (process->IsAlive()) @@ -168,10 +159,10 @@ public: else plugin_name = NULL; - process = target->CreateProcess (*listener, plugin_name).get(); + process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get(); - const Args *environment = interpreter->GetEnvironmentVariables(); - const Args *run_args = interpreter->GetProgramArguments(); + const Args *environment = interpreter.GetEnvironmentVariables(); + const Args *run_args = interpreter.GetProgramArguments(); // There are two possible sources of args to be passed to the process upon launching: Those the user // typed at the run command (launch_args); or those the user pre-set in the run-args variable (run_args). @@ -185,7 +176,7 @@ public: else { // launch-args was not empty; use that, AND re-set run-args to contains launch-args values. - StateVariable *run_args_var = interpreter->GetStateVariable ("run-args"); + StateVariable *run_args_var = interpreter.GetStateVariable ("run-args"); if (run_args_var != NULL) { run_args_var->ArrayClearValues(); @@ -229,7 +220,7 @@ public: { // Call continue_command. CommandReturnObject continue_result; - interpreter->HandleCommand("process continue", false, continue_result); + interpreter.HandleCommand("process continue", false, continue_result); } if (synchronous_execution) @@ -296,12 +287,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -310,14 +300,8 @@ public: } // If our listener is NULL, users aren't allows to launch - Listener *listener = interpreter->GetListener(); - if (listener == NULL) - { - result.AppendError ("operation not allowed through the command interpreter"); - result.SetStatus (eReturnStatusFailed); - return false; - } - Process *process = context->GetExecutionContext().process; + + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process) { if (process->IsAlive()) @@ -340,7 +324,7 @@ public: if (!m_options.plugin_name.empty()) plugin_name = m_options.plugin_name.c_str(); - process = target->CreateProcess (*listener, plugin_name).get(); + process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get(); if (process) { @@ -508,13 +492,12 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; - bool synchronous_execution = interpreter->GetSynchronous (); + Process *process = interpreter.GetDebugger().GetExecutionContext().process; + bool synchronous_execution = interpreter.GetSynchronous (); if (process == NULL) { @@ -595,12 +578,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("must have a valid process in order to detach"); @@ -643,12 +625,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to signal"); @@ -711,12 +692,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to halt"); @@ -773,12 +753,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to kill"); @@ -832,15 +811,14 @@ public: bool Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { StreamString &output_stream = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.process) { const StateType state = exe_ctx.process->GetState(); @@ -891,19 +869,19 @@ public: // CommandObjectMultiwordProcess //------------------------------------------------------------------------- -CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter *interpreter) : +CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter &interpreter) : CommandObjectMultiword ("process", "A set of commands for operating on a process.", "process <subcommand> [<subcommand-options>]") { - LoadSubCommand (CommandObjectSP (new CommandObjectProcessAttach ()), "attach", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessLaunch ()), "launch", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessContinue ()), "continue", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessDetach ()), "detach", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessSignal ()), "signal", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessStatus ()), "status", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessInterrupt ()), "interrupt", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessKill ()), "kill", interpreter); + LoadSubCommand (interpreter, "attach", CommandObjectSP (new CommandObjectProcessAttach ())); + LoadSubCommand (interpreter, "launch", CommandObjectSP (new CommandObjectProcessLaunch ())); + LoadSubCommand (interpreter, "continue", CommandObjectSP (new CommandObjectProcessContinue ())); + LoadSubCommand (interpreter, "detach", CommandObjectSP (new CommandObjectProcessDetach ())); + LoadSubCommand (interpreter, "signal", CommandObjectSP (new CommandObjectProcessSignal ())); + LoadSubCommand (interpreter, "status", CommandObjectSP (new CommandObjectProcessStatus ())); + LoadSubCommand (interpreter, "interrupt", CommandObjectSP (new CommandObjectProcessInterrupt ())); + LoadSubCommand (interpreter, "kill", CommandObjectSP (new CommandObjectProcessKill ())); } CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess () diff --git a/lldb/source/Commands/CommandObjectProcess.h b/lldb/source/Commands/CommandObjectProcess.h index 9a8d59e70e6..0aaa74d28a0 100644 --- a/lldb/source/Commands/CommandObjectProcess.h +++ b/lldb/source/Commands/CommandObjectProcess.h @@ -25,7 +25,7 @@ namespace lldb_private { class CommandObjectMultiwordProcess : public CommandObjectMultiword { public: - CommandObjectMultiwordProcess (CommandInterpreter *interpreter); + CommandObjectMultiwordProcess (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordProcess (); diff --git a/lldb/source/Commands/CommandObjectQuit.cpp b/lldb/source/Commands/CommandObjectQuit.cpp index 23aee3bb6f3..1d85555d195 100644 --- a/lldb/source/Commands/CommandObjectQuit.cpp +++ b/lldb/source/Commands/CommandObjectQuit.cpp @@ -35,13 +35,12 @@ CommandObjectQuit::~CommandObjectQuit () bool CommandObjectQuit::Execute ( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result ) { - interpreter->BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived); + interpreter.BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived); result.SetStatus (eReturnStatusQuit); return true; } diff --git a/lldb/source/Commands/CommandObjectQuit.h b/lldb/source/Commands/CommandObjectQuit.h index a45d8a4b51b..f696828237b 100644 --- a/lldb/source/Commands/CommandObjectQuit.h +++ b/lldb/source/Commands/CommandObjectQuit.h @@ -39,9 +39,8 @@ public: ~CommandObjectQuit (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectRegister.cpp b/lldb/source/Commands/CommandObjectRegister.cpp index cd7708489ae..2aded26d2b4 100644 --- a/lldb/source/Commands/CommandObjectRegister.cpp +++ b/lldb/source/Commands/CommandObjectRegister.cpp @@ -13,10 +13,11 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/Args.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Scalar.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/Args.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/RegisterContext.h" @@ -44,14 +45,16 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { StreamString &output_stream = result.GetOutputStream(); DataExtractor reg_data; - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) @@ -150,13 +153,15 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { DataExtractor reg_data; - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) @@ -213,13 +218,13 @@ public: //---------------------------------------------------------------------- // CommandObjectRegister constructor //---------------------------------------------------------------------- -CommandObjectRegister::CommandObjectRegister(CommandInterpreter *interpreter) : +CommandObjectRegister::CommandObjectRegister(CommandInterpreter &interpreter) : CommandObjectMultiword ("register", "Access thread registers.", "register [read|write] ...") { - LoadSubCommand (CommandObjectSP (new CommandObjectRegisterRead ()), "read", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectRegisterWrite ()), "write", interpreter); + LoadSubCommand (interpreter, "read", CommandObjectSP (new CommandObjectRegisterRead ())); + LoadSubCommand (interpreter, "write", CommandObjectSP (new CommandObjectRegisterWrite ())); } diff --git a/lldb/source/Commands/CommandObjectRegister.h b/lldb/source/Commands/CommandObjectRegister.h index 740bc5424e4..7f856c2de52 100644 --- a/lldb/source/Commands/CommandObjectRegister.h +++ b/lldb/source/Commands/CommandObjectRegister.h @@ -28,7 +28,8 @@ public: //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectRegister(CommandInterpreter *interpreter); + CommandObjectRegister(CommandInterpreter &interpreter); + virtual ~CommandObjectRegister(); diff --git a/lldb/source/Commands/CommandObjectRemove.cpp b/lldb/source/Commands/CommandObjectRemove.cpp deleted file mode 100644 index 28736cd16ec..00000000000 --- a/lldb/source/Commands/CommandObjectRemove.cpp +++ /dev/null @@ -1,89 +0,0 @@ -//===-- CommandObjectRemove.cpp ---------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectRemove.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; - -//------------------------------------------------------------------------- -// CommandObjectRemove -//------------------------------------------------------------------------- - -CommandObjectRemove::CommandObjectRemove () : - CommandObject ("remove", - "Allows the user to remove/delete user-defined command functions (script functions).", - "remove <command-name-to-be-removed>") -{ -} - -CommandObjectRemove::~CommandObjectRemove() -{ -} - - -bool -CommandObjectRemove::Execute (Args& args, CommandContext *context, CommandInterpreter *interpreter, - 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->RemoveUser (command_name) == false) - { - if (interpreter->UserCommandExists (command_name)) - result.AppendErrorWithFormat ("Unknown error occurred; unable to remove command '%s'.\n", - command_name); - else - result.AppendErrorWithFormat ("'%s' is not a user-defined command/function name.\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 remove with a valid command"); - result.SetStatus (eReturnStatusFailed); - } - - return result.Succeeded(); -} - diff --git a/lldb/source/Commands/CommandObjectRemove.h b/lldb/source/Commands/CommandObjectRemove.h deleted file mode 100644 index 4b017a4fbb1..00000000000 --- a/lldb/source/Commands/CommandObjectRemove.h +++ /dev/null @@ -1,44 +0,0 @@ -//===-- CommandObjectRemove.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_CommandObjectRemove_h_ -#define liblldb_CommandObjectRemove_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { - -//------------------------------------------------------------------------- -// CommandObjectRemove -//------------------------------------------------------------------------- - -class CommandObjectRemove : public CommandObject -{ -public: - - CommandObjectRemove (); - - virtual - ~CommandObjectRemove (); - - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectRemove_h_ diff --git a/lldb/source/Commands/CommandObjectSet.cpp b/lldb/source/Commands/CommandObjectSet.cpp index 46ad049fd1b..89f154a083e 100644 --- a/lldb/source/Commands/CommandObjectSet.cpp +++ b/lldb/source/Commands/CommandObjectSet.cpp @@ -38,9 +38,8 @@ CommandObjectSet::~CommandObjectSet() bool CommandObjectSet::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -66,7 +65,7 @@ CommandObjectSet::Execute else if (var_value == NULL || var_value[0] == '\0') { // No value given: Check to see if we're trying to clear an array. - StateVariable *var = interpreter->GetStateVariable (var_name); + StateVariable *var = interpreter.GetStateVariable (var_name); if (var != NULL && var->GetType() == StateVariable::eTypeStringArray) { @@ -81,7 +80,7 @@ CommandObjectSet::Execute } else { - StateVariable *var = interpreter->GetStateVariable(var_name); + StateVariable *var = interpreter.GetStateVariable(var_name); if (var == NULL) { result.AppendErrorWithFormat ("'%s' is not a settable internal variable.\n", var_name); @@ -98,7 +97,7 @@ CommandObjectSet::Execute if (success) { result.SetStatus(eReturnStatusSuccessFinishResult); - if (!var->HasVerifyFunction() || var->VerifyValue (interpreter, (void *) &new_value, result)) + if (!var->HasVerifyFunction() || var->VerifyValue (&interpreter, (void *) &new_value, result)) var->SetBoolValue (new_value); } else @@ -115,7 +114,7 @@ CommandObjectSet::Execute if (success) { result.SetStatus(eReturnStatusSuccessFinishResult); - if (!var->HasVerifyFunction() || var->VerifyValue (interpreter, (void *) &new_value, result)) + if (!var->HasVerifyFunction() || var->VerifyValue (&interpreter, (void *) &new_value, result)) var->SetIntValue (new_value); } else @@ -126,7 +125,7 @@ CommandObjectSet::Execute } else if (var->GetType() == StateVariable::eTypeString) { - if (!var->HasVerifyFunction() || var->VerifyValue (interpreter, (void *) var_value, result)) + if (!var->HasVerifyFunction() || var->VerifyValue (&interpreter, (void *) var_value, result)) var->SetStringValue (var_value); } else if (var->GetType() == StateVariable::eTypeStringArray) diff --git a/lldb/source/Commands/CommandObjectSet.h b/lldb/source/Commands/CommandObjectSet.h index 1a3c3dfd1bc..8e4d81f8d42 100644 --- a/lldb/source/Commands/CommandObjectSet.h +++ b/lldb/source/Commands/CommandObjectSet.h @@ -32,9 +32,8 @@ public: ~CommandObjectSet (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectSettings.cpp b/lldb/source/Commands/CommandObjectSettings.cpp index 078b699ffdb..3b75c870a34 100644 --- a/lldb/source/Commands/CommandObjectSettings.cpp +++ b/lldb/source/Commands/CommandObjectSettings.cpp @@ -38,9 +38,8 @@ CommandObjectSettings::~CommandObjectSettings() bool CommandObjectSettings::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -53,7 +52,7 @@ CommandObjectSettings::Execute } else { - interpreter->ShowVariableHelp (result); + interpreter.ShowVariableHelp (result); result.SetStatus (eReturnStatusSuccessFinishNoResult); } diff --git a/lldb/source/Commands/CommandObjectSettings.h b/lldb/source/Commands/CommandObjectSettings.h index 674a98b8ca8..4159b8b03b6 100644 --- a/lldb/source/Commands/CommandObjectSettings.h +++ b/lldb/source/Commands/CommandObjectSettings.h @@ -32,9 +32,8 @@ public: ~CommandObjectSettings (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectShow.cpp b/lldb/source/Commands/CommandObjectShow.cpp index be6f6888a99..4acbf66d548 100644 --- a/lldb/source/Commands/CommandObjectShow.cpp +++ b/lldb/source/Commands/CommandObjectShow.cpp @@ -38,9 +38,8 @@ CommandObjectShow::~CommandObjectShow() bool CommandObjectShow::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -51,7 +50,7 @@ CommandObjectShow::Execute // The user requested to see the value of a particular variable. const char *var_name = command.GetArgumentAtIndex(0); - StateVariable *var = interpreter->GetStateVariable(var_name); + StateVariable *var = interpreter.GetStateVariable(var_name); if (var) { var->AppendVariableInformation (result); @@ -66,7 +65,7 @@ CommandObjectShow::Execute else { // The user didn't specify a particular variable, so show the values of all of them. - interpreter->ShowVariableValues(result); + interpreter.ShowVariableValues(result); result.SetStatus (eReturnStatusSuccessFinishNoResult); } diff --git a/lldb/source/Commands/CommandObjectShow.h b/lldb/source/Commands/CommandObjectShow.h index 460280a3c55..a51cd4d6516 100644 --- a/lldb/source/Commands/CommandObjectShow.h +++ b/lldb/source/Commands/CommandObjectShow.h @@ -32,9 +32,8 @@ public: ~CommandObjectShow (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectSource.cpp b/lldb/source/Commands/CommandObjectSource.cpp index 97c04a71654..9be4dccc8d9 100644 --- a/lldb/source/Commands/CommandObjectSource.cpp +++ b/lldb/source/Commands/CommandObjectSource.cpp @@ -14,7 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/Args.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Process.h" @@ -43,9 +43,8 @@ CommandObjectSource::~CommandObjectSource () bool CommandObjectSource::Execute ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -88,8 +87,8 @@ CommandObjectSource::Execute size_t i; for (i = 0; i<num_commands; ++i) { - result.GetOutputStream().Printf("%s %s\n", interpreter->GetPrompt(), commands[i].c_str()); - if (!interpreter->HandleCommand(commands[i].c_str(), false, result)) + result.GetOutputStream().Printf("%s %s\n", interpreter.GetPrompt(), commands[i].c_str()); + if (!interpreter.HandleCommand(commands[i].c_str(), false, result)) break; } diff --git a/lldb/source/Commands/CommandObjectSource.h b/lldb/source/Commands/CommandObjectSource.h index 416e3c02b2c..8bc1ae58b3d 100644 --- a/lldb/source/Commands/CommandObjectSource.h +++ b/lldb/source/Commands/CommandObjectSource.h @@ -36,9 +36,8 @@ public: GetCommands (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectSourceFile.cpp b/lldb/source/Commands/CommandObjectSourceFile.cpp index 6e6082c81c2..cfb53e0ad34 100644 --- a/lldb/source/Commands/CommandObjectSourceFile.cpp +++ b/lldb/source/Commands/CommandObjectSourceFile.cpp @@ -14,7 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/Args.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Process.h" @@ -119,9 +119,8 @@ CommandObjectSourceFile::GetOptions () bool CommandObjectSourceFile::Execute ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -133,7 +132,7 @@ CommandObjectSourceFile::Execute result.SetStatus (eReturnStatusFailed); } - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (m_options.file_name.empty()) { // Last valid source manager context, or the current frame if no @@ -142,14 +141,14 @@ CommandObjectSourceFile::Execute // more likely because you typed it once, then typed it again if (m_options.start_line == 0) { - if (interpreter->GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream())) + if (interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream())) { result.SetStatus (eReturnStatusSuccessFinishResult); } } else { - if (interpreter->GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile( + 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 @@ -164,7 +163,7 @@ CommandObjectSourceFile::Execute else { const char *filename = m_options.file_name.c_str(); - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -187,13 +186,13 @@ CommandObjectSourceFile::Execute { if (sc.comp_unit) { - interpreter->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()); - + 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); } diff --git a/lldb/source/Commands/CommandObjectSourceFile.h b/lldb/source/Commands/CommandObjectSourceFile.h index f25fcc0eff9..9d15b198d53 100644 --- a/lldb/source/Commands/CommandObjectSourceFile.h +++ b/lldb/source/Commands/CommandObjectSourceFile.h @@ -62,9 +62,8 @@ public: ~CommandObjectSourceFile (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual diff --git a/lldb/source/Commands/CommandObjectSyntax.cpp b/lldb/source/Commands/CommandObjectSyntax.cpp index 092a9fce3f1..3279da2c1d6 100644 --- a/lldb/source/Commands/CommandObjectSyntax.cpp +++ b/lldb/source/Commands/CommandObjectSyntax.cpp @@ -43,7 +43,7 @@ bool CommandObjectSyntax::OldExecute ( Args& command, - CommandContext *context, + Debugger *context, CommandInterpreter *interpreter, CommandReturnObject &result ) @@ -86,7 +86,7 @@ CommandObjectSyntax::OldExecute } bool -CommandObjectSyntax::Execute (Args &command, CommandContext *context, CommandInterpreter *interpreter, +CommandObjectSyntax::Execute (Args &command, Debugger *context, CommandInterpreter *interpreter, CommandReturnObject &result) { CommandObject::CommandMap::iterator pos; diff --git a/lldb/source/Commands/CommandObjectSyntax.h b/lldb/source/Commands/CommandObjectSyntax.h index e5f5f4e544d..3caf533fed8 100644 --- a/lldb/source/Commands/CommandObjectSyntax.h +++ b/lldb/source/Commands/CommandObjectSyntax.h @@ -33,13 +33,13 @@ public: bool OldExecute (Args& command, - CommandContext *context, + Debugger *context, CommandInterpreter *interpreter, CommandReturnObject &result); virtual bool Execute (Args& command, - CommandContext *context, + Debugger *context, CommandInterpreter *interpreter, CommandReturnObject &result); diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 1762f5d9977..3f8581c80fa 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -18,7 +18,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Timer.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Process.h" @@ -46,12 +46,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target * target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) { uint32_t argc = command.GetArgumentCount(); @@ -70,9 +69,9 @@ public: if (from[0] && to[0]) { bool last_pair = ((argc - i) == 2); - target->GetImageSearchPathList().Append(ConstString(from), - ConstString(to), - last_pair); // Notify if this is the last pair + target->GetImageSearchPathList().Append (ConstString(from), + ConstString(to), + last_pair); // Notify if this is the last pair } else { @@ -110,12 +109,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target * target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) { bool notify = true; @@ -146,12 +144,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target * target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) { uint32_t argc = command.GetArgumentCount(); @@ -230,12 +227,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target * target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) { if (command.GetArgumentCount() != 0) @@ -272,12 +268,11 @@ public: } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target * target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) { if (command.GetArgumentCount() != 1) @@ -327,8 +322,8 @@ public: // // bool // Execute (Args& command, -// CommandContext *context, -// CommandInterpreter *interpreter, +// Debugger *context, +// CommandInterpreter &interpreter, // CommandReturnObject &result) // { // ExecutionContext exe_ctx (context->GetExecutionContext()); @@ -392,16 +387,16 @@ class CommandObjectMultiwordImageSearchPaths : public CommandObjectMultiword { public: - CommandObjectMultiwordImageSearchPaths (CommandInterpreter *interpreter) : + CommandObjectMultiwordImageSearchPaths (CommandInterpreter &interpreter) : CommandObjectMultiword ("target image-search-paths", "A set of commands for operating on debugger target image search paths.", "target image-search-paths <subcommand> [<subcommand-options>]") { - LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsAdd ()), "add", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsClear ()), "clear", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsInsert ()), "insert", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsList ()), "list", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsQuery ()), "query", interpreter); + LoadSubCommand (interpreter, "add", CommandObjectSP (new CommandObjectTargetImageSearchPathsAdd ())); + LoadSubCommand (interpreter, "clear", CommandObjectSP (new CommandObjectTargetImageSearchPathsClear ())); + LoadSubCommand (interpreter, "insert", CommandObjectSP (new CommandObjectTargetImageSearchPathsInsert ())); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectTargetImageSearchPathsList ())); + LoadSubCommand (interpreter, "query", CommandObjectSP (new CommandObjectTargetImageSearchPathsQuery ())); } ~CommandObjectMultiwordImageSearchPaths() @@ -416,12 +411,12 @@ public: // CommandObjectMultiwordTarget //------------------------------------------------------------------------- -CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter *interpreter) : +CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter &interpreter) : CommandObjectMultiword ("target", "A set of commands for operating on debugger targets.", "target <subcommand> [<subcommand-options>]") { - LoadSubCommand (CommandObjectSP (new CommandObjectMultiwordImageSearchPaths (interpreter)), "image-search-paths", interpreter); + LoadSubCommand (interpreter, "image-search-paths", CommandObjectSP (new CommandObjectMultiwordImageSearchPaths (interpreter))); } CommandObjectMultiwordTarget::~CommandObjectMultiwordTarget () diff --git a/lldb/source/Commands/CommandObjectTarget.h b/lldb/source/Commands/CommandObjectTarget.h index 06c89dc7a51..7b6637812c4 100644 --- a/lldb/source/Commands/CommandObjectTarget.h +++ b/lldb/source/Commands/CommandObjectTarget.h @@ -28,7 +28,7 @@ class CommandObjectMultiwordTarget : public CommandObjectMultiword { public: - CommandObjectMultiwordTarget (CommandInterpreter *interpreter); + CommandObjectMultiwordTarget (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordTarget (); diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index ef529f0e70b..bf4843da67f 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -39,7 +39,7 @@ using namespace lldb_private; bool lldb_private::DisplayThreadInfo ( - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream &strm, Thread *thread, bool only_threads_with_stop_reason, @@ -96,7 +96,7 @@ lldb_private::DisplayThreadInfo size_t lldb_private::DisplayThreadsInfo ( - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, ExecutionContext *exe_ctx, CommandReturnObject &result, bool only_threads_with_stop_reason, @@ -145,7 +145,7 @@ size_t lldb_private::DisplayFramesForExecutionContext ( Thread *thread, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream& strm, bool ascending, uint32_t first_frame, @@ -226,7 +226,7 @@ lldb_private::DisplayFrameForExecutionContext ( Thread *thread, StackFrame *frame, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream& strm, bool show_frame_info, bool show_source, @@ -248,7 +248,7 @@ lldb_private::DisplayFrameForExecutionContext if (show_source && sc.comp_unit && sc.line_entry.IsValid()) { - interpreter->GetSourceManager().DisplaySourceLinesWithLineNumbers ( + interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers ( sc.line_entry.file, sc.line_entry.line, 3, @@ -285,18 +285,17 @@ public: } - bool + virtual bool Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { if (command.GetArgumentCount() == 0) { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.thread) { bool show_frame_info = true; @@ -441,13 +440,15 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - Process *process = context->GetExecutionContext().process; - bool synchronous_execution = interpreter->GetSynchronous(); + Process *process = interpreter.GetDebugger().GetExecutionContext().process; + bool synchronous_execution = interpreter.GetSynchronous(); if (process == NULL) { @@ -647,21 +648,23 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - bool synchronous_execution = interpreter->GetSynchronous (); + bool synchronous_execution = interpreter.GetSynchronous (); - if (!context->GetTarget()) + if (!interpreter.GetDebugger().GetCurrentTarget().get()) { result.AppendError ("invalid target, set executable file using 'file' command"); result.SetStatus (eReturnStatusFailed); return false; } - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process exists. Cannot continue"); @@ -897,21 +900,23 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - bool synchronous_execution = interpreter->GetSynchronous (); + bool synchronous_execution = interpreter.GetSynchronous (); - if (!context->GetTarget()) + if (!interpreter.GetDebugger().GetCurrentTarget().get()) { result.AppendError ("invalid target, set executable file using 'file' command"); result.SetStatus (eReturnStatusFailed); return false; } - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("need a valid process to step"); @@ -1085,12 +1090,14 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process"); @@ -1132,128 +1139,130 @@ public: // CommandObjectThreadList //------------------------------------------------------------------------- -CommandObjectThreadList::CommandObjectThreadList (): - CommandObject ("thread list", - "Shows a summary of all current threads in a process.", - "thread list", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) +class CommandObjectThreadList : public CommandObject { -} +public: -CommandObjectThreadList::~CommandObjectThreadList() -{ -} -bool -CommandObjectThreadList::Execute -( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result -) -{ - StreamString &strm = result.GetOutputStream(); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(context->GetExecutionContext()); - if (exe_ctx.process) + CommandObjectThreadList (): + CommandObject ("thread list", + "Shows a summary of all current threads in a process.", + "thread list", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) + { + } + + ~CommandObjectThreadList() { - const StateType state = exe_ctx.process->GetState(); + } - if (StateIsStoppedState(state)) + bool + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) + { + StreamString &strm = result.GetOutputStream(); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + if (exe_ctx.process) { - if (state == eStateExited) - { - int exit_status = exe_ctx.process->GetExitStatus(); - const char *exit_description = exe_ctx.process->GetExitDescription(); - strm.Printf ("Process %d exited with status = %i (0x%8.8x) %s\n", - exe_ctx.process->GetID(), - exit_status, - exit_status, - exit_description ? exit_description : ""); - } - else + const StateType state = exe_ctx.process->GetState(); + + if (StateIsStoppedState(state)) { - strm.Printf ("Process %d state is %s\n", exe_ctx.process->GetID(), StateAsCString (state)); - if (exe_ctx.thread == NULL) - exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); - if (exe_ctx.thread != NULL) + if (state == eStateExited) { - DisplayThreadsInfo (interpreter, &exe_ctx, result, false, false); + int exit_status = exe_ctx.process->GetExitStatus(); + const char *exit_description = exe_ctx.process->GetExitDescription(); + strm.Printf ("Process %d exited with status = %i (0x%8.8x) %s\n", + exe_ctx.process->GetID(), + exit_status, + exit_status, + exit_description ? exit_description : ""); } else { - result.AppendError ("no valid thread found in current process"); - result.SetStatus (eReturnStatusFailed); + strm.Printf ("Process %d state is %s\n", exe_ctx.process->GetID(), StateAsCString (state)); + if (exe_ctx.thread == NULL) + exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); + if (exe_ctx.thread != NULL) + { + DisplayThreadsInfo (interpreter, &exe_ctx, result, false, false); + } + else + { + result.AppendError ("no valid thread found in current process"); + result.SetStatus (eReturnStatusFailed); + } } } + else + { + result.AppendError ("process is currently running"); + result.SetStatus (eReturnStatusFailed); + } } else { - result.AppendError ("process is currently running"); + result.AppendError ("no current location or status available"); result.SetStatus (eReturnStatusFailed); } + return result.Succeeded(); } - else - { - result.AppendError ("no current location or status available"); - result.SetStatus (eReturnStatusFailed); - } - return result.Succeeded(); -} +}; //------------------------------------------------------------------------- // CommandObjectMultiwordThread //------------------------------------------------------------------------- -CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter *interpreter) : +CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter &interpreter) : CommandObjectMultiword ("thread", "A set of commands for operating on one or more thread within a running process.", "thread <subcommand> [<subcommand-options>]") { - LoadSubCommand (CommandObjectSP (new CommandObjectThreadBacktrace ()), "backtrace", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadContinue ()), "continue", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadList ()), "list", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadSelect ()), "select", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadUntil ()), "until", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-in", - "Source level single step in in specified thread (current thread, if none specified).", - "thread step-in [<thread-id>]", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, - eStepTypeInto, - eStepScopeSource)), - "step-in", interpreter); - - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-out", + LoadSubCommand (interpreter, "backtrace", CommandObjectSP (new CommandObjectThreadBacktrace ())); + LoadSubCommand (interpreter, "continue", CommandObjectSP (new CommandObjectThreadContinue ())); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectThreadList ())); + LoadSubCommand (interpreter, "select", CommandObjectSP (new CommandObjectThreadSelect ())); + LoadSubCommand (interpreter, "until", CommandObjectSP (new CommandObjectThreadUntil ())); + LoadSubCommand (interpreter, "step-in", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + "thread step-in", + "Source level single step in in specified thread (current thread, if none specified).", + "thread step-in [<thread-id>]", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, + eStepTypeInto, + eStepScopeSource))); + + LoadSubCommand (interpreter, "step-out", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-out", "Source level single step out in specified thread (current thread, if none specified).", "thread step-out [<thread-id>]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeOut, - eStepScopeSource)), - "step-out", interpreter); + eStepScopeSource))); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-over", + LoadSubCommand (interpreter, "step-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-over", "Source level single step over in specified thread (current thread, if none specified).", "thread step-over [<thread-id>]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeOver, - eStepScopeSource)), - "step-over", interpreter); + eStepScopeSource))); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst", + LoadSubCommand (interpreter, "step-inst", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst", "Single step one instruction in specified thread (current thread, if none specified).", "thread step-inst [<thread-id>]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeTrace, - eStepScopeInstruction)), - "step-inst", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst-over", + eStepScopeInstruction))); + + LoadSubCommand (interpreter, "step-inst-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst-over", "Single step one instruction in specified thread (current thread, if none specified), stepping over calls.", "thread step-inst-over [<thread-id>]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeTraceOver, - eStepScopeInstruction)), - "step-inst-over", interpreter); + eStepScopeInstruction))); } CommandObjectMultiwordThread::~CommandObjectMultiwordThread () diff --git a/lldb/source/Commands/CommandObjectThread.h b/lldb/source/Commands/CommandObjectThread.h index 21bba714626..1a913eb73ad 100644 --- a/lldb/source/Commands/CommandObjectThread.h +++ b/lldb/source/Commands/CommandObjectThread.h @@ -18,27 +18,11 @@ namespace lldb_private { -class CommandObjectThreadList : public CommandObject -{ -public: - - CommandObjectThreadList (); - - ~CommandObjectThreadList (); - - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); -}; - - class CommandObjectMultiwordThread : public CommandObjectMultiword { public: - CommandObjectMultiwordThread (CommandInterpreter *interpreter); + CommandObjectMultiwordThread (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordThread (); @@ -47,14 +31,14 @@ public: bool -DisplayThreadInfo (CommandInterpreter *interpreter, +DisplayThreadInfo (CommandInterpreter &interpreter, Stream &strm, Thread *thread, bool only_threads_with_stop_reason, bool show_source); size_t -DisplayThreadsInfo (CommandInterpreter *interpreter, +DisplayThreadsInfo (CommandInterpreter &interpreter, ExecutionContext *exe_ctx, CommandReturnObject &result, bool only_threads_with_stop_reason, @@ -62,7 +46,7 @@ DisplayThreadsInfo (CommandInterpreter *interpreter, size_t DisplayFramesForExecutionContext (Thread *thread, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream& strm, bool ascending, uint32_t first_frame, @@ -75,7 +59,7 @@ DisplayFramesForExecutionContext (Thread *thread, bool DisplayFrameForExecutionContext (Thread *thread, StackFrame *frame, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream& strm, bool show_frame_info, bool show_source, diff --git a/lldb/source/Commands/CommandObjectTranslate.cpp b/lldb/source/Commands/CommandObjectTranslate.cpp deleted file mode 100644 index ef899159043..00000000000 --- a/lldb/source/Commands/CommandObjectTranslate.cpp +++ /dev/null @@ -1,75 +0,0 @@ -//===-- CommandObjectTranslate.cpp ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectTranslate.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/Args.h" -#include "lldb/Interpreter/Options.h" - -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectTranslate -//------------------------------------------------------------------------- - -CommandObjectTranslate::CommandObjectTranslate () : - CommandObject ("translate", - "Shows the actual function called for a given debugger command.", - "translate <command>") -{ -} - -CommandObjectTranslate::~CommandObjectTranslate() -{ -} - - -bool -CommandObjectTranslate::Execute -( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result -) -{ - CommandObject *cmd_obj; - - if (command.GetArgumentCount() != 0) - { - cmd_obj = interpreter->GetCommandObject(command.GetArgumentAtIndex(0)); - if (cmd_obj) - { - result.SetStatus (eReturnStatusSuccessFinishNoResult); - result.AppendMessageWithFormat ("%s\n", cmd_obj->Translate()); - } - else - { - result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command.GetArgumentAtIndex(0)); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendError ("must call translate with a valid command"); - result.SetStatus (eReturnStatusFailed); - } - - return result.Succeeded(); -} diff --git a/lldb/source/Commands/CommandObjectTranslate.h b/lldb/source/Commands/CommandObjectTranslate.h deleted file mode 100644 index efc3c8b4092..00000000000 --- a/lldb/source/Commands/CommandObjectTranslate.h +++ /dev/null @@ -1,44 +0,0 @@ -//===-- CommandObjectTranslate.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_CommandObjectTranslate_h_ -#define liblldb_CommandObjectTranslate_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { - -//------------------------------------------------------------------------- -// CommandObjectTranslate -//------------------------------------------------------------------------- - -class CommandObjectTranslate : public CommandObject -{ -public: - - CommandObjectTranslate (); - - virtual - ~CommandObjectTranslate (); - - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectTranslate_h_ diff --git a/lldb/source/Commands/CommandObjectUnalias.cpp b/lldb/source/Commands/CommandObjectUnalias.cpp index 6c2f5085cf8..253414c4305 100644 --- a/lldb/source/Commands/CommandObjectUnalias.cpp +++ b/lldb/source/Commands/CommandObjectUnalias.cpp @@ -25,8 +25,8 @@ using namespace lldb_private; CommandObjectUnalias::CommandObjectUnalias () : CommandObject ("unalias", - "Allows the user to remove/delete a user-defined command abbreviation.", - "unalias <alias-name-to-be-removed>") + "Allows the user to remove/delete a user-defined command abbreviation.", + "unalias <alias-name-to-be-removed>") { } @@ -36,8 +36,12 @@ CommandObjectUnalias::~CommandObjectUnalias() bool -CommandObjectUnalias::Execute (Args& args, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectUnalias::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { CommandObject::CommandMap::iterator pos; CommandObject *cmd_obj; @@ -45,10 +49,10 @@ CommandObjectUnalias::Execute (Args& args, CommandContext *context, CommandInter if (args.GetArgumentCount() != 0) { const char *command_name = args.GetArgumentAtIndex(0); - cmd_obj = interpreter->GetCommandObject(command_name); + cmd_obj = interpreter.GetCommandObject(command_name); if (cmd_obj) { - if (interpreter->CommandExists (command_name)) + if (interpreter.CommandExists (command_name)) { result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be removed.\n", command_name); @@ -57,9 +61,9 @@ CommandObjectUnalias::Execute (Args& args, CommandContext *context, CommandInter else { - if (interpreter->RemoveAlias (command_name) == false) + if (interpreter.RemoveAlias (command_name) == false) { - if (interpreter->AliasExists (command_name)) + 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); diff --git a/lldb/source/Commands/CommandObjectUnalias.h b/lldb/source/Commands/CommandObjectUnalias.h index 5d1cafbcc71..29ce9a408a4 100644 --- a/lldb/source/Commands/CommandObjectUnalias.h +++ b/lldb/source/Commands/CommandObjectUnalias.h @@ -32,9 +32,8 @@ public: ~CommandObjectUnalias (); virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result); }; diff --git a/lldb/source/Commands/CommandObjectVariable.cpp b/lldb/source/Commands/CommandObjectVariable.cpp index 398273461b9..a14fa510d5c 100644 --- a/lldb/source/Commands/CommandObjectVariable.cpp +++ b/lldb/source/Commands/CommandObjectVariable.cpp @@ -465,12 +465,14 @@ public: } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame == NULL) { result.AppendError ("invalid frame"); @@ -492,14 +494,13 @@ public: if (!m_options.globals.empty()) { uint32_t fail_count = 0; - Target *target = context->GetTarget(); - if (target) + if (exe_ctx.target) { const size_t num_globals = m_options.globals.size(); for (idx = 0; idx < num_globals; ++idx) { VariableList global_var_list; - const uint32_t num_matching_globals = target->GetImages().FindGlobalVariables (m_options.globals[idx], true, UINT32_MAX, global_var_list); + const uint32_t num_matching_globals = exe_ctx.target->GetImages().FindGlobalVariables (m_options.globals[idx], true, UINT32_MAX, global_var_list); if (num_matching_globals == 0) { @@ -781,12 +782,12 @@ CommandObjectVariableList::CommandOptions::g_option_table[] = //---------------------------------------------------------------------- // CommandObjectVariable constructor //---------------------------------------------------------------------- -CommandObjectVariable::CommandObjectVariable(CommandInterpreter *interpreter) : +CommandObjectVariable::CommandObjectVariable(CommandInterpreter &interpreter) : CommandObjectMultiword ("variable", - "Access program arguments, locals, static and global variables.", - "variable [list] ...") + "Access program arguments, locals, static and global variables.", + "variable [list] ...") { - LoadSubCommand (CommandObjectSP (new CommandObjectVariableList ()), "list", interpreter); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectVariableList ())); } //---------------------------------------------------------------------- diff --git a/lldb/source/Commands/CommandObjectVariable.h b/lldb/source/Commands/CommandObjectVariable.h index 65869c73d72..c13b4b709fd 100644 --- a/lldb/source/Commands/CommandObjectVariable.h +++ b/lldb/source/Commands/CommandObjectVariable.h @@ -26,7 +26,7 @@ class CommandObjectVariable : public CommandObjectMultiword { public: - CommandObjectVariable (CommandInterpreter *iterpreter); + CommandObjectVariable (CommandInterpreter &interpreter); virtual ~CommandObjectVariable (); diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index c106d838fed..0b7676ca732 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -13,7 +13,7 @@ #include "lldb/Core/InputReader.h" #include "lldb/Core/State.h" #include "lldb/Core/Timer.h" - +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Target/TargetList.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" @@ -22,115 +22,137 @@ using namespace lldb; using namespace lldb_private; -int Debugger::g_shared_debugger_refcount = 0; -bool Debugger::g_in_terminate = false; - -Debugger::DebuggerSP & -Debugger::GetDebuggerSP () -{ - static DebuggerSP g_shared_debugger_sp; - return g_shared_debugger_sp; -} +static uint32_t g_shared_debugger_refcount = 0; void Debugger::Initialize () { - g_shared_debugger_refcount++; - if (GetDebuggerSP().get() == NULL) - { - GetDebuggerSP().reset (new Debugger()); + if (g_shared_debugger_refcount == 0) lldb_private::Initialize(); - GetDebuggerSP()->GetCommandInterpreter().Initialize(); - } + g_shared_debugger_refcount++; } void Debugger::Terminate () { - g_shared_debugger_refcount--; - if (g_shared_debugger_refcount == 0) + if (g_shared_debugger_refcount > 0) { - // Because Terminate is called also in the destructor, we need to make sure - // that none of the calls to GetSharedInstance leads to a call to Initialize, - // thus bumping the refcount back to 1 & causing Debugger::~Debugger to try to - // re-terminate. So we use g_in_terminate to indicate this condition. - // When we can require at least Initialize to be called, we won't have to do - // this since then the GetSharedInstance won't have to auto-call Initialize... - - g_in_terminate = true; - int num_targets = GetDebuggerSP()->GetTargetList().GetNumTargets(); - for (int i = 0; i < num_targets; i++) + g_shared_debugger_refcount--; + if (g_shared_debugger_refcount == 0) { - ProcessSP process_sp(GetDebuggerSP()->GetTargetList().GetTargetAtIndex (i)->GetProcessSP()); - if (process_sp) - process_sp->Destroy(); + lldb_private::WillTerminate(); + lldb_private::Terminate(); } - GetDebuggerSP()->DisconnectInput(); - lldb_private::WillTerminate(); - GetDebuggerSP().reset(); } } -Debugger & -Debugger::GetSharedInstance() +typedef std::vector<DebuggerSP> DebuggerList; + +static Mutex & +GetDebuggerListMutex () +{ + static Mutex g_mutex(Mutex::eMutexTypeRecursive); + return g_mutex; +} + +static DebuggerList & +GetDebuggerList() +{ + // hide the static debugger list inside a singleton accessor to avoid + // global init contructors + static DebuggerList g_list; + return g_list; +} + + +DebuggerSP +Debugger::CreateInstance () +{ + DebuggerSP debugger_sp (new Debugger); + // Scope for locker + { + Mutex::Locker locker (GetDebuggerListMutex ()); + GetDebuggerList().push_back(debugger_sp); + } + return debugger_sp; +} + +lldb::DebuggerSP +Debugger::GetSP () { - // Don't worry about thread race conditions with the code below as - // lldb_private::Initialize(); does this in a thread safe way. I just - // want to avoid having to lock and unlock a mutex in - // lldb_private::Initialize(); every time we want to access the - // Debugger shared instance. + lldb::DebuggerSP debugger_sp; - // FIXME: We intend to require clients to call Initialize by hand (since they - // will also have to call Terminate by hand.) But for now it is not clear where - // we can reliably call these in JH. So the present version initializes on first use - // here, and terminates in the destructor. - if (g_shared_debugger_refcount == 0 && !g_in_terminate) - Initialize(); - - assert(GetDebuggerSP().get()!= NULL); - return *(GetDebuggerSP().get()); + Mutex::Locker locker (GetDebuggerListMutex ()); + DebuggerList &debugger_list = GetDebuggerList(); + DebuggerList::iterator pos, end = debugger_list.end(); + for (pos = debugger_list.begin(); pos != end; ++pos) + { + if ((*pos).get() == this) + { + debugger_sp = *pos; + break; + } + } + return debugger_sp; } + +TargetSP +Debugger::FindTargetWithProcessID (lldb::pid_t pid) +{ + lldb::TargetSP target_sp; + Mutex::Locker locker (GetDebuggerListMutex ()); + DebuggerList &debugger_list = GetDebuggerList(); + DebuggerList::iterator pos, end = debugger_list.end(); + for (pos = debugger_list.begin(); pos != end; ++pos) + { + target_sp = (*pos)->GetTargetList().FindTargetWithProcessID (pid); + if (target_sp) + break; + } + return target_sp; +} + + Debugger::Debugger () : m_input_comm("debugger.input"), m_input_file (), m_output_file (), m_error_file (), - m_async_execution (true), m_target_list (), m_listener ("lldb.Debugger"), m_source_manager (), - m_command_interpreter (eScriptLanguageDefault, false, &m_listener, m_source_manager), + m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)), + m_exe_ctx (), m_input_readers (), m_input_reader_data () { + m_command_interpreter_ap->Initialize (); } Debugger::~Debugger () { - // FIXME: - // Remove this once this version of lldb has made its way through a build. - Terminate(); + int num_targets = m_target_list.GetNumTargets(); + for (int i = 0; i < num_targets; i++) + { + ProcessSP process_sp (m_target_list.GetTargetAtIndex (i)->GetProcessSP()); + if (process_sp) + process_sp->Destroy(); + } + DisconnectInput(); } bool Debugger::GetAsyncExecution () { - return m_async_execution; + return !m_command_interpreter_ap->GetSynchronous(); } void Debugger::SetAsyncExecution (bool async_execution) { - static bool value_has_been_set = false; - - if (!value_has_been_set) - { - value_has_been_set = true; - m_async_execution = async_execution; - m_command_interpreter.SetSynchronous (!async_execution); - } + m_command_interpreter_ap->SetSynchronous (!async_execution); } void @@ -203,7 +225,8 @@ Debugger::GetErrorFileHandle () CommandInterpreter & Debugger::GetCommandInterpreter () { - return m_command_interpreter; + assert (m_command_interpreter_ap.get()); + return *m_command_interpreter_ap; } Listener & @@ -432,3 +455,39 @@ Debugger::ActivateInputReader (const InputReaderSP &reader_sp) } } } + +void +Debugger::UpdateExecutionContext (ExecutionContext *override_context) +{ + m_exe_ctx.Clear(); + + if (override_context != NULL) + { + m_exe_ctx.target = override_context->target; + m_exe_ctx.process = override_context->process; + m_exe_ctx.thread = override_context->thread; + m_exe_ctx.frame = override_context->frame; + } + else + { + TargetSP target_sp (GetCurrentTarget()); + if (target_sp) + { + m_exe_ctx.target = target_sp.get(); + m_exe_ctx.process = target_sp->GetProcessSP().get(); + if (m_exe_ctx.process && m_exe_ctx.process->IsRunning() == false) + { + m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetCurrentThread().get(); + if (m_exe_ctx.thread == NULL) + m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); + if (m_exe_ctx.thread) + { + m_exe_ctx.frame = m_exe_ctx.thread->GetCurrentFrame().get(); + if (m_exe_ctx.frame == NULL) + m_exe_ctx.frame = m_exe_ctx.thread->GetStackFrameAtIndex (0).get(); + } + } + } + } +} + diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp index 570ff726225..9cdf618c087 100644 --- a/lldb/source/Core/Disassembler.cpp +++ b/lldb/source/Core/Disassembler.cpp @@ -55,6 +55,7 @@ Disassembler::FindPlugin (const ArchSpec &arch) bool Disassembler::Disassemble ( + Debugger &debugger, const ArchSpec &arch, const ExecutionContext &exe_ctx, uint32_t mixed_context_lines, @@ -144,7 +145,7 @@ Disassembler::Disassemble if (sc.comp_unit && sc.line_entry.IsValid()) { - Debugger::GetSharedInstance().GetSourceManager().DisplaySourceLinesWithLineNumbers ( + debugger.GetSourceManager().DisplaySourceLinesWithLineNumbers ( sc.line_entry.file, sc.line_entry.line, mixed_context_lines, diff --git a/lldb/source/Core/InputReader.cpp b/lldb/source/Core/InputReader.cpp index c139a87387a..afda9fa25f6 100644 --- a/lldb/source/Core/InputReader.cpp +++ b/lldb/source/Core/InputReader.cpp @@ -15,7 +15,8 @@ using namespace lldb; using namespace lldb_private; -InputReader::InputReader () : +InputReader::InputReader (Debugger &debugger) : + m_debugger (debugger), m_callback (NULL), m_callback_baton (NULL), m_end_token (), @@ -126,7 +127,7 @@ InputReader::HandleRawBytes (const char *bytes, size_t bytes_len) break; } - if (m_callback (m_callback_baton, this, eInputReaderGotToken, p, 1) == 0) + if (m_callback (m_callback_baton, *this, eInputReaderGotToken, p, 1) == 0) break; ++p; if (IsDone()) @@ -175,7 +176,7 @@ InputReader::HandleRawBytes (const char *bytes, size_t bytes_len) { const size_t word_len = p - word_start; size_t bytes_handled = m_callback (m_callback_baton, - this, + *this, eInputReaderGotToken, word_start, word_len); @@ -212,7 +213,7 @@ InputReader::HandleRawBytes (const char *bytes, size_t bytes_len) { SetIsDone(true); m_callback (m_callback_baton, - this, + *this, eInputReaderGotToken, line_start, end_token - line_start); @@ -221,7 +222,7 @@ InputReader::HandleRawBytes (const char *bytes, size_t bytes_len) } size_t bytes_handled = m_callback (m_callback_baton, - this, + *this, eInputReaderGotToken, line_start, line_length); @@ -259,7 +260,7 @@ InputReader::HandleRawBytes (const char *bytes, size_t bytes_len) { size_t length = end_token - bytes; size_t bytes_handled = m_callback (m_callback_baton, - this, + *this, eInputReaderGotToken, bytes, length); @@ -287,19 +288,6 @@ InputReader::HandleRawBytes (const char *bytes, size_t bytes_len) return 0; } - -FILE * -InputReader::GetInputFileHandle () -{ - return Debugger::GetSharedInstance().GetInputFileHandle (); -} - -FILE * -InputReader::GetOutputFileHandle () -{ - return Debugger::GetSharedInstance().GetOutputFileHandle (); -} - const char * InputReader::GetPrompt () const { @@ -314,7 +302,7 @@ InputReader::RefreshPrompt () { if (!m_prompt.empty()) { - FILE *out_fh = GetOutputFileHandle(); + FILE *out_fh = m_debugger.GetOutputFileHandle(); if (out_fh) ::fprintf (out_fh, "%s", m_prompt.c_str()); } @@ -339,5 +327,5 @@ InputReader::Notify (InputReaderAction notification) return; // We don't notify the tokens here, it is done in HandleRawBytes } if (m_callback) - m_callback (m_callback_baton, this, notification, NULL, 0); + m_callback (m_callback_baton, *this, notification, NULL, 0); } diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp index 217f6c40297..1be3c525ae0 100644 --- a/lldb/source/Core/Log.cpp +++ b/lldb/source/Core/Log.cpp @@ -43,18 +43,8 @@ StreamForSTDOUTAccess (bool set, StreamSP &stream_sp) if (set) g_stream_sp = stream_sp; else - { - if (g_stream_sp) - stream_sp = g_stream_sp; - else - { - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - if (out_fh) - stream_sp.reset(new StreamFile(out_fh)); - else - stream_sp.reset(); - } - } + stream_sp = g_stream_sp; + return stream_sp.get(); } @@ -91,7 +81,7 @@ StreamForSTDERRAccess (bool set, StreamSP &stream_sp) // Since we are in a shared library and we can't have global // constructors, we need to control access to this static variable // through an accessor function to get and set the value. - static StreamSP g_stream_sp(new StreamFile(Debugger::GetSharedInstance().GetErrorFileHandle())); + static StreamSP g_stream_sp; if (set) g_stream_sp = stream_sp; diff --git a/lldb/source/Interpreter/CommandContext.cpp b/lldb/source/Interpreter/CommandContext.cpp deleted file mode 100644 index 012611c5262..00000000000 --- a/lldb/source/Interpreter/CommandContext.cpp +++ /dev/null @@ -1,77 +0,0 @@ -//===-- CommandContext.cpp --------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Interpreter/CommandContext.h" - -#include "lldb/Core/Debugger.h" -#include "lldb/Core/StreamString.h" -#include "lldb/Interpreter/CommandObject.h" -#include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/Thread.h" - -using namespace lldb; -using namespace lldb_private; - -CommandContext::CommandContext () : - m_exe_ctx () -{ -} - -CommandContext::~CommandContext () -{ -} - -Target * -CommandContext::GetTarget() -{ - return Debugger::GetSharedInstance().GetCurrentTarget().get(); -} - - -ExecutionContext & -CommandContext::GetExecutionContext() -{ - return m_exe_ctx; -} - -void -CommandContext::Update (ExecutionContext *override_context) -{ - m_exe_ctx.Clear(); - - if (override_context != NULL) - { - m_exe_ctx.target = override_context->target; - m_exe_ctx.process = override_context->process; - m_exe_ctx.thread = override_context->thread; - m_exe_ctx.frame = override_context->frame; - } - else - { - TargetSP target_sp (Debugger::GetSharedInstance().GetCurrentTarget()); - if (target_sp) - { - m_exe_ctx.process = target_sp->GetProcessSP().get(); - if (m_exe_ctx.process && m_exe_ctx.process->IsRunning() == false) - { - m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetCurrentThread().get(); - if (m_exe_ctx.thread == NULL) - m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); - if (m_exe_ctx.thread) - { - m_exe_ctx.frame = m_exe_ctx.thread->GetCurrentFrame().get(); - if (m_exe_ctx.frame == NULL) - m_exe_ctx.frame = m_exe_ctx.thread->GetStackFrameAtIndex (0).get(); - } - } - } - } -} diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 2c278b1f13f..984711de193 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -12,7 +12,6 @@ #include <getopt.h> #include <stdlib.h> -#include "../Commands/CommandObjectAdd.h" #include "../Commands/CommandObjectAlias.h" #include "../Commands/CommandObjectAppend.h" #include "../Commands/CommandObjectApropos.h" @@ -33,7 +32,6 @@ #include "../Commands/CommandObjectQuit.h" #include "lldb/Interpreter/CommandObjectRegexCommand.h" #include "../Commands/CommandObjectRegister.h" -#include "../Commands/CommandObjectRemove.h" #include "CommandObjectScript.h" #include "../Commands/CommandObjectSelect.h" #include "../Commands/CommandObjectSet.h" @@ -44,7 +42,6 @@ #include "../Commands/CommandObjectSyntax.h" #include "../Commands/CommandObjectTarget.h" #include "../Commands/CommandObjectThread.h" -#include "../Commands/CommandObjectTranslate.h" #include "../Commands/CommandObjectUnalias.h" #include "../Commands/CommandObjectVariable.h" @@ -64,16 +61,14 @@ using namespace lldb_private; CommandInterpreter::CommandInterpreter ( + Debugger &debugger, ScriptLanguage script_language, - bool synchronous_execution, - Listener *listener, - SourceManager& source_manager + bool synchronous_execution ) : Broadcaster ("CommandInterpreter"), + m_debugger (debugger), m_script_language (script_language), - m_synchronous_execution (synchronous_execution), - m_listener (listener), - m_source_manager (source_manager) + m_synchronous_execution (synchronous_execution) { } @@ -204,43 +199,38 @@ CommandInterpreter::LoadCommandDictionary () // the crossref object exists and is ready to take the cross reference. Put the cross referencing command // objects into the CommandDictionary now, so they are ready for use when the other commands get created. - m_command_dict["select"] = CommandObjectSP (new CommandObjectSelect ()); - m_command_dict["info"] = CommandObjectSP (new CommandObjectInfo ()); - m_command_dict["delete"] = CommandObjectSP (new CommandObjectDelete ()); + m_command_dict["select"] = CommandObjectSP (new CommandObjectSelect ()); + m_command_dict["info"] = CommandObjectSP (new CommandObjectInfo ()); + m_command_dict["delete"] = CommandObjectSP (new CommandObjectDelete ()); // Non-CommandObjectCrossref commands can now be created. - //m_command_dict["add"] = CommandObjectSP (new CommandObjectAdd ()); m_command_dict["alias"] = CommandObjectSP (new CommandObjectAlias ()); m_command_dict["append"] = CommandObjectSP (new CommandObjectAppend ()); m_command_dict["apropos"] = CommandObjectSP (new CommandObjectApropos ()); - //m_command_dict["args"] = CommandObjectSP (new CommandObjectArgs ()); - m_command_dict["breakpoint"]= CommandObjectSP (new CommandObjectMultiwordBreakpoint (this)); + m_command_dict["breakpoint"]= CommandObjectSP (new CommandObjectMultiwordBreakpoint (*this)); m_command_dict["call"] = CommandObjectSP (new CommandObjectCall ()); m_command_dict["disassemble"] = CommandObjectSP (new CommandObjectDisassemble ()); m_command_dict["expression"]= CommandObjectSP (new CommandObjectExpression ()); m_command_dict["file"] = CommandObjectSP (new CommandObjectFile ()); - m_command_dict["frame"] = CommandObjectSP (new CommandObjectMultiwordFrame (this)); + m_command_dict["frame"] = CommandObjectSP (new CommandObjectMultiwordFrame (*this)); m_command_dict["help"] = CommandObjectSP (new CommandObjectHelp ()); - m_command_dict["image"] = CommandObjectSP (new CommandObjectImage (this)); - m_command_dict["log"] = CommandObjectSP (new CommandObjectLog (this)); - m_command_dict["memory"] = CommandObjectSP (new CommandObjectMemory (this)); - m_command_dict["process"] = CommandObjectSP (new CommandObjectMultiwordProcess (this)); + m_command_dict["image"] = CommandObjectSP (new CommandObjectImage (*this)); + m_command_dict["log"] = CommandObjectSP (new CommandObjectLog (*this)); + m_command_dict["memory"] = CommandObjectSP (new CommandObjectMemory (*this)); + m_command_dict["process"] = CommandObjectSP (new CommandObjectMultiwordProcess (*this)); m_command_dict["quit"] = CommandObjectSP (new CommandObjectQuit ()); - m_command_dict["register"] = CommandObjectSP (new CommandObjectRegister (this)); - //m_command_dict["remove"] = CommandObjectSP (new CommandObjectRemove ()); + m_command_dict["register"] = CommandObjectSP (new CommandObjectRegister (*this)); m_command_dict["script"] = CommandObjectSP (new CommandObjectScript (m_script_language)); 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["syntax"] = CommandObjectSP (new CommandObjectSyntax ()); - m_command_dict["target"] = CommandObjectSP (new CommandObjectMultiwordTarget (this)); - m_command_dict["thread"] = CommandObjectSP (new CommandObjectMultiwordThread (this)); - //m_command_dict["translate"] = CommandObjectSP (new CommandObjectTranslate ()); + 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)); + m_command_dict["variable"] = CommandObjectSP (new CommandObjectVariable (*this)); std::auto_ptr<CommandObjectRegexCommand> break_regex_cmd_ap(new CommandObjectRegexCommand ("regexp-break", @@ -568,8 +558,13 @@ CommandInterpreter::ShowVariableHelp (CommandReturnObject &result) // parses the line and takes the appropriate actions. bool -CommandInterpreter::HandleCommand (const char *command_line, bool add_to_history, CommandReturnObject &result, - ExecutionContext *override_context) +CommandInterpreter::HandleCommand +( + const char *command_line, + bool add_to_history, + CommandReturnObject &result, + ExecutionContext *override_context +) { // FIXME: there should probably be a mutex to make sure only one thread can // run the interpreter at a time. @@ -580,7 +575,7 @@ CommandInterpreter::HandleCommand (const char *command_line, bool add_to_history // result.AppendMessageWithFormat ("Processing command: %s\n", command_line); // } - m_current_context.Update (override_context); + m_debugger.UpdateExecutionContext (override_context); if (command_line == NULL || command_line[0] == '\0') { @@ -639,7 +634,7 @@ CommandInterpreter::HandleCommand (const char *command_line, bool add_to_history stripped_command += strlen(command_cstr); while (isspace(*stripped_command)) ++stripped_command; - command_obj->ExecuteRawCommandString(stripped_command, Context(), this, result); + command_obj->ExecuteRawCommandString (*this, stripped_command, result); } } else @@ -649,7 +644,7 @@ CommandInterpreter::HandleCommand (const char *command_line, bool add_to_history // Remove the command from the args. command_args.Shift(); - command_obj->ExecuteWithOptions (command_args, Context(), this, result); + command_obj->ExecuteWithOptions (*this, command_args, result); } } else @@ -658,9 +653,12 @@ CommandInterpreter::HandleCommand (const char *command_line, bool add_to_history int num_matches; int cursor_index = command_args.GetArgumentCount() - 1; int cursor_char_position = strlen (command_args.GetArgumentAtIndex(command_args.GetArgumentCount() - 1)); - num_matches = HandleCompletionMatches (command_args, cursor_index, - cursor_char_position, - 0, -1, matches); + num_matches = HandleCompletionMatches (command_args, + cursor_index, + cursor_char_position, + 0, + -1, + matches); if (num_matches > 0) { @@ -740,8 +738,12 @@ CommandInterpreter::HandleCompletionMatches (Args &parsed_line, { parsed_line.Shift(); cursor_index--; - num_command_matches = command_object->HandleCompletion (parsed_line, cursor_index, cursor_char_position, - match_start_point, max_return_elements, this, + num_command_matches = command_object->HandleCompletion (*this, + parsed_line, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, matches); } } @@ -779,8 +781,12 @@ CommandInterpreter::HandleCompletion (const char *current_line, // Only max_return_elements == -1 is supported at present: assert (max_return_elements == -1); - num_command_matches = HandleCompletionMatches (parsed_line, cursor_index, cursor_char_position, match_start_point, - max_return_elements, matches); + num_command_matches = HandleCompletionMatches (parsed_line, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + matches); if (num_command_matches <= 0) return num_command_matches; @@ -817,12 +823,6 @@ CommandInterpreter::HandleCompletion (const char *current_line, return num_command_matches; } -CommandContext * -CommandInterpreter::Context () -{ - return &m_current_context; -} - const Args * CommandInterpreter::GetProgramArguments () { @@ -916,20 +916,6 @@ CommandInterpreter::SetScriptLanguage (ScriptLanguage lang) m_script_language = lang; } -Listener * -CommandInterpreter::GetListener () -{ - return m_listener; -} - -SourceManager & -CommandInterpreter::GetSourceManager () -{ - return m_source_manager; -} - - - OptionArgVectorSP CommandInterpreter::GetAliasOptions (const char *alias_name) { @@ -1132,16 +1118,15 @@ CommandInterpreter::SourceInitFile (bool in_cwd, CommandReturnObject &result) ScriptInterpreter * CommandInterpreter::GetScriptInterpreter () { - CommandObject::CommandMap::iterator pos; - - pos = m_command_dict.find ("script"); - if (pos != m_command_dict.end()) + CommandObject::CommandMap::iterator pos; + + pos = m_command_dict.find ("script"); + if (pos != m_command_dict.end()) { - CommandObject *script_cmd_obj = pos->second.get(); - return ((CommandObjectScript *) script_cmd_obj)->GetInterpreter (); + CommandObject *script_cmd_obj = pos->second.get(); + return ((CommandObjectScript *) script_cmd_obj)->GetInterpreter (*this); } - else - return NULL; + return NULL; } diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index eb8cdd2260d..384c03acfa2 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -133,21 +133,20 @@ CommandObject::GetFlags() const bool CommandObject::ExecuteCommandString ( + CommandInterpreter &interpreter, const char *command_line, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { Args command_args(command_line); - return ExecuteWithOptions (command_args, context, interpreter, result); + return ExecuteWithOptions (interpreter, command_args, result); } bool CommandObject::ParseOptions ( + CommandInterpreter &interpreter, Args& args, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -189,9 +188,8 @@ CommandObject::ParseOptions bool CommandObject::ExecuteWithOptions ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -199,10 +197,10 @@ CommandObject::ExecuteWithOptions { const char *tmp_str = args.GetArgumentAtIndex (i); if (tmp_str[0] == '`') // back-quote - args.ReplaceArgumentAtIndex (i, interpreter->ProcessEmbeddedScriptCommands (tmp_str)); + args.ReplaceArgumentAtIndex (i, interpreter.ProcessEmbeddedScriptCommands (tmp_str)); } - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { if (GetFlags().IsSet(CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused)) @@ -248,11 +246,11 @@ CommandObject::ExecuteWithOptions } } - if (!ParseOptions (args, interpreter, result)) + if (!ParseOptions (interpreter, args, result)) return false; // Call the command-specific version of 'Execute', passing it the already processed arguments. - return Execute (args, context, interpreter, result); + return Execute (interpreter, args, result); } class CommandDictCommandPartialMatch @@ -300,12 +298,12 @@ CommandObject::AddNamesMatchingPartialString (CommandObject::CommandMap &in_map, int CommandObject::HandleCompletion ( + CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) { @@ -340,46 +338,30 @@ CommandObject::HandleCompletion input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1); bool handled_by_options; - handled_by_options = cur_options->HandleOptionCompletion(input, - opt_element_vector, - cursor_index, - cursor_char_position, - match_start_point, - max_return_elements, - interpreter, - matches); + handled_by_options = cur_options->HandleOptionCompletion (interpreter, + input, + opt_element_vector, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + matches); if (handled_by_options) return matches.GetSize(); } // If we got here, the last word is not an option or an option argument. - return HandleArgumentCompletion(input, - cursor_index, - cursor_char_position, - opt_element_vector, - match_start_point, - max_return_elements, - interpreter, - matches); + return HandleArgumentCompletion (interpreter, + input, + cursor_index, + cursor_char_position, + opt_element_vector, + match_start_point, + max_return_elements, + matches); } } -int -CommandObject::HandleArgumentCompletion -( - Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches -) -{ - return 0; -} - // Case insensitive version of ::strstr() // Returns true if s2 is contained within s1. diff --git a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp index b3fa6a41d97..e165fc8009a 100644 --- a/lldb/source/Interpreter/CommandObjectRegexCommand.cpp +++ b/lldb/source/Interpreter/CommandObjectRegexCommand.cpp @@ -46,9 +46,8 @@ CommandObjectRegexCommand::~CommandObjectRegexCommand() bool CommandObjectRegexCommand::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -59,9 +58,8 @@ CommandObjectRegexCommand::Execute bool CommandObjectRegexCommand::ExecuteRawCommandString ( + CommandInterpreter &interpreter, const char *command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -92,7 +90,7 @@ CommandObjectRegexCommand::ExecuteRawCommandString // Interpret the new command and return this as the result! // if (m_options.verbose) // result.GetOutputStream().Printf("%s\n", new_command.c_str()); - return interpreter->HandleCommand(new_command.c_str(), true, result); + return interpreter.HandleCommand(new_command.c_str(), true, result); } } result.SetStatus(eReturnStatusFailed); diff --git a/lldb/source/Interpreter/CommandObjectScript.cpp b/lldb/source/Interpreter/CommandObjectScript.cpp index 2cbca117bfc..3a7362de075 100644 --- a/lldb/source/Interpreter/CommandObjectScript.cpp +++ b/lldb/source/Interpreter/CommandObjectScript.cpp @@ -43,15 +43,12 @@ CommandObjectScript::~CommandObjectScript () bool CommandObjectScript::ExecuteRawCommandString ( + CommandInterpreter &interpreter, const char *command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - std::string arg_str (command); - - ScriptInterpreter *script_interpreter = GetInterpreter (); + ScriptInterpreter *script_interpreter = GetInterpreter (interpreter); if (script_interpreter == NULL) { @@ -59,23 +56,11 @@ CommandObjectScript::ExecuteRawCommandString result.SetStatus (eReturnStatusFailed); } - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - FILE *err_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - if (out_fh && err_fh) - { - if (arg_str.empty()) - script_interpreter->ExecuteInterpreterLoop (out_fh, err_fh); - else - script_interpreter->ExecuteOneLine (arg_str, out_fh, err_fh); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } + if (command == NULL || command[0] == '\0') + script_interpreter->ExecuteInterpreterLoop (interpreter); else - { - if (out_fh == NULL) - result.AppendError("invalid output file handle"); - else - result.AppendError("invalid error file handle"); - } + script_interpreter->ExecuteOneLine (interpreter, command); + result.SetStatus (eReturnStatusSuccessFinishNoResult); return result.Succeeded(); } @@ -88,60 +73,29 @@ CommandObjectScript::WantsRawCommandString() bool CommandObjectScript::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - std::string arg_str; - ScriptInterpreter *script_interpreter = GetInterpreter (); - - if (script_interpreter == NULL) - { - result.AppendError("no script interpeter"); - result.SetStatus (eReturnStatusFailed); - } - - const int argc = command.GetArgumentCount(); - for (int i = 0; i < argc; ++i) - arg_str.append(command.GetArgumentAtIndex(i)); - - - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - FILE *err_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - if (out_fh && err_fh) - { - if (arg_str.empty()) - script_interpreter->ExecuteInterpreterLoop (out_fh, err_fh); - else - script_interpreter->ExecuteOneLine (arg_str, out_fh, err_fh); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - if (out_fh == NULL) - result.AppendError("invalid output file handle"); - else - result.AppendError("invalid error file handle"); - } - return result.Succeeded(); + // everything should be handled in ExecuteRawCommandString + return false; } ScriptInterpreter * -CommandObjectScript::GetInterpreter () +CommandObjectScript::GetInterpreter (CommandInterpreter &interpreter) { if (m_interpreter_ap.get() == NULL) { switch (m_script_lang) { case eScriptLanguagePython: - m_interpreter_ap.reset (new ScriptInterpreterPython ()); + m_interpreter_ap.reset (new ScriptInterpreterPython (interpreter)); break; case eScriptLanguageNone: - m_interpreter_ap.reset (new ScriptInterpreterNone ()); + m_interpreter_ap.reset (new ScriptInterpreterNone (interpreter)); break; } } diff --git a/lldb/source/Interpreter/CommandObjectScript.h b/lldb/source/Interpreter/CommandObjectScript.h index 7cd57518ff7..d74f7b156fd 100644 --- a/lldb/source/Interpreter/CommandObjectScript.h +++ b/lldb/source/Interpreter/CommandObjectScript.h @@ -34,19 +34,17 @@ public: bool WantsRawCommandString(); virtual bool - ExecuteRawCommandString (const char *command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); + ExecuteRawCommandString (CommandInterpreter &interpreter, + const char *command, + CommandReturnObject &result); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); ScriptInterpreter * - GetInterpreter (); + GetInterpreter (CommandInterpreter &interpreter); private: lldb::ScriptLanguage m_script_lang; diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp index 1f42e2a417b..9baa9d26d43 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -532,13 +532,13 @@ Options::VerifyPartialOptions (CommandReturnObject &result) bool Options::HandleOptionCompletion ( + CommandInterpreter &interpreter, Args &input, OptionElementVector &opt_element_vector, int cursor_index, int char_pos, int match_start_point, int max_return_elements, - lldb_private::CommandInterpreter *interpreter, lldb_private::StringList &matches ) { @@ -625,15 +625,15 @@ Options::HandleOptionCompletion if (opt_defs_index != -1) { - HandleOptionArgumentCompletion (input, - cursor_index, - strlen (input.GetArgumentAtIndex(cursor_index)), - opt_element_vector, - i, - match_start_point, - max_return_elements, - interpreter, - matches); + HandleOptionArgumentCompletion (interpreter, + input, + cursor_index, + strlen (input.GetArgumentAtIndex(cursor_index)), + opt_element_vector, + i, + match_start_point, + max_return_elements, + matches); return true; } else @@ -655,6 +655,7 @@ Options::HandleOptionCompletion bool Options::HandleOptionArgumentCompletion ( + CommandInterpreter &interpreter, Args &input, int cursor_index, int char_pos, @@ -662,7 +663,6 @@ Options::HandleOptionArgumentCompletion int opt_element_index, int match_start_point, int max_return_elements, - lldb_private::CommandInterpreter *interpreter, lldb_private::StringList &matches ) { @@ -713,7 +713,7 @@ Options::HandleOptionArgumentCompletion if (module_name) { FileSpec module_spec(module_name); - lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP(); + lldb::TargetSP target_sp = interpreter.GetDebugger().GetCurrentTarget(); // Search filters require a target... if (target_sp != NULL) filter_ap.reset (new SearchFilterByModule (target_sp, module_spec)); @@ -723,12 +723,12 @@ Options::HandleOptionArgumentCompletion } } - return CommandCompletions::InvokeCommonCompletionCallbacks (completion_mask, - input.GetArgumentAtIndex (opt_arg_pos), - match_start_point, - max_return_elements, - interpreter, - filter_ap.get(), - matches); - + return CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + completion_mask, + input.GetArgumentAtIndex (opt_arg_pos), + match_start_point, + max_return_elements, + filter_ap.get(), + matches); + } diff --git a/lldb/source/Interpreter/ScriptInterpreterNone.cpp b/lldb/source/Interpreter/ScriptInterpreterNone.cpp index cdc399e7d86..c9bd2827fc9 100644 --- a/lldb/source/Interpreter/ScriptInterpreterNone.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterNone.cpp @@ -10,11 +10,13 @@ #include "lldb/Interpreter/ScriptInterpreterNone.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StringList.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/CommandInterpreter.h" using namespace lldb; using namespace lldb_private; -ScriptInterpreterNone::ScriptInterpreterNone () : +ScriptInterpreterNone::ScriptInterpreterNone (CommandInterpreter &interpreter) : ScriptInterpreter (eScriptLanguageNone) { } @@ -24,15 +26,15 @@ ScriptInterpreterNone::~ScriptInterpreterNone () } void -ScriptInterpreterNone::ExecuteOneLine (const std::string &line, FILE *out, FILE *err) +ScriptInterpreterNone::ExecuteOneLine (CommandInterpreter &interpreter, const char *command) { - ::fprintf (err, "error: there is no embedded script interpreter in this mode.\n"); + interpreter.GetDebugger().GetErrorStream().PutCString ("error: there is no embedded script interpreter in this mode.\n"); } void -ScriptInterpreterNone::ExecuteInterpreterLoop (FILE *out, FILE *err) +ScriptInterpreterNone::ExecuteInterpreterLoop (CommandInterpreter &interpreter) { - fprintf (err, "error: there is no embedded script interpreter in this mode.\n"); + interpreter.GetDebugger().GetErrorStream().PutCString ("error: there is no embedded script interpreter in this mode.\n"); } diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp index 59eb4642298..5fb0130f354 100644 --- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp +++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp @@ -24,6 +24,7 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" +#include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/FileSpec.h" #include "lldb/Core/InputReader.h" @@ -33,6 +34,7 @@ #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Core/Debugger.h" #include "lldb/Target/Process.h" extern "C" void init_lldb (void); @@ -139,7 +141,7 @@ _check_and_flush (FILE *stream) return fflush (stream) || prev_fail ? EOF : 0; } -ScriptInterpreterPython::ScriptInterpreterPython () : +ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interpreter) : ScriptInterpreter (eScriptLanguagePython), m_compiled_module (NULL), m_termios_valid (false) @@ -194,7 +196,7 @@ ScriptInterpreterPython::ScriptInterpreterPython () : } const char *pty_slave_name = GetScriptInterpreterPtyName (); - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); + FILE *out_fh = interpreter.GetDebugger().GetOutputFileHandle(); PyObject *pmod = PyImport_ExecCodeModule( const_cast<char*>("embedded_interpreter"), @@ -249,14 +251,15 @@ ScriptInterpreterPython::~ScriptInterpreterPython () } void -ScriptInterpreterPython::ExecuteOneLine (const std::string& line, FILE *out, FILE *err) +ScriptInterpreterPython::ExecuteOneLine (CommandInterpreter &interpreter, const char *command) { - int success; - - success = PyRun_SimpleString (line.c_str()); - if (success != 0) + if (command) { - fprintf (err, "error: python failed attempting to evaluate '%s'\n", line.c_str()); + int success; + + success = PyRun_SimpleString (command); + if (success != 0) + interpreter.GetDebugger().GetErrorStream().Printf ("error: python failed attempting to evaluate '%s'\n", command); } } @@ -266,7 +269,7 @@ size_t ScriptInterpreterPython::InputReaderCallback ( void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len @@ -275,19 +278,20 @@ ScriptInterpreterPython::InputReaderCallback if (baton == NULL) return 0; - ScriptInterpreterPython *interpreter = (ScriptInterpreterPython *) baton; + ScriptInterpreterPython *script_interpreter = (ScriptInterpreterPython *) baton; switch (notification) { case eInputReaderActivate: { // Save terminal settings if we can - interpreter->m_termios_valid = ::tcgetattr (::fileno (reader->GetInputFileHandle()), - &interpreter->m_termios) == 0; + FILE *input_fh = reader.GetDebugger().GetInputFileHandle(); + int input_fd = ::fileno (input_fh); + script_interpreter->m_termios_valid = ::tcgetattr (input_fd, &script_interpreter->m_termios) == 0; struct termios tmp_termios; - if (::tcgetattr (::fileno (reader->GetInputFileHandle()), &tmp_termios) == 0) + if (::tcgetattr (input_fd, &tmp_termios) == 0) { tmp_termios.c_cc[VEOF] = _POSIX_VDISABLE; - ::tcsetattr (::fileno (reader->GetInputFileHandle()), TCSANOW, &tmp_termios); + ::tcsetattr (input_fd, TCSANOW, &tmp_termios); } } break; @@ -302,11 +306,11 @@ ScriptInterpreterPython::InputReaderCallback if (bytes && bytes_len) { if ((int) bytes[0] == 4) - ::write (interpreter->GetMasterFileDescriptor(), "quit()", 6); + ::write (script_interpreter->GetMasterFileDescriptor(), "quit()", 6); else - ::write (interpreter->GetMasterFileDescriptor(), bytes, bytes_len); + ::write (script_interpreter->GetMasterFileDescriptor(), bytes, bytes_len); } - ::write (interpreter->GetMasterFileDescriptor(), "\n", 1); + ::write (script_interpreter->GetMasterFileDescriptor(), "\n", 1); break; case eInputReaderDone: @@ -315,11 +319,11 @@ ScriptInterpreterPython::InputReaderCallback // Write a newline out to the reader output //::fwrite ("\n", 1, 1, out_fh); // Restore terminal settings if they were validly saved - if (interpreter->m_termios_valid) + if (script_interpreter->m_termios_valid) { - ::tcsetattr (::fileno (reader->GetInputFileHandle()), + ::tcsetattr (::fileno (reader.GetDebugger().GetInputFileHandle()), TCSANOW, - &interpreter->m_termios); + &script_interpreter->m_termios); } break; } @@ -329,11 +333,12 @@ ScriptInterpreterPython::InputReaderCallback void -ScriptInterpreterPython::ExecuteInterpreterLoop (FILE *out, FILE *err) +ScriptInterpreterPython::ExecuteInterpreterLoop (CommandInterpreter &interpreter) { Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); - InputReaderSP reader_sp (new InputReader()); + Debugger &debugger = interpreter.GetDebugger(); + InputReaderSP reader_sp (new InputReader(debugger)); if (reader_sp) { Error error (reader_sp->Initialize (ScriptInterpreterPython::InputReaderCallback, @@ -345,9 +350,9 @@ ScriptInterpreterPython::ExecuteInterpreterLoop (FILE *out, FILE *err) if (error.Success()) { - Debugger::GetSharedInstance().PushInputReader (reader_sp); - ExecuteOneLine ("run_python_interpreter(ConsoleDict)", out, err); - Debugger::GetSharedInstance().PopInputReader (reader_sp); + debugger.PushInputReader (reader_sp); + ExecuteOneLine (interpreter, "run_python_interpreter(ConsoleDict)"); + debugger.PopInputReader (reader_sp); } } } @@ -528,7 +533,7 @@ size_t ScriptInterpreterPython::GenerateBreakpointOptionsCommandCallback ( void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len @@ -536,7 +541,7 @@ ScriptInterpreterPython::GenerateBreakpointOptionsCommandCallback { static StringList commands_in_progress; - FILE *out_fh = reader->GetOutputFileHandle(); + FILE *out_fh = reader.GetDebugger().GetOutputFileHandle(); switch (notification) { case eInputReaderActivate: @@ -545,8 +550,8 @@ ScriptInterpreterPython::GenerateBreakpointOptionsCommandCallback if (out_fh) { ::fprintf (out_fh, "%s\n", g_reader_instructions); - if (reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); } } break; @@ -555,16 +560,16 @@ ScriptInterpreterPython::GenerateBreakpointOptionsCommandCallback break; case eInputReaderReactivate: - if (reader->GetPrompt() && out_fh) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (reader.GetPrompt() && out_fh) + ::fprintf (out_fh, "%s", reader.GetPrompt()); break; case eInputReaderGotToken: { std::string temp_string (bytes, bytes_len); commands_in_progress.AppendString (temp_string.c_str()); - if (out_fh && !reader->IsDone() && reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (out_fh && !reader.IsDone() && reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); } break; @@ -575,7 +580,7 @@ ScriptInterpreterPython::GenerateBreakpointOptionsCommandCallback data_ap->user_source.AppendList (commands_in_progress); if (data_ap.get()) { - ScriptInterpreter *interpreter = Debugger::GetSharedInstance().GetCommandInterpreter().GetScriptInterpreter(); + ScriptInterpreter *interpreter = reader.GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); if (interpreter) { if (interpreter->GenerateBreakpointCommandCallbackData (data_ap->user_source, @@ -602,10 +607,12 @@ ScriptInterpreterPython::GenerateBreakpointOptionsCommandCallback } void -ScriptInterpreterPython::CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, +ScriptInterpreterPython::CollectDataForBreakpointCommandCallback (CommandInterpreter &interpreter, + BreakpointOptions *bp_options, CommandReturnObject &result) { - InputReaderSP reader_sp (new InputReader ()); + Debugger &debugger = interpreter.GetDebugger(); + InputReaderSP reader_sp (new InputReader (debugger)); if (reader_sp) { @@ -618,7 +625,7 @@ ScriptInterpreterPython::CollectDataForBreakpointCommandCallback (BreakpointOpti true); // echo input if (err.Success()) - Debugger::GetSharedInstance().PushInputReader (reader_sp); + debugger.PushInputReader (reader_sp); else { result.AppendError (err.AsCString()); @@ -819,11 +826,11 @@ ScriptInterpreterPython::BreakpointCallbackFunction if (python_string != NULL) { - bool success = - Debugger::GetSharedInstance().GetCommandInterpreter().GetScriptInterpreter()->ExecuteOneLineWithReturn - (python_string, - ScriptInterpreter::eBool, - (void *) &temp_bool); + bool success = context->exe_ctx.target->GetDebugger(). + GetCommandInterpreter(). + GetScriptInterpreter()->ExecuteOneLineWithReturn (python_string, + ScriptInterpreter::eBool, + (void *) &temp_bool); if (success) ret_value = temp_bool; } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index a528120915d..1452cc8905a 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1922,7 +1922,7 @@ ProcessGDBRemote::MonitorDebugserverProcess // debugserver that we are tracking... lldb::pid_t gdb_remote_pid = (lldb::pid_t)(intptr_t)callback_baton; - TargetSP target_sp(Debugger::GetSharedInstance().GetTargetList().FindTargetWithProcessID (gdb_remote_pid)); + TargetSP target_sp(Debugger::FindTargetWithProcessID (gdb_remote_pid)); if (target_sp) { ProcessSP process_sp (target_sp->GetProcessSP()); diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 970e1e48994..1d9329188be 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -347,7 +347,7 @@ Process::SetProcessExitStatus { if (signo == 0 || exit_status) { - TargetSP target_sp(Debugger::GetSharedInstance().GetTargetList().FindTargetWithProcessID (pid)); + TargetSP target_sp(Debugger::FindTargetWithProcessID (pid)); if (target_sp) { ProcessSP process_sp (target_sp->GetProcessSP()); diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index cb832951661..3ebc0c28a98 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -176,7 +176,9 @@ StackFrame::Disassemble () { ExecutionContext exe_ctx; Calculate(exe_ctx); - Disassembler::Disassemble (m_thread.GetProcess().GetTarget().GetArchitecture(), + Target &target = m_thread.GetProcess().GetTarget(); + Disassembler::Disassemble (target.GetDebugger(), + target.GetArchitecture(), exe_ctx, 0, m_disassembly); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 48f2ea70fd0..1ba125ca653 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -33,8 +33,9 @@ using namespace lldb_private; //---------------------------------------------------------------------- // Target constructor //---------------------------------------------------------------------- -Target::Target() : +Target::Target(Debugger &debugger) : Broadcaster("Target"), + m_debugger (debugger), m_images(), m_breakpoint_list (false), m_internal_breakpoint_list (true), @@ -111,7 +112,7 @@ Target::GetProcessSP () const lldb::TargetSP Target::GetSP() { - return Debugger::GetSharedInstance().GetTargetList().GetTargetSP(this); + return m_debugger.GetTargetList().GetTargetSP(this); } BreakpointList & diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp index d92940003d6..4e2952ec0a3 100644 --- a/lldb/source/Target/TargetList.cpp +++ b/lldb/source/Target/TargetList.cpp @@ -46,6 +46,7 @@ TargetList::~TargetList() Error TargetList::CreateTarget ( + Debugger &debugger, const FileSpec& file, const ArchSpec& arch, const UUID *uuid_ptr, @@ -74,7 +75,7 @@ TargetList::CreateTarget NULL); if (exe_module_sp) { - target_sp.reset(new Target); + target_sp.reset(new Target(debugger)); target_sp->SetExecutableModule (exe_module_sp, get_dependent_files); if (target_sp.get()) diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 4afe254a329..9d9281bbae6 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -79,6 +79,7 @@ static lldb::OptionDefinition g_options[] = Driver::Driver () : SBBroadcaster ("Driver"), + m_debugger (SBDebugger::Create()), m_editline_pty (), m_editline_slave_fh (NULL), m_editline_reader (), @@ -323,9 +324,93 @@ BuildGetOptTable (lldb::OptionDefinition *expanded_option_table, struct option * } +Driver::OptionData::OptionData () : + m_filename(), + m_script_lang (lldb::eScriptLanguageDefault), + m_source_command_files (), + m_debug_mode (false), + m_print_help (false), + m_print_version (false) + +{ +} + +Driver::OptionData::~OptionData () +{ +} + +void +Driver::OptionData::Clear () +{ + m_filename.clear (); + m_script_lang = lldb::eScriptLanguageDefault; + m_source_command_files.clear (); + m_debug_mode = false; + m_print_help = false; + m_print_version = false; +} + +void +Driver::ResetOptionValues () +{ + m_option_data.Clear (); +} + +const char * +Driver::GetFilename() const +{ + if (m_option_data.m_filename.empty()) + return NULL; + return m_option_data.m_filename.c_str(); +} + +const char * +Driver::GetCrashLogFilename() const +{ + if (m_option_data.m_crash_log.empty()) + return NULL; + return m_option_data.m_crash_log.c_str(); +} + +lldb::ScriptLanguage +Driver::GetScriptLanguage() const +{ + return m_option_data.m_script_lang; +} + +size_t +Driver::GetNumSourceCommandFiles () const +{ + return m_option_data.m_source_command_files.size(); +} + +const char * +Driver::GetSourceCommandFileAtIndex (uint32_t idx) const +{ + if (idx < m_option_data.m_source_command_files.size()) + return m_option_data.m_source_command_files[idx].c_str(); + return NULL; +} + +bool +Driver::GetDebugMode() const +{ + return m_option_data.m_debug_mode; +} + + +// Check the arguments that were passed to this program to make sure they are valid and to get their +// argument values (if any). Return a boolean value indicating whether or not to start up the full +// debugger (i.e. the Command Interpreter) or not. Return FALSE if the arguments were invalid OR +// if the user only wanted help or version information. + SBError -ParseOptions (Driver::OptionData &data, int argc, const char **argv) +Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit) { + ResetOptionValues (); + + SBCommandReturnObject result; + SBError error; std::string option_string; struct option *long_options = NULL; @@ -389,7 +474,7 @@ ParseOptions (Driver::OptionData &data, int argc, const char **argv) break; else if (val == '?') { - data.m_print_help = true; + m_option_data.m_print_help = true; error.SetErrorStringWithFormat ("unknown or ambiguous option"); break; } @@ -397,7 +482,7 @@ ParseOptions (Driver::OptionData &data, int argc, const char **argv) continue; else { - data.m_seen_options.insert ((char) val); + m_option_data.m_seen_options.insert ((char) val); if (long_options_index == -1) { for (int i = 0; @@ -414,180 +499,68 @@ ParseOptions (Driver::OptionData &data, int argc, const char **argv) if (long_options_index >= 0) { - error = Driver::SetOptionValue (long_options_index, - long_options[long_options_index].has_arg == no_argument ? NULL : optarg, - data); - } - else - { - error.SetErrorStringWithFormat ("invalid option with value %i", val); - } - if (error.Fail()) - break; - } - } - - return error; -} + const char short_option = (char) g_options[long_options_index].short_option; -Driver::OptionData::OptionData () : - m_filename(), - m_script_lang (lldb::eScriptLanguageDefault), - m_source_command_files (), - m_debug_mode (false), - m_print_help (false), - m_print_version (false) + switch (short_option) + { + case 'h': + m_option_data.m_print_help = true; + break; -{ -} + case 'v': + m_option_data.m_print_version = true; + break; -Driver::OptionData::~OptionData () -{ -} + case 'c': + m_option_data.m_crash_log = optarg; + break; -void -Driver::OptionData::Clear () -{ - m_filename.clear (); - m_script_lang = lldb::eScriptLanguageDefault; - m_source_command_files.clear (); - m_debug_mode = false; - m_print_help = false; - m_print_version = false; -} + case 'f': + { + SBFileSpec file(optarg); + if (file.Exists()) + m_option_data.m_filename = optarg; + else + error.SetErrorStringWithFormat("file specified in --file (-f) option doesn't exist: '%s'", optarg); + } + break; -SBError -Driver::SetOptionValue (int option_idx, const char *option_arg, Driver::OptionData &option_data) -{ - SBError error; - const char short_option = (char) g_options[option_idx].short_option; + case 'a': + if (!m_debugger.SetDefaultArchitecture (optarg)) + error.SetErrorStringWithFormat("invalid architecture in the -a or --arch option: '%s'", optarg); + break; - switch (short_option) - { - case 'h': - option_data.m_print_help = true; - break; + case 'l': + m_option_data.m_script_lang = m_debugger.GetScriptingLanguage (optarg); + break; - case 'v': - option_data.m_print_version = true; - break; + case 'd': + m_option_data.m_debug_mode = true; + break; - case 'c': - option_data.m_crash_log = option_arg; - break; + case 's': + { + SBFileSpec file(optarg); + if (file.Exists()) + m_option_data.m_source_command_files.push_back (optarg); + else + error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg); + } + break; - case 'f': - { - SBFileSpec file(option_arg); - if (file.Exists()) - option_data.m_filename = option_arg; - else - error.SetErrorStringWithFormat("file specified in --file (-f) option doesn't exist: '%s'", option_arg); + default: + m_option_data.m_print_help = true; + error.SetErrorStringWithFormat ("unrecognized option %c", short_option); + break; + } } - break; - - case 'a': - if (!SBDebugger::SetDefaultArchitecture (option_arg)) - error.SetErrorStringWithFormat("invalid architecture in the -a or --arch option: '%s'", option_arg); - break; - - case 'l': - option_data.m_script_lang = SBDebugger::GetScriptingLanguage (option_arg); - break; - - case 'd': - option_data.m_debug_mode = true; - break; - - case 's': + else { - SBFileSpec file(option_arg); - if (file.Exists()) - option_data.m_source_command_files.push_back (option_arg); - else - error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", option_arg); + error.SetErrorStringWithFormat ("invalid option with value %i", val); } - break; - - default: - option_data.m_print_help = true; - error.SetErrorStringWithFormat ("unrecognized option %c", short_option); - break; - } - - return error; -} - -void -Driver::ResetOptionValues () -{ - m_option_data.Clear (); -} - -const char * -Driver::GetFilename() const -{ - if (m_option_data.m_filename.empty()) - return NULL; - return m_option_data.m_filename.c_str(); -} - -const char * -Driver::GetCrashLogFilename() const -{ - if (m_option_data.m_crash_log.empty()) - return NULL; - return m_option_data.m_crash_log.c_str(); -} - -lldb::ScriptLanguage -Driver::GetScriptLanguage() const -{ - return m_option_data.m_script_lang; -} - -size_t -Driver::GetNumSourceCommandFiles () const -{ - return m_option_data.m_source_command_files.size(); -} - -const char * -Driver::GetSourceCommandFileAtIndex (uint32_t idx) const -{ - if (idx < m_option_data.m_source_command_files.size()) - return m_option_data.m_source_command_files[idx].c_str(); - return NULL; -} - -bool -Driver::GetDebugMode() const -{ - return m_option_data.m_debug_mode; -} - - -// Check the arguments that were passed to this program to make sure they are valid and to get their -// argument values (if any). Return a boolean value indicating whether or not to start up the full -// debugger (i.e. the Command Interpreter) or not. Return FALSE if the arguments were invalid OR -// if the user only wanted help or version information. - -bool -Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, FILE *err_fh) -{ - bool valid = true; - - ResetOptionValues (); - - SBCommandReturnObject result; - - SBError error = ParseOptions (m_option_data, argc, argv); - if (error.Fail()) - { - const char *error_cstr = error.GetCString (); - if (error_cstr) - ::fprintf (err_fh, "error: %s\n", error_cstr); - valid = false; + if (error.Fail()) + return error; + } } // If there is a trailing argument, it is the filename. @@ -599,28 +572,24 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, FILE *err_fh) } else { - ::fprintf (err_fh, "error: don't provide a file both on in the -f option and as an argument."); - valid = false; + error.SetErrorStringWithFormat ("error: don't provide a file both on in the -f option and as an argument."); } } else if (optind < argc - 1) { // Trailing extra arguments... - ::fprintf (err_fh, "error: trailing extra arguments - only one the filename is allowed."); - valid = false; - + error.SetErrorStringWithFormat ("error: trailing extra arguments - only one the filename is allowed."); } - if (!valid || m_option_data.m_print_help) + if (error.Fail() || m_option_data.m_print_help) { ShowUsage (out_fh, g_options, m_option_data); - valid = false; } else if (m_option_data.m_print_version) { - ::fprintf (out_fh, "%s\n", SBDebugger::GetVersionString()); - valid = false; + ::fprintf (out_fh, "%s\n", m_debugger.GetVersionString()); + exit = true; } else if (! m_option_data.m_crash_log.empty()) { @@ -631,7 +600,7 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, FILE *err_fh) // All other combinations are valid; do nothing more here. } - return valid; + return error; } void @@ -640,7 +609,7 @@ Driver::GetProcessSTDOUT () // The process has stuff waiting for stdout; get it and write it out to the appropriate place. char stdio_buffer[1024]; size_t len; - while ((len = SBDebugger::GetCurrentTarget().GetProcess().GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0) + while ((len = m_debugger.GetCurrentTarget().GetProcess().GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0) m_io_channel_ap->OutWrite (stdio_buffer, len); } @@ -650,7 +619,7 @@ Driver::GetProcessSTDERR () // The process has stuff waiting for stderr; get it and write it out to the appropriate place. char stdio_buffer[1024]; size_t len; - while ((len = SBDebugger::GetCurrentTarget().GetProcess().GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0) + while ((len = m_debugger.GetCurrentTarget().GetProcess().GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0) m_io_channel_ap->ErrWrite (stdio_buffer, len); } @@ -658,7 +627,7 @@ void Driver::UpdateCurrentThread () { using namespace lldb; - SBProcess process(SBDebugger::GetCurrentTarget().GetProcess()); + SBProcess process(m_debugger.GetCurrentTarget().GetProcess()); if (process.IsValid()) { SBThread curr_thread (process.GetCurrentThread()); @@ -765,7 +734,7 @@ Driver::HandleProcessEvent (const SBEvent &event) { char message[1024]; int message_len = ::snprintf (message, sizeof(message), "Process %d %s\n", process.GetProcessID(), - SBDebugger::StateAsCString (event_state)); + m_debugger.StateAsCString (event_state)); m_io_channel_ap->OutWrite(message, message_len); } break; @@ -775,7 +744,7 @@ Driver::HandleProcessEvent (const SBEvent &event) break; case eStateExited: - SBDebugger::HandleCommand("process status"); + m_debugger.HandleCommand("process status"); m_io_channel_ap->RefreshPrompt(); break; @@ -794,7 +763,7 @@ Driver::HandleProcessEvent (const SBEvent &event) else { UpdateCurrentThread (); - SBDebugger::HandleCommand("process status"); + m_debugger.HandleCommand("process status"); m_io_channel_ap->RefreshPrompt(); } break; @@ -820,7 +789,7 @@ Driver::HandleIOEvent (const SBEvent &event) if (command_string == NULL) command_string == ""; SBCommandReturnObject result; - if (SBDebugger::GetCommandInterpreter().HandleCommand (command_string, result, true) != lldb::eReturnStatusQuit) + if (m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, true) != lldb::eReturnStatusQuit) { m_io_channel_ap->ErrWrite (result.GetError(), result.GetErrorSize()); m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize()); @@ -971,7 +940,7 @@ Driver::HandleIOEvent (const SBEvent &event) // // if (crash_infos.size()) // { -// SBTarget target (SBDebugger::CreateTarget (crash_infos.front().path.c_str(), +// SBTarget target (m_debugger.CreateTarget (crash_infos.front().path.c_str(), // lldb::GetDefaultArchitecture().AsCString (), // false)); // if (target.IsValid()) @@ -995,7 +964,7 @@ Driver::GetFromMaster (const char *src, size_t src_len) { // Echo the characters back to the Debugger's stdout, that way if you // type characters while a command is running, you'll see what you've typed. - FILE *out_fh = SBDebugger::GetOutputFileHandle(); + FILE *out_fh = m_debugger.GetOutputFileHandle(); if (out_fh) ::fwrite (src, 1, src_len, out_fh); } @@ -1076,9 +1045,9 @@ Driver::MainLoop () ::setbuf (stdin, NULL); ::setbuf (stdout, NULL); - SBDebugger::SetErrorFileHandle (stderr, false); - SBDebugger::SetOutputFileHandle (stdout, false); - SBDebugger::SetInputFileHandle (stdin, true); + m_debugger.SetErrorFileHandle (stderr, false); + m_debugger.SetOutputFileHandle (stdout, false); + m_debugger.SetInputFileHandle (stdin, true); // You have to drain anything that comes to the master side of the PTY. master_out_comm is // for that purpose. The reason you need to do this is a curious reason... editline will echo @@ -1104,7 +1073,7 @@ Driver::MainLoop () // ParseCrashLog (crash_log); // } // - SBCommandInterpreter sb_interpreter = SBDebugger::GetCommandInterpreter(); + SBCommandInterpreter sb_interpreter = m_debugger.GetCommandInterpreter(); m_io_channel_ap.reset (new IOChannel(m_editline_slave_fh, stdout, stderr, this)); @@ -1115,13 +1084,14 @@ Driver::MainLoop () char buffer[25]; sprintf (buffer, "set term-width %d", window_size.ws_col); - SBDebugger::HandleCommand ((const char *) buffer); + m_debugger.HandleCommand ((const char *) buffer); } // Since input can be redirected by the debugger, we must insert our editline // input reader in the queue so we know when our reader should be active // and so we can receive bytes only when we are supposed to. - SBError err (m_editline_reader.Initialize (Driver::EditLineInputReaderCallback, // callback + SBError err (m_editline_reader.Initialize (m_debugger, + Driver::EditLineInputReaderCallback, // callback this, // baton eInputReaderGranularityByte, // token_size NULL, // end token - NULL means never done @@ -1135,9 +1105,9 @@ Driver::MainLoop () exit (6); } - SBDebugger::PushInputReader (m_editline_reader); + m_debugger.PushInputReader (m_editline_reader); - SBListener listener(SBDebugger::GetListener()); + SBListener listener(m_debugger.GetListener()); if (listener.IsValid()) { @@ -1161,8 +1131,8 @@ Driver::MainLoop () sb_interpreter.SourceInitFileInHomeDirectory(result); if (GetDebugMode()) { - result.PutError (SBDebugger::GetErrorFileHandle()); - result.PutOutput (SBDebugger::GetOutputFileHandle()); + result.PutError (m_debugger.GetErrorFileHandle()); + result.PutOutput (m_debugger.GetOutputFileHandle()); } // Now we handle options we got from the command line @@ -1174,11 +1144,11 @@ Driver::MainLoop () { const char *command_file = GetSourceCommandFileAtIndex(i); ::snprintf (command_string, sizeof(command_string), "source '%s'", command_file); - SBDebugger::GetCommandInterpreter().HandleCommand (command_string, result, false); + m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, false); if (GetDebugMode()) { - result.PutError (SBDebugger::GetErrorFileHandle()); - result.PutOutput (SBDebugger::GetOutputFileHandle()); + result.PutError (m_debugger.GetErrorFileHandle()); + result.PutOutput (m_debugger.GetOutputFileHandle()); } } } @@ -1186,13 +1156,13 @@ Driver::MainLoop () if (!m_option_data.m_filename.empty()) { char arch_name[64]; - if (SBDebugger::GetDefaultArchitecture (arch_name, sizeof (arch_name))) + if (m_debugger.GetDefaultArchitecture (arch_name, sizeof (arch_name))) ::snprintf (command_string, sizeof (command_string), "file --arch=%s '%s'", arch_name, m_option_data.m_filename.c_str()); else ::snprintf (command_string, sizeof(command_string), "file '%s'", m_option_data.m_filename.c_str()); - SBDebugger::HandleCommand (command_string); + m_debugger.HandleCommand (command_string); } // Now that all option parsing is done, we try and parse the .lldbinit @@ -1200,8 +1170,8 @@ Driver::MainLoop () sb_interpreter.SourceInitFileInCurrentWorkingDirectory (result); if (GetDebugMode()) { - result.PutError(SBDebugger::GetErrorFileHandle()); - result.PutOutput(SBDebugger::GetOutputFileHandle()); + result.PutError(m_debugger.GetErrorFileHandle()); + result.PutOutput(m_debugger.GetOutputFileHandle()); } SBEvent event; @@ -1237,7 +1207,7 @@ Driver::MainLoop () else done = HandleIOEvent (event); } - else if (event.BroadcasterMatchesRef (SBDebugger::GetCurrentTarget().GetProcess().GetBroadcaster())) + else if (event.BroadcasterMatchesRef (m_debugger.GetCurrentTarget().GetProcess().GetBroadcaster())) { HandleProcessEvent (event); } @@ -1267,7 +1237,7 @@ Driver::MainLoop () } } - SBProcess process = SBDebugger::GetCurrentTarget().GetProcess(); + SBProcess process = m_debugger.GetCurrentTarget().GetProcess(); if (process.IsValid()) process.Destroy(); } @@ -1289,19 +1259,27 @@ Driver::ReadyForCommand () int main (int argc, char const *argv[]) { - SBDebugger::Initialize(); SBHostOS::ThreadCreated ("[main]"); - // Do a little setup on the debugger before we get going - SBDebugger::SetAsync(true); - Driver driver; - - bool valid_args = driver.ParseArgs (argc, argv, stdout, stderr); - if (valid_args) + // Create a scope for driver so that the driver object will destroy itself + // before SBDebugger::Terminate() is called. { - driver.MainLoop (); + Driver driver; + + bool exit = false; + SBError error (driver.ParseArgs (argc, argv, stdout, exit)); + if (error.Fail()) + { + const char *error_cstr = error.GetCString (); + if (error_cstr) + ::fprintf (stderr, "error: %s\n", error_cstr); + } + else if (!exit) + { + driver.MainLoop (); + } } SBDebugger::Terminate(); diff --git a/lldb/tools/driver/Driver.h b/lldb/tools/driver/Driver.h index 61eb0e7b1f4..4f485bdba37 100644 --- a/lldb/tools/driver/Driver.h +++ b/lldb/tools/driver/Driver.h @@ -19,6 +19,7 @@ #include "lldb/API/SBDefines.h" #include "lldb/API/SBBroadcaster.h" +#include "lldb/API/SBDebugger.h" #include "lldb/API/SBError.h" #include "lldb/API/SBInputReader.h" @@ -59,8 +60,8 @@ public: void HandleProcessEvent (const lldb::SBEvent &event); - bool - ParseArgs (int argc, const char *argv[], FILE *out_fh, FILE *err_fh); + lldb::SBError + ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &do_exit); const char * GetFilename() const; @@ -113,7 +114,14 @@ public: Driver::OptionData &data); + lldb::SBDebugger & + GetDebugger() + { + return m_debugger; + } + private: + lldb::SBDebugger m_debugger; lldb_utility::PseudoTerminal m_editline_pty; FILE *m_editline_slave_fh; lldb::SBInputReader m_editline_reader; diff --git a/lldb/tools/driver/IOChannel.cpp b/lldb/tools/driver/IOChannel.cpp index 8b833b1a6cc..52f5ba858b9 100644 --- a/lldb/tools/driver/IOChannel.cpp +++ b/lldb/tools/driver/IOChannel.cpp @@ -70,13 +70,12 @@ IOChannel::HandleCompletion (EditLine *e, int ch) SBStringList completions; size_t page_size = 40; - int num_completions - = SBDebugger::GetCommandInterpreter().HandleCompletion (line_info->buffer, - line_info->cursor, - line_info->lastchar, - 0, - -1, - completions); + int num_completions = m_driver->GetDebugger().GetCommandInterpreter().HandleCompletion (line_info->buffer, + line_info->cursor, + line_info->lastchar, + 0, + -1, + completions); if (num_completions == -1) { @@ -269,7 +268,7 @@ IOChannel::Run () SBListener listener("IOChannel::Run"); std::string new_line; - SBBroadcaster interpreter_broadcaster (SBDebugger::GetCommandInterpreter().GetBroadcaster()); + SBBroadcaster interpreter_broadcaster (m_driver->GetDebugger().GetCommandInterpreter().GetBroadcaster()); listener.StartListeningForEvents (interpreter_broadcaster, SBCommandInterpreter::eBroadcastBitResetPrompt | SBCommandInterpreter::eBroadcastBitThreadShouldExit | |