diff options
author | Ed Maste <emaste@FreeBSD.org> | 2013-08-23 17:46:38 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2013-08-23 17:46:38 +0000 |
commit | f034231a6a1fd5d6395206c1651de8cd9402cca3 (patch) | |
tree | f561dabc721ad515599172c16da3a4400b7f4aec /include/lldb/API | |
download | src-f034231a6a1fd5d6395206c1651de8cd9402cca3.tar.gz src-f034231a6a1fd5d6395206c1651de8cd9402cca3.zip |
Import lldb as of SVN r188801
(A number of files not required for the FreeBSD build have been removed.)
Sponsored by: DARPA, AFRL
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=254721
Diffstat (limited to 'include/lldb/API')
49 files changed, 7257 insertions, 0 deletions
diff --git a/include/lldb/API/LLDB.h b/include/lldb/API/LLDB.h new file mode 100644 index 000000000000..93bc3bc121e2 --- /dev/null +++ b/include/lldb/API/LLDB.h @@ -0,0 +1,54 @@ +//===-- LLDB.h --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_LLDB_h_ +#define LLDB_LLDB_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBBlock.h" +#include "lldb/API/SBBreakpoint.h" +#include "lldb/API/SBBreakpointLocation.h" +#include "lldb/API/SBBroadcaster.h" +#include "lldb/API/SBCommandInterpreter.h" +#include "lldb/API/SBCommandReturnObject.h" +#include "lldb/API/SBCommunication.h" +#include "lldb/API/SBCompileUnit.h" +#include "lldb/API/SBData.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBDeclaration.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBEvent.h" +#include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBFrame.h" +#include "lldb/API/SBFunction.h" +#include "lldb/API/SBHostOS.h" +#include "lldb/API/SBInputReader.h" +#include "lldb/API/SBInstruction.h" +#include "lldb/API/SBInstructionList.h" +#include "lldb/API/SBLineEntry.h" +#include "lldb/API/SBListener.h" +#include "lldb/API/SBModule.h" +#include "lldb/API/SBProcess.h" +#include "lldb/API/SBSourceManager.h" +#include "lldb/API/SBStream.h" +#include "lldb/API/SBStringList.h" +#include "lldb/API/SBSymbol.h" +#include "lldb/API/SBSymbolContext.h" +#include "lldb/API/SBTarget.h" +#include "lldb/API/SBThread.h" +#include "lldb/API/SBType.h" +#include "lldb/API/SBValue.h" +#include "lldb/API/SBValueList.h" + +#endif // LLDB_LLDB_h_ diff --git a/include/lldb/API/SBAddress.h b/include/lldb/API/SBAddress.h new file mode 100644 index 000000000000..c5e8cc685a4c --- /dev/null +++ b/include/lldb/API/SBAddress.h @@ -0,0 +1,150 @@ +//===-- SBAddress.h ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBAddress_h_ +#define LLDB_SBAddress_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBModule.h" + +namespace lldb { + +class SBAddress +{ +public: + + SBAddress (); + + SBAddress (const lldb::SBAddress &rhs); + + SBAddress (lldb::SBSection section, lldb::addr_t offset); + + // Create an address by resolving a load address using the supplied target + SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target); + + ~SBAddress (); + + const lldb::SBAddress & + operator = (const lldb::SBAddress &rhs); + + bool + IsValid () const; + + void + Clear (); + + addr_t + GetFileAddress () const; + + addr_t + GetLoadAddress (const lldb::SBTarget &target) const; + + void + SetAddress (lldb::SBSection section, lldb::addr_t offset); + + void + SetLoadAddress (lldb::addr_t load_addr, + lldb::SBTarget &target); + bool + OffsetAddress (addr_t offset); + + bool + GetDescription (lldb::SBStream &description); + + // The following queries can lookup symbol information for a given address. + // An address might refer to code or data from an existing module, or it + // might refer to something on the stack or heap. The following functions + // will only return valid values if the address has been resolved to a code + // or data address using "void SBAddress::SetLoadAddress(...)" or + // "lldb::SBAddress SBTarget::ResolveLoadAddress (...)". + lldb::SBSymbolContext + GetSymbolContext (uint32_t resolve_scope); + + + // The following functions grab individual objects for a given address and + // are less efficient if you want more than one symbol related objects. + // Use one of the following when you want multiple debug symbol related + // objects for an address: + // lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t resolve_scope); + // lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress &addr, uint32_t resolve_scope); + // One or more bits from the SymbolContextItem enumerations can be logically + // OR'ed together to more efficiently retrieve multiple symbol objects. + + lldb::SBSection + GetSection (); + + lldb::addr_t + GetOffset (); + + lldb::SBModule + GetModule (); + + lldb::SBCompileUnit + GetCompileUnit (); + + lldb::SBFunction + GetFunction (); + + lldb::SBBlock + GetBlock (); + + lldb::SBSymbol + GetSymbol (); + + lldb::SBLineEntry + GetLineEntry (); + + lldb::AddressClass + GetAddressClass (); + +protected: + + friend class SBBlock; + friend class SBBreakpointLocation; + friend class SBFrame; + friend class SBFunction; + friend class SBLineEntry; + friend class SBInstruction; + friend class SBModule; + friend class SBSection; + friend class SBSymbol; + friend class SBSymbolContext; + friend class SBTarget; + friend class SBThread; + friend class SBValue; + + lldb_private::Address * + operator->(); + + const lldb_private::Address * + operator->() const; + + lldb_private::Address * + get (); + + lldb_private::Address & + ref(); + + const lldb_private::Address & + ref() const; + + SBAddress (const lldb_private::Address *lldb_object_ptr); + + void + SetAddress (const lldb_private::Address *lldb_object_ptr); + +private: + + std::unique_ptr<lldb_private::Address> m_opaque_ap; +}; + + +} // namespace lldb + +#endif // LLDB_SBAddress_h_ diff --git a/include/lldb/API/SBBlock.h b/include/lldb/API/SBBlock.h new file mode 100644 index 000000000000..b8e61fc6eb27 --- /dev/null +++ b/include/lldb/API/SBBlock.h @@ -0,0 +1,123 @@ +//===-- SBBlock.h -----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBBlock_h_ +#define LLDB_SBBlock_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBFrame.h" +#include "lldb/API/SBTarget.h" +#include "lldb/API/SBValueList.h" + +namespace lldb { + +class SBBlock +{ +public: + + SBBlock (); + + SBBlock (const lldb::SBBlock &rhs); + + ~SBBlock (); + + const lldb::SBBlock & + operator = (const lldb::SBBlock &rhs); + + bool + IsInlined () const; + + bool + IsValid () const; + + const char * + GetInlinedName () const; + + lldb::SBFileSpec + GetInlinedCallSiteFile () const; + + uint32_t + GetInlinedCallSiteLine () const; + + uint32_t + GetInlinedCallSiteColumn () const; + + lldb::SBBlock + GetParent (); + + lldb::SBBlock + GetSibling (); + + lldb::SBBlock + GetFirstChild (); + + uint32_t + GetNumRanges (); + + lldb::SBAddress + GetRangeStartAddress (uint32_t idx); + + lldb::SBAddress + GetRangeEndAddress (uint32_t idx); + + uint32_t + GetRangeIndexForBlockAddress (lldb::SBAddress block_addr); + + lldb::SBValueList + GetVariables (lldb::SBFrame& frame, + bool arguments, + bool locals, + bool statics, + lldb::DynamicValueType use_dynamic); + + lldb::SBValueList + GetVariables (lldb::SBTarget& target, + bool arguments, + bool locals, + bool statics); + //------------------------------------------------------------------ + /// Get the inlined block that contains this block. + /// + /// @return + /// If this block is inlined, it will return this block, else + /// parent blocks will be searched to see if any contain this + /// block and are themselves inlined. An invalid SBBlock will + /// be returned if this block nor any parent blocks are inlined + /// function blocks. + //------------------------------------------------------------------ + lldb::SBBlock + GetContainingInlinedBlock (); + + bool + GetDescription (lldb::SBStream &description); + +private: + friend class SBAddress; + friend class SBFrame; + friend class SBFunction; + friend class SBSymbolContext; + + lldb_private::Block * + GetPtr (); + + void + SetPtr (lldb_private::Block *lldb_object_ptr); + + SBBlock (lldb_private::Block *lldb_object_ptr); + + void + AppendVariables (bool can_create, bool get_parent_variables, lldb_private::VariableList *var_list); + + lldb_private::Block *m_opaque_ptr; +}; + + +} // namespace lldb + +#endif // LLDB_SBBlock_h_ diff --git a/include/lldb/API/SBBreakpoint.h b/include/lldb/API/SBBreakpoint.h new file mode 100644 index 000000000000..be9c499798e1 --- /dev/null +++ b/include/lldb/API/SBBreakpoint.h @@ -0,0 +1,175 @@ +//===-- SBBreakpoint.h ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBBreakpoint_h_ +#define LLDB_SBBreakpoint_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBBreakpoint +{ +public: + + typedef bool (*BreakpointHitCallback) (void *baton, + SBProcess &process, + SBThread &thread, + lldb::SBBreakpointLocation &location); + + SBBreakpoint (); + + SBBreakpoint (const lldb::SBBreakpoint& rhs); + + ~SBBreakpoint(); + + const lldb::SBBreakpoint & + operator = (const lldb::SBBreakpoint& rhs); + + // Tests to see if the opaque breakpoint object in this object matches the + // opaque breakpoint object in "rhs". + bool + operator == (const lldb::SBBreakpoint& rhs); + + bool + operator != (const lldb::SBBreakpoint& rhs); + + break_id_t + GetID () const; + + bool + IsValid() const; + + void + ClearAllBreakpointSites (); + + lldb::SBBreakpointLocation + FindLocationByAddress (lldb::addr_t vm_addr); + + lldb::break_id_t + FindLocationIDByAddress (lldb::addr_t vm_addr); + + lldb::SBBreakpointLocation + FindLocationByID (lldb::break_id_t bp_loc_id); + + lldb::SBBreakpointLocation + GetLocationAtIndex (uint32_t index); + + void + SetEnabled (bool enable); + + bool + IsEnabled (); + + void + SetOneShot (bool one_shot); + + bool + IsOneShot () const; + + bool + IsInternal (); + + uint32_t + GetHitCount () const; + + void + SetIgnoreCount (uint32_t count); + + uint32_t + GetIgnoreCount () const; + + void + SetCondition (const char *condition); + + const char * + GetCondition (); + + void + SetThreadID (lldb::tid_t sb_thread_id); + + lldb::tid_t + GetThreadID (); + + void + SetThreadIndex (uint32_t index); + + uint32_t + GetThreadIndex() const; + + void + SetThreadName (const char *thread_name); + + const char * + GetThreadName () const; + + void + SetQueueName (const char *queue_name); + + const char * + GetQueueName () const; + + void + SetCallback (BreakpointHitCallback callback, void *baton); + + size_t + GetNumResolvedLocations() const; + + size_t + GetNumLocations() const; + + bool + GetDescription (lldb::SBStream &description); + + static bool + EventIsBreakpointEvent (const lldb::SBEvent &event); + + static lldb::BreakpointEventType + GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event); + + static lldb::SBBreakpoint + GetBreakpointFromEvent (const lldb::SBEvent& event); + + static lldb::SBBreakpointLocation + GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx); + + static uint32_t + GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event_sp); + + +private: + friend class SBBreakpointLocation; + friend class SBTarget; + + SBBreakpoint (const lldb::BreakpointSP &bp_sp); + + lldb_private::Breakpoint * + operator->() const; + + lldb_private::Breakpoint * + get() const; + + lldb::BreakpointSP & + operator *(); + + const lldb::BreakpointSP & + operator *() const; + + static bool + PrivateBreakpointHitCallback (void *baton, + lldb_private::StoppointCallbackContext *context, + lldb::user_id_t break_id, + lldb::user_id_t break_loc_id); + + lldb::BreakpointSP m_opaque_sp; +}; + +} // namespace lldb + +#endif // LLDB_SBBreakpoint_h_ diff --git a/include/lldb/API/SBBreakpointLocation.h b/include/lldb/API/SBBreakpointLocation.h new file mode 100644 index 000000000000..3b2ca2cf88e8 --- /dev/null +++ b/include/lldb/API/SBBreakpointLocation.h @@ -0,0 +1,110 @@ +//===-- SBBreakpointLocation.h ----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBBreakpointLocation_h_ +#define LLDB_SBBreakpointLocation_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBBreakpoint.h" + +namespace lldb { + +class SBBreakpointLocation +{ +public: + + SBBreakpointLocation (); + + SBBreakpointLocation (const lldb::SBBreakpointLocation &rhs); + + ~SBBreakpointLocation (); + + const lldb::SBBreakpointLocation & + operator = (const lldb::SBBreakpointLocation &rhs); + + break_id_t + GetID (); + + bool + IsValid() const; + + lldb::SBAddress + GetAddress (); + + lldb::addr_t + GetLoadAddress (); + + void + SetEnabled(bool enabled); + + bool + IsEnabled (); + + uint32_t + GetIgnoreCount (); + + void + SetIgnoreCount (uint32_t n); + + void + SetCondition (const char *condition); + + const char * + GetCondition (); + + void + SetThreadID (lldb::tid_t sb_thread_id); + + lldb::tid_t + GetThreadID (); + + void + SetThreadIndex (uint32_t index); + + uint32_t + GetThreadIndex() const; + + void + SetThreadName (const char *thread_name); + + const char * + GetThreadName () const; + + void + SetQueueName (const char *queue_name); + + const char * + GetQueueName () const; + + bool + IsResolved (); + + bool + GetDescription (lldb::SBStream &description, DescriptionLevel level); + + SBBreakpoint + GetBreakpoint (); + + SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp); + +private: + friend class SBBreakpoint; +#ifndef LLDB_DISABLE_PYTHON + friend class lldb_private::ScriptInterpreterPython; +#endif + void + SetLocation (const lldb::BreakpointLocationSP &break_loc_sp); + + lldb::BreakpointLocationSP m_opaque_sp; + +}; + +} // namespace lldb + +#endif // LLDB_SBBreakpointLocation_h_ diff --git a/include/lldb/API/SBBroadcaster.h b/include/lldb/API/SBBroadcaster.h new file mode 100644 index 000000000000..7b32d85faa0f --- /dev/null +++ b/include/lldb/API/SBBroadcaster.h @@ -0,0 +1,97 @@ +//===-- SBBroadcaster.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBBroadcaster_h_ +#define LLDB_SBBroadcaster_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBBroadcaster +{ +public: + SBBroadcaster (); + + SBBroadcaster (const char *name); + + SBBroadcaster (const SBBroadcaster &rhs); + + const SBBroadcaster & + operator = (const SBBroadcaster &rhs); + + ~SBBroadcaster(); + + bool + IsValid () const; + + void + Clear (); + + void + BroadcastEventByType (uint32_t event_type, bool unique = false); + + void + BroadcastEvent (const lldb::SBEvent &event, bool unique = false); + + void + AddInitialEventsToListener (const lldb::SBListener &listener, uint32_t requested_events); + + uint32_t + AddListener (const lldb::SBListener &listener, uint32_t event_mask); + + const char * + GetName () const; + + bool + EventTypeHasListeners (uint32_t event_type); + + bool + RemoveListener (const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX); + + // This comparison is checking if the internal opaque pointer value + // is equal to that in "rhs". + bool + operator == (const lldb::SBBroadcaster &rhs) const; + + // This comparison is checking if the internal opaque pointer value + // is not equal to that in "rhs". + bool + operator != (const lldb::SBBroadcaster &rhs) const; + + // This comparison is checking if the internal opaque pointer value + // is less than that in "rhs" so SBBroadcaster objects can be contained + // in ordered containers. + bool + operator < (const lldb::SBBroadcaster &rhs) const; + +protected: + friend class SBCommandInterpreter; + friend class SBCommunication; + friend class SBEvent; + friend class SBListener; + friend class SBProcess; + friend class SBTarget; + + SBBroadcaster (lldb_private::Broadcaster *broadcaster, bool owns); + + lldb_private::Broadcaster * + get () const; + + void + reset (lldb_private::Broadcaster *broadcaster, bool owns); + +private: + lldb::BroadcasterSP m_opaque_sp; + lldb_private::Broadcaster *m_opaque_ptr; +}; + +} // namespace lldb + +#endif // LLDB_SBBroadcaster_h_ diff --git a/include/lldb/API/SBCommandInterpreter.h b/include/lldb/API/SBCommandInterpreter.h new file mode 100644 index 000000000000..9b2583cd85ca --- /dev/null +++ b/include/lldb/API/SBCommandInterpreter.h @@ -0,0 +1,193 @@ +//===-- SBCommandInterpreter.h ----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBCommandInterpreter_h_ +#define LLDB_SBCommandInterpreter_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBDebugger.h" + +namespace lldb { + +class SBCommandInterpreter +{ +public: + enum + { + eBroadcastBitThreadShouldExit = (1 << 0), + eBroadcastBitResetPrompt = (1 << 1), + eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit + eBroadcastBitAsynchronousOutputData = (1 << 3), + eBroadcastBitAsynchronousErrorData = (1 << 4) + }; + + SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs); + + const lldb::SBCommandInterpreter & + operator = (const lldb::SBCommandInterpreter &rhs); + + ~SBCommandInterpreter (); + + static const char * + GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type); + + static const char * + GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type); + + bool + IsValid() const; + + bool + CommandExists (const char *cmd); + + bool + AliasExists (const char *cmd); + + lldb::SBBroadcaster + GetBroadcaster (); + + static const char * + GetBroadcasterClass (); + + bool + HasCommands (); + + bool + HasAliases (); + + bool + HasAliasOptions (); + + lldb::SBProcess + GetProcess (); + + lldb::SBDebugger + GetDebugger (); + + lldb::SBCommand + AddMultiwordCommand (const char* name, const char* help); + + lldb::SBCommand + AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help); + + void + SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result); + + void + SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result); + + lldb::ReturnStatus + HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false); + + // The pointer based interface is not useful in SWIG, since the cursor & last_char arguments are string pointers INTO current_line + // and you can't do that in a scripting language interface in general... + + // In either case, the way this works is that the you give it a line and cursor position in the line. The function + // will return the number of completions. The matches list will contain number_of_completions + 1 elements. The first + // element is the common substring after the cursor position for all the matches. The rest of the elements are the + // matches. The first element is useful if you are emulating the common shell behavior where the tab completes + // to the string that is common among all the matches, then you should first check if the first element is non-empty, + // and if so just insert it and move the cursor to the end of the insertion. The next tab will return an empty + // common substring, and a list of choices (if any), at which point you should display the choices and let the user + // type further to disambiguate. + + int + HandleCompletion (const char *current_line, + const char *cursor, + const char *last_char, + int match_start_point, + int max_return_elements, + lldb::SBStringList &matches); + + int + HandleCompletion (const char *current_line, + uint32_t cursor_pos, + int match_start_point, + int max_return_elements, + lldb::SBStringList &matches); + + // Catch commands before they execute by registering a callback that will + // get called when the command gets executed. This allows GUI or command + // line interfaces to intercept a command and stop it from happening + bool + SetCommandOverrideCallback (const char *command_name, + lldb::CommandOverrideCallback callback, + void *baton); + + SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr = NULL); // Access using SBDebugger::GetCommandInterpreter(); + +protected: + + lldb_private::CommandInterpreter & + ref (); + + lldb_private::CommandInterpreter * + get (); + + void + reset (lldb_private::CommandInterpreter *); +private: + friend class SBDebugger; + + static void + InitializeSWIG (); + + lldb_private::CommandInterpreter *m_opaque_ptr; +}; + +class SBCommandPluginInterface +{ +public: + virtual bool + DoExecute (lldb::SBDebugger debugger, + char** command, + lldb::SBCommandReturnObject &result) + { + return false; + } + + virtual + ~SBCommandPluginInterface () + {} +}; + +class SBCommand +{ +public: + + SBCommand (); + + bool + IsValid (); + + const char* + GetName (); + + const char* + GetHelp (); + + lldb::SBCommand + AddMultiwordCommand (const char* name, const char* help = NULL); + + lldb::SBCommand + AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help = NULL); + +private: + + friend class SBDebugger; + friend class SBCommandInterpreter; + + SBCommand (lldb::CommandObjectSP cmd_sp); + + lldb::CommandObjectSP m_opaque_sp; +}; + +} // namespace lldb + +#endif // LLDB_SBCommandInterpreter_h_ diff --git a/include/lldb/API/SBCommandReturnObject.h b/include/lldb/API/SBCommandReturnObject.h new file mode 100644 index 000000000000..f2d274802330 --- /dev/null +++ b/include/lldb/API/SBCommandReturnObject.h @@ -0,0 +1,133 @@ +//===-- SBCommandReturnObject.h ---------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBCommandReturnObject_h_ +#define LLDB_SBCommandReturnObject_h_ + +#include <stdio.h> + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBCommandReturnObject +{ +public: + + SBCommandReturnObject (); + + SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs); + + const lldb::SBCommandReturnObject & + operator = (const lldb::SBCommandReturnObject &rhs); + + + SBCommandReturnObject (lldb_private::CommandReturnObject *ptr); + + lldb_private::CommandReturnObject * + Release (); + + ~SBCommandReturnObject (); + + bool + IsValid() const; + + const char * + GetOutput (); + + const char * + GetError (); + + size_t + PutOutput (FILE *fh); + + size_t + GetOutputSize (); + + size_t + GetErrorSize (); + + size_t + PutError (FILE *fh); + + void + Clear(); + + lldb::ReturnStatus + GetStatus(); + + void + SetStatus (lldb::ReturnStatus status); + + bool + Succeeded (); + + bool + HasResult (); + + void + AppendMessage (const char *message); + + void + AppendWarning (const char *message); + + bool + GetDescription (lldb::SBStream &description); + + void + SetImmediateOutputFile (FILE *fh); + + void + SetImmediateErrorFile (FILE *fh); + + void + PutCString(const char* string, int len = -1); + + size_t + Printf(const char* format, ...) __attribute__ ((format (printf, 2, 3))); + + const char * + GetOutput (bool only_if_no_immediate); + + const char * + GetError (bool only_if_no_immediate); + + void + SetError (lldb::SBError &error, + const char *fallback_error_cstr = NULL); + + void + SetError (const char* error_cstr); + +protected: + friend class SBCommandInterpreter; + friend class SBOptions; + + lldb_private::CommandReturnObject * + operator->() const; + + lldb_private::CommandReturnObject * + get() const; + + lldb_private::CommandReturnObject & + operator*() const; + + lldb_private::CommandReturnObject & + ref() const; + + void + SetLLDBObjectPtr (lldb_private::CommandReturnObject *ptr); + + private: + std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_ap; +}; + +} // namespace lldb + +#endif // LLDB_SBCommandReturnObject_h_ diff --git a/include/lldb/API/SBCommunication.h b/include/lldb/API/SBCommunication.h new file mode 100644 index 000000000000..ecaaa3523c91 --- /dev/null +++ b/include/lldb/API/SBCommunication.h @@ -0,0 +1,99 @@ +//===-- SBCommunication.h ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBCommunication_h_ +#define LLDB_SBCommunication_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBError.h" + +namespace lldb { + +class SBCommunication +{ +public: + enum { + eBroadcastBitDisconnected = (1 << 0), ///< Sent when the communications connection is lost. + eBroadcastBitReadThreadGotBytes = (1 << 1), ///< Sent by the read thread when bytes become available. + eBroadcastBitReadThreadDidExit = (1 << 2), ///< Sent by the read thread when it exits to inform clients. + eBroadcastBitReadThreadShouldExit = (1 << 3), ///< Sent by clients that need to cancel the read thread. + eBroadcastBitPacketAvailable = (1 << 4), ///< Sent when data received makes a complete packet. + eAllEventBits = 0xffffffff + }; + + typedef void (*ReadThreadBytesReceived) (void *baton, const void *src, size_t src_len); + + SBCommunication (); + SBCommunication (const char * broadcaster_name); + ~SBCommunication (); + + + bool + IsValid () const; + + lldb::SBBroadcaster + GetBroadcaster (); + + static const char *GetBroadcasterClass(); + + lldb::ConnectionStatus + AdoptFileDesriptor (int fd, bool owns_fd); + + lldb::ConnectionStatus + Connect (const char *url); + + lldb::ConnectionStatus + Disconnect (); + + bool + IsConnected () const; + + bool + GetCloseOnEOF (); + + void + SetCloseOnEOF (bool b); + + size_t + Read (void *dst, + size_t dst_len, + uint32_t timeout_usec, + lldb::ConnectionStatus &status); + + size_t + Write (const void *src, + size_t src_len, + lldb::ConnectionStatus &status); + + bool + ReadThreadStart (); + + bool + ReadThreadStop (); + + bool + ReadThreadIsRunning (); + + bool + SetReadThreadBytesReceivedCallback (ReadThreadBytesReceived callback, + void *callback_baton); + + +private: + + DISALLOW_COPY_AND_ASSIGN (SBCommunication); + + lldb_private::Communication *m_opaque; + bool m_opaque_owned; +}; + + +} // namespace lldb + +#endif // LLDB_SBCommunication_h_ diff --git a/include/lldb/API/SBCompileUnit.h b/include/lldb/API/SBCompileUnit.h new file mode 100644 index 000000000000..95af3d4722ce --- /dev/null +++ b/include/lldb/API/SBCompileUnit.h @@ -0,0 +1,116 @@ +//===-- SBCompileUnit.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBCompileUnit_h_ +#define LLDB_SBCompileUnit_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBFileSpec.h" + +namespace lldb { + +class SBCompileUnit +{ +public: + + SBCompileUnit (); + + SBCompileUnit (const lldb::SBCompileUnit &rhs); + + ~SBCompileUnit (); + + const lldb::SBCompileUnit & + operator = (const lldb::SBCompileUnit &rhs); + + bool + IsValid () const; + + lldb::SBFileSpec + GetFileSpec () const; + + uint32_t + GetNumLineEntries () const; + + lldb::SBLineEntry + GetLineEntryAtIndex (uint32_t idx) const; + + uint32_t + FindLineEntryIndex (uint32_t start_idx, + uint32_t line, + lldb::SBFileSpec *inline_file_spec) const; + + uint32_t + FindLineEntryIndex (uint32_t start_idx, + uint32_t line, + lldb::SBFileSpec *inline_file_spec, + bool exact) const; + + SBFileSpec + GetSupportFileAtIndex (uint32_t idx) const; + + uint32_t + GetNumSupportFiles () const; + + uint32_t + FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full); + + //------------------------------------------------------------------ + /// Get all types matching \a type_mask from debug info in this + /// compile unit. + /// + /// @param[in] type_mask + /// A bitfield that consists of one or more bits logically OR'ed + /// together from the lldb::TypeClass enumeration. This allows + /// you to request only structure types, or only class, struct + /// and union types. Passing in lldb::eTypeClassAny will return + /// all types found in the debug information for this compile + /// unit. + /// + /// @return + /// A list of types in this compile unit that match \a type_mask + //------------------------------------------------------------------ + lldb::SBTypeList + GetTypes (uint32_t type_mask = lldb::eTypeClassAny); + + bool + operator == (const lldb::SBCompileUnit &rhs) const; + + bool + operator != (const lldb::SBCompileUnit &rhs) const; + + bool + GetDescription (lldb::SBStream &description); + +private: + friend class SBAddress; + friend class SBFrame; + friend class SBSymbolContext; + friend class SBModule; + + SBCompileUnit (lldb_private::CompileUnit *lldb_object_ptr); + + const lldb_private::CompileUnit * + operator->() const; + + const lldb_private::CompileUnit & + operator*() const; + + lldb_private::CompileUnit * + get (); + + void + reset (lldb_private::CompileUnit *lldb_object_ptr); + + lldb_private::CompileUnit *m_opaque_ptr; +}; + + +} // namespace lldb + +#endif // LLDB_SBCompileUnit_h_ diff --git a/include/lldb/API/SBData.h b/include/lldb/API/SBData.h new file mode 100644 index 000000000000..10c002247271 --- /dev/null +++ b/include/lldb/API/SBData.h @@ -0,0 +1,180 @@ +//===-- SBData.h -----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBData_h_ +#define LLDB_SBData_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBData +{ +public: + + SBData (); + + SBData (const SBData &rhs); + + const SBData & + operator = (const SBData &rhs); + + ~SBData (); + + uint8_t + GetAddressByteSize (); + + void + SetAddressByteSize (uint8_t addr_byte_size); + + void + Clear (); + + bool + IsValid(); + + size_t + GetByteSize (); + + lldb::ByteOrder + GetByteOrder(); + + void + SetByteOrder (lldb::ByteOrder endian); + + float + GetFloat (lldb::SBError& error, lldb::offset_t offset); + + double + GetDouble (lldb::SBError& error, lldb::offset_t offset); + + long double + GetLongDouble (lldb::SBError& error, lldb::offset_t offset); + + lldb::addr_t + GetAddress (lldb::SBError& error, lldb::offset_t offset); + + uint8_t + GetUnsignedInt8 (lldb::SBError& error, lldb::offset_t offset); + + uint16_t + GetUnsignedInt16 (lldb::SBError& error, lldb::offset_t offset); + + uint32_t + GetUnsignedInt32 (lldb::SBError& error, lldb::offset_t offset); + + uint64_t + GetUnsignedInt64 (lldb::SBError& error, lldb::offset_t offset); + + int8_t + GetSignedInt8 (lldb::SBError& error, lldb::offset_t offset); + + int16_t + GetSignedInt16 (lldb::SBError& error, lldb::offset_t offset); + + int32_t + GetSignedInt32 (lldb::SBError& error, lldb::offset_t offset); + + int64_t + GetSignedInt64 (lldb::SBError& error, lldb::offset_t offset); + + const char* + GetString (lldb::SBError& error, lldb::offset_t offset); + + size_t + ReadRawData (lldb::SBError& error, + lldb::offset_t offset, + void *buf, + size_t size); + + bool + GetDescription (lldb::SBStream &description, lldb::addr_t base_addr = LLDB_INVALID_ADDRESS); + + // it would be nice to have SetData(SBError, const void*, size_t) when endianness and address size can be + // inferred from the existing DataExtractor, but having two SetData() signatures triggers a SWIG bug where + // the typemap isn't applied before resolving the overload, and thus the right function never gets called + void + SetData (lldb::SBError& error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size); + + // see SetData() for why we don't have Append(const void* buf, size_t size) + bool + Append (const SBData& rhs); + + static lldb::SBData + CreateDataFromCString (lldb::ByteOrder endian, uint32_t addr_byte_size, const char* data); + + // in the following CreateData*() and SetData*() prototypes, the two parameters array and array_len + // should not be renamed or rearranged, because doing so will break the SWIG typemap + static lldb::SBData + CreateDataFromUInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t* array, size_t array_len); + + static lldb::SBData + CreateDataFromUInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, uint32_t* array, size_t array_len); + + static lldb::SBData + CreateDataFromSInt64Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int64_t* array, size_t array_len); + + static lldb::SBData + CreateDataFromSInt32Array (lldb::ByteOrder endian, uint32_t addr_byte_size, int32_t* array, size_t array_len); + + static lldb::SBData + CreateDataFromDoubleArray (lldb::ByteOrder endian, uint32_t addr_byte_size, double* array, size_t array_len); + + bool + SetDataFromCString (const char* data); + + bool + SetDataFromUInt64Array (uint64_t* array, size_t array_len); + + bool + SetDataFromUInt32Array (uint32_t* array, size_t array_len); + + bool + SetDataFromSInt64Array (int64_t* array, size_t array_len); + + bool + SetDataFromSInt32Array (int32_t* array, size_t array_len); + + bool + SetDataFromDoubleArray (double* array, size_t array_len); + + +protected: + + // Mimic shared pointer... + lldb_private::DataExtractor * + get() const; + + lldb_private::DataExtractor * + operator->() const; + + lldb::DataExtractorSP & + operator*(); + + const lldb::DataExtractorSP & + operator*() const; + + SBData (const lldb::DataExtractorSP &data_sp); + + void + SetOpaque (const lldb::DataExtractorSP &data_sp); + +private: + friend class SBInstruction; + friend class SBProcess; + friend class SBSection; + friend class SBValue; + + lldb::DataExtractorSP m_opaque_sp; +}; + + +} // namespace lldb + +#endif // LLDB_SBData_h_ diff --git a/include/lldb/API/SBDebugger.h b/include/lldb/API/SBDebugger.h new file mode 100644 index 000000000000..518cbf67c932 --- /dev/null +++ b/include/lldb/API/SBDebugger.h @@ -0,0 +1,339 @@ +//===-- SBDebugger.h --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBDebugger_h_ +#define LLDB_SBDebugger_h_ + +#include "lldb/API/SBDefines.h" +#include <stdio.h> + +namespace lldb { + +class SBDebugger +{ +public: + + static void + Initialize(); + + static void + Terminate(); + + // Deprecated, use the one that takes a source_init_files bool. + static lldb::SBDebugger + Create(); + + static lldb::SBDebugger + Create(bool source_init_files); + + static lldb::SBDebugger + Create(bool source_init_files, lldb::LogOutputCallback log_callback, void *baton); + + static void + Destroy (lldb::SBDebugger &debugger); + + static void + MemoryPressureDetected (); + + SBDebugger(); + + SBDebugger(const lldb::SBDebugger &rhs); + + SBDebugger(const lldb::DebuggerSP &debugger_sp); + + lldb::SBDebugger & + operator = (const lldb::SBDebugger &rhs); + + ~SBDebugger(); + + bool + IsValid() const; + + void + Clear (); + + void + SetAsync (bool b); + + bool + GetAsync (); + + void + SkipLLDBInitFiles (bool b); + + void + SkipAppInitFiles (bool b); + + void + SetInputFileHandle (FILE *f, bool transfer_ownership); + + void + SetOutputFileHandle (FILE *f, bool transfer_ownership); + + void + SetErrorFileHandle (FILE *f, bool transfer_ownership); + + FILE * + GetInputFileHandle (); + + FILE * + GetOutputFileHandle (); + + FILE * + GetErrorFileHandle (); + + void + SaveInputTerminalState(); + + void + RestoreInputTerminalState(); + + lldb::SBCommandInterpreter + GetCommandInterpreter (); + + void + HandleCommand (const char *command); + + lldb::SBListener + GetListener (); + + void + HandleProcessEvent (const lldb::SBProcess &process, + const lldb::SBEvent &event, + FILE *out, + FILE *err); + + lldb::SBTarget + CreateTarget (const char *filename, + const char *target_triple, + const char *platform_name, + bool add_dependent_modules, + lldb::SBError& error); + + lldb::SBTarget + CreateTargetWithFileAndTargetTriple (const char *filename, + const char *target_triple); + + lldb::SBTarget + CreateTargetWithFileAndArch (const char *filename, + const char *archname); + + lldb::SBTarget + CreateTarget (const char *filename); + + // Return true if target is deleted from the target list of the debugger. + bool + DeleteTarget (lldb::SBTarget &target); + + lldb::SBTarget + GetTargetAtIndex (uint32_t idx); + + uint32_t + GetIndexOfTarget (lldb::SBTarget target); + + lldb::SBTarget + FindTargetWithProcessID (pid_t pid); + + lldb::SBTarget + FindTargetWithFileAndArch (const char *filename, + const char *arch); + + uint32_t + GetNumTargets (); + + lldb::SBTarget + GetSelectedTarget (); + + void + SetSelectedTarget (SBTarget& target); + + lldb::SBSourceManager + GetSourceManager (); + + // REMOVE: just for a quick fix, need to expose platforms through + // SBPlatform from this class. + lldb::SBError + SetCurrentPlatform (const char *platform_name); + + bool + SetCurrentPlatformSDKRoot (const char *sysroot); + + // FIXME: Once we get the set show stuff in place, the driver won't need + // an interface to the Set/Get UseExternalEditor. + bool + SetUseExternalEditor (bool input); + + bool + GetUseExternalEditor (); + + bool + SetUseColor (bool use_color); + + bool + GetUseColor () const; + + static bool + GetDefaultArchitecture (char *arch_name, size_t arch_name_len); + + static bool + SetDefaultArchitecture (const char *arch_name); + + lldb::ScriptLanguage + GetScriptingLanguage (const char *script_language_name); + + static const char * + GetVersionString (); + + static const char * + StateAsCString (lldb::StateType state); + + static bool + StateIsRunningState (lldb::StateType state); + + static bool + StateIsStoppedState (lldb::StateType state); + + bool + EnableLog (const char *channel, const char **categories); + + void + SetLoggingCallback (lldb::LogOutputCallback log_callback, void *baton); + + // DEPRECATED + void + DispatchInput (void* baton, + const void* data, + size_t data_len); + + void + DispatchInput (const void *data, size_t data_len); + + void + DispatchInputInterrupt (); + + void + DispatchInputEndOfFile (); + + void + PushInputReader (lldb::SBInputReader &reader); + + void + NotifyTopInputReader (lldb::InputReaderAction notification); + + bool + InputReaderIsTopReader (const lldb::SBInputReader &reader); + + const char * + GetInstanceName (); + + static SBDebugger + FindDebuggerWithID (int id); + + static lldb::SBError + SetInternalVariable (const char *var_name, const char *value, const char *debugger_instance_name); + + static lldb::SBStringList + GetInternalVariableValue (const char *var_name, const char *debugger_instance_name); + + bool + GetDescription (lldb::SBStream &description); + + uint32_t + GetTerminalWidth () const; + + void + SetTerminalWidth (uint32_t term_width); + + lldb::user_id_t + GetID (); + + const char * + GetPrompt() const; + + void + SetPrompt (const char *prompt); + + lldb::ScriptLanguage + GetScriptLanguage() const; + + void + SetScriptLanguage (lldb::ScriptLanguage script_lang); + + bool + GetCloseInputOnEOF () const; + + void + SetCloseInputOnEOF (bool b); + + SBTypeCategory + GetCategory (const char* category_name); + + SBTypeCategory + CreateCategory (const char* category_name); + + bool + DeleteCategory (const char* category_name); + + uint32_t + GetNumCategories (); + + SBTypeCategory + GetCategoryAtIndex (uint32_t); + + SBTypeCategory + GetDefaultCategory(); + + SBTypeFormat + GetFormatForType (SBTypeNameSpecifier); + +#ifndef LLDB_DISABLE_PYTHON + SBTypeSummary + GetSummaryForType (SBTypeNameSpecifier); +#endif + + SBTypeFilter + GetFilterForType (SBTypeNameSpecifier); + +#ifndef LLDB_DISABLE_PYTHON + SBTypeSynthetic + GetSyntheticForType (SBTypeNameSpecifier); +#endif + +private: + + friend class SBCommandInterpreter; + friend class SBInputReader; + friend class SBListener; + friend class SBProcess; + friend class SBSourceManager; + 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; + + const lldb::DebuggerSP & + get_sp () const; + + lldb::DebuggerSP m_opaque_sp; + +}; // class SBDebugger + + +} // namespace lldb + +#endif // LLDB_SBDebugger_h_ diff --git a/include/lldb/API/SBDeclaration.h b/include/lldb/API/SBDeclaration.h new file mode 100644 index 000000000000..190026c0d2d0 --- /dev/null +++ b/include/lldb/API/SBDeclaration.h @@ -0,0 +1,89 @@ +//===-- SBDeclaration.h -------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBDeclaration_h_ +#define LLDB_SBDeclaration_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBFileSpec.h" + +namespace lldb { + + class SBDeclaration + { + public: + + SBDeclaration (); + + SBDeclaration (const lldb::SBDeclaration &rhs); + + ~SBDeclaration (); + + const lldb::SBDeclaration & + operator = (const lldb::SBDeclaration &rhs); + + bool + IsValid () const; + + lldb::SBFileSpec + GetFileSpec () const; + + uint32_t + GetLine () const; + + uint32_t + GetColumn () const; + + void + SetFileSpec (lldb::SBFileSpec filespec); + + void + SetLine (uint32_t line); + + void + SetColumn (uint32_t column); + + bool + operator == (const lldb::SBDeclaration &rhs) const; + + bool + operator != (const lldb::SBDeclaration &rhs) const; + + bool + GetDescription (lldb::SBStream &description); + + protected: + + lldb_private::Declaration * + get (); + + private: + friend class SBValue; + + const lldb_private::Declaration * + operator->() const; + + lldb_private::Declaration & + ref(); + + const lldb_private::Declaration & + ref() const; + + SBDeclaration (const lldb_private::Declaration *lldb_object_ptr); + + void + SetDeclaration (const lldb_private::Declaration &lldb_object_ref); + + std::unique_ptr<lldb_private::Declaration> m_opaque_ap; + }; + + +} // namespace lldb + +#endif // LLDB_SBDeclaration_h_ diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h new file mode 100644 index 000000000000..2cdf92170d8d --- /dev/null +++ b/include/lldb/API/SBDefines.h @@ -0,0 +1,84 @@ +//===-- SBDefines.h ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBDefines_h_ +#define LLDB_SBDefines_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes + +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" +#include "lldb/lldb-versioning.h" + +// Forward Declarations + +namespace lldb { + +class SBAddress; +class SBBlock; +class SBBreakpoint; +class SBBreakpointLocation; +class SBBroadcaster; +class SBCommand; +class SBCommandInterpreter; +class SBCommandPluginInterface; +class SBCommandReturnObject; +class SBCommunication; +class SBCompileUnit; +class SBData; +class SBDebugger; +class SBDeclaration; +class SBError; +class SBEvent; +class SBEventList; +class SBExpressionOptions; +class SBFileSpec; +class SBFileSpecList; +class SBFrame; +class SBFunction; +class SBHostOS; +class SBInputReader; +class SBInstruction; +class SBInstructionList; +class SBLineEntry; +class SBListener; +class SBModule; +class SBModuleSpec; +class SBModuleSpecList; +class SBProcess; +class SBSourceManager; +class SBStream; +class SBStringList; +class SBSymbol; +class SBSymbolContext; +class SBSymbolContextList; +class SBTarget; +class SBThread; +class SBType; +class SBTypeCategory; +class SBTypeFilter; +class SBTypeFormat; +class SBTypeNameSpecifier; +class SBTypeSummary; +#ifndef LLDB_DISABLE_PYTHON +class SBTypeSynthetic; +#endif +class SBTypeList; +class SBValue; +class SBValueList; +class SBWatchpoint; + +} + +#endif // LLDB_SBDefines_h_ diff --git a/include/lldb/API/SBError.h b/include/lldb/API/SBError.h new file mode 100644 index 000000000000..a6d3dacb4549 --- /dev/null +++ b/include/lldb/API/SBError.h @@ -0,0 +1,106 @@ +//===-- SBError.h -----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBError_h_ +#define LLDB_SBError_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBError { +public: + SBError (); + + SBError (const lldb::SBError &rhs); + + ~SBError(); + + const SBError & + operator =(const lldb::SBError &rhs); + + const char * + GetCString () const; + + void + Clear (); + + bool + Fail () const; + + bool + Success () const; + + uint32_t + GetError () const; + + lldb::ErrorType + GetType () const; + + void + SetError (uint32_t err, lldb::ErrorType type); + + void + SetErrorToErrno (); + + void + SetErrorToGenericError (); + + void + SetErrorString (const char *err_str); + + int + SetErrorStringWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3))); + + bool + IsValid () const; + + bool + GetDescription (lldb::SBStream &description); + +protected: + + friend class SBCommandReturnObject; + friend class SBData; + friend class SBDebugger; + friend class SBCommunication; + friend class SBHostOS; + friend class SBInputReader; + friend class SBProcess; + friend class SBThread; + friend class SBTarget; + friend class SBValue; + friend class SBWatchpoint; + + lldb_private::Error * + get(); + + lldb_private::Error * + operator->(); + + const lldb_private::Error & + operator*() const; + + lldb_private::Error & + ref(); + + void + SetError (const lldb_private::Error &lldb_error); + +private: + std::unique_ptr<lldb_private::Error> m_opaque_ap; + + void + CreateIfNeeded (); +}; + + +} // namespace lldb + +#endif // LLDB_SBError_h_ diff --git a/include/lldb/API/SBEvent.h b/include/lldb/API/SBEvent.h new file mode 100644 index 000000000000..6cb975a1ff7b --- /dev/null +++ b/include/lldb/API/SBEvent.h @@ -0,0 +1,102 @@ +//===-- SBEvent.h -----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBEvent_h_ +#define LLDB_SBEvent_h_ + +#include "lldb/API/SBDefines.h" + +#include <stdio.h> +#include <vector> + + +namespace lldb { + +class SBBroadcaster; + +class SBEvent +{ +public: + SBEvent(); + + SBEvent (const lldb::SBEvent &rhs); + + // Make an event that contains a C string. + SBEvent (uint32_t event, const char *cstr, uint32_t cstr_len); + + ~SBEvent(); + + const SBEvent & + operator = (const lldb::SBEvent &rhs); + + bool + IsValid() const; + + const char * + GetDataFlavor (); + + uint32_t + GetType () const; + + lldb::SBBroadcaster + GetBroadcaster () const; + + const char * + GetBroadcasterClass () const; + + bool + BroadcasterMatchesPtr (const lldb::SBBroadcaster *broadcaster); + + bool + BroadcasterMatchesRef (const lldb::SBBroadcaster &broadcaster); + + void + Clear(); + + static const char * + GetCStringFromEvent (const lldb::SBEvent &event); + + bool + GetDescription (lldb::SBStream &description); + + bool + GetDescription (lldb::SBStream &description) const; + +protected: + friend class SBListener; + friend class SBBroadcaster; + friend class SBBreakpoint; + friend class SBDebugger; + friend class SBProcess; + friend class SBThread; + friend class SBWatchpoint; + + SBEvent (lldb::EventSP &event_sp); + + lldb::EventSP & + GetSP () const; + + void + reset (lldb::EventSP &event_sp); + + void + reset (lldb_private::Event* event); + + lldb_private::Event * + get () const; + +private: + + mutable lldb::EventSP m_event_sp; + mutable lldb_private::Event *m_opaque_ptr; +}; + +} // namespace lldb + +#endif // LLDB_SBEvent_h_ diff --git a/include/lldb/API/SBExpressionOptions.h b/include/lldb/API/SBExpressionOptions.h new file mode 100644 index 000000000000..eed9ed528bef --- /dev/null +++ b/include/lldb/API/SBExpressionOptions.h @@ -0,0 +1,89 @@ +//===-- SBEvent.h -----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBExpressionOptions_h_ +#define LLDB_SBExpressionOptions_h_ + +#include "lldb/API/SBDefines.h" + +#include <vector> + +namespace lldb { + + +class SBExpressionOptions +{ +public: + SBExpressionOptions(); + + SBExpressionOptions (const lldb::SBExpressionOptions &rhs); + + ~SBExpressionOptions(); + + const SBExpressionOptions & + operator = (const lldb::SBExpressionOptions &rhs); + + bool + GetCoerceResultToId () const; + + void + SetCoerceResultToId (bool coerce = true); + + bool + GetUnwindOnError () const; + + void + SetUnwindOnError (bool unwind = true); + + bool + GetIgnoreBreakpoints () const; + + void + SetIgnoreBreakpoints (bool ignore = true); + + lldb::DynamicValueType + GetFetchDynamicValue () const; + + void + SetFetchDynamicValue (lldb::DynamicValueType dynamic = lldb::eDynamicCanRunTarget); + + uint32_t + GetTimeoutInMicroSeconds () const; + + void + SetTimeoutInMicroSeconds (uint32_t timeout = 0); + + bool + GetTryAllThreads () const; + + void + SetTryAllThreads (bool run_others = true); + +protected: + + SBExpressionOptions (lldb_private::EvaluateExpressionOptions &expression_options); + + lldb_private::EvaluateExpressionOptions * + get () const; + + lldb_private::EvaluateExpressionOptions & + ref () const; + + friend class SBFrame; + friend class SBValue; + friend class SBTarget; + +private: + // This auto_pointer is made in the constructor and is always valid. + mutable std::unique_ptr<lldb_private::EvaluateExpressionOptions> m_opaque_ap; +}; + +} // namespace lldb + +#endif // LLDB_SBExpressionOptions_h_ diff --git a/include/lldb/API/SBFileSpec.h b/include/lldb/API/SBFileSpec.h new file mode 100644 index 000000000000..e44abe4759c6 --- /dev/null +++ b/include/lldb/API/SBFileSpec.h @@ -0,0 +1,96 @@ +//===-- SBFileSpec.h --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBFileSpec_h_ +#define LLDB_SBFileSpec_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBFileSpec +{ +public: + SBFileSpec (); + + SBFileSpec (const lldb::SBFileSpec &rhs); + + SBFileSpec (const char *path);// Deprected, use SBFileSpec (const char *path, bool resolve) + + SBFileSpec (const char *path, bool resolve); + + ~SBFileSpec (); + + const SBFileSpec & + operator = (const lldb::SBFileSpec &rhs); + + bool + IsValid() const; + + bool + Exists () const; + + bool + ResolveExecutableLocation (); + + const char * + GetFilename() const; + + const char * + GetDirectory() const; + + uint32_t + GetPath (char *dst_path, size_t dst_len) const; + + static int + ResolvePath (const char *src_path, char *dst_path, size_t dst_len); + + bool + GetDescription (lldb::SBStream &description) const; + +private: + friend class SBAttachInfo; + friend class SBBlock; + friend class SBCompileUnit; + friend class SBDeclaration; + friend class SBFileSpecList; + friend class SBHostOS; + friend class SBLaunchInfo; + friend class SBLineEntry; + friend class SBModule; + friend class SBModuleSpec; + friend class SBProcess; + friend class SBSourceManager; + friend class SBThread; + friend class SBTarget; + + SBFileSpec (const lldb_private::FileSpec& fspec); + + void + SetFileSpec (const lldb_private::FileSpec& fspec); + + const lldb_private::FileSpec * + operator->() const; + + const lldb_private::FileSpec * + get() const; + + const lldb_private::FileSpec & + operator*() const; + + const lldb_private::FileSpec & + ref() const; + + std::unique_ptr<lldb_private::FileSpec> m_opaque_ap; +}; + + +} // namespace lldb + +#endif // LLDB_SBFileSpec_h_ diff --git a/include/lldb/API/SBFileSpecList.h b/include/lldb/API/SBFileSpecList.h new file mode 100644 index 000000000000..734e7d4d35cc --- /dev/null +++ b/include/lldb/API/SBFileSpecList.h @@ -0,0 +1,72 @@ +//===-- SBFileSpecList.h --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBFileSpecList_h_ +#define LLDB_SBFileSpecList_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBFileSpecList +{ +public: + SBFileSpecList (); + + SBFileSpecList (const lldb::SBFileSpecList &rhs); + + ~SBFileSpecList (); + + const SBFileSpecList & + operator = (const lldb::SBFileSpecList &rhs); + + uint32_t + GetSize () const; + + bool + GetDescription (SBStream &description) const; + + void + Append (const SBFileSpec &sb_file); + + bool + AppendIfUnique (const SBFileSpec &sb_file); + + void + Clear(); + + uint32_t + FindFileIndex (uint32_t idx, const SBFileSpec &sb_file, bool full); + + const SBFileSpec + GetFileSpecAtIndex (uint32_t idx) const; + +private: + +friend class SBTarget; + + const lldb_private::FileSpecList * + operator->() const; + + const lldb_private::FileSpecList * + get() const; + + const lldb_private::FileSpecList & + operator*() const; + + const lldb_private::FileSpecList & + ref() const; + + std::unique_ptr<lldb_private::FileSpecList> m_opaque_ap; +}; + + +} // namespace lldb + +#endif // LLDB_SBFileSpecList_h_ diff --git a/include/lldb/API/SBFrame.h b/include/lldb/API/SBFrame.h new file mode 100644 index 000000000000..4ae38c13bede --- /dev/null +++ b/include/lldb/API/SBFrame.h @@ -0,0 +1,242 @@ +//===-- SBFrame.h -----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBFrame_h_ +#define LLDB_SBFrame_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBValueList.h" + +namespace lldb { + +class SBFrame +{ +public: + SBFrame (); + + SBFrame (const lldb::SBFrame &rhs); + + const lldb::SBFrame & + operator =(const lldb::SBFrame &rhs); + + ~SBFrame(); + + bool + IsEqual (const lldb::SBFrame &that) const; + + bool + IsValid() const; + + uint32_t + GetFrameID () const; + + lldb::addr_t + GetPC () const; + + bool + SetPC (lldb::addr_t new_pc); + + lldb::addr_t + GetSP () const; + + lldb::addr_t + GetFP () const; + + lldb::SBAddress + GetPCAddress () const; + + lldb::SBSymbolContext + GetSymbolContext (uint32_t resolve_scope) const; + + lldb::SBModule + GetModule () const; + + lldb::SBCompileUnit + GetCompileUnit () const; + + lldb::SBFunction + GetFunction () const; + + lldb::SBSymbol + GetSymbol () const; + + /// Gets the deepest block that contains the frame PC. + /// + /// See also GetFrameBlock(). + lldb::SBBlock + GetBlock () const; + + /// Get the appropriate function name for this frame. Inlined functions in + /// LLDB are represented by Blocks that have inlined function information, so + /// just looking at the SBFunction or SBSymbol for a frame isn't enough. + /// This function will return the appriopriate function, symbol or inlined + /// function name for the frame. + /// + /// This function returns: + /// - the name of the inlined function (if there is one) + /// - the name of the concrete function (if there is one) + /// - the name of the symbol (if there is one) + /// - NULL + /// + /// See also IsInlined(). + const char * + GetFunctionName(); + + /// Return true if this frame represents an inlined function. + /// + /// See also GetFunctionName(). + bool + IsInlined(); + + /// The version that doesn't supply a 'use_dynamic' value will use the + /// target's default. + lldb::SBValue + EvaluateExpression (const char *expr); + + lldb::SBValue + EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic); + + lldb::SBValue + EvaluateExpression (const char *expr, lldb::DynamicValueType use_dynamic, bool unwind_on_error); + + lldb::SBValue + EvaluateExpression (const char *expr, const SBExpressionOptions &options); + + /// Gets the lexical block that defines the stack frame. Another way to think + /// of this is it will return the block that contains all of the variables + /// for a stack frame. Inlined functions are represented as SBBlock objects + /// that have inlined function information: the name of the inlined function, + /// where it was called from. The block that is returned will be the first + /// block at or above the block for the PC (SBFrame::GetBlock()) that defines + /// the scope of the frame. When a function contains no inlined functions, + /// this will be the top most lexical block that defines the function. + /// When a function has inlined functions and the PC is currently + /// in one of those inlined functions, this method will return the inlined + /// block that defines this frame. If the PC isn't currently in an inlined + /// function, the lexical block that defines the function is returned. + lldb::SBBlock + GetFrameBlock () const; + + lldb::SBLineEntry + GetLineEntry () const; + + lldb::SBThread + GetThread () const; + + const char * + Disassemble () const; + + void + Clear(); + + bool + operator == (const lldb::SBFrame &rhs) const; + + bool + operator != (const lldb::SBFrame &rhs) const; + + /// The version that doesn't supply a 'use_dynamic' value will use the + /// target's default. + lldb::SBValueList + GetVariables (bool arguments, + bool locals, + bool statics, + bool in_scope_only); + + lldb::SBValueList + GetVariables (bool arguments, + bool locals, + bool statics, + bool in_scope_only, + lldb::DynamicValueType use_dynamic); + + lldb::SBValueList + GetRegisters (); + + lldb::SBValue + FindRegister (const char *name); + + /// The version that doesn't supply a 'use_dynamic' value will use the + /// target's default. + lldb::SBValue + FindVariable (const char *var_name); + + lldb::SBValue + FindVariable (const char *var_name, lldb::DynamicValueType use_dynamic); + + // Find a value for a variable expression path like "rect.origin.x" or + // "pt_ptr->x", "*self", "*this->obj_ptr". The returned value is _not_ + // and expression result and is not a constant object like + // SBFrame::EvaluateExpression(...) returns, but a child object of + // the variable value. + lldb::SBValue + GetValueForVariablePath (const char *var_expr_cstr, + DynamicValueType use_dynamic); + + /// The version that doesn't supply a 'use_dynamic' value will use the + /// target's default. + lldb::SBValue + GetValueForVariablePath (const char *var_path); + + /// Find variables, register sets, registers, or persistent variables using + /// the frame as the scope. + /// + /// NB. This function does not look up ivars in the function object pointer. + /// To do that use GetValueForVariablePath. + /// + /// The version that doesn't supply a 'use_dynamic' value will use the + /// target's default. + lldb::SBValue + FindValue (const char *name, ValueType value_type); + + lldb::SBValue + FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic); + + /// Find and watch a variable using the frame as the scope. + /// It returns an SBValue, similar to FindValue() method, if find-and-watch + /// operation succeeds. Otherwise, an invalid SBValue is returned. + /// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. + lldb::SBValue + WatchValue (const char *name, ValueType value_type, uint32_t watch_type); + + /// Find and watch the location pointed to by a variable using the frame as + /// the scope. + /// It returns an SBValue, similar to FindValue() method, if find-and-watch + /// operation succeeds. Otherwise, an invalid SBValue is returned. + /// You can use LLDB_WATCH_TYPE_READ | LLDB_WATCH_TYPE_WRITE for 'rw' watch. + lldb::SBValue + WatchLocation (const char *name, ValueType value_type, uint32_t watch_type, size_t size); + + bool + GetDescription (lldb::SBStream &description); + + SBFrame (const lldb::StackFrameSP &lldb_object_sp); + +protected: + + friend class SBBlock; + friend class SBInstruction; + friend class SBThread; + friend class SBValue; +#ifndef LLDB_DISABLE_PYTHON + friend class lldb_private::ScriptInterpreterPython; +#endif + + lldb::StackFrameSP + GetFrameSP() const; + + void + SetFrameSP (const lldb::StackFrameSP &lldb_object_sp); + + lldb::ExecutionContextRefSP m_opaque_sp; +}; + +} // namespace lldb + +#endif // LLDB_SBFrame_h_ diff --git a/include/lldb/API/SBFunction.h b/include/lldb/API/SBFunction.h new file mode 100644 index 000000000000..49a3847efbec --- /dev/null +++ b/include/lldb/API/SBFunction.h @@ -0,0 +1,93 @@ +//===-- SBFunction.h --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBFunction_h_ +#define LLDB_SBFunction_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBInstructionList.h" + +namespace lldb { + +class SBFunction +{ +public: + + SBFunction (); + + SBFunction (const lldb::SBFunction &rhs); + + const lldb::SBFunction & + operator = (const lldb::SBFunction &rhs); + + ~SBFunction (); + + bool + IsValid () const; + + const char * + GetName() const; + + const char * + GetMangledName () const; + + lldb::SBInstructionList + GetInstructions (lldb::SBTarget target); + + lldb::SBInstructionList + GetInstructions (lldb::SBTarget target, const char *flavor); + + lldb::SBAddress + GetStartAddress (); + + lldb::SBAddress + GetEndAddress (); + + uint32_t + GetPrologueByteSize (); + + lldb::SBType + GetType (); + + lldb::SBBlock + GetBlock (); + + bool + operator == (const lldb::SBFunction &rhs) const; + + bool + operator != (const lldb::SBFunction &rhs) const; + + bool + GetDescription (lldb::SBStream &description); + +protected: + + lldb_private::Function * + get (); + + void + reset (lldb_private::Function *lldb_object_ptr); + +private: + friend class SBAddress; + friend class SBFrame; + friend class SBSymbolContext; + + SBFunction (lldb_private::Function *lldb_object_ptr); + + + lldb_private::Function *m_opaque_ptr; +}; + + +} // namespace lldb + +#endif // LLDB_SBFunction_h_ diff --git a/include/lldb/API/SBHostOS.h b/include/lldb/API/SBHostOS.h new file mode 100644 index 000000000000..52754ea4e829 --- /dev/null +++ b/include/lldb/API/SBHostOS.h @@ -0,0 +1,57 @@ +//===-- SBHostOS.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBHostOS_h_ +#define LLDB_SBHostOS_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBFileSpec.h" + +namespace lldb { + +class SBHostOS +{ +public: + + static lldb::SBFileSpec + GetProgramFileSpec (); + + static lldb::SBFileSpec + GetLLDBPythonPath (); + + static void + ThreadCreated (const char *name); + + static lldb::thread_t + ThreadCreate (const char *name, + void *(*thread_function)(void *), + void *thread_arg, + lldb::SBError *err); + + static bool + ThreadCancel (lldb::thread_t thread, + lldb::SBError *err); + + static bool + ThreadDetach (lldb::thread_t thread, + lldb::SBError *err); + static bool + ThreadJoin (lldb::thread_t thread, + void **result, + lldb::SBError *err); + + +private: + +}; + + +} // namespace lldb + +#endif // LLDB_SBHostOS_h_ diff --git a/include/lldb/API/SBInputReader.h b/include/lldb/API/SBInputReader.h new file mode 100644 index 000000000000..61f7de4fde4c --- /dev/null +++ b/include/lldb/API/SBInputReader.h @@ -0,0 +1,97 @@ +//===-- SBInputReader.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBInputReader_h_ +#define LLDB_SBInputReader_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBInputReader +{ +public: + + typedef size_t (*Callback) (void *baton, + SBInputReader *reader, + InputReaderAction notification, + const char *bytes, + size_t bytes_len); + + SBInputReader (); + + SBInputReader (const lldb::InputReaderSP &reader_sp); + + SBInputReader (const lldb::SBInputReader &rhs); + + ~SBInputReader (); + + + SBError + Initialize (SBDebugger &debugger, + Callback callback, + void *callback_baton, + lldb::InputReaderGranularity granularity, + const char *end_token, + const char *prompt, + bool echo); + + bool + IsValid () const; + + const lldb::SBInputReader & + operator = (const lldb::SBInputReader &rhs); + + bool + IsActive () const; + + bool + IsDone () const; + + void + SetIsDone (bool value); + + InputReaderGranularity + GetGranularity (); + +protected: + friend class SBDebugger; + + lldb_private::InputReader * + operator->() const; + + lldb::InputReaderSP & + operator *(); + + const lldb::InputReaderSP & + operator *() const; + + lldb_private::InputReader * + get() const; + + lldb_private::InputReader & + ref() const; + +private: + + static size_t + PrivateCallback (void *baton, + lldb_private::InputReader &reader, + lldb::InputReaderAction notification, + const char *bytes, + size_t bytes_len); + + lldb::InputReaderSP m_opaque_sp; + Callback m_callback_function; + void *m_callback_baton; +}; + +} // namespace lldb + +#endif // LLDB_SBInputReader_h_ diff --git a/include/lldb/API/SBInstruction.h b/include/lldb/API/SBInstruction.h new file mode 100644 index 000000000000..aad2d87f4f33 --- /dev/null +++ b/include/lldb/API/SBInstruction.h @@ -0,0 +1,94 @@ +//===-- SBInstruction.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBInstruction_h_ +#define LLDB_SBInstruction_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBData.h" + +#include <stdio.h> + +// There's a lot to be fixed here, but need to wait for underlying insn implementation +// to be revised & settle down first. + +namespace lldb { + +class SBInstruction +{ +public: + + SBInstruction (); + + SBInstruction (const SBInstruction &rhs); + + const SBInstruction & + operator = (const SBInstruction &rhs); + + ~SBInstruction (); + + bool + IsValid(); + + SBAddress + GetAddress(); + + lldb::AddressClass + GetAddressClass (); + + const char * + GetMnemonic (lldb::SBTarget target); + + const char * + GetOperands (lldb::SBTarget target); + + const char * + GetComment (lldb::SBTarget target); + + lldb::SBData + GetData (lldb::SBTarget target); + + size_t + GetByteSize (); + + bool + DoesBranch (); + + void + Print (FILE *out); + + bool + GetDescription (lldb::SBStream &description); + + bool + EmulateWithFrame (lldb::SBFrame &frame, uint32_t evaluate_options); + + bool + DumpEmulation (const char * triple); // triple is to specify the architecture, e.g. 'armv6' or 'armv7-apple-ios' + + bool + TestEmulation (lldb::SBStream &output_stream, const char *test_file); + +protected: + friend class SBInstructionList; + + SBInstruction (const lldb::InstructionSP &inst_sp); + + void + SetOpaque (const lldb::InstructionSP &inst_sp); + +private: + + lldb::InstructionSP m_opaque_sp; +}; + + +} // namespace lldb + +#endif // LLDB_SBInstruction_h_ diff --git a/include/lldb/API/SBInstructionList.h b/include/lldb/API/SBInstructionList.h new file mode 100644 index 000000000000..944e144a1480 --- /dev/null +++ b/include/lldb/API/SBInstructionList.h @@ -0,0 +1,71 @@ +//===-- SBInstructionList.h -------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBInstructionList_h_ +#define LLDB_SBInstructionList_h_ + +#include "lldb/API/SBDefines.h" + +#include <stdio.h> + +namespace lldb { + +class SBInstructionList +{ +public: + + SBInstructionList (); + + SBInstructionList (const SBInstructionList &rhs); + + const SBInstructionList & + operator = (const SBInstructionList &rhs); + + ~SBInstructionList (); + + bool + IsValid () const; + + size_t + GetSize (); + + lldb::SBInstruction + GetInstructionAtIndex (uint32_t idx); + + void + Clear (); + + void + AppendInstruction (lldb::SBInstruction inst); + + void + Print (FILE *out); + + bool + GetDescription (lldb::SBStream &description); + + bool + DumpEmulationForAllInstructions (const char *triple); + +protected: + friend class SBFunction; + friend class SBSymbol; + friend class SBTarget; + + void + SetDisassembler (const lldb::DisassemblerSP &opaque_sp); + +private: + lldb::DisassemblerSP m_opaque_sp; +}; + + +} // namespace lldb + +#endif // LLDB_SBInstructionList_h_ diff --git a/include/lldb/API/SBLineEntry.h b/include/lldb/API/SBLineEntry.h new file mode 100644 index 000000000000..2d099a297980 --- /dev/null +++ b/include/lldb/API/SBLineEntry.h @@ -0,0 +1,99 @@ +//===-- SBLineEntry.h -------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBLineEntry_h_ +#define LLDB_SBLineEntry_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBFileSpec.h" + +namespace lldb { + +class SBLineEntry +{ +public: + + SBLineEntry (); + + SBLineEntry (const lldb::SBLineEntry &rhs); + + ~SBLineEntry (); + + const lldb::SBLineEntry & + operator = (const lldb::SBLineEntry &rhs); + + lldb::SBAddress + GetStartAddress () const; + + lldb::SBAddress + GetEndAddress () const; + + bool + IsValid () const; + + lldb::SBFileSpec + GetFileSpec () const; + + uint32_t + GetLine () const; + + uint32_t + GetColumn () const; + + void + SetFileSpec (lldb::SBFileSpec filespec); + + void + SetLine (uint32_t line); + + void + SetColumn (uint32_t column); + + bool + operator == (const lldb::SBLineEntry &rhs) const; + + bool + operator != (const lldb::SBLineEntry &rhs) const; + + bool + GetDescription (lldb::SBStream &description); + +protected: + + lldb_private::LineEntry * + get (); + +private: + friend class SBAddress; + friend class SBCompileUnit; + friend class SBFrame; + friend class SBSymbolContext; + + const lldb_private::LineEntry * + operator->() const; + + lldb_private::LineEntry & + ref(); + + const lldb_private::LineEntry & + ref() const; + + SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr); + + void + SetLineEntry (const lldb_private::LineEntry &lldb_object_ref); + + std::unique_ptr<lldb_private::LineEntry> m_opaque_ap; +}; + + +} // namespace lldb + +#endif // LLDB_SBLineEntry_h_ diff --git a/include/lldb/API/SBListener.h b/include/lldb/API/SBListener.h new file mode 100644 index 000000000000..c5a047341741 --- /dev/null +++ b/include/lldb/API/SBListener.h @@ -0,0 +1,135 @@ +//===-- SBListener.h --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBListener_h_ +#define LLDB_SBListener_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBListener +{ +public: + SBListener (); + + SBListener (const char *name); + + SBListener (const SBListener &rhs); + + ~SBListener (); + + const lldb::SBListener & + operator = (const lldb::SBListener &rhs); + + void + AddEvent (const lldb::SBEvent &event); + + void + Clear (); + + bool + IsValid () const; + + uint32_t + StartListeningForEventClass (SBDebugger &debugger, + const char *broadcaster_class, + uint32_t event_mask); + + bool + StopListeningForEventClass (SBDebugger &debugger, + const char *broadcaster_class, + uint32_t event_mask); + + uint32_t + StartListeningForEvents (const lldb::SBBroadcaster& broadcaster, + uint32_t event_mask); + + bool + StopListeningForEvents (const lldb::SBBroadcaster& broadcaster, + uint32_t event_mask); + + // Returns true if an event was recieved, false if we timed out. + bool + WaitForEvent (uint32_t num_seconds, + lldb::SBEvent &event); + + bool + WaitForEventForBroadcaster (uint32_t num_seconds, + const lldb::SBBroadcaster &broadcaster, + lldb::SBEvent &sb_event); + + bool + WaitForEventForBroadcasterWithType (uint32_t num_seconds, + const lldb::SBBroadcaster &broadcaster, + uint32_t event_type_mask, + lldb::SBEvent &sb_event); + + bool + PeekAtNextEvent (lldb::SBEvent &sb_event); + + bool + PeekAtNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster, + lldb::SBEvent &sb_event); + + bool + PeekAtNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster, + uint32_t event_type_mask, + lldb::SBEvent &sb_event); + + bool + GetNextEvent (lldb::SBEvent &sb_event); + + bool + GetNextEventForBroadcaster (const lldb::SBBroadcaster &broadcaster, + lldb::SBEvent &sb_event); + + bool + GetNextEventForBroadcasterWithType (const lldb::SBBroadcaster &broadcaster, + uint32_t event_type_mask, + lldb::SBEvent &sb_event); + + bool + HandleBroadcastEvent (const lldb::SBEvent &event); + +protected: + friend class SBBroadcaster; + friend class SBCommandInterpreter; + friend class SBDebugger; + friend class SBTarget; + + SBListener (lldb_private::Listener &listener); + +private: + + lldb_private::Listener * + operator->() const; + + lldb_private::Listener * + get() const; + + lldb_private::Listener & + ref() const; + + lldb_private::Listener & + operator *(); + + const lldb_private::Listener & + operator *() const; + + void + reset(lldb_private::Listener *listener, bool transfer_ownership); + + lldb::ListenerSP m_opaque_sp; + lldb_private::Listener *m_opaque_ptr; +}; + +} // namespace lldb + +#endif // LLDB_SBListener_h_ diff --git a/include/lldb/API/SBModule.h b/include/lldb/API/SBModule.h new file mode 100644 index 000000000000..a3c4879aa2f9 --- /dev/null +++ b/include/lldb/API/SBModule.h @@ -0,0 +1,287 @@ +//===-- SBModule.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBModule_h_ +#define LLDB_SBModule_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBSection.h" +#include "lldb/API/SBSymbolContext.h" +#include "lldb/API/SBValueList.h" + +namespace lldb { + +class SBModule +{ +public: + + SBModule (); + + SBModule (const SBModule &rhs); + + SBModule (const SBModuleSpec &module_spec); + + const SBModule & + operator = (const SBModule &rhs); + + SBModule (lldb::SBProcess &process, + lldb::addr_t header_addr); + + ~SBModule (); + + bool + IsValid () const; + + void + Clear(); + + //------------------------------------------------------------------ + /// Get const accessor for the module file specification. + /// + /// This function returns the file for the module on the host system + /// that is running LLDB. This can differ from the path on the + /// platform since we might be doing remote debugging. + /// + /// @return + /// A const reference to the file specification object. + //------------------------------------------------------------------ + lldb::SBFileSpec + GetFileSpec () const; + + //------------------------------------------------------------------ + /// Get accessor for the module platform file specification. + /// + /// Platform file refers to the path of the module as it is known on + /// the remote system on which it is being debugged. For local + /// debugging this is always the same as Module::GetFileSpec(). But + /// remote debugging might mention a file '/usr/lib/liba.dylib' + /// which might be locally downloaded and cached. In this case the + /// platform file could be something like: + /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib' + /// The file could also be cached in a local developer kit directory. + /// + /// @return + /// A const reference to the file specification object. + //------------------------------------------------------------------ + lldb::SBFileSpec + GetPlatformFileSpec () const; + + bool + SetPlatformFileSpec (const lldb::SBFileSpec &platform_file); + + lldb::ByteOrder + GetByteOrder (); + + uint32_t + GetAddressByteSize(); + + const char * + GetTriple (); + + const uint8_t * + GetUUIDBytes () const; + + const char * + GetUUIDString () const; + + bool + operator == (const lldb::SBModule &rhs) const; + + bool + operator != (const lldb::SBModule &rhs) const; + + lldb::SBSection + FindSection (const char *sect_name); + + lldb::SBAddress + ResolveFileAddress (lldb::addr_t vm_addr); + + lldb::SBSymbolContext + ResolveSymbolContextForAddress (const lldb::SBAddress& addr, + uint32_t resolve_scope); + + bool + GetDescription (lldb::SBStream &description); + + uint32_t + GetNumCompileUnits(); + + lldb::SBCompileUnit + GetCompileUnitAtIndex (uint32_t); + + size_t + GetNumSymbols (); + + lldb::SBSymbol + GetSymbolAtIndex (size_t idx); + + lldb::SBSymbol + FindSymbol (const char *name, + lldb::SymbolType type = eSymbolTypeAny); + + lldb::SBSymbolContextList + FindSymbols (const char *name, + lldb::SymbolType type = eSymbolTypeAny); + + size_t + GetNumSections (); + + lldb::SBSection + GetSectionAtIndex (size_t idx); + //------------------------------------------------------------------ + /// Find functions by name. + /// + /// @param[in] name + /// The name of the function we are looking for. + /// + /// @param[in] name_type_mask + /// A logical OR of one or more FunctionNameType enum bits that + /// indicate what kind of names should be used when doing the + /// lookup. Bits include fully qualified names, base names, + /// C++ methods, or ObjC selectors. + /// See FunctionNameType for more details. + /// + /// @return + /// A lldb::SBSymbolContextList that gets filled in with all of + /// the symbol contexts for all the matches. + //------------------------------------------------------------------ + lldb::SBSymbolContextList + FindFunctions (const char *name, + uint32_t name_type_mask = lldb::eFunctionNameTypeAny); + + //------------------------------------------------------------------ + /// Find global and static variables by name. + /// + /// @param[in] target + /// A valid SBTarget instance representing the debuggee. + /// + /// @param[in] name + /// The name of the global or static variable we are looking + /// for. + /// + /// @param[in] max_matches + /// Allow the number of matches to be limited to \a max_matches. + /// + /// @return + /// A list of matched variables in an SBValueList. + //------------------------------------------------------------------ + lldb::SBValueList + FindGlobalVariables (lldb::SBTarget &target, + const char *name, + uint32_t max_matches); + + //------------------------------------------------------------------ + /// Find the first global (or static) variable by name. + /// + /// @param[in] target + /// A valid SBTarget instance representing the debuggee. + /// + /// @param[in] name + /// The name of the global or static variable we are looking + /// for. + /// + /// @return + /// An SBValue that gets filled in with the found variable (if any). + //------------------------------------------------------------------ + lldb::SBValue + FindFirstGlobalVariable (lldb::SBTarget &target, const char *name); + + lldb::SBType + FindFirstType (const char* name); + + lldb::SBTypeList + FindTypes (const char* type); + + lldb::SBType + GetBasicType(lldb::BasicType type); + + //------------------------------------------------------------------ + /// Get all types matching \a type_mask from debug info in this + /// module. + /// + /// @param[in] type_mask + /// A bitfield that consists of one or more bits logically OR'ed + /// together from the lldb::TypeClass enumeration. This allows + /// you to request only structure types, or only class, struct + /// and union types. Passing in lldb::eTypeClassAny will return + /// all types found in the debug information for this module. + /// + /// @return + /// A list of types in this module that match \a type_mask + //------------------------------------------------------------------ + lldb::SBTypeList + GetTypes (uint32_t type_mask = lldb::eTypeClassAny); + + //------------------------------------------------------------------ + /// Get the module version numbers. + /// + /// Many object files have a set of version numbers that describe + /// the version of the executable or shared library. Typically there + /// are major, minor and build, but there may be more. This function + /// will extract the versions from object files if they are available. + /// + /// If \a versions is NULL, or if \a num_versions is 0, the return + /// value will indicate how many version numbers are available in + /// this object file. Then a subsequent call can be made to this + /// function with a value of \a versions and \a num_versions that + /// has enough storage to store some or all version numbers. + /// + /// @param[out] versions + /// A pointer to an array of uint32_t types that is \a num_versions + /// long. If this value is NULL, the return value will indicate + /// how many version numbers are required for a subsequent call + /// to this function so that all versions can be retrieved. If + /// the value is non-NULL, then at most \a num_versions of the + /// existing versions numbers will be filled into \a versions. + /// If there is no version information available, \a versions + /// will be filled with \a num_versions UINT32_MAX values + /// and zero will be returned. + /// + /// @param[in] num_versions + /// The maximum number of entries to fill into \a versions. If + /// this value is zero, then the return value will indicate + /// how many version numbers there are in total so another call + /// to this function can be make with adequate storage in + /// \a versions to get all of the version numbers. If \a + /// num_versions is less than the actual number of version + /// numbers in this object file, only \a num_versions will be + /// filled into \a versions (if \a versions is non-NULL). + /// + /// @return + /// This function always returns the number of version numbers + /// that this object file has regardless of the number of + /// version numbers that were copied into \a versions. + //------------------------------------------------------------------ + uint32_t + GetVersion (uint32_t *versions, + uint32_t num_versions); + +private: + friend class SBAddress; + friend class SBFrame; + friend class SBSection; + friend class SBSymbolContext; + friend class SBTarget; + + explicit SBModule (const lldb::ModuleSP& module_sp); + + ModuleSP + GetSP () const; + + void + SetSP (const ModuleSP &module_sp); + + lldb::ModuleSP m_opaque_sp; +}; + + +} // namespace lldb + +#endif // LLDB_SBModule_h_ diff --git a/include/lldb/API/SBModuleSpec.h b/include/lldb/API/SBModuleSpec.h new file mode 100644 index 000000000000..a615e017cbc8 --- /dev/null +++ b/include/lldb/API/SBModuleSpec.h @@ -0,0 +1,154 @@ +//===-- SBModuleSpec.h ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBModuleSpec_h_ +#define LLDB_SBModuleSpec_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBFileSpec.h" + +namespace lldb { + +class SBModuleSpec +{ +public: + + SBModuleSpec (); + + SBModuleSpec (const SBModuleSpec &rhs); + + ~SBModuleSpec (); + + const SBModuleSpec & + operator = (const SBModuleSpec &rhs); + + bool + IsValid () const; + + void + Clear(); + + //------------------------------------------------------------------ + /// Get const accessor for the module file. + /// + /// This function returns the file for the module on the host system + /// that is running LLDB. This can differ from the path on the + /// platform since we might be doing remote debugging. + /// + /// @return + /// A const reference to the file specification object. + //------------------------------------------------------------------ + lldb::SBFileSpec + GetFileSpec (); + + void + SetFileSpec (const lldb::SBFileSpec &fspec); + + //------------------------------------------------------------------ + /// Get accessor for the module platform file. + /// + /// Platform file refers to the path of the module as it is known on + /// the remote system on which it is being debugged. For local + /// debugging this is always the same as Module::GetFileSpec(). But + /// remote debugging might mention a file '/usr/lib/liba.dylib' + /// which might be locally downloaded and cached. In this case the + /// platform file could be something like: + /// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib' + /// The file could also be cached in a local developer kit directory. + /// + /// @return + /// A const reference to the file specification object. + //------------------------------------------------------------------ + lldb::SBFileSpec + GetPlatformFileSpec (); + + void + SetPlatformFileSpec (const lldb::SBFileSpec &fspec); + + lldb::SBFileSpec + GetSymbolFileSpec (); + + void + SetSymbolFileSpec (const lldb::SBFileSpec &fspec); + + const char * + GetObjectName (); + + void + SetObjectName (const char *name); + + const char * + GetTriple (); + + void + SetTriple (const char *triple); + + const uint8_t * + GetUUIDBytes (); + + size_t + GetUUIDLength (); + + bool + SetUUIDBytes (const uint8_t *uuid, size_t uuid_len); + + bool + GetDescription (lldb::SBStream &description); + +private: + friend class SBModuleSpecList; + friend class SBModule; + friend class SBTarget; + + std::unique_ptr<lldb_private::ModuleSpec> m_opaque_ap; +}; + +class SBModuleSpecList +{ +public: + SBModuleSpecList(); + + SBModuleSpecList (const SBModuleSpecList &rhs); + + ~SBModuleSpecList(); + + SBModuleSpecList & + operator = (const SBModuleSpecList &rhs); + + static SBModuleSpecList + GetModuleSpecifications (const char *path); + + void + Append (const SBModuleSpec &spec); + + void + Append (const SBModuleSpecList &spec_list); + + SBModuleSpec + FindFirstMatchingSpec (const SBModuleSpec &match_spec); + + SBModuleSpecList + FindMatchingSpecs (const SBModuleSpec &match_spec); + + size_t + GetSize(); + + SBModuleSpec + GetSpecAtIndex (size_t i); + + bool + GetDescription (lldb::SBStream &description); + +private: + std::unique_ptr<lldb_private::ModuleSpecList> m_opaque_ap; +}; + +} // namespace lldb + +#endif // LLDB_SBModuleSpec_h_ diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h new file mode 100644 index 000000000000..784f362122a9 --- /dev/null +++ b/include/lldb/API/SBProcess.h @@ -0,0 +1,295 @@ +//===-- SBProcess.h ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBProcess_h_ +#define LLDB_SBProcess_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBTarget.h" +#include <stdio.h> + +namespace lldb { + +class SBEvent; + +class SBProcess +{ +public: + //------------------------------------------------------------------ + /// Broadcaster event bits definitions. + //------------------------------------------------------------------ + enum + { + eBroadcastBitStateChanged = (1 << 0), + eBroadcastBitInterrupt = (1 << 1), + eBroadcastBitSTDOUT = (1 << 2), + eBroadcastBitSTDERR = (1 << 3), + eBroadcastBitProfileData = (1 << 4) + }; + + SBProcess (); + + SBProcess (const lldb::SBProcess& rhs); + + const lldb::SBProcess& + operator = (const lldb::SBProcess& rhs); + + SBProcess (const lldb::ProcessSP &process_sp); + + ~SBProcess(); + + static const char * + GetBroadcasterClassName (); + + const char * + GetPluginName (); + + // DEPRECATED: use GetPluginName() + const char * + GetShortPluginName (); + + void + Clear (); + + bool + IsValid() const; + + lldb::SBTarget + GetTarget() const; + + lldb::ByteOrder + GetByteOrder() const; + + size_t + PutSTDIN (const char *src, size_t src_len); + + size_t + GetSTDOUT (char *dst, size_t dst_len) const; + + size_t + GetSTDERR (char *dst, size_t dst_len) const; + + size_t + GetAsyncProfileData(char *dst, size_t dst_len) const; + + void + ReportEventState (const lldb::SBEvent &event, FILE *out) const; + + void + AppendEventStateReport (const lldb::SBEvent &event, lldb::SBCommandReturnObject &result); + + //------------------------------------------------------------------ + /// Remote connection related functions. These will fail if the + /// process is not in eStateConnected. They are intended for use + /// when connecting to an externally managed debugserver instance. + //------------------------------------------------------------------ + bool + RemoteAttachToProcessWithID (lldb::pid_t pid, + lldb::SBError& error); + + bool + RemoteLaunch (char const **argv, + char const **envp, + const char *stdin_path, + const char *stdout_path, + const char *stderr_path, + const char *working_directory, + uint32_t launch_flags, + bool stop_at_entry, + lldb::SBError& error); + + //------------------------------------------------------------------ + // Thread related functions + //------------------------------------------------------------------ + uint32_t + GetNumThreads (); + + lldb::SBThread + GetThreadAtIndex (size_t index); + + lldb::SBThread + GetThreadByID (lldb::tid_t sb_thread_id); + + lldb::SBThread + GetThreadByIndexID (uint32_t index_id); + + lldb::SBThread + GetSelectedThread () const; + + //------------------------------------------------------------------ + // Function for lazily creating a thread using the current OS + // plug-in. This function will be removed in the future when there + // are APIs to create SBThread objects through the interface and add + // them to the process through the SBProcess API. + //------------------------------------------------------------------ + lldb::SBThread + CreateOSPluginThread (lldb::tid_t tid, lldb::addr_t context); + + bool + SetSelectedThread (const lldb::SBThread &thread); + + bool + SetSelectedThreadByID (lldb::tid_t tid); + + bool + SetSelectedThreadByIndexID (uint32_t index_id); + + //------------------------------------------------------------------ + // Stepping related functions + //------------------------------------------------------------------ + + lldb::StateType + GetState (); + + int + GetExitStatus (); + + const char * + GetExitDescription (); + + //------------------------------------------------------------------ + /// Gets the process ID + /// + /// Returns the process identifier for the process as it is known + /// on the system on which the process is running. For unix systems + /// this is typically the same as if you called "getpid()" in the + /// process. + /// + /// @return + /// Returns LLDB_INVALID_PROCESS_ID if this object does not + /// contain a valid process object, or if the process has not + /// been launched. Returns a valid process ID if the process is + /// valid. + //------------------------------------------------------------------ + lldb::pid_t + GetProcessID (); + + //------------------------------------------------------------------ + /// Gets the unique ID associated with this process object + /// + /// Unique IDs start at 1 and increment up with each new process + /// instance. Since starting a process on a system might always + /// create a process with the same process ID, there needs to be a + /// way to tell two process instances apart. + /// + /// @return + /// Returns a non-zero integer ID if this object contains a + /// valid process object, zero if this object does not contain + /// a valid process object. + //------------------------------------------------------------------ + uint32_t + GetUniqueID(); + + uint32_t + GetAddressByteSize() const; + + lldb::SBError + Destroy (); + + lldb::SBError + Continue (); + + lldb::SBError + Stop (); + + lldb::SBError + Kill (); + + lldb::SBError + Detach (); + + lldb::SBError + Detach (bool keep_stopped); + + lldb::SBError + Signal (int signal); + + void + SendAsyncInterrupt(); + + uint32_t + GetStopID(bool include_expression_stops = false); + + size_t + ReadMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); + + size_t + WriteMemory (addr_t addr, const void *buf, size_t size, lldb::SBError &error); + + size_t + ReadCStringFromMemory (addr_t addr, void *buf, size_t size, lldb::SBError &error); + + uint64_t + ReadUnsignedFromMemory (addr_t addr, uint32_t byte_size, lldb::SBError &error); + + lldb::addr_t + ReadPointerFromMemory (addr_t addr, lldb::SBError &error); + + // Events + static lldb::StateType + GetStateFromEvent (const lldb::SBEvent &event); + + static bool + GetRestartedFromEvent (const lldb::SBEvent &event); + + static size_t + GetNumRestartedReasonsFromEvent (const lldb::SBEvent &event); + + static const char * + GetRestartedReasonAtIndexFromEvent (const lldb::SBEvent &event, size_t idx); + + static lldb::SBProcess + GetProcessFromEvent (const lldb::SBEvent &event); + + static bool + EventIsProcessEvent (const lldb::SBEvent &event); + + lldb::SBBroadcaster + GetBroadcaster () const; + + static const char * + GetBroadcasterClass (); + + bool + GetDescription (lldb::SBStream &description); + + uint32_t + GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const; + + uint32_t + LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error); + + lldb::SBError + UnloadImage (uint32_t image_token); + +protected: + friend class SBAddress; + friend class SBBreakpoint; + friend class SBBreakpointLocation; + friend class SBCommandInterpreter; + friend class SBDebugger; + friend class SBFunction; + friend class SBModule; + friend class SBTarget; + friend class SBThread; + friend class SBValue; + + lldb::ProcessSP + GetSP() const; + + void + SetSP (const lldb::ProcessSP &process_sp); + + lldb::ProcessWP m_opaque_wp; +}; + +} // namespace lldb + +#endif // LLDB_SBProcess_h_ diff --git a/include/lldb/API/SBSection.h b/include/lldb/API/SBSection.h new file mode 100644 index 000000000000..3386484f6496 --- /dev/null +++ b/include/lldb/API/SBSection.h @@ -0,0 +1,104 @@ +//===-- SBSection.h ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBSection_h_ +#define LLDB_SBSection_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBData.h" + +namespace lldb { + +class SBSection +{ +public: + + SBSection (); + + SBSection (const lldb::SBSection &rhs); + + ~SBSection (); + + const lldb::SBSection & + operator = (const lldb::SBSection &rhs); + + bool + IsValid () const; + + const char * + GetName (); + + lldb::SBSection + GetParent(); + + lldb::SBSection + FindSubSection (const char *sect_name); + + size_t + GetNumSubSections (); + + lldb::SBSection + GetSubSectionAtIndex (size_t idx); + + lldb::addr_t + GetFileAddress (); + + lldb::addr_t + GetLoadAddress (lldb::SBTarget &target); + + lldb::addr_t + GetByteSize (); + + uint64_t + GetFileOffset (); + + uint64_t + GetFileByteSize (); + + lldb::SBData + GetSectionData (); + + lldb::SBData + GetSectionData (uint64_t offset, + uint64_t size); + + SectionType + GetSectionType (); + + bool + operator == (const lldb::SBSection &rhs); + + bool + operator != (const lldb::SBSection &rhs); + + bool + GetDescription (lldb::SBStream &description); + + +private: + + friend class SBAddress; + friend class SBModule; + friend class SBTarget; + + SBSection (const lldb::SectionSP §ion_sp); + + lldb::SectionSP + GetSP() const; + + void + SetSP(const lldb::SectionSP §ion_sp); + + lldb::SectionWP m_opaque_wp; +}; + + +} // namespace lldb + +#endif // LLDB_SBSection_h_ diff --git a/include/lldb/API/SBSourceManager.h b/include/lldb/API/SBSourceManager.h new file mode 100644 index 000000000000..5b52c49ff3ee --- /dev/null +++ b/include/lldb/API/SBSourceManager.h @@ -0,0 +1,53 @@ +//===-- SBSourceManager.h ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBSourceManager_h_ +#define LLDB_SBSourceManager_h_ + +#include "lldb/API/SBDefines.h" + +#include <stdio.h> + +namespace lldb { + +class SBSourceManager +{ +public: + SBSourceManager (const SBDebugger &debugger); + SBSourceManager (const SBTarget &target); + SBSourceManager (const SBSourceManager &rhs); + + ~SBSourceManager(); + + const lldb::SBSourceManager & + operator = (const lldb::SBSourceManager &rhs); + + size_t + DisplaySourceLinesWithLineNumbers (const lldb::SBFileSpec &file, + uint32_t line, + uint32_t context_before, + uint32_t context_after, + const char* current_line_cstr, + lldb::SBStream &s); + + +protected: + friend class SBCommandInterpreter; + friend class SBDebugger; + + SBSourceManager(lldb_private::SourceManager *source_manager); + +private: + + std::unique_ptr<lldb_private::SourceManagerImpl> m_opaque_ap; +}; + +} // namespace lldb + +#endif // LLDB_SBSourceManager_h_ diff --git a/include/lldb/API/SBStream.h b/include/lldb/API/SBStream.h new file mode 100644 index 000000000000..038adf68542c --- /dev/null +++ b/include/lldb/API/SBStream.h @@ -0,0 +1,111 @@ +//===-- SBStream.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBStream_h_ +#define LLDB_SBStream_h_ + +#include <stdio.h> + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBStream +{ +public: + + SBStream (); + + ~SBStream (); + + bool + IsValid() const; + + // If this stream is not redirected to a file, it will maintain a local + // cache for the stream data which can be accessed using this accessor. + const char * + GetData (); + + // If this stream is not redirected to a file, it will maintain a local + // cache for the stream output whose length can be accessed using this + // accessor. + size_t + GetSize(); + + void + Printf (const char *format, ...) __attribute__ ((format (printf, 2, 3))); + + void + RedirectToFile (const char *path, bool append); + + void + RedirectToFileHandle (FILE *fh, bool transfer_fh_ownership); + + void + RedirectToFileDescriptor (int fd, bool transfer_fh_ownership); + + // If the stream is redirected to a file, forget about the file and if + // ownership of the file was transfered to this object, close the file. + // If the stream is backed by a local cache, clear this cache. + void + Clear (); + +protected: + friend class SBAddress; + friend class SBBlock; + friend class SBBreakpoint; + friend class SBBreakpointLocation; + friend class SBCommandReturnObject; + friend class SBCompileUnit; + friend class SBData; + friend class SBDebugger; + friend class SBDeclaration; + friend class SBEvent; + friend class SBFileSpec; + friend class SBFileSpecList; + friend class SBFrame; + friend class SBFunction; + friend class SBInstruction; + friend class SBInstructionList; + friend class SBLineEntry; + friend class SBModule; + friend class SBModuleSpec; + friend class SBModuleSpecList; + friend class SBProcess; + friend class SBSection; + friend class SBSourceManager; + friend class SBSymbol; + friend class SBSymbolContext; + friend class SBSymbolContextList; + friend class SBTarget; + friend class SBThread; + friend class SBType; + friend class SBTypeMember; + friend class SBValue; + friend class SBWatchpoint; + + lldb_private::Stream * + operator->(); + + lldb_private::Stream * + get(); + + lldb_private::Stream & + ref(); + +private: + + DISALLOW_COPY_AND_ASSIGN (SBStream); + std::unique_ptr<lldb_private::Stream> m_opaque_ap; + bool m_is_file; +}; + +} // namespace lldb + +#endif // LLDB_SBStream_h_ diff --git a/include/lldb/API/SBStringList.h b/include/lldb/API/SBStringList.h new file mode 100644 index 000000000000..9d0be6e8a741 --- /dev/null +++ b/include/lldb/API/SBStringList.h @@ -0,0 +1,71 @@ +//===-- SBStringList.h ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBStringList_h_ +#define LLDB_SBStringList_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBStringList +{ +public: + + SBStringList (); + + SBStringList (const lldb::SBStringList &rhs); + + const SBStringList & + operator = (const SBStringList &rhs); + + ~SBStringList (); + + bool + IsValid() const; + + void + AppendString (const char *str); + + void + AppendList (const char **strv, int strc); + + void + AppendList (const lldb::SBStringList &strings); + + uint32_t + GetSize () const; + + const char * + GetStringAtIndex (size_t idx); + + void + Clear (); + +protected: + friend class SBCommandInterpreter; + friend class SBDebugger; + + SBStringList (const lldb_private::StringList *lldb_strings); + + const lldb_private::StringList * + operator->() const; + + const lldb_private::StringList & + operator*() const; + +private: + + std::unique_ptr<lldb_private::StringList> m_opaque_ap; + +}; + +} // namespace lldb + +#endif // LLDB_SBStringList_h_ diff --git a/include/lldb/API/SBSymbol.h b/include/lldb/API/SBSymbol.h new file mode 100644 index 000000000000..0a528a9ac96f --- /dev/null +++ b/include/lldb/API/SBSymbol.h @@ -0,0 +1,109 @@ +//===-- SBSymbol.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBSymbol_h_ +#define LLDB_SBSymbol_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBInstructionList.h" +#include "lldb/API/SBTarget.h" + +namespace lldb { + +class SBSymbol +{ +public: + + SBSymbol (); + + ~SBSymbol (); + + SBSymbol (const lldb::SBSymbol &rhs); + + const lldb::SBSymbol & + operator = (const lldb::SBSymbol &rhs); + + bool + IsValid () const; + + + const char * + GetName() const; + + const char * + GetMangledName () const; + + lldb::SBInstructionList + GetInstructions (lldb::SBTarget target); + + lldb::SBInstructionList + GetInstructions (lldb::SBTarget target, const char *flavor_string); + + SBAddress + GetStartAddress (); + + SBAddress + GetEndAddress (); + + uint32_t + GetPrologueByteSize (); + + SymbolType + GetType (); + + bool + operator == (const lldb::SBSymbol &rhs) const; + + bool + operator != (const lldb::SBSymbol &rhs) const; + + bool + GetDescription (lldb::SBStream &description); + + //---------------------------------------------------------------------- + // Returns true if the symbol is externally visible in the module that + // it is defined in + //---------------------------------------------------------------------- + bool + IsExternal(); + + //---------------------------------------------------------------------- + // Returns true if the symbol was synthetically generated from something + // other than the actual symbol table itself in the object file. + //---------------------------------------------------------------------- + bool + IsSynthetic(); + +protected: + + lldb_private::Symbol * + get (); + + void + reset (lldb_private::Symbol *); + +private: + friend class SBAddress; + friend class SBFrame; + friend class SBModule; + friend class SBSymbolContext; + + SBSymbol (lldb_private::Symbol *lldb_object_ptr); + + void + SetSymbol (lldb_private::Symbol *lldb_object_ptr); + + lldb_private::Symbol *m_opaque_ptr; +}; + + +} // namespace lldb + +#endif // LLDB_SBSymbol_h_ diff --git a/include/lldb/API/SBSymbolContext.h b/include/lldb/API/SBSymbolContext.h new file mode 100644 index 000000000000..fee2d19179d0 --- /dev/null +++ b/include/lldb/API/SBSymbolContext.h @@ -0,0 +1,94 @@ +//===-- SBSymbolContext.h ---------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBSymbolContext_h_ +#define LLDB_SBSymbolContext_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBBlock.h" +#include "lldb/API/SBCompileUnit.h" +#include "lldb/API/SBFunction.h" +#include "lldb/API/SBLineEntry.h" +#include "lldb/API/SBModule.h" +#include "lldb/API/SBSymbol.h" + +namespace lldb { + +class SBSymbolContext +{ +public: + SBSymbolContext (); + + SBSymbolContext (const lldb::SBSymbolContext& rhs); + + ~SBSymbolContext (); + + bool + IsValid () const; + + const lldb::SBSymbolContext & + operator = (const lldb::SBSymbolContext &rhs); + + lldb::SBModule GetModule (); + lldb::SBCompileUnit GetCompileUnit (); + lldb::SBFunction GetFunction (); + lldb::SBBlock GetBlock (); + lldb::SBLineEntry GetLineEntry (); + lldb::SBSymbol GetSymbol (); + + void SetModule (lldb::SBModule module); + void SetCompileUnit (lldb::SBCompileUnit compile_unit); + void SetFunction (lldb::SBFunction function); + void SetBlock (lldb::SBBlock block); + void SetLineEntry (lldb::SBLineEntry line_entry); + void SetSymbol (lldb::SBSymbol symbol); + + SBSymbolContext + GetParentOfInlinedScope (const SBAddress &curr_frame_pc, + SBAddress &parent_frame_addr) const; + + bool + GetDescription (lldb::SBStream &description); + +protected: + friend class SBAddress; + friend class SBFrame; + friend class SBModule; + friend class SBThread; + friend class SBTarget; + friend class SBSymbolContextList; + + lldb_private::SymbolContext* + operator->() const; + + lldb_private::SymbolContext& + operator*(); + + lldb_private::SymbolContext& + ref(); + + const lldb_private::SymbolContext& + operator*() const; + + lldb_private::SymbolContext * + get() const; + + SBSymbolContext (const lldb_private::SymbolContext *sc_ptr); + + void + SetSymbolContext (const lldb_private::SymbolContext *sc_ptr); + +private: + std::unique_ptr<lldb_private::SymbolContext> m_opaque_ap; +}; + + +} // namespace lldb + +#endif // LLDB_SBSymbolContext_h_ diff --git a/include/lldb/API/SBSymbolContextList.h b/include/lldb/API/SBSymbolContextList.h new file mode 100644 index 000000000000..6cc78e472c6f --- /dev/null +++ b/include/lldb/API/SBSymbolContextList.h @@ -0,0 +1,69 @@ +//===-- SBSymbolContextList.h -----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBSymbolContextList_h_ +#define LLDB_SBSymbolContextList_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBSymbolContext.h" + +namespace lldb { + +class SBSymbolContextList +{ +public: + SBSymbolContextList (); + + SBSymbolContextList (const lldb::SBSymbolContextList& rhs); + + ~SBSymbolContextList (); + + const lldb::SBSymbolContextList & + operator = (const lldb::SBSymbolContextList &rhs); + + bool + IsValid () const; + + uint32_t + GetSize() const; + + lldb::SBSymbolContext + GetContextAtIndex (uint32_t idx); + + bool + GetDescription (lldb::SBStream &description); + + void + Append (lldb::SBSymbolContext &sc); + + void + Append (lldb::SBSymbolContextList &sc_list); + + void + Clear(); + +protected: + + friend class SBModule; + friend class SBTarget; + + lldb_private::SymbolContextList* + operator->() const; + + lldb_private::SymbolContextList& + operator*() const; + +private: + std::unique_ptr<lldb_private::SymbolContextList> m_opaque_ap; +}; + + +} // namespace lldb + +#endif // LLDB_SBSymbolContextList_h_ diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h new file mode 100644 index 000000000000..15aeed4b600c --- /dev/null +++ b/include/lldb/API/SBTarget.h @@ -0,0 +1,828 @@ +//===-- SBTarget.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTarget_h_ +#define LLDB_SBTarget_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBBroadcaster.h" +#include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBFileSpecList.h" +#include "lldb/API/SBSymbolContextList.h" +#include "lldb/API/SBType.h" +#include "lldb/API/SBValue.h" +#include "lldb/API/SBWatchpoint.h" + +namespace lldb { + +class SBLaunchInfo +{ +public: + SBLaunchInfo (const char **argv); + + ~SBLaunchInfo(); + + uint32_t + GetUserID(); + + uint32_t + GetGroupID(); + + bool + UserIDIsValid (); + + bool + GroupIDIsValid (); + + void + SetUserID (uint32_t uid); + + void + SetGroupID (uint32_t gid); + + uint32_t + GetNumArguments (); + + const char * + GetArgumentAtIndex (uint32_t idx); + + void + SetArguments (const char **argv, bool append); + + uint32_t + GetNumEnvironmentEntries (); + + const char * + GetEnvironmentEntryAtIndex (uint32_t idx); + + void + SetEnvironmentEntries (const char **envp, bool append); + + void + Clear (); + + const char * + GetWorkingDirectory () const; + + void + SetWorkingDirectory (const char *working_dir); + + uint32_t + GetLaunchFlags (); + + void + SetLaunchFlags (uint32_t flags); + + const char * + GetProcessPluginName (); + + void + SetProcessPluginName (const char *plugin_name); + + const char * + GetShell (); + + void + SetShell (const char * path); + + uint32_t + GetResumeCount (); + + void + SetResumeCount (uint32_t c); + + bool + AddCloseFileAction (int fd); + + bool + AddDuplicateFileAction (int fd, int dup_fd); + + bool + AddOpenFileAction (int fd, const char *path, bool read, bool write); + + bool + AddSuppressFileAction (int fd, bool read, bool write); + +protected: + friend class SBTarget; + + lldb_private::ProcessLaunchInfo & + ref (); + + ProcessLaunchInfoSP m_opaque_sp; +}; + +class SBAttachInfo +{ +public: + SBAttachInfo (); + + SBAttachInfo (lldb::pid_t pid); + + SBAttachInfo (const char *path, bool wait_for); + + SBAttachInfo (const SBAttachInfo &rhs); + + ~SBAttachInfo(); + + SBAttachInfo & + operator = (const SBAttachInfo &rhs); + + lldb::pid_t + GetProcessID (); + + void + SetProcessID (lldb::pid_t pid); + + void + SetExecutable (const char *path); + + void + SetExecutable (lldb::SBFileSpec exe_file); + + bool + GetWaitForLaunch (); + + void + SetWaitForLaunch (bool b); + + bool + GetIgnoreExisting (); + + void + SetIgnoreExisting (bool b); + + uint32_t + GetResumeCount (); + + void + SetResumeCount (uint32_t c); + + const char * + GetProcessPluginName (); + + void + SetProcessPluginName (const char *plugin_name); + + uint32_t + GetUserID(); + + uint32_t + GetGroupID(); + + bool + UserIDIsValid (); + + bool + GroupIDIsValid (); + + void + SetUserID (uint32_t uid); + + void + SetGroupID (uint32_t gid); + + uint32_t + GetEffectiveUserID(); + + uint32_t + GetEffectiveGroupID(); + + bool + EffectiveUserIDIsValid (); + + bool + EffectiveGroupIDIsValid (); + + void + SetEffectiveUserID (uint32_t uid); + + void + SetEffectiveGroupID (uint32_t gid); + + lldb::pid_t + GetParentProcessID (); + + void + SetParentProcessID (lldb::pid_t pid); + + bool + ParentProcessIDIsValid(); + + +protected: + friend class SBTarget; + + lldb_private::ProcessAttachInfo & + ref (); + + ProcessAttachInfoSP m_opaque_sp; +}; + +class SBTarget +{ +public: + //------------------------------------------------------------------ + // Broadcaster bits. + //------------------------------------------------------------------ + enum + { + eBroadcastBitBreakpointChanged = (1 << 0), + eBroadcastBitModulesLoaded = (1 << 1), + eBroadcastBitModulesUnloaded = (1 << 2), + eBroadcastBitWatchpointChanged = (1 << 3), + eBroadcastBitSymbolsLoaded = (1 << 4) + }; + + //------------------------------------------------------------------ + // Constructors + //------------------------------------------------------------------ + SBTarget (); + + SBTarget (const lldb::SBTarget& rhs); + + SBTarget (const lldb::TargetSP& target_sp); + + const lldb::SBTarget& + operator = (const lldb::SBTarget& rhs); + + //------------------------------------------------------------------ + // Destructor + //------------------------------------------------------------------ + ~SBTarget(); + + bool + IsValid() const; + + static const char * + GetBroadcasterClassName (); + + lldb::SBProcess + GetProcess (); + + //------------------------------------------------------------------ + /// Launch a new process. + /// + /// Launch a new process by spawning a new process using the + /// target object's executable module's file as the file to launch. + /// Arguments are given in \a argv, and the environment variables + /// are in \a envp. Standard input and output files can be + /// optionally re-directed to \a stdin_path, \a stdout_path, and + /// \a stderr_path. + /// + /// @param[in] listener + /// An optional listener that will receive all process events. + /// If \a listener is valid then \a listener will listen to all + /// process events. If not valid, then this target's debugger + /// (SBTarget::GetDebugger()) will listen to all process events. + /// + /// @param[in] argv + /// The argument array. + /// + /// @param[in] envp + /// The environment array. + /// + /// @param[in] launch_flags + /// Flags to modify the launch (@see lldb::LaunchFlags) + /// + /// @param[in] stdin_path + /// The path to use when re-directing the STDIN of the new + /// process. If all stdXX_path arguments are NULL, a pseudo + /// terminal will be used. + /// + /// @param[in] stdout_path + /// The path to use when re-directing the STDOUT of the new + /// process. If all stdXX_path arguments are NULL, a pseudo + /// terminal will be used. + /// + /// @param[in] stderr_path + /// The path to use when re-directing the STDERR of the new + /// process. If all stdXX_path arguments are NULL, a pseudo + /// terminal will be used. + /// + /// @param[in] working_directory + /// The working directory to have the child process run in + /// + /// @param[in] launch_flags + /// Some launch options specified by logical OR'ing + /// lldb::LaunchFlags enumeration values together. + /// + /// @param[in] stop_at_endtry + /// If false do not stop the inferior at the entry point. + /// + /// @param[out] + /// An error object. Contains the reason if there is some failure. + /// + /// @return + /// A process object for the newly created process. + //------------------------------------------------------------------ + lldb::SBProcess + Launch (SBListener &listener, + char const **argv, + char const **envp, + const char *stdin_path, + const char *stdout_path, + const char *stderr_path, + const char *working_directory, + uint32_t launch_flags, // See LaunchFlags + bool stop_at_entry, + lldb::SBError& error); + + + //------------------------------------------------------------------ + /// Launch a new process with sensible defaults. + /// + /// @param[in] argv + /// The argument array. + /// + /// @param[in] envp + /// The environment array. + /// + /// @param[in] working_directory + /// The working directory to have the child process run in + /// + /// Default: listener + /// Set to the target's debugger (SBTarget::GetDebugger()) + /// + /// Default: launch_flags + /// Empty launch flags + /// + /// Default: stdin_path + /// Default: stdout_path + /// Default: stderr_path + /// A pseudo terminal will be used. + /// + /// @return + /// A process object for the newly created process. + //------------------------------------------------------------------ + SBProcess + LaunchSimple (const char **argv, + const char **envp, + const char *working_directory); + + SBProcess + Launch (SBLaunchInfo &launch_info, SBError& error); + + SBProcess + LoadCore (const char *core_file); + + SBProcess + Attach (SBAttachInfo &attach_info, SBError& error); + + //------------------------------------------------------------------ + /// Attach to process with pid. + /// + /// @param[in] listener + /// An optional listener that will receive all process events. + /// If \a listener is valid then \a listener will listen to all + /// process events. If not valid, then this target's debugger + /// (SBTarget::GetDebugger()) will listen to all process events. + /// + /// @param[in] pid + /// The process ID to attach to. + /// + /// @param[out] + /// An error explaining what went wrong if attach fails. + /// + /// @return + /// A process object for the attached process. + //------------------------------------------------------------------ + lldb::SBProcess + AttachToProcessWithID (SBListener &listener, + lldb::pid_t pid, + lldb::SBError& error); + +#if defined(__APPLE__) + // We need to keep this around for a build or two since Xcode links + // to the 32 bit version of this function. We will take it out soon. + lldb::SBProcess + AttachToProcessWithID (SBListener &listener, + ::pid_t pid, // 32 bit int process ID + lldb::SBError& error); // DEPRECATED +#endif + //------------------------------------------------------------------ + /// Attach to process with name. + /// + /// @param[in] listener + /// An optional listener that will receive all process events. + /// If \a listener is valid then \a listener will listen to all + /// process events. If not valid, then this target's debugger + /// (SBTarget::GetDebugger()) will listen to all process events. + /// + /// @param[in] name + /// Basename of process to attach to. + /// + /// @param[in] wait_for + /// If true wait for a new instance of 'name' to be launched. + /// + /// @param[out] + /// An error explaining what went wrong if attach fails. + /// + /// @return + /// A process object for the attached process. + //------------------------------------------------------------------ + lldb::SBProcess + AttachToProcessWithName (SBListener &listener, + const char *name, + bool wait_for, + lldb::SBError& error); + + //------------------------------------------------------------------ + /// Connect to a remote debug server with url. + /// + /// @param[in] listener + /// An optional listener that will receive all process events. + /// If \a listener is valid then \a listener will listen to all + /// process events. If not valid, then this target's debugger + /// (SBTarget::GetDebugger()) will listen to all process events. + /// + /// @param[in] url + /// The url to connect to, e.g., 'connect://localhost:12345'. + /// + /// @param[in] plugin_name + /// The plugin name to be used; can be NULL. + /// + /// @param[out] + /// An error explaining what went wrong if the connect fails. + /// + /// @return + /// A process object for the connected process. + //------------------------------------------------------------------ + lldb::SBProcess + ConnectRemote (SBListener &listener, + const char *url, + const char *plugin_name, + SBError& error); + + lldb::SBFileSpec + GetExecutable (); + + bool + AddModule (lldb::SBModule &module); + + lldb::SBModule + AddModule (const char *path, + const char *triple, + const char *uuid); + + lldb::SBModule + AddModule (const char *path, + const char *triple, + const char *uuid_cstr, + const char *symfile); + + lldb::SBModule + AddModule (const SBModuleSpec &module_spec); + + uint32_t + GetNumModules () const; + + lldb::SBModule + GetModuleAtIndex (uint32_t idx); + + bool + RemoveModule (lldb::SBModule module); + + lldb::SBDebugger + GetDebugger() const; + + lldb::SBModule + FindModule (const lldb::SBFileSpec &file_spec); + + lldb::ByteOrder + GetByteOrder (); + + uint32_t + GetAddressByteSize(); + + const char * + GetTriple (); + + //------------------------------------------------------------------ + /// Set the base load address for a module section. + /// + /// @param[in] section + /// The section whose base load address will be set within this + /// target. + /// + /// @param[in] section_base_addr + /// The base address for the section. + /// + /// @return + /// An error to indicate success, fail, and any reason for + /// failure. + //------------------------------------------------------------------ + lldb::SBError + SetSectionLoadAddress (lldb::SBSection section, + lldb::addr_t section_base_addr); + + //------------------------------------------------------------------ + /// Clear the base load address for a module section. + /// + /// @param[in] section + /// The section whose base load address will be cleared within + /// this target. + /// + /// @return + /// An error to indicate success, fail, and any reason for + /// failure. + //------------------------------------------------------------------ + lldb::SBError + ClearSectionLoadAddress (lldb::SBSection section); + + //------------------------------------------------------------------ + /// Slide all file addresses for all module sections so that \a module + /// appears to loaded at these slide addresses. + /// + /// When you need all sections within a module to be loaded at a + /// rigid slide from the addresses found in the module object file, + /// this function will allow you to easily and quickly slide all + /// module sections. + /// + /// @param[in] module + /// The module to load. + /// + /// @param[in] sections_offset + /// An offset that will be applied to all section file addresses + /// (the virtual addresses found in the object file itself). + /// + /// @return + /// An error to indicate success, fail, and any reason for + /// failure. + //------------------------------------------------------------------ + lldb::SBError + SetModuleLoadAddress (lldb::SBModule module, + int64_t sections_offset); + + + //------------------------------------------------------------------ + /// The the section base load addresses for all sections in a module. + /// + /// @param[in] module + /// The module to unload. + /// + /// @return + /// An error to indicate success, fail, and any reason for + /// failure. + //------------------------------------------------------------------ + lldb::SBError + ClearModuleLoadAddress (lldb::SBModule module); + + //------------------------------------------------------------------ + /// Find functions by name. + /// + /// @param[in] name + /// The name of the function we are looking for. + /// + /// @param[in] name_type_mask + /// A logical OR of one or more FunctionNameType enum bits that + /// indicate what kind of names should be used when doing the + /// lookup. Bits include fully qualified names, base names, + /// C++ methods, or ObjC selectors. + /// See FunctionNameType for more details. + /// + /// @return + /// A lldb::SBSymbolContextList that gets filled in with all of + /// the symbol contexts for all the matches. + //------------------------------------------------------------------ + lldb::SBSymbolContextList + FindFunctions (const char *name, + uint32_t name_type_mask = lldb::eFunctionNameTypeAny); + + //------------------------------------------------------------------ + /// Find global and static variables by name. + /// + /// @param[in] name + /// The name of the global or static variable we are looking + /// for. + /// + /// @param[in] max_matches + /// Allow the number of matches to be limited to \a max_matches. + /// + /// @return + /// A list of matched variables in an SBValueList. + //------------------------------------------------------------------ + lldb::SBValueList + FindGlobalVariables (const char *name, + uint32_t max_matches); + + //------------------------------------------------------------------ + /// Find the first global (or static) variable by name. + /// + /// @param[in] name + /// The name of the global or static variable we are looking + /// for. + /// + /// @return + /// An SBValue that gets filled in with the found variable (if any). + //------------------------------------------------------------------ + lldb::SBValue + FindFirstGlobalVariable (const char* name); + + void + Clear (); + + lldb::SBAddress + ResolveLoadAddress (lldb::addr_t vm_addr); + + SBSymbolContext + ResolveSymbolContextForAddress (const SBAddress& addr, + uint32_t resolve_scope); + + lldb::SBBreakpoint + BreakpointCreateByLocation (const char *file, uint32_t line); + + lldb::SBBreakpoint + BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); + + lldb::SBBreakpoint + BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); + + // This version uses name_type_mask = eFunctionNameTypeAuto + lldb::SBBreakpoint + BreakpointCreateByName (const char *symbol_name, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint + BreakpointCreateByName (const char *symbol_name, + uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint + BreakpointCreateByNames (const char *symbol_name[], + uint32_t num_names, + uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint + BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); + + lldb::SBBreakpoint + BreakpointCreateByRegex (const char *symbol_name_regex, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list); + + lldb::SBBreakpoint + BreakpointCreateBySourceRegex (const char *source_regex, + const lldb::SBFileSpec &source_file, + const char *module_name = NULL); + + lldb::SBBreakpoint + BreakpointCreateBySourceRegex (const char *source_regex, + const SBFileSpecList &module_list, + const lldb::SBFileSpecList &source_file); + + lldb::SBBreakpoint + BreakpointCreateForException (lldb::LanguageType language, + bool catch_bp, + bool throw_bp); + + lldb::SBBreakpoint + BreakpointCreateByAddress (addr_t address); + + uint32_t + GetNumBreakpoints () const; + + lldb::SBBreakpoint + GetBreakpointAtIndex (uint32_t idx) const; + + bool + BreakpointDelete (break_id_t break_id); + + lldb::SBBreakpoint + FindBreakpointByID (break_id_t break_id); + + bool + EnableAllBreakpoints (); + + bool + DisableAllBreakpoints (); + + bool + DeleteAllBreakpoints (); + + uint32_t + GetNumWatchpoints () const; + + lldb::SBWatchpoint + GetWatchpointAtIndex (uint32_t idx) const; + + bool + DeleteWatchpoint (lldb::watch_id_t watch_id); + + lldb::SBWatchpoint + FindWatchpointByID (lldb::watch_id_t watch_id); + + lldb::SBWatchpoint + WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, SBError& error); + + bool + EnableAllWatchpoints (); + + bool + DisableAllWatchpoints (); + + bool + DeleteAllWatchpoints (); + + lldb::SBBroadcaster + GetBroadcaster () const; + + lldb::SBType + FindFirstType (const char* type); + + lldb::SBTypeList + FindTypes (const char* type); + + lldb::SBType + GetBasicType(lldb::BasicType type); + + SBSourceManager + GetSourceManager(); + + lldb::SBInstructionList + ReadInstructions (lldb::SBAddress base_addr, uint32_t count); + + lldb::SBInstructionList + ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string); + + lldb::SBInstructionList + GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size); + + // The "WithFlavor" is necessary to keep SWIG from getting confused about overloaded arguments when + // using the buf + size -> Python Object magic. + + lldb::SBInstructionList + GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size); + + lldb::SBInstructionList + GetInstructions (lldb::addr_t base_addr, const void *buf, size_t size); + + lldb::SBInstructionList + GetInstructionsWithFlavor (lldb::addr_t base_addr, const char *flavor_string, const void *buf, size_t size); + + lldb::SBSymbolContextList + FindSymbols (const char *name, + lldb::SymbolType type = eSymbolTypeAny); + + bool + operator == (const lldb::SBTarget &rhs) const; + + bool + operator != (const lldb::SBTarget &rhs) const; + + bool + GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); + + lldb::SBValue + EvaluateExpression (const char *expr, const SBExpressionOptions &options); + + lldb::addr_t + GetStackRedZoneSize(); + +protected: + friend class SBAddress; + friend class SBBlock; + friend class SBDebugger; + friend class SBFunction; + friend class SBInstruction; + friend class SBModule; + friend class SBProcess; + friend class SBSection; + friend class SBSourceManager; + friend class SBSymbol; + friend class SBValue; + + //------------------------------------------------------------------ + // Constructors are private, use static Target::Create function to + // create an instance of this class. + //------------------------------------------------------------------ + + lldb::TargetSP + GetSP () const; + + void + SetSP (const lldb::TargetSP& target_sp); + + +private: + //------------------------------------------------------------------ + // For Target only + //------------------------------------------------------------------ + + lldb::TargetSP m_opaque_sp; +}; + +} // namespace lldb + +#endif // LLDB_SBTarget_h_ diff --git a/include/lldb/API/SBThread.h b/include/lldb/API/SBThread.h new file mode 100644 index 000000000000..9645f925035e --- /dev/null +++ b/include/lldb/API/SBThread.h @@ -0,0 +1,220 @@ +//===-- SBThread.h ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBThread_h_ +#define LLDB_SBThread_h_ + +#include "lldb/API/SBDefines.h" + +#include <stdio.h> + +namespace lldb { + +class SBFrame; + +class SBThread +{ +public: + enum + { + eBroadcastBitStackChanged = (1 << 0), + eBroadcastBitThreadSuspended = (1 << 1), + eBroadcastBitThreadResumed = (1 << 2), + eBroadcastBitSelectedFrameChanged = (1 << 3), + eBroadcastBitThreadSelected = (1 << 4) + }; + + static const char * + GetBroadcasterClassName (); + + SBThread (); + + SBThread (const lldb::SBThread &thread); + + SBThread (const lldb::ThreadSP& lldb_object_sp); + + ~SBThread(); + + bool + IsValid() const; + + void + Clear (); + + lldb::StopReason + GetStopReason(); + + /// Get the number of words associated with the stop reason. + /// See also GetStopReasonDataAtIndex(). + size_t + GetStopReasonDataCount(); + + //-------------------------------------------------------------------------- + /// Get information associated with a stop reason. + /// + /// Breakpoint stop reasons will have data that consists of pairs of + /// breakpoint IDs followed by the breakpoint location IDs (they always come + /// in pairs). + /// + /// Stop Reason Count Data Type + /// ======================== ===== ========================================= + /// eStopReasonNone 0 + /// eStopReasonTrace 0 + /// eStopReasonBreakpoint N duple: {breakpoint id, location id} + /// eStopReasonWatchpoint 1 watchpoint id + /// eStopReasonSignal 1 unix signal number + /// eStopReasonException N exception data + /// eStopReasonExec 0 + /// eStopReasonPlanComplete 0 + //-------------------------------------------------------------------------- + uint64_t + GetStopReasonDataAtIndex(uint32_t idx); + + size_t + GetStopDescription (char *dst, size_t dst_len); + + SBValue + GetStopReturnValue (); + + lldb::tid_t + GetThreadID () const; + + uint32_t + GetIndexID () const; + + const char * + GetName () const; + + const char * + GetQueueName() const; + + void + StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + + void + StepInto (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + + void + StepInto (const char *target_name, lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + + void + StepOut (); + + void + StepOutOfFrame (lldb::SBFrame &frame); + + void + StepInstruction(bool step_over); + + SBError + StepOverUntil (lldb::SBFrame &frame, + lldb::SBFileSpec &file_spec, + uint32_t line); + + void + RunToAddress (lldb::addr_t addr); + + SBError + ReturnFromFrame (SBFrame &frame, SBValue &return_value); + + //-------------------------------------------------------------------------- + /// LLDB currently supports process centric debugging which means when any + /// thread in a process stops, all other threads are stopped. The Suspend() + /// call here tells our process to suspend a thread and not let it run when + /// the other threads in a process are allowed to run. So when + /// SBProcess::Continue() is called, any threads that aren't suspended will + /// be allowed to run. If any of the SBThread functions for stepping are + /// called (StepOver, StepInto, StepOut, StepInstruction, RunToAddres), the + /// thread will not be allowed to run and these funtions will simply return. + /// + /// Eventually we plan to add support for thread centric debugging where + /// each thread is controlled individually and each thread would broadcast + /// its state, but we haven't implemented this yet. + /// + /// Likewise the SBThread::Resume() call will again allow the thread to run + /// when the process is continued. + /// + /// Suspend() and Resume() functions are not currently reference counted, if + /// anyone has the need for them to be reference counted, please let us + /// know. + //-------------------------------------------------------------------------- + bool + Suspend(); + + bool + Resume (); + + bool + IsSuspended(); + + bool + IsStopped(); + + uint32_t + GetNumFrames (); + + lldb::SBFrame + GetFrameAtIndex (uint32_t idx); + + lldb::SBFrame + GetSelectedFrame (); + + lldb::SBFrame + SetSelectedFrame (uint32_t frame_idx); + + static bool + EventIsThreadEvent (const SBEvent &event); + + static SBFrame + GetStackFrameFromEvent (const SBEvent &event); + + static SBThread + GetThreadFromEvent (const SBEvent &event); + + lldb::SBProcess + GetProcess (); + + const lldb::SBThread & + operator = (const lldb::SBThread &rhs); + + bool + operator == (const lldb::SBThread &rhs) const; + + bool + operator != (const lldb::SBThread &rhs) const; + + bool + GetDescription (lldb::SBStream &description) const; + + bool + GetStatus (lldb::SBStream &status) const; + +protected: + friend class SBBreakpoint; + friend class SBBreakpointLocation; + friend class SBFrame; + friend class SBProcess; + friend class SBDebugger; + friend class SBValue; + + void + SetThread (const lldb::ThreadSP& lldb_object_sp); + +#ifndef SWIG + SBError + ResumeNewPlan (lldb_private::ExecutionContext &exe_ctx, lldb_private::ThreadPlan *new_plan); +#endif + +private: + lldb::ExecutionContextRefSP m_opaque_sp; +}; + +} // namespace lldb + +#endif // LLDB_SBThread_h_ diff --git a/include/lldb/API/SBType.h b/include/lldb/API/SBType.h new file mode 100644 index 000000000000..3729b2f84b90 --- /dev/null +++ b/include/lldb/API/SBType.h @@ -0,0 +1,244 @@ +//===-- SBType.h ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBType_h_ +#define LLDB_SBType_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBTypeList; + +class SBTypeMember +{ +public: + SBTypeMember (); + + SBTypeMember (const lldb::SBTypeMember& rhs); + + ~SBTypeMember(); + + lldb::SBTypeMember& + operator = (const lldb::SBTypeMember& rhs); + + bool + IsValid() const; + + const char * + GetName (); + + lldb::SBType + GetType (); + + uint64_t + GetOffsetInBytes(); + + uint64_t + GetOffsetInBits(); + + bool + IsBitfield(); + + uint32_t + GetBitfieldSizeInBits(); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + +protected: + friend class SBType; + + void + reset (lldb_private::TypeMemberImpl *); + + lldb_private::TypeMemberImpl & + ref (); + + const lldb_private::TypeMemberImpl & + ref () const; + + std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_ap; +}; + +class SBType +{ +public: + + SBType(); + + SBType (const lldb::SBType &rhs); + + ~SBType (); + + bool + IsValid() const; + + uint64_t + GetByteSize(); + + bool + IsPointerType(); + + bool + IsReferenceType(); + + bool + IsFunctionType (); + + bool + IsPolymorphicClass (); + + lldb::SBType + GetPointerType(); + + lldb::SBType + GetPointeeType(); + + lldb::SBType + GetReferenceType(); + + lldb::SBType + GetDereferencedType(); + + lldb::SBType + GetUnqualifiedType(); + + lldb::SBType + GetCanonicalType(); + // Get the "lldb::BasicType" enumeration for a type. If a type is not a basic + // type eBasicTypeInvalid will be returned + lldb::BasicType + GetBasicType(); + + // The call below confusing and should really be renamed to "CreateBasicType" + lldb::SBType + GetBasicType(lldb::BasicType type); + + uint32_t + GetNumberOfFields (); + + uint32_t + GetNumberOfDirectBaseClasses (); + + uint32_t + GetNumberOfVirtualBaseClasses (); + + lldb::SBTypeMember + GetFieldAtIndex (uint32_t idx); + + lldb::SBTypeMember + GetDirectBaseClassAtIndex (uint32_t idx); + + lldb::SBTypeMember + GetVirtualBaseClassAtIndex (uint32_t idx); + + uint32_t + GetNumberOfTemplateArguments (); + + lldb::SBType + GetTemplateArgumentType (uint32_t idx); + + lldb::TemplateArgumentKind + GetTemplateArgumentKind (uint32_t idx); + + lldb::SBType + GetFunctionReturnType (); + + lldb::SBTypeList + GetFunctionArgumentTypes (); + + const char* + GetName(); + + lldb::TypeClass + GetTypeClass (); + + bool + IsTypeComplete (); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + lldb::SBType & + operator = (const lldb::SBType &rhs); + + bool + operator == (lldb::SBType &rhs); + + bool + operator != (lldb::SBType &rhs); + +protected: + + lldb_private::TypeImpl & + ref (); + + const lldb_private::TypeImpl & + ref () const; + + lldb::TypeImplSP + GetSP (); + + void + SetSP (const lldb::TypeImplSP &type_impl_sp); + + lldb::TypeImplSP m_opaque_sp; + + friend class SBFunction; + friend class SBModule; + friend class SBTarget; + friend class SBTypeNameSpecifier; + friend class SBTypeMember; + friend class SBTypeList; + friend class SBValue; + + SBType (const lldb_private::ClangASTType &); + SBType (const lldb::TypeSP &); + SBType (const lldb::TypeImplSP &); + +}; + +class SBTypeList +{ +public: + SBTypeList(); + + SBTypeList(const lldb::SBTypeList& rhs); + + ~SBTypeList(); + + lldb::SBTypeList& + operator = (const lldb::SBTypeList& rhs); + + bool + IsValid(); + + void + Append (lldb::SBType type); + + lldb::SBType + GetTypeAtIndex (uint32_t index); + + uint32_t + GetSize(); + + +private: + std::unique_ptr<lldb_private::TypeListImpl> m_opaque_ap; + friend class SBModule; + friend class SBCompileUnit; +}; + + +} // namespace lldb + +#endif // LLDB_SBType_h_ diff --git a/include/lldb/API/SBTypeCategory.h b/include/lldb/API/SBTypeCategory.h new file mode 100644 index 000000000000..f123e931e17d --- /dev/null +++ b/include/lldb/API/SBTypeCategory.h @@ -0,0 +1,168 @@ +//===-- SBTypeCategory.h --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTypeCategory_h_ +#define LLDB_SBTypeCategory_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + + class SBTypeCategory + { + public: + + SBTypeCategory(); + + SBTypeCategory (const lldb::SBTypeCategory &rhs); + + ~SBTypeCategory (); + + bool + IsValid() const; + + bool + GetEnabled (); + + void + SetEnabled (bool); + + const char* + GetName(); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + uint32_t + GetNumFormats (); + + uint32_t + GetNumSummaries (); + + uint32_t + GetNumFilters (); + +#ifndef LLDB_DISABLE_PYTHON + uint32_t + GetNumSynthetics (); +#endif + + SBTypeNameSpecifier + GetTypeNameSpecifierForFilterAtIndex (uint32_t); + + SBTypeNameSpecifier + GetTypeNameSpecifierForFormatAtIndex (uint32_t); + + SBTypeNameSpecifier + GetTypeNameSpecifierForSummaryAtIndex (uint32_t); + +#ifndef LLDB_DISABLE_PYTHON + SBTypeNameSpecifier + GetTypeNameSpecifierForSyntheticAtIndex (uint32_t); +#endif + + SBTypeFilter + GetFilterForType (SBTypeNameSpecifier); + + SBTypeFormat + GetFormatForType (SBTypeNameSpecifier); + +#ifndef LLDB_DISABLE_PYTHON + SBTypeSummary + GetSummaryForType (SBTypeNameSpecifier); +#endif + +#ifndef LLDB_DISABLE_PYTHON + SBTypeSynthetic + GetSyntheticForType (SBTypeNameSpecifier); +#endif + +#ifndef LLDB_DISABLE_PYTHON + SBTypeFilter + GetFilterAtIndex (uint32_t); +#endif + + SBTypeFormat + GetFormatAtIndex (uint32_t); + +#ifndef LLDB_DISABLE_PYTHON + SBTypeSummary + GetSummaryAtIndex (uint32_t); +#endif + +#ifndef LLDB_DISABLE_PYTHON + SBTypeSynthetic + GetSyntheticAtIndex (uint32_t); +#endif + + bool + AddTypeFormat (SBTypeNameSpecifier, + SBTypeFormat); + + bool + DeleteTypeFormat (SBTypeNameSpecifier); + +#ifndef LLDB_DISABLE_PYTHON + bool + AddTypeSummary (SBTypeNameSpecifier, + SBTypeSummary); +#endif + + bool + DeleteTypeSummary (SBTypeNameSpecifier); + + bool + AddTypeFilter (SBTypeNameSpecifier, + SBTypeFilter); + + bool + DeleteTypeFilter (SBTypeNameSpecifier); + +#ifndef LLDB_DISABLE_PYTHON + bool + AddTypeSynthetic (SBTypeNameSpecifier, + SBTypeSynthetic); + + bool + DeleteTypeSynthetic (SBTypeNameSpecifier); +#endif + + lldb::SBTypeCategory & + operator = (const lldb::SBTypeCategory &rhs); + + bool + operator == (lldb::SBTypeCategory &rhs); + + bool + operator != (lldb::SBTypeCategory &rhs); + + protected: + friend class SBDebugger; + + lldb::TypeCategoryImplSP + GetSP (); + + void + SetSP (const lldb::TypeCategoryImplSP &typecategory_impl_sp); + + TypeCategoryImplSP m_opaque_sp; + + SBTypeCategory (const lldb::TypeCategoryImplSP &); + + SBTypeCategory (const char*); + + bool + IsDefaultCategory(); + + }; + +} // namespace lldb + +#endif // LLDB_SBTypeCategory_h_ diff --git a/include/lldb/API/SBTypeFilter.h b/include/lldb/API/SBTypeFilter.h new file mode 100644 index 000000000000..016954943e28 --- /dev/null +++ b/include/lldb/API/SBTypeFilter.h @@ -0,0 +1,92 @@ +//===-- SBTypeFilter.h --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTypeFilter_h_ +#define LLDB_SBTypeFilter_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + + class SBTypeFilter + { + public: + + SBTypeFilter(); + + SBTypeFilter (uint32_t options); // see lldb::eTypeOption values + + SBTypeFilter (const lldb::SBTypeFilter &rhs); + + ~SBTypeFilter (); + + bool + IsValid() const; + + uint32_t + GetNumberOfExpressionPaths (); + + const char* + GetExpressionPathAtIndex (uint32_t i); + + bool + ReplaceExpressionPathAtIndex (uint32_t i, const char* item); + + void + AppendExpressionPath (const char* item); + + void + Clear(); + + uint32_t + GetOptions(); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + lldb::SBTypeFilter & + operator = (const lldb::SBTypeFilter &rhs); + + bool + IsEqualTo (lldb::SBTypeFilter &rhs); + + bool + operator == (lldb::SBTypeFilter &rhs); + + bool + operator != (lldb::SBTypeFilter &rhs); + + protected: + friend class SBDebugger; + friend class SBTypeCategory; + friend class SBValue; + + lldb::TypeFilterImplSP + GetSP (); + + void + SetSP (const lldb::TypeFilterImplSP &typefilter_impl_sp); + + lldb::TypeFilterImplSP m_opaque_sp; + + SBTypeFilter (const lldb::TypeFilterImplSP &); + + bool + CopyOnWrite_Impl(); + + }; + + +} // namespace lldb + +#endif // LLDB_SBTypeFilter_h_ diff --git a/include/lldb/API/SBTypeFormat.h b/include/lldb/API/SBTypeFormat.h new file mode 100644 index 000000000000..cd6345fbe6fa --- /dev/null +++ b/include/lldb/API/SBTypeFormat.h @@ -0,0 +1,84 @@ +//===-- SBTypeFormat.h --------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTypeFormat_h_ +#define LLDB_SBTypeFormat_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBTypeFormat +{ +public: + + SBTypeFormat(); + + SBTypeFormat (lldb::Format format, + uint32_t options = 0); // see lldb::eTypeOption values + + SBTypeFormat (const lldb::SBTypeFormat &rhs); + + ~SBTypeFormat (); + + bool + IsValid() const; + + lldb::Format + GetFormat (); + + uint32_t + GetOptions(); + + void + SetFormat (lldb::Format); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + lldb::SBTypeFormat & + operator = (const lldb::SBTypeFormat &rhs); + + bool + IsEqualTo (lldb::SBTypeFormat &rhs); + + bool + operator == (lldb::SBTypeFormat &rhs); + + bool + operator != (lldb::SBTypeFormat &rhs); + +protected: + friend class SBDebugger; + friend class SBTypeCategory; + friend class SBValue; + + lldb::TypeFormatImplSP + GetSP (); + + void + SetSP (const lldb::TypeFormatImplSP &typeformat_impl_sp); + + lldb::TypeFormatImplSP m_opaque_sp; + + SBTypeFormat (const lldb::TypeFormatImplSP &); + + bool + CopyOnWrite_Impl(); + +}; + + +} // namespace lldb + +#endif // LLDB_SBTypeFormat_h_ diff --git a/include/lldb/API/SBTypeNameSpecifier.h b/include/lldb/API/SBTypeNameSpecifier.h new file mode 100644 index 000000000000..19d1988aa0c5 --- /dev/null +++ b/include/lldb/API/SBTypeNameSpecifier.h @@ -0,0 +1,77 @@ +//===-- SBTypeNameSpecifier.h --------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTypeNameSpecifier_h_ +#define LLDB_SBTypeNameSpecifier_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + + class SBTypeNameSpecifier + { + public: + + SBTypeNameSpecifier(); + + SBTypeNameSpecifier (const char* name, + bool is_regex = false); + + SBTypeNameSpecifier (SBType type); + + SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs); + + ~SBTypeNameSpecifier (); + + bool + IsValid() const; + + const char* + GetName(); + + SBType + GetType (); + + bool + IsRegex(); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + lldb::SBTypeNameSpecifier & + operator = (const lldb::SBTypeNameSpecifier &rhs); + + bool + IsEqualTo (lldb::SBTypeNameSpecifier &rhs); + + bool + operator == (lldb::SBTypeNameSpecifier &rhs); + + bool + operator != (lldb::SBTypeNameSpecifier &rhs); + + protected: + friend class SBDebugger; + friend class SBTypeCategory; + + lldb::TypeNameSpecifierImplSP + GetSP (); + + void + SetSP (const lldb::TypeNameSpecifierImplSP &type_namespec_sp); + + lldb::TypeNameSpecifierImplSP m_opaque_sp; + + SBTypeNameSpecifier (const lldb::TypeNameSpecifierImplSP &); + }; + +} // namespace lldb + +#endif // LLDB_SBTypeNameSpecifier_h_ diff --git a/include/lldb/API/SBTypeSummary.h b/include/lldb/API/SBTypeSummary.h new file mode 100644 index 000000000000..67a8607511cc --- /dev/null +++ b/include/lldb/API/SBTypeSummary.h @@ -0,0 +1,115 @@ +//===-- SBTypeSummary.h -------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTypeSummary_h_ +#define LLDB_SBTypeSummary_h_ + +#include "lldb/API/SBDefines.h" + +#ifndef LLDB_DISABLE_PYTHON + +namespace lldb { + + class SBTypeSummary + { + public: + + SBTypeSummary(); + + static SBTypeSummary + CreateWithSummaryString (const char* data, + uint32_t options = 0); // see lldb::eTypeOption values + + static SBTypeSummary + CreateWithFunctionName (const char* data, + uint32_t options = 0); // see lldb::eTypeOption values + + static SBTypeSummary + CreateWithScriptCode (const char* data, + uint32_t options = 0); // see lldb::eTypeOption values + + SBTypeSummary (const lldb::SBTypeSummary &rhs); + + ~SBTypeSummary (); + + bool + IsValid() const; + + bool + IsFunctionCode(); + + bool + IsFunctionName(); + + bool + IsSummaryString(); + + const char* + GetData (); + + void + SetSummaryString (const char* data); + + void + SetFunctionName (const char* data); + + void + SetFunctionCode (const char* data); + + uint32_t + GetOptions (); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + lldb::SBTypeSummary & + operator = (const lldb::SBTypeSummary &rhs); + + bool + IsEqualTo (lldb::SBTypeSummary &rhs); + + bool + operator == (lldb::SBTypeSummary &rhs); + + bool + operator != (lldb::SBTypeSummary &rhs); + + protected: + friend class SBDebugger; + friend class SBTypeCategory; + friend class SBValue; + + lldb::TypeSummaryImplSP + GetSP (); + + void + SetSP (const lldb::TypeSummaryImplSP &typefilter_impl_sp); + + lldb::TypeSummaryImplSP m_opaque_sp; + + SBTypeSummary (const lldb::TypeSummaryImplSP &); + + bool + CopyOnWrite_Impl(); + + bool + ChangeSummaryType (bool want_script); + + }; + + +} // namespace lldb + +#endif // LLDB_DISABLE_PYTHON + +#endif // LLDB_SBTypeSummary_h_ diff --git a/include/lldb/API/SBTypeSynthetic.h b/include/lldb/API/SBTypeSynthetic.h new file mode 100644 index 000000000000..e77cbfef598c --- /dev/null +++ b/include/lldb/API/SBTypeSynthetic.h @@ -0,0 +1,102 @@ +//===-- SBTypeSynthetic.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBTypeSynthetic_h_ +#define LLDB_SBTypeSynthetic_h_ + +#include "lldb/API/SBDefines.h" + +#ifndef LLDB_DISABLE_PYTHON + +namespace lldb { + + class SBTypeSynthetic + { + public: + + SBTypeSynthetic(); + + static SBTypeSynthetic + CreateWithClassName (const char* data, + uint32_t options = 0); // see lldb::eTypeOption values + + static SBTypeSynthetic + CreateWithScriptCode (const char* data, + uint32_t options = 0); // see lldb::eTypeOption values + + SBTypeSynthetic (const lldb::SBTypeSynthetic &rhs); + + ~SBTypeSynthetic (); + + bool + IsValid() const; + + bool + IsClassCode(); + + bool + IsClassName(); + + const char* + GetData (); + + void + SetClassName (const char* data); + + void + SetClassCode (const char* data); + + uint32_t + GetOptions (); + + void + SetOptions (uint32_t); + + bool + GetDescription (lldb::SBStream &description, + lldb::DescriptionLevel description_level); + + lldb::SBTypeSynthetic & + operator = (const lldb::SBTypeSynthetic &rhs); + + bool + IsEqualTo (lldb::SBTypeSynthetic &rhs); + + bool + operator == (lldb::SBTypeSynthetic &rhs); + + bool + operator != (lldb::SBTypeSynthetic &rhs); + + protected: + friend class SBDebugger; + friend class SBTypeCategory; + friend class SBValue; + + lldb::ScriptedSyntheticChildrenSP + GetSP (); + + void + SetSP (const lldb::ScriptedSyntheticChildrenSP &typefilter_impl_sp); + + lldb::ScriptedSyntheticChildrenSP m_opaque_sp; + + SBTypeSynthetic (const lldb::ScriptedSyntheticChildrenSP &); + + bool + CopyOnWrite_Impl(); + + }; + + +} // namespace lldb + +#endif // LLDB_DISABLE_PYTHON + +#endif // LLDB_SBTypeSynthetic_h_ diff --git a/include/lldb/API/SBValue.h b/include/lldb/API/SBValue.h new file mode 100644 index 000000000000..2b9a344b9300 --- /dev/null +++ b/include/lldb/API/SBValue.h @@ -0,0 +1,488 @@ +//===-- SBValue.h -----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBValue_h_ +#define LLDB_SBValue_h_ + +#include "lldb/API/SBData.h" +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBType.h" + +class ValueImpl; +class ValueLocker; + +namespace lldb { + +class SBValue +{ +friend class ValueLocker; + +public: + SBValue (); + + SBValue (const lldb::SBValue &rhs); + + lldb::SBValue & + operator =(const lldb::SBValue &rhs); + + ~SBValue (); + + bool + IsValid(); + + void + Clear(); + + SBError + GetError(); + + lldb::user_id_t + GetID (); + + const char * + GetName(); + + const char * + GetTypeName (); + + size_t + GetByteSize (); + + bool + IsInScope (); + + lldb::Format + GetFormat (); + + void + SetFormat (lldb::Format format); + + const char * + GetValue (); + + int64_t + GetValueAsSigned (lldb::SBError& error, int64_t fail_value=0); + + uint64_t + GetValueAsUnsigned (lldb::SBError& error, uint64_t fail_value=0); + + int64_t + GetValueAsSigned(int64_t fail_value=0); + + uint64_t + GetValueAsUnsigned(uint64_t fail_value=0); + + ValueType + GetValueType (); + + bool + GetValueDidChange (); + + const char * + GetSummary (); + + const char * + GetObjectDescription (); + + lldb::SBValue + GetDynamicValue (lldb::DynamicValueType use_dynamic); + + lldb::SBValue + GetStaticValue (); + + lldb::SBValue + GetNonSyntheticValue (); + + lldb::DynamicValueType + GetPreferDynamicValue (); + + void + SetPreferDynamicValue (lldb::DynamicValueType use_dynamic); + + bool + GetPreferSyntheticValue (); + + void + SetPreferSyntheticValue (bool use_synthetic); + + bool + IsDynamic (); + + bool + IsSynthetic (); + + const char * + GetLocation (); + + // Deprecated - use the one that takes SBError& + bool + SetValueFromCString (const char *value_str); + + bool + SetValueFromCString (const char *value_str, lldb::SBError& error); + + lldb::SBTypeFormat + GetTypeFormat (); + +#ifndef LLDB_DISABLE_PYTHON + lldb::SBTypeSummary + GetTypeSummary (); +#endif + + lldb::SBTypeFilter + GetTypeFilter (); + +#ifndef LLDB_DISABLE_PYTHON + lldb::SBTypeSynthetic + GetTypeSynthetic (); +#endif + + lldb::SBValue + GetChildAtIndex (uint32_t idx); + + lldb::SBValue + CreateChildAtOffset (const char *name, uint32_t offset, lldb::SBType type); + + lldb::SBValue + Cast (lldb::SBType type); + + lldb::SBValue + CreateValueFromExpression (const char *name, const char* expression); + + lldb::SBValue + CreateValueFromExpression (const char *name, const char* expression, SBExpressionOptions &options); + + lldb::SBValue + CreateValueFromAddress (const char* name, + lldb::addr_t address, + lldb::SBType type); + + // this has no address! GetAddress() and GetLoadAddress() as well as AddressOf() + // on the return of this call all return invalid + lldb::SBValue + CreateValueFromData (const char* name, + lldb::SBData data, + lldb::SBType type); + + //------------------------------------------------------------------ + /// Get a child value by index from a value. + /// + /// Structs, unions, classes, arrays and and pointers have child + /// values that can be access by index. + /// + /// Structs and unions access child members using a zero based index + /// for each child member. For + /// + /// Classes reserve the first indexes for base classes that have + /// members (empty base classes are omitted), and all members of the + /// current class will then follow the base classes. + /// + /// Pointers differ depending on what they point to. If the pointer + /// points to a simple type, the child at index zero + /// is the only child value available, unless \a synthetic_allowed + /// is \b true, in which case the pointer will be used as an array + /// and can create 'synthetic' child values using positive or + /// negative indexes. If the pointer points to an aggregate type + /// (an array, class, union, struct), then the pointee is + /// transparently skipped and any children are going to be the indexes + /// of the child values within the aggregate type. For example if + /// we have a 'Point' type and we have a SBValue that contains a + /// pointer to a 'Point' type, then the child at index zero will be + /// the 'x' member, and the child at index 1 will be the 'y' member + /// (the child at index zero won't be a 'Point' instance). + /// + /// Arrays have a preset number of children that can be accessed by + /// index and will returns invalid child values for indexes that are + /// out of bounds unless the \a synthetic_allowed is \b true. In this + /// case the array can create 'synthetic' child values for indexes + /// that aren't in the array bounds using positive or negative + /// indexes. + /// + /// @param[in] idx + /// The index of the child value to get + /// + /// @param[in] use_dynamic + /// An enumeration that specifies wether to get dynamic values, + /// and also if the target can be run to figure out the dynamic + /// type of the child value. + /// + /// @param[in] synthetic_allowed + /// If \b true, then allow child values to be created by index + /// for pointers and arrays for indexes that normally wouldn't + /// be allowed. + /// + /// @return + /// A new SBValue object that represents the child member value. + //------------------------------------------------------------------ + lldb::SBValue + GetChildAtIndex (uint32_t idx, + lldb::DynamicValueType use_dynamic, + bool can_create_synthetic); + + // Matches children of this object only and will match base classes and + // member names if this is a clang typed object. + uint32_t + GetIndexOfChildWithName (const char *name); + + // Matches child members of this object and child members of any base + // classes. + lldb::SBValue + GetChildMemberWithName (const char *name); + + // Matches child members of this object and child members of any base + // classes. + lldb::SBValue + GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic); + + // Expands nested expressions like .a->b[0].c[1]->d + lldb::SBValue + GetValueForExpressionPath(const char* expr_path); + + lldb::SBValue + AddressOf(); + + lldb::addr_t + GetLoadAddress(); + + lldb::SBAddress + GetAddress(); + + //------------------------------------------------------------------ + /// Get an SBData wrapping what this SBValue points to. + /// + /// This method will dereference the current SBValue, if its + /// data type is a T* or T[], and extract item_count elements + /// of type T from it, copying their contents in an SBData. + /// + /// @param[in] item_idx + /// The index of the first item to retrieve. For an array + /// this is equivalent to array[item_idx], for a pointer + /// to *(pointer + item_idx). In either case, the measurement + /// unit for item_idx is the sizeof(T) rather than the byte + /// + /// @param[in] item_count + /// How many items should be copied into the output. By default + /// only one item is copied, but more can be asked for. + /// + /// @return + /// An SBData with the contents of the copied items, on success. + /// An empty SBData otherwise. + //------------------------------------------------------------------ + lldb::SBData + GetPointeeData (uint32_t item_idx = 0, + uint32_t item_count = 1); + + //------------------------------------------------------------------ + /// Get an SBData wrapping the contents of this SBValue. + /// + /// This method will read the contents of this object in memory + /// and copy them into an SBData for future use. + /// + /// @return + /// An SBData with the contents of this SBValue, on success. + /// An empty SBData otherwise. + //------------------------------------------------------------------ + lldb::SBData + GetData (); + + bool + SetData (lldb::SBData &data, lldb::SBError& error); + + lldb::SBDeclaration + GetDeclaration (); + + //------------------------------------------------------------------ + /// Find out if a SBValue might have children. + /// + /// This call is much more efficient than GetNumChildren() as it + /// doesn't need to complete the underlying type. This is designed + /// to be used in a UI environment in order to detect if the + /// disclosure triangle should be displayed or not. + /// + /// This function returns true for class, union, structure, + /// pointers, references, arrays and more. Again, it does so without + /// doing any expensive type completion. + /// + /// @return + /// Returns \b true if the SBValue might have children, or \b + /// false otherwise. + //------------------------------------------------------------------ + bool + MightHaveChildren (); + + uint32_t + GetNumChildren (); + + void * + GetOpaqueType(); + + lldb::SBTarget + GetTarget(); + + lldb::SBProcess + GetProcess(); + + lldb::SBThread + GetThread(); + + lldb::SBFrame + GetFrame(); + + lldb::SBValue + Dereference (); + + bool + TypeIsPointerType (); + + lldb::SBType + GetType(); + + bool + GetDescription (lldb::SBStream &description); + + bool + GetExpressionPath (lldb::SBStream &description); + + bool + GetExpressionPath (lldb::SBStream &description, + bool qualify_cxx_base_classes); + + SBValue (const lldb::ValueObjectSP &value_sp); + + //------------------------------------------------------------------ + /// Watch this value if it resides in memory. + /// + /// Sets a watchpoint on the value. + /// + /// @param[in] resolve_location + /// Resolve the location of this value once and watch its address. + /// This value must currently be set to \b true as watching all + /// locations of a variable or a variable path is not yet supported, + /// though we plan to support it in the future. + /// + /// @param[in] read + /// Stop when this value is accessed. + /// + /// @param[in] write + /// Stop when this value is modified + /// + /// @param[out] + /// An error object. Contains the reason if there is some failure. + /// + /// @return + /// An SBWatchpoint object. This object might not be valid upon + /// return due to a value not being contained in memory, too + /// large, or watchpoint resources are not available or all in + /// use. + //------------------------------------------------------------------ + lldb::SBWatchpoint + Watch (bool resolve_location, bool read, bool write, SBError &error); + + // Backward compatibility fix in the interim. + lldb::SBWatchpoint + Watch (bool resolve_location, bool read, bool write); + + //------------------------------------------------------------------ + /// Watch this value that this value points to in memory + /// + /// Sets a watchpoint on the value. + /// + /// @param[in] resolve_location + /// Resolve the location of this value once and watch its address. + /// This value must currently be set to \b true as watching all + /// locations of a variable or a variable path is not yet supported, + /// though we plan to support it in the future. + /// + /// @param[in] read + /// Stop when this value is accessed. + /// + /// @param[in] write + /// Stop when this value is modified + /// + /// @param[out] + /// An error object. Contains the reason if there is some failure. + /// + /// @return + /// An SBWatchpoint object. This object might not be valid upon + /// return due to a value not being contained in memory, too + /// large, or watchpoint resources are not available or all in + /// use. + //------------------------------------------------------------------ + lldb::SBWatchpoint + WatchPointee (bool resolve_location, bool read, bool write, SBError &error); + + //------------------------------------------------------------------ + /// Same as the protected version of GetSP that takes a locker, except that we make the + /// locker locally in the function. Since the Target API mutex is recursive, and the + /// StopLocker is a read lock, you can call this function even if you are already + /// holding the two above-mentioned locks. + /// + /// @return + /// A ValueObjectSP of the best kind (static, dynamic or synthetic) we + /// can cons up, in accordance with the SBValue's settings. + //------------------------------------------------------------------ + lldb::ValueObjectSP + GetSP () const; + +protected: + friend class SBBlock; + friend class SBFrame; + friend class SBTarget; + friend class SBThread; + friend class SBValueList; + + //------------------------------------------------------------------ + /// Get the appropriate ValueObjectSP from this SBValue, consulting the + /// use_dynamic and use_synthetic options passed in to SetSP when the + /// SBValue's contents were set. Since this often requires examining memory, + /// and maybe even running code, it needs to acquire the Target API and Process StopLock. + /// Those are held in an opaque class ValueLocker which is currently local to SBValue.cpp. + /// So you don't have to get these yourself just default construct a ValueLocker, and pass it into this. + /// If we need to make a ValueLocker and use it in some other .cpp file, we'll have to move it to + /// ValueObject.h/cpp or somewhere else convenient. We haven't needed to so far. + /// + /// @param[in] value_locker + /// An object that will hold the Target API, and Process RunLocks, and + /// auto-destroy them when it goes out of scope. Currently this is only useful in + /// SBValue.cpp. + /// + /// @return + /// A ValueObjectSP of the best kind (static, dynamic or synthetic) we + /// can cons up, in accordance with the SBValue's settings. + //------------------------------------------------------------------ + lldb::ValueObjectSP + GetSP (ValueLocker &value_locker) const; + + // these calls do the right thing WRT adjusting their settings according to the target's preferences + void + SetSP (const lldb::ValueObjectSP &sp); + + void + SetSP (const lldb::ValueObjectSP &sp, bool use_synthetic); + + void + SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic); + + void + SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic, bool use_synthetic); + + void + SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, const char *name); + +private: + typedef std::shared_ptr<ValueImpl> ValueImplSP; + ValueImplSP m_opaque_sp; + + void + SetSP (ValueImplSP impl_sp); +}; + +} // namespace lldb + +#endif // LLDB_SBValue_h_ diff --git a/include/lldb/API/SBValueList.h b/include/lldb/API/SBValueList.h new file mode 100644 index 000000000000..b9a6aedea3cb --- /dev/null +++ b/include/lldb/API/SBValueList.h @@ -0,0 +1,93 @@ +//===-- SBValueList.h -------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBValueList_h_ +#define LLDB_SBValueList_h_ + +#include "lldb/API/SBDefines.h" + +class ValueListImpl; + +namespace lldb { + +class SBValueList +{ +public: + + SBValueList (); + + SBValueList (const lldb::SBValueList &rhs); + + ~SBValueList(); + + bool + IsValid() const; + + void + Clear(); + + void + Append (const lldb::SBValue &val_obj); + + void + Append (const lldb::SBValueList& value_list); + + uint32_t + GetSize() const; + + lldb::SBValue + GetValueAtIndex (uint32_t idx) const; + + lldb::SBValue + FindValueObjectByUID (lldb::user_id_t uid); + + const lldb::SBValueList & + operator = (const lldb::SBValueList &rhs); + +protected: + + // only useful for visualizing the pointer or comparing two SBValueLists + // to see if they are backed by the same underlying Impl. + void * + opaque_ptr (); + +private: + friend class SBFrame; + + SBValueList (const ValueListImpl *lldb_object_ptr); + + void + Append (lldb::ValueObjectSP& val_obj_sp); + + void + CreateIfNeeded (); + + ValueListImpl * + operator -> (); + + ValueListImpl & + operator* (); + + const ValueListImpl * + operator -> () const; + + const ValueListImpl & + operator* () const; + + + ValueListImpl & + ref (); + + std::unique_ptr<ValueListImpl> m_opaque_ap; +}; + + +} // namespace lldb + +#endif // LLDB_SBValueList_h_ diff --git a/include/lldb/API/SBWatchpoint.h b/include/lldb/API/SBWatchpoint.h new file mode 100644 index 000000000000..9bf51fd1ad05 --- /dev/null +++ b/include/lldb/API/SBWatchpoint.h @@ -0,0 +1,104 @@ +//===-- SBWatchpoint.h ----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLDB_SBWatchpoint_h_ +#define LLDB_SBWatchpoint_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBWatchpoint +{ +public: + + SBWatchpoint (); + + SBWatchpoint (const lldb::SBWatchpoint &rhs); + + SBWatchpoint (const lldb::WatchpointSP &wp_sp); + + ~SBWatchpoint (); + + const lldb::SBWatchpoint & + operator = (const lldb::SBWatchpoint &rhs); + + bool + IsValid() const; + + SBError + GetError(); + + watch_id_t + GetID (); + + /// With -1 representing an invalid hardware index. + int32_t + GetHardwareIndex (); + + lldb::addr_t + GetWatchAddress (); + + size_t + GetWatchSize(); + + void + SetEnabled(bool enabled); + + bool + IsEnabled (); + + uint32_t + GetHitCount (); + + uint32_t + GetIgnoreCount (); + + void + SetIgnoreCount (uint32_t n); + + const char * + GetCondition (); + + void + SetCondition (const char *condition); + + bool + GetDescription (lldb::SBStream &description, DescriptionLevel level); + + void + Clear (); + + lldb::WatchpointSP + GetSP () const; + + void + SetSP (const lldb::WatchpointSP &sp); + + static bool + EventIsWatchpointEvent (const lldb::SBEvent &event); + + static lldb::WatchpointEventType + GetWatchpointEventTypeFromEvent (const lldb::SBEvent& event); + + static lldb::SBWatchpoint + GetWatchpointFromEvent (const lldb::SBEvent& event); + +private: + friend class SBTarget; + friend class SBValue; + + + lldb::WatchpointSP m_opaque_sp; + +}; + +} // namespace lldb + +#endif // LLDB_SBWatchpoint_h_ |