diff options
author | Ed Maste <emaste@FreeBSD.org> | 2013-11-06 16:48:53 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2013-11-06 16:48:53 +0000 |
commit | f21a844f60ae6c74fcf1fddca32461acce3c1ee0 (patch) | |
tree | 56d79f94966870db1cecd65a7264510a25fd1cba /include | |
parent | 37d22554be9f5a677dad2a95b7ef22fe59c66a8a (diff) | |
download | src-f21a844f60ae6c74fcf1fddca32461acce3c1ee0.tar.gz src-f21a844f60ae6c74fcf1fddca32461acce3c1ee0.zip |
Import lldb as of SVN r194122vendor/lldb/lldb-r194122
Sponsored by: DARPA, AFRL
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=257752
svn path=/vendor/lldb/lldb-r194122/; revision=257753; tag=vendor/lldb/lldb-r194122
Diffstat (limited to 'include')
107 files changed, 2963 insertions, 936 deletions
diff --git a/include/lldb/API/SBHostOS.h b/include/lldb/API/SBHostOS.h index 52754ea4e829..e5fab6fe7849 100644 --- a/include/lldb/API/SBHostOS.h +++ b/include/lldb/API/SBHostOS.h @@ -30,7 +30,7 @@ public: static lldb::thread_t ThreadCreate (const char *name, - void *(*thread_function)(void *), + thread_func_t thread_function, void *thread_arg, lldb::SBError *err); @@ -43,7 +43,7 @@ public: lldb::SBError *err); static bool ThreadJoin (lldb::thread_t thread, - void **result, + thread_result_t *result, lldb::SBError *err); diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h index 784f362122a9..4ecaeaa49920 100644 --- a/include/lldb/API/SBProcess.h +++ b/include/lldb/API/SBProcess.h @@ -269,6 +269,38 @@ public: lldb::SBError UnloadImage (uint32_t image_token); + //------------------------------------------------------------------ + /// Return the number of different thread-origin extended backtraces + /// this process can support. + /// + /// When the process is stopped and you have an SBThread, lldb may be + /// able to show a backtrace of when that thread was originally created, + /// or the work item was enqueued to it (in the case of a libdispatch + /// queue). + /// + /// @return + /// The number of thread-origin extended backtrace types that may be + /// available. + //------------------------------------------------------------------ + uint32_t + GetNumExtendedBacktraceTypes (); + + //------------------------------------------------------------------ + /// Return the name of one of the thread-origin extended backtrace + /// methods. + /// + /// @param [in] idx + /// The index of the name to return. They will be returned in + /// the order that the user will most likely want to see them. + /// e.g. if the type at index 0 is not available for a thread, + /// see if the type at index 1 provides an extended backtrace. + /// + /// @return + /// The name at that index. + //------------------------------------------------------------------ + const char * + GetExtendedBacktraceTypeAtIndex (uint32_t idx); + protected: friend class SBAddress; friend class SBBreakpoint; diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h index 15aeed4b600c..7bcf91c16d77 100644 --- a/include/lldb/API/SBTarget.h +++ b/include/lldb/API/SBTarget.h @@ -747,6 +747,9 @@ public: lldb::SBType GetBasicType(lldb::BasicType type); + lldb::SBValue + CreateValueFromAddress (const char *name, lldb::SBAddress addr, lldb::SBType type); + SBSourceManager GetSourceManager(); diff --git a/include/lldb/API/SBThread.h b/include/lldb/API/SBThread.h index 9645f925035e..d062d7121303 100644 --- a/include/lldb/API/SBThread.h +++ b/include/lldb/API/SBThread.h @@ -94,6 +94,9 @@ public: const char * GetQueueName() const; + lldb::queue_id_t + GetQueueID() const; + void StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); @@ -117,6 +120,9 @@ public: lldb::SBFileSpec &file_spec, uint32_t line); + SBError + JumpToLine (lldb::SBFileSpec &file_spec, uint32_t line); + void RunToAddress (lldb::addr_t addr); @@ -195,6 +201,9 @@ public: bool GetStatus (lldb::SBStream &status) const; + SBThread + GetExtendedBacktrace (const char *type); + protected: friend class SBBreakpoint; friend class SBBreakpointLocation; diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h index bd11a1c91e21..30cc3314af3a 100644 --- a/include/lldb/Breakpoint/Breakpoint.h +++ b/include/lldb/Breakpoint/Breakpoint.h @@ -576,6 +576,12 @@ public: InvokeCallback (StoppointCallbackContext *context, lldb::break_id_t bp_loc_id); + bool + IsHardware() const + { + return m_hardware; + } + protected: friend class Target; //------------------------------------------------------------------ @@ -590,7 +596,10 @@ protected: /// variants that make breakpoints for some common cases. //------------------------------------------------------------------ // This is the generic constructor - Breakpoint(Target &target, lldb::SearchFilterSP &filter_sp, lldb::BreakpointResolverSP &resolver_sp); + Breakpoint(Target &target, + lldb::SearchFilterSP &filter_sp, + lldb::BreakpointResolverSP &resolver_sp, + bool hardware); friend class BreakpointLocation; // To call the following two when determining whether to stop. @@ -609,12 +618,13 @@ private: // For Breakpoint only //------------------------------------------------------------------ bool m_being_created; + bool m_hardware; // If this breakpoint is required to use a hardware breakpoint Target &m_target; // The target that holds this breakpoint. lldb::SearchFilterSP m_filter_sp; // The filter that constrains the breakpoint's domain. lldb::BreakpointResolverSP m_resolver_sp; // The resolver that defines this breakpoint. BreakpointOptions m_options; // Settable breakpoint options BreakpointLocationList m_locations; // The list of locations currently found for this breakpoint. - std::string m_kind_description; + std::string m_kind_description; void SendBreakpointChangedEvent (lldb::BreakpointEventType eventKind); diff --git a/include/lldb/Breakpoint/BreakpointList.h b/include/lldb/Breakpoint/BreakpointList.h index 97eb2b46bc0c..c6708db118df 100644 --- a/include/lldb/Breakpoint/BreakpointList.h +++ b/include/lldb/Breakpoint/BreakpointList.h @@ -149,11 +149,17 @@ public: /// @param[in] module_list /// The module list that has changed. /// - /// @param[in] added + /// @param[in] load /// \b true if the modules are loaded, \b false if unloaded. + /// + /// @param[in] delete_locations + /// If \a load is \b false, then delete breakpoint locations when + /// when updating breakpoints. //------------------------------------------------------------------ void - UpdateBreakpoints (ModuleList &module_list, bool added); + UpdateBreakpoints (ModuleList &module_list, + bool load, + bool delete_locations); void UpdateBreakpointsWhenModuleIsReplaced (lldb::ModuleSP old_module_sp, lldb::ModuleSP new_module_sp); diff --git a/include/lldb/Breakpoint/BreakpointLocation.h b/include/lldb/Breakpoint/BreakpointLocation.h index 9ab0a79c6844..f4ba21a385f8 100644 --- a/include/lldb/Breakpoint/BreakpointLocation.h +++ b/include/lldb/Breakpoint/BreakpointLocation.h @@ -324,7 +324,6 @@ public: protected: friend class BreakpointLocationList; - friend class CommandObjectBreakpointCommandAdd; friend class Process; //------------------------------------------------------------------ @@ -375,8 +374,8 @@ private: BreakpointLocation (lldb::break_id_t bid, Breakpoint &owner, const Address &addr, - lldb::tid_t tid = LLDB_INVALID_THREAD_ID, - bool hardware = false); + lldb::tid_t tid, + bool hardware); //------------------------------------------------------------------ // Data members: diff --git a/include/lldb/Breakpoint/BreakpointResolver.h b/include/lldb/Breakpoint/BreakpointResolver.h index 3db3795453e8..184bdc950cbc 100644 --- a/include/lldb/Breakpoint/BreakpointResolver.h +++ b/include/lldb/Breakpoint/BreakpointResolver.h @@ -134,6 +134,13 @@ public: } protected: + //------------------------------------------------------------------ + /// SetSCMatchesByLine - Takes a symbol context list of matches which supposedly represent the same file and + /// line number in a CU, and find the nearest actual line number that matches, and then filter down the + /// matching addresses to unique entries, and skip the prologue if asked to do so, and then set + /// breakpoint locations in this breakpoint for all the resultant addresses. + void SetSCMatchesByLine (SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, const char *log_ident); + Breakpoint *m_breakpoint; // This is the breakpoint we add locations to. private: diff --git a/include/lldb/Breakpoint/BreakpointSiteList.h b/include/lldb/Breakpoint/BreakpointSiteList.h index 0d4dafc4baab..d7bb8fd777ef 100644 --- a/include/lldb/Breakpoint/BreakpointSiteList.h +++ b/include/lldb/Breakpoint/BreakpointSiteList.h @@ -13,6 +13,7 @@ // C Includes // C++ Includes #include <map> +#include <functional> // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointSite.h" diff --git a/include/lldb/Breakpoint/StoppointLocation.h b/include/lldb/Breakpoint/StoppointLocation.h index ccedc511951d..452c6388c82d 100644 --- a/include/lldb/Breakpoint/StoppointLocation.h +++ b/include/lldb/Breakpoint/StoppointLocation.h @@ -72,20 +72,20 @@ public: uint32_t GetHardwareIndex () const { - return m_hw_index; + return m_hardware_index; } bool - HardwarePreferred () const + HardwareRequired () const { - return m_hw_preferred; + return m_hardware; } virtual bool IsHardware () const { - return m_hw_index != LLDB_INVALID_INDEX32; + return m_hardware_index != LLDB_INVALID_INDEX32; } @@ -103,7 +103,7 @@ public: void SetHardwareIndex (uint32_t index) { - m_hw_index = index; + m_hardware_index = index; } @@ -120,8 +120,8 @@ protected: lldb::break_id_t m_loc_id; // Stoppoint location ID lldb::addr_t m_addr; // The load address of this stop point. The base Stoppoint doesn't // store a full Address since that's not needed for the breakpoint sites. - bool m_hw_preferred; // 1 if this point has been requested to be set using hardware (which may fail due to lack of resources) - uint32_t m_hw_index; // The hardware resource index for this breakpoint/watchpoint + bool m_hardware; // True if this point has been is required to use hardware (which may fail due to lack of resources) + uint32_t m_hardware_index; // The hardware resource index for this breakpoint/watchpoint uint32_t m_byte_size; // The size in bytes of stop location. e.g. the length of the trap opcode for // software breakpoints, or the optional length in bytes for // hardware breakpoints, or the length of the watchpoint. diff --git a/include/lldb/Core/Address.h b/include/lldb/Core/Address.h index 60cd4a86bd4a..da7cc5c03d38 100644 --- a/include/lldb/Core/Address.h +++ b/include/lldb/Core/Address.h @@ -540,6 +540,18 @@ protected: //------------------------------------------------------------------ lldb::SectionWP m_section_wp; ///< The section for the address, can be NULL. std::atomic<lldb::addr_t> m_offset; ///< Offset into section if \a m_section_wp is valid... + + //------------------------------------------------------------------ + // Returns true if the m_section_wp once had a reference to a valid + // section shared pointer, but no longer does. This can happen if + // we have an address from a module that gets unloaded and deleted. + // This function should only be called if GetSection() returns an + // empty shared pointer and you want to know if this address used to + // have a valid section. + //------------------------------------------------------------------ + bool + SectionWasDeleted() const; + }; diff --git a/include/lldb/Core/ArchSpec.h b/include/lldb/Core/ArchSpec.h index 3bfa96be0cee..7f2fd77a0934 100644 --- a/include/lldb/Core/ArchSpec.h +++ b/include/lldb/Core/ArchSpec.h @@ -41,6 +41,7 @@ public: eCore_arm_armv5e, eCore_arm_armv5t, eCore_arm_armv6, + eCore_arm_armv6m, eCore_arm_armv7, eCore_arm_armv7f, eCore_arm_armv7s, @@ -53,6 +54,7 @@ public: eCore_thumbv5, eCore_thumbv5e, eCore_thumbv6, + eCore_thumbv6m, eCore_thumbv7, eCore_thumbv7f, eCore_thumbv7s, @@ -60,6 +62,8 @@ public: eCore_thumbv7m, eCore_thumbv7em, + eCore_mips64, + eCore_ppc_generic, eCore_ppc_ppc601, eCore_ppc_ppc602, diff --git a/include/lldb/Core/ConnectionFileDescriptor.h b/include/lldb/Core/ConnectionFileDescriptor.h index fe704d4cadf7..3a2f0dd1ed0b 100644 --- a/include/lldb/Core/ConnectionFileDescriptor.h +++ b/include/lldb/Core/ConnectionFileDescriptor.h @@ -11,20 +11,27 @@ #define liblldb_ConnectionFileDescriptor_h_ // C Includes +#ifdef _WIN32 +typedef unsigned short in_port_t; +#else #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> +#endif // C++ Includes +#include <memory> + // Other libraries and framework includes // Project includes #include "lldb/Core/Connection.h" #include "lldb/Host/Mutex.h" #include "lldb/Host/Predicate.h" -#include "lldb/Host/SocketAddress.h" namespace lldb_private { +class SocketAddress; + class ConnectionFileDescriptor : public Connection { @@ -70,6 +77,13 @@ public: GetWritePort () const; protected: + + typedef enum + { + eFDTypeFile, // Other FD requireing read/write + eFDTypeSocket, // Socket requiring send/recv + eFDTypeSocketUDP // Unconnected UDP socket requiring sendto/recvfrom + } FDType; void OpenCommandPipe (); @@ -96,20 +110,13 @@ protected: NamedSocketConnect (const char *socket_name, Error *error_ptr); lldb::ConnectionStatus - Close (int& fd, Error *error); - - typedef enum - { - eFDTypeFile, // Other FD requireing read/write - eFDTypeSocket, // Socket requiring send/recv - eFDTypeSocketUDP // Unconnected UDP socket requiring sendto/recvfrom - } FDType; + Close (int& fd, FDType type, Error *error); int m_fd_send; int m_fd_recv; FDType m_fd_send_type; FDType m_fd_recv_type; - SocketAddress m_udp_send_sockaddr; + std::unique_ptr<SocketAddress> m_udp_send_sockaddr; bool m_should_close_fd; // True if this class should close the file descriptor when it goes away. uint32_t m_socket_timeout_usec; int m_pipe_read; // A pipe that we select on the reading end of along with diff --git a/include/lldb/Core/ConnectionMachPort.h b/include/lldb/Core/ConnectionMachPort.h index 5613e7ee8008..04ec7f69136b 100644 --- a/include/lldb/Core/ConnectionMachPort.h +++ b/include/lldb/Core/ConnectionMachPort.h @@ -12,7 +12,8 @@ #define liblldb_ConnectionMachPort_h_ // C Includes -#include <mach/mach.h> +#include <mach/port.h> +#include <mach/kern_return.h> // C++ Includes #include <string> diff --git a/include/lldb/Core/ConstString.h b/include/lldb/Core/ConstString.h index e692d3b96e5d..684cc8f921ed 100644 --- a/include/lldb/Core/ConstString.h +++ b/include/lldb/Core/ConstString.h @@ -86,7 +86,7 @@ public: /// @param[in] cstr /// A pointer to the first character in the C string. The C /// string can be NULL terminated in a buffer that contains - /// more characters than the length of the stirng, or the + /// more characters than the length of the string, or the /// string can be part of another string and a new substring /// can be created. /// @@ -148,11 +148,11 @@ public: /// /b True this object contains a valid non-empty C string, \b /// false otherwise. //------------------------------------------------------------------ - operator bool() const + explicit operator bool() const { return m_string && m_string[0]; } - + //------------------------------------------------------------------ /// Assignment operator /// diff --git a/include/lldb/Core/DataExtractor.h b/include/lldb/Core/DataExtractor.h index a8593043cb15..c9db2dab73d2 100644 --- a/include/lldb/Core/DataExtractor.h +++ b/include/lldb/Core/DataExtractor.h @@ -468,6 +468,27 @@ public: } //------------------------------------------------------------------ + /// Copy \a length bytes from \a *offset, without swapping bytes. + /// + /// @param[in] offset + /// The offset into this data from which to start copying + /// + /// @param[in] length + /// The length of the data to copy from this object + /// + /// @param[out] dst + /// The buffer to place the output data. + /// + /// @return + /// Returns the number of bytes that were copied, or zero if + /// anything goes wrong. + //------------------------------------------------------------------ + lldb::offset_t + CopyData (lldb::offset_t offset, + lldb::offset_t length, + void *dst) const; + + //------------------------------------------------------------------ /// Copy \a dst_len bytes from \a *offset_ptr and ensure the copied /// data is treated as a value that can be swapped to match the /// specified byte order. diff --git a/include/lldb/Core/Debugger.h b/include/lldb/Core/Debugger.h index bed93fe02528..671b378df807 100644 --- a/include/lldb/Core/Debugger.h +++ b/include/lldb/Core/Debugger.h @@ -13,7 +13,6 @@ #include <stdint.h> -#include <unistd.h> #include <stack> @@ -323,6 +322,9 @@ public: GetDisassemblyLineCount () const; bool + GetAutoOneLineSummaries () const; + + bool GetNotifyVoid () const; diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h index d6e90071dc5b..f434d56943d4 100644 --- a/include/lldb/Core/Disassembler.h +++ b/include/lldb/Core/Disassembler.h @@ -270,7 +270,8 @@ public: const char *plugin_name, const char *flavor, const ExecutionContext &exe_ctx, - const AddressRange &disasm_range); + const AddressRange &disasm_range, + bool prefer_file_cache); static lldb::DisassemblerSP DisassembleBytes (const ArchSpec &arch, diff --git a/include/lldb/Core/EmulateInstruction.h b/include/lldb/Core/EmulateInstruction.h index 08b97e424913..19a3269ae374 100644 --- a/include/lldb/Core/EmulateInstruction.h +++ b/include/lldb/Core/EmulateInstruction.h @@ -69,14 +69,14 @@ /// debugging. The current debugging model is "process centric" where /// all threads must be stopped when any thread is stopped; when /// hitting software breakpoints we must disable the breakpoint by -/// restoring the original breakpoint opcde, single stepping and +/// restoring the original breakpoint opcode, single stepping and /// restoring the breakpoint trap. If all threads were allowed to run /// then other threads could miss the breakpoint. /// /// This class centralizes the code that usually is done in separate /// code paths in a debugger (single step prediction, finding save /// restore locations of registers for unwinding stack frame variables) -/// and emulating the intruction is just a bonus. +/// and emulating the instruction is just a bonus. //---------------------------------------------------------------------- namespace lldb_private { @@ -394,7 +394,7 @@ public: // Mandatory overrides //---------------------------------------------------------------------- virtual bool - SupportsEmulatingIntructionsOfType (InstructionType inst_type) = 0; + SupportsEmulatingInstructionsOfType (InstructionType inst_type) = 0; virtual bool SetTargetTriple (const ArchSpec &arch) = 0; diff --git a/include/lldb/Core/Error.h b/include/lldb/Core/Error.h index 9e45d5f555d6..39c67f621c92 100644 --- a/include/lldb/Core/Error.h +++ b/include/lldb/Core/Error.h @@ -11,11 +11,10 @@ #define __DCError_h__ #if defined(__cplusplus) -#if defined (__APPLE__) -#include <mach/mach.h> -#endif -#include <stdint.h> -#include <stdio.h> +#include "llvm/Support/DataTypes.h" + +#include <cstdarg> +#include <cstdio> #include <string> #include "lldb/lldb-private.h" @@ -70,7 +69,7 @@ public: Error (ValueType err, lldb::ErrorType type = lldb::eErrorTypeGeneric); explicit - Error (const char* err_str); + Error (const char *format, ...) __attribute__ ((format (printf, 2, 3))); Error (const Error &rhs); //------------------------------------------------------------------ diff --git a/include/lldb/Core/Flags.h b/include/lldb/Core/Flags.h index 233f098ead23..5f4f8830456b 100644 --- a/include/lldb/Core/Flags.h +++ b/include/lldb/Core/Flags.h @@ -13,7 +13,6 @@ #include <stdint.h> -#include <unistd.h> namespace lldb_private { diff --git a/include/lldb/Core/Log.h b/include/lldb/Core/Log.h index ced6f2565d9a..b389946e264c 100644 --- a/include/lldb/Core/Log.h +++ b/include/lldb/Core/Log.h @@ -11,11 +11,10 @@ #define liblldb_Log_h_ // C Includes -#include <stdbool.h> +#include <stdarg.h> #include <stdint.h> #include <signal.h> #include <stdio.h> -#include <unistd.h> // C++ Includes // Other libraries and framework includes diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h index 9c135529f453..1473fb90cf85 100644 --- a/include/lldb/Core/Module.h +++ b/include/lldb/Core/Module.h @@ -347,6 +347,32 @@ public: SymbolContextList& sc_list); //------------------------------------------------------------------ + /// Find addresses by file/line + /// + /// @param[in] target_sp + /// The target the addresses are desired for. + /// + /// @param[in] file + /// Source file to locate. + /// + /// @param[in] line + /// Source line to locate. + /// + /// @param[in] function + /// Optional filter function. Addresses within this function will be + /// added to the 'local' list. All others will be added to the 'extern' list. + /// + /// @param[out] output_local + /// All matching addresses within 'function' + /// + /// @param[out] output_extern + /// All matching addresses not within 'function' + void FindAddressesForLine (const lldb::TargetSP target_sp, + const FileSpec &file, uint32_t line, + Function *function, + std::vector<Address> &output_local, std::vector<Address> &output_extern); + + //------------------------------------------------------------------ /// Find global and static variables by name. /// /// @param[in] name @@ -723,8 +749,49 @@ public: bool ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr); + //------------------------------------------------------------------ + /// Resolve the symbol context for the given address. + /// + /// Tries to resolve the matching symbol context based on a lookup + /// from the current symbol vendor. If the lazy lookup fails, + /// an attempt is made to parse the eh_frame section to handle + /// stripped symbols. If this fails, an attempt is made to resolve + /// the symbol to the previous address to handle the case of a + /// function with a tail call. + /// + /// Use properties of the modified SymbolContext to inspect any + /// resolved target, module, compilation unit, symbol, function, + /// function block or line entry. Use the return value to determine + /// which of these properties have been modified. + /// + /// @param[in] so_addr + /// A load address to resolve. + /// + /// @param[in] resolve_scope + /// The scope that should be resolved (see SymbolContext::Scope). + /// A combination of flags from the enumeration SymbolContextItem + /// requesting a resolution depth. Note that the flags that are + /// actually resolved may be a superset of the requested flags. + /// For instance, eSymbolContextSymbol requires resolution of + /// eSymbolContextModule, and eSymbolContextFunction requires + /// eSymbolContextSymbol. + /// + /// @param[out] sc + /// The SymbolContext that is modified based on symbol resolution. + /// + /// @param[in] resolve_tail_call_address + /// Determines if so_addr should resolve to a symbol in the case + /// of a function whose last instruction is a call. In this case, + /// the PC can be one past the address range of the function. + /// + /// @return + /// The scope that has been resolved (see SymbolContext::Scope). + /// + /// @see SymbolContext::Scope + //------------------------------------------------------------------ uint32_t - ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc); + ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, + SymbolContext& sc, bool resolve_tail_call_address = false); //------------------------------------------------------------------ /// Resolve items in the symbol context for a given file and line. diff --git a/include/lldb/Core/ModuleList.h b/include/lldb/Core/ModuleList.h index 1198e4196481..f03f79fb00ce 100644 --- a/include/lldb/Core/ModuleList.h +++ b/include/lldb/Core/ModuleList.h @@ -439,7 +439,35 @@ public: bool FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const; - + + + //------------------------------------------------------------------ + /// Find addresses by file/line + /// + /// @param[in] target_sp + /// The target the addresses are desired for. + /// + /// @param[in] file + /// Source file to locate. + /// + /// @param[in] line + /// Source line to locate. + /// + /// @param[in] function + /// Optional filter function. Addresses within this function will be + /// added to the 'local' list. All others will be added to the 'extern' list. + /// + /// @param[out] output_local + /// All matching addresses within 'function' + /// + /// @param[out] output_extern + /// All matching addresses not within 'function' + void FindAddressesForLine (const lldb::TargetSP target_sp, + const FileSpec &file, uint32_t line, + Function *function, + std::vector<Address> &output_local, std::vector<Address> &output_extern); + + bool Remove (const lldb::ModuleSP &module_sp); diff --git a/include/lldb/Core/ModuleSpec.h b/include/lldb/Core/ModuleSpec.h index 10e1ea9f17a9..dfeb7b73ca37 100644 --- a/include/lldb/Core/ModuleSpec.h +++ b/include/lldb/Core/ModuleSpec.h @@ -288,7 +288,7 @@ public: } - operator bool () const + explicit operator bool () const { if (m_file) return true; diff --git a/include/lldb/Core/Opcode.h b/include/lldb/Core/Opcode.h index c07193b62059..fd80231a44e7 100644 --- a/include/lldb/Core/Opcode.h +++ b/include/lldb/Core/Opcode.h @@ -38,7 +38,7 @@ namespace lldb_private { eType64, eTypeBytes }; - + Opcode () : m_type (eTypeInvalid) { } @@ -78,7 +78,7 @@ namespace lldb_private { { return m_type; } - + uint8_t GetOpcode8 (uint8_t invalid_opcode = UINT8_MAX) const { @@ -91,7 +91,6 @@ namespace lldb_private { case Opcode::eType32: break; case Opcode::eType64: break; case Opcode::eTypeBytes: break; - break; } return invalid_opcode; } @@ -157,7 +156,7 @@ namespace lldb_private { m_type = eType16; m_data.inst16 = inst; } - + void SetOpcode16_2 (uint32_t inst) { @@ -206,7 +205,7 @@ namespace lldb_private { return m_data.inst.bytes; return NULL; } - + uint32_t GetByteSize () const { @@ -222,7 +221,7 @@ namespace lldb_private { } return 0; } - + // Get the opcode exactly as it would be laid out in memory. uint32_t GetData (DataExtractor &data) const; @@ -246,7 +245,7 @@ namespace lldb_private { } return NULL; } - + lldb::ByteOrder GetDataByteOrder () const; @@ -257,7 +256,7 @@ namespace lldb_private { uint16_t inst16; uint32_t inst32; uint64_t inst64; - struct + struct { uint8_t bytes[16]; // This must be big enough to handle any opcode for any supported target. uint8_t length; diff --git a/include/lldb/Core/PluginManager.h b/include/lldb/Core/PluginManager.h index 91f8fbb997f9..e02f43f4fa8b 100644 --- a/include/lldb/Core/PluginManager.h +++ b/include/lldb/Core/PluginManager.h @@ -132,6 +132,24 @@ public: //------------------------------------------------------------------ + // SystemRuntime + //------------------------------------------------------------------ + static bool + RegisterPlugin (const ConstString &name, + const char *description, + SystemRuntimeCreateInstance create_callback); + + static bool + UnregisterPlugin (SystemRuntimeCreateInstance create_callback); + + static SystemRuntimeCreateInstance + GetSystemRuntimeCreateCallbackAtIndex (uint32_t idx); + + static SystemRuntimeCreateInstance + GetSystemRuntimeCreateCallbackForPluginName (const ConstString &name); + + + //------------------------------------------------------------------ // ObjectFile //------------------------------------------------------------------ static bool diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Core/RangeMap.h index ee42467c18bf..d78504c7d285 100644 --- a/include/lldb/Core/RangeMap.h +++ b/include/lldb/Core/RangeMap.h @@ -592,7 +592,7 @@ namespace lldb_private { void Reserve (typename Collection::size_type size) { - m_entries.resize (size); + m_entries.reserve (size); } bool @@ -1229,16 +1229,11 @@ namespace lldb_private { typename Collection::const_iterator end = m_entries.end(); typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + while(pos != begin && pos[-1].Contains(addr)) + --pos; + if (pos != end && pos->Contains(addr)) - { return std::distance (begin, pos); - } - else if (pos != begin) - { - --pos; - if (pos->Contains(addr)) - return std::distance (begin, pos); - } } return UINT32_MAX; } @@ -1257,19 +1252,12 @@ namespace lldb_private { typename Collection::iterator begin = m_entries.begin(); typename Collection::iterator end = m_entries.end(); typename Collection::iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + + while(pos != begin && pos[-1].Contains(addr)) + --pos; if (pos != end && pos->Contains(addr)) - { return &(*pos); - } - else if (pos != begin) - { - --pos; - if (pos->Contains(addr)) - { - return &(*pos); - } - } } return NULL; } @@ -1288,18 +1276,11 @@ namespace lldb_private { typename Collection::const_iterator end = m_entries.end(); typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); - if (pos != end && pos->Contains(addr)) - { - return &(*pos); - } - else if (pos != begin) - { + while(pos != begin && pos[-1].Contains(addr)) --pos; - if (pos->Contains(addr)) - { - return &(*pos); - } - } + + if (pos != end && pos->Contains(addr)) + return &(*pos); } return NULL; } @@ -1316,18 +1297,11 @@ namespace lldb_private { typename Collection::const_iterator end = m_entries.end(); typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan); - if (pos != end && pos->Contains(range)) - { - return &(*pos); - } - else if (pos != begin) - { + while(pos != begin && pos[-1].Contains(range)) --pos; - if (pos->Contains(range)) - { - return &(*pos); - } - } + + if (pos != end && pos->Contains(range)) + return &(*pos); } return NULL; } @@ -1501,12 +1475,15 @@ namespace lldb_private { typename Collection::iterator end = m_entries.end(); typename Collection::iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + while(pos != begin && pos[-1].addr == addr) + --pos; + if (pos != end) { if (pos->addr == addr || !exact_match_only) return &(*pos); } - } + } return NULL; } diff --git a/include/lldb/Core/RegularExpression.h b/include/lldb/Core/RegularExpression.h index eeeb914bfa90..c116d439b94a 100644 --- a/include/lldb/Core/RegularExpression.h +++ b/include/lldb/Core/RegularExpression.h @@ -11,7 +11,36 @@ #define liblldb_DBRegex_h_ #if defined(__cplusplus) +#ifdef _WIN32 +#include "../lib/Support/regex_impl.h" + +typedef llvm_regmatch_t regmatch_t; +typedef llvm_regex_t regex_t; + +inline int regcomp(llvm_regex_t * a, const char *b, int c) +{ + return llvm_regcomp(a, b, c); +} + +inline size_t regerror(int a, const llvm_regex_t *b, char *c, size_t d) +{ + return llvm_regerror(a, b, c, d); +} + +inline int regexec(const llvm_regex_t * a, const char * b, size_t c, + llvm_regmatch_t d [], int e) +{ + return llvm_regexec(a, b, c, d, e); +} + +inline void regfree(llvm_regex_t * a) +{ + llvm_regfree(a); +} + +#else #include <regex.h> +#endif #include <stdint.h> #include <string> diff --git a/include/lldb/Core/StreamGDBRemote.h b/include/lldb/Core/StreamGDBRemote.h new file mode 100644 index 000000000000..3fdb6f6e7012 --- /dev/null +++ b/include/lldb/Core/StreamGDBRemote.h @@ -0,0 +1,54 @@ +//===-- StreamGDBRemote.h ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_StreamGDBRemote_h_ +#define liblldb_StreamGDBRemote_h_ + +// C Includes +// C++ Includes + +// Other libraries and framework includes +// Project includes + +#include "lldb/Core/StreamString.h" + +namespace lldb_private { + + class StreamGDBRemote : public StreamString + { + public: + StreamGDBRemote (); + + StreamGDBRemote (uint32_t flags, + uint32_t addr_size, + lldb::ByteOrder byte_order); + + virtual + ~StreamGDBRemote (); + + //------------------------------------------------------------------ + /// Output a block of data to the stream performing GDB-remote escaping. + /// + /// @param[in] s + /// A block of data. + /// + /// @param[in] src_len + /// The amount of data to write. + /// + /// @return + /// Number of bytes written. + //------------------------------------------------------------------ + int + PutEscapedBytes (const void* s, + size_t src_len); + }; + +} // namespace lldb_private + +#endif // liblldb_StreamGDBRemote_h_ diff --git a/include/lldb/Core/UUID.h b/include/lldb/Core/UUID.h index fe72b8eb0c70..3bb14421b1e9 100644 --- a/include/lldb/Core/UUID.h +++ b/include/lldb/Core/UUID.h @@ -12,6 +12,8 @@ // C Includes // C++ Includes +#include <string> + // Other libraries and framework includes // Project includes diff --git a/include/lldb/Core/Value.h b/include/lldb/Core/Value.h index 5461ca73d082..c7d44322333c 100644 --- a/include/lldb/Core/Value.h +++ b/include/lldb/Core/Value.h @@ -114,7 +114,7 @@ public: #if defined (ENABLE_128_BIT_SUPPORT) else if (length >= 16) scalar = *(const __uint128_t *)bytes; #else - else if (length >= 16) scalar = *(const __uint64_t *)bytes; + else if (length >= 16) scalar = *(const uint64_t *)bytes; #endif } return scalar; diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h index 0d965d6ccc01..1ef421676ee1 100644 --- a/include/lldb/Core/ValueObject.h +++ b/include/lldb/Core/ValueObject.h @@ -12,7 +12,6 @@ // C Includes // C++ Includes -#include <initializer_list> #include <map> #include <vector> // Other libraries and framework includes @@ -217,229 +216,6 @@ public: } }; - - struct DumpValueObjectOptions - { - uint32_t m_max_ptr_depth; - uint32_t m_max_depth; - bool m_show_types; - bool m_show_location; - bool m_use_objc; - lldb::DynamicValueType m_use_dynamic; - bool m_use_synthetic; - bool m_scope_already_checked; - bool m_flat_output; - uint32_t m_omit_summary_depth; - bool m_ignore_cap; - lldb::Format m_format; - lldb::TypeSummaryImplSP m_summary_sp; - std::string m_root_valobj_name; - bool m_hide_root_type; - bool m_hide_name; - bool m_hide_value; - - DumpValueObjectOptions() : - m_max_ptr_depth(0), - m_max_depth(UINT32_MAX), - m_show_types(false), - m_show_location(false), - m_use_objc(false), - m_use_dynamic(lldb::eNoDynamicValues), - m_use_synthetic(true), - m_scope_already_checked(false), - m_flat_output(false), - m_omit_summary_depth(0), - m_ignore_cap(false), - m_format (lldb::eFormatDefault), - m_summary_sp(), - m_root_valobj_name(), - m_hide_root_type(false), // provide a special compact display for "po" - m_hide_name(false), // provide a special compact display for "po" - m_hide_value(false) // provide a special compact display for "po" - {} - - static const DumpValueObjectOptions - DefaultOptions() - { - static DumpValueObjectOptions g_default_options; - - return g_default_options; - } - - DumpValueObjectOptions (const DumpValueObjectOptions& rhs) : - m_max_ptr_depth(rhs.m_max_ptr_depth), - m_max_depth(rhs.m_max_depth), - m_show_types(rhs.m_show_types), - m_show_location(rhs.m_show_location), - m_use_objc(rhs.m_use_objc), - m_use_dynamic(rhs.m_use_dynamic), - m_use_synthetic(rhs.m_use_synthetic), - m_scope_already_checked(rhs.m_scope_already_checked), - m_flat_output(rhs.m_flat_output), - m_omit_summary_depth(rhs.m_omit_summary_depth), - m_ignore_cap(rhs.m_ignore_cap), - m_format(rhs.m_format), - m_summary_sp(rhs.m_summary_sp), - m_root_valobj_name(rhs.m_root_valobj_name), - m_hide_root_type(rhs.m_hide_root_type), - m_hide_name(rhs.m_hide_name), - m_hide_value(rhs.m_hide_value) - {} - - DumpValueObjectOptions& - SetMaximumPointerDepth(uint32_t depth = 0) - { - m_max_ptr_depth = depth; - return *this; - } - - DumpValueObjectOptions& - SetMaximumDepth(uint32_t depth = 0) - { - m_max_depth = depth; - return *this; - } - - DumpValueObjectOptions& - SetShowTypes(bool show = false) - { - m_show_types = show; - return *this; - } - - DumpValueObjectOptions& - SetShowLocation(bool show = false) - { - m_show_location = show; - return *this; - } - - DumpValueObjectOptions& - SetUseObjectiveC(bool use = false) - { - m_use_objc = use; - return *this; - } - - DumpValueObjectOptions& - SetShowSummary(bool show = true) - { - if (show == false) - SetOmitSummaryDepth(UINT32_MAX); - else - SetOmitSummaryDepth(0); - return *this; - } - - DumpValueObjectOptions& - SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues) - { - m_use_dynamic = dyn; - return *this; - } - - DumpValueObjectOptions& - SetUseSyntheticValue(bool use_synthetic = true) - { - m_use_synthetic = use_synthetic; - return *this; - } - - DumpValueObjectOptions& - SetScopeChecked(bool check = true) - { - m_scope_already_checked = check; - return *this; - } - - DumpValueObjectOptions& - SetFlatOutput(bool flat = false) - { - m_flat_output = flat; - return *this; - } - - DumpValueObjectOptions& - SetOmitSummaryDepth(uint32_t depth = 0) - { - m_omit_summary_depth = depth; - return *this; - } - - DumpValueObjectOptions& - SetIgnoreCap(bool ignore = false) - { - m_ignore_cap = ignore; - return *this; - } - - DumpValueObjectOptions& - SetRawDisplay(bool raw = false) - { - if (raw) - { - SetUseSyntheticValue(false); - SetOmitSummaryDepth(UINT32_MAX); - SetIgnoreCap(true); - SetHideName(false); - SetHideValue(false); - } - else - { - SetUseSyntheticValue(true); - SetOmitSummaryDepth(0); - SetIgnoreCap(false); - SetHideName(false); - SetHideValue(false); - } - return *this; - } - - DumpValueObjectOptions& - SetFormat (lldb::Format format = lldb::eFormatDefault) - { - m_format = format; - return *this; - } - - DumpValueObjectOptions& - SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP()) - { - m_summary_sp = summary; - return *this; - } - - DumpValueObjectOptions& - SetRootValueObjectName (const char* name = NULL) - { - if (name) - m_root_valobj_name.assign(name); - else - m_root_valobj_name.clear(); - return *this; - } - - DumpValueObjectOptions& - SetHideRootType (bool hide_root_type = false) - { - m_hide_root_type = hide_root_type; - return *this; - } - - DumpValueObjectOptions& - SetHideName (bool hide_name = false) - { - m_hide_name = hide_name; - return *this; - } - - DumpValueObjectOptions& - SetHideValue (bool hide_value = false) - { - m_hide_value = hide_value; - return *this; - } - }; class EvaluationPoint { @@ -598,6 +374,10 @@ public: ClangASTType GetClangType (); + + // this vends a TypeImpl that is useful at the SB API layer + virtual TypeImpl + GetTypeImpl (); //------------------------------------------------------------------ // Sublasses must implement the functions below. @@ -725,6 +505,9 @@ public: virtual uint64_t GetValueAsUnsigned (uint64_t fail_value, bool *success = NULL); + virtual int64_t + GetValueAsSigned (int64_t fail_value, bool *success = NULL); + virtual bool SetValueFromCString (const char *value_str, Error& error); @@ -768,6 +551,23 @@ public: lldb::ValueObjectSP GetChildAtIndexPath (const std::vector< std::pair<size_t, bool> > &idxs, size_t* index_of_error = NULL); + + // this will always create the children if necessary + lldb::ValueObjectSP + GetChildAtNamePath (const std::initializer_list<ConstString> &names, + ConstString* name_of_error = NULL); + + lldb::ValueObjectSP + GetChildAtNamePath (const std::vector<ConstString> &names, + ConstString* name_of_error = NULL); + + lldb::ValueObjectSP + GetChildAtNamePath (const std::initializer_list< std::pair<ConstString, bool> > &names, + ConstString* name_of_error = NULL); + + lldb::ValueObjectSP + GetChildAtNamePath (const std::vector< std::pair<ConstString, bool> > &names, + ConstString* name_of_error = NULL); virtual lldb::ValueObjectSP GetChildMemberWithName (const ConstString &name, bool can_create); @@ -937,13 +737,12 @@ public: virtual SymbolContextScope * GetSymbolContextScope(); - static void - DumpValueObject (Stream &s, - ValueObject *valobj); - static void - DumpValueObject (Stream &s, - ValueObject *valobj, - const DumpValueObjectOptions& options); + void + Dump (Stream &s); + + void + Dump (Stream &s, + const DumpValueObjectOptions& options); static lldb::ValueObjectSP CreateValueObjectFromExpression (const char* name, @@ -962,13 +761,11 @@ public: const ExecutionContext& exe_ctx, ClangASTType type); - static void - LogValueObject (Log *log, - ValueObject *valobj); + void + LogValueObject (Log *log); - static void + void LogValueObject (Log *log, - ValueObject *valobj, const DumpValueObjectOptions& options); diff --git a/include/lldb/Core/ValueObjectDynamicValue.h b/include/lldb/Core/ValueObjectDynamicValue.h index c0f6baade3fb..68f88c96e545 100644 --- a/include/lldb/Core/ValueObjectDynamicValue.h +++ b/include/lldb/Core/ValueObjectDynamicValue.h @@ -93,6 +93,9 @@ public: virtual bool SetData (DataExtractor &data, Error &error); + virtual TypeImpl + GetTypeImpl (); + protected: virtual bool UpdateValue (); @@ -116,6 +119,7 @@ protected: TypeAndOrName m_dynamic_type_info; // We can have a type_sp or just a name lldb::ValueObjectSP m_owning_valobj_sp; lldb::DynamicValueType m_use_dynamic; + TypeImpl m_type_impl; private: friend class ValueObject; diff --git a/include/lldb/Core/dwarf.h b/include/lldb/Core/dwarf.h index bf77125d86a8..91c8dfb9d0da 100644 --- a/include/lldb/Core/dwarf.h +++ b/include/lldb/Core/dwarf.h @@ -11,7 +11,6 @@ #define DebugBase_dwarf_h_ #include <stdint.h> -#include <stdbool.h> // Get the DWARF constant defintions from llvm #include "llvm/Support/Dwarf.h" diff --git a/include/lldb/DataFormatters/CXXFormatterFunctions.h b/include/lldb/DataFormatters/CXXFormatterFunctions.h index 2f56c56810ab..433c2a3c407b 100644 --- a/include/lldb/DataFormatters/CXXFormatterFunctions.h +++ b/include/lldb/DataFormatters/CXXFormatterFunctions.h @@ -868,6 +868,39 @@ namespace lldb_private { SyntheticChildrenFrontEnd* LibcxxStdMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); + class LibcxxStdUnorderedMapSyntheticFrontEnd : public SyntheticChildrenFrontEnd + { + public: + LibcxxStdUnorderedMapSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp); + + virtual size_t + CalculateNumChildren (); + + virtual lldb::ValueObjectSP + GetChildAtIndex (size_t idx); + + virtual bool + Update(); + + virtual bool + MightHaveChildren (); + + virtual size_t + GetIndexOfChildWithName (const ConstString &name); + + virtual + ~LibcxxStdUnorderedMapSyntheticFrontEnd (); + private: + + ValueObject* m_tree; + size_t m_num_elements; + ValueObject* m_next_element; + std::map<size_t,lldb::ValueObjectSP> m_children; + std::vector<std::pair<ValueObject*, uint64_t> > m_elements_cache; + }; + + SyntheticChildrenFrontEnd* LibcxxStdUnorderedMapSyntheticFrontEndCreator (CXXSyntheticChildren*, lldb::ValueObjectSP); + } // namespace formatters } // namespace lldb_private diff --git a/include/lldb/DataFormatters/DataVisualization.h b/include/lldb/DataFormatters/DataVisualization.h index 499e0fe14d93..ca0714c29f84 100644 --- a/include/lldb/DataFormatters/DataVisualization.h +++ b/include/lldb/DataFormatters/DataVisualization.h @@ -36,40 +36,19 @@ public: static uint32_t GetCurrentRevision (); - class ValueFormats - { - public: - static lldb::TypeFormatImplSP - GetFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic); - - static lldb::TypeFormatImplSP - GetFormat (const ConstString &type); - - static void - Add (const ConstString &type, const lldb::TypeFormatImplSP &entry); - - static bool - Delete (const ConstString &type); - - static void - Clear (); - - static void - LoopThrough (TypeFormatImpl::ValueCallback callback, void* callback_baton); - - static size_t - GetCount (); - - static lldb::TypeNameSpecifierImplSP - GetTypeNameSpecifierForFormatAtIndex (size_t); - - static lldb::TypeFormatImplSP - GetFormatAtIndex (size_t); - }; + static bool + ShouldPrintAsOneLiner (ValueObject& valobj); + + static lldb::TypeFormatImplSP + GetFormat (ValueObject& valobj, + lldb::DynamicValueType use_dynamic); + + static lldb::TypeFormatImplSP + GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp); static lldb::TypeSummaryImplSP - GetSummaryFormat(ValueObject& valobj, - lldb::DynamicValueType use_dynamic); + GetSummaryFormat (ValueObject& valobj, + lldb::DynamicValueType use_dynamic); static lldb::TypeSummaryImplSP GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp); diff --git a/include/lldb/DataFormatters/FormatCache.h b/include/lldb/DataFormatters/FormatCache.h index 941b96c1facc..bd9e20ccc9ee 100644 --- a/include/lldb/DataFormatters/FormatCache.h +++ b/include/lldb/DataFormatters/FormatCache.h @@ -27,23 +27,32 @@ private: struct Entry { private: + bool m_format_cached : 1; bool m_summary_cached : 1; bool m_synthetic_cached : 1; + lldb::TypeFormatImplSP m_format_sp; lldb::TypeSummaryImplSP m_summary_sp; lldb::SyntheticChildrenSP m_synthetic_sp; public: Entry (); + Entry (lldb::TypeFormatImplSP); Entry (lldb::TypeSummaryImplSP); Entry (lldb::SyntheticChildrenSP); - Entry (lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP); + Entry (lldb::TypeFormatImplSP,lldb::TypeSummaryImplSP,lldb::SyntheticChildrenSP); bool + IsFormatCached (); + + bool IsSummaryCached (); bool IsSyntheticCached (); + lldb::TypeFormatImplSP + GetFormat (); + lldb::TypeSummaryImplSP GetSummary (); @@ -51,6 +60,9 @@ private: GetSynthetic (); void + SetFormat (lldb::TypeFormatImplSP); + + void SetSummary (lldb::TypeSummaryImplSP); void @@ -70,12 +82,18 @@ public: FormatCache (); bool + GetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp); + + bool GetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp); bool GetSynthetic (const ConstString& type,lldb::SyntheticChildrenSP& synthetic_sp); void + SetFormat (const ConstString& type,lldb::TypeFormatImplSP& format_sp); + + void SetSummary (const ConstString& type,lldb::TypeSummaryImplSP& summary_sp); void diff --git a/include/lldb/DataFormatters/FormatClasses.h b/include/lldb/DataFormatters/FormatClasses.h index 48a8eda4ad43..6d9a50e8f2c5 100644 --- a/include/lldb/DataFormatters/FormatClasses.h +++ b/include/lldb/DataFormatters/FormatClasses.h @@ -12,7 +12,6 @@ // C Includes #include <stdint.h> -#include <unistd.h> // C++ Includes #include <string> @@ -61,7 +60,7 @@ public: if (type) { m_type.m_type_name.assign(type->GetName().GetCString()); - m_type.m_typeimpl_sp = lldb::TypeImplSP(new TypeImpl(type)); + m_type.m_type_pair.SetType(type); } } @@ -72,7 +71,7 @@ public: if (type.IsValid()) { m_type.m_type_name.assign(type.GetConstTypeName().GetCString()); - m_type.m_typeimpl_sp = lldb::TypeImplSP(new TypeImpl(type)); + m_type.m_type_pair.SetType(type); } } @@ -87,16 +86,16 @@ public: lldb::TypeSP GetTypeSP () { - if (m_type.m_typeimpl_sp && m_type.m_typeimpl_sp->IsValid()) - return m_type.m_typeimpl_sp->GetTypeSP(); + if (m_type.m_type_pair.IsValid()) + return m_type.m_type_pair.GetTypeSP(); return lldb::TypeSP(); } ClangASTType GetClangASTType () { - if (m_type.m_typeimpl_sp && m_type.m_typeimpl_sp->IsValid()) - return m_type.m_typeimpl_sp->GetClangASTType(); + if (m_type.m_type_pair.IsValid()) + return m_type.m_type_pair.GetClangASTType(); return ClangASTType(); } @@ -109,12 +108,11 @@ public: private: bool m_is_regex; // this works better than TypeAndOrName because the latter only wraps a TypeSP - // whereas TypeImplSP can also be backed by a ClangASTType which is more commonly - // used in LLDB. moreover, TypeImplSP is also what is currently backing SBType + // whereas TypePair can also be backed by a ClangASTType struct TypeOrName { std::string m_type_name; - lldb::TypeImplSP m_typeimpl_sp; + TypePair m_type_pair; }; TypeOrName m_type; diff --git a/include/lldb/DataFormatters/FormatManager.h b/include/lldb/DataFormatters/FormatManager.h index 162e25143f27..3c90c993e0c4 100644 --- a/include/lldb/DataFormatters/FormatManager.h +++ b/include/lldb/DataFormatters/FormatManager.h @@ -23,6 +23,8 @@ #include "lldb/DataFormatters/TypeCategory.h" #include "lldb/DataFormatters/TypeCategoryMap.h" +#include <atomic> + namespace lldb_private { // this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization @@ -32,8 +34,6 @@ namespace lldb_private { class FormatManager : public IFormatChangeListener { - typedef FormatNavigator<ConstString, TypeFormatImpl> ValueNavigator; - typedef ValueNavigator::MapType ValueMap; typedef FormatMap<ConstString, TypeSummaryImpl> NamedSummariesMap; typedef TypeCategoryMap::MapType::iterator CategoryMapIterator; public: @@ -42,12 +42,6 @@ public: FormatManager (); - ValueNavigator& - GetValueNavigator () - { - return m_value_nav; - } - NamedSummariesMap& GetNamedSummaryNavigator () { @@ -124,6 +118,9 @@ public: lldb::TypeCategoryImplSP GetCategory (const ConstString& category_name, bool can_create = true); + + lldb::TypeFormatImplSP + GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp); lldb::TypeSummaryImplSP GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp); @@ -141,6 +138,10 @@ public: GetSyntheticChildrenForType (lldb::TypeNameSpecifierImplSP type_sp); #endif + lldb::TypeFormatImplSP + GetFormat (ValueObject& valobj, + lldb::DynamicValueType use_dynamic); + lldb::TypeSummaryImplSP GetSummaryFormat (ValueObject& valobj, lldb::DynamicValueType use_dynamic); @@ -188,10 +189,17 @@ public: static lldb::Format GetSingleItemFormat (lldb::Format vector_format); + // this returns true if the ValueObjectPrinter is *highly encouraged* + // to actually represent this ValueObject in one-liner format + // If this object has a summary formatter, however, we should not + // try and do one-lining, just let the summary do the right thing + bool + ShouldPrintAsOneLiner (ValueObject& valobj); + void Changed () { - __sync_add_and_fetch(&m_last_revision, +1); + ++m_last_revision; m_format_cache.Clear (); } @@ -207,9 +215,8 @@ public: private: FormatCache m_format_cache; - ValueNavigator m_value_nav; NamedSummariesMap m_named_summaries_map; - uint32_t m_last_revision; + std::atomic<uint32_t> m_last_revision; TypeCategoryMap m_categories_map; ConstString m_default_category_name; diff --git a/include/lldb/DataFormatters/FormatNavigator.h b/include/lldb/DataFormatters/FormatNavigator.h index a738cfd069e7..cd5f6824e199 100644 --- a/include/lldb/DataFormatters/FormatNavigator.h +++ b/include/lldb/DataFormatters/FormatNavigator.h @@ -76,7 +76,7 @@ GetValidTypeName_Impl (const ConstString& type) { int strip_len = 0; - if (type == false) + if ((bool)type == false) return type; const char* type_cstr = type.AsCString(); diff --git a/include/lldb/DataFormatters/TypeCategory.h b/include/lldb/DataFormatters/TypeCategory.h index b76d84f4772f..6461c4e97e4e 100644 --- a/include/lldb/DataFormatters/TypeCategory.h +++ b/include/lldb/DataFormatters/TypeCategory.h @@ -24,6 +24,8 @@ namespace lldb_private { class TypeCategoryImpl { private: + typedef FormatNavigator<ConstString, TypeFormatImpl> ValueNavigator; + typedef FormatNavigator<lldb::RegularExpressionSP, TypeFormatImpl> RegexValueNavigator; typedef FormatNavigator<ConstString, TypeSummaryImpl> SummaryNavigator; typedef FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl> RegexSummaryNavigator; @@ -35,11 +37,16 @@ namespace lldb_private { typedef FormatNavigator<ConstString, ScriptedSyntheticChildren> SynthNavigator; typedef FormatNavigator<lldb::RegularExpressionSP, ScriptedSyntheticChildren> RegexSynthNavigator; #endif // #ifndef LLDB_DISABLE_PYTHON - + + typedef ValueNavigator::MapType ValueMap; + typedef RegexValueNavigator::MapType RegexValueMap; + typedef SummaryNavigator::MapType SummaryMap; typedef RegexSummaryNavigator::MapType RegexSummaryMap; + typedef FilterNavigator::MapType FilterMap; typedef RegexFilterNavigator::MapType RegexFilterMap; + #ifndef LLDB_DISABLE_PYTHON typedef SynthNavigator::MapType SynthMap; typedef RegexSynthNavigator::MapType RegexSynthMap; @@ -49,9 +56,13 @@ namespace lldb_private { typedef uint16_t FormatCategoryItems; static const uint16_t ALL_ITEM_TYPES = UINT16_MAX; + + typedef ValueNavigator::SharedPointer ValueNavigatorSP; + typedef RegexValueNavigator::SharedPointer RegexValueNavigatorSP; typedef SummaryNavigator::SharedPointer SummaryNavigatorSP; typedef RegexSummaryNavigator::SharedPointer RegexSummaryNavigatorSP; + typedef FilterNavigator::SharedPointer FilterNavigatorSP; typedef RegexFilterNavigator::SharedPointer RegexFilterNavigatorSP; #ifndef LLDB_DISABLE_PYTHON @@ -62,6 +73,18 @@ namespace lldb_private { TypeCategoryImpl (IFormatChangeListener* clist, ConstString name); + ValueNavigatorSP + GetValueNavigator () + { + return ValueNavigatorSP(m_value_nav); + } + + RegexValueNavigatorSP + GetRegexValueNavigator () + { + return RegexValueNavigatorSP(m_regex_value_nav); + } + SummaryNavigatorSP GetSummaryNavigator () { @@ -85,6 +108,9 @@ namespace lldb_private { { return RegexFilterNavigatorSP(m_regex_filter_nav); } + + ValueNavigator::MapValueType + GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp); SummaryNavigator::MapValueType GetSummaryForType (lldb::TypeNameSpecifierImplSP type_sp); @@ -98,7 +124,13 @@ namespace lldb_private { #endif lldb::TypeNameSpecifierImplSP + GetTypeNameSpecifierForFormatAtIndex (size_t index); + + lldb::TypeNameSpecifierImplSP GetTypeNameSpecifierForSummaryAtIndex (size_t index); + + ValueNavigator::MapValueType + GetFormatAtIndex (size_t index); SummaryNavigator::MapValueType GetSummaryAtIndex (size_t index); @@ -145,6 +177,13 @@ namespace lldb_private { return m_enabled_position; } + + bool + Get (ValueObject& valobj, + lldb::TypeFormatImplSP& entry, + lldb::DynamicValueType use_dynamic, + uint32_t* reason = NULL); + bool Get (ValueObject& valobj, lldb::TypeSummaryImplSP& entry, @@ -183,10 +222,15 @@ namespace lldb_private { typedef std::shared_ptr<TypeCategoryImpl> SharedPointer; private: + ValueNavigator::SharedPointer m_value_nav; + RegexValueNavigator::SharedPointer m_regex_value_nav; + SummaryNavigator::SharedPointer m_summary_nav; RegexSummaryNavigator::SharedPointer m_regex_summary_nav; + FilterNavigator::SharedPointer m_filter_nav; RegexFilterNavigator::SharedPointer m_regex_filter_nav; + #ifndef LLDB_DISABLE_PYTHON SynthNavigator::SharedPointer m_synth_nav; RegexSynthNavigator::SharedPointer m_regex_synth_nav; @@ -213,6 +257,9 @@ namespace lldb_private { friend class TypeCategoryMap; + friend class FormatNavigator<ConstString, TypeFormatImpl>; + friend class FormatNavigator<lldb::RegularExpressionSP, TypeFormatImpl>; + friend class FormatNavigator<ConstString, TypeSummaryImpl>; friend class FormatNavigator<lldb::RegularExpressionSP, TypeSummaryImpl>; diff --git a/include/lldb/DataFormatters/TypeCategoryMap.h b/include/lldb/DataFormatters/TypeCategoryMap.h index c2465ad13aa7..6bed18719893 100644 --- a/include/lldb/DataFormatters/TypeCategoryMap.h +++ b/include/lldb/DataFormatters/TypeCategoryMap.h @@ -93,6 +93,10 @@ namespace lldb_private { { return m_map.size(); } + + lldb::TypeFormatImplSP + GetFormat (ValueObject& valobj, + lldb::DynamicValueType use_dynamic); lldb::TypeSummaryImplSP GetSummaryFormat (ValueObject& valobj, diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h index 2183384b9d62..1c195ab2ba4d 100644 --- a/include/lldb/DataFormatters/TypeSummary.h +++ b/include/lldb/DataFormatters/TypeSummary.h @@ -12,7 +12,6 @@ // C Includes #include <stdint.h> -#include <unistd.h> // C++ Includes #include <string> @@ -239,7 +238,7 @@ namespace lldb_private { } bool - IsOneliner () const + IsOneLiner () const { return m_flags.GetShowMembersOneLiner(); } @@ -281,7 +280,7 @@ namespace lldb_private { } void - SetIsOneliner (bool value) + SetIsOneLiner (bool value) { m_flags.SetShowMembersOneLiner(value); } diff --git a/include/lldb/DataFormatters/TypeSynthetic.h b/include/lldb/DataFormatters/TypeSynthetic.h index a32f4b761175..18b9d011e96a 100644 --- a/include/lldb/DataFormatters/TypeSynthetic.h +++ b/include/lldb/DataFormatters/TypeSynthetic.h @@ -12,7 +12,6 @@ // C Includes #include <stdint.h> -#include <unistd.h> // C++ Includes #include <string> @@ -533,6 +532,12 @@ namespace lldb_private { FrontEnd (std::string pclass, ValueObject &backend); + bool + IsValid () + { + return m_wrapper_sp.get() != nullptr && m_wrapper_sp->operator bool() && m_interpreter != nullptr; + } + virtual ~FrontEnd (); @@ -582,8 +587,11 @@ namespace lldb_private { virtual SyntheticChildrenFrontEnd::AutoPointer GetFrontEnd(ValueObject &backend) { - return SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(m_python_class, backend)); - } + auto synth_ptr = SyntheticChildrenFrontEnd::AutoPointer(new FrontEnd(m_python_class, backend)); + if (synth_ptr && ((FrontEnd*)synth_ptr.get())->IsValid()) + return synth_ptr; + return NULL; + } private: DISALLOW_COPY_AND_ASSIGN(ScriptedSyntheticChildren); diff --git a/include/lldb/DataFormatters/ValueObjectPrinter.h b/include/lldb/DataFormatters/ValueObjectPrinter.h new file mode 100644 index 000000000000..4e23ceedcc16 --- /dev/null +++ b/include/lldb/DataFormatters/ValueObjectPrinter.h @@ -0,0 +1,394 @@ +//===-- ValueObjectPrinter.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_ValueObjectPrinter_h_ +#define lldb_ValueObjectPrinter_h_ + +// C Includes +// C++ Includes + +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/lldb-public.h" + +#include "lldb/Core/Stream.h" +#include "lldb/Core/ValueObject.h" +#include "lldb/DataFormatters/TypeSummary.h" + +namespace lldb_private { + +struct DumpValueObjectOptions +{ + uint32_t m_max_ptr_depth; + uint32_t m_max_depth; + bool m_show_types; + bool m_show_location; + bool m_use_objc; + lldb::DynamicValueType m_use_dynamic; + bool m_use_synthetic; + bool m_scope_already_checked; + bool m_flat_output; + uint32_t m_omit_summary_depth; + bool m_ignore_cap; + lldb::Format m_format; + lldb::TypeSummaryImplSP m_summary_sp; + std::string m_root_valobj_name; + bool m_hide_root_type; + bool m_hide_name; + bool m_hide_value; + bool m_be_raw; + + DumpValueObjectOptions() : + m_max_ptr_depth(0), + m_max_depth(UINT32_MAX), + m_show_types(false), + m_show_location(false), + m_use_objc(false), + m_use_dynamic(lldb::eNoDynamicValues), + m_use_synthetic(true), + m_scope_already_checked(false), + m_flat_output(false), + m_omit_summary_depth(0), + m_ignore_cap(false), + m_format (lldb::eFormatDefault), + m_summary_sp(), + m_root_valobj_name(), + m_hide_root_type(false), // provide a special compact display for "po" + m_hide_name(false), // provide a special compact display for "po" + m_hide_value(false), // provide a special compact display for "po" + m_be_raw(false) + {} + + static const DumpValueObjectOptions + DefaultOptions() + { + static DumpValueObjectOptions g_default_options; + + return g_default_options; + } + + DumpValueObjectOptions (const DumpValueObjectOptions& rhs) : + m_max_ptr_depth(rhs.m_max_ptr_depth), + m_max_depth(rhs.m_max_depth), + m_show_types(rhs.m_show_types), + m_show_location(rhs.m_show_location), + m_use_objc(rhs.m_use_objc), + m_use_dynamic(rhs.m_use_dynamic), + m_use_synthetic(rhs.m_use_synthetic), + m_scope_already_checked(rhs.m_scope_already_checked), + m_flat_output(rhs.m_flat_output), + m_omit_summary_depth(rhs.m_omit_summary_depth), + m_ignore_cap(rhs.m_ignore_cap), + m_format(rhs.m_format), + m_summary_sp(rhs.m_summary_sp), + m_root_valobj_name(rhs.m_root_valobj_name), + m_hide_root_type(rhs.m_hide_root_type), + m_hide_name(rhs.m_hide_name), + m_hide_value(rhs.m_hide_value), + m_be_raw(rhs.m_be_raw) + {} + + DumpValueObjectOptions& + SetMaximumPointerDepth(uint32_t depth = 0) + { + m_max_ptr_depth = depth; + return *this; + } + + DumpValueObjectOptions& + SetMaximumDepth(uint32_t depth = 0) + { + m_max_depth = depth; + return *this; + } + + DumpValueObjectOptions& + SetShowTypes(bool show = false) + { + m_show_types = show; + return *this; + } + + DumpValueObjectOptions& + SetShowLocation(bool show = false) + { + m_show_location = show; + return *this; + } + + DumpValueObjectOptions& + SetUseObjectiveC(bool use = false) + { + m_use_objc = use; + return *this; + } + + DumpValueObjectOptions& + SetShowSummary(bool show = true) + { + if (show == false) + SetOmitSummaryDepth(UINT32_MAX); + else + SetOmitSummaryDepth(0); + return *this; + } + + DumpValueObjectOptions& + SetUseDynamicType(lldb::DynamicValueType dyn = lldb::eNoDynamicValues) + { + m_use_dynamic = dyn; + return *this; + } + + DumpValueObjectOptions& + SetUseSyntheticValue(bool use_synthetic = true) + { + m_use_synthetic = use_synthetic; + return *this; + } + + DumpValueObjectOptions& + SetScopeChecked(bool check = true) + { + m_scope_already_checked = check; + return *this; + } + + DumpValueObjectOptions& + SetFlatOutput(bool flat = false) + { + m_flat_output = flat; + return *this; + } + + DumpValueObjectOptions& + SetOmitSummaryDepth(uint32_t depth = 0) + { + m_omit_summary_depth = depth; + return *this; + } + + DumpValueObjectOptions& + SetIgnoreCap(bool ignore = false) + { + m_ignore_cap = ignore; + return *this; + } + + DumpValueObjectOptions& + SetRawDisplay(bool raw = false) + { + if (raw) + { + SetUseSyntheticValue(false); + SetOmitSummaryDepth(UINT32_MAX); + SetIgnoreCap(true); + SetHideName(false); + SetHideValue(false); + m_be_raw = true; + } + else + { + SetUseSyntheticValue(true); + SetOmitSummaryDepth(0); + SetIgnoreCap(false); + SetHideName(false); + SetHideValue(false); + m_be_raw = false; + } + return *this; + } + + DumpValueObjectOptions& + SetFormat (lldb::Format format = lldb::eFormatDefault) + { + m_format = format; + return *this; + } + + DumpValueObjectOptions& + SetSummary (lldb::TypeSummaryImplSP summary = lldb::TypeSummaryImplSP()) + { + m_summary_sp = summary; + return *this; + } + + DumpValueObjectOptions& + SetRootValueObjectName (const char* name = NULL) + { + if (name) + m_root_valobj_name.assign(name); + else + m_root_valobj_name.clear(); + return *this; + } + + DumpValueObjectOptions& + SetHideRootType (bool hide_root_type = false) + { + m_hide_root_type = hide_root_type; + return *this; + } + + DumpValueObjectOptions& + SetHideName (bool hide_name = false) + { + m_hide_name = hide_name; + return *this; + } + + DumpValueObjectOptions& + SetHideValue (bool hide_value = false) + { + m_hide_value = hide_value; + return *this; + } +}; + +class ValueObjectPrinter +{ +public: + + ValueObjectPrinter (ValueObject* valobj, + Stream* s, + const DumpValueObjectOptions& options); + + ~ValueObjectPrinter () {} + + bool + PrintValueObject (); + + bool + PrintChildrenOneLiner (bool hide_names); + +protected: + + // only this class (and subclasses, if any) should ever be concerned with + // the depth mechanism + ValueObjectPrinter (ValueObject* valobj, + Stream* s, + const DumpValueObjectOptions& options, + uint32_t ptr_depth, + uint32_t curr_depth); + + // we should actually be using delegating constructors here + // but some versions of GCC still have trouble with those + void + Init (ValueObject* valobj, + Stream* s, + const DumpValueObjectOptions& options, + uint32_t ptr_depth, + uint32_t curr_depth); + + bool + GetDynamicValueIfNeeded (); + + const char* + GetDescriptionForDisplay (); + + const char* + GetRootNameForDisplay (const char* if_fail = nullptr); + + bool + ShouldPrintValueObject (); + + bool + IsNil (); + + bool + IsPtr (); + + bool + IsRef (); + + bool + IsAggregate (); + + bool + PrintLocationIfNeeded (); + + bool + PrintTypeIfNeeded (); + + bool + PrintNameIfNeeded (bool show_type); + + bool + CheckScopeIfNeeded (); + + TypeSummaryImpl* + GetSummaryFormatter (); + + void + GetValueSummaryError (std::string& value, + std::string& summary, + std::string& error); + + bool + PrintValueAndSummaryIfNeeded (bool& value_printed, + bool& summary_printed); + + bool + PrintObjectDescriptionIfNeeded (bool value_printed, + bool summary_printed); + + bool + ShouldPrintChildren (bool is_failed_description, + uint32_t& curr_ptr_depth); + + ValueObject* + GetValueObjectForChildrenGeneration (); + + void + PrintChildrenPreamble (); + + void + PrintChildrenPostamble (bool print_dotdotdot); + + void + PrintChild (lldb::ValueObjectSP child_sp, + uint32_t curr_ptr_depth); + + uint32_t + GetMaxNumChildrenToPrint (bool& print_dotdotdot); + + void + PrintChildren (uint32_t curr_ptr_depth); + + void + PrintChildrenIfNeeded (bool value_printed, + bool summary_printed); + +private: + + ValueObject *m_orig_valobj; + ValueObject *m_valobj; + Stream *m_stream; + DumpValueObjectOptions options; + Flags m_type_flags; + ClangASTType m_clang_type; + uint32_t m_ptr_depth; + uint32_t m_curr_depth; + LazyBool m_should_print; + LazyBool m_is_nil; + LazyBool m_is_ptr; + LazyBool m_is_ref; + LazyBool m_is_aggregate; + std::pair<TypeSummaryImpl*,bool> m_summary_formatter; + std::string m_value; + std::string m_summary; + std::string m_error; + + DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter); +}; + +} // namespace lldb_private + +#endif // lldb_ValueObjectPrinter_h_ diff --git a/include/lldb/Expression/ClangExpressionDeclMap.h b/include/lldb/Expression/ClangExpressionDeclMap.h index b2a43e0ac75f..b04e1bd6f116 100644 --- a/include/lldb/Expression/ClangExpressionDeclMap.h +++ b/include/lldb/Expression/ClangExpressionDeclMap.h @@ -291,6 +291,9 @@ public: /// @param[in] name /// The name of the symbol. /// + /// @param[in] module + /// The module to limit the search to. This can be NULL + /// /// @return /// Valid load address for the symbol //------------------------------------------------------------------ @@ -298,7 +301,8 @@ public: GetSymbolAddress (Target &target, Process *process, const ConstString &name, - lldb::SymbolType symbol_type); + lldb::SymbolType symbol_type, + Module *module = NULL); lldb::addr_t GetSymbolAddress (const ConstString &name, @@ -504,12 +508,16 @@ private: /// @param[in] name /// The name as a plain C string. /// + /// @param[in] module + /// The module to limit the search to. This can be NULL + /// /// @return /// The LLDB Symbol found, or NULL if none was found. - //--------------------------------------------------------- + //------------------------------------------------------------------ const Symbol * FindGlobalDataSymbol (Target &target, - const ConstString &name); + const ConstString &name, + Module *module = NULL); //------------------------------------------------------------------ /// Given a target, find a variable that matches the given name and diff --git a/include/lldb/Expression/ClangFunction.h b/include/lldb/Expression/ClangFunction.h index 3f96f7bd3117..9cb22ed15cb5 100644 --- a/include/lldb/Expression/ClangFunction.h +++ b/include/lldb/Expression/ClangFunction.h @@ -67,8 +67,8 @@ class ClangFunction : public ClangExpression { friend class ASTStructExtractor; public: - //------------------------------------------------------------------ - /// Constructor + //------------------------------------------------------------------ + /// Constructor /// /// @param[in] exe_scope /// An execution context scope that gets us at least a target and @@ -84,14 +84,14 @@ public: /// @param[in] arg_value_list /// The default values to use when calling this function. Can /// be overridden using WriteFunctionArguments(). - //------------------------------------------------------------------ - ClangFunction (ExecutionContextScope &exe_scope, + //------------------------------------------------------------------ + ClangFunction (ExecutionContextScope &exe_scope, Function &function_ptr, ClangASTContext *ast_context, const ValueList &arg_value_list); //------------------------------------------------------------------ - /// Constructor + /// Constructor /// /// @param[in] exe_scope /// An execution context scope that gets us at least a target and @@ -110,32 +110,32 @@ public: /// @param[in] arg_value_list /// The default values to use when calling this function. Can /// be overridden using WriteFunctionArguments(). - //------------------------------------------------------------------ - ClangFunction (ExecutionContextScope &exe_scope, + //------------------------------------------------------------------ + ClangFunction (ExecutionContextScope &exe_scope, const ClangASTType &return_type, const Address& function_address, const ValueList &arg_value_list); //------------------------------------------------------------------ - /// Destructor - //------------------------------------------------------------------ - virtual + /// Destructor + //------------------------------------------------------------------ + virtual ~ClangFunction(); //------------------------------------------------------------------ - /// Compile the wrapper function + /// Compile the wrapper function /// /// @param[in] errors /// The stream to print parser errors to. /// /// @return /// The number of errors. - //------------------------------------------------------------------ + //------------------------------------------------------------------ unsigned CompileFunction (Stream &errors); //------------------------------------------------------------------ - /// Insert the default function wrapper and its default argument struct + /// Insert the default function wrapper and its default argument struct /// /// @param[in] exe_ctx /// The execution context to insert the function and its arguments @@ -151,14 +151,14 @@ public: /// /// @return /// True on success; false otherwise. - //------------------------------------------------------------------ + //------------------------------------------------------------------ bool InsertFunction (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, Stream &errors); //------------------------------------------------------------------ - /// Insert the default function wrapper (using the JIT) + /// Insert the default function wrapper (using the JIT) /// /// @param[in] exe_ctx /// The execution context to insert the function and its arguments @@ -169,12 +169,12 @@ public: /// /// @return /// True on success; false otherwise. - //------------------------------------------------------------------ + //------------------------------------------------------------------ bool WriteFunctionWrapper (ExecutionContext &exe_ctx, Stream &errors); //------------------------------------------------------------------ - /// Insert the default function argument struct + /// Insert the default function argument struct /// /// @param[in] exe_ctx /// The execution context to insert the function and its arguments @@ -190,13 +190,13 @@ public: /// /// @return /// True on success; false otherwise. - //------------------------------------------------------------------ + //------------------------------------------------------------------ bool WriteFunctionArguments (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, Stream &errors); //------------------------------------------------------------------ - /// Insert an argument struct with a non-default function address and + /// Insert an argument struct with a non-default function address and /// non-default argument values /// /// @param[in] exe_ctx @@ -219,7 +219,7 @@ public: /// /// @return /// True on success; false otherwise. - //------------------------------------------------------------------ + //------------------------------------------------------------------ bool WriteFunctionArguments (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, Address function_address, @@ -227,7 +227,7 @@ public: Stream &errors); //------------------------------------------------------------------ - /// [Static] Execute a function, passing it a single void* parameter. + /// [Static] Execute a function, passing it a single void* parameter. /// ClangFunction uses this to call the wrapper function. /// /// @param[in] exe_ctx @@ -266,7 +266,7 @@ public: /// /// @return /// Returns one of the ExecutionResults enum indicating function call status. - //------------------------------------------------------------------ + //------------------------------------------------------------------ static ExecutionResults ExecuteFunction (ExecutionContext &exe_ctx, lldb::addr_t function_address, @@ -446,7 +446,7 @@ public: /// /// @return /// A ThreadPlan for executing the function. - //------------------------------------------------------------------ + //------------------------------------------------------------------ static ThreadPlan * GetThreadPlanToCallFunction (ExecutionContext &exe_ctx, lldb::addr_t func_addr, @@ -482,7 +482,7 @@ public: /// /// @return /// A ThreadPlan for executing the function. - //------------------------------------------------------------------ + //------------------------------------------------------------------ ThreadPlan * GetThreadPlanToCallFunction (ExecutionContext &exe_ctx, lldb::addr_t &args_addr_ref, @@ -514,7 +514,7 @@ public: /// /// @return /// True on success; false otherwise. - //------------------------------------------------------------------ + //------------------------------------------------------------------ bool FetchFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t args_addr, Value &ret_value); @@ -528,7 +528,7 @@ public: /// /// @param[in] args_addr /// The address of the argument struct. - //------------------------------------------------------------------ + //------------------------------------------------------------------ void DeallocateFunctionResults (ExecutionContext &exe_ctx, lldb::addr_t args_addr); @@ -614,9 +614,9 @@ public: return m_arg_values; } private: - //------------------------------------------------------------------ - // For ClangFunction only - //------------------------------------------------------------------ + //------------------------------------------------------------------ + // For ClangFunction only + //------------------------------------------------------------------ std::unique_ptr<ClangExpressionParser> m_parser; ///< The parser responsible for compiling the function. std::unique_ptr<IRExecutionUnit> m_execution_unit_ap; @@ -624,17 +624,18 @@ private: Function *m_function_ptr; ///< The function we're going to call. May be NULL if we don't have debug info for the function. Address m_function_addr; ///< If we don't have the FunctionSP, we at least need the address & return type. ClangASTType m_function_return_type; ///< The opaque clang qual type for the function return type. - ClangASTContext *m_clang_ast_context; ///< This is the clang_ast_context that we're getting types from the and value, and the function return the function pointer is NULL. std::string m_wrapper_function_name; ///< The name of the wrapper function. std::string m_wrapper_function_text; ///< The contents of the wrapper function. std::string m_wrapper_struct_name; ///< The name of the struct that contains the target function address, arguments, and result. std::list<lldb::addr_t> m_wrapper_args_addrs; ///< The addresses of the arguments to the wrapper function. + std::unique_ptr<ASTStructExtractor> m_struct_extractor; ///< The class that generates the argument struct below. + bool m_struct_valid; ///< True if the ASTStructExtractor has populated the variables below. - //------------------------------------------------------------------ - /// These values are populated by the ASTStructExtractor + //------------------------------------------------------------------ + /// These values are populated by the ASTStructExtractor size_t m_struct_size; ///< The size of the argument struct, in bytes. std::vector<uint64_t> m_member_offsets; ///< The offset of each member in the struct, in bytes. uint64_t m_return_size; ///< The size of the result variable, in bytes. diff --git a/include/lldb/Expression/ClangUserExpression.h b/include/lldb/Expression/ClangUserExpression.h index 47bfebb46648..b8c3c128acf4 100644 --- a/include/lldb/Expression/ClangUserExpression.h +++ b/include/lldb/Expression/ClangUserExpression.h @@ -126,13 +126,8 @@ public: /// The execution context to use when looking up entities that /// are needed for parsing (locations of variables, etc.) /// - /// @param[in] unwind_on_error - /// If true, and the execution stops before completion, we unwind the - /// function call, and return the program state to what it was before the - /// execution. If false, we leave the program in the stopped state. - /// - /// @param[in] ignore_breakpoints - /// If true, ignore breakpoints while executing the expression. + /// @param[in] options + /// Expression evaluation options. /// /// @param[in] shared_ptr_to_me /// This is a shared pointer to this ClangUserExpression. This is @@ -145,29 +140,15 @@ public: /// A pointer to direct at the persistent variable in which the /// expression's result is stored. /// - /// @param[in] try_all_threads - /// If true, then we will try to run all threads if the function doesn't complete on - /// one thread. See timeout_usec for the interaction of this variable and - /// the timeout. - /// - /// @param[in] timeout_usec - /// Timeout value (0 for no timeout). If try_all_threads is true, then we - /// will try on one thread for the lesser of .25 sec and half the total timeout. - /// then switch to running all threads, otherwise this will be the total timeout. - /// - /// /// @return /// A Process::Execution results value. //------------------------------------------------------------------ ExecutionResults Execute (Stream &error_stream, ExecutionContext &exe_ctx, - bool unwind_on_error, - bool ignore_breakpoints, + const EvaluateExpressionOptions& options, ClangUserExpressionSP &shared_ptr_to_me, - lldb::ClangExpressionVariableSP &result, - bool try_all_threads, - uint32_t timeout_usec); + lldb::ClangExpressionVariableSP &result); ThreadPlan * GetThreadPlanToExecuteJITExpression (Stream &error_stream, @@ -300,25 +281,8 @@ public: /// @param[in] exe_ctx /// The execution context to use when evaluating the expression. /// - /// @param[in] execution_policy - /// Determines whether or not to try using the IR interpreter to - /// avoid running the expression on the parser. - /// - /// @param[in] language - /// If not eLanguageTypeUnknown, a language to use when parsing - /// the expression. Currently restricted to those languages - /// supported by Clang. - /// - /// @param[in] unwind_on_error - /// True if the thread's state should be restored in the case - /// of an error. - /// - /// @param[in] ignore_breakpoints - /// If true, ignore breakpoints while executing the expression. - /// - /// @param[in] result_type - /// If not eResultTypeAny, the type of the desired result. Will - /// result in parse errors if impossible. + /// @param[in] options + /// Expression evaluation options. /// /// @param[in] expr_cstr /// A C string containing the expression to be evaluated. @@ -330,45 +294,20 @@ public: /// @param[in/out] result_valobj_sp /// If execution is successful, the result valobj is placed here. /// - /// @param[in] try_all_threads - /// If true, then we will try to run all threads if the function doesn't complete on - /// one thread. See timeout_usec for the interaction of this variable and - /// the timeout. - /// - /// @param[in] timeout_usec - /// Timeout value (0 for no timeout). If try_all_threads is true, then we - /// will try on one thread for the lesser of .25 sec and half the total timeout. - /// then switch to running all threads, otherwise this will be the total timeout. + /// @param[out] + /// Filled in with an error in case the expression evaluation + /// fails to parse, run, or evaluated. /// /// @result /// A Process::ExecutionResults value. eExecutionCompleted for success. //------------------------------------------------------------------ static ExecutionResults Evaluate (ExecutionContext &exe_ctx, - lldb_private::ExecutionPolicy execution_policy, - lldb::LanguageType language, - ResultType desired_type, - bool unwind_on_error, - bool ignore_breakpoints, + const EvaluateExpressionOptions& options, const char *expr_cstr, const char *expr_prefix, lldb::ValueObjectSP &result_valobj_sp, - bool try_all_threads, - uint32_t timeout_usec); - - static ExecutionResults - EvaluateWithError (ExecutionContext &exe_ctx, - lldb_private::ExecutionPolicy execution_policy, - lldb::LanguageType language, - ResultType desired_type, - bool unwind_on_error, - bool ignore_breakpoints, - const char *expr_cstr, - const char *expr_prefix, - lldb::ValueObjectSP &result_valobj_sp, - Error &error, - bool try_all_threads, - uint32_t timeout_usec); + Error &error); static const Error::ValueType kNoResult = 0x1001; ///< ValueObject::GetError() returns this if there is no result from the expression. private: diff --git a/include/lldb/Expression/DWARFExpression.h b/include/lldb/Expression/DWARFExpression.h index 2692831ecc84..5ecdf7fe9ee5 100644 --- a/include/lldb/Expression/DWARFExpression.h +++ b/include/lldb/Expression/DWARFExpression.h @@ -58,7 +58,8 @@ public: /// @param[in] data_length /// The byte length of the location expression. //------------------------------------------------------------------ - DWARFExpression(const DataExtractor& data, + DWARFExpression(lldb::ModuleSP module, + const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length); @@ -172,6 +173,9 @@ public: /// Make the expression parser read its location information from a /// given data source /// + /// @param[in] module_sp + /// The module that defines the DWARF expression. + /// /// @param[in] data /// A data extractor configured to read the DWARF location expression's /// bytecode. @@ -183,7 +187,7 @@ public: /// The byte length of the location expression. //------------------------------------------------------------------ void - SetOpcodeData(const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length); + SetOpcodeData(lldb::ModuleSP module_sp, const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length); //------------------------------------------------------------------ /// Copy the DWARF location expression into a local buffer. @@ -199,6 +203,9 @@ public: /// the data, it shouldn't amount to that much for the variables we /// end up parsing. /// + /// @param[in] module_sp + /// The module that defines the DWARF expression. + /// /// @param[in] data /// A data extractor configured to read and copy the DWARF /// location expression's bytecode. @@ -210,7 +217,8 @@ public: /// The byte length of the location expression. //------------------------------------------------------------------ void - CopyOpcodeData (const DataExtractor& data, + CopyOpcodeData (lldb::ModuleSP module_sp, + const DataExtractor& data, lldb::offset_t data_offset, lldb::offset_t data_length); @@ -279,6 +287,9 @@ public: /// expression. The location expression may access the target's /// memory, especially if it comes from the expression parser. /// + /// @param[in] opcode_ctx + /// The module which defined the expression. + /// /// @param[in] opcodes /// This is a static method so the opcodes need to be provided /// explicitly. @@ -332,6 +343,7 @@ public: ClangExpressionVariableList *expr_locals, ClangExpressionDeclMap *decl_map, RegisterContext *reg_ctx, + lldb::ModuleSP opcode_ctx, const DataExtractor& opcodes, const lldb::offset_t offset, const lldb::offset_t length, @@ -410,7 +422,8 @@ protected: //------------------------------------------------------------------ /// Classes that inherit from DWARFExpression can see and modify these //------------------------------------------------------------------ - + + lldb::ModuleWP m_module_wp; ///< Module which defined this expression. DataExtractor m_data; ///< A data extractor capable of reading opcode bytes lldb::RegisterKind m_reg_kind; ///< One of the defines that starts with LLDB_REGKIND_ lldb::addr_t m_loclist_slide; ///< A value used to slide the location list offsets so that diff --git a/include/lldb/Expression/IRExecutionUnit.h b/include/lldb/Expression/IRExecutionUnit.h index 885b6516b0c6..2820317e108e 100644 --- a/include/lldb/Expression/IRExecutionUnit.h +++ b/include/lldb/Expression/IRExecutionUnit.h @@ -287,7 +287,8 @@ private: /// Allocated space. //------------------------------------------------------------------ virtual uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, - unsigned SectionID); + unsigned SectionID, + llvm::StringRef SectionName); //------------------------------------------------------------------ /// Allocate space for data, and add it to the m_spaceBlocks map @@ -308,7 +309,9 @@ private: /// Allocated space. //------------------------------------------------------------------ virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, - unsigned SectionID, bool IsReadOnly); + unsigned SectionID, + llvm::StringRef SectionName, + bool IsReadOnly); //------------------------------------------------------------------ /// Allocate space for a global variable, and add it to the @@ -388,6 +391,10 @@ private: return m_default_mm_ap->GetNumStubSlabs(); } + virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) { + return m_default_mm_ap->registerEHFrames(Addr, LoadAddr, Size); + } + //------------------------------------------------------------------ /// Passthrough interface stub //------------------------------------------------------------------ diff --git a/include/lldb/Expression/IRForTarget.h b/include/lldb/Expression/IRForTarget.h index 151bf2ab4774..566328772502 100644 --- a/include/lldb/Expression/IRForTarget.h +++ b/include/lldb/Expression/IRForTarget.h @@ -19,6 +19,7 @@ #include "llvm/Pass.h" #include <map> +#include <functional> namespace llvm { class BasicBlock; diff --git a/include/lldb/Host/Condition.h b/include/lldb/Host/Condition.h index 98439ee2ebdf..2f1858b75a56 100644 --- a/include/lldb/Host/Condition.h +++ b/include/lldb/Host/Condition.h @@ -12,7 +12,7 @@ #if defined(__cplusplus) -#include <pthread.h> +#include "lldb/lldb-types.h" #include "lldb/Host/Mutex.h" namespace lldb_private { @@ -105,7 +105,7 @@ protected: //------------------------------------------------------------------ // Member variables //------------------------------------------------------------------ - pthread_cond_t m_condition; ///< The condition variable. + lldb::condition_t m_condition; ///< The condition variable. //------------------------------------------------------------------ /// Get accessor to the pthread condition object. @@ -113,7 +113,7 @@ protected: /// @return /// A pointer to the condition variable owned by this object. //------------------------------------------------------------------ - pthread_cond_t * + lldb::condition_t * GetCondition (); }; diff --git a/include/lldb/Host/Config.h b/include/lldb/Host/Config.h index 2d5d39baac3d..80616b747cf5 100644 --- a/include/lldb/Host/Config.h +++ b/include/lldb/Host/Config.h @@ -14,7 +14,7 @@ #include "lldb/Host/macosx/Config.h" -#elif defined(__linux__) +#elif defined(__linux__) || defined(__GNU__) #include "lldb/Host/linux/Config.h" @@ -26,6 +26,10 @@ #include "lldb/Host/mingw/Config.h" +#elif defined(_MSC_VER) + +#include "lldb/Host/msvc/Config.h" + #else #error undefined platform diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h index df7fe92cccba..7ca582402b32 100644 --- a/include/lldb/Host/File.h +++ b/include/lldb/Host/File.h @@ -11,7 +11,9 @@ #define liblldb_File_h_ #if defined(__cplusplus) +#include <stdarg.h> #include <stdio.h> +#include <sys/types.h> #include "lldb/lldb-private.h" @@ -41,17 +43,20 @@ public: eOpenOptionCanCreateNewOnly = (1u << 6) // Can create file only if it doesn't already exist }; + static mode_t + ConvertOpenOptionsForPOSIXOpen (uint32_t open_options); + enum Permissions { - ePermissionsUserRead = (1u << 0), - ePermissionsUserWrite = (1u << 1), - ePermissionsUserExecute = (1u << 2), - ePermissionsGroupRead = (1u << 3), + ePermissionsUserRead = (1u << 8), + ePermissionsUserWrite = (1u << 7), + ePermissionsUserExecute = (1u << 6), + ePermissionsGroupRead = (1u << 5), ePermissionsGroupWrite = (1u << 4), - ePermissionsGroupExecute = (1u << 5), - ePermissionsWorldRead = (1u << 6), - ePermissionsWorldWrite = (1u << 7), - ePermissionsWorldExecute = (1u << 8), + ePermissionsGroupExecute = (1u << 3), + ePermissionsWorldRead = (1u << 2), + ePermissionsWorldWrite = (1u << 1), + ePermissionsWorldExecute = (1u << 0), ePermissionsUserRW = (ePermissionsUserRead | ePermissionsUserWrite | 0 ), ePermissionsUserRX = (ePermissionsUserRead | 0 | ePermissionsUserExecute ), @@ -117,6 +122,27 @@ public: uint32_t options, uint32_t permissions = ePermissionsDefault); + //------------------------------------------------------------------ + /// Constructor with FileSpec. + /// + /// Takes a FileSpec pointing to a file which can be just a filename, or a full + /// path. If \a path is not NULL or empty, this function will call + /// File::Open (const char *path, uint32_t options, uint32_t permissions). + /// + /// @param[in] path + /// The FileSpec for this file. + /// + /// @param[in] options + /// Options to use when opening (see File::OpenOptions) + /// + /// @param[in] permissions + /// Options to use when opening (see File::Permissions) + /// + /// @see File::Open (const char *path, uint32_t options, uint32_t permissions) + //------------------------------------------------------------------ + File (const FileSpec& filespec, + uint32_t options, + uint32_t permissions = ePermissionsDefault); File (int fd, bool tranfer_ownership) : m_descriptor (fd), @@ -451,6 +477,19 @@ public: //------------------------------------------------------------------ Error Sync (); + + //------------------------------------------------------------------ + /// Get the permissions for a this file. + /// + /// @return + /// Bits logical OR'ed together from the permission bits defined + /// in lldb_private::File::Permissions. + //------------------------------------------------------------------ + uint32_t + GetPermissions(Error &error) const; + + static uint32_t + GetPermissions (const char *path, Error &error); //------------------------------------------------------------------ /// Output printf formatted output to the stream. diff --git a/include/lldb/Host/FileSpec.h b/include/lldb/Host/FileSpec.h index c58be9ec09d5..dfc6b711ae4a 100644 --- a/include/lldb/Host/FileSpec.h +++ b/include/lldb/Host/FileSpec.h @@ -177,7 +177,7 @@ public: /// A pointer to this object if either the directory or filename /// is valid, NULL otherwise. //------------------------------------------------------------------ - operator bool() const; + explicit operator bool() const; //------------------------------------------------------------------ /// Logical NOT operator. @@ -624,6 +624,21 @@ public: static size_t Resolve (const char *src_path, char *dst_path, size_t dst_len); + FileSpec + CopyByAppendingPathComponent (const char *new_path) const; + + FileSpec + CopyByRemovingLastPathComponent () const; + + void + AppendPathComponent (const char *new_path); + + void + RemoveLastPathComponent (); + + const char* + GetLastPathComponent () const; + //------------------------------------------------------------------ /// Resolves the user name at the beginning of \a src_path, and writes the output /// to \a dst_path. Note, \a src_path can contain other path components after the diff --git a/include/lldb/Host/Host.h b/include/lldb/Host/Host.h index 547bdd5d637b..1d667dee5a20 100644 --- a/include/lldb/Host/Host.h +++ b/include/lldb/Host/Host.h @@ -18,6 +18,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/StringList.h" +#include "lldb/Host/File.h" namespace lldb_private { @@ -209,6 +210,9 @@ public: static lldb::pid_t GetCurrentProcessID (); + static void + Kill(lldb::pid_t pid, int signo); + //------------------------------------------------------------------ /// Get the thread ID for the calling thread in the current process. /// @@ -264,6 +268,17 @@ public: lldb::thread_result_t *thread_result_ptr, Error *error); + typedef void (*ThreadLocalStorageCleanupCallback) (void *p); + + static lldb::thread_key_t + ThreadLocalStorageCreate(ThreadLocalStorageCleanupCallback callback); + + static void* + ThreadLocalStorageGet(lldb::thread_key_t key); + + static void + ThreadLocalStorageSet(lldb::thread_key_t key, void *value); + //------------------------------------------------------------------ /// Gets the name of a thread in a process. /// @@ -458,7 +473,7 @@ public: int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit std::string *command_output, // Pass NULL if you don't want the command output uint32_t timeout_sec, - const char *shell = "/bin/bash"); + const char *shell = LLDB_DEFAULT_SHELL); static lldb::DataBufferSP GetAuxvData (lldb_private::Process *process); @@ -494,6 +509,45 @@ public: DynamicLibraryGetSymbol (void *dynamic_library_handle, const char *symbol_name, Error &error); + + static uint32_t + MakeDirectory (const char* path, mode_t mode); + + static lldb::user_id_t + OpenFile (const FileSpec& file_spec, + uint32_t flags, + mode_t mode, + Error &error); + + static bool + CloseFile (lldb::user_id_t fd, + Error &error); + + static uint64_t + WriteFile (lldb::user_id_t fd, + uint64_t offset, + const void* src, + uint64_t src_len, + Error &error); + + static uint64_t + ReadFile (lldb::user_id_t fd, + uint64_t offset, + void* dst, + uint64_t dst_len, + Error &error); + + static lldb::user_id_t + GetFileSize (const FileSpec& file_spec); + + static bool + GetFileExists (const FileSpec& file_spec); + + static bool + CalculateMD5 (const FileSpec& file_spec, + uint64_t &low, + uint64_t &high); + }; } // namespace lldb_private diff --git a/include/lldb/Host/Mutex.h b/include/lldb/Host/Mutex.h index 63f759efe366..496dd0496c13 100644 --- a/include/lldb/Host/Mutex.h +++ b/include/lldb/Host/Mutex.h @@ -11,7 +11,7 @@ #define liblldb_Mutex_h_ #if defined(__cplusplus) -#include <pthread.h> +#include "lldb/lldb-types.h" #include <assert.h> #ifdef LLDB_CONFIGURATION_DEBUG @@ -238,7 +238,7 @@ protected: //------------------------------------------------------------------ // TODO: Hide the mutex in the implementation file in case we ever need to port to an // architecture that doesn't have pthread mutexes. - pthread_mutex_t m_mutex; ///< The pthread mutex object. + lldb::mutex_t m_mutex; ///< The OS mutex object. private: //------------------------------------------------------------------ @@ -247,7 +247,7 @@ private: /// @return /// A pointer to the pthread mutex object owned by this object. //------------------------------------------------------------------ - pthread_mutex_t * + lldb::mutex_t * GetMutex(); Mutex(const Mutex&); diff --git a/include/lldb/Host/OptionParser.h b/include/lldb/Host/OptionParser.h new file mode 100644 index 000000000000..410e4d9f9468 --- /dev/null +++ b/include/lldb/Host/OptionParser.h @@ -0,0 +1,53 @@ +//===-- OptionParser.h ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_OptionParser_h_ +#define liblldb_OptionParser_h_ + +namespace lldb_private { + +typedef struct Option +{ + // name of long option + const char *name; + // one of no_argument, required_argument, and optional_argument: + // whether option takes an argument + int has_arg; + // if not NULL, set *flag to val when option found + int *flag; + // if flag not NULL, value to set *flag to; else return value + int val; +} Option; + +class OptionParser +{ +public: + enum OptionArgument + { + eNoArgument = 0, + eRequiredArgument, + eOptionalArgument + }; + + static void Prepare(); + + static void EnableError(bool error); + + static int Parse(int argc, char * const argv [], + const char *optstring, + const Option *longopts, int *longindex); + + static char* GetOptionArgument(); + static int GetOptionIndex(); + static int GetOptionErrorCause(); +}; + +} + +#endif // liblldb_OptionParser_h_ diff --git a/include/lldb/Host/ProcessRunLock.h b/include/lldb/Host/ProcessRunLock.h index f563be73fce0..eca1ad375fc6 100644 --- a/include/lldb/Host/ProcessRunLock.h +++ b/include/lldb/Host/ProcessRunLock.h @@ -11,9 +11,9 @@ #define liblldb_ProcessRunLock_h_ #if defined(__cplusplus) +#include "lldb/lldb-defines.h" #include "lldb/Host/Mutex.h" #include "lldb/Host/Condition.h" -#include <pthread.h> #include <stdint.h> #include <time.h> @@ -32,75 +32,14 @@ namespace lldb_private { class ProcessRunLock { public: - ProcessRunLock () : - m_rwlock(), - m_running(false) - { - int err = ::pthread_rwlock_init(&m_rwlock, NULL); (void)err; -//#if LLDB_CONFIGURATION_DEBUG -// assert(err == 0); -//#endif - } - - ~ProcessRunLock () - { - int err = ::pthread_rwlock_destroy (&m_rwlock); (void)err; -//#if LLDB_CONFIGURATION_DEBUG -// assert(err == 0); -//#endif - } - - bool - ReadTryLock () - { - ::pthread_rwlock_rdlock (&m_rwlock); - if (m_running == false) - { - return true; - } - ::pthread_rwlock_unlock (&m_rwlock); - return false; - } - - bool - ReadUnlock () - { - return ::pthread_rwlock_unlock (&m_rwlock) == 0; - } - - bool - SetRunning() - { - ::pthread_rwlock_wrlock (&m_rwlock); - m_running = true; - ::pthread_rwlock_unlock (&m_rwlock); - return true; - } - - bool - TrySetRunning() - { - bool r; - - if (::pthread_rwlock_trywrlock (&m_rwlock) == 0) - { - r = !m_running; - m_running = true; - ::pthread_rwlock_unlock (&m_rwlock); - return r; - } - return false; - } - - bool - SetStopped () - { - ::pthread_rwlock_wrlock (&m_rwlock); - m_running = false; - ::pthread_rwlock_unlock (&m_rwlock); - return true; - } - + ProcessRunLock(); + ~ProcessRunLock(); + bool ReadTryLock (); + bool ReadUnlock (); + bool SetRunning (); + bool TrySetRunning (); + bool SetStopped (); +public: class ProcessRunLocker { public: @@ -153,7 +92,7 @@ public: }; protected: - pthread_rwlock_t m_rwlock; + lldb::rwlock_t m_rwlock; bool m_running; private: DISALLOW_COPY_AND_ASSIGN(ProcessRunLock); diff --git a/include/lldb/Host/SocketAddress.h b/include/lldb/Host/SocketAddress.h index e63b238c7994..5e79e94fa9ec 100644 --- a/include/lldb/Host/SocketAddress.h +++ b/include/lldb/Host/SocketAddress.h @@ -12,9 +12,18 @@ // C Includes #include <stdint.h> + +#ifdef _WIN32 +#include "lldb/Host/windows/windows.h" +#include <winsock2.h> +#include <WS2tcpip.h> +typedef ADDRESS_FAMILY sa_family_t; +typedef USHORT in_port_t; +#else #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> +#endif #if defined(__FreeBSD__) #include <sys/types.h> diff --git a/include/lldb/Host/Symbols.h b/include/lldb/Host/Symbols.h index 9db68e1ecf15..652a614e6355 100644 --- a/include/lldb/Host/Symbols.h +++ b/include/lldb/Host/Symbols.h @@ -12,7 +12,6 @@ // C Includes #include <stdint.h> -#include <sys/time.h> // C++ Includes // Other libraries and framework includes diff --git a/include/lldb/Host/Terminal.h b/include/lldb/Host/Terminal.h index b334717c796b..5ea88c515637 100644 --- a/include/lldb/Host/Terminal.h +++ b/include/lldb/Host/Terminal.h @@ -12,6 +12,7 @@ #if defined(__cplusplus) #include "lldb/lldb-private.h" +#include "lldb/Host/Config.h" struct termios; @@ -173,7 +174,9 @@ protected: //------------------------------------------------------------------ Terminal m_tty; ///< A terminal int m_tflags; ///< Cached tflags information. +#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED std::unique_ptr<struct termios> m_termios_ap; ///< Cached terminal state information. +#endif lldb::pid_t m_process_group;///< Cached process group information. }; diff --git a/include/lldb/Host/TimeValue.h b/include/lldb/Host/TimeValue.h index 8c43d6d0e5ff..ba230045307f 100644 --- a/include/lldb/Host/TimeValue.h +++ b/include/lldb/Host/TimeValue.h @@ -12,6 +12,7 @@ // C Includes #include <stdint.h> +#ifndef _MSC_VER #include <sys/time.h> // BEGIN: MinGW work around @@ -19,6 +20,7 @@ #include <pthread.h> #endif // END: MinGW work around +#endif // C++ Includes // Other libraries and framework includes @@ -40,7 +42,7 @@ public: TimeValue(); TimeValue(const TimeValue& rhs); TimeValue(const struct timespec& ts); - TimeValue(const struct timeval& tv); + explicit TimeValue(uint32_t seconds, uint32_t nanos = 0); ~TimeValue(); //------------------------------------------------------------------ @@ -64,9 +66,6 @@ public: struct timespec GetAsTimeSpec () const; - struct timeval - GetAsTimeVal () const; - bool IsValid () const; @@ -85,6 +84,23 @@ public: void Dump (Stream *s, uint32_t width = 0) const; + /// Returns only the seconds component of the TimeValue. The nanoseconds + /// portion is ignored. No rounding is performed. + /// @brief Retrieve the seconds component + uint32_t seconds() const { return m_nano_seconds / NanoSecPerSec; } + + /// Returns only the nanoseconds component of the TimeValue. The seconds + /// portion is ignored. + /// @brief Retrieve the nanoseconds component. + uint32_t nanoseconds() const { return m_nano_seconds % NanoSecPerSec; } + + /// Returns only the fractional portion of the TimeValue rounded down to the + /// nearest microsecond (divide by one thousand). + /// @brief Retrieve the fractional part as microseconds; + uint32_t microseconds() const { + return (m_nano_seconds % NanoSecPerSec) / NanoSecPerMicroSec; + } + protected: //------------------------------------------------------------------ // Classes that inherit from TimeValue can see and modify these diff --git a/include/lldb/Interpreter/Args.h b/include/lldb/Interpreter/Args.h index d06c3e56aecd..27feca63e4ad 100644 --- a/include/lldb/Interpreter/Args.h +++ b/include/lldb/Interpreter/Args.h @@ -11,8 +11,6 @@ #define liblldb_Command_h_ // C Includes -#include <getopt.h> - // C++ Includes #include <list> #include <string> @@ -24,6 +22,7 @@ #include "lldb/lldb-private-types.h" #include "lldb/lldb-types.h" #include "lldb/Core/Error.h" +#include "lldb/Host/OptionParser.h" namespace lldb_private { @@ -319,7 +318,7 @@ public: ParseOptions (Options &options); size_t - FindArgumentIndexForOption (struct option *long_options, int long_options_index); + FindArgumentIndexForOption (Option *long_options, int long_options_index); bool IsPositionalArgument (const char *arg); diff --git a/include/lldb/Interpreter/CommandObject.h b/include/lldb/Interpreter/CommandObject.h index 2bfab0a8ecc4..8544fd9f9c3f 100644 --- a/include/lldb/Interpreter/CommandObject.h +++ b/include/lldb/Interpreter/CommandObject.h @@ -42,7 +42,7 @@ public: return (*help_callback)(); } - operator bool() const + explicit operator bool() const { return (help_callback != NULL); } diff --git a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h index da05e127d5d1..c09528f9f514 100644 --- a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h +++ b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h @@ -62,8 +62,8 @@ public: ignore_cap == true; } - ValueObject::DumpValueObjectOptions - GetAsDumpOptions (bool objc_is_compact = false, + DumpValueObjectOptions + GetAsDumpOptions (LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity = eLanguageRuntimeDescriptionDisplayVerbosityFull, lldb::Format format = lldb::eFormatDefault, lldb::TypeSummaryImplSP summary_sp = lldb::TypeSummaryImplSP()); diff --git a/include/lldb/Interpreter/OptionValueBoolean.h b/include/lldb/Interpreter/OptionValueBoolean.h index 2b935e9e03e6..e024f3a0f3db 100644 --- a/include/lldb/Interpreter/OptionValueBoolean.h +++ b/include/lldb/Interpreter/OptionValueBoolean.h @@ -92,7 +92,7 @@ public: /// /b True this object contains a valid namespace decl, \b /// false otherwise. //------------------------------------------------------------------ - operator bool() const + explicit operator bool() const { return m_current_value; } diff --git a/include/lldb/Interpreter/OptionValueEnumeration.h b/include/lldb/Interpreter/OptionValueEnumeration.h index 012eeb68ac0e..68beddfce0d0 100644 --- a/include/lldb/Interpreter/OptionValueEnumeration.h +++ b/include/lldb/Interpreter/OptionValueEnumeration.h @@ -34,7 +34,7 @@ public: const char *description; }; typedef UniqueCStringMap<EnumeratorInfo> EnumerationMap; - typedef typename EnumerationMap::Entry EnumerationMapEntry; + typedef EnumerationMap::Entry EnumerationMapEntry; OptionValueEnumeration (const OptionEnumValueElement *enumerators, enum_type value); diff --git a/include/lldb/Interpreter/Options.h b/include/lldb/Interpreter/Options.h index ac4daa8f579a..2b4ac1190557 100644 --- a/include/lldb/Interpreter/Options.h +++ b/include/lldb/Interpreter/Options.h @@ -11,7 +11,6 @@ #define liblldb_Options_h_ // C Includes -#include <getopt.h> // C++ Includes #include <set> @@ -141,7 +140,7 @@ public: /// @see Args::ParseOptions (Options&) /// @see man getopt_long_only //------------------------------------------------------------------ - struct option * + Option * GetLongOptions (); // This gets passed the short option as an integer... @@ -309,7 +308,7 @@ protected: typedef std::vector<OptionSet> OptionSetVector; CommandInterpreter &m_interpreter; - std::vector<struct option> m_getopt_table; + std::vector<Option> m_getopt_table; OptionSet m_seen_options; OptionSetVector m_required_options; OptionSetVector m_optional_options; @@ -448,6 +447,12 @@ protected: void Finalize (); + bool + DidFinalize () + { + return m_did_finalize; + } + virtual Error SetOptionValue (uint32_t option_idx, const char *option_arg); @@ -464,6 +469,10 @@ protected: assert (m_did_finalize); return &m_option_defs[0]; } + + const OptionGroup* + GetGroupWithOption (char short_opt); + struct OptionInfo { OptionInfo (OptionGroup* g, uint32_t i) : diff --git a/include/lldb/Interpreter/PythonDataObjects.h b/include/lldb/Interpreter/PythonDataObjects.h index b2c9240db09f..a54318159d14 100644 --- a/include/lldb/Interpreter/PythonDataObjects.h +++ b/include/lldb/Interpreter/PythonDataObjects.h @@ -105,7 +105,7 @@ namespace lldb_private { PythonString Str (); - operator bool () const + explicit operator bool () const { return m_py_obj != NULL; } diff --git a/include/lldb/Interpreter/ScriptInterpreter.h b/include/lldb/Interpreter/ScriptInterpreter.h index 9a66c775d47a..9f529b822910 100644 --- a/include/lldb/Interpreter/ScriptInterpreter.h +++ b/include/lldb/Interpreter/ScriptInterpreter.h @@ -41,7 +41,7 @@ public: return m_object; } - operator bool () + explicit operator bool () { return m_object != NULL; } @@ -108,44 +108,47 @@ public: const char *session_dictionary_name, const lldb::ProcessSP& process_sp); - typedef uint32_t (*SWIGPythonCalculateNumChildren) (void *implementor); - typedef void* (*SWIGPythonGetChildAtIndex) (void *implementor, uint32_t idx); - typedef int (*SWIGPythonGetIndexOfChildWithName) (void *implementor, const char* child_name); - typedef void* (*SWIGPythonCastPyObjectToSBValue) (void* data); - typedef bool (*SWIGPythonUpdateSynthProviderInstance) (void* data); - typedef bool (*SWIGPythonMightHaveChildrenSynthProviderInstance) (void* data); - - - typedef bool (*SWIGPythonCallCommand) (const char *python_function_name, - const char *session_dictionary_name, - lldb::DebuggerSP& debugger, - const char* args, - lldb_private::CommandReturnObject& cmd_retobj); - - typedef bool (*SWIGPythonCallModuleInit) (const char *python_module_name, - const char *session_dictionary_name, - lldb::DebuggerSP& debugger); - - typedef bool (*SWIGPythonScriptKeyword_Process) (const char* python_function_name, - const char* session_dictionary_name, - lldb::ProcessSP& process, - std::string& output); - typedef bool (*SWIGPythonScriptKeyword_Thread) (const char* python_function_name, - const char* session_dictionary_name, - lldb::ThreadSP& thread, - std::string& output); - - typedef bool (*SWIGPythonScriptKeyword_Target) (const char* python_function_name, - const char* session_dictionary_name, - lldb::TargetSP& target, - std::string& output); - - typedef bool (*SWIGPythonScriptKeyword_Frame) (const char* python_function_name, - const char* session_dictionary_name, - lldb::StackFrameSP& frame, - std::string& output); - - + typedef uint32_t (*SWIGPythonCalculateNumChildren) (void *implementor); + typedef void* (*SWIGPythonGetChildAtIndex) (void *implementor, uint32_t idx); + typedef int (*SWIGPythonGetIndexOfChildWithName) (void *implementor, const char* child_name); + typedef void* (*SWIGPythonCastPyObjectToSBValue) (void* data); + typedef lldb::ValueObjectSP (*SWIGPythonGetValueObjectSPFromSBValue) (void* data); + typedef bool (*SWIGPythonUpdateSynthProviderInstance) (void* data); + typedef bool (*SWIGPythonMightHaveChildrenSynthProviderInstance) (void* data); + + + typedef bool (*SWIGPythonCallCommand) (const char *python_function_name, + const char *session_dictionary_name, + lldb::DebuggerSP& debugger, + const char* args, + lldb_private::CommandReturnObject& cmd_retobj); + + typedef bool (*SWIGPythonCallModuleInit) (const char *python_module_name, + const char *session_dictionary_name, + lldb::DebuggerSP& debugger); + + typedef bool (*SWIGPythonScriptKeyword_Process) (const char* python_function_name, + const char* session_dictionary_name, + lldb::ProcessSP& process, + std::string& output); + typedef bool (*SWIGPythonScriptKeyword_Thread) (const char* python_function_name, + const char* session_dictionary_name, + lldb::ThreadSP& thread, + std::string& output); + + typedef bool (*SWIGPythonScriptKeyword_Target) (const char* python_function_name, + const char* session_dictionary_name, + lldb::TargetSP& target, + std::string& output); + + typedef bool (*SWIGPythonScriptKeyword_Frame) (const char* python_function_name, + const char* session_dictionary_name, + lldb::StackFrameSP& frame, + std::string& output); + + typedef void* (*SWIGPython_GetDynamicSetting) (void* module, + const char* setting, + const lldb::TargetSP& target_sp); typedef enum { @@ -162,7 +165,8 @@ public: eScriptReturnTypeFloat, eScriptReturnTypeDouble, eScriptReturnTypeChar, - eScriptReturnTypeCharStrOrNone + eScriptReturnTypeCharStrOrNone, + eScriptReturnTypeOpaqueObject } ScriptReturnType; ScriptInterpreter (CommandInterpreter &interpreter, lldb::ScriptLanguage script_lang); @@ -336,6 +340,22 @@ public: { return lldb::ScriptInterpreterObjectSP(); } + + virtual lldb::ScriptInterpreterObjectSP + LoadPluginModule (const FileSpec& file_spec, + lldb_private::Error& error) + { + return lldb::ScriptInterpreterObjectSP(); + } + + virtual lldb::ScriptInterpreterObjectSP + GetDynamicSettings (lldb::ScriptInterpreterObjectSP plugin_module_sp, + Target* target, + const char* setting_name, + lldb_private::Error& error) + { + return lldb::ScriptInterpreterObjectSP(); + } virtual bool GenerateFunction(const char *signature, const StringList &input) @@ -473,7 +493,8 @@ public: LoadScriptingModule (const char* filename, bool can_reload, bool init_session, - lldb_private::Error& error) + lldb_private::Error& error, + lldb::ScriptInterpreterObjectSP* module_sp = nullptr) { error.SetErrorString("loading unimplemented"); return false; @@ -501,7 +522,26 @@ public: LanguageToString (lldb::ScriptLanguage language); static void - InitializeInterpreter (SWIGInitCallback python_swig_init_callback); + InitializeInterpreter (SWIGInitCallback python_swig_init_callback, + SWIGBreakpointCallbackFunction swig_breakpoint_callback, + SWIGWatchpointCallbackFunction swig_watchpoint_callback, + SWIGPythonTypeScriptCallbackFunction swig_typescript_callback, + SWIGPythonCreateSyntheticProvider swig_synthetic_script, + SWIGPythonCalculateNumChildren swig_calc_children, + SWIGPythonGetChildAtIndex swig_get_child_index, + SWIGPythonGetIndexOfChildWithName swig_get_index_child, + SWIGPythonCastPyObjectToSBValue swig_cast_to_sbvalue , + SWIGPythonGetValueObjectSPFromSBValue swig_get_valobj_sp_from_sbvalue, + SWIGPythonUpdateSynthProviderInstance swig_update_provider, + SWIGPythonMightHaveChildrenSynthProviderInstance swig_mighthavechildren_provider, + SWIGPythonCallCommand swig_call_command, + SWIGPythonCallModuleInit swig_call_module_init, + SWIGPythonCreateOSPlugin swig_create_os_plugin, + SWIGPythonScriptKeyword_Process swig_run_script_keyword_process, + SWIGPythonScriptKeyword_Thread swig_run_script_keyword_thread, + SWIGPythonScriptKeyword_Target swig_run_script_keyword_target, + SWIGPythonScriptKeyword_Frame swig_run_script_keyword_frame, + SWIGPython_GetDynamicSetting swig_plugin_get); static void TerminateInterpreter (); diff --git a/include/lldb/Interpreter/ScriptInterpreterPython.h b/include/lldb/Interpreter/ScriptInterpreterPython.h index 2616f575d20e..4b3dc61f3ee8 100644 --- a/include/lldb/Interpreter/ScriptInterpreterPython.h +++ b/include/lldb/Interpreter/ScriptInterpreterPython.h @@ -98,6 +98,16 @@ public: lldb::tid_t tid, lldb::addr_t context); + virtual lldb::ScriptInterpreterObjectSP + LoadPluginModule (const FileSpec& file_spec, + lldb_private::Error& error); + + virtual lldb::ScriptInterpreterObjectSP + GetDynamicSettings (lldb::ScriptInterpreterObjectSP plugin_module_sp, + Target* target, + const char* setting_name, + lldb_private::Error& error); + virtual size_t CalculateNumChildren (const lldb::ScriptInterpreterObjectSP& implementor); @@ -200,7 +210,8 @@ public: LoadScriptingModule (const char* filename, bool can_reload, bool init_session, - lldb_private::Error& error); + lldb_private::Error& error, + lldb::ScriptInterpreterObjectSP* module_sp = nullptr); virtual lldb::ScriptInterpreterObjectSP MakeScriptObject (void* object); @@ -239,7 +250,26 @@ public: InitializePrivate (); static void - InitializeInterpreter (SWIGInitCallback python_swig_init_callback); + InitializeInterpreter (SWIGInitCallback python_swig_init_callback, + SWIGBreakpointCallbackFunction swig_breakpoint_callback, + SWIGWatchpointCallbackFunction swig_watchpoint_callback, + SWIGPythonTypeScriptCallbackFunction swig_typescript_callback, + SWIGPythonCreateSyntheticProvider swig_synthetic_script, + SWIGPythonCalculateNumChildren swig_calc_children, + SWIGPythonGetChildAtIndex swig_get_child_index, + SWIGPythonGetIndexOfChildWithName swig_get_index_child, + SWIGPythonCastPyObjectToSBValue swig_cast_to_sbvalue , + SWIGPythonGetValueObjectSPFromSBValue swig_get_valobj_sp_from_sbvalue, + SWIGPythonUpdateSynthProviderInstance swig_update_provider, + SWIGPythonMightHaveChildrenSynthProviderInstance swig_mighthavechildren_provider, + SWIGPythonCallCommand swig_call_command, + SWIGPythonCallModuleInit swig_call_module_init, + SWIGPythonCreateOSPlugin swig_create_os_plugin, + SWIGPythonScriptKeyword_Process swig_run_script_keyword_process, + SWIGPythonScriptKeyword_Thread swig_run_script_keyword_thread, + SWIGPythonScriptKeyword_Target swig_run_script_keyword_target, + SWIGPythonScriptKeyword_Frame swig_run_script_keyword_frame, + SWIGPython_GetDynamicSetting swig_plugin_get); protected: @@ -254,7 +284,7 @@ protected: void RestoreTerminalState (); - + private: class SynchronicityHandler @@ -282,7 +312,7 @@ private: Py_XINCREF(m_object); } - operator bool () + explicit operator bool () { return m_object && m_object != Py_None; } @@ -351,7 +381,7 @@ private: public: PythonInputReaderManager (ScriptInterpreterPython *interpreter); - operator bool() + explicit operator bool() { return m_error; } diff --git a/include/lldb/Symbol/Block.h b/include/lldb/Symbol/Block.h index a2d703b9069c..4a305e3cbbec 100644 --- a/include/lldb/Symbol/Block.h +++ b/include/lldb/Symbol/Block.h @@ -17,6 +17,7 @@ #include "lldb/Core/UserID.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/SymbolContext.h" +#include "lldb/Symbol/ClangASTType.h" namespace lldb_private { diff --git a/include/lldb/Symbol/ClangASTImporter.h b/include/lldb/Symbol/ClangASTImporter.h index 10df7da893a8..dc6ce6b5b95b 100644 --- a/include/lldb/Symbol/ClangASTImporter.h +++ b/include/lldb/Symbol/ClangASTImporter.h @@ -278,6 +278,8 @@ private: clang::Decl *Imported (clang::Decl *from, clang::Decl *to); + clang::Decl *GetOriginalDecl (clang::Decl *To); + std::set<clang::NamedDecl *> *m_decls_to_deport; std::set<clang::NamedDecl *> *m_decls_already_deported; ClangASTImporter &m_master; diff --git a/include/lldb/Symbol/ClangASTType.h b/include/lldb/Symbol/ClangASTType.h index d9e754e8ceb9..19b5d6ec6727 100644 --- a/include/lldb/Symbol/ClangASTType.h +++ b/include/lldb/Symbol/ClangASTType.h @@ -98,7 +98,7 @@ public: // Tests //---------------------------------------------------------------------- - operator bool () const + explicit operator bool () const { return m_type != NULL && m_ast != NULL; } @@ -155,6 +155,12 @@ public: bool IsFunctionType (bool *is_variadic_ptr = NULL) const; + size_t + GetNumberOfFunctionArguments () const; + + ClangASTType + GetFunctionArgumentAtIndex (const size_t index); + bool IsVariadicFunctionType () const; @@ -195,6 +201,9 @@ public: IsPointerToScalarType () const; bool + IsRuntimeGeneratedType () const; + + bool IsPointerType (ClangASTType *pointee_type = NULL) const; bool @@ -249,7 +258,7 @@ public: ConstString GetConstTypeName () const; - std::string + ConstString GetTypeName () const; uint32_t diff --git a/include/lldb/Symbol/ClangNamespaceDecl.h b/include/lldb/Symbol/ClangNamespaceDecl.h index d10ab2a29665..13a4c0011aff 100644 --- a/include/lldb/Symbol/ClangNamespaceDecl.h +++ b/include/lldb/Symbol/ClangNamespaceDecl.h @@ -10,6 +10,8 @@ #ifndef liblldb_ClangNamespaceDecl_h_ #define liblldb_ClangNamespaceDecl_h_ +#include <string> + #include "lldb/lldb-public.h" #include "lldb/Core/ClangForward.h" @@ -60,7 +62,7 @@ public: /// /b True this object contains a valid namespace decl, \b /// false otherwise. //------------------------------------------------------------------ - operator bool() const + explicit operator bool() const { return m_ast != NULL && m_namespace_decl != NULL; } diff --git a/include/lldb/Symbol/ObjectFile.h b/include/lldb/Symbol/ObjectFile.h index 8934c31bb988..ad500f5413b8 100644 --- a/include/lldb/Symbol/ObjectFile.h +++ b/include/lldb/Symbol/ObjectFile.h @@ -368,6 +368,34 @@ public: GetSymtab () = 0; //------------------------------------------------------------------ + /// Appends a Symbol for the specified so_addr to the symbol table. + /// + /// If verify_unique is false, the symbol table is not searched + /// to determine if a Symbol found at this address has already been + /// added to the symbol table. When verify_unique is true, this + /// method resolves the Symbol as the first match in the SymbolTable + /// and appends a Symbol only if required/found. + /// + /// @return + /// The resolved symbol or nullptr. Returns nullptr if a + /// a Symbol could not be found for the specified so_addr. + //------------------------------------------------------------------ + virtual Symbol * + ResolveSymbolForAddress(const Address &so_addr, bool verify_unique) + { + // Typically overridden to lazily add stripped symbols recoverable from + // the exception handling unwind information (i.e. without parsing + // the entire eh_frame section. + // + // The availability of LC_FUNCTION_STARTS allows ObjectFileMachO + // to efficiently add stripped symbols when the symbol table is + // first constructed. Poorer cousins are PECoff and ELF. + return nullptr; + } + + //------------------------------------------------------------------ + /// Detect if this object file has been stripped of local symbols. + //------------------------------------------------------------------ /// Detect if this object file has been stripped of local symbols. /// /// @return @@ -478,7 +506,7 @@ public: /// The address of any auxiliary tables, or an invalid address if this /// object file format does not support or contain such information. virtual lldb_private::Address - GetImageInfoAddress () { return Address(); } + GetImageInfoAddress (Target *target) { return Address(); } //------------------------------------------------------------------ /// Returns the address of the Entry Point in this object file - if @@ -612,6 +640,72 @@ public: } return 0; } + + //------------------------------------------------------------------ + /// Get the minimum OS version this object file can run on. + /// + /// Some object files have information that specifies the minimum OS + /// version that they can be used on. + /// + /// 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. + //------------------------------------------------------------------ + virtual uint32_t + GetMinimumOSVersion (uint32_t *versions, uint32_t num_versions) + { + if (versions && num_versions) + { + for (uint32_t i=0; i<num_versions; ++i) + versions[i] = UINT32_MAX; + } + return 0; + } + + //------------------------------------------------------------------ + /// Get the SDK OS version this object file was built with. + /// + /// The versions arguments and returns values are the same as the + /// GetMinimumOSVersion() + //------------------------------------------------------------------ + virtual uint32_t + GetSDKVersion (uint32_t *versions, uint32_t num_versions) + { + if (versions && num_versions) + { + for (uint32_t i=0; i<num_versions; ++i) + versions[i] = UINT32_MAX; + } + return 0; + } //------------------------------------------------------------------ // Member Functions diff --git a/include/lldb/Symbol/Symbol.h b/include/lldb/Symbol/Symbol.h index 11c1cc7af9ab..75e0900ab640 100644 --- a/include/lldb/Symbol/Symbol.h +++ b/include/lldb/Symbol/Symbol.h @@ -122,6 +122,21 @@ public: return m_mangled; } + ConstString + GetReExportedSymbolName() const; + + FileSpec + GetReExportedSymbolSharedLibrary () const; + + bool + SetReExportedSymbolName(const ConstString &name); + + bool + SetReExportedSymbolSharedLibrary (const FileSpec &fspec); + + Symbol * + ResolveReExportedSymbol (Target &target); + uint32_t GetSiblingIndex () const; @@ -238,24 +253,6 @@ public: m_size_is_sibling = b; } -// void -// SetValue (Address &value) -// { -// m_addr_range.GetBaseAddress() = value; -// } -// -// void -// SetValue (const AddressRange &range) -// { -// m_addr_range = range; -// } -// -// void -// SetValue (lldb::addr_t value); -// { -// m_addr_range.GetBaseAddress().SetRawAddress(value); -// } - // If m_type is "Code" or "Function" then this will return the prologue size // in bytes, else it will return zero. uint32_t diff --git a/include/lldb/Symbol/SymbolContext.h b/include/lldb/Symbol/SymbolContext.h index 5b12adebf5f5..a0501440f18c 100644 --- a/include/lldb/Symbol/SymbolContext.h +++ b/include/lldb/Symbol/SymbolContext.h @@ -16,7 +16,6 @@ #include "lldb/lldb-private.h" #include "lldb/Core/Address.h" #include "lldb/Core/Mangled.h" -#include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/LineEntry.h" namespace lldb_private { diff --git a/include/lldb/Symbol/Symtab.h b/include/lldb/Symbol/Symtab.h index 666c3b5686b9..5dfb1c822d51 100644 --- a/include/lldb/Symbol/Symtab.h +++ b/include/lldb/Symbol/Symtab.h @@ -95,6 +95,10 @@ public: bool add_mangled, NameToIndexMap &name_to_index_map) const; + ObjectFile * GetObjectFile() + { + return m_objfile; + } protected: typedef std::vector<Symbol> collection; typedef collection::iterator iterator; diff --git a/include/lldb/Symbol/Type.h b/include/lldb/Symbol/Type.h index 50b22fe96b9d..920f571fa1e9 100644 --- a/include/lldb/Symbol/Type.h +++ b/include/lldb/Symbol/Type.h @@ -304,147 +304,236 @@ protected: ResolveClangType (ResolveState clang_type_resolve_state); }; +// these classes are used to back the SBType* objects -/// -/// Sometimes you can find the name of the type corresponding to an object, but we don't have debug -/// information for it. If that is the case, you can return one of these objects, and then if it -/// has a full type, you can use that, but if not at least you can print the name for informational -/// purposes. -/// - -class TypeAndOrName -{ -public: - TypeAndOrName (); - TypeAndOrName (lldb::TypeSP &type_sp); - TypeAndOrName (const char *type_str); - TypeAndOrName (const TypeAndOrName &rhs); - TypeAndOrName (ConstString &type_const_string); +class TypePair { +private: + ClangASTType clang_type; + lldb::TypeSP type_sp; - TypeAndOrName & - operator= (const TypeAndOrName &rhs); +public: + TypePair () : clang_type(), type_sp() {} + TypePair (ClangASTType type) : + clang_type(type), + type_sp() + { + } - bool - operator==(const TypeAndOrName &other) const; + TypePair (lldb::TypeSP type) : + clang_type(), + type_sp(type) + { + clang_type = type_sp->GetClangForwardType(); + } bool - operator!=(const TypeAndOrName &other) const; - - ConstString GetName () const; - - lldb::TypeSP - GetTypeSP () const + IsValid () const { - return m_type_sp; + return clang_type.IsValid() || (type_sp.get() != nullptr); } - void - SetName (const ConstString &type_name); - - void - SetName (const char *type_name_cstr); - - void - SetTypeSP (lldb::TypeSP type_sp); - - bool - IsEmpty (); + explicit operator bool () const + { + return IsValid(); + } bool - HasName (); + operator == (const TypePair& rhs) const + { + return clang_type == rhs.clang_type && + type_sp.get() == rhs.type_sp.get(); + } bool - HasTypeSP (); + operator != (const TypePair& rhs) const + { + return clang_type != rhs.clang_type || + type_sp.get() != rhs.type_sp.get(); + } void - Clear (); + Clear () + { + clang_type.Clear(); + type_sp.reset(); + } - operator - bool () + ConstString + GetName () const { - return !IsEmpty(); + if (type_sp) + return type_sp->GetName(); + if (clang_type) + return clang_type.GetTypeName(); + return ConstString (); } -private: - lldb::TypeSP m_type_sp; - ConstString m_type_name; -}; - -// the two classes here are used by the public API as a backend to -// the SBType and SBTypeList classes + void + SetType (ClangASTType type) + { + type_sp.reset(); + clang_type = type; + } -class TypeImpl -{ -public: + void + SetType (lldb::TypeSP type) + { + type_sp = type; + clang_type = type_sp->GetClangForwardType(); + } - TypeImpl() : - m_clang_ast_type(), - m_type_sp() + lldb::TypeSP + GetTypeSP () const { + return type_sp; } - TypeImpl(const TypeImpl& rhs) : - m_clang_ast_type(rhs.m_clang_ast_type), - m_type_sp(rhs.m_type_sp) + ClangASTType + GetClangASTType () const { + return clang_type; } - TypeImpl(const lldb_private::ClangASTType& type); + ClangASTType + GetPointerType () const + { + if (type_sp) + return type_sp->GetClangLayoutType().GetPointerType(); + return clang_type.GetPointerType(); + } - TypeImpl(const lldb::TypeSP& type); + ClangASTType + GetPointeeType () const + { + if (type_sp) + return type_sp->GetClangFullType().GetPointeeType(); + return clang_type.GetPointeeType(); + } - TypeImpl& - operator = (const TypeImpl& rhs); + ClangASTType + GetReferenceType () const + { + if (type_sp) + return type_sp->GetClangLayoutType().GetLValueReferenceType(); + return clang_type.GetLValueReferenceType(); + } - bool - operator == (const TypeImpl& rhs) + ClangASTType + GetDereferencedType () const { - return m_clang_ast_type == rhs.m_clang_ast_type && m_type_sp.get() == rhs.m_type_sp.get(); + if (type_sp) + return type_sp->GetClangFullType().GetNonReferenceType(); + return clang_type.GetNonReferenceType(); } - - bool - operator != (const TypeImpl& rhs) + + ClangASTType + GetUnqualifiedType () const { - return m_clang_ast_type != rhs.m_clang_ast_type || m_type_sp.get() != rhs.m_type_sp.get(); + if (type_sp) + return type_sp->GetClangLayoutType().GetFullyUnqualifiedType(); + return clang_type.GetFullyUnqualifiedType(); } - bool - IsValid() + ClangASTType + GetCanonicalType () const { - return m_type_sp.get() != NULL || m_clang_ast_type.IsValid(); + if (type_sp) + return type_sp->GetClangFullType().GetCanonicalType(); + return clang_type.GetCanonicalType(); } - const lldb_private::ClangASTType & - GetClangASTType() const + clang::ASTContext * + GetClangASTContext () const { - return m_clang_ast_type; + return clang_type.GetASTContext(); } +}; - clang::ASTContext* - GetASTContext(); +class TypeImpl +{ +public: + + TypeImpl(); + + ~TypeImpl () {} + + TypeImpl(const TypeImpl& rhs); + + TypeImpl (lldb::TypeSP type_sp); + + TypeImpl (ClangASTType clang_type); - lldb::clang_type_t - GetOpaqueQualType(); + TypeImpl (lldb::TypeSP type_sp, ClangASTType dynamic); + + TypeImpl (ClangASTType clang_type, ClangASTType dynamic); + + TypeImpl (TypePair pair, ClangASTType dynamic); - lldb::TypeSP - GetTypeSP () - { - return m_type_sp; - } + void + SetType (lldb::TypeSP type_sp); + + void + SetType (ClangASTType clang_type); + + void + SetType (lldb::TypeSP type_sp, ClangASTType dynamic); + + void + SetType (ClangASTType clang_type, ClangASTType dynamic); + + void + SetType (TypePair pair, ClangASTType dynamic); + + TypeImpl& + operator = (const TypeImpl& rhs); + + bool + operator == (const TypeImpl& rhs) const; + + bool + operator != (const TypeImpl& rhs) const; + + bool + IsValid() const; + + explicit operator bool () const; + + void Clear(); ConstString - GetName (); - + GetName () const; + + TypeImpl + GetPointerType () const; + + TypeImpl + GetPointeeType () const; + + TypeImpl + GetReferenceType () const; + + TypeImpl + GetDereferencedType () const; + + TypeImpl + GetUnqualifiedType() const; + + TypeImpl + GetCanonicalType() const; + + ClangASTType + GetClangASTType (bool prefer_dynamic); + + clang::ASTContext * + GetClangASTContext (bool prefer_dynamic); + bool GetDescription (lldb_private::Stream &strm, lldb::DescriptionLevel description_level); - void - SetType (const lldb::TypeSP &type_sp); - private: - ClangASTType m_clang_ast_type; - lldb::TypeSP m_type_sp; + TypePair m_static_type; + ClangASTType m_dynamic_type; }; class TypeListImpl @@ -590,6 +679,89 @@ protected: }; +/// +/// Sometimes you can find the name of the type corresponding to an object, but we don't have debug +/// information for it. If that is the case, you can return one of these objects, and then if it +/// has a full type, you can use that, but if not at least you can print the name for informational +/// purposes. +/// + +class TypeAndOrName +{ +public: + TypeAndOrName (); + TypeAndOrName (lldb::TypeSP &type_sp); + TypeAndOrName (const ClangASTType &clang_type); + TypeAndOrName (const char *type_str); + TypeAndOrName (const TypeAndOrName &rhs); + TypeAndOrName (ConstString &type_const_string); + + TypeAndOrName & + operator= (const TypeAndOrName &rhs); + + bool + operator==(const TypeAndOrName &other) const; + + bool + operator!=(const TypeAndOrName &other) const; + + ConstString GetName () const; + + lldb::TypeSP + GetTypeSP () const + { + return m_type_pair.GetTypeSP(); + } + + ClangASTType + GetClangASTType () const + { + return m_type_pair.GetClangASTType(); + } + + void + SetName (const ConstString &type_name); + + void + SetName (const char *type_name_cstr); + + void + SetTypeSP (lldb::TypeSP type_sp); + + void + SetClangASTType (ClangASTType clang_type); + + bool + IsEmpty () const; + + bool + HasName () const; + + bool + HasTypeSP () const; + + bool + HasClangASTType () const; + + bool + HasType () const + { + return HasTypeSP() || HasClangASTType(); + } + + void + Clear (); + + explicit operator bool () + { + return !IsEmpty(); + } + +private: + TypePair m_type_pair; + ConstString m_type_name; +}; + } // namespace lldb_private #endif // liblldb_Type_h_ diff --git a/include/lldb/Symbol/TypeList.h b/include/lldb/Symbol/TypeList.h index 9c74db6bf1f4..be7d35482da0 100644 --- a/include/lldb/Symbol/TypeList.h +++ b/include/lldb/Symbol/TypeList.h @@ -13,6 +13,7 @@ #include "lldb/lldb-private.h" #include "lldb/Symbol/Type.h" #include <map> +#include <functional> namespace lldb_private { diff --git a/include/lldb/Target/DynamicLoader.h b/include/lldb/Target/DynamicLoader.h index 6b76e5891ae8..272f64f33113 100644 --- a/include/lldb/Target/DynamicLoader.h +++ b/include/lldb/Target/DynamicLoader.h @@ -224,6 +224,26 @@ public: return false; } + //------------------------------------------------------------------ + /// Retrieves the per-module TLS block for a given thread. + /// + /// @param[in] module + /// The module to query TLS data for. + /// + /// @param[in] thread + /// The specific thread to query TLS data for. + /// + /// @return + /// If the given thread has TLS data allocated for the + /// module, the address of the TLS block. Otherwise + /// LLDB_INVALID_ADDRESS is returned. + //------------------------------------------------------------------ + virtual lldb::addr_t + GetThreadLocalData (const lldb::ModuleSP module, const lldb::ThreadSP thread) + { + return LLDB_INVALID_ADDRESS; + } + protected: //------------------------------------------------------------------ // Member variables. diff --git a/include/lldb/Target/ExecutionContext.h b/include/lldb/Target/ExecutionContext.h index de5fe14934a7..4038e70b0c56 100644 --- a/include/lldb/Target/ExecutionContext.h +++ b/include/lldb/Target/ExecutionContext.h @@ -461,6 +461,9 @@ public: uint32_t GetAddressByteSize() const; + + lldb::ByteOrder + GetByteOrder() const; //------------------------------------------------------------------ /// Returns a pointer to the target object. diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h index b0a07946e74e..93cd67d66659 100644 --- a/include/lldb/Target/Platform.h +++ b/include/lldb/Target/Platform.h @@ -22,6 +22,7 @@ #include "lldb/Core/ArchSpec.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/PluginInterface.h" +#include "lldb/Interpreter/Options.h" #include "lldb/Host/Mutex.h" namespace lldb_private { @@ -459,6 +460,15 @@ namespace lldb_private { virtual lldb::BreakpointSP SetThreadCreationBreakpoint (Target &target); + //------------------------------------------------------------------ + // Given a target, find the local SDK directory if one exists on the + // current host. + //------------------------------------------------------------------ + virtual lldb_private::ConstString + GetSDKDirectory (lldb_private::Target &target) + { + return lldb_private::ConstString(); + } const std::string & GetRemoteURL () const @@ -542,9 +552,249 @@ namespace lldb_private { return false; } + virtual uint32_t + MakeDirectory (const std::string &path, + mode_t mode) + { + return UINT32_MAX; + } + + // this need not be virtual: the core behavior is in + // MakeDirectory(std::string,mode_t) + uint32_t + MakeDirectory (const FileSpec &spec, + mode_t mode); + + virtual lldb::user_id_t + OpenFile (const FileSpec& file_spec, + uint32_t flags, + mode_t mode, + Error &error) + { + return UINT64_MAX; + } + + virtual bool + CloseFile (lldb::user_id_t fd, + Error &error) + { + return false; + } + + virtual lldb::user_id_t + GetFileSize (const FileSpec& file_spec) + { + return UINT64_MAX; + } + + virtual uint64_t + ReadFile (lldb::user_id_t fd, + uint64_t offset, + void *dst, + uint64_t dst_len, + Error &error) + { + error.SetErrorStringWithFormat ("Platform::ReadFile() is not supported in the %s platform", GetName().GetCString()); + return -1; + } + + virtual uint64_t + WriteFile (lldb::user_id_t fd, + uint64_t offset, + const void* src, + uint64_t src_len, + Error &error) + { + error.SetErrorStringWithFormat ("Platform::ReadFile() is not supported in the %s platform", GetName().GetCString()); + return -1; + } + + virtual Error + PutFile (const FileSpec& source, + const FileSpec& destination, + uint32_t uid = UINT32_MAX, + uint32_t gid = UINT32_MAX); + virtual size_t GetEnvironment (StringList &environment); + virtual Error + GetFile (const FileSpec& source, + const FileSpec& destination); + + virtual bool + GetFileExists (const lldb_private::FileSpec& file_spec); + + virtual uint32_t + GetFilePermissions (const lldb_private::FileSpec &file_spec, + Error &error) + { + error.SetErrorStringWithFormat ("Platform::GetFilePermissions() is not supported in the %s platform", GetName().GetCString()); + return 0; + } + + virtual bool + GetSupportsRSync () + { + return m_supports_rsync; + } + + virtual void + SetSupportsRSync(bool flag) + { + m_supports_rsync = flag; + } + + virtual const char* + GetRSyncOpts () + { + return m_rsync_opts.c_str(); + } + + virtual void + SetRSyncOpts (const char* opts) + { + m_rsync_opts.assign(opts); + } + + virtual const char* + GetRSyncPrefix () + { + return m_rsync_prefix.c_str(); + } + + virtual void + SetRSyncPrefix (const char* prefix) + { + m_rsync_prefix.assign(prefix); + } + + virtual bool + GetSupportsSSH () + { + return m_supports_ssh; + } + + virtual void + SetSupportsSSH(bool flag) + { + m_supports_ssh = flag; + } + + virtual const char* + GetSSHOpts () + { + return m_ssh_opts.c_str(); + } + + virtual void + SetSSHOpts (const char* opts) + { + m_ssh_opts.assign(opts); + } + + virtual bool + GetIgnoresRemoteHostname () + { + return m_ignores_remote_hostname; + } + + virtual void + SetIgnoresRemoteHostname(bool flag) + { + m_ignores_remote_hostname = flag; + } + + virtual lldb_private::OptionGroupOptions * + GetConnectionOptions (CommandInterpreter& interpreter) + { + return NULL; + } + + virtual lldb_private::Error + RunShellCommand (const char *command, // Shouldn't be NULL + const char *working_dir, // Pass NULL to use the current working directory + int *status_ptr, // Pass NULL if you don't want the process exit status + int *signo_ptr, // Pass NULL if you don't want the signal that caused the process to exit + std::string *command_output, // Pass NULL if you don't want the command output + uint32_t timeout_sec); // Timeout in seconds to wait for shell program to finish + + virtual void + SetLocalCacheDirectory (const char* local); + + virtual const char* + GetLocalCacheDirectory (); + + virtual std::string + GetPlatformSpecificConnectionInformation() + { + return ""; + } + + virtual bool + CalculateMD5 (const FileSpec& file_spec, + uint64_t &low, + uint64_t &high); + + virtual int32_t + GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info) + { + return 1; + } + + //------------------------------------------------------------------ + /// Locate a queue name given a thread's qaddr + /// + /// On a system using libdispatch ("Grand Central Dispatch") style + /// queues, a thread may be associated with a GCD queue or not, + /// and a queue may be associated with multiple threads. + /// The process/thread must provide a way to find the "dispatch_qaddr" + /// for each thread, and from that dispatch_qaddr this Platform method + /// will locate the queue name and provide that. + /// + /// @param[in] process + /// A process is required for reading memory. + /// + /// @param[in] dispatch_qaddr + /// The dispatch_qaddr for this thread. + /// + /// @return + /// The name of the queue, if there is one. An empty string + /// means that this thread is not associated with a dispatch + /// queue. + //------------------------------------------------------------------ + virtual std::string + GetQueueNameForThreadQAddress (Process *process, lldb::addr_t dispatch_qaddr) + { + return ""; + } + + //------------------------------------------------------------------ + /// Locate a queue ID given a thread's qaddr + /// + /// On a system using libdispatch ("Grand Central Dispatch") style + /// queues, a thread may be associated with a GCD queue or not, + /// and a queue may be associated with multiple threads. + /// The process/thread must provide a way to find the "dispatch_qaddr" + /// for each thread, and from that dispatch_qaddr this Platform method + /// will locate the queue ID and provide that. + /// + /// @param[in] process + /// A process is required for reading memory. + /// + /// @param[in] dispatch_qaddr + /// The dispatch_qaddr for this thread. + /// + /// @return + /// The queue_id for this thread, if this thread is associated + /// with a dispatch queue. Else LLDB_INVALID_QUEUE_ID is returned. + //------------------------------------------------------------------ + virtual lldb::queue_id_t + GetQueueIDForThreadQAddress (Process *process, lldb::addr_t dispatch_qaddr) + { + return LLDB_INVALID_QUEUE_ID; + } + protected: bool m_is_host; // Set to true when we are able to actually set the OS version while @@ -569,7 +819,14 @@ namespace lldb_private { IDToNameMap m_gid_map; size_t m_max_uid_name_len; size_t m_max_gid_name_len; - + bool m_supports_rsync; + std::string m_rsync_opts; + std::string m_rsync_prefix; + bool m_supports_ssh; + std::string m_ssh_opts; + bool m_ignores_remote_hostname; + std::string m_local_cache_directory; + const char * GetCachedUserName (uint32_t uid) { @@ -750,6 +1007,110 @@ namespace lldb_private { private: DISALLOW_COPY_AND_ASSIGN (PlatformList); }; + + class OptionGroupPlatformRSync : public lldb_private::OptionGroup + { + public: + OptionGroupPlatformRSync (); + + virtual + ~OptionGroupPlatformRSync (); + + virtual lldb_private::Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value); + + void + OptionParsingStarting (CommandInterpreter &interpreter); + + const lldb_private::OptionDefinition* + GetDefinitions (); + + virtual uint32_t + GetNumDefinitions (); + + // Options table: Required for subclasses of Options. + + static lldb_private::OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + + bool m_rsync; + std::string m_rsync_opts; + std::string m_rsync_prefix; + bool m_ignores_remote_hostname; + private: + DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformRSync); + }; + + class OptionGroupPlatformSSH : public lldb_private::OptionGroup + { + public: + OptionGroupPlatformSSH (); + + virtual + ~OptionGroupPlatformSSH (); + + virtual lldb_private::Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value); + + void + OptionParsingStarting (CommandInterpreter &interpreter); + + virtual uint32_t + GetNumDefinitions (); + + const lldb_private::OptionDefinition* + GetDefinitions (); + + // Options table: Required for subclasses of Options. + + static lldb_private::OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + + bool m_ssh; + std::string m_ssh_opts; + private: + DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformSSH); + }; + + class OptionGroupPlatformCaching : public lldb_private::OptionGroup + { + public: + OptionGroupPlatformCaching (); + + virtual + ~OptionGroupPlatformCaching (); + + virtual lldb_private::Error + SetOptionValue (CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value); + + void + OptionParsingStarting (CommandInterpreter &interpreter); + + virtual uint32_t + GetNumDefinitions (); + + const lldb_private::OptionDefinition* + GetDefinitions (); + + // Options table: Required for subclasses of Options. + + static lldb_private::OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + + std::string m_cache_dir; + private: + DISALLOW_COPY_AND_ASSIGN(OptionGroupPlatformCaching); + }; + } // namespace lldb_private #endif // liblldb_Platform_h_ diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h index ef89a1eb1418..aa7b5edc5af1 100644 --- a/include/lldb/Target/Process.h +++ b/include/lldb/Target/Process.h @@ -10,9 +10,10 @@ #ifndef liblldb_Process_h_ #define liblldb_Process_h_ +#include "lldb/Host/Config.h" + // C Includes #include <limits.h> -#include <spawn.h> // C++ Includes #include <list> @@ -239,6 +240,12 @@ public: return m_arch; } + void + SetArchitecture (ArchSpec arch) + { + m_arch = arch; + } + lldb::pid_t GetProcessID () const { @@ -475,11 +482,13 @@ public: bool Open (int fd, const char *path, bool read, bool write); +#ifndef LLDB_DISABLE_POSIX static bool - AddPosixSpawnFileAction (posix_spawn_file_actions_t *file_actions, + AddPosixSpawnFileAction (void *file_actions, const FileAction *info, Log *log, Error& error); +#endif int GetFD () const @@ -777,7 +786,8 @@ public: ConvertArgumentsForLaunchingInShell (Error &error, bool localhost, bool will_debug, - bool first_arg_is_full_shell_command); + bool first_arg_is_full_shell_command, + int32_t num_resumes); void SetMonitorProcessCallback (Host::MonitorChildProcessCallback callback, @@ -1358,9 +1368,7 @@ class Process : { friend class ThreadList; friend class ClangFunction; // For WaitForStateChangeEventsPrivate -friend class CommandObjectProcessLaunch; friend class ProcessEventData; -friend class CommandObjectBreakpointCommand; friend class StopInfo; public: @@ -1749,7 +1757,7 @@ public: error.SetErrorStringWithFormat("error: %s does not support loading core files.", GetPluginName().GetCString()); return error; } - + //------------------------------------------------------------------ /// Get the dynamic loader plug-in for this process. /// @@ -1763,6 +1771,16 @@ public: GetDynamicLoader (); //------------------------------------------------------------------ + /// Get the system runtime plug-in for this process. + /// + /// @return + /// Returns a pointer to the SystemRuntime plugin for this Process + /// if one is available. Else returns NULL. + //------------------------------------------------------------------ + virtual SystemRuntime * + GetSystemRuntime (); + + //------------------------------------------------------------------ /// Attach to an existing process using the process attach info. /// /// This function is not meant to be overridden by Process @@ -3308,8 +3326,11 @@ public: lldb::StateType GetNextEvent (lldb::EventSP &event_sp); + // Returns the process state when it is stopped. If specified, event_sp_ptr + // is set to the event which triggered the stop. If wait_always = false, + // and the process is already stopped, this function returns immediately. lldb::StateType - WaitForProcessToStop (const TimeValue *timeout, lldb::EventSP *event_sp_ptr = NULL); + WaitForProcessToStop (const TimeValue *timeout, lldb::EventSP *event_sp_ptr = NULL, bool wait_always = true); lldb::StateType WaitForStateChangedEvents (const TimeValue *timeout, lldb::EventSP &event_sp); @@ -3656,6 +3677,7 @@ protected: std::unique_ptr<DynamicLoader> m_dyld_ap; std::unique_ptr<DynamicCheckerFunctions> m_dynamic_checkers_ap; ///< The functions used by the expression parser to validate data that expressions use. std::unique_ptr<OperatingSystem> m_os_ap; + std::unique_ptr<SystemRuntime> m_system_runtime_ap; UnixSignals m_unix_signals; /// This is the current signal set for this process. lldb::ABISP m_abi_sp; lldb::InputReaderSP m_process_input_reader; @@ -3711,10 +3733,10 @@ protected: void ResumePrivateStateThread (); - static void * + static lldb::thread_result_t PrivateStateThread (void *arg); - void * + lldb::thread_result_t RunPrivateStateThread (); void diff --git a/include/lldb/Target/RegisterContext.h b/include/lldb/Target/RegisterContext.h index dd0e73fc7eb3..7da462700110 100644 --- a/include/lldb/Target/RegisterContext.h +++ b/include/lldb/Target/RegisterContext.h @@ -123,12 +123,17 @@ public: const RegisterInfo * GetRegisterInfoByName (const char *reg_name, uint32_t start_idx = 0); + const RegisterInfo * + GetRegisterInfo (uint32_t reg_kind, uint32_t reg_num); + uint64_t GetPC (uint64_t fail_value = LLDB_INVALID_ADDRESS); bool SetPC (uint64_t pc); + bool SetPC (Address addr); + uint64_t GetSP (uint64_t fail_value = LLDB_INVALID_ADDRESS); diff --git a/include/lldb/Target/StackFrame.h b/include/lldb/Target/StackFrame.h index 877bd8ce661b..e7b57cd26ac9 100644 --- a/include/lldb/Target/StackFrame.h +++ b/include/lldb/Target/StackFrame.h @@ -26,9 +26,21 @@ namespace lldb_private { +/// @class StackFrame StackFrame.h "lldb/Target/StackFrame.h" +/// +/// @brief This base class provides an interface to stack frames. +/// +/// StackFrames may have a Canonical Frame Address (CFA) or not. +/// A frame may have a plain pc value or it may have a pc value + stop_id +/// to indicate a specific point in the debug session so the correct section +/// load list is used for symbolication. +/// +/// Local variables may be available, or not. A register context may be +/// available, or not. + class StackFrame : - public std::enable_shared_from_this<StackFrame>, - public ExecutionContextScope + public ExecutionContextScope, + public std::enable_shared_from_this<StackFrame> { public: enum ExpressionPathOption @@ -39,14 +51,72 @@ public: eExpressionPathOptionsNoSyntheticArrayRange = (1u << 3), eExpressionPathOptionsAllowDirectIVarAccess = (1u << 4) }; + //------------------------------------------------------------------ - // Constructors and Destructors + /// Construct a StackFrame object without supplying a RegisterContextSP. + /// + /// This is the one constructor that doesn't take a RegisterContext + /// parameter. This ctor may be called when creating a history StackFrame; + /// these are used if we've collected a stack trace of pc addresses at + /// some point in the past. We may only have pc values. We may have pc + /// values and the stop_id when the stack trace was recorded. We may have a + /// CFA, or more likely, we won't. + /// + /// @param [in] thread_sp + /// The Thread that this frame belongs to. + /// + /// @param [in] frame_idx + /// This StackFrame's frame index number in the Thread. If inlined stack + /// frames are being created, this may differ from the concrete_frame_idx + /// which is the frame index without any inlined stack frames. + /// + /// @param [in] concrete_frame_idx + /// The StackFrame's frame index number in the Thread without any inlined + /// stack frames being included in the index. + /// + /// @param [in] cfa + /// The Canonical Frame Address (this terminology from DWARF) for this + /// stack frame. The CFA for a stack frame does not change over the + /// span of the stack frame's existence. It is often the value of the + /// caller's stack pointer before the call instruction into this frame's + /// function. It is usually not the same as the frame pointer register's + /// value. + /// + /// @param [in] cfa_is_valid + /// A history stack frame may not have a CFA value collected. We want to + /// distinguish between "no CFA available" and a CFA of + /// LLDB_INVALID_ADDRESS. + /// + /// @param [in] pc + /// The current pc value of this stack frame. + /// + /// @param [in] stop_id + /// The stop_id which should be used when looking up symbols for the pc value, + /// if appropriate. This argument is ignored if stop_id_is_valid is false. + /// + /// @param [in] stop_id_is_valid + /// If the stop_id argument provided is not needed for this StackFrame, this + /// should be false. If this is a history stack frame and we know the stop_id + /// when the pc value was collected, that stop_id should be provided and this + /// will be true. + /// + /// @param [in] is_history_frame + /// If this is a historical stack frame -- possibly without CFA or registers or + /// local variables -- then this should be set to true. + /// + /// @param [in] sc_ptr + /// Optionally seed the StackFrame with the SymbolContext information that has + /// already been discovered. //------------------------------------------------------------------ StackFrame (const lldb::ThreadSP &thread_sp, lldb::user_id_t frame_idx, lldb::user_id_t concrete_frame_idx, lldb::addr_t cfa, + bool cfa_is_valid, lldb::addr_t pc, + uint32_t stop_id, + bool stop_id_is_valid, + bool is_history_frame, const SymbolContext *sc_ptr); StackFrame (const lldb::ThreadSP &thread_sp, @@ -76,21 +146,103 @@ public: StackID& GetStackID(); + //------------------------------------------------------------------ + /// Get an Address for the current pc value in this StackFrame. + /// + /// May not be the same as the actual PC value for inlined stack frames. + /// + /// @return + /// The Address object set to the current PC value. + //------------------------------------------------------------------ const Address& GetFrameCodeAddress(); - - void + + //------------------------------------------------------------------ + /// Change the pc value for a given thread. + /// + /// Change the current pc value for the frame on this thread. + /// + /// @param[in] pc + /// The load address that the pc will be set to. + /// + /// @return + /// true if the pc was changed. false if this failed -- possibly + /// because this frame is not a live StackFrame. + //------------------------------------------------------------------ + bool ChangePC (lldb::addr_t pc); + //------------------------------------------------------------------ + /// Provide a SymbolContext for this StackFrame's current pc value. + /// + /// The StackFrame maintains this SymbolContext and adds additional information + /// to it on an as-needed basis. This helps to avoid different functions + /// looking up symbolic information for a given pc value multple times. + /// + /// @params [in] resolve_scope + /// Flags from the SymbolContextItem enumerated type which specify what + /// type of symbol context is needed by this caller. + /// + /// @return + /// A SymbolContext reference which includes the types of information + /// requested by resolve_scope, if they are available. + //------------------------------------------------------------------ const SymbolContext& GetSymbolContext (uint32_t resolve_scope); + //------------------------------------------------------------------ + /// Return the Canonical Frame Address (DWARF term) for this frame. + /// + /// The CFA is typically the value of the stack pointer register before + /// the call invocation is made. It will not change during the lifetime + /// of a stack frame. It is often not the same thing as the frame pointer + /// register value. + /// + /// Live StackFrames will always have a CFA but other types of frames may + /// not be able to supply one. + /// + /// @param [out] value + /// The address of the CFA for this frame, if available. + /// + /// @param [out] error_ptr + /// If there is an error determining the CFA address, this may contain a + /// string explaining the failure. + /// + /// @return + /// Returns true if the CFA value was successfully set in value. Some + /// frames may be unable to provide this value; they will return false. + //------------------------------------------------------------------ bool GetFrameBaseValue(Scalar &value, Error *error_ptr); + //------------------------------------------------------------------ + /// Get the current lexical scope block for this StackFrame, if possible. + /// + /// If debug information is available for this stack frame, return a + /// pointer to the innermost lexical Block that the frame is currently + /// executing. + /// + /// @return + /// A pointer to the current Block. NULL is returned if this can + /// not be provided. + //------------------------------------------------------------------ Block * GetFrameBlock (); + //------------------------------------------------------------------ + /// Get the RegisterContext for this frame, if possible. + /// + /// Returns a shared pointer to the RegisterContext for this stack frame. + /// Only a live StackFrame object will be able to return a RegisterContext - + /// callers must be prepared for an empty shared pointer being returned. + /// + /// Even a live StackFrame RegisterContext may not be able to provide all + /// registers. Only the currently executing frame (frame 0) can reliably + /// provide every register in the register context. + /// + /// @return + /// The RegisterContext shared point for this frame. + //------------------------------------------------------------------ lldb::RegisterContextSP GetRegisterContext (); @@ -100,73 +252,237 @@ public: return m_reg_context_sp; } + //------------------------------------------------------------------ + /// Retrieve the list of variables that are in scope at this StackFrame's pc. + /// + /// A frame that is not live may return an empty VariableList for a given + /// pc value even though variables would be available at this point if + /// it were a live stack frame. + /// + /// @param[in] get_file_globals + /// Whether to also retrieve compilation-unit scoped variables + /// that are visisble to the entire compilation unit (e.g. file + /// static in C, globals that are homed in this CU). + /// + /// @return + /// A pointer to a list of variables. + //------------------------------------------------------------------ VariableList * GetVariableList (bool get_file_globals); + //------------------------------------------------------------------ + /// Retrieve the list of variables that are in scope at this StackFrame's pc. + /// + /// A frame that is not live may return an empty VariableListSP for a + /// given pc value even though variables would be available at this point + /// if it were a live stack frame. + /// + /// @param[in] get_file_globals + /// Whether to also retrieve compilation-unit scoped variables + /// that are visisble to the entire compilation unit (e.g. file + /// static in C, globals that are homed in this CU). + /// + /// @return + /// A pointer to a list of variables. + //------------------------------------------------------------------ lldb::VariableListSP GetInScopeVariableList (bool get_file_globals); - // See ExpressionPathOption enumeration for "options" values + //------------------------------------------------------------------ + /// Create a ValueObject for a variable name / pathname, possibly + /// including simple dereference/child selection syntax. + /// + /// @param[in] var_expr + /// The string specifying a variable to base the VariableObject off + /// of. + /// + /// @param[in] use_dynamic + /// Whether the correct dynamic type of an object pointer should be + /// determined before creating the object, or if the static type is + /// sufficient. One of the DynamicValueType enumerated values. + /// + /// @param[in] options + /// An unsigned integer of flags, values from StackFrame::ExpressionPathOption + /// enum. + /// @param[in] var_sp + /// A VariableSP that will be set to the variable described in the + /// var_expr path. + /// + /// @param[in] error + /// Record any errors encountered while evaluating var_expr. + /// + /// @return + /// A shared pointer to the ValueObject described by var_expr. + //------------------------------------------------------------------ lldb::ValueObjectSP - GetValueForVariableExpressionPath (const char *var_expr, - lldb::DynamicValueType use_dynamic, + GetValueForVariableExpressionPath (const char *var_expr, + lldb::DynamicValueType use_dynamic, uint32_t options, lldb::VariableSP &var_sp, Error &error); + //------------------------------------------------------------------ + /// Determine whether this StackFrame has debug information available or not + /// + /// @return + // true if debug information is available for this frame (function, + // compilation unit, block, etc.) + //------------------------------------------------------------------ bool HasDebugInformation (); + //------------------------------------------------------------------ + /// Return the disassembly for the instructions of this StackFrame's function + /// as a single C string. + /// + /// @return + // C string with the assembly instructions for this function. + //------------------------------------------------------------------ const char * Disassemble (); + //------------------------------------------------------------------ + /// Print a description for this frame using the frame-format formatter settings. + /// + /// @param [in] strm + /// The Stream to print the description to. + /// + /// @param [in] frame_marker + /// Optional string that will be prepended to the frame output description. + //------------------------------------------------------------------ void - DumpUsingSettingsFormat (Stream *strm); - + DumpUsingSettingsFormat (Stream *strm, const char *frame_marker = NULL); + + //------------------------------------------------------------------ + /// Print a description for this frame using a default format. + /// + /// @param [in] strm + /// The Stream to print the description to. + /// + /// @param [in] show_frame_index + /// Whether to print the frame number or not. + /// + /// @param [in] show_fullpaths + /// Whether to print the full source paths or just the file base name. + //------------------------------------------------------------------ void Dump (Stream *strm, bool show_frame_index, bool show_fullpaths); - + + //------------------------------------------------------------------ + /// Print a description of this stack frame and/or the source context/assembly + /// for this stack frame. + /// + /// @param[in] strm + /// The Stream to send the output to. + /// + /// @param[in] show_frame_info + /// If true, print the frame info by calling DumpUsingSettingsFormat(). + /// + /// @param[in] show_source + /// If true, print source or disassembly as per the user's settings. + /// + /// @param[in] frame_marker + /// Passed to DumpUsingSettingsFormat() for the frame info printing. + /// + /// @return + /// Returns true if successful. + //------------------------------------------------------------------ + bool + GetStatus (Stream &strm, + bool show_frame_info, + bool show_source, + const char *frame_marker = NULL); + + //------------------------------------------------------------------ + /// Query whether this frame is a concrete frame on the call stack, + /// or if it is an inlined frame derived from the debug information + /// and presented by the debugger. + /// + /// @return + /// true if this is an inlined frame. + //------------------------------------------------------------------ bool IsInlined (); + //------------------------------------------------------------------ + /// Query this frame to find what frame it is in this Thread's StackFrameList. + /// + /// @return + /// StackFrame index 0 indicates the currently-executing function. Inline + /// frames are included in this frame index count. + //------------------------------------------------------------------ uint32_t GetFrameIndex () const; + //------------------------------------------------------------------ + /// Query this frame to find what frame it is in this Thread's StackFrameList, + /// not counting inlined frames. + /// + /// @return + /// StackFrame index 0 indicates the currently-executing function. Inline + /// frames are not included in this frame index count; their concrete + /// frame index will be the same as the concrete frame that they are + /// derived from. + //------------------------------------------------------------------ uint32_t GetConcreteFrameIndex () const { return m_concrete_frame_index; } - + + //------------------------------------------------------------------ + /// Create a ValueObject for a given Variable in this StackFrame. + /// + /// @params [in] variable_sp + /// The Variable to base this ValueObject on + /// + /// @params [in] use_dynamic + /// Whether the correct dynamic type of the variable should be + /// determined before creating the ValueObject, or if the static type + /// is sufficient. One of the DynamicValueType enumerated values. + /// + /// @return + // A ValueObject for this variable. + //------------------------------------------------------------------ lldb::ValueObjectSP GetValueObjectForFrameVariable (const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic); + //------------------------------------------------------------------ + /// Add an arbitrary Variable object (e.g. one that specifics a global or static) + /// to a StackFrame's list of ValueObjects. + /// + /// @params [in] variable_sp + /// The Variable to base this ValueObject on + /// + /// @params [in] use_dynamic + /// Whether the correct dynamic type of the variable should be + /// determined before creating the ValueObject, or if the static type + /// is sufficient. One of the DynamicValueType enumerated values. + /// + /// @return + // A ValueObject for this variable. + //------------------------------------------------------------------ lldb::ValueObjectSP TrackGlobalVariable (const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic); - + //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions //------------------------------------------------------------------ virtual lldb::TargetSP CalculateTarget (); - + virtual lldb::ProcessSP CalculateProcess (); - + virtual lldb::ThreadSP CalculateThread (); - + virtual lldb::StackFrameSP CalculateStackFrame (); - virtual void + void CalculateExecutionContext (ExecutionContext &exe_ctx); - - bool - GetStatus (Stream &strm, - bool show_frame_info, - bool show_source); - + protected: friend class StackFrameList; @@ -175,7 +491,7 @@ protected: void UpdateCurrentFrameFromPreviousFrame (StackFrame &prev_frame); - + void UpdatePreviousFrameFromCurrentFrame (StackFrame &curr_frame); @@ -196,6 +512,10 @@ private: Flags m_flags; Scalar m_frame_base; Error m_frame_base_error; + bool m_cfa_is_valid; // Does this frame have a CFA? Different from CFA == LLDB_INVALID_ADDRESS + uint32_t m_stop_id; + bool m_stop_id_is_valid; // Does this frame have a stop_id? Use it when referring to the m_frame_code_addr. + bool m_is_history_frame; lldb::VariableListSP m_variable_list_sp; ValueObjectList m_variable_list_value_objects; // Value objects for each variable in m_variable_list_sp StreamString m_disassembly; diff --git a/include/lldb/Target/StackFrameList.h b/include/lldb/Target/StackFrameList.h index b2689d0391e9..2680be3e5a68 100644 --- a/include/lldb/Target/StackFrameList.h +++ b/include/lldb/Target/StackFrameList.h @@ -88,7 +88,8 @@ public: uint32_t first_frame, uint32_t num_frames, bool show_frame_info, - uint32_t num_frames_with_source); + uint32_t num_frames_with_source, + const char *frame_marker = NULL); protected: diff --git a/include/lldb/Target/StackID.h b/include/lldb/Target/StackID.h index 7e713c73d972..75ad8ab38903 100644 --- a/include/lldb/Target/StackID.h +++ b/include/lldb/Target/StackID.h @@ -110,13 +110,18 @@ public: protected: friend class StackFrame; - + void SetPC (lldb::addr_t pc) { m_pc = pc; } + void + SetCFA (lldb::addr_t cfa) + { + m_cfa = cfa; + } //------------------------------------------------------------------ // Classes that inherit from StackID can see and modify these diff --git a/include/lldb/Target/SystemRuntime.h b/include/lldb/Target/SystemRuntime.h new file mode 100644 index 000000000000..6c0a4205d5f2 --- /dev/null +++ b/include/lldb/Target/SystemRuntime.h @@ -0,0 +1,174 @@ +//===-- SystemRuntime.h -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_SystemRuntime_h_ +#define liblldb_SystemRuntime_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include <vector> + +#include "lldb/lldb-public.h" +#include "lldb/Core/ConstString.h" +#include "lldb/Core/ModuleList.h" +#include "lldb/Core/PluginInterface.h" +#include "lldb/lldb-private.h" + + +namespace lldb_private { + +//---------------------------------------------------------------------- +/// @class SystemRuntime SystemRuntime.h "lldb/Target/SystemRuntime.h" +/// @brief A plug-in interface definition class for system runtimes. +/// +/// The system runtime plugins can collect information from the system +/// libraries during a Process' lifetime and provide information about +/// how objects/threads were originated. +/// +/// For instance, a system runtime plugin use a breakpoint when threads +/// are created to record the backtrace of where that thread was created. +/// Later, when backtracing the created thread, it could extend the backtrace +/// to show where it was originally created from. +/// +/// The plugin will insert its own breakpoint when Created and start collecting +/// information. Later when it comes time to augment a Thread, it can be +/// asked to provide that information. +/// +//---------------------------------------------------------------------- + +class SystemRuntime : + public PluginInterface +{ +public: + //------------------------------------------------------------------ + /// Find a system runtime plugin for a given process. + /// + /// Scans the installed SystemRuntime plugins and tries to find + /// an instance that can be used to track image changes in \a + /// process. + /// + /// @param[in] process + /// The process for which to try and locate a system runtime + /// plugin instance. + //------------------------------------------------------------------ + static SystemRuntime* + FindPlugin (Process *process); + + //------------------------------------------------------------------ + /// Construct with a process. + // ----------------------------------------------------------------- + SystemRuntime(lldb_private::Process *process); + + //------------------------------------------------------------------ + /// Destructor. + /// + /// The destructor is virtual since this class is designed to be + /// inherited by the plug-in instance. + //------------------------------------------------------------------ + virtual + ~SystemRuntime(); + + //------------------------------------------------------------------ + /// Called after attaching to a process. + /// + /// Allow the SystemRuntime plugin to execute some code after attaching + /// to a process. + //------------------------------------------------------------------ + virtual void + DidAttach (); + + //------------------------------------------------------------------ + /// Called after launching a process. + /// + /// Allow the SystemRuntime plugin to execute some code after launching + /// a process. + //------------------------------------------------------------------ + virtual void + DidLaunch(); + + //------------------------------------------------------------------ + /// Called when modules have been loaded in the process. + /// + /// Allow the SystemRuntime plugin to enable logging features in the + /// system runtime libraries. + //------------------------------------------------------------------ + virtual void + ModulesDidLoad(lldb_private::ModuleList &module_list); + + + //------------------------------------------------------------------ + /// Return a list of thread origin extended backtraces that may + /// be available. + /// + /// A System Runtime may be able to provide a backtrace of when this + /// thread was originally created. Furthermore, it may be able to + /// provide that extended backtrace for different styles of creation. + /// On a system with both pthreads and libdispatch, aka Grand Central + /// Dispatch, queues, the system runtime may be able to provide the + /// pthread creation of the thread and it may also be able to provide + /// the backtrace of when this GCD queue work block was enqueued. + /// The caller may request these different origins by name. + /// + /// The names will be provided in the order that they are most likely + /// to be requested. For instance, a most natural order may be to + /// request the GCD libdispatch queue origin. If there is none, then + /// request the pthread origin. + /// + /// @return + /// A vector of ConstStrings with names like "pthread" or "libdispatch". + /// An empty vector may be returned if no thread origin extended + /// backtrace capabilities are available. + //------------------------------------------------------------------ + virtual std::vector<ConstString> + GetExtendedBacktraceTypes (); + + //------------------------------------------------------------------ + /// Return a Thread which shows the origin of this thread's creation. + /// + /// This likely returns a HistoryThread which shows how thread was + /// originally created (e.g. "pthread" type), or how the work that + /// is currently executing on it was originally enqueued (e.g. + /// "libdispatch" type). + /// + /// There may be a chain of thread-origins; it may be informative to + /// the end user to query the returned ThreadSP for its origins as + /// well. + /// + /// @param [in] thread + /// The thread to examine. + /// + /// @param [in] type + /// The type of thread origin being requested. The types supported + /// are returned from SystemRuntime::GetExtendedBacktraceTypes. + /// + /// @return + /// A ThreadSP which will have a StackList of frames. This Thread will + /// not appear in the Process' list of current threads. Normal thread + /// operations like stepping will not be available. This is a historical + /// view thread and may be only useful for showing a backtrace. + /// + /// An empty ThreadSP will be returned if no thread origin is available. + //------------------------------------------------------------------ + virtual lldb::ThreadSP + GetExtendedBacktrace (lldb::ThreadSP thread, ConstString type); + +protected: + //------------------------------------------------------------------ + // Member variables. + //------------------------------------------------------------------ + Process *m_process; +private: + DISALLOW_COPY_AND_ASSIGN (SystemRuntime); +}; + +} // namespace lldb_private + +#endif // liblldb_SystemRuntime_h_ diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h index 87fa57b3a299..1c90ea6f15eb 100644 --- a/include/lldb/Target/Target.h +++ b/include/lldb/Target/Target.h @@ -184,11 +184,13 @@ public: static const uint32_t default_timeout = 500000; EvaluateExpressionOptions() : m_execution_policy(eExecutionPolicyOnlyWhenNeeded), + m_language (lldb::eLanguageTypeUnknown), m_coerce_to_id(false), m_unwind_on_error(true), m_ignore_breakpoints (false), m_keep_in_memory(false), m_run_others(true), + m_debug(false), m_use_dynamic(lldb::eNoDynamicValues), m_timeout_usec(default_timeout) {} @@ -206,6 +208,19 @@ public: return *this; } + lldb::LanguageType + GetLanguage() const + { + return m_language; + } + + EvaluateExpressionOptions& + SetLanguage(lldb::LanguageType language) + { + m_language = language; + return *this; + } + bool DoesCoerceToId () const { @@ -297,13 +312,28 @@ public: return *this; } + bool + GetDebug() const + { + return m_debug; + } + + EvaluateExpressionOptions& + SetDebug(bool b) + { + m_debug = b; + return *this; + } + private: ExecutionPolicy m_execution_policy; + lldb::LanguageType m_language; bool m_coerce_to_id; bool m_unwind_on_error; bool m_ignore_breakpoints; bool m_keep_in_memory; bool m_run_others; + bool m_debug; lldb::DynamicValueType m_use_dynamic; uint32_t m_timeout_usec; }; @@ -503,26 +533,30 @@ public: CreateBreakpoint (const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, - LazyBool check_inlines = eLazyBoolCalculate, - LazyBool skip_prologue = eLazyBoolCalculate, - bool internal = false); + LazyBool check_inlines, + LazyBool skip_prologue, + bool internal, + bool request_hardware); // Use this to create breakpoint that matches regex against the source lines in files given in source_file_list: lldb::BreakpointSP CreateSourceRegexBreakpoint (const FileSpecList *containingModules, const FileSpecList *source_file_list, RegularExpression &source_regex, - bool internal = false); + bool internal, + bool request_hardware); // Use this to create a breakpoint from a load address lldb::BreakpointSP CreateBreakpoint (lldb::addr_t load_addr, - bool internal = false); + bool internal, + bool request_hardware); // Use this to create Address breakpoints: lldb::BreakpointSP CreateBreakpoint (Address &addr, - bool internal = false); + bool internal, + bool request_hardware); // Use this to create a function breakpoint by regexp in containingModule/containingSourceFiles, or all modules if it is NULL // When "skip_prologue is set to eLazyBoolCalculate, we use the current target @@ -531,8 +565,9 @@ public: CreateFuncRegexBreakpoint (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, RegularExpression &func_regexp, - LazyBool skip_prologue = eLazyBoolCalculate, - bool internal = false); + LazyBool skip_prologue, + bool internal, + bool request_hardware); // Use this to create a function breakpoint by name in containingModule, or all modules if it is NULL // When "skip_prologue is set to eLazyBoolCalculate, we use the current target @@ -542,11 +577,12 @@ public: const FileSpecList *containingSourceFiles, const char *func_name, uint32_t func_name_type_mask, - LazyBool skip_prologue = eLazyBoolCalculate, - bool internal = false); + LazyBool skip_prologue, + bool internal, + bool request_hardware); lldb::BreakpointSP - CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal = false); + CreateExceptionBreakpoint (enum lldb::LanguageType language, bool catch_bp, bool throw_bp, bool internal); // This is the same as the func_name breakpoint except that you can specify a vector of names. This is cheaper // than a regular expression breakpoint in the case where you just want to set a breakpoint on a set of names @@ -557,23 +593,26 @@ public: const char *func_names[], size_t num_names, uint32_t func_name_type_mask, - LazyBool skip_prologue = eLazyBoolCalculate, - bool internal = false); + LazyBool skip_prologue, + bool internal, + bool request_hardware); lldb::BreakpointSP CreateBreakpoint (const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, const std::vector<std::string> &func_names, uint32_t func_name_type_mask, - LazyBool skip_prologue = eLazyBoolCalculate, - bool internal = false); + LazyBool skip_prologue, + bool internal, + bool request_hardware); // Use this to create a general breakpoint: lldb::BreakpointSP CreateBreakpoint (lldb::SearchFilterSP &filter_sp, lldb::BreakpointResolverSP &resolver_sp, - bool internal = false); + bool internal, + bool request_hardware); // Use this to create a watchpoint: lldb::WatchpointSP @@ -696,11 +735,14 @@ public: ModulesDidLoad (ModuleList &module_list); void - ModulesDidUnload (ModuleList &module_list); + ModulesDidUnload (ModuleList &module_list, bool delete_locations); void SymbolsDidLoad (ModuleList &module_list); + void + ClearModules(); + //------------------------------------------------------------------ /// Gets the module for the main executable. /// @@ -1095,21 +1137,7 @@ public: { return m_suppress_stop_hooks; } - - bool - SetSuppressSyntheticValue (bool suppress) - { - bool old_value = m_suppress_synthetic_value; - m_suppress_synthetic_value = suppress; - return old_value; - } - - bool - GetSuppressSyntheticValue () - { - return m_suppress_synthetic_value; - } - + // StopHookSP & // GetStopHookByIndex (size_t index); // diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h index e4e532e4b331..7dac37caa200 100644 --- a/include/lldb/Target/Thread.h +++ b/include/lldb/Target/Thread.h @@ -339,6 +339,12 @@ public: return NULL; } + virtual lldb::queue_id_t + GetQueueID () + { + return LLDB_INVALID_QUEUE_ID; + } + virtual const char * GetQueueName () { @@ -377,7 +383,10 @@ public: Error ReturnFromFrame (lldb::StackFrameSP frame_sp, lldb::ValueObjectSP return_value_sp, bool broadcast = false); - + + Error + JumpToLine (const FileSpec &file, uint32_t line, bool can_leave_function, std::string *warnings = NULL); + virtual lldb::StackFrameSP GetFrameWithStackID (const StackID &stack_id) { @@ -452,6 +461,33 @@ public: DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx); //------------------------------------------------------------------ + /// Retrieves the per-thread data area. + /// Most OSs maintain a per-thread pointer (e.g. the FS register on + /// x64), which we return the value of here. + /// + /// @return + /// LLDB_INVALID_ADDRESS if not supported, otherwise the thread + /// pointer value. + //------------------------------------------------------------------ + virtual lldb::addr_t + GetThreadPointer (); + + //------------------------------------------------------------------ + /// Retrieves the per-module TLS block for a thread. + /// + /// @param[in] module + /// The module to query TLS data for. + /// + /// @return + /// If the thread has TLS data allocated for the + /// module, the address of the TLS block. Otherwise + /// LLDB_INVALID_ADDRESS is returned. + //------------------------------------------------------------------ + virtual lldb::addr_t + GetThreadLocalData (const lldb::ModuleSP module); + + + //------------------------------------------------------------------ // Thread Plan Providers: // This section provides the basic thread plans that the Process control // machinery uses to run the target. ThreadPlan.h provides more details on diff --git a/include/lldb/Target/ThreadPlanCallFunction.h b/include/lldb/Target/ThreadPlanCallFunction.h index d747706c6393..7b8efb60b880 100644 --- a/include/lldb/Target/ThreadPlanCallFunction.h +++ b/include/lldb/Target/ThreadPlanCallFunction.h @@ -136,7 +136,13 @@ public: virtual bool RestoreThreadState(); - + + virtual void + ThreadDestroyed () + { + m_takedown_done = true; + } + protected: void ReportRegisterState (const char *message); diff --git a/include/lldb/Target/ThreadPlanStepOverRange.h b/include/lldb/Target/ThreadPlanStepOverRange.h index de9e66829dc7..2cb5288272ea 100644 --- a/include/lldb/Target/ThreadPlanStepOverRange.h +++ b/include/lldb/Target/ThreadPlanStepOverRange.h @@ -41,6 +41,8 @@ protected: private: + bool IsEquivalentContext(const SymbolContext &context); + bool m_first_resume; DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepOverRange); diff --git a/include/lldb/Utility/RefCounter.h b/include/lldb/Utility/RefCounter.h deleted file mode 100644 index 6daed5498eb8..000000000000 --- a/include/lldb/Utility/RefCounter.h +++ /dev/null @@ -1,56 +0,0 @@ -//===-- RefCounter.h --------------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_RefCounter_h_ -#define liblldb_RefCounter_h_ - -#include "lldb/lldb-public.h" - -namespace lldb_utility { - -//---------------------------------------------------------------------- -// A simple reference counter object. You need an uint32_t* to use it -// Once that is in place, everyone who needs to ref-count, can say -// RefCounter ref(ptr); -// (of course, the pointer is a shared resource, and must be accessible to -// everyone who needs it). Synchronization is handled by RefCounter itself -// The counter is decreased each time a RefCounter to it goes out of scope -//---------------------------------------------------------------------- -class RefCounter -{ -public: - typedef uint32_t value_type; - - RefCounter(value_type* ctr); - - ~RefCounter(); - -private: - value_type* m_counter; - DISALLOW_COPY_AND_ASSIGN (RefCounter); - - template <class T> - inline T - increment(T* t) - { - return __sync_fetch_and_add(t, 1); - } - - template <class T> - inline T - decrement(T* t) - { - return __sync_fetch_and_add(t, -1); - } - -}; - -} // namespace lldb_utility - -#endif // #ifndef liblldb_RefCounter_h_ diff --git a/include/lldb/Utility/SharingPtr.h b/include/lldb/Utility/SharingPtr.h index 814b54b5cfe6..c451ee6e3593 100644 --- a/include/lldb/Utility/SharingPtr.h +++ b/include/lldb/Utility/SharingPtr.h @@ -13,6 +13,15 @@ #include <algorithm> #include <memory> +// Microsoft Visual C++ currently does not enable std::atomic to work +// in CLR mode - as such we need to "hack around it" for MSVC++ builds only +// using Windows specific instrinsics instead of the C++11 atomic support +#ifdef _MSC_VER +#include <intrin.h> +#else +#include <atomic> +#endif + //#define ENABLE_SP_LOGGING 1 // DON'T CHECK THIS LINE IN UNLESS COMMENTED OUT #if defined (ENABLE_SP_LOGGING) @@ -24,27 +33,17 @@ namespace lldb_private { namespace imp { -template <class T> -inline T -increment(T& t) -{ - return __sync_add_and_fetch(&t, 1); -} - -template <class T> -inline T -decrement(T& t) -{ - return __sync_add_and_fetch(&t, -1); -} - class shared_count { shared_count(const shared_count&); shared_count& operator=(const shared_count&); protected: +#ifdef _MSC_VER long shared_owners_; +#else + std::atomic<long> shared_owners_; +#endif virtual ~shared_count(); private: virtual void on_zero_shared() = 0; @@ -592,14 +591,22 @@ private: void lldb_private::ReferenceCountedBase<T>::add_shared() { - imp::increment(shared_owners_); +#ifdef _MSC_VER + _InterlockedIncrement(&shared_owners_); +#else + ++shared_owners_; +#endif } template <class T> void lldb_private::ReferenceCountedBase<T>::release_shared() { - if (imp::decrement(shared_owners_) == -1) +#ifdef _MSC_VER + if (_InterlockedDecrement(&shared_owners_) == -1) +#else + if (--shared_owners_ == -1) +#endif delete static_cast<T*>(this); } @@ -713,7 +720,7 @@ public: return ptr_; } - operator bool() const + explicit operator bool() const { return ptr_ != 0; } diff --git a/include/lldb/lldb-defines.h b/include/lldb/lldb-defines.h index 3318aa15f5ac..82307d2f5310 100644 --- a/include/lldb/lldb-defines.h +++ b/include/lldb/lldb-defines.h @@ -33,6 +33,7 @@ // LLDB defines //---------------------------------------------------------------------- #define LLDB_GENERIC_ERROR UINT32_MAX +#define LLDB_DEFAULT_SHELL "/bin/sh" //---------------------------------------------------------------------- // Breakpoints @@ -81,6 +82,8 @@ #define LLDB_INVALID_FRAME_ID UINT32_MAX #define LLDB_INVALID_SIGNAL_NUMBER INT32_MAX #define LLDB_INVALID_OFFSET UINT64_MAX // Must match max of lldb::offset_t +#define LLDB_INVALID_LINE_NUMBER UINT32_MAX +#define LLDB_INVALID_QUEUE_ID 0 //---------------------------------------------------------------------- /// CPU Type defintions @@ -109,6 +112,15 @@ #define LLDB_OPT_SET_10 (1U << 9) #define LLDB_OPT_SET_FROM_TO(A, B) (((1U << (B)) - 1) ^ (((1U << (A))-1) >> 1)) +#ifdef _WIN32 +#define MAX_PATH 260 +#endif + +#ifdef _MSC_VER +// ignore GCC function attributes +#define __attribute__(X) +#endif + #if defined(__cplusplus) //---------------------------------------------------------------------- diff --git a/include/lldb/lldb-enumerations.h b/include/lldb/lldb-enumerations.h index 6ec5ed6a35e2..ae8c92be900b 100644 --- a/include/lldb/lldb-enumerations.h +++ b/include/lldb/lldb-enumerations.h @@ -380,6 +380,7 @@ namespace lldb { eArgTypeClassName, eArgTypeCommandName, eArgTypeCount, + eArgTypeDescriptionVerbosity, eArgTypeDirectoryName, eArgTypeDisassemblyFlavor, eArgTypeEndAddress, @@ -406,6 +407,9 @@ namespace lldb { eArgTypeOffset, eArgTypeOldPathPrefix, eArgTypeOneLiner, + eArgTypePath, + eArgTypePermissionsNumber, + eArgTypePermissionsString, eArgTypePid, eArgTypePlugin, eArgTypeProcessName, @@ -480,7 +484,8 @@ namespace lldb { eSymbolTypeUndefined, eSymbolTypeObjCClass, eSymbolTypeObjCMetaClass, - eSymbolTypeObjCIVar + eSymbolTypeObjCIVar, + eSymbolTypeReExported } SymbolType; typedef enum SectionType diff --git a/include/lldb/lldb-forward.h b/include/lldb/lldb-forward.h index 84af8b646901..cd8a5c2e8130 100644 --- a/include/lldb/lldb-forward.h +++ b/include/lldb/lldb-forward.h @@ -79,6 +79,7 @@ class DataExtractor; class Debugger; class Declaration; class Disassembler; +struct DumpValueObjectOptions; class DynamicLibrary; class DynamicLoader; class EmulateInstruction; @@ -90,6 +91,7 @@ class ExecutionContext; class ExecutionContextRef; class ExecutionContextRefLocker; class ExecutionContextScope; +class File; class FileSpec; class FileSpecList; class Flags; @@ -104,6 +106,7 @@ class Instruction; class InstructionList; class IRExecutionUnit; class LanguageRuntime; +class SystemRuntime; class LineTable; class Listener; class Log; @@ -119,6 +122,7 @@ struct NameSearchContext; class ObjCLanguageRuntime; class ObjectContainer; class OptionGroup; +class OptionGroupOptions; class OptionGroupPlatform; class ObjectFile; class OperatingSystem; @@ -224,13 +228,14 @@ class ThreadPlanTracer; class ThreadSpec; class TimeValue; class Type; +class TypeAndOrName; class TypeCategoryMap; class TypeImpl; -class TypeAndOrName; class TypeList; class TypeListImpl; class TypeMemberImpl; class TypeNameSpecifierImpl; +class TypePair; class UUID; class Unwind; class UnwindAssembly; @@ -246,6 +251,7 @@ class ValueObjectConstResult; class ValueObjectConstResultChild; class ValueObjectConstResultImpl; class ValueObjectList; +class ValueObjectPrinter; class Variable; class VariableList; class Watchpoint; @@ -285,12 +291,14 @@ namespace lldb { typedef std::shared_ptr<lldb_private::DynamicLoader> DynamicLoaderSP; typedef std::shared_ptr<lldb_private::Event> EventSP; typedef std::shared_ptr<lldb_private::ExecutionContextRef> ExecutionContextRefSP; + typedef std::shared_ptr<lldb_private::File> FileSP; typedef std::shared_ptr<lldb_private::Function> FunctionSP; typedef std::shared_ptr<lldb_private::FuncUnwinders> FuncUnwindersSP; typedef std::shared_ptr<lldb_private::InlineFunctionInfo> InlineFunctionInfoSP; typedef std::shared_ptr<lldb_private::InputReader> InputReaderSP; typedef std::shared_ptr<lldb_private::Instruction> InstructionSP; typedef std::shared_ptr<lldb_private::LanguageRuntime> LanguageRuntimeSP; + typedef std::shared_ptr<lldb_private::SystemRuntime> SystemRuntimeSP; typedef std::shared_ptr<lldb_private::LineTable> LineTableSP; typedef std::shared_ptr<lldb_private::Listener> ListenerSP; typedef std::shared_ptr<lldb_private::LogChannel> LogChannelSP; diff --git a/include/lldb/lldb-private-enumerations.h b/include/lldb/lldb-private-enumerations.h index 60c90907145f..e523b912eac6 100644 --- a/include/lldb/lldb-private-enumerations.h +++ b/include/lldb/lldb-private-enumerations.h @@ -51,6 +51,7 @@ typedef enum ArchitectureType eArchTypeInvalid, eArchTypeMachO, eArchTypeELF, + eArchTypeCOFF, kNumArchTypes } ArchitectureType; @@ -191,7 +192,9 @@ typedef enum FormatCategoryItem eFormatCategoryItemFilter = 0x0004, eFormatCategoryItemRegexFilter = 0x0008, eFormatCategoryItemSynth = 0x0010, - eFormatCategoryItemRegexSynth = 0x0020 + eFormatCategoryItemRegexSynth = 0x0020, + eFormatCategoryItemValue = 0x0040, + eFormatCategoryItemRegexValue = 0x0080 } FormatCategoryItem; //------------------------------------------------------------------ @@ -228,6 +231,14 @@ typedef enum ScriptedCommandSynchronicity eScriptedCommandSynchronicityCurrentValue // use whatever the current synchronicity is } ScriptedCommandSynchronicity; +//---------------------------------------------------------------------- +// Verbosity mode of "po" output +//---------------------------------------------------------------------- +typedef enum LanguageRuntimeDescriptionDisplayVerbosity +{ + eLanguageRuntimeDescriptionDisplayVerbosityCompact, // only print the description string, if any + eLanguageRuntimeDescriptionDisplayVerbosityFull, // print the full-blown output +} LanguageRuntimeDescriptionDisplayVerbosity; //---------------------------------------------------------------------- // Loading modules from memory diff --git a/include/lldb/lldb-private-interfaces.h b/include/lldb/lldb-private-interfaces.h index 949cafed98b3..5a2da8989f35 100644 --- a/include/lldb/lldb-private-interfaces.h +++ b/include/lldb/lldb-private-interfaces.h @@ -27,6 +27,7 @@ namespace lldb_private typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ArchSpec &arch, InstructionType inst_type); typedef OperatingSystem* (*OperatingSystemCreateInstance) (Process *process, bool force); typedef LanguageRuntime *(*LanguageRuntimeCreateInstance) (Process *process, lldb::LanguageType language); + typedef SystemRuntime *(*SystemRuntimeCreateInstance) (Process *process); typedef Platform* (*PlatformCreateInstance) (bool force, const ArchSpec *arch); typedef lldb::ProcessSP (*ProcessCreateInstance) (Target &target, Listener &listener, const FileSpec *crash_file_path); typedef SymbolFile* (*SymbolFileCreateInstance) (ObjectFile* obj_file); diff --git a/include/lldb/lldb-private-log.h b/include/lldb/lldb-private-log.h index 31a1c23c5e67..48cce69d36cc 100644 --- a/include/lldb/lldb-private-log.h +++ b/include/lldb/lldb-private-log.h @@ -44,6 +44,7 @@ #define LIBLLDB_LOG_TARGET (1u << 22) #define LIBLLDB_LOG_MMAP (1u << 23) #define LIBLLDB_LOG_OS (1u << 24) +#define LIBLLDB_LOG_PLATFORM (1u << 25) #define LIBLLDB_LOG_ALL (UINT32_MAX) #define LIBLLDB_LOG_DEFAULT (LIBLLDB_LOG_PROCESS |\ LIBLLDB_LOG_THREAD |\ diff --git a/include/lldb/lldb-private.h b/include/lldb/lldb-private.h index 90590601d945..05b2c4fd6381 100644 --- a/include/lldb/lldb-private.h +++ b/include/lldb/lldb-private.h @@ -12,6 +12,10 @@ #if defined(__cplusplus) +#ifdef _WIN32 +#include "lldb/Host/windows/win32.h" +#endif + #include "lldb/lldb-public.h" #include "lldb/lldb-private-enumerations.h" #include "lldb/lldb-private-interfaces.h" diff --git a/include/lldb/lldb-types.h b/include/lldb/lldb-types.h index 2693c0c822bb..5851b5d3f923 100644 --- a/include/lldb/lldb-types.h +++ b/include/lldb/lldb-types.h @@ -14,11 +14,8 @@ #include "lldb/lldb-forward.h" #include <assert.h> -#include <pthread.h> #include <signal.h> #include <stdint.h> -#include <stdbool.h> -#include <unistd.h> //---------------------------------------------------------------------- // All host systems must define: @@ -38,13 +35,42 @@ // things should be defined. Currently MacOSX is being assumed by default // since that is what lldb was first developed for. +#ifndef _MSC_VER +#include <stdbool.h> +#include <unistd.h> +#endif + +#ifdef _WIN32 + +#include <process.h> + +namespace lldb +{ + typedef void* mutex_t; + typedef void* condition_t; + typedef void* rwlock_t; + typedef uintptr_t thread_t; // Host thread type + typedef uint32_t thread_key_t; + typedef void * thread_arg_t; // Host thread argument type + typedef unsigned thread_result_t; // Host thread result type + typedef thread_result_t (*thread_func_t)(void *); // Host thread function type + typedef void (*LogOutputCallback) (const char *, void *baton); + typedef bool (*CommandOverrideCallback)(void *baton, const char **argv); +} + +#else + +#include <pthread.h> + namespace lldb { //---------------------------------------------------------------------- // MacOSX Types //---------------------------------------------------------------------- typedef ::pthread_mutex_t mutex_t; typedef pthread_cond_t condition_t; + typedef pthread_rwlock_t rwlock_t; typedef pthread_t thread_t; // Host thread type + typedef pthread_key_t thread_key_t; typedef void * thread_arg_t; // Host thread argument type typedef void * thread_result_t; // Host thread result type typedef void * (*thread_func_t)(void *); // Host thread function type @@ -52,19 +78,11 @@ namespace lldb { typedef bool (*CommandOverrideCallback)(void *baton, const char **argv); } // namespace lldb -#if defined(__MINGW32__) - -const lldb::thread_t lldb_invalid_host_thread_const = { NULL, 0 } ; -#define LLDB_INVALID_HOST_THREAD (lldb_invalid_host_thread_const) -#define IS_VALID_LLDB_HOST_THREAD(t) (!(NULL == (t).p && 0 == (t).x)) - -#else +#endif #define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL) #define IS_VALID_LLDB_HOST_THREAD(t) ((t) != LLDB_INVALID_HOST_THREAD) -#endif - #define LLDB_INVALID_HOST_TIME { 0, 0 } namespace lldb @@ -77,6 +95,7 @@ namespace lldb typedef int32_t break_id_t; typedef int32_t watch_id_t; typedef void * clang_type_t; + typedef uint64_t queue_id_t; } diff --git a/include/lldb/lldb-versioning.h b/include/lldb/lldb-versioning.h index 8ccc67d8e9c0..d0498a569f58 100644 --- a/include/lldb/lldb-versioning.h +++ b/include/lldb/lldb-versioning.h @@ -1604,4 +1604,4 @@ #define LLDB_API_DEPRECATED_IN_DOT_99 #endif // defined(LLDB_CHECK_API_VERSIONING) && defined(LLDB_API_MAJOR_VERSION_WANTED) && defined(LLDB_API_MINOR_VERSION_WANTED) && defined (LLDB_API_MAJOR_VERSION) -#endif // LLDB_lldb_versioning_h_
\ No newline at end of file +#endif // LLDB_lldb_versioning_h_ |