diff options
Diffstat (limited to 'include/lldb')
326 files changed, 3109 insertions, 3783 deletions
diff --git a/include/lldb/API/LLDB.h b/include/lldb/API/LLDB.h index c51ced893d7a..2b3dd96aef0e 100644 --- a/include/lldb/API/LLDB.h +++ b/include/lldb/API/LLDB.h @@ -10,10 +10,6 @@ #ifndef LLDB_LLDB_h_ #define LLDB_LLDB_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/API/SBAddress.h" #include "lldb/API/SBAttachInfo.h" #include "lldb/API/SBBlock.h" diff --git a/include/lldb/API/SBAddress.h b/include/lldb/API/SBAddress.h index 02e847b97aa1..891324254cd6 100644 --- a/include/lldb/API/SBAddress.h +++ b/include/lldb/API/SBAddress.h @@ -82,6 +82,7 @@ public: protected: friend class SBBlock; + friend class SBBreakpoint; friend class SBBreakpointLocation; friend class SBFrame; friend class SBFunction; diff --git a/include/lldb/API/SBBreakpoint.h b/include/lldb/API/SBBreakpoint.h index 216d675b9d22..2c93bf103e3e 100644 --- a/include/lldb/API/SBBreakpoint.h +++ b/include/lldb/API/SBBreakpoint.h @@ -23,6 +23,8 @@ public: SBBreakpoint(const lldb::SBBreakpoint &rhs); + SBBreakpoint(const lldb::BreakpointSP &bp_sp); + ~SBBreakpoint(); const lldb::SBBreakpoint &operator=(const lldb::SBBreakpoint &rhs); @@ -127,14 +129,18 @@ public: static uint32_t GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event_sp); + bool IsHardware() const; + + // Can only be called from a ScriptedBreakpointResolver... + SBError + AddLocation(SBAddress &address); + private: friend class SBBreakpointList; friend class SBBreakpointLocation; friend class SBBreakpointName; friend class SBTarget; - SBBreakpoint(const lldb::BreakpointSP &bp_sp); - lldb::BreakpointSP GetSP() const; lldb::BreakpointWP m_opaque_wp; diff --git a/include/lldb/API/SBCommandInterpreter.h b/include/lldb/API/SBCommandInterpreter.h index 8b9f06599366..f98894478811 100644 --- a/include/lldb/API/SBCommandInterpreter.h +++ b/include/lldb/API/SBCommandInterpreter.h @@ -10,12 +10,8 @@ #ifndef LLDB_SBCommandInterpreter_h_ #define LLDB_SBCommandInterpreter_h_ -// C Includes -// C++ Includes #include <memory> -// Other libraries and framework includes -// Project includes #include "lldb/API/SBDebugger.h" #include "lldb/API/SBDefines.h" @@ -45,6 +41,10 @@ public: void SetEchoCommands(bool); + bool GetEchoCommentCommands() const; + + void SetEchoCommentCommands(bool echo); + bool GetPrintResults() const; void SetPrintResults(bool); @@ -162,6 +162,20 @@ public: int match_start_point, int max_return_elements, lldb::SBStringList &matches); + // Same as HandleCompletion, but also fills out `descriptions` with + // descriptions for each match. + int HandleCompletionWithDescriptions( + const char *current_line, const char *cursor, const char *last_char, + int match_start_point, int max_return_elements, + lldb::SBStringList &matches, lldb::SBStringList &descriptions); + + int HandleCompletionWithDescriptions(const char *current_line, + uint32_t cursor_pos, + int match_start_point, + int max_return_elements, + lldb::SBStringList &matches, + lldb::SBStringList &descriptions); + bool WasInterrupted() const; // Catch commands before they execute by registering a callback that will get diff --git a/include/lldb/API/SBCommandReturnObject.h b/include/lldb/API/SBCommandReturnObject.h index a372ea2ad9ee..798aa92a7ef2 100644 --- a/include/lldb/API/SBCommandReturnObject.h +++ b/include/lldb/API/SBCommandReturnObject.h @@ -10,14 +10,10 @@ #ifndef LLDB_SBCommandReturnObject_h_ #define LLDB_SBCommandReturnObject_h_ -// C Includes #include <stdio.h> -// C++ Includes #include <memory> -// Other libraries and framework includes -// Project includes #include "lldb/API/SBDefines.h" namespace lldb { diff --git a/include/lldb/API/SBDebugger.h b/include/lldb/API/SBDebugger.h index a416b460f318..3f31bf16da8d 100644 --- a/include/lldb/API/SBDebugger.h +++ b/include/lldb/API/SBDebugger.h @@ -13,6 +13,7 @@ #include <stdio.h> #include "lldb/API/SBDefines.h" +#include "lldb/API/SBInitializerOptions.h" #include "lldb/API/SBPlatform.h" namespace lldb { @@ -45,6 +46,7 @@ public: lldb::SBDebugger &operator=(const lldb::SBDebugger &rhs); static void Initialize(); + static lldb::SBError Initialize(SBInitializerOptions &options); static void Terminate(); @@ -109,7 +111,7 @@ public: const char *archname); lldb::SBTarget CreateTarget(const char *filename); - + lldb::SBTarget GetDummyTarget(); // Return true if target is deleted from the target list of the debugger. @@ -226,6 +228,8 @@ public: void SetPrompt(const char *prompt); + const char *GetReproducerPath() const; + lldb::ScriptLanguage GetScriptLanguage() const; void SetScriptLanguage(lldb::ScriptLanguage script_lang); diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h index ec92c9196737..c5c9851272f2 100644 --- a/include/lldb/API/SBDefines.h +++ b/include/lldb/API/SBDefines.h @@ -10,10 +10,6 @@ #ifndef LLDB_SBDefines_h_ #define LLDB_SBDefines_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" @@ -55,6 +51,7 @@ class LLDB_API SBFileSpecList; class LLDB_API SBFrame; class LLDB_API SBFunction; class LLDB_API SBHostOS; +class LLDB_API SBInitializerOptions; class LLDB_API SBInstruction; class LLDB_API SBInstructionList; class LLDB_API SBLanguageRuntime; diff --git a/include/lldb/API/SBExpressionOptions.h b/include/lldb/API/SBExpressionOptions.h index 1459ba6fee2a..b861436caf98 100644 --- a/include/lldb/API/SBExpressionOptions.h +++ b/include/lldb/API/SBExpressionOptions.h @@ -90,6 +90,12 @@ public: bool GetTopLevel(); void SetTopLevel(bool b = true); + + // Gets whether we will JIT an expression if it cannot be interpreted + bool GetAllowJIT(); + + // Sets whether we will JIT an expression if it cannot be interpreted + void SetAllowJIT(bool allow); protected: SBExpressionOptions( diff --git a/include/lldb/API/SBFileSpec.h b/include/lldb/API/SBFileSpec.h index 33e48f5c7c41..9ad1a5df0cfa 100644 --- a/include/lldb/API/SBFileSpec.h +++ b/include/lldb/API/SBFileSpec.h @@ -59,6 +59,7 @@ private: friend class SBDeclaration; friend class SBFileSpecList; friend class SBHostOS; + friend class SBInitializerOptions; friend class SBLaunchInfo; friend class SBLineEntry; friend class SBModule; @@ -67,8 +68,8 @@ private: friend class SBProcess; friend class SBProcessInfo; friend class SBSourceManager; - friend class SBThread; friend class SBTarget; + friend class SBThread; SBFileSpec(const lldb_private::FileSpec &fspec); diff --git a/include/lldb/API/SBFrame.h b/include/lldb/API/SBFrame.h index b8953dd13236..1123dade5de2 100644 --- a/include/lldb/API/SBFrame.h +++ b/include/lldb/API/SBFrame.h @@ -90,6 +90,10 @@ public: bool IsInlined() const; + bool IsArtificial(); + + bool IsArtificial() const; + /// The version that doesn't supply a 'use_dynamic' value will use the /// target's default. lldb::SBValue EvaluateExpression(const char *expr); diff --git a/include/lldb/API/SBInitializerOptions.h b/include/lldb/API/SBInitializerOptions.h new file mode 100644 index 000000000000..184c82df4f86 --- /dev/null +++ b/include/lldb/API/SBInitializerOptions.h @@ -0,0 +1,43 @@ +//===-- SBInitializerOptions.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_SBInitializerOptuions_h_ +#define LLDB_SBInitializerOptuions_h_ + +#include "lldb/API/SBDefines.h" +#include "lldb/API/SBFileSpec.h" + +namespace lldb_private { +struct InitializerOptions; +} + +namespace lldb { + +class LLDB_API SBInitializerOptions { +public: + SBInitializerOptions(); + SBInitializerOptions(const lldb::SBInitializerOptions &rhs); + ~SBInitializerOptions(); + const SBInitializerOptions &operator=(const lldb::SBInitializerOptions &rhs); + + void SetCaptureReproducer(bool b); + void SetReplayReproducer(bool b); + void SetReproducerPath(const char *path); + + lldb_private::InitializerOptions &ref() const; + +private: + friend class SBDebugger; + + std::unique_ptr<lldb_private::InitializerOptions> m_opaque_up; +}; + +} // namespace lldb + +#endif // LLDB_SBInitializerOptuions_h_ diff --git a/include/lldb/API/SBMemoryRegionInfo.h b/include/lldb/API/SBMemoryRegionInfo.h index 297f877a6341..5675d93b8eaf 100644 --- a/include/lldb/API/SBMemoryRegionInfo.h +++ b/include/lldb/API/SBMemoryRegionInfo.h @@ -102,6 +102,7 @@ private: const lldb_private::MemoryRegionInfo &ref() const; + // Unused. SBMemoryRegionInfo(const lldb_private::MemoryRegionInfo *lldb_object_ptr); lldb::MemoryRegionInfoUP m_opaque_ap; diff --git a/include/lldb/API/SBMemoryRegionInfoList.h b/include/lldb/API/SBMemoryRegionInfoList.h index 883a2224c92d..1e67997cdaf1 100644 --- a/include/lldb/API/SBMemoryRegionInfoList.h +++ b/include/lldb/API/SBMemoryRegionInfoList.h @@ -42,6 +42,12 @@ protected: const MemoryRegionInfoListImpl &operator*() const; private: + friend class SBProcess; + + lldb_private::MemoryRegionInfos &ref(); + + const lldb_private::MemoryRegionInfos &ref() const; + std::unique_ptr<MemoryRegionInfoListImpl> m_opaque_ap; }; diff --git a/include/lldb/API/SBModule.h b/include/lldb/API/SBModule.h index d73267f8af50..7a10e9fc96b3 100644 --- a/include/lldb/API/SBModule.h +++ b/include/lldb/API/SBModule.h @@ -309,6 +309,7 @@ public: lldb::SBFileSpec GetSymbolFileSpec() const; lldb::SBAddress GetObjectFileHeaderAddress() const; + lldb::SBAddress GetObjectFileEntryPointAddress() const; private: friend class SBAddress; diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h index 4ad24f63f076..69cf8b4ce854 100644 --- a/include/lldb/API/SBProcess.h +++ b/include/lldb/API/SBProcess.h @@ -318,11 +318,11 @@ public: /// library name and a list of paths, searching along the list of /// paths till you find a matching library. /// - /// @param[in] local_spec + /// @param[in] image_spec /// The name of the shared library that you want to load. - /// If local_spec is a relative path, the relative path will be + /// If image_spec is a relative path, the relative path will be /// appended to the search paths. - /// If the local_spec is an absolute path, just the basename is used. + /// If the image_spec is an absolute path, just the basename is used. /// /// @param[in] paths /// A list of paths to search for the library whose basename is diff --git a/include/lldb/API/SBStructuredData.h b/include/lldb/API/SBStructuredData.h index ca8229a574df..629d4f3e35ee 100644 --- a/include/lldb/API/SBStructuredData.h +++ b/include/lldb/API/SBStructuredData.h @@ -22,6 +22,8 @@ public: SBStructuredData(const lldb::SBStructuredData &rhs); SBStructuredData(const lldb::EventSP &event_sp); + + SBStructuredData(lldb_private::StructuredDataImpl *impl); ~SBStructuredData(); @@ -41,7 +43,7 @@ public: /// Return the type of data in this data structure //------------------------------------------------------------------ lldb::StructuredDataType GetType() const; - + //------------------------------------------------------------------ /// Return the size (i.e. number of elements) in this data structure /// if it is an array or dictionary type. For other types, 0 will be @@ -50,6 +52,12 @@ public: size_t GetSize() const; //------------------------------------------------------------------ + /// Fill keys with the keys in this object and return true if this data + /// structure is a dictionary. Returns false otherwise. + //------------------------------------------------------------------ + bool GetKeys(lldb::SBStringList &keys) const; + + //------------------------------------------------------------------ /// Return the value corresponding to a key if this data structure /// is a dictionary type. //------------------------------------------------------------------ diff --git a/include/lldb/API/SBSymbolContext.h b/include/lldb/API/SBSymbolContext.h index 04ee15e8ecb1..9078b5b789e0 100644 --- a/include/lldb/API/SBSymbolContext.h +++ b/include/lldb/API/SBSymbolContext.h @@ -26,6 +26,8 @@ public: SBSymbolContext(const lldb::SBSymbolContext &rhs); + SBSymbolContext(const lldb_private::SymbolContext *sc_ptr); + ~SBSymbolContext(); bool IsValid() const; @@ -69,8 +71,6 @@ protected: lldb_private::SymbolContext *get() const; - SBSymbolContext(const lldb_private::SymbolContext *sc_ptr); - void SetSymbolContext(const lldb_private::SymbolContext *sc_ptr); private: diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h index 8d99545902fe..18de267fee00 100644 --- a/include/lldb/API/SBTarget.h +++ b/include/lldb/API/SBTarget.h @@ -10,10 +10,6 @@ #ifndef LLDB_SBTarget_h_ #define LLDB_SBTarget_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/API/SBAddress.h" #include "lldb/API/SBAttachInfo.h" #include "lldb/API/SBBreakpoint.h" @@ -75,6 +71,31 @@ public: lldb::SBProcess GetProcess(); + //------------------------------------------------------------------ + /// Sets whether we should collect statistics on lldb or not. + /// + /// @param[in] v + /// A boolean to control the collection. + /// @return + /// void + //------------------------------------------------------------------ + void SetCollectingStats(bool v); + + //------------------------------------------------------------------ + /// Returns whether statistics collection are enabled. + /// + /// @return + /// true if statistics are currently being collected, false + /// otherwise. + //------------------------------------------------------------------ + bool GetCollectingStats(); + + //------------------------------------------------------------------ + /// Returns a dump of the collected statistics. + /// + /// @return + /// A SBStructuredData with the statistics collected. + //------------------------------------------------------------------ lldb::SBStructuredData GetStatistics(); //------------------------------------------------------------------ @@ -272,6 +293,10 @@ public: lldb::SBFileSpec GetExecutable(); + // Append the path mapping (from -> to) to the target's paths mapping list. + void AppendImageSearchPath(const char *from, const char *to, + lldb::SBError &error); + bool AddModule(lldb::SBModule &module); lldb::SBModule AddModule(const char *path, const char *triple, @@ -576,6 +601,11 @@ public: BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line, lldb::addr_t offset, SBFileSpecList &module_list); + lldb::SBBreakpoint + BreakpointCreateByLocation(const lldb::SBFileSpec &file_spec, uint32_t line, + uint32_t column, lldb::addr_t offset, + SBFileSpecList &module_list); + lldb::SBBreakpoint BreakpointCreateByName(const char *symbol_name, const char *module_name = nullptr); @@ -653,6 +683,37 @@ public: lldb::SBBreakpoint BreakpointCreateByAddress(addr_t address); lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address); + + //------------------------------------------------------------------ + /// Create a breakpoint using a scripted resolver. + /// + /// @param[in] class_name + /// This is the name of the class that implements a scripted resolver. + /// + /// @param[in] extra_args + /// This is an SBStructuredData object that will get passed to the + /// constructor of the class in class_name. You can use this to + /// reuse the same class, parametrizing with entries from this + /// dictionary. + /// + /// @param module_list + /// If this is non-empty, this will be used as the module filter in the + /// SearchFilter created for this breakpoint. + /// + /// @param file_list + /// If this is non-empty, this will be used as the comp unit filter in the + /// SearchFilter created for this breakpoint. + /// + /// @return + /// An SBBreakpoint that will set locations based on the logic in the + /// resolver's search callback. + //------------------------------------------------------------------ + lldb::SBBreakpoint BreakpointCreateFromScript( + const char *class_name, + SBStructuredData &extra_args, + const SBFileSpecList &module_list, + const SBFileSpecList &file_list, + bool request_hardware = false); //------------------------------------------------------------------ /// Read breakpoints from source_file and return the newly created @@ -842,6 +903,7 @@ protected: friend class SBSourceManager; friend class SBSymbol; friend class SBValue; + friend class SBVariablesOptions; //------------------------------------------------------------------ // Constructors are private, use static Target::Create function to create an diff --git a/include/lldb/API/SBThread.h b/include/lldb/API/SBThread.h index afc05d2c61ad..63816eef51b7 100644 --- a/include/lldb/API/SBThread.h +++ b/include/lldb/API/SBThread.h @@ -198,6 +198,10 @@ public: uint32_t GetExtendedBacktraceOriginatingIndexID(); + SBValue GetCurrentException(); + + SBThread GetCurrentExceptionBacktrace(); + bool SafeToCallFunctions(); #ifndef SWIG diff --git a/include/lldb/API/SBThreadPlan.h b/include/lldb/API/SBThreadPlan.h index abc14bf8fe4a..5084a427e1b8 100644 --- a/include/lldb/API/SBThreadPlan.h +++ b/include/lldb/API/SBThreadPlan.h @@ -79,14 +79,28 @@ public: // plans... SBThreadPlan QueueThreadPlanForStepOverRange(SBAddress &start_address, lldb::addr_t range_size); + SBThreadPlan QueueThreadPlanForStepOverRange(SBAddress &start_address, + lldb::addr_t range_size, + SBError &error); SBThreadPlan QueueThreadPlanForStepInRange(SBAddress &start_address, lldb::addr_t range_size); + SBThreadPlan QueueThreadPlanForStepInRange(SBAddress &start_address, + lldb::addr_t range_size, + SBError &error); SBThreadPlan QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, bool first_insn = false); + SBThreadPlan QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, + bool first_insn, SBError &error); SBThreadPlan QueueThreadPlanForRunToAddress(SBAddress address); + SBThreadPlan QueueThreadPlanForRunToAddress(SBAddress address, + SBError &error); + + SBThreadPlan QueueThreadPlanForStepScripted(const char *script_class_name); + SBThreadPlan QueueThreadPlanForStepScripted(const char *script_class_name, + SBError &error); #ifndef SWIG lldb_private::ThreadPlan *get(); diff --git a/include/lldb/API/SBVariablesOptions.h b/include/lldb/API/SBVariablesOptions.h index 756da6439e3b..0059a41129c5 100644 --- a/include/lldb/API/SBVariablesOptions.h +++ b/include/lldb/API/SBVariablesOptions.h @@ -33,6 +33,10 @@ public: void SetIncludeArguments(bool); + bool GetIncludeRecognizedArguments(const lldb::SBTarget &) const; + + void SetIncludeRecognizedArguments(bool); + bool GetIncludeLocals() const; void SetIncludeLocals(bool); diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h index ec4bc946280f..5861a3be36e1 100644 --- a/include/lldb/Breakpoint/Breakpoint.h +++ b/include/lldb/Breakpoint/Breakpoint.h @@ -10,23 +10,19 @@ #ifndef liblldb_Breakpoint_h_ #define liblldb_Breakpoint_h_ -// C Includes -// C++ Includes #include <memory> #include <string> #include <unordered_set> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/BreakpointLocationCollection.h" #include "lldb/Breakpoint/BreakpointLocationList.h" #include "lldb/Breakpoint/BreakpointName.h" #include "lldb/Breakpoint/BreakpointOptions.h" #include "lldb/Breakpoint/Stoppoint.h" -#include "lldb/Core/Event.h" #include "lldb/Core/SearchFilter.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/StringList.h" #include "lldb/Utility/StructuredData.h" @@ -503,6 +499,14 @@ public: size_t GetNumResolvedLocations() const; //------------------------------------------------------------------ + /// Return whether this breakpoint has any resolved locations. + /// + /// @return + /// True if GetNumResolvedLocations > 0 + //------------------------------------------------------------------ + bool HasResolvedLocations() const; + + //------------------------------------------------------------------ /// Return the number of breakpoint locations. /// /// @return diff --git a/include/lldb/Breakpoint/BreakpointID.h b/include/lldb/Breakpoint/BreakpointID.h index bbad45ca2d8b..5acb942ed2ad 100644 --- a/include/lldb/Breakpoint/BreakpointID.h +++ b/include/lldb/Breakpoint/BreakpointID.h @@ -10,10 +10,6 @@ #ifndef liblldb_BreakpointID_h_ #define liblldb_BreakpointID_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" diff --git a/include/lldb/Breakpoint/BreakpointIDList.h b/include/lldb/Breakpoint/BreakpointIDList.h index ec305583e8d9..2820b9fdcaa5 100644 --- a/include/lldb/Breakpoint/BreakpointIDList.h +++ b/include/lldb/Breakpoint/BreakpointIDList.h @@ -10,13 +10,9 @@ #ifndef liblldb_BreakpointIDList_h_ #define liblldb_BreakpointIDList_h_ -// C Includes -// C++ Includes #include <utility> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/Breakpoint/BreakpointID.h" diff --git a/include/lldb/Breakpoint/BreakpointList.h b/include/lldb/Breakpoint/BreakpointList.h index f4c013d41cc2..c4fc650a29f0 100644 --- a/include/lldb/Breakpoint/BreakpointList.h +++ b/include/lldb/Breakpoint/BreakpointList.h @@ -10,13 +10,9 @@ #ifndef liblldb_BreakpointList_h_ #define liblldb_BreakpointList_h_ -// C Includes -// C++ Includes #include <list> #include <mutex> -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/Breakpoint.h" namespace lldb_private { @@ -54,18 +50,6 @@ public: void Dump(Stream *s) const; //------------------------------------------------------------------ - /// Returns a shared pointer to the breakpoint with id \a breakID. - /// - /// @param[in] breakID - /// The breakpoint ID to seek for. - /// - /// @result - /// A shared pointer to the breakpoint. May contain a NULL pointer if the - /// breakpoint doesn't exist. - //------------------------------------------------------------------ - lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID); - - //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint with id \a breakID. Const /// version. /// @@ -76,7 +60,7 @@ public: /// A shared pointer to the breakpoint. May contain a NULL pointer if the /// breakpoint doesn't exist. //------------------------------------------------------------------ - const lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID) const; + lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID) const; //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint with index \a i. @@ -88,20 +72,7 @@ public: /// A shared pointer to the breakpoint. May contain a NULL pointer if the /// breakpoint doesn't exist. //------------------------------------------------------------------ - lldb::BreakpointSP GetBreakpointAtIndex(size_t i); - - //------------------------------------------------------------------ - /// Returns a shared pointer to the breakpoint with index \a i, const - /// version - /// - /// @param[in] i - /// The breakpoint index to seek for. - /// - /// @result - /// A shared pointer to the breakpoint. May contain a NULL pointer if the - /// breakpoint doesn't exist. - //------------------------------------------------------------------ - const lldb::BreakpointSP GetBreakpointAtIndex(size_t i) const; + lldb::BreakpointSP GetBreakpointAtIndex(size_t i) const; //------------------------------------------------------------------ /// Find all the breakpoints with a given name @@ -201,7 +172,7 @@ public: void GetListMutex(std::unique_lock<std::recursive_mutex> &lock); protected: - typedef std::list<lldb::BreakpointSP> bp_collection; + typedef std::vector<lldb::BreakpointSP> bp_collection; bp_collection::iterator GetBreakpointIDIterator(lldb::break_id_t breakID); @@ -211,7 +182,7 @@ protected: std::recursive_mutex &GetMutex() const { return m_mutex; } mutable std::recursive_mutex m_mutex; - bp_collection m_breakpoints; // The breakpoint list, currently a list. + bp_collection m_breakpoints; lldb::break_id_t m_next_break_id; bool m_is_internal; diff --git a/include/lldb/Breakpoint/BreakpointLocation.h b/include/lldb/Breakpoint/BreakpointLocation.h index c5911085e61b..6448cb16e927 100644 --- a/include/lldb/Breakpoint/BreakpointLocation.h +++ b/include/lldb/Breakpoint/BreakpointLocation.h @@ -10,13 +10,9 @@ #ifndef liblldb_BreakpointLocation_h_ #define liblldb_BreakpointLocation_h_ -// C Includes -// C++ Includes #include <memory> #include <mutex> -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointOptions.h" #include "lldb/Breakpoint/StoppointLocation.h" #include "lldb/Core/Address.h" diff --git a/include/lldb/Breakpoint/BreakpointLocationCollection.h b/include/lldb/Breakpoint/BreakpointLocationCollection.h index 579d468647f3..5a188539622b 100644 --- a/include/lldb/Breakpoint/BreakpointLocationCollection.h +++ b/include/lldb/Breakpoint/BreakpointLocationCollection.h @@ -10,13 +10,9 @@ #ifndef liblldb_BreakpointLocationCollection_h_ #define liblldb_BreakpointLocationCollection_h_ -// C Includes -// C++ Includes #include <mutex> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Iterable.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Breakpoint/BreakpointLocationList.h b/include/lldb/Breakpoint/BreakpointLocationList.h index 4e61abb2838e..01ee5b5dcce9 100644 --- a/include/lldb/Breakpoint/BreakpointLocationList.h +++ b/include/lldb/Breakpoint/BreakpointLocationList.h @@ -10,14 +10,10 @@ #ifndef liblldb_BreakpointLocationList_h_ #define liblldb_BreakpointLocationList_h_ -// C Includes -// C++ Includes #include <map> #include <mutex> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/Address.h" #include "lldb/Utility/Iterable.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Breakpoint/BreakpointName.h b/include/lldb/Breakpoint/BreakpointName.h index 292a0de4f48b..5e5a04fe9117 100644 --- a/include/lldb/Breakpoint/BreakpointName.h +++ b/include/lldb/Breakpoint/BreakpointName.h @@ -10,22 +10,18 @@ #ifndef liblldb_Breakpoint_Name_h_ #define liblldb_Breakpoint_Name_h_ -// C Includes -// C++ Includes #include <memory> #include <string> #include <unordered_set> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/BreakpointLocationCollection.h" #include "lldb/Breakpoint/BreakpointLocationList.h" #include "lldb/Breakpoint/BreakpointOptions.h" #include "lldb/Breakpoint/Stoppoint.h" -#include "lldb/Core/Event.h" #include "lldb/Core/SearchFilter.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Flags.h" #include "lldb/Utility/StringList.h" #include "lldb/Utility/StructuredData.h" diff --git a/include/lldb/Breakpoint/BreakpointOptions.h b/include/lldb/Breakpoint/BreakpointOptions.h index 84821817f980..e91df20ed305 100644 --- a/include/lldb/Breakpoint/BreakpointOptions.h +++ b/include/lldb/Breakpoint/BreakpointOptions.h @@ -10,13 +10,9 @@ #ifndef liblldb_BreakpointOptions_h_ #define liblldb_BreakpointOptions_h_ -// C Includes -// C++ Includes #include <memory> #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Baton.h" #include "lldb/Utility/Flags.h" #include "lldb/Utility/StringList.h" diff --git a/include/lldb/Breakpoint/BreakpointResolver.h b/include/lldb/Breakpoint/BreakpointResolver.h index 944741308da6..32008f3dd96f 100644 --- a/include/lldb/Breakpoint/BreakpointResolver.h +++ b/include/lldb/Breakpoint/BreakpointResolver.h @@ -10,10 +10,6 @@ #ifndef liblldb_BreakpointResolver_h_ #define liblldb_BreakpointResolver_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/Address.h" #include "lldb/Core/SearchFilter.h" @@ -158,6 +154,7 @@ public: AddressResolver, // This is an instance of BreakpointResolverAddress NameResolver, // This is an instance of BreakpointResolverName FileRegexResolver, + PythonResolver, ExceptionResolver, LastKnownResolverType = ExceptionResolver, UnknownResolver @@ -200,17 +197,23 @@ protected: Inlines, LanguageName, LineNumber, + Column, ModuleName, NameMaskArray, Offset, + PythonClassName, RegexString, + ScriptArgs, SectionName, + SearchDepth, SkipPrologue, SymbolNameArray, LastOptionName }; static const char *g_option_names[static_cast<uint32_t>(OptionNames::LastOptionName)]; + + virtual void NotifyBreakpointSet() {}; public: static const char *GetKey(OptionNames enum_value) { @@ -224,8 +227,11 @@ protected: /// 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. + /// When \p column is nonzero the \p line and \p column args are used to + /// filter the results to find the first breakpoint >= (line, column). void SetSCMatchesByLine(SearchFilter &filter, SymbolContextList &sc_list, - bool skip_prologue, llvm::StringRef log_ident); + bool skip_prologue, llvm::StringRef log_ident, + uint32_t line = 0, uint32_t column = 0); void SetSCMatchesByLine(SearchFilter &, SymbolContextList &, bool, const char *) = delete; @@ -237,6 +243,10 @@ protected: // breakpoints we set. private: + /// Helper for \p SetSCMatchesByLine. + void AddLocation(SearchFilter &filter, const SymbolContext &sc, + bool skip_prologue, llvm::StringRef log_ident); + // Subclass identifier (for llvm isa/dyn_cast) const unsigned char SubclassID; DISALLOW_COPY_AND_ASSIGN(BreakpointResolver); diff --git a/include/lldb/Breakpoint/BreakpointResolverAddress.h b/include/lldb/Breakpoint/BreakpointResolverAddress.h index 5845fe7cabed..5d8c0b6b7530 100644 --- a/include/lldb/Breakpoint/BreakpointResolverAddress.h +++ b/include/lldb/Breakpoint/BreakpointResolverAddress.h @@ -10,10 +10,6 @@ #ifndef liblldb_BreakpointResolverAddress_h_ #define liblldb_BreakpointResolverAddress_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Core/ModuleSpec.h" @@ -51,7 +47,7 @@ public: SymbolContext &context, Address *addr, bool containing) override; - Searcher::Depth GetDepth() override; + lldb::SearchDepth GetDepth() override; void GetDescription(Stream *s) override; diff --git a/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/include/lldb/Breakpoint/BreakpointResolverFileLine.h index 3464f8ea80d8..8671cd2e5562 100644 --- a/include/lldb/Breakpoint/BreakpointResolverFileLine.h +++ b/include/lldb/Breakpoint/BreakpointResolverFileLine.h @@ -10,10 +10,6 @@ #ifndef liblldb_BreakpointResolverFileLine_h_ #define liblldb_BreakpointResolverFileLine_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointResolver.h" namespace lldb_private { @@ -28,9 +24,9 @@ namespace lldb_private { class BreakpointResolverFileLine : public BreakpointResolver { public: BreakpointResolverFileLine(Breakpoint *bkpt, const FileSpec &resolver, - uint32_t line_no, lldb::addr_t m_offset, - bool check_inlines, bool skip_prologue, - bool exact_match); + uint32_t line_no, uint32_t column, + lldb::addr_t m_offset, bool check_inlines, + bool skip_prologue, bool exact_match); static BreakpointResolver * CreateFromStructuredData(Breakpoint *bkpt, @@ -45,7 +41,7 @@ public: SymbolContext &context, Address *addr, bool containing) override; - Searcher::Depth GetDepth() override; + lldb::SearchDepth GetDepth() override; void GetDescription(Stream *s) override; @@ -65,10 +61,11 @@ protected: void FilterContexts(SymbolContextList &sc_list, bool is_relative); friend class Breakpoint; - FileSpec m_file_spec; // This is the file spec we are looking for. - uint32_t m_line_number; // This is the line number that we are looking for. - bool m_inlines; // This determines whether the resolver looks for inlined - // functions or not. + FileSpec m_file_spec; ///< This is the file spec we are looking for. + uint32_t m_line_number; ///< This is the line number that we are looking for. + uint32_t m_column; ///< This is the column that we are looking for. + bool m_inlines; ///< This determines whether the resolver looks for inlined + ///< functions or not. bool m_skip_prologue; bool m_exact_match; diff --git a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h index c1a7a15566a5..db4f67cf3951 100644 --- a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h +++ b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h @@ -11,11 +11,7 @@ #ifndef liblldb_BreakpointResolverFileRegex_h_ #define liblldb_BreakpointResolverFileRegex_h_ -// C Includes -// C++ Includes #include <set> -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Utility/ConstString.h" @@ -47,7 +43,7 @@ public: SymbolContext &context, Address *addr, bool containing) override; - Searcher::Depth GetDepth() override; + lldb::SearchDepth GetDepth() override; void GetDescription(Stream *s) override; diff --git a/include/lldb/Breakpoint/BreakpointResolverName.h b/include/lldb/Breakpoint/BreakpointResolverName.h index 794ea67bb721..416e1aa301b1 100644 --- a/include/lldb/Breakpoint/BreakpointResolverName.h +++ b/include/lldb/Breakpoint/BreakpointResolverName.h @@ -10,13 +10,9 @@ #ifndef liblldb_BreakpointResolverName_h_ #define liblldb_BreakpointResolverName_h_ -// C Includes -// C++ Includes #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Core/Module.h" @@ -31,20 +27,23 @@ namespace lldb_private { class BreakpointResolverName : public BreakpointResolver { public: BreakpointResolverName(Breakpoint *bkpt, const char *name, - uint32_t name_type_mask, lldb::LanguageType language, + lldb::FunctionNameType name_type_mask, + lldb::LanguageType language, Breakpoint::MatchType type, lldb::addr_t offset, bool skip_prologue); // This one takes an array of names. It is always MatchType = Exact. BreakpointResolverName(Breakpoint *bkpt, const char *names[], - size_t num_names, uint32_t name_type_mask, + size_t num_names, + lldb::FunctionNameType name_type_mask, lldb::LanguageType language, lldb::addr_t offset, bool skip_prologue); // This one takes a C++ array of names. It is always MatchType = Exact. BreakpointResolverName(Breakpoint *bkpt, std::vector<std::string> names, - uint32_t name_type_mask, lldb::LanguageType language, - lldb::addr_t offset, bool skip_prologue); + lldb::FunctionNameType name_type_mask, + lldb::LanguageType language, lldb::addr_t offset, + bool skip_prologue); // Creates a function breakpoint by regular expression. Takes over control // of the lifespan of func_regex. @@ -65,7 +64,7 @@ public: SymbolContext &context, Address *addr, bool containing) override; - Searcher::Depth GetDepth() override; + lldb::SearchDepth GetDepth() override; void GetDescription(Stream *s) override; @@ -89,7 +88,8 @@ protected: lldb::LanguageType m_language; bool m_skip_prologue; - void AddNameLookup(const ConstString &name, uint32_t name_type_mask); + void AddNameLookup(const ConstString &name, + lldb::FunctionNameType name_type_mask); }; } // namespace lldb_private diff --git a/include/lldb/Breakpoint/BreakpointResolverScripted.h b/include/lldb/Breakpoint/BreakpointResolverScripted.h new file mode 100644 index 000000000000..aaa9cbe4d354 --- /dev/null +++ b/include/lldb/Breakpoint/BreakpointResolverScripted.h @@ -0,0 +1,81 @@ +//===-- BreakpointResolverScripted.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_BreakpointResolverScripted_h_ +#define liblldb_BreakpointResolverScripted_h_ + +#include "lldb/lldb-forward.h" +#include "lldb/Breakpoint/BreakpointResolver.h" +#include "lldb/Core/ModuleSpec.h" + + +namespace lldb_private { + +//---------------------------------------------------------------------- +/// @class BreakpointResolverScripted BreakpointResolverScripted.h +/// "lldb/Breakpoint/BreakpointResolverScripted.h" This class sets breakpoints +/// on a given Address. This breakpoint only takes once, and then it won't +/// attempt to reset itself. +//---------------------------------------------------------------------- + +class BreakpointResolverScripted : public BreakpointResolver { +public: + BreakpointResolverScripted(Breakpoint *bkpt, + const llvm::StringRef class_name, + lldb::SearchDepth depth, + StructuredDataImpl *args_data, + ScriptInterpreter &script_interp); + + ~BreakpointResolverScripted() override; + + static BreakpointResolver * + CreateFromStructuredData(Breakpoint *bkpt, + const StructuredData::Dictionary &options_dict, + Status &error); + + StructuredData::ObjectSP SerializeToStructuredData() override; + + Searcher::CallbackReturn SearchCallback(SearchFilter &filter, + SymbolContext &context, Address *addr, + bool containing) override; + + lldb::SearchDepth GetDepth() override; + + void GetDescription(Stream *s) override; + + void Dump(Stream *s) const override; + + /// Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const BreakpointResolverScripted *) { return true; } + static inline bool classof(const BreakpointResolver *V) { + return V->getResolverID() == BreakpointResolver::PythonResolver; + } + + lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override; + +protected: + void NotifyBreakpointSet() override; +private: + void CreateImplementationIfNeeded(); + ScriptInterpreter *GetScriptInterpreter(); + + std::string m_class_name; + lldb::SearchDepth m_depth; + StructuredDataImpl *m_args_ptr; // We own this, but the implementation + // has to manage the UP (since that is + // how it gets stored in the + // SBStructuredData). + StructuredData::GenericSP m_implementation_sp; + + DISALLOW_COPY_AND_ASSIGN(BreakpointResolverScripted); +}; + +} // namespace lldb_private + +#endif // liblldb_BreakpointResolverScripted_h_ diff --git a/include/lldb/Breakpoint/BreakpointSite.h b/include/lldb/Breakpoint/BreakpointSite.h index c9bd883ca738..8d1d69076b1c 100644 --- a/include/lldb/Breakpoint/BreakpointSite.h +++ b/include/lldb/Breakpoint/BreakpointSite.h @@ -10,15 +10,11 @@ #ifndef liblldb_BreakpointSite_h_ #define liblldb_BreakpointSite_h_ -// C Includes -// C++ Includes #include <list> #include <mutex> -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointLocationCollection.h" #include "lldb/Breakpoint/StoppointLocation.h" #include "lldb/Utility/UserID.h" diff --git a/include/lldb/Breakpoint/BreakpointSiteList.h b/include/lldb/Breakpoint/BreakpointSiteList.h index d6530c170430..2f2e31cd3126 100644 --- a/include/lldb/Breakpoint/BreakpointSiteList.h +++ b/include/lldb/Breakpoint/BreakpointSiteList.h @@ -10,14 +10,10 @@ #ifndef liblldb_BreakpointSiteList_h_ #define liblldb_BreakpointSiteList_h_ -// C Includes -// C++ Includes #include <functional> #include <map> #include <mutex> -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointSite.h" namespace lldb_private { diff --git a/include/lldb/Breakpoint/Stoppoint.h b/include/lldb/Breakpoint/Stoppoint.h index 3195ef942d9e..78baa6ce6cbb 100644 --- a/include/lldb/Breakpoint/Stoppoint.h +++ b/include/lldb/Breakpoint/Stoppoint.h @@ -10,10 +10,6 @@ #ifndef liblldb_Stoppoint_h_ #define liblldb_Stoppoint_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Breakpoint/StoppointLocation.h b/include/lldb/Breakpoint/StoppointLocation.h index 5c717bbc3b0f..5c78d2e3d659 100644 --- a/include/lldb/Breakpoint/StoppointLocation.h +++ b/include/lldb/Breakpoint/StoppointLocation.h @@ -10,10 +10,6 @@ #ifndef liblldb_StoppointLocation_h_ #define liblldb_StoppointLocation_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" // #include "lldb/Breakpoint/BreakpointOptions.h" diff --git a/include/lldb/Breakpoint/Watchpoint.h b/include/lldb/Breakpoint/Watchpoint.h index 10df18a5c266..2aaae37eb095 100644 --- a/include/lldb/Breakpoint/Watchpoint.h +++ b/include/lldb/Breakpoint/Watchpoint.h @@ -10,13 +10,9 @@ #ifndef liblldb_Watchpoint_h_ #define liblldb_Watchpoint_h_ -// C Includes -// C++ Includes #include <memory> #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/StoppointLocation.h" #include "lldb/Breakpoint/WatchpointOptions.h" #include "lldb/Symbol/CompilerType.h" diff --git a/include/lldb/Breakpoint/WatchpointList.h b/include/lldb/Breakpoint/WatchpointList.h index d5e0da444afb..9bfa817456bc 100644 --- a/include/lldb/Breakpoint/WatchpointList.h +++ b/include/lldb/Breakpoint/WatchpointList.h @@ -10,14 +10,10 @@ #ifndef liblldb_WatchpointList_h_ #define liblldb_WatchpointList_h_ -// C Includes -// C++ Includes #include <list> #include <mutex> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/Address.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Breakpoint/WatchpointOptions.h b/include/lldb/Breakpoint/WatchpointOptions.h index 8cb3b97f3a62..0f4f399b5e4d 100644 --- a/include/lldb/Breakpoint/WatchpointOptions.h +++ b/include/lldb/Breakpoint/WatchpointOptions.h @@ -10,13 +10,9 @@ #ifndef liblldb_WatchpointOptions_h_ #define liblldb_WatchpointOptions_h_ -// C Includes -// C++ Includes #include <memory> #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Baton.h" #include "lldb/Utility/StringList.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Core/Address.h b/include/lldb/Core/Address.h index 617aaefe91c9..a02a0d45a082 100644 --- a/include/lldb/Core/Address.h +++ b/include/lldb/Core/Address.h @@ -10,13 +10,13 @@ #ifndef liblldb_Address_h_ #define liblldb_Address_h_ -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-forward.h" // for SectionWP, SectionSP, ModuleSP -#include "lldb/lldb-private-enumerations.h" // for AddressClass -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, UINT32_MAX, int64_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class Block; @@ -508,9 +508,9 @@ public: /// /// @see SymbolContextScope::CalculateSymbolContext(SymbolContext*) //------------------------------------------------------------------ - uint32_t CalculateSymbolContext( - SymbolContext *sc, - uint32_t resolve_scope = lldb::eSymbolContextEverything) const; + uint32_t CalculateSymbolContext(SymbolContext *sc, + lldb::SymbolContextItem resolve_scope = + lldb::eSymbolContextEverything) const; lldb::ModuleSP CalculateSymbolContextModule() const; diff --git a/include/lldb/Core/AddressRange.h b/include/lldb/Core/AddressRange.h index 9f69c87ee354..e3c820782aaf 100644 --- a/include/lldb/Core/AddressRange.h +++ b/include/lldb/Core/AddressRange.h @@ -11,10 +11,10 @@ #define liblldb_AddressRange_h_ #include "lldb/Core/Address.h" -#include "lldb/lldb-forward.h" // for SectionSP -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" -#include <stddef.h> // for size_t +#include <stddef.h> namespace lldb_private { class SectionList; diff --git a/include/lldb/Core/AddressResolver.h b/include/lldb/Core/AddressResolver.h index cfd103e0be01..32751d64d6b4 100644 --- a/include/lldb/Core/AddressResolver.h +++ b/include/lldb/Core/AddressResolver.h @@ -12,9 +12,9 @@ #include "lldb/Core/AddressRange.h" #include "lldb/Core/SearchFilter.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/lldb-defines.h" -#include <stddef.h> // for size_t +#include <stddef.h> #include <vector> namespace lldb_private { diff --git a/include/lldb/Core/AddressResolverFileLine.h b/include/lldb/Core/AddressResolverFileLine.h index e434a62e0319..bee72245ee6b 100644 --- a/include/lldb/Core/AddressResolverFileLine.h +++ b/include/lldb/Core/AddressResolverFileLine.h @@ -11,11 +11,11 @@ #define liblldb_AddressResolverFileLine_h_ #include "lldb/Core/AddressResolver.h" -#include "lldb/Core/SearchFilter.h" // for Searcher, Searcher::CallbackR... -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/Core/SearchFilter.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-defines.h" -#include <stdint.h> // for uint32_t +#include <stdint.h> namespace lldb_private { class Address; @@ -47,7 +47,7 @@ public: SymbolContext &context, Address *addr, bool containing) override; - Searcher::Depth GetDepth() override; + lldb::SearchDepth GetDepth() override; void GetDescription(Stream *s) override; diff --git a/include/lldb/Core/AddressResolverName.h b/include/lldb/Core/AddressResolverName.h index 49a805f2115a..b4291938b290 100644 --- a/include/lldb/Core/AddressResolverName.h +++ b/include/lldb/Core/AddressResolverName.h @@ -11,10 +11,10 @@ #define liblldb_AddressResolverName_h_ #include "lldb/Core/AddressResolver.h" -#include "lldb/Core/SearchFilter.h" // for Searcher, Searcher::Call... -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Core/SearchFilter.h" +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/RegularExpression.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/lldb-defines.h" namespace lldb_private { class Address; @@ -52,7 +52,7 @@ public: SymbolContext &context, Address *addr, bool containing) override; - Searcher::Depth GetDepth() override; + lldb::SearchDepth GetDepth() override; void GetDescription(Stream *s) override; diff --git a/include/lldb/Core/Architecture.h b/include/lldb/Core/Architecture.h index 3a5a9789223d..20537d67b02c 100644 --- a/include/lldb/Core/Architecture.h +++ b/include/lldb/Core/Architecture.h @@ -67,6 +67,51 @@ public: virtual void AdjustBreakpointAddress(const Symbol &func, Address &addr) const {} + + //------------------------------------------------------------------ + /// Get \a load_addr as a callable code load address for this target + /// + /// Take \a load_addr and potentially add any address bits that are + /// needed to make the address callable. For ARM this can set bit + /// zero (if it already isn't) if \a load_addr is a thumb function. + /// If \a addr_class is set to AddressClass::eInvalid, then the address + /// adjustment will always happen. If it is set to an address class + /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be + /// returned. + //------------------------------------------------------------------ + virtual lldb::addr_t GetCallableLoadAddress( + lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const { + return addr; + } + + //------------------------------------------------------------------ + /// Get \a load_addr as an opcode for this target. + /// + /// Take \a load_addr and potentially strip any address bits that are + /// needed to make the address point to an opcode. For ARM this can + /// clear bit zero (if it already isn't) if \a load_addr is a + /// thumb function and load_addr is in code. + /// If \a addr_class is set to AddressClass::eInvalid, then the address + /// adjustment will always happen. If it is set to an address class + /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be + /// returned. + //------------------------------------------------------------------ + + virtual lldb::addr_t GetOpcodeLoadAddress( + lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const { + return addr; + } + + // Get load_addr as breakable load address for this target. Take a addr and + // check if for any reason there is a better address than this to put a + // breakpoint on. If there is then return that address. For MIPS, if + // instruction at addr is a delay slot instruction then this method will find + // the address of its previous instruction and return that address. + virtual lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr, + Target &target) const { + return addr; + } + private: Architecture(const Architecture &) = delete; void operator=(const Architecture &) = delete; diff --git a/include/lldb/Core/ClangForward.h b/include/lldb/Core/ClangForward.h index b3cab8a22f21..3fc12a555301 100644 --- a/include/lldb/Core/ClangForward.h +++ b/include/lldb/Core/ClangForward.h @@ -10,10 +10,6 @@ #ifndef liblldb_ClangForward_h_ #define liblldb_ClangForward_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #if defined(__cplusplus) diff --git a/include/lldb/Core/Communication.h b/include/lldb/Core/Communication.h index 3e29307039e4..f129b8f879d0 100644 --- a/include/lldb/Core/Communication.h +++ b/include/lldb/Core/Communication.h @@ -10,21 +10,21 @@ #ifndef liblldb_Communication_h_ #define liblldb_Communication_h_ -#include "lldb/Core/Broadcaster.h" #include "lldb/Host/HostThread.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/Timeout.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ConnectionStatus, FLAGS_ANONYMOU... -#include "lldb/lldb-forward.h" // for ConnectionSP -#include "lldb/lldb-types.h" // for thread_arg_t, thread_result_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" #include <atomic> #include <mutex> -#include <ratio> // for micro +#include <ratio> #include <string> -#include <stddef.h> // for size_t -#include <stdint.h> // for uint8_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class Connection; diff --git a/include/lldb/Core/Debugger.h b/include/lldb/Core/Debugger.h index cc7176e5c95d..09f75ef0f8c6 100644 --- a/include/lldb/Core/Debugger.h +++ b/include/lldb/Core/Debugger.h @@ -10,44 +10,40 @@ #ifndef liblldb_Debugger_h_ #define liblldb_Debugger_h_ -// C Includes #include <stdint.h> -// C++ Includes #include <memory> #include <vector> -// Other libraries and framework includes -// Project includes -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/FormatEntity.h" #include "lldb/Core/IOHandler.h" #include "lldb/Core/SourceManager.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/Terminal.h" -#include "lldb/Target/ExecutionContext.h" // for ExecutionContext +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Platform.h" #include "lldb/Target/TargetList.h" -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/Utility/Status.h" // for Status +#include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Status.h" #include "lldb/Utility/UserID.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ScriptLanguage, Langua... -#include "lldb/lldb-forward.h" // for StreamFileSP, DebuggerSP -#include "lldb/lldb-private-enumerations.h" // for VarSetOperationType -#include "lldb/lldb-private-types.h" // for LoadPluginCallbackType -#include "lldb/lldb-types.h" // for LogOutputCallback, thr... - -#include "llvm/ADT/ArrayRef.h" // for ArrayRef -#include "llvm/ADT/StringMap.h" // for StringMap -#include "llvm/ADT/StringRef.h" // for StringRef -#include "llvm/Support/DynamicLibrary.h" // for DynamicLibrary +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-private-types.h" +#include "lldb/lldb-types.h" + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/Threading.h" -#include <assert.h> // for assert -#include <stddef.h> // for size_t +#include <assert.h> +#include <stddef.h> #include <stdio.h> namespace lldb_private { @@ -192,7 +188,8 @@ public: lldb::StreamFileSP &out, lldb::StreamFileSP &err); - void PushIOHandler(const lldb::IOHandlerSP &reader_sp); + void PushIOHandler(const lldb::IOHandlerSP &reader_sp, + bool cancel_top_handler = true); bool PopIOHandler(const lldb::IOHandlerSP &reader_sp); @@ -264,6 +261,8 @@ public: void SetPrompt(llvm::StringRef p); void SetPrompt(const char *) = delete; + llvm::StringRef GetReproducerPath() const; + bool GetUseExternalEditor() const; bool SetUseExternalEditor(bool use_external_editor_p); @@ -272,11 +271,13 @@ public: bool SetUseColor(bool use_color); + bool GetHighlightSource() const; + lldb::StopShowColumn GetStopShowColumn() const; - const FormatEntity::Entry *GetStopShowColumnAnsiPrefix() const; + llvm::StringRef GetStopShowColumnAnsiPrefix() const; - const FormatEntity::Entry *GetStopShowColumnAnsiSuffix() const; + llvm::StringRef GetStopShowColumnAnsiSuffix() const; uint32_t GetStopSourceLineCount(bool before) const; diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h index ef1f2ee54dd1..7cec837e71f8 100644 --- a/include/lldb/Core/Disassembler.h +++ b/include/lldb/Core/Disassembler.h @@ -12,32 +12,32 @@ #include "lldb/Core/Address.h" #include "lldb/Core/EmulateInstruction.h" -#include "lldb/Core/FormatEntity.h" // for FormatEntity +#include "lldb/Core/FormatEntity.h" #include "lldb/Core/Opcode.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Interpreter/OptionValue.h" #include "lldb/Symbol/LineEntry.h" -#include "lldb/Target/ExecutionContext.h" // for ExecutionContext +#include "lldb/Target/ExecutionContext.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for InstructionSP, DisassemblerSP -#include "lldb/lldb-private-enumerations.h" // for AddressClass -#include "lldb/lldb-types.h" // for addr_t, offset_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" -#include <functional> // for function +#include <functional> #include <map> -#include <memory> // for enable_shared_from_this +#include <memory> #include <set> #include <string> #include <vector> -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, int64_t -#include <stdio.h> // for FILE +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> namespace lldb_private { class AddressRange; diff --git a/include/lldb/Core/DumpDataExtractor.h b/include/lldb/Core/DumpDataExtractor.h index 46e676c239d1..88446d48fa64 100644 --- a/include/lldb/Core/DumpDataExtractor.h +++ b/include/lldb/Core/DumpDataExtractor.h @@ -10,11 +10,11 @@ #ifndef LLDB_CORE_DUMPDATAEXTRACTOR_H #define LLDB_CORE_DUMPDATAEXTRACTOR_H -#include "lldb/lldb-enumerations.h" // for Format +#include "lldb/lldb-enumerations.h" #include "lldb/lldb-types.h" -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/EmulateInstruction.h b/include/lldb/Core/EmulateInstruction.h index 5d23bcd7b96e..5198f3eac922 100644 --- a/include/lldb/Core/EmulateInstruction.h +++ b/include/lldb/Core/EmulateInstruction.h @@ -12,18 +12,18 @@ #include <string> -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h" #include "lldb/Core/Opcode.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for RegisterKind, ByteOrder -#include "lldb/lldb-private-enumerations.h" // for InstructionType -#include "lldb/lldb-private-types.h" // for RegisterInfo -#include "lldb/lldb-types.h" // for addr_t - -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t, int64_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-private-types.h" +#include "lldb/lldb-types.h" + +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class OptionValueDictionary; } diff --git a/include/lldb/Core/FileLineResolver.h b/include/lldb/Core/FileLineResolver.h index 855d749ed5d4..6de99bc0c4dc 100644 --- a/include/lldb/Core/FileLineResolver.h +++ b/include/lldb/Core/FileLineResolver.h @@ -10,12 +10,12 @@ #ifndef liblldb_FileLineResolver_h_ #define liblldb_FileLineResolver_h_ -#include "lldb/Core/SearchFilter.h" // for Searcher, Searcher::CallbackR... +#include "lldb/Core/SearchFilter.h" #include "lldb/Symbol/SymbolContext.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-defines.h" -#include <stdint.h> // for uint32_t, UINT32_MAX +#include <stdint.h> namespace lldb_private { class Address; @@ -48,7 +48,7 @@ public: SymbolContext &context, Address *addr, bool containing) override; - Searcher::Depth GetDepth() override; + lldb::SearchDepth GetDepth() override; void GetDescription(Stream *s) override; diff --git a/include/lldb/Core/FileSpecList.h b/include/lldb/Core/FileSpecList.h index 713ed2aaffc6..db6490ef7133 100644 --- a/include/lldb/Core/FileSpecList.h +++ b/include/lldb/Core/FileSpecList.h @@ -15,7 +15,7 @@ #include <vector> -#include <stddef.h> // for size_t +#include <stddef.h> namespace lldb_private { class Stream; diff --git a/include/lldb/Core/FormatEntity.h b/include/lldb/Core/FormatEntity.h index 93c7b3a94e4e..b58f3b104e46 100644 --- a/include/lldb/Core/FormatEntity.h +++ b/include/lldb/Core/FormatEntity.h @@ -11,13 +11,13 @@ #define liblldb_FormatEntity_h_ #include "lldb/Utility/CompletionRequest.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" -#include "lldb/lldb-enumerations.h" // for Format::eFormatDefault, Format -#include "lldb/lldb-types.h" // for addr_t -#include <algorithm> // for min -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-types.h" +#include <algorithm> +#include <stddef.h> +#include <stdint.h> #include <string> #include <vector> @@ -88,6 +88,7 @@ public: FrameRegisterFP, FrameRegisterFlags, FrameRegisterByName, + FrameIsArtificial, ScriptFrame, FunctionID, FunctionDidChange, @@ -104,6 +105,7 @@ public: FunctionIsOptimized, LineEntryFile, LineEntryLineNumber, + LineEntryColumn, LineEntryStartAddress, LineEntryEndAddress, CurrentPCArrow diff --git a/include/lldb/Core/Highlighter.h b/include/lldb/Core/Highlighter.h new file mode 100644 index 000000000000..220557c1f032 --- /dev/null +++ b/include/lldb/Core/Highlighter.h @@ -0,0 +1,165 @@ +//===-- Highlighter.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_Highlighter_h_ +#define liblldb_Highlighter_h_ + +#include <utility> +#include <vector> + +#include "lldb/Utility/Stream.h" +#include "lldb/lldb-enumerations.h" +#include "llvm/ADT/StringRef.h" + +namespace lldb_private { + +//---------------------------------------------------------------------- +/// Represents style that the highlighter should apply to the given source code. +/// Stores information about how every kind of token should be annotated. +//---------------------------------------------------------------------- +struct HighlightStyle { + + //---------------------------------------------------------------------- + /// A pair of strings that should be placed around a certain token. Usually + /// stores color codes in these strings (the suffix string is often used for + /// resetting the terminal attributes back to normal). + //---------------------------------------------------------------------- + class ColorStyle { + std::string m_prefix; + std::string m_suffix; + + public: + ColorStyle() = default; + ColorStyle(llvm::StringRef prefix, llvm::StringRef suffix) { + Set(prefix, suffix); + } + + /// Applies this style to the given value. + /// \param s + /// The stream to which the result should be appended. + /// \param value + /// The value that we should place our strings around. + void Apply(Stream &s, llvm::StringRef value) const; + + /// Sets the prefix and suffix strings. + /// @param prefix + /// @param suffix + void Set(llvm::StringRef prefix, llvm::StringRef suffix); + }; + + /// The style for the token which is below the cursor of the user. Note that + /// this style is overwritten by the SourceManager with the values of + /// stop-show-column-ansi-prefix/stop-show-column-ansi-suffix. + ColorStyle selected; + + /// Matches identifiers to variable or functions. + ColorStyle identifier; + /// Matches any string or character literals in the language: "foo" or 'f' + ColorStyle string_literal; + /// Matches scalar value literals like '42' or '0.1'. + ColorStyle scalar_literal; + /// Matches all reserved keywords in the language. + ColorStyle keyword; + /// Matches any comments in the language. + ColorStyle comment; + /// Matches commas: ',' + ColorStyle comma; + /// Matches one colon: ':' + ColorStyle colon; + /// Matches any semicolon: ';' + ColorStyle semicolons; + /// Matches operators like '+', '-', '%', '&', '=' + ColorStyle operators; + + /// Matches '{' or '}' + ColorStyle braces; + /// Matches '[' or ']' + ColorStyle square_brackets; + /// Matches '(' or ')' + ColorStyle parentheses; + + //----------------------------------------------------------------------- + // C language specific options + //----------------------------------------------------------------------- + + /// Matches directives to a preprocessor (if the language has any). + ColorStyle pp_directive; + + /// Returns a HighlightStyle that is based on vim's default highlight style. + static HighlightStyle MakeVimStyle(); +}; + +//---------------------------------------------------------------------- +/// Annotates source code with color attributes. +//---------------------------------------------------------------------- +class Highlighter { +public: + Highlighter() = default; + virtual ~Highlighter() = default; + DISALLOW_COPY_AND_ASSIGN(Highlighter); + + /// Returns a human readable name for the selected highlighter. + virtual llvm::StringRef GetName() const = 0; + + /// Highlights the given line + /// \param options + /// \param line + /// The user supplied line that needs to be highlighted. + /// \param cursor_pos + /// The cursor position of the user in this line, starting at 0 (which + /// means the cursor is on the first character in 'line'). + /// \param previous_lines + /// Any previous lines the user has written which we should only use + /// for getting the context of the Highlighting right. + /// \param s + /// The stream to which the highlighted version of the user string should + /// be written. + virtual void Highlight(const HighlightStyle &options, llvm::StringRef line, + llvm::Optional<size_t> cursor_pos, + llvm::StringRef previous_lines, Stream &s) const = 0; + + /// Utility method for calling Highlight without a stream. + std::string Highlight(const HighlightStyle &options, llvm::StringRef line, + llvm::Optional<size_t> cursor_pos, + llvm::StringRef previous_lines = "") const; +}; + +/// A default highlighter that only highlights the user cursor, but doesn't +/// do any other highlighting. +class DefaultHighlighter : public Highlighter { +public: + llvm::StringRef GetName() const override { return "none"; } + + void Highlight(const HighlightStyle &options, llvm::StringRef line, + llvm::Optional<size_t> cursor_pos, + llvm::StringRef previous_lines, Stream &s) const override; +}; + +/// Manages the available highlighters. +class HighlighterManager { + DefaultHighlighter m_default; + +public: + /// Queries all known highlighter for one that can highlight some source code. + /// \param language_type + /// The language type that the caller thinks the source code was given in. + /// \param path + /// The path to the file the source code is from. Used as a fallback when + /// the user can't provide a language. + /// \return + /// The highlighter that wants to highlight the source code. Could be an + /// empty highlighter that does nothing. + const Highlighter &getHighlighterFor(lldb::LanguageType language_type, + llvm::StringRef path) const; + const Highlighter &getDefaultHighlighter() const { return m_default; } +}; + +} // namespace lldb_private + +#endif // liblldb_Highlighter_h_ diff --git a/include/lldb/Core/IOHandler.h b/include/lldb/Core/IOHandler.h index 2170ad10674e..4bd577390b2c 100644 --- a/include/lldb/Core/IOHandler.h +++ b/include/lldb/Core/IOHandler.h @@ -11,22 +11,22 @@ #define liblldb_IOHandler_h_ #include "lldb/Core/ValueObjectList.h" -#include "lldb/Host/Predicate.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Flags.h" +#include "lldb/Utility/Predicate.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StringList.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for IOHandlerSP, StreamFileSP -#include "llvm/ADT/StringRef.h" // for StringRef +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "llvm/ADT/StringRef.h" #include <memory> #include <mutex> #include <string> #include <vector> -#include <stdint.h> // for uint32_t -#include <stdio.h> // for FILE +#include <stdint.h> +#include <stdio.h> namespace lldb_private { class Debugger; @@ -205,7 +205,7 @@ public: virtual int IOHandlerComplete(IOHandler &io_handler, const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, - StringList &matches); + StringList &matches, StringList &descriptions); virtual const char *IOHandlerGetFixIndentationCharacters() { return nullptr; } @@ -430,7 +430,8 @@ private: static int AutoCompleteCallback(const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, - StringList &matches, void *baton); + StringList &matches, StringList &descriptions, + void *baton); #endif protected: @@ -464,7 +465,7 @@ public: int IOHandlerComplete(IOHandler &io_handler, const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, - StringList &matches) override; + StringList &matches, StringList &descriptions) override; void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override; diff --git a/include/lldb/Core/LoadedModuleInfoList.h b/include/lldb/Core/LoadedModuleInfoList.h index 6554c64fa870..5ef0f8929b89 100644 --- a/include/lldb/Core/LoadedModuleInfoList.h +++ b/include/lldb/Core/LoadedModuleInfoList.h @@ -10,14 +10,11 @@ #ifndef liblldb_LoadedModuleInfoList_h_ #define liblldb_LoadedModuleInfoList_h_ -// C Includes -// C++ Includes #include <cassert> #include <string> #include <vector> -// Other libraries and framework includes #include "lldb/lldb-defines.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-types.h" diff --git a/include/lldb/Core/Mangled.h b/include/lldb/Core/Mangled.h index d263297ecfc6..12edf8200e43 100644 --- a/include/lldb/Core/Mangled.h +++ b/include/lldb/Core/Mangled.h @@ -11,18 +11,15 @@ #define liblldb_Mangled_h_ #if defined(__cplusplus) +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" + #include "lldb/Utility/ConstString.h" -#include "lldb/lldb-enumerations.h" // for LanguageType -#include "llvm/ADT/StringRef.h" // for StringRef -#include <stddef.h> // for size_t +#include "llvm/ADT/StringRef.h" -namespace lldb_private { -class RegularExpression; -} -namespace lldb_private { -class Stream; -} +#include <memory> +#include <stddef.h> namespace lldb_private { @@ -238,7 +235,6 @@ public: return true; return GetDemangledName(language) == name; } - bool NameMatches(const RegularExpression ®ex, lldb::LanguageType language) const; @@ -300,6 +296,36 @@ public: //---------------------------------------------------------------------- lldb::LanguageType GuessLanguage() const; + /// Function signature for filtering mangled names. + using SkipMangledNameFn = bool(llvm::StringRef, ManglingScheme); + + //---------------------------------------------------------------------- + /// Trigger explicit demangling to obtain rich mangling information. This is + /// optimized for batch processing while populating a name index. To get the + /// pure demangled name string for a single entity, use GetDemangledName() + /// instead. + /// + /// For names that match the Itanium mangling scheme, this uses LLVM's + /// ItaniumPartialDemangler. All other names fall back to LLDB's builtin + /// parser currently. + /// + /// This function is thread-safe when used with different \a context + /// instances in different threads. + /// + /// @param[in] context + /// The context for this function. A single instance can be stack- + /// allocated in the caller's frame and used for multiple calls. + /// + /// @param[in] skip_mangled_name + /// A filtering function for skipping entities based on name and mangling + /// scheme. This can be null if unused. + /// + /// @return + /// True on success, false otherwise. + //---------------------------------------------------------------------- + bool DemangleWithRichManglingInfo(RichManglingContext &context, + SkipMangledNameFn *skip_mangled_name); + private: //---------------------------------------------------------------------- /// Mangled member variables. diff --git a/include/lldb/Core/MappedHash.h b/include/lldb/Core/MappedHash.h index 1bdf59c73649..8d9a91e69079 100644 --- a/include/lldb/Core/MappedHash.h +++ b/include/lldb/Core/MappedHash.h @@ -10,18 +10,14 @@ #ifndef liblldb_MappedHash_h_ #define liblldb_MappedHash_h_ -// C Includes #include <assert.h> #include <stdint.h> -// C++ Includes #include <algorithm> #include <functional> #include <map> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Stream.h" #include "llvm/Support/DJB.h" diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h index 83d5f519f086..270a401172fa 100644 --- a/include/lldb/Core/Module.h +++ b/include/lldb/Core/Module.h @@ -10,31 +10,31 @@ #ifndef liblldb_Module_h_ #define liblldb_Module_h_ -#include "lldb/Core/Address.h" // for Address -#include "lldb/Core/ModuleSpec.h" // for ModuleSpec -#include "lldb/Symbol/ObjectFile.h" // for ObjectFile +#include "lldb/Core/Address.h" +#include "lldb/Core/ModuleSpec.h" +#include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContextScope.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/PathMappingList.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Status.h" // for Status +#include "lldb/Utility/Status.h" #include "lldb/Utility/UUID.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for LanguageType, SymbolType +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" -#include "lldb/lldb-types.h" // for addr_t, offset_t +#include "lldb/lldb-types.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Chrono.h" #include <atomic> -#include <memory> // for enable_shared_from_this +#include <memory> #include <mutex> -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t +#include <stddef.h> +#include <stdint.h> #include <string> #include <vector> @@ -168,10 +168,11 @@ public: // Once we get the object file, update our module with the object file's // architecture since it might differ in vendor/os if some parts were // unknown. - if (!module_sp->m_objfile_sp->GetArchitecture(module_sp->m_arch)) - return nullptr; - - return module_sp; + if (ArchSpec arch = module_sp->m_objfile_sp->GetArchitecture()) { + module_sp->m_arch = arch; + return module_sp; + } + return nullptr; } //------------------------------------------------------------------ @@ -380,7 +381,7 @@ public: //------------------------------------------------------------------ size_t FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool symbols_ok, + lldb::FunctionNameType name_type_mask, bool symbols_ok, bool inlines_ok, bool append, SymbolContextList &sc_list); @@ -498,10 +499,6 @@ public: /// have to specify complete scoping on all expressions, but it also allows /// for exact matching when required. /// - /// @param[in] sc - /// A symbol context that scopes where to extract a type list - /// from. - /// /// @param[in] type_name /// The name of the type we are looking for that is a fully /// or partially qualified type name. @@ -520,8 +517,7 @@ public: /// The number of matches added to \a type_list. //------------------------------------------------------------------ size_t - FindTypes(const SymbolContext &sc, const ConstString &type_name, - bool exact_match, size_t max_matches, + FindTypes(const ConstString &type_name, bool exact_match, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeList &types); @@ -533,10 +529,6 @@ public: /// expression parser when searches need to happen in an exact namespace /// scope. /// - /// @param[in] sc - /// A symbol context that scopes where to extract a type list - /// from. - /// /// @param[in] type_name /// The name of a type within a namespace that should not include /// any qualifying namespaces (just a type basename). @@ -550,8 +542,7 @@ public: /// @return /// The number of matches added to \a type_list. //------------------------------------------------------------------ - size_t FindTypesInNamespace(const SymbolContext &sc, - const ConstString &type_name, + size_t FindTypesInNamespace(const ConstString &type_name, const CompilerDeclContext *parent_decl_ctx, size_t max_matches, TypeList &type_list); @@ -816,10 +807,9 @@ public: /// /// @see SymbolContext::Scope //------------------------------------------------------------------ - uint32_t - ResolveSymbolContextForAddress(const Address &so_addr, uint32_t resolve_scope, - SymbolContext &sc, - bool resolve_tail_call_address = false); + uint32_t ResolveSymbolContextForAddress( + const Address &so_addr, lldb::SymbolContextItem resolve_scope, + SymbolContext &sc, bool resolve_tail_call_address = false); //------------------------------------------------------------------ /// Resolve items in the symbol context for a given file and line. @@ -862,10 +852,9 @@ public: /// /// @see SymbolContext::Scope //------------------------------------------------------------------ - uint32_t ResolveSymbolContextForFilePath(const char *file_path, uint32_t line, - bool check_inlines, - uint32_t resolve_scope, - SymbolContextList &sc_list); + uint32_t ResolveSymbolContextForFilePath( + const char *file_path, uint32_t line, bool check_inlines, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); //------------------------------------------------------------------ /// Resolve items in the symbol context for a given file and line. @@ -909,10 +898,9 @@ public: /// /// @see SymbolContext::Scope //------------------------------------------------------------------ - uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec, - uint32_t line, bool check_inlines, - uint32_t resolve_scope, - SymbolContextList &sc_list); + uint32_t ResolveSymbolContextsForFileSpec( + const FileSpec &file_spec, uint32_t line, bool check_inlines, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); void SetFileSpecAndObjectName(const FileSpec &file, const ConstString &object_name); @@ -1031,9 +1019,10 @@ public: public: LookupInfo() : m_name(), m_lookup_name(), m_language(lldb::eLanguageTypeUnknown), - m_name_type_mask(0), m_match_name_after_lookup(false) {} + m_name_type_mask(lldb::eFunctionNameTypeNone), + m_match_name_after_lookup(false) {} - LookupInfo(const ConstString &name, uint32_t name_type_mask, + LookupInfo(const ConstString &name, lldb::FunctionNameType name_type_mask, lldb::LanguageType language); const ConstString &GetName() const { return m_name; } @@ -1044,24 +1033,31 @@ public: void SetLookupName(const ConstString &name) { m_lookup_name = name; } - uint32_t GetNameTypeMask() const { return m_name_type_mask; } + lldb::FunctionNameType GetNameTypeMask() const { return m_name_type_mask; } - void SetNameTypeMask(uint32_t mask) { m_name_type_mask = mask; } + void SetNameTypeMask(lldb::FunctionNameType mask) { + m_name_type_mask = mask; + } void Prune(SymbolContextList &sc_list, size_t start_idx) const; protected: - ConstString m_name; ///< What the user originally typed - ConstString m_lookup_name; ///< The actual name will lookup when calling in - ///the object or symbol file - lldb::LanguageType - m_language; ///< Limit matches to only be for this language - uint32_t m_name_type_mask; ///< One or more bits from lldb::FunctionNameType - ///that indicate what kind of names we are - ///looking for - bool m_match_name_after_lookup; ///< If \b true, then demangled names that - ///match will need to contain "m_name" in - ///order to be considered a match + /// What the user originally typed + ConstString m_name; + + /// The actual name will lookup when calling in the object or symbol file + ConstString m_lookup_name; + + /// Limit matches to only be for this language + lldb::LanguageType m_language; + + /// One or more bits from lldb::FunctionNameType that indicate what kind of + /// names we are looking for + lldb::FunctionNameType m_name_type_mask; + + ///< If \b true, then demangled names that match will need to contain + ///< "m_name" in order to be considered a match + bool m_match_name_after_lookup; }; protected: @@ -1155,7 +1151,7 @@ protected: //------------------------------------------------------------------ uint32_t ResolveSymbolContextForAddress(lldb::addr_t vm_addr, bool vm_addr_is_file_addr, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, Address &so_addr, SymbolContext &sc); void SymbolIndicesToSymbolContextList(Symtab *symtab, @@ -1176,9 +1172,8 @@ private: Module(); // Only used internally by CreateJITModule () size_t FindTypes_Impl( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - size_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); diff --git a/include/lldb/Core/ModuleList.h b/include/lldb/Core/ModuleList.h index e1d8a9a7fb85..a28d97113d63 100644 --- a/include/lldb/Core/ModuleList.h +++ b/include/lldb/Core/ModuleList.h @@ -10,12 +10,12 @@ #ifndef liblldb_ModuleList_h_ #define liblldb_ModuleList_h_ -#include "lldb/Core/Address.h" // for Address -#include "lldb/Core/ModuleSpec.h" // for ModuleSpec +#include "lldb/Core/Address.h" +#include "lldb/Core/ModuleSpec.h" #include "lldb/Core/UserSettingsController.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Iterable.h" -#include "lldb/Utility/Status.h" // for Status +#include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" @@ -27,8 +27,8 @@ #include <mutex> #include <vector> -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class ConstString; @@ -300,14 +300,16 @@ public: //------------------------------------------------------------------ /// @see Module::FindFunctions () //------------------------------------------------------------------ - size_t FindFunctions(const ConstString &name, uint32_t name_type_mask, + size_t FindFunctions(const ConstString &name, + lldb::FunctionNameType name_type_mask, bool include_symbols, bool include_inlines, bool append, SymbolContextList &sc_list) const; //------------------------------------------------------------------ /// @see Module::FindFunctionSymbols () //------------------------------------------------------------------ - size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask, + size_t FindFunctionSymbols(const ConstString &name, + lldb::FunctionNameType name_type_mask, SymbolContextList &sc_list); //------------------------------------------------------------------ @@ -415,9 +417,9 @@ public: //------------------------------------------------------------------ /// Find types by name. /// - /// @param[in] sc - /// A symbol context that scopes where to extract a type list - /// from. + /// @param[in] search_first + /// If non-null, this module will be searched before any other + /// modules. /// /// @param[in] name /// The name of the type we are looking for. @@ -445,7 +447,7 @@ public: /// @return /// The number of matches added to \a type_list. //------------------------------------------------------------------ - size_t FindTypes(const SymbolContext &sc, const ConstString &name, + size_t FindTypes(Module *search_first, const ConstString &name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeList &types) const; @@ -495,26 +497,24 @@ public: /// &,uint32_t,SymbolContext&) //------------------------------------------------------------------ uint32_t ResolveSymbolContextForAddress(const Address &so_addr, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContext &sc) const; //------------------------------------------------------------------ /// @copydoc Module::ResolveSymbolContextForFilePath (const char /// *,uint32_t,bool,uint32_t,SymbolContextList&) //------------------------------------------------------------------ - uint32_t ResolveSymbolContextForFilePath(const char *file_path, uint32_t line, - bool check_inlines, - uint32_t resolve_scope, - SymbolContextList &sc_list) const; + uint32_t ResolveSymbolContextForFilePath( + const char *file_path, uint32_t line, bool check_inlines, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) const; //------------------------------------------------------------------ /// @copydoc Module::ResolveSymbolContextsForFileSpec (const FileSpec /// &,uint32_t,bool,uint32_t,SymbolContextList&) //------------------------------------------------------------------ - uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec, - uint32_t line, bool check_inlines, - uint32_t resolve_scope, - SymbolContextList &sc_list) const; + uint32_t ResolveSymbolContextsForFileSpec( + const FileSpec &file_spec, uint32_t line, bool check_inlines, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) const; //------------------------------------------------------------------ /// Gets the size of the module list. diff --git a/include/lldb/Core/ModuleSpec.h b/include/lldb/Core/ModuleSpec.h index 16a35a187780..ae772c2a1efe 100644 --- a/include/lldb/Core/ModuleSpec.h +++ b/include/lldb/Core/ModuleSpec.h @@ -10,18 +10,15 @@ #ifndef liblldb_ModuleSpec_h_ #define liblldb_ModuleSpec_h_ -// Project includes +#include "lldb/Host/FileSystem.h" #include "lldb/Target/PathMappingList.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/UUID.h" -// Other libraries and framework includes #include "llvm/Support/Chrono.h" -// C Includes -// C++ Includes #include <mutex> #include <vector> @@ -34,15 +31,17 @@ public: m_object_name(), m_object_offset(0), m_object_size(0), m_source_mappings() {} - ModuleSpec(const FileSpec &file_spec, const UUID& uuid = UUID()) + ModuleSpec(const FileSpec &file_spec, const UUID &uuid = UUID()) : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(), m_uuid(uuid), m_object_name(), m_object_offset(0), - m_object_size(file_spec.GetByteSize()), m_source_mappings() {} + m_object_size(FileSystem::Instance().GetByteSize(file_spec)), + m_source_mappings() {} ModuleSpec(const FileSpec &file_spec, const ArchSpec &arch) : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(arch), m_uuid(), m_object_name(), m_object_offset(0), - m_object_size(file_spec.GetByteSize()), m_source_mappings() {} + m_object_size(FileSystem::Instance().GetByteSize(file_spec)), + m_source_mappings() {} ModuleSpec(const ModuleSpec &rhs) : m_file(rhs.m_file), m_platform_file(rhs.m_platform_file), @@ -256,20 +255,20 @@ public: if (match_module_spec.GetFileSpecPtr()) { const FileSpec &fspec = match_module_spec.GetFileSpec(); if (!FileSpec::Equal(fspec, GetFileSpec(), - fspec.GetDirectory().IsEmpty() == false)) + !fspec.GetDirectory().IsEmpty())) return false; } if (GetPlatformFileSpec() && match_module_spec.GetPlatformFileSpecPtr()) { const FileSpec &fspec = match_module_spec.GetPlatformFileSpec(); if (!FileSpec::Equal(fspec, GetPlatformFileSpec(), - fspec.GetDirectory().IsEmpty() == false)) + !fspec.GetDirectory().IsEmpty())) return false; } // Only match the symbol file spec if there is one in this ModuleSpec if (GetSymbolFileSpec() && match_module_spec.GetSymbolFileSpecPtr()) { const FileSpec &fspec = match_module_spec.GetSymbolFileSpec(); if (!FileSpec::Equal(fspec, GetSymbolFileSpec(), - fspec.GetDirectory().IsEmpty() == false)) + !fspec.GetDirectory().IsEmpty())) return false; } if (match_module_spec.GetArchitecturePtr()) { diff --git a/include/lldb/Core/Opcode.h b/include/lldb/Core/Opcode.h index 33857457b2c4..fb6cc825abd2 100644 --- a/include/lldb/Core/Opcode.h +++ b/include/lldb/Core/Opcode.h @@ -11,12 +11,12 @@ #define lldb_Opcode_h #include "lldb/Utility/Endian.h" -#include "lldb/lldb-enumerations.h" // for ByteOrder, ByteOrder::eByteOrde... +#include "lldb/lldb-enumerations.h" #include "llvm/Support/MathExtras.h" -#include <assert.h> // for assert -#include <stdint.h> // for uint32_t, uint8_t, uint16_t +#include <assert.h> +#include <stdint.h> #include <string.h> namespace lldb_private { diff --git a/include/lldb/Core/PluginInterface.h b/include/lldb/Core/PluginInterface.h index edda15a1ace0..24f53c62ab09 100644 --- a/include/lldb/Core/PluginInterface.h +++ b/include/lldb/Core/PluginInterface.h @@ -10,10 +10,6 @@ #ifndef liblldb_PluginInterface_h_ #define liblldb_PluginInterface_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Core/PluginManager.h b/include/lldb/Core/PluginManager.h index b782294f1f60..598ee9a8d8e3 100644 --- a/include/lldb/Core/PluginManager.h +++ b/include/lldb/Core/PluginManager.h @@ -12,14 +12,14 @@ #include "lldb/Core/Architecture.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-enumerations.h" // for ScriptLanguage -#include "lldb/lldb-forward.h" // for OptionValuePropertiesSP -#include "lldb/lldb-private-interfaces.h" // for DebuggerInitializeCallback -#include "llvm/ADT/StringRef.h" // for StringRef - -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t +#include "lldb/Utility/Status.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-interfaces.h" +#include "llvm/ADT/StringRef.h" + +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class CommandInterpreter; diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Core/RangeMap.h index 45bda26e2659..5a75a24f7f61 100644 --- a/include/lldb/Core/RangeMap.h +++ b/include/lldb/Core/RangeMap.h @@ -10,15 +10,11 @@ #ifndef liblldb_RangeMap_h_ #define liblldb_RangeMap_h_ -// C Includes -// C++ Includes #include <algorithm> #include <vector> -// Other libraries and framework includes #include "llvm/ADT/SmallVector.h" -// Project includes #include "lldb/lldb-private.h" // Uncomment to make sure all Range objects are sorted when needed @@ -169,8 +165,6 @@ public: #ifdef ASSERT_RANGEMAP_ARE_SORTED bool IsSorted() const { typename Collection::const_iterator pos, end, prev; - // First we determine if we can combine any of the Entry objects so we - // don't end up allocating and making a new collection for no reason for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) { if (prev != end && *pos < *prev) @@ -639,201 +633,12 @@ struct RangeData : public Range<B, S> { } }; -template <typename B, typename S, typename T, unsigned N> class RangeDataArray { +template <typename B, typename S, typename T, unsigned N = 0> +class RangeDataVector { public: typedef RangeData<B, S, T> Entry; typedef llvm::SmallVector<Entry, N> Collection; - RangeDataArray() = default; - - ~RangeDataArray() = default; - - void Append(const Entry &entry) { m_entries.push_back(entry); } - - void Sort() { - if (m_entries.size() > 1) - std::stable_sort(m_entries.begin(), m_entries.end()); - } - -#ifdef ASSERT_RANGEMAP_ARE_SORTED - bool IsSorted() const { - typename Collection::const_iterator pos, end, prev; - // First we determine if we can combine any of the Entry objects so we - // don't end up allocating and making a new collection for no reason - for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; - prev = pos++) { - if (prev != end && *pos < *prev) - return false; - } - return true; - } -#endif - - void CombineConsecutiveEntriesWithEqualData() { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - typename Collection::iterator pos; - typename Collection::iterator end; - typename Collection::iterator prev; - bool can_combine = false; - // First we determine if we can combine any of the Entry objects so we - // don't end up allocating and making a new collection for no reason - for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; - prev = pos++) { - if (prev != end && prev->data == pos->data) { - can_combine = true; - break; - } - } - - // We we can combine at least one entry, then we make a new collection and - // populate it accordingly, and then swap it into place. - if (can_combine) { - Collection minimal_ranges; - for (pos = m_entries.begin(), end = m_entries.end(), prev = end; - pos != end; prev = pos++) { - if (prev != end && prev->data == pos->data) - minimal_ranges.back().SetRangeEnd(pos->GetRangeEnd()); - else - minimal_ranges.push_back(*pos); - } - // Use the swap technique in case our new vector is much smaller. We must - // swap when using the STL because std::vector objects never release or - // reduce the memory once it has been allocated/reserved. - m_entries.swap(minimal_ranges); - } - } - - void Clear() { m_entries.clear(); } - - bool IsEmpty() const { return m_entries.empty(); } - - size_t GetSize() const { return m_entries.size(); } - - const Entry *GetEntryAtIndex(size_t i) const { - return ((i < m_entries.size()) ? &m_entries[i] : nullptr); - } - - // Clients must ensure that "i" is a valid index prior to calling this - // function - const Entry &GetEntryRef(size_t i) const { return m_entries[i]; } - - static bool BaseLessThan(const Entry &lhs, const Entry &rhs) { - return lhs.GetRangeBase() < rhs.GetRangeBase(); - } - - uint32_t FindEntryIndexThatContains(B addr) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry(addr, 1); - typename Collection::const_iterator begin = m_entries.begin(); - 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 std::distance(begin, pos); - } else if (pos != begin) { - --pos; - if (pos->Contains(addr)) - return std::distance(begin, pos); - } - } - return UINT32_MAX; - } - - Entry *FindEntryThatContains(B addr) { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry; - entry.SetRangeBase(addr); - entry.SetByteSize(1); - 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); - - if (pos != end && pos->Contains(addr)) { - return &(*pos); - } else if (pos != begin) { - --pos; - if (pos->Contains(addr)) { - return &(*pos); - } - } - } - return nullptr; - } - - const Entry *FindEntryThatContains(B addr) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry; - entry.SetRangeBase(addr); - entry.SetByteSize(1); - typename Collection::const_iterator begin = m_entries.begin(); - 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) { - --pos; - if (pos->Contains(addr)) { - return &(*pos); - } - } - } - return nullptr; - } - - const Entry *FindEntryThatContains(const Entry &range) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - typename Collection::const_iterator begin = m_entries.begin(); - 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) { - --pos; - if (pos->Contains(range)) { - return &(*pos); - } - } - } - return nullptr; - } - - Entry *Back() { return (m_entries.empty() ? nullptr : &m_entries.back()); } - - const Entry *Back() const { - return (m_entries.empty() ? nullptr : &m_entries.back()); - } - -protected: - Collection m_entries; -}; - -// Same as RangeDataArray, but uses std::vector as to not require static -// storage of N items in the class itself -template <typename B, typename S, typename T> class RangeDataVector { -public: - typedef RangeData<B, S, T> Entry; - typedef std::vector<Entry> Collection; - RangeDataVector() = default; ~RangeDataVector() = default; @@ -895,38 +700,8 @@ public: } } - // Calculate the byte size of ranges with zero byte sizes by finding the next - // entry with a base address > the current base address - void CalculateSizesOfZeroByteSizeRanges(S full_size = 0) { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - typename Collection::iterator pos; - typename Collection::iterator end; - typename Collection::iterator next; - for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos) { - if (pos->GetByteSize() == 0) { - // Watch out for multiple entries with same address and make sure we - // find an entry that is greater than the current base address before - // we use that for the size - auto curr_base = pos->GetRangeBase(); - for (next = pos + 1; next != end; ++next) { - auto next_base = next->GetRangeBase(); - if (next_base > curr_base) { - pos->SetByteSize(next_base - curr_base); - break; - } - } - if (next == end && full_size > curr_base) - pos->SetByteSize(full_size - curr_base); - } - } - } - void Clear() { m_entries.clear(); } - void Reserve(typename Collection::size_type size) { m_entries.resize(size); } - bool IsEmpty() const { return m_entries.empty(); } size_t GetSize() const { return m_entries.size(); } @@ -948,22 +723,9 @@ public: } uint32_t FindEntryIndexThatContains(B addr) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry(addr, 1); - typename Collection::const_iterator begin = m_entries.begin(); - 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); - } + const Entry *entry = FindEntryThatContains(addr); + if (entry) + return std::distance(m_entries.begin(), entry); return UINT32_MAX; } @@ -983,47 +745,13 @@ public: } Entry *FindEntryThatContains(B addr) { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry; - entry.SetRangeBase(addr); - entry.SetByteSize(1); - 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); - } - return nullptr; + return const_cast<Entry *>( + static_cast<const RangeDataVector *>(this)->FindEntryThatContains( + addr)); } const Entry *FindEntryThatContains(B addr) const { -#ifdef ASSERT_RANGEMAP_ARE_SORTED - assert(IsSorted()); -#endif - if (!m_entries.empty()) { - Entry entry; - entry.SetRangeBase(addr); - entry.SetByteSize(1); - typename Collection::const_iterator begin = m_entries.begin(); - 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 &(*pos); - } - return nullptr; + return FindEntryThatContains(Entry(addr, 1)); } const Entry *FindEntryThatContains(const Entry &range) const { diff --git a/include/lldb/Core/RichManglingContext.h b/include/lldb/Core/RichManglingContext.h new file mode 100644 index 000000000000..30841bfb2668 --- /dev/null +++ b/include/lldb/Core/RichManglingContext.h @@ -0,0 +1,108 @@ +//===-- RichManglingContext.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_RichManglingContext_h_ +#define liblldb_RichManglingContext_h_ + +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private.h" + +#include "lldb/Utility/ConstString.h" + +#include "llvm/ADT/Any.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/Demangle/Demangle.h" + +namespace lldb_private { + +/// Uniform wrapper for access to rich mangling information from different +/// providers. See Mangled::DemangleWithRichManglingInfo() +class RichManglingContext { +public: + RichManglingContext() : m_provider(None), m_ipd_buf_size(2048) { + m_ipd_buf = static_cast<char *>(std::malloc(m_ipd_buf_size)); + m_ipd_buf[0] = '\0'; + } + + ~RichManglingContext() { std::free(m_ipd_buf); } + + /// Use the ItaniumPartialDemangler to obtain rich mangling information from + /// the given mangled name. + bool FromItaniumName(const ConstString &mangled); + + /// Use the legacy language parser implementation to obtain rich mangling + /// information from the given demangled name. + bool FromCxxMethodName(const ConstString &demangled); + + /// If this symbol describes a constructor or destructor. + bool IsCtorOrDtor() const; + + /// If this symbol describes a function. + bool IsFunction() const; + + /// Get the base name of a function. This doesn't include trailing template + /// arguments, ie "a::b<int>" gives "b". The result will overwrite the + /// internal buffer. It can be obtained via GetBufferRef(). + void ParseFunctionBaseName(); + + /// Get the context name for a function. For "a::b::c", this function returns + /// "a::b". The result will overwrite the internal buffer. It can be obtained + /// via GetBufferRef(). + void ParseFunctionDeclContextName(); + + /// Get the entire demangled name. The result will overwrite the internal + /// buffer. It can be obtained via GetBufferRef(). + void ParseFullName(); + + /// Obtain a StringRef to the internal buffer that holds the result of the + /// most recent ParseXy() operation. The next ParseXy() call invalidates it. + llvm::StringRef GetBufferRef() const { + assert(m_provider != None && "Initialize a provider first"); + return m_buffer; + } + +private: + enum InfoProvider { None, ItaniumPartialDemangler, PluginCxxLanguage }; + + /// Selects the rich mangling info provider. + InfoProvider m_provider; + + /// Reference to the buffer used for results of ParseXy() operations. + llvm::StringRef m_buffer; + + /// Members for ItaniumPartialDemangler + llvm::ItaniumPartialDemangler m_ipd; + char *m_ipd_buf; + size_t m_ipd_buf_size; + + /// Members for PluginCxxLanguage + /// Cannot forward declare inner class CPlusPlusLanguage::MethodName. The + /// respective header is in Plugins and including it from here causes cyclic + /// dependency. Instead keep a llvm::Any and cast it on-access in the cpp. + llvm::Any m_cxx_method_parser; + + /// Clean up memory and set a new info provider for this instance. + void ResetProvider(InfoProvider new_provider); + + /// Uniform handling of string buffers for ItaniumPartialDemangler. + void processIPDStrResult(char *ipd_res, size_t res_len); + + /// Cast the given parser to the given type. Ideally we would have a type + /// trait to deduce \a ParserT from a given InfoProvider, but unfortunately we + /// can't access CPlusPlusLanguage::MethodName from within the header. + template <class ParserT> static ParserT *get(llvm::Any parser) { + assert(parser.hasValue()); + assert(llvm::any_isa<ParserT *>(parser)); + return llvm::any_cast<ParserT *>(parser); + } +}; + +} // namespace lldb_private + +#endif diff --git a/include/lldb/Core/STLUtils.h b/include/lldb/Core/STLUtils.h index 55f1ac05c975..0ed354fa4e32 100644 --- a/include/lldb/Core/STLUtils.h +++ b/include/lldb/Core/STLUtils.h @@ -10,16 +10,12 @@ #ifndef liblldb_STLUtils_h_ #define liblldb_STLUtils_h_ -// C Includes #include <string.h> -// C++ Includes #include <map> #include <ostream> #include <vector> -// Other libraries and framework includes -// Project includes //---------------------------------------------------------------------- // C string less than compare function object diff --git a/include/lldb/Core/SearchFilter.h b/include/lldb/Core/SearchFilter.h index 2e641983dc73..f53ef658fd3f 100644 --- a/include/lldb/Core/SearchFilter.h +++ b/include/lldb/Core/SearchFilter.h @@ -13,10 +13,10 @@ #include "lldb/Core/FileSpecList.h" #include "lldb/Utility/StructuredData.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/lldb-forward.h" // for SearchFilterSP, TargetSP, Modu... +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-forward.h" -#include <stdint.h> // for uint32_t +#include <stdint.h> namespace lldb_private { class Address; @@ -70,15 +70,6 @@ public: eCallbackReturnPop // Pop one level up and continue iterating } CallbackReturn; - typedef enum { - eDepthTarget, - eDepthModule, - eDepthCompUnit, - eDepthFunction, - eDepthBlock, - eDepthAddress - } Depth; - Searcher(); virtual ~Searcher(); @@ -87,7 +78,7 @@ public: SymbolContext &context, Address *addr, bool complete) = 0; - virtual Depth GetDepth() = 0; + virtual lldb::SearchDepth GetDepth() = 0; //------------------------------------------------------------------ /// Prints a canonical description for the searcher to the stream \a s. @@ -193,6 +184,18 @@ public: virtual bool CompUnitPasses(CompileUnit &compUnit); //------------------------------------------------------------------ + /// Call this method with a Function to see if \a function passes the + /// filter. + /// + /// @param[in] function + /// The Functions to check against the filter. + /// + /// @return + /// \b true if \a function passes, and \b false otherwise. + //------------------------------------------------------------------ + virtual bool FunctionPasses(Function &function); + + //------------------------------------------------------------------ /// Call this method to do the search using the Searcher. /// /// @param[in] searcher diff --git a/include/lldb/Core/Section.h b/include/lldb/Core/Section.h index 8e275ce3199e..4157bb877b4c 100644 --- a/include/lldb/Core/Section.h +++ b/include/lldb/Core/Section.h @@ -14,16 +14,16 @@ #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Flags.h" #include "lldb/Utility/UserID.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for SectionType -#include "lldb/lldb-forward.h" // for SectionSP, ModuleSP, SectionWP -#include "lldb/lldb-types.h" // for addr_t, offset_t, user_id_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" -#include <memory> // for enable_shared_from_this -#include <vector> // for vector +#include <memory> +#include <vector> -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, UINT32_MAX +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class Address; diff --git a/include/lldb/Core/SourceManager.h b/include/lldb/Core/SourceManager.h index ef652531244d..d31ba037c5d6 100644 --- a/include/lldb/Core/SourceManager.h +++ b/include/lldb/Core/SourceManager.h @@ -11,16 +11,16 @@ #define liblldb_SourceManager_h_ #include "lldb/Utility/FileSpec.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for DebuggerSP, DebuggerWP, DataBufferSP +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" #include "llvm/Support/Chrono.h" -#include <cstdint> // for uint32_t, UINT32_MAX +#include <cstdint> #include <map> #include <memory> -#include <stddef.h> // for size_t -#include <string> // for string +#include <stddef.h> +#include <string> #include <vector> namespace lldb_private { @@ -52,7 +52,7 @@ public: void UpdateIfNeeded(); - size_t DisplaySourceLines(uint32_t line, uint32_t column, + size_t DisplaySourceLines(uint32_t line, llvm::Optional<size_t> column, uint32_t context_before, uint32_t context_after, Stream *s); void FindLinesMatchingRegex(RegularExpression ®ex, uint32_t start_line, diff --git a/include/lldb/Core/StreamAsynchronousIO.h b/include/lldb/Core/StreamAsynchronousIO.h index 29b109757da7..89667be05878 100644 --- a/include/lldb/Core/StreamAsynchronousIO.h +++ b/include/lldb/Core/StreamAsynchronousIO.h @@ -14,7 +14,7 @@ #include <string> -#include <stddef.h> // for size_t +#include <stddef.h> namespace lldb_private { class Debugger; @@ -30,7 +30,8 @@ public: void Flush() override; - size_t Write(const void *src, size_t src_len) override; +protected: + size_t WriteImpl(const void *src, size_t src_len) override; private: Debugger &m_debugger; diff --git a/include/lldb/Core/StreamBuffer.h b/include/lldb/Core/StreamBuffer.h index 307dc7e18a5e..7b2468330ad2 100644 --- a/include/lldb/Core/StreamBuffer.h +++ b/include/lldb/Core/StreamBuffer.h @@ -30,12 +30,6 @@ public: // Nothing to do when flushing a buffer based stream... } - virtual size_t Write(const void *s, size_t length) { - if (s && length) - m_packet.append((const char *)s, ((const char *)s) + length); - return length; - } - void Clear() { m_packet.clear(); } // Beware, this might not be NULL terminated as you can expect from @@ -48,6 +42,12 @@ public: protected: llvm::SmallVector<char, N> m_packet; + + virtual size_t WriteImpl(const void *s, size_t length) { + if (s && length) + m_packet.append((const char *)s, ((const char *)s) + length); + return length; + } }; } // namespace lldb_private diff --git a/include/lldb/Core/StreamFile.h b/include/lldb/Core/StreamFile.h index a26ae84c7be5..86db3e4ae487 100644 --- a/include/lldb/Core/StreamFile.h +++ b/include/lldb/Core/StreamFile.h @@ -12,11 +12,11 @@ #include "lldb/Host/File.h" #include "lldb/Utility/Stream.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for FilePermissions::eFilePermission... +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" -#include <stdint.h> // for uint32_t -#include <stdio.h> // for size_t, FILE +#include <stdint.h> +#include <stdio.h> namespace lldb_private { @@ -46,13 +46,13 @@ public: void Flush() override; - size_t Write(const void *s, size_t length) override; protected: //------------------------------------------------------------------ // Classes that inherit from StreamFile can see and modify these //------------------------------------------------------------------ File m_file; + size_t WriteImpl(const void *s, size_t length) override; private: DISALLOW_COPY_AND_ASSIGN(StreamFile); diff --git a/include/lldb/Core/StructuredDataImpl.h b/include/lldb/Core/StructuredDataImpl.h index 819d1d9e5d2f..2912f4ec7de0 100644 --- a/include/lldb/Core/StructuredDataImpl.h +++ b/include/lldb/Core/StructuredDataImpl.h @@ -10,8 +10,8 @@ #ifndef liblldb_StructuredDataImpl_h_ #define liblldb_StructuredDataImpl_h_ -#include "lldb/Core/Event.h" #include "lldb/Target/StructuredDataPlugin.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" diff --git a/include/lldb/Core/ThreadSafeDenseMap.h b/include/lldb/Core/ThreadSafeDenseMap.h index 9b52e0355314..2fc428c4f7d4 100644 --- a/include/lldb/Core/ThreadSafeDenseMap.h +++ b/include/lldb/Core/ThreadSafeDenseMap.h @@ -11,14 +11,10 @@ #ifndef liblldb_ThreadSafeDenseMap_h_ #define liblldb_ThreadSafeDenseMap_h_ -// C Includes -// C++ Includes #include <mutex> -// Other libraries and framework includes #include "llvm/ADT/DenseMap.h" -// Project includes namespace lldb_private { diff --git a/include/lldb/Core/ThreadSafeDenseSet.h b/include/lldb/Core/ThreadSafeDenseSet.h index 44ec2464385f..74a010544705 100644 --- a/include/lldb/Core/ThreadSafeDenseSet.h +++ b/include/lldb/Core/ThreadSafeDenseSet.h @@ -11,14 +11,10 @@ #ifndef liblldb_ThreadSafeDenseSet_h_ #define liblldb_ThreadSafeDenseSet_h_ -// C Includes -// C++ Includes #include <mutex> -// Other libraries and framework includes #include "llvm/ADT/DenseSet.h" -// Project includes namespace lldb_private { diff --git a/include/lldb/Core/ThreadSafeSTLMap.h b/include/lldb/Core/ThreadSafeSTLMap.h index 5520920c4559..4058fdfe15a8 100644 --- a/include/lldb/Core/ThreadSafeSTLMap.h +++ b/include/lldb/Core/ThreadSafeSTLMap.h @@ -10,13 +10,9 @@ #ifndef liblldb_ThreadSafeSTLMap_h_ #define liblldb_ThreadSafeSTLMap_h_ -// C Includes -// C++ Includes #include <map> #include <mutex> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-defines.h" namespace lldb_private { diff --git a/include/lldb/Core/ThreadSafeSTLVector.h b/include/lldb/Core/ThreadSafeSTLVector.h index 466f4309c2d5..b65936f81fec 100644 --- a/include/lldb/Core/ThreadSafeSTLVector.h +++ b/include/lldb/Core/ThreadSafeSTLVector.h @@ -11,13 +11,9 @@ #ifndef liblldb_ThreadSafeSTLVector_h_ #define liblldb_ThreadSafeSTLVector_h_ -// C Includes -// C++ Includes #include <mutex> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-defines.h" namespace lldb_private { diff --git a/include/lldb/Core/ThreadSafeValue.h b/include/lldb/Core/ThreadSafeValue.h index 10ef8fa41d0c..35424a1791e6 100644 --- a/include/lldb/Core/ThreadSafeValue.h +++ b/include/lldb/Core/ThreadSafeValue.h @@ -10,13 +10,9 @@ #ifndef liblldb_ThreadSafeValue_h_ #define liblldb_ThreadSafeValue_h_ -// C Includes -// C++ Includes #include <mutex> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-defines.h" namespace lldb_private { diff --git a/include/lldb/Core/UniqueCStringMap.h b/include/lldb/Core/UniqueCStringMap.h index fe3e831a6045..cfb84b4c2160 100644 --- a/include/lldb/Core/UniqueCStringMap.h +++ b/include/lldb/Core/UniqueCStringMap.h @@ -10,13 +10,9 @@ #ifndef liblldb_UniqueCStringMap_h_ #define liblldb_UniqueCStringMap_h_ -// C Includes -// C++ Includes #include <algorithm> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/ConstString.h" #include "lldb/Utility/RegularExpression.h" @@ -221,7 +217,7 @@ public: // } // my_map.Sort(); //------------------------------------------------------------------ - void Sort() { std::sort(m_map.begin(), m_map.end()); } + void Sort() { llvm::sort(m_map.begin(), m_map.end()); } //------------------------------------------------------------------ // Since we are using a vector to contain our items it will always double its diff --git a/include/lldb/Core/UserSettingsController.h b/include/lldb/Core/UserSettingsController.h index aefd42e751ab..350b5babb47b 100644 --- a/include/lldb/Core/UserSettingsController.h +++ b/include/lldb/Core/UserSettingsController.h @@ -10,16 +10,16 @@ #ifndef liblldb_UserSettingsController_h_ #define liblldb_UserSettingsController_h_ -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-forward.h" // for OptionValuePropertiesSP -#include "lldb/lldb-private-enumerations.h" // for VarSetOperationType +#include "lldb/Utility/Status.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #include <vector> -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class CommandInterpreter; diff --git a/include/lldb/Core/Value.h b/include/lldb/Core/Value.h index 801e818c6f5c..249adb24fbc9 100644 --- a/include/lldb/Core/Value.h +++ b/include/lldb/Core/Value.h @@ -10,20 +10,20 @@ #ifndef liblldb_Value_h_ #define liblldb_Value_h_ -#include "lldb/Core/Scalar.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Utility/DataBufferHeap.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" -#include "lldb/lldb-enumerations.h" // for ByteOrder, ByteOrder::eB... -#include "lldb/lldb-private-enumerations.h" // for AddressType -#include "lldb/lldb-private-types.h" // for type128, RegisterInfo +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-private-types.h" -#include "llvm/ADT/APInt.h" // for APInt +#include "llvm/ADT/APInt.h" #include <vector> -#include <stdint.h> // for uint8_t, uint32_t, uint64_t -#include <string.h> // for size_t, memcpy +#include <stdint.h> +#include <string.h> namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h index fddc06413196..cb6de7b41807 100644 --- a/include/lldb/Core/ValueObject.h +++ b/include/lldb/Core/ValueObject.h @@ -12,7 +12,7 @@ #include "lldb/Core/Value.h" #include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/Type.h" // for TypeImpl +#include "lldb/Symbol/Type.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" @@ -20,26 +20,26 @@ #include "lldb/Utility/SharedCluster.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/UserID.h" -#include "lldb/lldb-defines.h" // for LLDB_INVALID... -#include "lldb/lldb-enumerations.h" // for DynamicValue... -#include "lldb/lldb-forward.h" // for ValueObjectSP -#include "lldb/lldb-private-enumerations.h" // for AddressType -#include "lldb/lldb-types.h" // for addr_t, offs... +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #include <functional> #include <initializer_list> #include <map> -#include <mutex> // for recursive_mutex -#include <string> // for string -#include <utility> // for pair +#include <mutex> +#include <string> +#include <utility> -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class Declaration; } @@ -635,9 +635,6 @@ public: virtual void SetLiveAddress(lldb::addr_t addr = LLDB_INVALID_ADDRESS, AddressType address_type = eAddressTypeLoad) {} - // Find the address of the C++ vtable pointer - virtual lldb::addr_t GetCPPVTableAddress(AddressType &address_type); - virtual lldb::ValueObjectSP Cast(const CompilerType &compiler_type); virtual lldb::ValueObjectSP CastPointerType(const char *name, diff --git a/include/lldb/Core/ValueObjectCast.h b/include/lldb/Core/ValueObjectCast.h index aaa1ecb67db8..34814d9b17bb 100644 --- a/include/lldb/Core/ValueObjectCast.h +++ b/include/lldb/Core/ValueObjectCast.h @@ -11,13 +11,13 @@ #define liblldb_ValueObjectCast_h_ #include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ValueType -#include "lldb/lldb-forward.h" // for ValueObjectSP +#include "lldb/Symbol/CompilerType.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class ConstString; diff --git a/include/lldb/Core/ValueObjectChild.h b/include/lldb/Core/ValueObjectChild.h index ec8c9e805cdf..6800775dc8f9 100644 --- a/include/lldb/Core/ValueObjectChild.h +++ b/include/lldb/Core/ValueObjectChild.h @@ -12,17 +12,17 @@ #include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ValueType -#include "lldb/lldb-private-enumerations.h" // for LazyBool, AddressType -#include "lldb/lldb-types.h" // for offset_t +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" #include "llvm/ADT/Optional.h" -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t, int32_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { diff --git a/include/lldb/Core/ValueObjectConstResult.h b/include/lldb/Core/ValueObjectConstResult.h index 1f56129df24a..c1c56d8dcb22 100644 --- a/include/lldb/Core/ValueObjectConstResult.h +++ b/include/lldb/Core/ValueObjectConstResult.h @@ -10,20 +10,20 @@ #ifndef liblldb_ValueObjectConstResult_h_ #define liblldb_ValueObjectConstResult_h_ -#include "lldb/Core/Value.h" // for Value +#include "lldb/Core/Value.h" #include "lldb/Core/ValueObject.h" #include "lldb/Core/ValueObjectConstResultImpl.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-enumerations.h" // for ByteOrder, Dynamic... -#include "lldb/lldb-forward.h" // for ValueObjectSP, Dat... -#include "lldb/lldb-private-enumerations.h" // for AddressType, Addre... -#include "lldb/lldb-types.h" // for addr_t - -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Status.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" + +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/ValueObjectConstResultCast.h b/include/lldb/Core/ValueObjectConstResultCast.h index 442cce420855..bb2b4e6f092f 100644 --- a/include/lldb/Core/ValueObjectConstResultCast.h +++ b/include/lldb/Core/ValueObjectConstResultCast.h @@ -12,14 +12,14 @@ #include "lldb/Core/ValueObjectCast.h" #include "lldb/Core/ValueObjectConstResultImpl.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_... -#include "lldb/lldb-forward.h" // for ValueObjectSP -#include "lldb/lldb-types.h" // for addr_t - -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, int32_t +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" + +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/ValueObjectConstResultChild.h b/include/lldb/Core/ValueObjectConstResultChild.h index a74da0013aba..f14fb75640e6 100644 --- a/include/lldb/Core/ValueObjectConstResultChild.h +++ b/include/lldb/Core/ValueObjectConstResultChild.h @@ -12,14 +12,14 @@ #include "lldb/Core/ValueObjectChild.h" #include "lldb/Core/ValueObjectConstResultImpl.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_... -#include "lldb/lldb-forward.h" // for ValueObjectSP -#include "lldb/lldb-types.h" // for addr_t - -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, int32_t +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" + +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class DataExtractor; } @@ -63,6 +63,9 @@ public: lldb::ValueObjectSP AddressOf(Status &error) override; + lldb::addr_t GetAddressOf(bool scalar_is_load_address = true, + AddressType *address_type = nullptr) override; + size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0, uint32_t item_count = 1) override; diff --git a/include/lldb/Core/ValueObjectConstResultImpl.h b/include/lldb/Core/ValueObjectConstResultImpl.h index d86f25e30579..5ea47bb3b3fa 100644 --- a/include/lldb/Core/ValueObjectConstResultImpl.h +++ b/include/lldb/Core/ValueObjectConstResultImpl.h @@ -10,14 +10,14 @@ #ifndef liblldb_ValueObjectConstResultImpl_h_ #define liblldb_ValueObjectConstResultImpl_h_ -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-forward.h" // for ValueObjectSP -#include "lldb/lldb-private-enumerations.h" // for AddressType, AddressType... -#include "lldb/lldb-types.h" // for addr_t - -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, int32_t +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" + +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class CompilerType; } diff --git a/include/lldb/Core/ValueObjectDynamicValue.h b/include/lldb/Core/ValueObjectDynamicValue.h index 018ee2c764bf..0c9ec8cce06e 100644 --- a/include/lldb/Core/ValueObjectDynamicValue.h +++ b/include/lldb/Core/ValueObjectDynamicValue.h @@ -10,20 +10,20 @@ #ifndef liblldb_ValueObjectDynamicValue_h_ #define liblldb_ValueObjectDynamicValue_h_ -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h" #include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType +#include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/SharingPtr.h" // for operator== -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for DynamicValueType, Langua... -#include "lldb/lldb-forward.h" // for ValueObjectSP, VariableSP -#include "lldb/lldb-private-enumerations.h" // for LazyBool, LazyBool::eLaz... - -#include <assert.h> // for assert -#include <stddef.h> // for size_t -#include <stdint.h> // for uint64_t, uint32_t +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/SharingPtr.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" + +#include <assert.h> +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/ValueObjectList.h b/include/lldb/Core/ValueObjectList.h index a0d2e681dedb..d17510f7f581 100644 --- a/include/lldb/Core/ValueObjectList.h +++ b/include/lldb/Core/ValueObjectList.h @@ -10,12 +10,12 @@ #ifndef liblldb_ValueObjectList_h_ #define liblldb_ValueObjectList_h_ -#include "lldb/lldb-forward.h" // for ValueObjectSP -#include "lldb/lldb-types.h" // for user_id_t +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" #include <vector> -#include <stddef.h> // for size_t +#include <stddef.h> namespace lldb_private { class ValueObject; diff --git a/include/lldb/Core/ValueObjectMemory.h b/include/lldb/Core/ValueObjectMemory.h index 8bb649cc3c52..c4b946af98ce 100644 --- a/include/lldb/Core/ValueObjectMemory.h +++ b/include/lldb/Core/ValueObjectMemory.h @@ -10,17 +10,17 @@ #ifndef liblldb_ValueObjectMemory_h_ #define liblldb_ValueObjectMemory_h_ -#include "lldb/Core/Address.h" // for Address +#include "lldb/Core/Address.h" #include "lldb/Core/ValueObject.h" #include "lldb/Symbol/CompilerType.h" -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ValueType -#include "lldb/lldb-forward.h" // for TypeSP, ValueObjectSP, ModuleSP -#include "llvm/ADT/StringRef.h" // for StringRef - -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "llvm/ADT/StringRef.h" + +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class ExecutionContextScope; diff --git a/include/lldb/Core/ValueObjectRegister.h b/include/lldb/Core/ValueObjectRegister.h index 2aaef9bee99e..fb10c259e7d0 100644 --- a/include/lldb/Core/ValueObjectRegister.h +++ b/include/lldb/Core/ValueObjectRegister.h @@ -10,17 +10,17 @@ #ifndef liblldb_ValueObjectRegister_h_ #define liblldb_ValueObjectRegister_h_ -#include "lldb/Core/RegisterValue.h" #include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ValueType, ValueType::eValueTy... -#include "lldb/lldb-forward.h" // for RegisterContextSP, ValueObjectSP -#include "lldb/lldb-private-types.h" // for RegisterInfo, RegisterSet (ptr... - -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t, int32_t +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/RegisterValue.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-types.h" + +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class DataExtractor; diff --git a/include/lldb/Core/ValueObjectSyntheticFilter.h b/include/lldb/Core/ValueObjectSyntheticFilter.h index b3af6c0ae827..9495d4ca5e25 100644 --- a/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -13,17 +13,17 @@ #include "lldb/Core/ThreadSafeSTLMap.h" #include "lldb/Core/ThreadSafeSTLVector.h" #include "lldb/Core/ValueObject.h" -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for ThreadSafeSTLMap::operator= -#include "lldb/lldb-enumerations.h" // for DynamicValueType, Langua... -#include "lldb/lldb-forward.h" // for ValueObjectSP, Synthetic... -#include "lldb/lldb-private-enumerations.h" // for LazyBool, LazyBool::eLaz... - -#include <cstdint> // for uint32_t, uint64_t +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" + +#include <cstdint> #include <memory> -#include <stddef.h> // for size_t +#include <stddef.h> namespace lldb_private { class Declaration; diff --git a/include/lldb/Core/ValueObjectVariable.h b/include/lldb/Core/ValueObjectVariable.h index 9dd140a84f45..81a8eabdacbb 100644 --- a/include/lldb/Core/ValueObjectVariable.h +++ b/include/lldb/Core/ValueObjectVariable.h @@ -12,15 +12,15 @@ #include "lldb/Core/ValueObject.h" -#include "lldb/Core/Value.h" // for Value -#include "lldb/Symbol/CompilerType.h" // for CompilerType -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ValueType -#include "lldb/lldb-forward.h" // for VariableSP, ModuleSP, ValueObj... - -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t +#include "lldb/Core/Value.h" +#include "lldb/Symbol/CompilerType.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" + +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class DataExtractor; diff --git a/include/lldb/DataFormatters/DataVisualization.h b/include/lldb/DataFormatters/DataVisualization.h index 369fa686a9ff..9ca2e95cd9cb 100644 --- a/include/lldb/DataFormatters/DataVisualization.h +++ b/include/lldb/DataFormatters/DataVisualization.h @@ -10,11 +10,7 @@ #ifndef lldb_DataVisualization_h_ #define lldb_DataVisualization_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/FormatClasses.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Utility/ConstString.h" diff --git a/include/lldb/DataFormatters/DumpValueObjectOptions.h b/include/lldb/DataFormatters/DumpValueObjectOptions.h index 00baea77f793..113c48afa6f8 100644 --- a/include/lldb/DataFormatters/DumpValueObjectOptions.h +++ b/include/lldb/DataFormatters/DumpValueObjectOptions.h @@ -10,12 +10,8 @@ #ifndef lldb_DumpValueObjectOptions_h_ #define lldb_DumpValueObjectOptions_h_ -// C Includes -// C++ Includes #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/FormatCache.h b/include/lldb/DataFormatters/FormatCache.h index 9901ec91ebd2..2c09b65a420a 100644 --- a/include/lldb/DataFormatters/FormatCache.h +++ b/include/lldb/DataFormatters/FormatCache.h @@ -11,13 +11,9 @@ #ifndef lldb_FormatCache_h_ #define lldb_FormatCache_h_ -// C Includes -// C++ Includes #include <map> #include <mutex> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/ConstString.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/FormatClasses.h b/include/lldb/DataFormatters/FormatClasses.h index 458477578d3f..1f08485d0292 100644 --- a/include/lldb/DataFormatters/FormatClasses.h +++ b/include/lldb/DataFormatters/FormatClasses.h @@ -10,15 +10,11 @@ #ifndef lldb_FormatClasses_h_ #define lldb_FormatClasses_h_ -// C Includes -// C++ Includes #include <functional> #include <memory> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/TypeFormat.h" #include "lldb/DataFormatters/TypeSummary.h" #include "lldb/DataFormatters/TypeSynthetic.h" diff --git a/include/lldb/DataFormatters/FormatManager.h b/include/lldb/DataFormatters/FormatManager.h index e973c8b3e849..9046ccf2e0bb 100644 --- a/include/lldb/DataFormatters/FormatManager.h +++ b/include/lldb/DataFormatters/FormatManager.h @@ -10,16 +10,12 @@ #ifndef lldb_FormatManager_h_ #define lldb_FormatManager_h_ -// C Includes -// C++ Includes #include <atomic> #include <initializer_list> #include <map> #include <mutex> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/FormattersContainer.h b/include/lldb/DataFormatters/FormattersContainer.h index df88e88011fe..dd8995d81132 100644 --- a/include/lldb/DataFormatters/FormattersContainer.h +++ b/include/lldb/DataFormatters/FormattersContainer.h @@ -10,16 +10,12 @@ #ifndef lldb_FormattersContainer_h_ #define lldb_FormattersContainer_h_ -// C Includes -// C++ Includes #include <functional> #include <map> #include <memory> #include <mutex> #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-public.h" #include "lldb/Core/ValueObject.h" diff --git a/include/lldb/DataFormatters/FormattersHelpers.h b/include/lldb/DataFormatters/FormattersHelpers.h index 14ba5e48feb4..028d5cc27688 100644 --- a/include/lldb/DataFormatters/FormattersHelpers.h +++ b/include/lldb/DataFormatters/FormattersHelpers.h @@ -11,10 +11,6 @@ #ifndef lldb_FormattersHelpers_h_ #define lldb_FormattersHelpers_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" diff --git a/include/lldb/DataFormatters/LanguageCategory.h b/include/lldb/DataFormatters/LanguageCategory.h index e94429407837..f2ac628636d4 100644 --- a/include/lldb/DataFormatters/LanguageCategory.h +++ b/include/lldb/DataFormatters/LanguageCategory.h @@ -11,11 +11,7 @@ #ifndef lldb_LanguageCategory_h_ #define lldb_LanguageCategory_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/DataFormatters/FormatCache.h" #include "lldb/DataFormatters/FormatClasses.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/StringPrinter.h b/include/lldb/DataFormatters/StringPrinter.h index 18207921bb71..38033f915bf9 100644 --- a/include/lldb/DataFormatters/StringPrinter.h +++ b/include/lldb/DataFormatters/StringPrinter.h @@ -10,13 +10,9 @@ #ifndef liblldb_StringPrinter_h_ #define liblldb_StringPrinter_h_ -// C Includes -// C++ Includes #include <functional> #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-forward.h" #include "lldb/Utility/DataExtractor.h" diff --git a/include/lldb/DataFormatters/TypeCategory.h b/include/lldb/DataFormatters/TypeCategory.h index 0a5b09baa624..177e602e6ec3 100644 --- a/include/lldb/DataFormatters/TypeCategory.h +++ b/include/lldb/DataFormatters/TypeCategory.h @@ -10,16 +10,12 @@ #ifndef lldb_TypeCategory_h_ #define lldb_TypeCategory_h_ -// C Includes -// C++ Includes #include <initializer_list> #include <memory> #include <mutex> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" @@ -348,7 +344,7 @@ public: bool IsEnabled() const { return m_enabled; } uint32_t GetEnabledPosition() { - if (m_enabled == false) + if (!m_enabled) return UINT32_MAX; else return m_enabled_position; diff --git a/include/lldb/DataFormatters/TypeCategoryMap.h b/include/lldb/DataFormatters/TypeCategoryMap.h index f767c985ff34..0ff078edf51b 100644 --- a/include/lldb/DataFormatters/TypeCategoryMap.h +++ b/include/lldb/DataFormatters/TypeCategoryMap.h @@ -10,15 +10,11 @@ #ifndef lldb_TypeCategoryMap_h_ #define lldb_TypeCategoryMap_h_ -// C Includes -// C++ Includes #include <functional> #include <list> #include <map> #include <mutex> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/TypeFormat.h b/include/lldb/DataFormatters/TypeFormat.h index 77e3542f5522..57ef0cf942cb 100644 --- a/include/lldb/DataFormatters/TypeFormat.h +++ b/include/lldb/DataFormatters/TypeFormat.h @@ -11,16 +11,12 @@ #ifndef lldb_TypeFormat_h_ #define lldb_TypeFormat_h_ -// C Includes -// C++ Includes #include <functional> #include <string> #include <unordered_map> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h index 17cd61ae8c1e..78947728be29 100644 --- a/include/lldb/DataFormatters/TypeSummary.h +++ b/include/lldb/DataFormatters/TypeSummary.h @@ -10,16 +10,12 @@ #ifndef lldb_TypeSummary_h_ #define lldb_TypeSummary_h_ -// C Includes #include <stdint.h> -// C++ Includes #include <functional> #include <memory> #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/TypeSynthetic.h b/include/lldb/DataFormatters/TypeSynthetic.h index 07dacd670a62..a9025fdb5397 100644 --- a/include/lldb/DataFormatters/TypeSynthetic.h +++ b/include/lldb/DataFormatters/TypeSynthetic.h @@ -10,18 +10,14 @@ #ifndef lldb_TypeSynthetic_h_ #define lldb_TypeSynthetic_h_ -// C Includes #include <stdint.h> -// C++ Includes #include <functional> #include <initializer_list> #include <memory> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/TypeValidator.h b/include/lldb/DataFormatters/TypeValidator.h index fa2a89148118..a50949cf22fe 100644 --- a/include/lldb/DataFormatters/TypeValidator.h +++ b/include/lldb/DataFormatters/TypeValidator.h @@ -11,15 +11,11 @@ #ifndef lldb_TypeValidator_h_ #define lldb_TypeValidator_h_ -// C Includes -// C++ Includes #include <functional> #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-private-enumerations.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/DataFormatters/ValueObjectPrinter.h b/include/lldb/DataFormatters/ValueObjectPrinter.h index 67048a4932cf..13124c9210c8 100644 --- a/include/lldb/DataFormatters/ValueObjectPrinter.h +++ b/include/lldb/DataFormatters/ValueObjectPrinter.h @@ -11,11 +11,7 @@ #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" @@ -24,10 +20,6 @@ #include "lldb/DataFormatters/DumpValueObjectOptions.h" #include "lldb/Symbol/CompilerType.h" -//#include <functional> -//#include <memory> -//#include <set> - namespace lldb_private { class ValueObjectPrinter { diff --git a/include/lldb/Expression/DWARFExpression.h b/include/lldb/Expression/DWARFExpression.h index b4bd9697da58..cdede56d86d9 100644 --- a/include/lldb/Expression/DWARFExpression.h +++ b/include/lldb/Expression/DWARFExpression.h @@ -12,8 +12,8 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Disassembler.h" -#include "lldb/Core/Scalar.h" #include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private.h" #include <functional> @@ -40,7 +40,10 @@ public: enum LocationListFormat : uint8_t { NonLocationList, // Not a location list RegularLocationList, // Location list format used in non-split dwarf files - SplitDwarfLocationList, // Location list format used in split dwarf files + SplitDwarfLocationList, // Location list format used in pre-DWARF v5 split + // dwarf files (.debug_loc.dwo) + LocLists, // Location list format used in DWARF v5 + // (.debug_loclists/.debug_loclists.dwo). }; //------------------------------------------------------------------ @@ -153,6 +156,8 @@ public: bool Update_DW_OP_addr(lldb::addr_t file_addr); + void SetModule(const lldb::ModuleSP &module) { m_module_wp = module; } + bool ContainsThreadLocalStorage() const; bool LinkThreadLocalStorage( diff --git a/include/lldb/Expression/Expression.h b/include/lldb/Expression/Expression.h index 6b9363864722..162dcd3e4672 100644 --- a/include/lldb/Expression/Expression.h +++ b/include/lldb/Expression/Expression.h @@ -10,14 +10,10 @@ #ifndef liblldb_Expression_h_ #define liblldb_Expression_h_ -// C Includes -// C++ Includes #include <map> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Expression/ExpressionTypeSystemHelper.h" #include "lldb/lldb-forward.h" diff --git a/include/lldb/Expression/ExpressionParser.h b/include/lldb/Expression/ExpressionParser.h index 66957926650a..7d337bd00ca6 100644 --- a/include/lldb/Expression/ExpressionParser.h +++ b/include/lldb/Expression/ExpressionParser.h @@ -10,6 +10,7 @@ #ifndef liblldb_ExpressionParser_h_ #define liblldb_ExpressionParser_h_ +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-private-enumerations.h" #include "lldb/lldb-public.h" @@ -50,6 +51,41 @@ public: virtual ~ExpressionParser(){}; //------------------------------------------------------------------ + /// Attempts to find possible command line completions for the given + /// expression. + /// + /// @param[out] request + /// The completion request to fill out. The completion should be a string + /// that would complete the current token at the cursor position. + /// Note that the string in the list replaces the current token + /// in the command line. + /// + /// @param[in] line + /// The line with the completion cursor inside the expression as a string. + /// The first line in the expression has the number 0. + /// + /// @param[in] pos + /// The character position in the line with the completion cursor. + /// If the value is 0, then the cursor is on top of the first character + /// in the line (i.e. the user has requested completion from the start of + /// the expression). + /// + /// @param[in] typed_pos + /// The cursor position in the line as typed by the user. If the user + /// expression has not been transformed in some form (e.g. wrapping it + /// in a function body for C languages), then this is equal to the + /// 'pos' parameter. The semantics of this value are otherwise equal to + /// 'pos' (e.g. a value of 0 means the cursor is at start of the + /// expression). + /// + /// @return + /// True if we added any completion results to the output; + /// false otherwise. + //------------------------------------------------------------------ + virtual bool Complete(CompletionRequest &request, unsigned line, unsigned pos, + unsigned typed_pos) = 0; + + //------------------------------------------------------------------ /// Parse a single expression and convert it to IR using Clang. Don't wrap /// the expression in anything at all. /// diff --git a/include/lldb/Expression/ExpressionVariable.h b/include/lldb/Expression/ExpressionVariable.h index 89b0500faf9c..01e9c416e7c0 100644 --- a/include/lldb/Expression/ExpressionVariable.h +++ b/include/lldb/Expression/ExpressionVariable.h @@ -10,15 +10,11 @@ #ifndef liblldb_ExpressionVariable_h_ #define liblldb_ExpressionVariable_h_ -// C Includes -// C++ Includes #include <memory> #include <vector> -// Other libraries and framework includes #include "llvm/ADT/DenseMap.h" -// Project includes #include "lldb/Core/ValueObject.h" #include "lldb/Utility/ConstString.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/Expression/FunctionCaller.h b/include/lldb/Expression/FunctionCaller.h index c36263e34240..0ec7e202dac9 100644 --- a/include/lldb/Expression/FunctionCaller.h +++ b/include/lldb/Expression/FunctionCaller.h @@ -10,15 +10,11 @@ #ifndef liblldb_FunctionCaller_h_ #define liblldb_FunctionCaller_h_ -// C Includes -// C++ Includes #include <list> #include <memory> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/Address.h" #include "lldb/Core/Value.h" #include "lldb/Expression/Expression.h" diff --git a/include/lldb/Expression/IRExecutionUnit.h b/include/lldb/Expression/IRExecutionUnit.h index e73f8956d955..b966d135deab 100644 --- a/include/lldb/Expression/IRExecutionUnit.h +++ b/include/lldb/Expression/IRExecutionUnit.h @@ -10,18 +10,14 @@ #ifndef liblldb_IRExecutionUnit_h_ #define liblldb_IRExecutionUnit_h_ -// C Includes -// C++ Includes #include <atomic> #include <memory> #include <string> #include <vector> -// Other libraries and framework includes #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/IR/Module.h" -// Project includes #include "lldb/Expression/IRMemoryMap.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" @@ -112,7 +108,7 @@ public: void PopulateSectionList(lldb_private::ObjectFile *obj_file, lldb_private::SectionList §ion_list) override; - bool GetArchitecture(lldb_private::ArchSpec &arch) override; + ArchSpec GetArchitecture() override; lldb::ModuleSP GetJITModule(); diff --git a/include/lldb/Expression/IRMemoryMap.h b/include/lldb/Expression/IRMemoryMap.h index df8a03f4763f..026ca6b98110 100644 --- a/include/lldb/Expression/IRMemoryMap.h +++ b/include/lldb/Expression/IRMemoryMap.h @@ -39,7 +39,7 @@ public: IRMemoryMap(lldb::TargetSP target_sp); ~IRMemoryMap(); - enum AllocationPolicy { + enum AllocationPolicy : uint8_t { eAllocationPolicyInvalid = 0, ///< It is an error for an allocation to have this policy. eAllocationPolicyHostOnly, ///< This allocation was created in the host and @@ -91,32 +91,32 @@ protected: private: struct Allocation { lldb::addr_t - m_process_alloc; ///< The (unaligned) base for the remote allocation + m_process_alloc; ///< The (unaligned) base for the remote allocation. lldb::addr_t - m_process_start; ///< The base address of the allocation in the process - size_t m_size; ///< The size of the requested allocation - uint32_t m_permissions; ///< The access permissions on the memory in the - ///process. In the host, the memory is always - ///read/write. - uint8_t m_alignment; ///< The alignment of the requested allocation + m_process_start; ///< The base address of the allocation in the process. + size_t m_size; ///< The size of the requested allocation. DataBufferHeap m_data; - ///< Flags + /// Flags. Keep these grouped together to avoid structure padding. AllocationPolicy m_policy; bool m_leak; + uint8_t m_permissions; ///< The access permissions on the memory in the + /// process. In the host, the memory is always + /// read/write. + uint8_t m_alignment; ///< The alignment of the requested allocation. public: Allocation(lldb::addr_t process_alloc, lldb::addr_t process_start, size_t size, uint32_t permissions, uint8_t alignment, AllocationPolicy m_policy); - Allocation() - : m_process_alloc(LLDB_INVALID_ADDRESS), - m_process_start(LLDB_INVALID_ADDRESS), m_size(0), m_permissions(0), - m_alignment(0), m_data(), m_policy(eAllocationPolicyInvalid), - m_leak(false) {} + DISALLOW_COPY_AND_ASSIGN(Allocation); }; + static_assert(sizeof(Allocation) <= + (4 * sizeof(lldb::addr_t)) + sizeof(DataBufferHeap), + "IRMemoryMap::Allocation is larger than expected"); + lldb::ProcessWP m_process_wp; lldb::TargetWP m_target_wp; typedef std::map<lldb::addr_t, Allocation> AllocationMap; diff --git a/include/lldb/Expression/LLVMUserExpression.h b/include/lldb/Expression/LLVMUserExpression.h index a2f87e8a6e25..1ba822265fca 100644 --- a/include/lldb/Expression/LLVMUserExpression.h +++ b/include/lldb/Expression/LLVMUserExpression.h @@ -10,16 +10,12 @@ #ifndef liblldb_LLVMUserExpression_h #define liblldb_LLVMUserExpression_h -// C Includes -// C++ Includes #include <map> #include <string> #include <vector> -// Other libraries and framework includes #include "llvm/IR/LegacyPassManager.h" -// Project includes #include "lldb/Expression/UserExpression.h" namespace lldb_private { diff --git a/include/lldb/Expression/Materializer.h b/include/lldb/Expression/Materializer.h index b86bc656d6b5..0bdfd372e921 100644 --- a/include/lldb/Expression/Materializer.h +++ b/include/lldb/Expression/Materializer.h @@ -10,13 +10,9 @@ #ifndef liblldb_Materializer_h #define liblldb_Materializer_h -// C Includes -// C++ Includes #include <memory> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Expression/IRMemoryMap.h" #include "lldb/Symbol/TaggedASTType.h" #include "lldb/Target/StackFrame.h" diff --git a/include/lldb/Expression/REPL.h b/include/lldb/Expression/REPL.h index 0c1e97fec259..f7780772cbea 100644 --- a/include/lldb/Expression/REPL.h +++ b/include/lldb/Expression/REPL.h @@ -10,12 +10,8 @@ #ifndef lldb_REPL_h #define lldb_REPL_h -// C Includes -// C++ Includes #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/../../source/Commands/CommandObjectExpression.h" #include "lldb/Interpreter/OptionGroupFormat.h" #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" @@ -117,7 +113,7 @@ public: int IOHandlerComplete(IOHandler &io_handler, const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, - StringList &matches) override; + StringList &matches, StringList &descriptions) override; protected: static int CalculateActualIndentation(const StringList &lines); diff --git a/include/lldb/Expression/UserExpression.h b/include/lldb/Expression/UserExpression.h index 96ca80c882e5..812d7e9a0eac 100644 --- a/include/lldb/Expression/UserExpression.h +++ b/include/lldb/Expression/UserExpression.h @@ -10,14 +10,10 @@ #ifndef liblldb_UserExpression_h_ #define liblldb_UserExpression_h_ -// C Includes -// C++ Includes #include <memory> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/Address.h" #include "lldb/Expression/Expression.h" #include "lldb/Expression/Materializer.h" @@ -98,6 +94,34 @@ public: lldb_private::ExecutionPolicy execution_policy, bool keep_result_in_memory, bool generate_debug_info) = 0; + //------------------------------------------------------------------ + /// Attempts to find possible command line completions for the given + /// (possible incomplete) user expression. + /// + /// @param[in] exe_ctx + /// The execution context to use when looking up entities that + /// are needed for parsing and completing (locations of functions, types + /// of variables, persistent variables, etc.) + /// + /// @param[out] request + /// The completion request to fill out. The completion should be a string + /// that would complete the current token at the cursor position. + /// Note that the string in the list replaces the current token + /// in the command line. + /// + /// @param[in] complete_pos + /// The position of the cursor inside the user expression string. + /// The completion process starts on the token that the cursor is in. + /// + /// @return + /// True if we added any completion results to the output; + /// false otherwise. + //------------------------------------------------------------------ + virtual bool Complete(ExecutionContext &exe_ctx, CompletionRequest &request, + unsigned complete_pos) { + return false; + } + virtual bool CanInterpret() = 0; bool MatchesContext(ExecutionContext &exe_ctx); diff --git a/include/lldb/Expression/UtilityFunction.h b/include/lldb/Expression/UtilityFunction.h index 5d4bc8676b95..4c87f4d10479 100644 --- a/include/lldb/Expression/UtilityFunction.h +++ b/include/lldb/Expression/UtilityFunction.h @@ -11,13 +11,9 @@ #ifndef liblldb_UtilityFunction_h_ #define liblldb_UtilityFunction_h_ -// C Includes -// C++ Includes #include <memory> #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/Expression/Expression.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Host/Debug.h b/include/lldb/Host/Debug.h index ed8e633c113f..d88725cf4e2e 100644 --- a/include/lldb/Host/Debug.h +++ b/include/lldb/Host/Debug.h @@ -10,12 +10,8 @@ #ifndef liblldb_Debug_h_ #define liblldb_Debug_h_ -// C Includes -// C++ Includes #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Host/Editline.h b/include/lldb/Host/Editline.h index beb96e7c4924..51d6e58c1e7a 100644 --- a/include/lldb/Host/Editline.h +++ b/include/lldb/Host/Editline.h @@ -54,8 +54,8 @@ #include <vector> #include "lldb/Host/ConnectionFileDescriptor.h" -#include "lldb/Host/Predicate.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Predicate.h" namespace lldb_private { namespace line_editor { @@ -101,7 +101,8 @@ typedef int (*FixIndentationCallbackType)(Editline *editline, typedef int (*CompleteCallbackType)(const char *current_line, const char *cursor, const char *last_char, int skip_first_n_matches, int max_matches, - StringList &matches, void *baton); + StringList &matches, + StringList &descriptions, void *baton); /// Status used to decide when and how to start editing another line in /// multi-line sessions diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h index d240f810bc8b..69ae2004e422 100644 --- a/include/lldb/Host/File.h +++ b/include/lldb/Host/File.h @@ -33,6 +33,8 @@ public: static int kInvalidDescriptor; static FILE *kInvalidStream; + // NB this enum is used in the lldb platform gdb-remote packet + // vFile:open: and existing values cannot be modified. enum OpenOptions { eOpenOptionRead = (1u << 0), // Open file for reading eOpenOptionWrite = (1u << 1), // Open file for writing @@ -54,57 +56,15 @@ public: : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor), m_stream(kInvalidStream), m_options(0), m_own_stream(false), m_is_interactive(eLazyBoolCalculate), - m_is_real_terminal(eLazyBoolCalculate) {} + m_is_real_terminal(eLazyBoolCalculate), + m_supports_colors(eLazyBoolCalculate) {} File(FILE *fh, bool transfer_ownership) : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor), m_stream(fh), m_options(0), m_own_stream(transfer_ownership), m_is_interactive(eLazyBoolCalculate), - m_is_real_terminal(eLazyBoolCalculate) {} - - //------------------------------------------------------------------ - /// Constructor with path. - /// - /// Takes a path to a file which can be just a filename, or a full path. If - /// \a path is not nullptr or empty, this function will call File::Open - /// (const char *path, uint32_t options, uint32_t permissions). - /// - /// @param[in] path - /// The full or partial path to a 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 char *path, uint32_t options, - uint32_t permissions = lldb::eFilePermissionsFileDefault); - - //------------------------------------------------------------------ - /// 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 nullptr or empty, this function will call - /// File::Open (const char *path, uint32_t options, uint32_t permissions). - /// - /// @param[in] filespec - /// 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 = lldb::eFilePermissionsFileDefault); + m_is_real_terminal(eLazyBoolCalculate), + m_supports_colors(eLazyBoolCalculate) {} File(int fd, bool transfer_ownership) : IOObject(eFDTypeFile, transfer_ownership), m_descriptor(fd), @@ -167,23 +127,6 @@ public: //------------------------------------------------------------------ Status GetFileSpec(FileSpec &file_spec) const; - //------------------------------------------------------------------ - /// Open a file for read/writing with the specified options. - /// - /// Takes a path to a file which can be just a filename, or a full path. - /// - /// @param[in] path - /// The full or partial path to a file. - /// - /// @param[in] options - /// Options to use when opening (see File::OpenOptions) - /// - /// @param[in] permissions - /// Options to use when opening (see File::Permissions) - //------------------------------------------------------------------ - Status Open(const char *path, uint32_t options, - uint32_t permissions = lldb::eFilePermissionsFileDefault); - Status Close() override; void Clear(); @@ -417,8 +360,6 @@ public: //------------------------------------------------------------------ uint32_t GetPermissions(Status &error) const; - static uint32_t GetPermissions(const FileSpec &file_spec, Status &error); - //------------------------------------------------------------------ /// Return true if this file is interactive. /// @@ -461,8 +402,10 @@ public: void SetOptions(uint32_t options) { m_options = options; } + static bool DescriptorIsValid(int descriptor) { return descriptor >= 0; }; + protected: - bool DescriptorIsValid() const { return m_descriptor >= 0; } + bool DescriptorIsValid() const { return DescriptorIsValid(m_descriptor); } bool StreamIsValid() const { return m_stream != kInvalidStream; } diff --git a/include/lldb/Host/FileSystem.h b/include/lldb/Host/FileSystem.h index c13d5c84c631..9e36649b0046 100644 --- a/include/lldb/Host/FileSystem.h +++ b/include/lldb/Host/FileSystem.h @@ -10,9 +10,14 @@ #ifndef liblldb_Host_FileSystem_h #define liblldb_Host_FileSystem_h +#include "lldb/Host/File.h" +#include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" + +#include "llvm/ADT/Optional.h" #include "llvm/Support/Chrono.h" +#include "llvm/Support/VirtualFileSystem.h" #include "lldb/lldb-types.h" @@ -26,17 +31,147 @@ public: static const char *DEV_NULL; static const char *PATH_CONVERSION_ERROR; - static Status Symlink(const FileSpec &src, const FileSpec &dst); - static Status Readlink(const FileSpec &src, FileSpec &dst); + FileSystem() : m_fs(llvm::vfs::getRealFileSystem()) {} + FileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs) : m_fs(fs) {} + + FileSystem(const FileSystem &fs) = delete; + FileSystem &operator=(const FileSystem &fs) = delete; + + static FileSystem &Instance(); + + static void Initialize(); + static void Initialize(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs); + static void Terminate(); + + Status Symlink(const FileSpec &src, const FileSpec &dst); + Status Readlink(const FileSpec &src, FileSpec &dst); + + Status ResolveSymbolicLink(const FileSpec &src, FileSpec &dst); + + /// Wraps ::fopen in a platform-independent way. + FILE *Fopen(const char *path, const char *mode); + + /// Wraps ::open in a platform-independent way. + int Open(const char *path, int flags, int mode); + + Status Open(File &File, const FileSpec &file_spec, uint32_t options, + uint32_t permissions = lldb::eFilePermissionsFileDefault); + + /// Get a directory iterator. + /// @{ + llvm::vfs::directory_iterator DirBegin(const FileSpec &file_spec, + std::error_code &ec); + llvm::vfs::directory_iterator DirBegin(const llvm::Twine &dir, + std::error_code &ec); + /// @} + + /// Returns the Status object for the given file. + /// @{ + llvm::ErrorOr<llvm::vfs::Status> GetStatus(const FileSpec &file_spec) const; + llvm::ErrorOr<llvm::vfs::Status> GetStatus(const llvm::Twine &path) const; + /// @} + + /// Returns the modification time of the given file. + /// @{ + llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec) const; + llvm::sys::TimePoint<> GetModificationTime(const llvm::Twine &path) const; + /// @} + + /// Returns the on-disk size of the given file in bytes. + /// @{ + uint64_t GetByteSize(const FileSpec &file_spec) const; + uint64_t GetByteSize(const llvm::Twine &path) const; + /// @} + + /// Return the current permissions of the given file. + /// + /// Returns a bitmask for the current permissions of the file (zero or more + /// of the permission bits defined in File::Permissions). + /// @{ + uint32_t GetPermissions(const FileSpec &file_spec) const; + uint32_t GetPermissions(const llvm::Twine &path) const; + uint32_t GetPermissions(const FileSpec &file_spec, std::error_code &ec) const; + uint32_t GetPermissions(const llvm::Twine &path, std::error_code &ec) const; + /// @} + + /// Returns whether the given file exists. + /// @{ + bool Exists(const FileSpec &file_spec) const; + bool Exists(const llvm::Twine &path) const; + /// @} + + /// Returns whether the given file is readable. + /// @{ + bool Readable(const FileSpec &file_spec) const; + bool Readable(const llvm::Twine &path) const; + /// @} + + /// Returns whether the given path is a directory. + /// @{ + bool IsDirectory(const FileSpec &file_spec) const; + bool IsDirectory(const llvm::Twine &path) const; + /// @} + + /// Returns whether the given path is local to the file system. + /// @{ + bool IsLocal(const FileSpec &file_spec) const; + bool IsLocal(const llvm::Twine &path) const; + /// @} + + /// Make the given file path absolute. + /// @{ + std::error_code MakeAbsolute(llvm::SmallVectorImpl<char> &path) const; + std::error_code MakeAbsolute(FileSpec &file_spec) const; + /// @} + + /// Resolve path to make it canonical. + /// @{ + void Resolve(llvm::SmallVectorImpl<char> &path); + void Resolve(FileSpec &file_spec); + /// @} + + //// Create memory buffer from path. + /// @{ + std::shared_ptr<DataBufferLLVM> CreateDataBuffer(const llvm::Twine &path, + uint64_t size = 0, + uint64_t offset = 0); + std::shared_ptr<DataBufferLLVM> CreateDataBuffer(const FileSpec &file_spec, + uint64_t size = 0, + uint64_t offset = 0); + /// @} + + /// Call into the Host to see if it can help find the file. + bool ResolveExecutableLocation(FileSpec &file_spec); + + enum EnumerateDirectoryResult { + /// Enumerate next entry in the current directory. + eEnumerateDirectoryResultNext, + /// Recurse into the current entry if it is a directory or symlink, or next + /// if not. + eEnumerateDirectoryResultEnter, + /// Stop directory enumerations at any level. + eEnumerateDirectoryResultQuit + }; + + typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType)( + void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef); + + typedef std::function<EnumerateDirectoryResult( + llvm::sys::fs::file_type file_type, llvm::StringRef)> + DirectoryCallback; - static Status ResolveSymbolicLink(const FileSpec &src, FileSpec &dst); + void EnumerateDirectory(llvm::Twine path, bool find_directories, + bool find_files, bool find_other, + EnumerateDirectoryCallbackType callback, + void *callback_baton); - /// Wraps ::fopen in a platform-independent way. Once opened, FILEs can be - /// manipulated and closed with the normal ::fread, ::fclose, etc. functions. - static FILE *Fopen(const char *path, const char *mode); + std::error_code GetRealPath(const llvm::Twine &path, + llvm::SmallVectorImpl<char> &output) const; - static llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec); +private: + static llvm::Optional<FileSystem> &InstanceImpl(); + llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs; }; -} +} // namespace lldb_private #endif diff --git a/include/lldb/Host/HostInfoBase.h b/include/lldb/Host/HostInfoBase.h index b2567b296277..f3e49c8f25d7 100644 --- a/include/lldb/Host/HostInfoBase.h +++ b/include/lldb/Host/HostInfoBase.h @@ -75,10 +75,6 @@ public: /// member of the FileSpec is filled in. static FileSpec GetHeaderDir(); - /// Returns the directory containing the python modules. Only the directory - /// member of the FileSpec is filled in. - static FileSpec GetPythonDir(); - /// Returns the directory containing the system plugins. Only the directory /// member of the FileSpec is filled in. static FileSpec GetSystemPluginDir(); diff --git a/include/lldb/Host/HostNativeThreadBase.h b/include/lldb/Host/HostNativeThreadBase.h index f1f89f3b75fe..326a9c6c793f 100644 --- a/include/lldb/Host/HostNativeThreadBase.h +++ b/include/lldb/Host/HostNativeThreadBase.h @@ -35,6 +35,7 @@ public: virtual Status Cancel() = 0; virtual bool IsJoinable() const; virtual void Reset(); + virtual bool EqualsThread(lldb::thread_t thread) const; lldb::thread_t Release(); lldb::thread_t GetSystemHandle() const; diff --git a/include/lldb/Host/MonitoringProcessLauncher.h b/include/lldb/Host/MonitoringProcessLauncher.h index 341284800a4e..179823efb966 100644 --- a/include/lldb/Host/MonitoringProcessLauncher.h +++ b/include/lldb/Host/MonitoringProcessLauncher.h @@ -10,11 +10,7 @@ #ifndef lldb_Host_MonitoringProcessLauncher_h_ #define lldb_Host_MonitoringProcessLauncher_h_ -// C Includes -// C++ Includes #include <memory> -// Other libraries and framework includes -// Project includes #include "lldb/Host/ProcessLauncher.h" namespace lldb_private { diff --git a/include/lldb/Host/PipeBase.h b/include/lldb/Host/PipeBase.h index ad62072c7ba5..88bd703960c4 100644 --- a/include/lldb/Host/PipeBase.h +++ b/include/lldb/Host/PipeBase.h @@ -41,6 +41,9 @@ public: virtual bool CanRead() const = 0; virtual bool CanWrite() const = 0; + virtual lldb::pipe_t GetReadPipe() const = 0; + virtual lldb::pipe_t GetWritePipe() const = 0; + virtual int GetReadFileDescriptor() const = 0; virtual int GetWriteFileDescriptor() const = 0; virtual int ReleaseReadFileDescriptor() = 0; diff --git a/include/lldb/Host/ProcessRunLock.h b/include/lldb/Host/ProcessRunLock.h index 6f39eea716e8..272772fedce1 100644 --- a/include/lldb/Host/ProcessRunLock.h +++ b/include/lldb/Host/ProcessRunLock.h @@ -10,13 +10,9 @@ #ifndef liblldb_ProcessRunLock_h_ #define liblldb_ProcessRunLock_h_ -// C Includes #include <stdint.h> #include <time.h> -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-defines.h" //---------------------------------------------------------------------- diff --git a/include/lldb/Utility/SafeMachO.h b/include/lldb/Host/SafeMachO.h index 1565b313f42b..1565b313f42b 100644 --- a/include/lldb/Utility/SafeMachO.h +++ b/include/lldb/Host/SafeMachO.h diff --git a/include/lldb/Host/Socket.h b/include/lldb/Host/Socket.h index f6e51fd45679..8b7f9fa4ed93 100644 --- a/include/lldb/Host/Socket.h +++ b/include/lldb/Host/Socket.h @@ -15,9 +15,9 @@ #include "lldb/lldb-private.h" -#include "lldb/Host/Predicate.h" #include "lldb/Host/SocketAddress.h" #include "lldb/Utility/IOObject.h" +#include "lldb/Utility/Predicate.h" #include "lldb/Utility/Status.h" #ifdef _WIN32 diff --git a/include/lldb/Host/SocketAddress.h b/include/lldb/Host/SocketAddress.h index 749a9c664c81..5e54ef1d8e0c 100644 --- a/include/lldb/Host/SocketAddress.h +++ b/include/lldb/Host/SocketAddress.h @@ -10,7 +10,6 @@ #ifndef liblldb_SocketAddress_h_ #define liblldb_SocketAddress_h_ -// C Includes #include <stdint.h> #ifdef _WIN32 @@ -28,9 +27,6 @@ typedef ADDRESS_FAMILY sa_family_t; #include <sys/types.h> #endif -// C++ Includes -// Other libraries and framework includes -// Project includes #include <string> #include <vector> diff --git a/include/lldb/Host/StringConvert.h b/include/lldb/Host/StringConvert.h index d197df10d79e..1a85471a20c2 100644 --- a/include/lldb/Host/StringConvert.h +++ b/include/lldb/Host/StringConvert.h @@ -10,13 +10,9 @@ #ifndef liblldb_StringConvert_h_ #define liblldb_StringConvert_h_ -// C Includes #include <stdint.h> -// C++ Includes -// Other libraries and framework includes -// Project includes namespace lldb_private { diff --git a/include/lldb/Host/Symbols.h b/include/lldb/Host/Symbols.h index ce95d91497f8..8b00900d3321 100644 --- a/include/lldb/Host/Symbols.h +++ b/include/lldb/Host/Symbols.h @@ -10,12 +10,8 @@ #ifndef liblldb_Symbols_h_ #define liblldb_Symbols_h_ -// C Includes #include <stdint.h> -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/FileSpec.h" namespace lldb_private { diff --git a/include/lldb/Host/TaskPool.h b/include/lldb/Host/TaskPool.h index fe1714151076..4001d187a2a9 100644 --- a/include/lldb/Host/TaskPool.h +++ b/include/lldb/Host/TaskPool.h @@ -11,12 +11,12 @@ #define utility_TaskPool_h_ #include "llvm/ADT/STLExtras.h" -#include <functional> // for bind, function +#include <functional> #include <future> #include <list> -#include <memory> // for make_shared -#include <mutex> // for mutex, unique_lock, condition_variable -#include <type_traits> // for forward, result_of, move +#include <memory> +#include <mutex> +#include <type_traits> namespace lldb_private { diff --git a/include/lldb/Host/XML.h b/include/lldb/Host/XML.h index 5088f1f25b0d..57e300752003 100644 --- a/include/lldb/Host/XML.h +++ b/include/lldb/Host/XML.h @@ -10,20 +10,16 @@ #ifndef liblldb_XML_h_ #define liblldb_XML_h_ -// C Includes #if defined(LIBXML2_DEFINED) #include <libxml/xmlreader.h> #endif -// C++ Includes #include <functional> #include <string> #include <vector> -// Other libraries and framework includes #include "llvm/ADT/StringRef.h" -// Project includes #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Host/common/NativeBreakpoint.h b/include/lldb/Host/common/NativeBreakpoint.h deleted file mode 100644 index 681570aadef0..000000000000 --- a/include/lldb/Host/common/NativeBreakpoint.h +++ /dev/null @@ -1,56 +0,0 @@ -//===-- NativeBreakpoint.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_NativeBreakpoint_h_ -#define liblldb_NativeBreakpoint_h_ - -#include "lldb/lldb-types.h" - -namespace lldb_private { -class NativeBreakpointList; - -class NativeBreakpoint { - friend class NativeBreakpointList; - -public: - // The assumption is that derived breakpoints are enabled when created. - NativeBreakpoint(lldb::addr_t addr); - - virtual ~NativeBreakpoint(); - - Status Enable(); - - Status Disable(); - - lldb::addr_t GetAddress() const { return m_addr; } - - bool IsEnabled() const { return m_enabled; } - - virtual bool IsSoftwareBreakpoint() const = 0; - -protected: - const lldb::addr_t m_addr; - int32_t m_ref_count; - - virtual Status DoEnable() = 0; - - virtual Status DoDisable() = 0; - -private: - bool m_enabled; - - // ----------------------------------------------------------- interface for - // NativeBreakpointList - // ----------------------------------------------------------- - void AddRef(); - int32_t DecRef(); -}; -} - -#endif // ifndef liblldb_NativeBreakpoint_h_ diff --git a/include/lldb/Host/common/NativeBreakpointList.h b/include/lldb/Host/common/NativeBreakpointList.h index ffa659fdd869..b57174e51564 100644 --- a/include/lldb/Host/common/NativeBreakpointList.h +++ b/include/lldb/Host/common/NativeBreakpointList.h @@ -10,13 +10,9 @@ #ifndef liblldb_NativeBreakpointList_h_ #define liblldb_NativeBreakpointList_h_ -#include "lldb/Utility/Status.h" #include "lldb/lldb-private-forward.h" -// #include "lldb/Host/NativeBreakpoint.h" - -#include <functional> +#include "lldb/lldb-types.h" #include <map> -#include <mutex> namespace lldb_private { @@ -26,35 +22,6 @@ struct HardwareBreakpoint { }; using HardwareBreakpointMap = std::map<lldb::addr_t, HardwareBreakpoint>; - -class NativeBreakpointList { -public: - typedef std::function<Status(lldb::addr_t addr, size_t size_hint, - bool hardware, - NativeBreakpointSP &breakpoint_sp)> - CreateBreakpointFunc; - - NativeBreakpointList(); - - Status AddRef(lldb::addr_t addr, size_t size_hint, bool hardware, - CreateBreakpointFunc create_func); - - Status DecRef(lldb::addr_t addr); - - Status EnableBreakpoint(lldb::addr_t addr); - - Status DisableBreakpoint(lldb::addr_t addr); - - Status GetBreakpoint(lldb::addr_t addr, NativeBreakpointSP &breakpoint_sp); - - Status RemoveTrapsFromBuffer(lldb::addr_t addr, void *buf, size_t size) const; - -private: - typedef std::map<lldb::addr_t, NativeBreakpointSP> BreakpointMap; - - std::recursive_mutex m_mutex; - BreakpointMap m_breakpoints; -}; } #endif // ifndef liblldb_NativeBreakpointList_h_ diff --git a/include/lldb/Host/common/NativeProcessProtocol.h b/include/lldb/Host/common/NativeProcessProtocol.h index d96835d75839..cb3b18eb0a3d 100644 --- a/include/lldb/Host/common/NativeProcessProtocol.h +++ b/include/lldb/Host/common/NativeProcessProtocol.h @@ -25,6 +25,8 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/MemoryBuffer.h" +#include <mutex> +#include <unordered_map> #include <vector> namespace lldb_private { @@ -35,8 +37,6 @@ class ResumeActionList; // NativeProcessProtocol //------------------------------------------------------------------ class NativeProcessProtocol { - friend class SoftwareBreakpoint; - public: virtual ~NativeProcessProtocol() {} @@ -84,8 +84,8 @@ public: virtual Status ReadMemory(lldb::addr_t addr, void *buf, size_t size, size_t &bytes_read) = 0; - virtual Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, - size_t size, size_t &bytes_read) = 0; + Status ReadMemoryWithoutTrap(lldb::addr_t addr, void *buf, size_t size, + size_t &bytes_read); virtual Status WriteMemory(lldb::addr_t addr, const void *buf, size_t size, size_t &bytes_written) = 0; @@ -111,10 +111,6 @@ public: virtual Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false); - virtual Status EnableBreakpoint(lldb::addr_t addr); - - virtual Status DisableBreakpoint(lldb::addr_t addr); - //---------------------------------------------------------------------- // Hardware Breakpoint functions //---------------------------------------------------------------------- @@ -402,6 +398,13 @@ public: } protected: + struct SoftwareBreakpoint { + uint32_t ref_count; + llvm::SmallVector<uint8_t, 4> saved_opcodes; + llvm::ArrayRef<uint8_t> breakpoint_opcodes; + }; + + std::unordered_map<lldb::addr_t, SoftwareBreakpoint> m_software_breakpoints; lldb::pid_t m_pid; std::vector<std::unique_ptr<NativeThreadProtocol>> m_threads; @@ -415,7 +418,6 @@ protected: std::recursive_mutex m_delegates_mutex; std::vector<NativeDelegate *> m_delegates; - NativeBreakpointList m_breakpoint_list; NativeWatchpointList m_watchpoint_list; HardwareBreakpointMap m_hw_breakpoints_map; int m_terminal_fd; @@ -446,12 +448,23 @@ protected: // ----------------------------------------------------------- Internal // interface for software breakpoints // ----------------------------------------------------------- + Status SetSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint); + Status RemoveSoftwareBreakpoint(lldb::addr_t addr); + + virtual llvm::Expected<llvm::ArrayRef<uint8_t>> + GetSoftwareBreakpointTrapOpcode(size_t size_hint); + + /// Return the offset of the PC relative to the software breakpoint that was hit. If an + /// architecture (e.g. arm) reports breakpoint hits before incrementing the PC, this offset + /// will be 0. If an architecture (e.g. intel) reports breakpoints hits after incrementing the + /// PC, this offset will be the size of the breakpoint opcode. + virtual size_t GetSoftwareBreakpointPCOffset(); - virtual Status - GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint, - size_t &actual_opcode_size, - const uint8_t *&trap_opcode_bytes) = 0; + // Adjust the thread's PC after hitting a software breakpoint. On + // architectures where the PC points after the breakpoint instruction, this + // resets it to point to the breakpoint itself. + void FixupBreakpointPCAsNeeded(NativeThreadProtocol &thread); // ----------------------------------------------------------- /// Notify the delegate that an exec occurred. @@ -465,6 +478,8 @@ protected: private: void SynchronouslyNotifyProcessStateChanged(lldb::StateType state); + llvm::Expected<SoftwareBreakpoint> + EnableSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint); }; } // namespace lldb_private diff --git a/include/lldb/Host/common/NativeRegisterContext.h b/include/lldb/Host/common/NativeRegisterContext.h index 26458db153c1..268e0f2473fd 100644 --- a/include/lldb/Host/common/NativeRegisterContext.h +++ b/include/lldb/Host/common/NativeRegisterContext.h @@ -10,10 +10,6 @@ #ifndef liblldb_NativeRegisterContext_h_ #define liblldb_NativeRegisterContext_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/common/NativeWatchpointList.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Host/common/SoftwareBreakpoint.h b/include/lldb/Host/common/SoftwareBreakpoint.h deleted file mode 100644 index e0f235fecd93..000000000000 --- a/include/lldb/Host/common/SoftwareBreakpoint.h +++ /dev/null @@ -1,53 +0,0 @@ -//===-- SoftwareBreakpoint.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_SoftwareBreakpoint_h_ -#define liblldb_SoftwareBreakpoint_h_ - -#include "NativeBreakpoint.h" -#include "lldb/lldb-private-forward.h" - -namespace lldb_private { -class SoftwareBreakpoint : public NativeBreakpoint { - friend class NativeBreakpointList; - -public: - static Status CreateSoftwareBreakpoint(NativeProcessProtocol &process, - lldb::addr_t addr, size_t size_hint, - NativeBreakpointSP &breakpoint_spn); - - SoftwareBreakpoint(NativeProcessProtocol &process, lldb::addr_t addr, - const uint8_t *saved_opcodes, const uint8_t *trap_opcodes, - size_t opcode_size); - -protected: - Status DoEnable() override; - - Status DoDisable() override; - - bool IsSoftwareBreakpoint() const override; - -private: - /// Max number of bytes that a software trap opcode sequence can occupy. - static const size_t MAX_TRAP_OPCODE_SIZE = 8; - - NativeProcessProtocol &m_process; - uint8_t m_saved_opcodes[MAX_TRAP_OPCODE_SIZE]; - uint8_t m_trap_opcodes[MAX_TRAP_OPCODE_SIZE]; - const size_t m_opcode_size; - - static Status EnableSoftwareBreakpoint(NativeProcessProtocol &process, - lldb::addr_t addr, - size_t bp_opcode_size, - const uint8_t *bp_opcode_bytes, - uint8_t *saved_opcode_bytes); -}; -} - -#endif // #ifndef liblldb_SoftwareBreakpoint_h_ diff --git a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h index 0d125ca2c813..e44737e481e6 100644 --- a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h +++ b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h @@ -10,19 +10,16 @@ #ifndef liblldb_Host_posix_ConnectionFileDescriptorPosix_h_ #define liblldb_Host_posix_ConnectionFileDescriptorPosix_h_ -// C++ Includes #include <atomic> #include <memory> #include <mutex> #include "lldb/lldb-forward.h" -// Other libraries and framework includes -// Project includes #include "lldb/Host/Pipe.h" -#include "lldb/Host/Predicate.h" #include "lldb/Utility/Connection.h" #include "lldb/Utility/IOObject.h" +#include "lldb/Utility/Predicate.h" namespace lldb_private { diff --git a/include/lldb/Host/posix/HostProcessPosix.h b/include/lldb/Host/posix/HostProcessPosix.h index 0a6d8822d44f..2cbd4871dd6a 100644 --- a/include/lldb/Host/posix/HostProcessPosix.h +++ b/include/lldb/Host/posix/HostProcessPosix.h @@ -10,10 +10,6 @@ #ifndef lldb_Host_HostProcesPosix_h_ #define lldb_Host_HostProcesPosix_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Host/HostNativeProcessBase.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-types.h" diff --git a/include/lldb/Host/posix/PipePosix.h b/include/lldb/Host/posix/PipePosix.h index bb65a56abd00..30d19d97152b 100644 --- a/include/lldb/Host/posix/PipePosix.h +++ b/include/lldb/Host/posix/PipePosix.h @@ -27,7 +27,7 @@ public: static int kInvalidDescriptor; PipePosix(); - PipePosix(int read_fd, int write_fd); + PipePosix(lldb::pipe_t read, lldb::pipe_t write); PipePosix(const PipePosix &) = delete; PipePosix(PipePosix &&pipe_posix); PipePosix &operator=(const PipePosix &) = delete; @@ -49,6 +49,13 @@ public: bool CanRead() const override; bool CanWrite() const override; + lldb::pipe_t GetReadPipe() const override { + return lldb::pipe_t(GetReadFileDescriptor()); + } + lldb::pipe_t GetWritePipe() const override { + return lldb::pipe_t(GetWriteFileDescriptor()); + } + int GetReadFileDescriptor() const override; int GetWriteFileDescriptor() const override; int ReleaseReadFileDescriptor() override; diff --git a/include/lldb/Host/windows/HostThreadWindows.h b/include/lldb/Host/windows/HostThreadWindows.h index 35d83c0ba2b2..8d5972e88fbc 100644 --- a/include/lldb/Host/windows/HostThreadWindows.h +++ b/include/lldb/Host/windows/HostThreadWindows.h @@ -29,6 +29,7 @@ public: virtual Status Join(lldb::thread_result_t *result); virtual Status Cancel(); virtual void Reset(); + virtual bool EqualsThread(lldb::thread_t thread) const; lldb::tid_t GetThreadId() const; diff --git a/include/lldb/Host/windows/PipeWindows.h b/include/lldb/Host/windows/PipeWindows.h index e309c421a71c..1ae780ccc0b6 100644 --- a/include/lldb/Host/windows/PipeWindows.h +++ b/include/lldb/Host/windows/PipeWindows.h @@ -24,10 +24,18 @@ namespace lldb_private { //---------------------------------------------------------------------- class PipeWindows : public PipeBase { public: + static const int kInvalidDescriptor = -1; + +public: PipeWindows(); + PipeWindows(lldb::pipe_t read, lldb::pipe_t write); ~PipeWindows() override; + // Create an unnamed pipe. Status CreateNew(bool child_process_inherit) override; + + // Create a named pipe. + Status CreateNewNamed(bool child_process_inherit); Status CreateNew(llvm::StringRef name, bool child_process_inherit) override; Status CreateWithUniqueName(llvm::StringRef prefix, bool child_process_inherit, @@ -41,6 +49,9 @@ public: bool CanRead() const override; bool CanWrite() const override; + lldb::pipe_t GetReadPipe() const { return lldb::pipe_t(m_read); } + lldb::pipe_t GetWritePipe() const { return lldb::pipe_t(m_write); } + int GetReadFileDescriptor() const override; int GetWriteFileDescriptor() const override; int ReleaseReadFileDescriptor() override; diff --git a/include/lldb/Host/windows/editlinewin.h b/include/lldb/Host/windows/editlinewin.h index 4522f0dd41b0..2bd637848ff0 100644 --- a/include/lldb/Host/windows/editlinewin.h +++ b/include/lldb/Host/windows/editlinewin.h @@ -113,4 +113,4 @@ void el_deletestr(EditLine *, int); History *history_init(void); void history_end(History *); int history(History *, HistEvent *, int, ...); -};
\ No newline at end of file +}; diff --git a/include/lldb/Host/windows/windows.h b/include/lldb/Host/windows/windows.h index 3dc9f77f8e24..98a675eed4fe 100644 --- a/include/lldb/Host/windows/windows.h +++ b/include/lldb/Host/windows/windows.h @@ -21,6 +21,7 @@ #undef GetUserName #undef LoadImage #undef CreateProcess +#undef Yield #undef far #undef near #undef FAR diff --git a/include/lldb/Initialization/SystemInitializer.h b/include/lldb/Initialization/SystemInitializer.h index 58bbb44b1f34..b665b9997214 100644 --- a/include/lldb/Initialization/SystemInitializer.h +++ b/include/lldb/Initialization/SystemInitializer.h @@ -10,13 +10,24 @@ #ifndef LLDB_INITIALIZATION_SYSTEM_INITIALIZER_H #define LLDB_INITIALIZATION_SYSTEM_INITIALIZER_H +#include "llvm/Support/Error.h" + +#include <string> + namespace lldb_private { + +struct InitializerOptions { + bool reproducer_capture = false; + bool reproducer_replay = false; + std::string reproducer_path; +}; + class SystemInitializer { public: SystemInitializer(); virtual ~SystemInitializer(); - virtual void Initialize() = 0; + virtual llvm::Error Initialize(const InitializerOptions &options) = 0; virtual void Terminate() = 0; }; } diff --git a/include/lldb/Initialization/SystemInitializerCommon.h b/include/lldb/Initialization/SystemInitializerCommon.h index 2a9851c6a34c..f33acaf40466 100644 --- a/include/lldb/Initialization/SystemInitializerCommon.h +++ b/include/lldb/Initialization/SystemInitializerCommon.h @@ -28,7 +28,7 @@ public: SystemInitializerCommon(); ~SystemInitializerCommon() override; - void Initialize() override; + llvm::Error Initialize(const InitializerOptions &options) override; void Terminate() override; }; diff --git a/include/lldb/Initialization/SystemLifetimeManager.h b/include/lldb/Initialization/SystemLifetimeManager.h index 0ebd4a50a342..0839856f21e2 100644 --- a/include/lldb/Initialization/SystemLifetimeManager.h +++ b/include/lldb/Initialization/SystemLifetimeManager.h @@ -10,21 +10,23 @@ #ifndef LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H #define LLDB_INITIALIZATION_SYSTEM_LIFETIME_MANAGER_H +#include "lldb/Initialization/SystemInitializer.h" #include "lldb/lldb-private-types.h" +#include "llvm/Support/Error.h" #include <memory> #include <mutex> namespace lldb_private { -class SystemInitializer; class SystemLifetimeManager { public: SystemLifetimeManager(); ~SystemLifetimeManager(); - void Initialize(std::unique_ptr<SystemInitializer> initializer, - LoadPluginCallbackType plugin_callback); + llvm::Error Initialize(std::unique_ptr<SystemInitializer> initializer, + const InitializerOptions &options, + LoadPluginCallbackType plugin_callback); void Terminate(); private: diff --git a/include/lldb/Interpreter/CommandAlias.h b/include/lldb/Interpreter/CommandAlias.h index 01522bd6ecea..c865ad7ff2c9 100644 --- a/include/lldb/Interpreter/CommandAlias.h +++ b/include/lldb/Interpreter/CommandAlias.h @@ -10,12 +10,8 @@ #ifndef liblldb_CommandAlias_h_ #define liblldb_CommandAlias_h_ -// C Includes -// C++ Includes #include <memory> -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/CompletionRequest.h" diff --git a/include/lldb/Interpreter/CommandCompletions.h b/include/lldb/Interpreter/CommandCompletions.h index d17864e05f3e..71b0af3295b6 100644 --- a/include/lldb/Interpreter/CommandCompletions.h +++ b/include/lldb/Interpreter/CommandCompletions.h @@ -10,12 +10,8 @@ #ifndef lldb_CommandCompletions_h_ #define lldb_CommandCompletions_h_ -// C Includes -// C++ Includes #include <set> -// Other libraries and framework includes -// Project includes #include "lldb/Core/FileSpecList.h" #include "lldb/Core/SearchFilter.h" #include "lldb/Utility/CompletionRequest.h" @@ -116,7 +112,7 @@ public: CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, Address *addr, bool complete) override = 0; - Depth GetDepth() override = 0; + lldb::SearchDepth GetDepth() override = 0; virtual size_t DoCompletion(SearchFilter *filter) = 0; @@ -136,7 +132,7 @@ public: SourceFileCompleter(CommandInterpreter &interpreter, bool include_support_files, CompletionRequest &request); - Searcher::Depth GetDepth() override; + lldb::SearchDepth GetDepth() override; Searcher::CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, @@ -162,7 +158,7 @@ public: ModuleCompleter(CommandInterpreter &interpreter, CompletionRequest &request); - Searcher::Depth GetDepth() override; + lldb::SearchDepth GetDepth() override; Searcher::CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, @@ -186,7 +182,7 @@ public: SymbolCompleter(CommandInterpreter &interpreter, CompletionRequest &request); - Searcher::Depth GetDepth() override; + lldb::SearchDepth GetDepth() override; Searcher::CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, diff --git a/include/lldb/Interpreter/CommandHistory.h b/include/lldb/Interpreter/CommandHistory.h index faef220bbe94..f414c55e2d64 100644 --- a/include/lldb/Interpreter/CommandHistory.h +++ b/include/lldb/Interpreter/CommandHistory.h @@ -10,14 +10,10 @@ #ifndef liblldb_CommandHistory_h_ #define liblldb_CommandHistory_h_ -// C Includes -// C++ Includes #include <mutex> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Stream.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Interpreter/CommandInterpreter.h b/include/lldb/Interpreter/CommandInterpreter.h index 78f505c24754..558246037ad0 100644 --- a/include/lldb/Interpreter/CommandInterpreter.h +++ b/include/lldb/Interpreter/CommandInterpreter.h @@ -10,80 +10,81 @@ #ifndef liblldb_CommandInterpreter_h_ #define liblldb_CommandInterpreter_h_ -// C Includes -// C++ Includes -#include <mutex> -// Other libraries and framework includes -// Project includes -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Event.h" #include "lldb/Core/IOHandler.h" #include "lldb/Interpreter/CommandAlias.h" #include "lldb/Interpreter/CommandHistory.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/CompletionRequest.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StringList.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" +#include <mutex> namespace lldb_private { class CommandInterpreterRunOptions { public: //------------------------------------------------------------------ - /// Construct a CommandInterpreterRunOptions object. - /// This class is used to control all the instances where we run multiple - /// commands, e.g. + /// Construct a CommandInterpreterRunOptions object. This class is used to + /// control all the instances where we run multiple commands, e.g. /// HandleCommands, HandleCommandsFromFile, RunCommandInterpreter. + /// /// The meanings of the options in this object are: /// /// @param[in] stop_on_continue - /// If \b true execution will end on the first command that causes the - /// process in the - /// execution context to continue. If \false, we won't check the execution - /// status. + /// If \b true, execution will end on the first command that causes the + /// process in the execution context to continue. If \b false, we won't + /// check the execution status. /// @param[in] stop_on_error - /// If \b true execution will end on the first command that causes an + /// If \b true, execution will end on the first command that causes an /// error. /// @param[in] stop_on_crash - /// If \b true when a command causes the target to run, and the end of the - /// run is a - /// signal or exception, stop executing the commands. + /// If \b true, when a command causes the target to run, and the end of the + /// run is a signal or exception, stop executing the commands. /// @param[in] echo_commands - /// If \b true echo the command before executing it. If \false, execute + /// If \b true, echo the command before executing it. If \b false, execute /// silently. + /// @param[in] echo_comments + /// If \b true, echo command even if it is a pure comment line. If + /// \b false, print no ouput in this case. This setting has an effect only + /// if \param echo_commands is \b true. /// @param[in] print_results - /// If \b true print the results of the command after executing it. If - /// \false, execute silently. + /// If \b true print the results of the command after executing it. If + /// \b false, execute silently. /// @param[in] add_to_history - /// If \b true add the commands to the command history. If \false, don't + /// If \b true add the commands to the command history. If \b false, don't /// add them. //------------------------------------------------------------------ CommandInterpreterRunOptions(LazyBool stop_on_continue, LazyBool stop_on_error, LazyBool stop_on_crash, - LazyBool echo_commands, LazyBool print_results, - LazyBool add_to_history) + LazyBool echo_commands, LazyBool echo_comments, + LazyBool print_results, LazyBool add_to_history) : m_stop_on_continue(stop_on_continue), m_stop_on_error(stop_on_error), m_stop_on_crash(stop_on_crash), m_echo_commands(echo_commands), - m_print_results(print_results), m_add_to_history(add_to_history) {} + m_echo_comment_commands(echo_comments), m_print_results(print_results), + m_add_to_history(add_to_history) {} CommandInterpreterRunOptions() : m_stop_on_continue(eLazyBoolCalculate), m_stop_on_error(eLazyBoolCalculate), m_stop_on_crash(eLazyBoolCalculate), m_echo_commands(eLazyBoolCalculate), + m_echo_comment_commands(eLazyBoolCalculate), m_print_results(eLazyBoolCalculate), m_add_to_history(eLazyBoolCalculate) {} void SetSilent(bool silent) { LazyBool value = silent ? eLazyBoolNo : eLazyBoolYes; - m_echo_commands = value; m_print_results = value; + m_echo_commands = value; + m_echo_comment_commands = value; m_add_to_history = value; } // These return the default behaviors if the behavior is not @@ -97,7 +98,7 @@ public: m_stop_on_continue = stop_on_continue ? eLazyBoolYes : eLazyBoolNo; } - bool GetStopOnError() const { return DefaultToNo(m_stop_on_continue); } + bool GetStopOnError() const { return DefaultToNo(m_stop_on_error); } void SetStopOnError(bool stop_on_error) { m_stop_on_error = stop_on_error ? eLazyBoolYes : eLazyBoolNo; @@ -115,6 +116,14 @@ public: m_echo_commands = echo_commands ? eLazyBoolYes : eLazyBoolNo; } + bool GetEchoCommentCommands() const { + return DefaultToYes(m_echo_comment_commands); + } + + void SetEchoCommentCommands(bool echo_comments) { + m_echo_comment_commands = echo_comments ? eLazyBoolYes : eLazyBoolNo; + } + bool GetPrintResults() const { return DefaultToYes(m_print_results); } void SetPrintResults(bool print_results) { @@ -131,6 +140,7 @@ public: LazyBool m_stop_on_error; LazyBool m_stop_on_crash; LazyBool m_echo_commands; + LazyBool m_echo_comment_commands; LazyBool m_print_results; LazyBool m_add_to_history; @@ -206,7 +216,8 @@ public: bool include_aliases) const; CommandObject *GetCommandObject(llvm::StringRef cmd, - StringList *matches = nullptr) const; + StringList *matches = nullptr, + StringList *descriptions = nullptr) const; bool CommandExists(llvm::StringRef cmd) const; @@ -310,7 +321,8 @@ public: // FIXME: Only max_return_elements == -1 is supported at present. int HandleCompletion(const char *current_line, const char *cursor, const char *last_char, int match_start_point, - int max_return_elements, StringList &matches); + int max_return_elements, StringList &matches, + StringList &descriptions); // This version just returns matches, and doesn't compute the substring. It // is here so the Help command can call it for the first argument. It uses @@ -319,7 +331,8 @@ public: int GetCommandNamesMatchingPartialString(const char *cmd_cstr, bool include_aliases, - StringList &matches); + StringList &matches, + StringList &descriptions); void GetHelp(CommandReturnObject &result, uint32_t types = eCommandTypesAllThem); @@ -456,6 +469,12 @@ public: void SetPromptOnQuit(bool b); + bool GetEchoCommands() const; + void SetEchoCommands(bool b); + + bool GetEchoCommentCommands() const; + void SetEchoCommentCommands(bool b); + //------------------------------------------------------------------ /// Specify if the command interpreter should allow that the user can /// specify a custom exit code when calling 'quit'. @@ -520,7 +539,8 @@ protected: lldb::CommandObjectSP GetCommandSP(llvm::StringRef cmd, bool include_aliases = true, bool exact = true, - StringList *matches = nullptr) const; + StringList *matches = nullptr, + StringList *descriptions = nullptr) const; private: Status PreprocessCommand(std::string &command); @@ -538,6 +558,9 @@ private: // An interruptible wrapper around the stream output void PrintCommandOutput(Stream &stream, llvm::StringRef str); + bool EchoCommandNonInteractive(llvm::StringRef line, + const Flags &io_handler_flags) const; + // A very simple state machine which models the command handling transitions enum class CommandHandlingState { eIdle, diff --git a/include/lldb/Interpreter/CommandObject.h b/include/lldb/Interpreter/CommandObject.h index 7afb18b2f598..f72628b8a643 100644 --- a/include/lldb/Interpreter/CommandObject.h +++ b/include/lldb/Interpreter/CommandObject.h @@ -10,14 +10,10 @@ #ifndef liblldb_CommandObject_h_ #define liblldb_CommandObject_h_ -// C Includes -// C++ Includes #include <map> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Flags.h" #include "lldb/Interpreter/CommandCompletions.h" @@ -37,8 +33,9 @@ namespace lldb_private { // number added. template <typename ValueType> -int AddNamesMatchingPartialString(const std::map<std::string, ValueType> &in_map, - llvm::StringRef cmd_str, StringList &matches) { +int AddNamesMatchingPartialString( + const std::map<std::string, ValueType> &in_map, llvm::StringRef cmd_str, + StringList &matches, StringList *descriptions = nullptr) { int number_added = 0; const bool add_all = cmd_str.empty(); @@ -47,6 +44,8 @@ int AddNamesMatchingPartialString(const std::map<std::string, ValueType> &in_map if (add_all || (iter->first.find(cmd_str, 0) == 0)) { ++number_added; matches.AppendString(iter->first.c_str()); + if (descriptions) + descriptions->AppendString(iter->second->GetHelp()); } } diff --git a/include/lldb/Interpreter/CommandObjectMultiword.h b/include/lldb/Interpreter/CommandObjectMultiword.h index d9eff9a6e545..e1ea39f7ec34 100644 --- a/include/lldb/Interpreter/CommandObjectMultiword.h +++ b/include/lldb/Interpreter/CommandObjectMultiword.h @@ -10,10 +10,6 @@ #ifndef liblldb_CommandObjectMultiword_h_ #define liblldb_CommandObjectMultiword_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" #include "lldb/Utility/CompletionRequest.h" diff --git a/include/lldb/Interpreter/CommandObjectRegexCommand.h b/include/lldb/Interpreter/CommandObjectRegexCommand.h index 36c3f068bdf3..d50bc3ba9141 100644 --- a/include/lldb/Interpreter/CommandObjectRegexCommand.h +++ b/include/lldb/Interpreter/CommandObjectRegexCommand.h @@ -10,12 +10,8 @@ #ifndef liblldb_CommandObjectRegexCommand_h_ #define liblldb_CommandObjectRegexCommand_h_ -// C Includes -// C++ Includes #include <list> -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/CommandObject.h" #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/RegularExpression.h" diff --git a/include/lldb/Interpreter/CommandOptionValidators.h b/include/lldb/Interpreter/CommandOptionValidators.h index 05724cace172..e0c8ddde6ecb 100644 --- a/include/lldb/Interpreter/CommandOptionValidators.h +++ b/include/lldb/Interpreter/CommandOptionValidators.h @@ -10,10 +10,6 @@ #ifndef liblldb_CommandOptionValidators_h_ #define liblldb_CommandOptionValidators_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private-types.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/CommandReturnObject.h b/include/lldb/Interpreter/CommandReturnObject.h index 7b04c391bc76..53a908f97ccb 100644 --- a/include/lldb/Interpreter/CommandReturnObject.h +++ b/include/lldb/Interpreter/CommandReturnObject.h @@ -10,10 +10,6 @@ #ifndef liblldb_CommandReturnObject_h_ #define liblldb_CommandReturnObject_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/STLUtils.h" #include "lldb/Core/StreamFile.h" #include "lldb/Utility/StreamString.h" diff --git a/include/lldb/Interpreter/OptionArgParser.h b/include/lldb/Interpreter/OptionArgParser.h index 5ace7e5d0250..b5a083929067 100644 --- a/include/lldb/Interpreter/OptionArgParser.h +++ b/include/lldb/Interpreter/OptionArgParser.h @@ -24,7 +24,7 @@ struct OptionArgParser { static char ToChar(llvm::StringRef s, char fail_value, bool *success_ptr); static int64_t ToOptionEnum(llvm::StringRef s, - OptionEnumValueElement *enum_values, + const OptionEnumValues &enum_values, int32_t fail_value, Status &error); static lldb::ScriptLanguage ToScriptLanguage(llvm::StringRef s, diff --git a/include/lldb/Interpreter/OptionGroupBoolean.h b/include/lldb/Interpreter/OptionGroupBoolean.h index 2489a648dd7e..161c12a41f9f 100644 --- a/include/lldb/Interpreter/OptionGroupBoolean.h +++ b/include/lldb/Interpreter/OptionGroupBoolean.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionGroupBoolean_h_ #define liblldb_OptionGroupBoolean_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueBoolean.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupFile.h b/include/lldb/Interpreter/OptionGroupFile.h index d0c25b8bf8e6..4a56e4c742fd 100644 --- a/include/lldb/Interpreter/OptionGroupFile.h +++ b/include/lldb/Interpreter/OptionGroupFile.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionGroupFile_h_ #define liblldb_OptionGroupFile_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueFileSpec.h" #include "lldb/Interpreter/OptionValueFileSpecList.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupFormat.h b/include/lldb/Interpreter/OptionGroupFormat.h index ddf2ccece3bd..52113d8777f5 100644 --- a/include/lldb/Interpreter/OptionGroupFormat.h +++ b/include/lldb/Interpreter/OptionGroupFormat.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionGroupFormat_h_ #define liblldb_OptionGroupFormat_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueFormat.h" #include "lldb/Interpreter/OptionValueSInt64.h" #include "lldb/Interpreter/OptionValueUInt64.h" diff --git a/include/lldb/Interpreter/OptionGroupOutputFile.h b/include/lldb/Interpreter/OptionGroupOutputFile.h index 19453c6215ef..88d45797358d 100644 --- a/include/lldb/Interpreter/OptionGroupOutputFile.h +++ b/include/lldb/Interpreter/OptionGroupOutputFile.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionGroupOutputFile_h_ #define liblldb_OptionGroupOutputFile_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueBoolean.h" #include "lldb/Interpreter/OptionValueFileSpec.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupPlatform.h b/include/lldb/Interpreter/OptionGroupPlatform.h index cda4246f1b01..9bc9588deab3 100644 --- a/include/lldb/Interpreter/OptionGroupPlatform.h +++ b/include/lldb/Interpreter/OptionGroupPlatform.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionGroupPlatform_h_ #define liblldb_OptionGroupPlatform_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/Options.h" #include "lldb/Utility/ConstString.h" #include "llvm/Support/VersionTuple.h" diff --git a/include/lldb/Interpreter/OptionGroupString.h b/include/lldb/Interpreter/OptionGroupString.h index 01e8aa9dc3b6..41889fe57d77 100644 --- a/include/lldb/Interpreter/OptionGroupString.h +++ b/include/lldb/Interpreter/OptionGroupString.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionGroupString_h_ #define liblldb_OptionGroupString_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupUInt64.h b/include/lldb/Interpreter/OptionGroupUInt64.h index 82eb0e26af9b..d6b06066b964 100644 --- a/include/lldb/Interpreter/OptionGroupUInt64.h +++ b/include/lldb/Interpreter/OptionGroupUInt64.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionGroupUInt64_h_ #define liblldb_OptionGroupUInt64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueUInt64.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupUUID.h b/include/lldb/Interpreter/OptionGroupUUID.h index def97d5f2551..390f128a8618 100644 --- a/include/lldb/Interpreter/OptionGroupUUID.h +++ b/include/lldb/Interpreter/OptionGroupUUID.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionGroupUUID_h_ #define liblldb_OptionGroupUUID_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueUUID.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h index 0e075773b3f7..8684453d89c6 100644 --- a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h +++ b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionGroupValueObjectDisplay_h_ #define liblldb_OptionGroupValueObjectDisplay_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/ValueObject.h" #include "lldb/Interpreter/Options.h" diff --git a/include/lldb/Interpreter/OptionGroupVariable.h b/include/lldb/Interpreter/OptionGroupVariable.h index c9e90320e141..663705acebbc 100644 --- a/include/lldb/Interpreter/OptionGroupVariable.h +++ b/include/lldb/Interpreter/OptionGroupVariable.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionGroupVariable_h_ #define liblldb_OptionGroupVariable_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueString.h" #include "lldb/Interpreter/Options.h" @@ -39,6 +35,8 @@ public: bool include_frame_options : 1, show_args : 1, // Frame option only (include_frame_options == true) + show_recognized_args : 1, // Frame option only (include_frame_options == + // true) show_locals : 1, // Frame option only (include_frame_options == true) show_globals : 1, // Frame option only (include_frame_options == true) use_regex : 1, show_scope : 1, show_decl : 1; diff --git a/include/lldb/Interpreter/OptionGroupWatchpoint.h b/include/lldb/Interpreter/OptionGroupWatchpoint.h index f2665638ba85..2d4456ef31a9 100644 --- a/include/lldb/Interpreter/OptionGroupWatchpoint.h +++ b/include/lldb/Interpreter/OptionGroupWatchpoint.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionGroupWatchpoint_h_ #define liblldb_OptionGroupWatchpoint_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/Options.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValue.h b/include/lldb/Interpreter/OptionValue.h index 4748e309c77e..e90d7ed6d8eb 100644 --- a/include/lldb/Interpreter/OptionValue.h +++ b/include/lldb/Interpreter/OptionValue.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionValue_h_ #define liblldb_OptionValue_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/FormatEntity.h" #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/ConstString.h" @@ -58,9 +54,11 @@ public: eDumpOptionValue = (1u << 2), eDumpOptionDescription = (1u << 3), eDumpOptionRaw = (1u << 4), + eDumpOptionCommand = (1u << 5), eDumpGroupValue = (eDumpOptionName | eDumpOptionType | eDumpOptionValue), eDumpGroupHelp = - (eDumpOptionName | eDumpOptionType | eDumpOptionDescription) + (eDumpOptionName | eDumpOptionType | eDumpOptionDescription), + eDumpGroupExport = (eDumpOptionCommand | eDumpOptionName | eDumpOptionValue) }; OptionValue() diff --git a/include/lldb/Interpreter/OptionValueArgs.h b/include/lldb/Interpreter/OptionValueArgs.h index 433679da134e..41af1298c2cb 100644 --- a/include/lldb/Interpreter/OptionValueArgs.h +++ b/include/lldb/Interpreter/OptionValueArgs.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionValueArgs_h_ #define liblldb_OptionValueArgs_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValueArray.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueArray.h b/include/lldb/Interpreter/OptionValueArray.h index 44709d00763f..06c482840260 100644 --- a/include/lldb/Interpreter/OptionValueArray.h +++ b/include/lldb/Interpreter/OptionValueArray.h @@ -10,12 +10,8 @@ #ifndef liblldb_OptionValueArray_h_ #define liblldb_OptionValueArray_h_ -// C Includes -// C++ Includes #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueBoolean.h b/include/lldb/Interpreter/OptionValueBoolean.h index 6d2a16e59597..572e6b1861fb 100644 --- a/include/lldb/Interpreter/OptionValueBoolean.h +++ b/include/lldb/Interpreter/OptionValueBoolean.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionValueBoolean_h_ #define liblldb_OptionValueBoolean_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueChar.h b/include/lldb/Interpreter/OptionValueChar.h index 0c5f602efe9b..e73976fefccc 100644 --- a/include/lldb/Interpreter/OptionValueChar.h +++ b/include/lldb/Interpreter/OptionValueChar.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionValueChar_h_ #define liblldb_OptionValueChar_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueDictionary.h b/include/lldb/Interpreter/OptionValueDictionary.h index 4e8c86008ea4..b6163e7a9a25 100644 --- a/include/lldb/Interpreter/OptionValueDictionary.h +++ b/include/lldb/Interpreter/OptionValueDictionary.h @@ -10,12 +10,8 @@ #ifndef liblldb_OptionValueDictionary_h_ #define liblldb_OptionValueDictionary_h_ -// C Includes -// C++ Includes #include <map> -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueEnumeration.h b/include/lldb/Interpreter/OptionValueEnumeration.h index 08d6ac70de52..16c09c589a27 100644 --- a/include/lldb/Interpreter/OptionValueEnumeration.h +++ b/include/lldb/Interpreter/OptionValueEnumeration.h @@ -30,8 +30,7 @@ public: typedef UniqueCStringMap<EnumeratorInfo> EnumerationMap; typedef EnumerationMap::Entry EnumerationMapEntry; - OptionValueEnumeration(const OptionEnumValueElement *enumerators, - enum_type value); + OptionValueEnumeration(const OptionEnumValues &enumerators, enum_type value); ~OptionValueEnumeration() override; @@ -80,7 +79,7 @@ public: void SetDefaultValue(enum_type value) { m_default_value = value; } protected: - void SetEnumerations(const OptionEnumValueElement *enumerators); + void SetEnumerations(const OptionEnumValues &enumerators); enum_type m_current_value; enum_type m_default_value; diff --git a/include/lldb/Interpreter/OptionValueFileSpecList.h b/include/lldb/Interpreter/OptionValueFileSpecList.h index 9529fbcf38bc..5c43b85bcea7 100644 --- a/include/lldb/Interpreter/OptionValueFileSpecList.h +++ b/include/lldb/Interpreter/OptionValueFileSpecList.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionValueFileSpecList_h_ #define liblldb_OptionValueFileSpecList_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/FileSpecList.h" #include "lldb/Interpreter/OptionValue.h" diff --git a/include/lldb/Interpreter/OptionValueFormat.h b/include/lldb/Interpreter/OptionValueFormat.h index ce7997024b09..6d46957d26f7 100644 --- a/include/lldb/Interpreter/OptionValueFormat.h +++ b/include/lldb/Interpreter/OptionValueFormat.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionValueFormat_h_ #define liblldb_OptionValueFormat_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueFormatEntity.h b/include/lldb/Interpreter/OptionValueFormatEntity.h index 880e434dc5c0..5d5a8ca02c97 100644 --- a/include/lldb/Interpreter/OptionValueFormatEntity.h +++ b/include/lldb/Interpreter/OptionValueFormatEntity.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionValueFormatEntity_h_ #define liblldb_OptionValueFormatEntity_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/FormatEntity.h" #include "lldb/Interpreter/OptionValue.h" diff --git a/include/lldb/Interpreter/OptionValueLanguage.h b/include/lldb/Interpreter/OptionValueLanguage.h index 8f81c5df0739..9d4956c6d789 100644 --- a/include/lldb/Interpreter/OptionValueLanguage.h +++ b/include/lldb/Interpreter/OptionValueLanguage.h @@ -11,10 +11,6 @@ #ifndef liblldb_OptionValueLanguage_h_ #define liblldb_OptionValueLanguage_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" #include "lldb/lldb-enumerations.h" diff --git a/include/lldb/Interpreter/OptionValuePathMappings.h b/include/lldb/Interpreter/OptionValuePathMappings.h index 0e2e98d74b74..85f9926b21f8 100644 --- a/include/lldb/Interpreter/OptionValuePathMappings.h +++ b/include/lldb/Interpreter/OptionValuePathMappings.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionValuePathMappings_h_ #define liblldb_OptionValuePathMappings_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" #include "lldb/Target/PathMappingList.h" diff --git a/include/lldb/Interpreter/OptionValueProperties.h b/include/lldb/Interpreter/OptionValueProperties.h index 96bd93ab3d7b..941e48561f77 100644 --- a/include/lldb/Interpreter/OptionValueProperties.h +++ b/include/lldb/Interpreter/OptionValueProperties.h @@ -10,12 +10,8 @@ #ifndef liblldb_OptionValueProperties_h_ #define liblldb_OptionValueProperties_h_ -// C Includes -// C++ Includes #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/FormatEntity.h" #include "lldb/Core/UniqueCStringMap.h" #include "lldb/Interpreter/OptionValue.h" @@ -62,7 +58,7 @@ public: void Apropos(llvm::StringRef keyword, std::vector<const Property *> &matching_properties) const; - void Initialize(const PropertyDefinition *setting_definitions); + void Initialize(const PropertyDefinitions &setting_definitions); // bool // GetQualifiedName (Stream &strm); diff --git a/include/lldb/Interpreter/OptionValueRegex.h b/include/lldb/Interpreter/OptionValueRegex.h index afe9318ae014..a77eb5323f23 100644 --- a/include/lldb/Interpreter/OptionValueRegex.h +++ b/include/lldb/Interpreter/OptionValueRegex.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionValueRegex_h_ #define liblldb_OptionValueRegex_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" #include "lldb/Utility/RegularExpression.h" diff --git a/include/lldb/Interpreter/OptionValueSInt64.h b/include/lldb/Interpreter/OptionValueSInt64.h index a6893d23e692..f630cbb8e283 100644 --- a/include/lldb/Interpreter/OptionValueSInt64.h +++ b/include/lldb/Interpreter/OptionValueSInt64.h @@ -11,10 +11,6 @@ #ifndef liblldb_OptionValueSInt64_h_ #define liblldb_OptionValueSInt64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueString.h b/include/lldb/Interpreter/OptionValueString.h index 4a9f2227680e..ab15595a08b4 100644 --- a/include/lldb/Interpreter/OptionValueString.h +++ b/include/lldb/Interpreter/OptionValueString.h @@ -10,12 +10,8 @@ #ifndef liblldb_OptionValueString_h_ #define liblldb_OptionValueString_h_ -// C Includes -// C++ Includes #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Flags.h" #include "lldb/Interpreter/OptionValue.h" diff --git a/include/lldb/Interpreter/OptionValueUInt64.h b/include/lldb/Interpreter/OptionValueUInt64.h index 96404bed8e67..5cbcafdb6e58 100644 --- a/include/lldb/Interpreter/OptionValueUInt64.h +++ b/include/lldb/Interpreter/OptionValueUInt64.h @@ -11,10 +11,6 @@ #ifndef liblldb_OptionValueUInt64_h_ #define liblldb_OptionValueUInt64_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Interpreter/OptionValue.h" namespace lldb_private { diff --git a/include/lldb/Interpreter/OptionValueUUID.h b/include/lldb/Interpreter/OptionValueUUID.h index 950efb518d5a..c2ee48962b42 100644 --- a/include/lldb/Interpreter/OptionValueUUID.h +++ b/include/lldb/Interpreter/OptionValueUUID.h @@ -10,10 +10,6 @@ #ifndef liblldb_OptionValueUUID_h_ #define liblldb_OptionValueUUID_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Utility/UUID.h" #include "lldb/Interpreter/OptionValue.h" diff --git a/include/lldb/Interpreter/Options.h b/include/lldb/Interpreter/Options.h index 316bf568fd92..aa9e564083a9 100644 --- a/include/lldb/Interpreter/Options.h +++ b/include/lldb/Interpreter/Options.h @@ -10,13 +10,9 @@ #ifndef liblldb_Options_h_ #define liblldb_Options_h_ -// C Includes -// C++ Includes #include <set> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Args.h" #include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/Status.h" diff --git a/include/lldb/Interpreter/Property.h b/include/lldb/Interpreter/Property.h index 9d0dc5fa0fd8..a7515e9903a4 100644 --- a/include/lldb/Interpreter/Property.h +++ b/include/lldb/Interpreter/Property.h @@ -28,10 +28,12 @@ struct PropertyDefinition { bool global; // false == this setting is a global setting by default uintptr_t default_uint_value; const char *default_cstr_value; - OptionEnumValueElement *enum_values; + OptionEnumValues enum_values; const char *description; }; +using PropertyDefinitions = llvm::ArrayRef<PropertyDefinition>; + class Property { public: Property(const PropertyDefinition &definition); diff --git a/include/lldb/Interpreter/ScriptInterpreter.h b/include/lldb/Interpreter/ScriptInterpreter.h index d2189edd04a6..640d9d34c617 100644 --- a/include/lldb/Interpreter/ScriptInterpreter.h +++ b/include/lldb/Interpreter/ScriptInterpreter.h @@ -10,15 +10,12 @@ #ifndef liblldb_ScriptInterpreter_h_ #define liblldb_ScriptInterpreter_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" #include "lldb/Breakpoint/BreakpointOptions.h" -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/PluginInterface.h" +#include "lldb/Core/SearchFilter.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StructuredData.h" @@ -173,6 +170,17 @@ public: } virtual StructuredData::GenericSP + CreateFrameRecognizer(const char *class_name) { + return StructuredData::GenericSP(); + } + + virtual lldb::ValueObjectListSP GetRecognizedArguments( + const StructuredData::ObjectSP &implementor, + lldb::StackFrameSP frame_sp) { + return lldb::ValueObjectListSP(); + } + + virtual StructuredData::GenericSP OSPlugin_CreatePluginObject(const char *class_name, lldb::ProcessSP process_sp) { return StructuredData::GenericSP(); @@ -234,6 +242,26 @@ public: return lldb::eStateStepping; } + virtual StructuredData::GenericSP + CreateScriptedBreakpointResolver(const char *class_name, + StructuredDataImpl *args_data, + lldb::BreakpointSP &bkpt_sp) { + return StructuredData::GenericSP(); + } + + virtual bool + ScriptedBreakpointResolverSearchCallback(StructuredData::GenericSP implementor_sp, + SymbolContext *sym_ctx) + { + return false; + } + + virtual lldb::SearchDepth + ScriptedBreakpointResolverSearchDepth(StructuredData::GenericSP implementor_sp) + { + return lldb::eSearchDepthModule; + } + virtual StructuredData::ObjectSP LoadPluginModule(const FileSpec &file_spec, lldb_private::Status &error) { return StructuredData::ObjectSP(); diff --git a/include/lldb/Symbol/Block.h b/include/lldb/Symbol/Block.h index 1664362431f9..2428a1d3ffca 100644 --- a/include/lldb/Symbol/Block.h +++ b/include/lldb/Symbol/Block.h @@ -10,12 +10,8 @@ #ifndef liblldb_Block_h_ #define liblldb_Block_h_ -// C Includes -// C++ Includes #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/AddressRange.h" #include "lldb/Core/RangeMap.h" #include "lldb/Symbol/CompilerType.h" @@ -327,6 +323,14 @@ public: return m_inlineInfoSP.get(); } + //------------------------------------------------------------------ + /// Get the symbol file which contains debug info for this block's + /// symbol context module. + /// + /// @return A pointer to the symbol file or nullptr. + //------------------------------------------------------------------ + SymbolFile *GetSymbolFile(); + CompilerDeclContext GetDeclContext(); //------------------------------------------------------------------ diff --git a/include/lldb/Symbol/ClangASTContext.h b/include/lldb/Symbol/ClangASTContext.h index 9364149d98e7..4cff9b256570 100644 --- a/include/lldb/Symbol/ClangASTContext.h +++ b/include/lldb/Symbol/ClangASTContext.h @@ -10,10 +10,8 @@ #ifndef liblldb_ClangASTContext_h_ #define liblldb_ClangASTContext_h_ -// C Includes #include <stdint.h> -// C++ Includes #include <functional> #include <initializer_list> #include <map> @@ -23,13 +21,12 @@ #include <utility> #include <vector> -// Other libraries and framework includes #include "clang/AST/ASTContext.h" #include "clang/AST/ExternalASTMerger.h" #include "clang/AST/TemplateBase.h" +#include "llvm/ADT/APSInt.h" #include "llvm/ADT/SmallVector.h" -// Project includes #include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" #include "lldb/Core/ClangForward.h" #include "lldb/Symbol/CompilerType.h" @@ -214,19 +211,24 @@ public: static CompilerType GetTypeForDecl(clang::ObjCInterfaceDecl *objc_decl); template <typename RecordDeclType> - CompilerType GetTypeForIdentifier(const ConstString &type_name) { + CompilerType + GetTypeForIdentifier(const ConstString &type_name, + clang::DeclContext *decl_context = nullptr) { CompilerType compiler_type; if (type_name.GetLength()) { clang::ASTContext *ast = getASTContext(); if (ast) { + if (!decl_context) + decl_context = ast->getTranslationUnitDecl(); + clang::IdentifierInfo &myIdent = ast->Idents.get(type_name.GetCString()); clang::DeclarationName myName = ast->DeclarationNames.getIdentifier(&myIdent); clang::DeclContext::lookup_result result = - ast->getTranslationUnitDecl()->lookup(myName); + decl_context->lookup(myName); if (!result.empty()) { clang::NamedDecl *named_decl = result[0]; @@ -372,7 +374,17 @@ public: const CompilerType &result_type, const CompilerType *args, unsigned num_args, bool is_variadic, - unsigned type_quals); + unsigned type_quals, + clang::CallingConv cc); + + static CompilerType CreateFunctionType(clang::ASTContext *ast, + const CompilerType &result_type, + const CompilerType *args, + unsigned num_args, bool is_variadic, + unsigned type_quals) { + return ClangASTContext::CreateFunctionType( + ast, result_type, args, num_args, is_variadic, type_quals, clang::CC_C); + } CompilerType CreateFunctionType(const CompilerType &result_type, const CompilerType *args, unsigned num_args, @@ -381,7 +393,17 @@ public: getASTContext(), result_type, args, num_args, is_variadic, type_quals); } - clang::ParmVarDecl *CreateParameterDeclaration(const char *name, + CompilerType CreateFunctionType(const CompilerType &result_type, + const CompilerType *args, unsigned num_args, + bool is_variadic, unsigned type_quals, + clang::CallingConv cc) { + return ClangASTContext::CreateFunctionType(getASTContext(), result_type, + args, num_args, is_variadic, + type_quals, cc); + } + + clang::ParmVarDecl *CreateParameterDeclaration(clang::DeclContext *decl_ctx, + const char *name, const CompilerType ¶m_type, int storage); @@ -720,7 +742,8 @@ public: size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) override; uint32_t GetNumChildren(lldb::opaque_compiler_type_t type, - bool omit_empty_base_classes) override; + bool omit_empty_base_classes, + const ExecutionContext *exe_ctx) override; CompilerType GetBuiltinTypeByName(const ConstString &name) override; @@ -809,7 +832,7 @@ public: // Modifying RecordType //---------------------------------------------------------------------- static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type, - const char *name, + llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size); @@ -819,7 +842,7 @@ public: static void SetIsPacked(const CompilerType &type); static clang::VarDecl *AddVariableToRecordType(const CompilerType &type, - const char *name, + llvm::StringRef name, const CompilerType &var_type, lldb::AccessType access); @@ -831,19 +854,17 @@ public: bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial); + void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type); + // C++ Base Classes - clang::CXXBaseSpecifier * + std::unique_ptr<clang::CXXBaseSpecifier> CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, lldb::AccessType access, bool is_virtual, bool base_of_class); - static void DeleteBaseClassSpecifiers(clang::CXXBaseSpecifier **base_classes, - unsigned num_base_classes); - - bool - SetBaseClassesForClassType(lldb::opaque_compiler_type_t type, - clang::CXXBaseSpecifier const *const *base_classes, - unsigned num_base_classes); + bool TransferBaseClasses( + lldb::opaque_compiler_type_t type, + std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases); static bool SetObjCSuperClass(const CompilerType &type, const CompilerType &superclass_compiler_type); @@ -879,10 +900,12 @@ public: //---------------------------------------------------------------------- // Modifying Enumeration types //---------------------------------------------------------------------- - bool AddEnumerationValueToEnumerationType( - lldb::opaque_compiler_type_t type, - const CompilerType &enumerator_qual_type, const Declaration &decl, - const char *name, int64_t enum_value, uint32_t enum_value_bit_size); + clang::EnumConstantDecl *AddEnumerationValueToEnumerationType( + const CompilerType &enum_type, const Declaration &decl, const char *name, + int64_t enum_value, uint32_t enum_value_bit_size); + clang::EnumConstantDecl *AddEnumerationValueToEnumerationType( + const CompilerType &enum_type, const Declaration &decl, const char *name, + const llvm::APSInt &value); CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type); @@ -904,6 +927,8 @@ public: //---------------------------------------------------------------------- // Dumping types //---------------------------------------------------------------------- + void Dump(Stream &s); + void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, @@ -935,6 +960,8 @@ public: static clang::TagDecl *GetAsTagDecl(const CompilerType &type); + static clang::TypedefNameDecl *GetAsTypedefDecl(const CompilerType &type); + clang::CXXRecordDecl *GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type); static clang::ObjCInterfaceDecl * diff --git a/include/lldb/Symbol/ClangASTImporter.h b/include/lldb/Symbol/ClangASTImporter.h index 52a164a1d2dd..465d7e24a1e7 100644 --- a/include/lldb/Symbol/ClangASTImporter.h +++ b/include/lldb/Symbol/ClangASTImporter.h @@ -10,14 +10,11 @@ #ifndef liblldb_ClangASTImporter_h_ #define liblldb_ClangASTImporter_h_ -// C Includes -// C++ Includes #include <map> #include <memory> #include <set> #include <vector> -// Other libraries and framework includes #include "clang/AST/ASTImporter.h" #include "clang/AST/CharUnits.h" #include "clang/AST/Decl.h" @@ -25,7 +22,6 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/FileSystemOptions.h" -// Project includes #include "lldb/Symbol/CompilerDeclContext.h" #include "lldb/lldb-types.h" diff --git a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h index ef0010314e1d..c077665e51ee 100644 --- a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h +++ b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h @@ -10,15 +10,11 @@ #ifndef liblldb_ClangExternalASTSourceCallbacks_h_ #define liblldb_ClangExternalASTSourceCallbacks_h_ -// C Includes #include <stdint.h> -// C++ Includes -// Other libraries and framework includes #include "clang/AST/CharUnits.h" #include "llvm/ADT/DenseMap.h" -// Project includes #include "lldb/Core/ClangForward.h" #include "lldb/Symbol/ClangExternalASTSourceCommon.h" #include "lldb/Symbol/CompilerType.h" diff --git a/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/include/lldb/Symbol/ClangExternalASTSourceCommon.h index 3e700ba2439c..894c91f157da 100644 --- a/include/lldb/Symbol/ClangExternalASTSourceCommon.h +++ b/include/lldb/Symbol/ClangExternalASTSourceCommon.h @@ -20,7 +20,6 @@ // file. So we have to define NDEBUG when including clang headers to avoid any // mismatches. This is covered by rdar://problem/8691220 -// C Includes #if !defined(NDEBUG) && !defined(LLVM_NDEBUG_OFF) #define LLDB_DEFINED_NDEBUG_FOR_CLANG #define NDEBUG @@ -35,11 +34,8 @@ #include <assert.h> #endif -// C++ Includes -// Other libraries and framework includes #include "clang/AST/ExternalASTSource.h" -// Project includes #include "lldb/Core/dwarf.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-enumerations.h" diff --git a/include/lldb/Symbol/ClangUtil.h b/include/lldb/Symbol/ClangUtil.h index cb380221152a..c8638f782548 100644 --- a/include/lldb/Symbol/ClangUtil.h +++ b/include/lldb/Symbol/ClangUtil.h @@ -16,6 +16,10 @@ #include "lldb/Symbol/CompilerType.h" +namespace clang { +class TagDecl; +} + namespace lldb_private { struct ClangUtil { static bool IsClangType(const CompilerType &ct); @@ -25,6 +29,8 @@ struct ClangUtil { static clang::QualType GetCanonicalQualType(const CompilerType &ct); static CompilerType RemoveFastQualifiers(const CompilerType &ct); + + static clang::TagDecl *GetAsTagDecl(const CompilerType &type); }; } diff --git a/include/lldb/Symbol/CompileUnit.h b/include/lldb/Symbol/CompileUnit.h index b816439cee13..a4d19cd3d8ae 100644 --- a/include/lldb/Symbol/CompileUnit.h +++ b/include/lldb/Symbol/CompileUnit.h @@ -18,6 +18,8 @@ #include "lldb/Utility/UserID.h" #include "lldb/lldb-enumerations.h" +#include "llvm/ADT/DenseMap.h" + namespace lldb_private { //---------------------------------------------------------------------- /// @class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h" @@ -163,21 +165,19 @@ public: void GetDescription(Stream *s, lldb::DescriptionLevel level) const; //------------------------------------------------------------------ - /// Get a shared pointer to a function in this compile unit by index. + /// Apply a lambda to each function in this compile unit. /// - /// Typically called when iterating though all functions in a compile unit - /// after all functions have been parsed. This provides raw access to the - /// function shared pointer list and will not cause the SymbolFile plug-in - /// to parse any unparsed functions. + /// This provides raw access to the function shared pointer list and will not + /// cause the SymbolFile plug-in to parse any unparsed functions. /// - /// @param[in] idx - /// An index into the function list. + /// @note Prefer using FindFunctionByUID over this if possible. /// - /// @return - /// A shared pointer to a function that might contain a NULL - /// Function class pointer. + /// @param[in] lambda + /// The lambda that should be applied to every function. The lambda can + /// return true if the iteration should be aborted earlier. //------------------------------------------------------------------ - lldb::FunctionSP GetFunctionAtIndex(size_t idx); + void ForeachFunction( + llvm::function_ref<bool(const lldb::FunctionSP &)> lambda) const; //------------------------------------------------------------------ /// Dump the compile unit contents to the stream \a s. @@ -391,7 +391,7 @@ public: //------------------------------------------------------------------ uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, bool exact, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); //------------------------------------------------------------------ @@ -409,15 +409,20 @@ public: //------------------------------------------------------------------ bool GetIsOptimized(); + //------------------------------------------------------------------ + /// Returns the number of functions in this compile unit + //------------------------------------------------------------------ + size_t GetNumFunctions() const { return m_functions_by_uid.size(); } + protected: void *m_user_data; ///< User data for the SymbolFile parser to store ///information into. lldb::LanguageType m_language; ///< The programming language enumeration value. Flags m_flags; ///< Compile unit flags that help with partial parsing. - std::vector<lldb::FunctionSP> m_functions; ///< The sparsely populated list of - ///shared pointers to functions - ///< that gets populated as functions get partially parsed. + + /// Maps UIDs to functions. + llvm::DenseMap<lldb::user_id_t, lldb::FunctionSP> m_functions_by_uid; std::vector<ConstString> m_imported_modules; ///< All modules, including the ///current module, imported by ///this diff --git a/include/lldb/Symbol/CompilerType.h b/include/lldb/Symbol/CompilerType.h index 1170832a7396..353313d8e2a3 100644 --- a/include/lldb/Symbol/CompilerType.h +++ b/include/lldb/Symbol/CompilerType.h @@ -10,14 +10,10 @@ #ifndef liblldb_CompilerType_h_ #define liblldb_CompilerType_h_ -// C Includes -// C++ Includes #include <functional> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/ClangForward.h" #include "lldb/lldb-private.h" #include "llvm/ADT/APSInt.h" @@ -291,9 +287,10 @@ public: struct IntegralTemplateArgument; - uint64_t GetByteSize(ExecutionContextScope *exe_scope) const; - - uint64_t GetBitSize(ExecutionContextScope *exe_scope) const; + /// Return the size of the type in bytes. + llvm::Optional<uint64_t> GetByteSize(ExecutionContextScope *exe_scope) const; + /// Return the size of the type in bits. + llvm::Optional<uint64_t> GetBitSize(ExecutionContextScope *exe_scope) const; lldb::Encoding GetEncoding(uint64_t &count) const; @@ -301,7 +298,8 @@ public: size_t GetTypeBitAlign() const; - uint32_t GetNumChildren(bool omit_empty_base_classes) const; + uint32_t GetNumChildren(bool omit_empty_base_classes, + const ExecutionContext *exe_ctx) const; lldb::BasicType GetBasicTypeEnumeration() const; diff --git a/include/lldb/Symbol/DebugMacros.h b/include/lldb/Symbol/DebugMacros.h index 640da027cd59..86700994fbcc 100644 --- a/include/lldb/Symbol/DebugMacros.h +++ b/include/lldb/Symbol/DebugMacros.h @@ -10,13 +10,9 @@ #ifndef liblldb_DebugMacros_h_ #define liblldb_DebugMacros_h_ -// C Includes -// C++ Includes #include <memory> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/ConstString.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Symbol/Function.h b/include/lldb/Symbol/Function.h index 28c6b4857b10..447abd2e6f78 100644 --- a/include/lldb/Symbol/Function.h +++ b/include/lldb/Symbol/Function.h @@ -16,6 +16,7 @@ #include "lldb/Symbol/Block.h" #include "lldb/Symbol/Declaration.h" #include "lldb/Utility/UserID.h" +#include "llvm/ADT/ArrayRef.h" namespace lldb_private { @@ -290,6 +291,64 @@ private: Declaration m_call_decl; }; +class Function; + +//---------------------------------------------------------------------- +/// @class CallEdge Function.h "lldb/Symbol/Function.h" +/// +/// Represent a call made within a Function. This can be used to find a path +/// in the call graph between two functions. +//---------------------------------------------------------------------- +class CallEdge { +public: + /// Construct a call edge using a symbol name to identify the calling + /// function, and a return PC within the calling function to identify a + /// specific call site. + /// + /// TODO: A symbol name may not be globally unique. To disambiguate ODR + /// conflicts, it's necessary to determine the \c Target a call edge is + /// associated with before resolving it. + CallEdge(const char *symbol_name, lldb::addr_t return_pc); + + CallEdge(CallEdge &&) = default; + CallEdge &operator=(CallEdge &&) = default; + + /// Get the callee's definition. + /// + /// Note that this might lazily invoke the DWARF parser. + Function *GetCallee(ModuleList &images); + + /// Get the load PC address of the instruction which executes after the call + /// returns. Returns LLDB_INVALID_ADDRESS iff this is a tail call. \p caller + /// is the Function containing this call, and \p target is the Target which + /// made the call. + lldb::addr_t GetReturnPCAddress(Function &caller, Target &target) const; + + /// Like \ref GetReturnPCAddress, but returns an unslid function-local PC + /// offset. + lldb::addr_t GetUnresolvedReturnPCAddress() const { return return_pc; } + +private: + void ParseSymbolFileAndResolve(ModuleList &images); + + /// Either the callee's mangled name or its definition, discriminated by + /// \ref resolved. + union { + const char *symbol_name; + Function *def; + } lazy_callee; + + /// An invalid address if this is a tail call. Otherwise, the function-local + /// PC offset. Adding this PC offset to the function's base load address + /// gives the return PC for the call. + lldb::addr_t return_pc; + + /// Whether or not an attempt was made to find the callee's definition. + bool resolved; + + DISALLOW_COPY_AND_ASSIGN(CallEdge); +}; + //---------------------------------------------------------------------- /// @class Function Function.h "lldb/Symbol/Function.h" /// A class that describes a function. @@ -349,40 +408,6 @@ public: Type *func_type, const AddressRange &range); //------------------------------------------------------------------ - /// Construct with a compile unit, function UID, function type UID, optional - /// mangled name, function type, and a section offset based address range. - /// - /// @param[in] comp_unit - /// The compile unit to which this function belongs. - /// - /// @param[in] func_uid - /// The UID for this function. This value is provided by the - /// SymbolFile plug-in and can be any value that allows - /// the plug-in to quickly find and parse more detailed - /// information when and if more information is needed. - /// - /// @param[in] func_type_uid - /// The type UID for the function Type to allow for lazy type - /// parsing from the debug information. - /// - /// @param[in] mangled - /// The optional mangled name for this function. If empty, there - /// is no mangled information. - /// - /// @param[in] func_type - /// The optional function type. If NULL, the function type will - /// be parsed on demand when accessed using the - /// Function::GetType() function by asking the SymbolFile - /// plug-in to get the type for \a func_type_uid. - /// - /// @param[in] range - /// The section offset based address for this function. - //------------------------------------------------------------------ - Function(CompileUnit *comp_unit, lldb::user_id_t func_uid, - lldb::user_id_t func_type_uid, const char *mangled, Type *func_type, - const AddressRange &range); - - //------------------------------------------------------------------ /// Destructor. //------------------------------------------------------------------ ~Function() override; @@ -431,6 +456,18 @@ public: void GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no); //------------------------------------------------------------------ + /// Get the outgoing call edges from this function, sorted by their return + /// PC addresses (in increasing order). + //------------------------------------------------------------------ + llvm::MutableArrayRef<CallEdge> GetCallEdges(); + + //------------------------------------------------------------------ + /// Get the outgoing tail-calling edges from this function. If none exist, + /// return None. + //------------------------------------------------------------------ + llvm::MutableArrayRef<CallEdge> GetTailCallingEdges(); + + //------------------------------------------------------------------ /// Get accessor for the block list. /// /// @return @@ -621,6 +658,10 @@ protected: Flags m_flags; uint32_t m_prologue_byte_size; ///< Compute the prologue size once and cache it + + bool m_call_edges_resolved = false; ///< Whether call site info has been + /// parsed. + std::vector<CallEdge> m_call_edges; ///< Outgoing call edges. private: DISALLOW_COPY_AND_ASSIGN(Function); }; diff --git a/include/lldb/Symbol/GoASTContext.h b/include/lldb/Symbol/GoASTContext.h deleted file mode 100644 index 29c8cdceacff..000000000000 --- a/include/lldb/Symbol/GoASTContext.h +++ /dev/null @@ -1,421 +0,0 @@ -//===-- GoASTContext.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_GoASTContext_h_ -#define liblldb_GoASTContext_h_ - -// C Includes -// C++ Includes -#include <map> -#include <memory> -#include <set> -#include <string> -#include <vector> - -// Other libraries and framework includes -// Project includes -#include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/TypeSystem.h" -#include "lldb/Utility/ConstString.h" - -namespace lldb_private { - -class Declaration; -class GoType; - -class GoASTContext : public TypeSystem { -public: - GoASTContext(); - ~GoASTContext() override; - - //------------------------------------------------------------------ - // PluginInterface functions - //------------------------------------------------------------------ - ConstString GetPluginName() override; - - uint32_t GetPluginVersion() override; - - static ConstString GetPluginNameStatic(); - - static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, - Module *module, Target *target); - - static void EnumerateSupportedLanguages( - std::set<lldb::LanguageType> &languages_for_types, - std::set<lldb::LanguageType> &languages_for_expressions); - - static void Initialize(); - - static void Terminate(); - - DWARFASTParser *GetDWARFParser() override; - - void SetAddressByteSize(int byte_size) { m_pointer_byte_size = byte_size; } - - //------------------------------------------------------------------ - // llvm casting support - //------------------------------------------------------------------ - static bool classof(const TypeSystem *ts) { - return ts->getKind() == TypeSystem::eKindGo; - } - - //---------------------------------------------------------------------- - // CompilerDecl functions - //---------------------------------------------------------------------- - ConstString DeclGetName(void *opaque_decl) override { return ConstString(); } - - //---------------------------------------------------------------------- - // CompilerDeclContext functions - //---------------------------------------------------------------------- - - bool DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) override { - return false; - } - - ConstString DeclContextGetName(void *opaque_decl_ctx) override { - return ConstString(); - } - - ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override { - return ConstString(); - } - - bool - DeclContextIsClassMethod(void *opaque_decl_ctx, - lldb::LanguageType *language_ptr, - bool *is_instance_method_ptr, - ConstString *language_object_name_ptr) override { - return false; - } - - //---------------------------------------------------------------------- - // Creating Types - //---------------------------------------------------------------------- - - CompilerType CreateArrayType(const ConstString &name, - const CompilerType &element_type, - uint64_t length); - - CompilerType CreateBaseType(int go_kind, - const ConstString &type_name_const_str, - uint64_t byte_size); - - // For interface, map, chan. - CompilerType CreateTypedefType(int kind, const ConstString &name, - CompilerType impl); - - CompilerType CreateVoidType(const ConstString &name); - CompilerType CreateFunctionType(const lldb_private::ConstString &name, - CompilerType *params, size_t params_count, - bool is_variadic); - - CompilerType CreateStructType(int kind, const ConstString &name, - uint32_t byte_size); - - void CompleteStructType(const CompilerType &type); - - void AddFieldToStruct(const CompilerType &struct_type, - const ConstString &name, const CompilerType &field_type, - uint32_t byte_offset); - - //---------------------------------------------------------------------- - // Tests - //---------------------------------------------------------------------- - - static bool IsGoString(const CompilerType &type); - static bool IsGoSlice(const CompilerType &type); - static bool IsGoInterface(const CompilerType &type); - static bool IsDirectIface(uint8_t kind); - static bool IsPointerKind(uint8_t kind); - - bool IsArrayType(lldb::opaque_compiler_type_t type, - CompilerType *element_type, uint64_t *size, - bool *is_incomplete) override; - - bool IsAggregateType(lldb::opaque_compiler_type_t type) override; - - bool IsCharType(lldb::opaque_compiler_type_t type) override; - - bool IsCompleteType(lldb::opaque_compiler_type_t type) override; - - bool IsDefined(lldb::opaque_compiler_type_t type) override; - - bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, - bool &is_complex) override; - - bool IsFunctionType(lldb::opaque_compiler_type_t type, - bool *is_variadic_ptr = nullptr) override; - - size_t - GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override; - - CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, - const size_t index) override; - - bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override; - - bool IsBlockPointerType(lldb::opaque_compiler_type_t type, - CompilerType *function_pointer_type_ptr) override; - - bool IsIntegerType(lldb::opaque_compiler_type_t type, - bool &is_signed) override; - - bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, - CompilerType *target_type, // Can pass nullptr - bool check_cplusplus, bool check_objc) override; - - bool IsPointerType(lldb::opaque_compiler_type_t type, - CompilerType *pointee_type = nullptr) override; - - bool IsScalarType(lldb::opaque_compiler_type_t type) override; - - bool IsVoidType(lldb::opaque_compiler_type_t type) override; - - bool SupportsLanguage(lldb::LanguageType language) override; - - //---------------------------------------------------------------------- - // Type Completion - //---------------------------------------------------------------------- - - bool GetCompleteType(lldb::opaque_compiler_type_t type) override; - - //---------------------------------------------------------------------- - // AST related queries - //---------------------------------------------------------------------- - - uint32_t GetPointerByteSize() override; - - //---------------------------------------------------------------------- - // Accessors - //---------------------------------------------------------------------- - - ConstString GetTypeName(lldb::opaque_compiler_type_t type) override; - - uint32_t GetTypeInfo( - lldb::opaque_compiler_type_t type, - CompilerType *pointee_or_element_compiler_type = nullptr) override; - - lldb::LanguageType - GetMinimumLanguage(lldb::opaque_compiler_type_t type) override; - - lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override; - - //---------------------------------------------------------------------- - // Creating related types - //---------------------------------------------------------------------- - - CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, - uint64_t *stride = nullptr) override; - - CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override; - - // Returns -1 if this isn't a function of if the function doesn't have a - // prototype Returns a value >= 0 if there is a prototype. - int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override; - - CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, - size_t idx) override; - - CompilerType - GetFunctionReturnType(lldb::opaque_compiler_type_t type) override; - - size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override; - - TypeMemberFunctionImpl - GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, - size_t idx) override; - - CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override; - - //---------------------------------------------------------------------- - // Exploring the type - //---------------------------------------------------------------------- - - uint64_t GetBitSize(lldb::opaque_compiler_type_t type, - ExecutionContextScope *exe_scope) override; - - lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, - uint64_t &count) override; - - lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override; - - uint32_t GetNumChildren(lldb::opaque_compiler_type_t type, - bool omit_empty_base_classes) override; - - lldb::BasicType - GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override; - - CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, - size_t bit_size) override; - - uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override; - - CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, - std::string &name, uint64_t *bit_offset_ptr, - uint32_t *bitfield_bit_size_ptr, - bool *is_bitfield_ptr) override; - - uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override { - return 0; - } - - uint32_t - GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override { - return 0; - } - - CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, - size_t idx, - uint32_t *bit_offset_ptr) override { - return CompilerType(); - } - - CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, - size_t idx, - uint32_t *bit_offset_ptr) override { - return CompilerType(); - } - - CompilerType GetChildCompilerTypeAtIndex( - lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, - bool transparent_pointers, bool omit_empty_base_classes, - bool ignore_array_bounds, std::string &child_name, - uint32_t &child_byte_size, int32_t &child_byte_offset, - uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class, bool &child_is_deref_of_parent, - ValueObject *valobj, uint64_t &language_flags) override; - - // Lookup a child given a name. This function will match base class names and - // member member names in "clang_type" only, not descendants. - uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, - const char *name, - bool omit_empty_base_classes) override; - - // Lookup a child member given a name. This function will match member names - // only and will descend into "clang_type" children in search for the first - // member in this class, or any base class that matches "name". - // TODO: Return all matches for a given name by returning a - // vector<vector<uint32_t>> - // so we catch all names that match a given child name, not just the first. - size_t - GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, - const char *name, bool omit_empty_base_classes, - std::vector<uint32_t> &child_indexes) override; - - size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override { - return 0; - } - - //---------------------------------------------------------------------- - // Dumping types - //---------------------------------------------------------------------- - void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, - Stream *s, lldb::Format format, const DataExtractor &data, - lldb::offset_t data_offset, size_t data_byte_size, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, - bool show_types, bool show_summary, bool verbose, - uint32_t depth) override; - - bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s, - lldb::Format format, const DataExtractor &data, - lldb::offset_t data_offset, size_t data_byte_size, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, - ExecutionContextScope *exe_scope) override; - - void DumpTypeDescription( - lldb::opaque_compiler_type_t type) override; // Dump to stdout - - void DumpTypeDescription(lldb::opaque_compiler_type_t type, - Stream *s) override; - - //---------------------------------------------------------------------- - // TODO: These methods appear unused. Should they be removed? - //---------------------------------------------------------------------- - - bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override; - - void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, - Stream *s, const DataExtractor &data, - lldb::offset_t data_offset, size_t data_byte_size) override; - - // Converts "s" to a floating point value and place resulting floating point - // bytes in the "dst" buffer. - size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, - const char *s, uint8_t *dst, - size_t dst_size) override; - - //---------------------------------------------------------------------- - // TODO: Determine if these methods should move to ClangASTContext. - //---------------------------------------------------------------------- - - bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, - CompilerType *pointee_type = nullptr) override; - - unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override; - - bool IsCStringType(lldb::opaque_compiler_type_t type, - uint32_t &length) override; - - size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) override; - - CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override; - - bool IsBeingDefined(lldb::opaque_compiler_type_t type) override; - - bool IsConst(lldb::opaque_compiler_type_t type) override; - - uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, - CompilerType *base_type_ptr) override; - - bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override; - - bool IsTypedefType(lldb::opaque_compiler_type_t type) override; - - // If the current object represents a typedef type, get the underlying type - CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override; - - bool IsVectorType(lldb::opaque_compiler_type_t type, - CompilerType *element_type, uint64_t *size) override; - - CompilerType - GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override; - - bool IsReferenceType(lldb::opaque_compiler_type_t type, - CompilerType *pointee_type = nullptr, - bool *is_rvalue = nullptr) override; - -private: - typedef std::map<ConstString, std::unique_ptr<GoType>> TypeMap; - int m_pointer_byte_size; - int m_int_byte_size; - std::unique_ptr<TypeMap> m_types; - std::unique_ptr<DWARFASTParser> m_dwarf_ast_parser_ap; - - GoASTContext(const GoASTContext &) = delete; - const GoASTContext &operator=(const GoASTContext &) = delete; -}; - -class GoASTContextForExpr : public GoASTContext { -public: - GoASTContextForExpr(lldb::TargetSP target) : m_target_wp(target) {} - UserExpression * - GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix, - lldb::LanguageType language, - Expression::ResultType desired_type, - const EvaluateExpressionOptions &options) override; - -private: - lldb::TargetWP m_target_wp; -}; -} -#endif // liblldb_GoASTContext_h_ diff --git a/include/lldb/Symbol/JavaASTContext.h b/include/lldb/Symbol/JavaASTContext.h deleted file mode 100644 index 41a881dcf4eb..000000000000 --- a/include/lldb/Symbol/JavaASTContext.h +++ /dev/null @@ -1,350 +0,0 @@ -//===-- JavaASTContext.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_JavaASTContext_h_ -#define liblldb_JavaASTContext_h_ - -// C Includes -// C++ Includes -#include <map> -#include <memory> -#include <set> - -// Other libraries and framework includes -// Project includes -#include "lldb/Symbol/TypeSystem.h" -#include "lldb/Utility/ConstString.h" - -namespace lldb_private { - -class JavaASTContext : public TypeSystem { -public: - class JavaType; - typedef std::map<ConstString, std::unique_ptr<JavaType>> JavaTypeMap; - - JavaASTContext(const ArchSpec &arch); - ~JavaASTContext() override; - - //------------------------------------------------------------------ - // PluginInterface functions - //------------------------------------------------------------------ - ConstString GetPluginName() override; - - uint32_t GetPluginVersion() override; - - static ConstString GetPluginNameStatic(); - - static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, - Module *module, Target *target); - - static void EnumerateSupportedLanguages( - std::set<lldb::LanguageType> &languages_for_types, - std::set<lldb::LanguageType> &languages_for_expressions); - - static void Initialize(); - - static void Terminate(); - - DWARFASTParser *GetDWARFParser() override; - - uint32_t GetPointerByteSize() override; - - //---------------------------------------------------------------------- - // CompilerDecl functions - //---------------------------------------------------------------------- - ConstString DeclGetName(void *opaque_decl) override; - - //---------------------------------------------------------------------- - // CompilerDeclContext functions - //---------------------------------------------------------------------- - - std::vector<CompilerDecl> - DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name, - const bool ignore_imported_decls) override; - - bool DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) override; - - ConstString DeclContextGetName(void *opaque_decl_ctx) override; - - bool DeclContextIsClassMethod(void *opaque_decl_ctx, - lldb::LanguageType *language_ptr, - bool *is_instance_method_ptr, - ConstString *language_object_name_ptr) override; - - //---------------------------------------------------------------------- - // Tests - //---------------------------------------------------------------------- - - bool IsArrayType(lldb::opaque_compiler_type_t type, - CompilerType *element_type, uint64_t *size, - bool *is_incomplete) override; - - bool IsAggregateType(lldb::opaque_compiler_type_t type) override; - - bool IsCharType(lldb::opaque_compiler_type_t type) override; - - bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, - bool &is_complex) override; - - bool IsFunctionType(lldb::opaque_compiler_type_t type, - bool *is_variadic_ptr = nullptr) override; - - size_t - GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override; - - CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, - const size_t index) override; - - bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override; - - bool IsBlockPointerType(lldb::opaque_compiler_type_t type, - CompilerType *function_pointer_type_ptr) override; - - bool IsIntegerType(lldb::opaque_compiler_type_t type, - bool &is_signed) override; - - bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, - CompilerType *target_type, bool check_cplusplus, - bool check_objc) override; - - bool IsPointerType(lldb::opaque_compiler_type_t type, - CompilerType *pointee_type = nullptr) override; - - bool IsReferenceType(lldb::opaque_compiler_type_t type, - CompilerType *pointee_type = nullptr, - bool *is_rvalue = nullptr) override; - - bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, - CompilerType *pointee_type = nullptr) override; - - bool IsScalarType(lldb::opaque_compiler_type_t type) override; - - bool IsVoidType(lldb::opaque_compiler_type_t type) override; - - bool IsCStringType(lldb::opaque_compiler_type_t type, - uint32_t &length) override; - - bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override; - - bool IsTypedefType(lldb::opaque_compiler_type_t type) override; - - bool IsVectorType(lldb::opaque_compiler_type_t type, - CompilerType *element_type, uint64_t *size) override; - - bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override; - - bool IsCompleteType(lldb::opaque_compiler_type_t type) override; - - bool IsConst(lldb::opaque_compiler_type_t type) override; - - bool IsBeingDefined(lldb::opaque_compiler_type_t type) override; - - bool IsDefined(lldb::opaque_compiler_type_t type) override; - - uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, - CompilerType *base_type_ptr) override; - - bool SupportsLanguage(lldb::LanguageType language) override; - - bool GetCompleteType(lldb::opaque_compiler_type_t type) override; - - ConstString GetTypeName(lldb::opaque_compiler_type_t type) override; - - uint32_t GetTypeInfo( - lldb::opaque_compiler_type_t type, - CompilerType *pointee_or_element_compiler_type = nullptr) override; - - lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override; - - lldb::LanguageType - GetMinimumLanguage(lldb::opaque_compiler_type_t type) override; - - CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, - uint64_t *stride = nullptr) override; - - CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override; - - CompilerType - GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override; - - CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, - size_t bit_size) override; - - size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) override; - - lldb::BasicType - GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override; - - uint64_t GetBitSize(lldb::opaque_compiler_type_t type, - ExecutionContextScope *exe_scope) override; - - lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, - uint64_t &count) override; - - lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override; - - unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override; - - size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override; - - int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override; - - CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, - size_t idx) override; - - CompilerType - GetFunctionReturnType(lldb::opaque_compiler_type_t type) override; - - size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override; - - TypeMemberFunctionImpl - GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, - size_t idx) override; - - uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override; - - CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, - std::string &name, uint64_t *bit_offset_ptr, - uint32_t *bitfield_bit_size_ptr, - bool *is_bitfield_ptr) override; - - uint32_t GetNumChildren(lldb::opaque_compiler_type_t type, - bool omit_empty_base_classes) override; - - uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override; - - uint32_t GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override; - - CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, - size_t idx, - uint32_t *bit_offset_ptr) override; - - CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, - size_t idx, - uint32_t *bit_offset_ptr) override; - - size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, - const char *s, uint8_t *dst, - size_t dst_size) override; - - void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, - Stream *s, lldb::Format format, const DataExtractor &data, - lldb::offset_t data_offset, size_t data_byte_size, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, - bool show_types, bool show_summary, bool verbose, - uint32_t depth) override; - - bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s, - lldb::Format format, const DataExtractor &data, - lldb::offset_t data_offset, size_t data_byte_size, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, - ExecutionContextScope *exe_scope) override; - - void DumpTypeDescription(lldb::opaque_compiler_type_t type) override; - - void DumpTypeDescription(lldb::opaque_compiler_type_t type, - Stream *s) override; - - void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, - Stream *s, const DataExtractor &data, - lldb::offset_t data_offset, size_t data_byte_size) override; - - CompilerType GetChildCompilerTypeAtIndex( - lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, - bool transparent_pointers, bool omit_empty_base_classes, - bool ignore_array_bounds, std::string &child_name, - uint32_t &child_byte_size, int32_t &child_byte_offset, - uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class, bool &child_is_deref_of_parent, - ValueObject *valobj, uint64_t &language_flags) override; - - uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, - const char *name, - bool omit_empty_base_classes) override; - - size_t - GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, - const char *name, bool omit_empty_base_classes, - std::vector<uint32_t> &child_indexes) override; - - CompilerType - GetLValueReferenceType(lldb::opaque_compiler_type_t type) override; - - ConstString DeclContextGetScopeQualifiedName( - lldb::opaque_compiler_type_t opaque_decl_ctx) override; - - CompilerType CreateBaseType(const ConstString &name); - - CompilerType CreateObjectType(const ConstString &name, - const ConstString &linkage_name, - uint32_t byte_size); - - CompilerType CreateArrayType(const ConstString &linkage_name, - const CompilerType &element_type, - const DWARFExpression &length_expression, - const lldb::addr_t data_offset); - - CompilerType CreateReferenceType(const CompilerType &pointee_type); - - void CompleteObjectType(const CompilerType &object_type); - - void AddBaseClassToObject(const CompilerType &object_type, - const CompilerType &member_type, - uint32_t member_offset); - - void AddMemberToObject(const CompilerType &object_type, - const ConstString &name, - const CompilerType &member_type, - uint32_t member_offset); - - void SetDynamicTypeId(const CompilerType &type, - const DWARFExpression &type_id); - - static uint64_t CalculateDynamicTypeId(ExecutionContext *exe_ctx, - const CompilerType &type, - ValueObject &in_value); - - static ConstString GetLinkageName(const CompilerType &type); - - static uint32_t CalculateArraySize(const CompilerType &type, - ValueObject &in_value); - - static uint64_t CalculateArrayElementOffset(const CompilerType &type, - size_t index); - - //------------------------------------------------------------------ - // llvm casting support - //------------------------------------------------------------------ - static bool classof(const TypeSystem *ts) { - return ts->getKind() == TypeSystem::eKindJava; - } - -private: - uint32_t m_pointer_byte_size; - std::unique_ptr<DWARFASTParser> m_dwarf_ast_parser_ap; - JavaTypeMap m_array_type_map; - JavaTypeMap m_base_type_map; - JavaTypeMap m_reference_type_map; - JavaTypeMap m_object_type_map; - - JavaASTContext(const JavaASTContext &) = delete; - const JavaASTContext &operator=(const JavaASTContext &) = delete; -}; -} -#endif // liblldb_JavaASTContext_h_ diff --git a/include/lldb/Symbol/LineTable.h b/include/lldb/Symbol/LineTable.h index fe8be0c55764..684972d50789 100644 --- a/include/lldb/Symbol/LineTable.h +++ b/include/lldb/Symbol/LineTable.h @@ -10,12 +10,8 @@ #ifndef liblldb_LineTable_h_ #define liblldb_LineTable_h_ -// C Includes -// C++ Includes #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/ModuleChild.h" #include "lldb/Core/RangeMap.h" #include "lldb/Core/Section.h" @@ -242,21 +238,22 @@ public: protected: struct Entry { Entry() - : file_addr(LLDB_INVALID_ADDRESS), line(0), column(0), file_idx(0), + : file_addr(LLDB_INVALID_ADDRESS), line(0), is_start_of_statement(false), is_start_of_basic_block(false), is_prologue_end(false), is_epilogue_begin(false), - is_terminal_entry(false) {} + is_terminal_entry(false), column(0), file_idx(0) {} Entry(lldb::addr_t _file_addr, uint32_t _line, uint16_t _column, uint16_t _file_idx, bool _is_start_of_statement, bool _is_start_of_basic_block, bool _is_prologue_end, bool _is_epilogue_begin, bool _is_terminal_entry) - : file_addr(_file_addr), line(_line), column(_column), - file_idx(_file_idx), is_start_of_statement(_is_start_of_statement), + : file_addr(_file_addr), line(_line), + is_start_of_statement(_is_start_of_statement), is_start_of_basic_block(_is_start_of_basic_block), is_prologue_end(_is_prologue_end), is_epilogue_begin(_is_epilogue_begin), - is_terminal_entry(_is_terminal_entry) {} + is_terminal_entry(_is_terminal_entry), column(_column), + file_idx(_file_idx) {} int bsearch_compare(const void *key, const void *arrmem); @@ -310,26 +307,30 @@ protected: //------------------------------------------------------------------ // Member variables. //------------------------------------------------------------------ - lldb::addr_t file_addr; ///< The file address for this line entry - uint32_t line; ///< The source line number, or zero if there is no line - ///number information. - uint16_t column; ///< The column number of the source line, or zero if there - ///is no column information. - uint16_t file_idx : 11, ///< The file index into CompileUnit's file table, - ///or zero if there is no file information. - is_start_of_statement : 1, ///< Indicates this entry is the beginning of - ///a statement. - is_start_of_basic_block : 1, ///< Indicates this entry is the beginning - ///of a basic block. - is_prologue_end : 1, ///< Indicates this entry is one (of possibly many) - ///where execution should be suspended for an entry - ///breakpoint of a function. - is_epilogue_begin : 1, ///< Indicates this entry is one (of possibly - ///many) where execution should be suspended for - ///an exit breakpoint of a function. - is_terminal_entry : 1; ///< Indicates this entry is that of the first - ///byte after the end of a sequence of target - ///machine instructions. + /// The file address for this line entry. + lldb::addr_t file_addr; + /// The source line number, or zero if there is no line number + /// information. + uint32_t line : 27; + /// Indicates this entry is the beginning of a statement. + uint32_t is_start_of_statement : 1; + /// Indicates this entry is the beginning of a basic block. + uint32_t is_start_of_basic_block : 1; + /// Indicates this entry is one (of possibly many) where execution + /// should be suspended for an entry breakpoint of a function. + uint32_t is_prologue_end : 1; + /// Indicates this entry is one (of possibly many) where execution + /// should be suspended for an exit breakpoint of a function. + uint32_t is_epilogue_begin : 1; + /// Indicates this entry is that of the first byte after the end + /// of a sequence of target machine instructions. + uint32_t is_terminal_entry : 1; + /// The column number of the source line, or zero if there is no + /// column information. + uint16_t column; + /// The file index into CompileUnit's file table, or zero if there + /// is no file information. + uint16_t file_idx; }; struct EntrySearchInfo { diff --git a/include/lldb/Symbol/OCamlASTContext.h b/include/lldb/Symbol/OCamlASTContext.h deleted file mode 100644 index 7144886e1c75..000000000000 --- a/include/lldb/Symbol/OCamlASTContext.h +++ /dev/null @@ -1,318 +0,0 @@ -//===-- OCamlASTContext.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_OCamlASTContext_h_ -#define liblldb_OCamlASTContext_h_ - -// C Includes -// C++ Includes -#include <map> -#include <memory> -#include <set> -#include <string> -#include <vector> - -// Other libraries and framework includes -// Project includes -#include "lldb/Symbol/CompilerType.h" -#include "lldb/Symbol/TypeSystem.h" -#include "lldb/Utility/ConstString.h" - -namespace lldb_private { - -class OCamlASTContext : public TypeSystem { -public: - class OCamlType; - typedef std::map<ConstString, std::unique_ptr<OCamlType>> OCamlTypeMap; - - OCamlASTContext(); - ~OCamlASTContext() override; - - ConstString GetPluginName() override; - - uint32_t GetPluginVersion() override; - - static ConstString GetPluginNameStatic(); - - static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language, - Module *module, Target *target); - - static void EnumerateSupportedLanguages( - std::set<lldb::LanguageType> &languages_for_types, - std::set<lldb::LanguageType> &languages_for_expressions); - - static void Initialize(); - - static void Terminate(); - - DWARFASTParser *GetDWARFParser() override; - - void SetAddressByteSize(int byte_size) { m_pointer_byte_size = byte_size; } - - static bool classof(const TypeSystem *ts) { - return ts->getKind() == TypeSystem::eKindOCaml; - } - - ConstString DeclGetName(void *opaque_decl) override { return ConstString(); } - - bool DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) override { - return false; - } - - ConstString DeclContextGetName(void *opaque_decl_ctx) override { - return ConstString(); - } - - ConstString DeclContextGetScopeQualifiedName(void *opaque_decl_ctx) override { - return ConstString(); - } - - bool - DeclContextIsClassMethod(void *opaque_decl_ctx, - lldb::LanguageType *language_ptr, - bool *is_instance_method_ptr, - ConstString *language_object_name_ptr) override { - return false; - } - - bool SupportsLanguage(lldb::LanguageType language) override; - uint32_t GetPointerByteSize() override; - - bool IsArrayType(lldb::opaque_compiler_type_t type, - CompilerType *element_type, uint64_t *size, - bool *is_incomplete) override; - - bool IsAggregateType(lldb::opaque_compiler_type_t type) override; - - bool IsCharType(lldb::opaque_compiler_type_t type) override; - - bool IsCompleteType(lldb::opaque_compiler_type_t type) override; - - bool IsDefined(lldb::opaque_compiler_type_t type) override; - - bool IsFloatingPointType(lldb::opaque_compiler_type_t type, uint32_t &count, - bool &is_complex) override; - - bool IsFunctionType(lldb::opaque_compiler_type_t type, - bool *is_variadic_ptr = nullptr) override; - - size_t - GetNumberOfFunctionArguments(lldb::opaque_compiler_type_t type) override; - - CompilerType GetFunctionArgumentAtIndex(lldb::opaque_compiler_type_t type, - const size_t index) override; - - bool IsFunctionPointerType(lldb::opaque_compiler_type_t type) override; - - bool IsBlockPointerType(lldb::opaque_compiler_type_t type, - CompilerType *function_pointer_type_ptr) override; - - bool IsIntegerType(lldb::opaque_compiler_type_t type, - bool &is_signed) override; - - bool IsPossibleDynamicType(lldb::opaque_compiler_type_t type, - CompilerType *target_type, bool check_cplusplus, - bool check_objc) override; - - bool IsPointerType(lldb::opaque_compiler_type_t type, - CompilerType *pointee_type = nullptr) override; - - bool IsScalarType(lldb::opaque_compiler_type_t type) override; - - bool IsVoidType(lldb::opaque_compiler_type_t type) override; - - bool GetCompleteType(lldb::opaque_compiler_type_t type) override; - - ConstString GetTypeName(lldb::opaque_compiler_type_t type) override; - - uint32_t GetTypeInfo( - lldb::opaque_compiler_type_t type, - CompilerType *pointee_or_element_compiler_type = nullptr) override; - - lldb::LanguageType - GetMinimumLanguage(lldb::opaque_compiler_type_t type) override; - - lldb::TypeClass GetTypeClass(lldb::opaque_compiler_type_t type) override; - - CompilerType GetArrayElementType(lldb::opaque_compiler_type_t type, - uint64_t *stride = nullptr) override; - - CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) override; - - int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) override; - - CompilerType GetFunctionArgumentTypeAtIndex(lldb::opaque_compiler_type_t type, - size_t idx) override; - - CompilerType - GetFunctionReturnType(lldb::opaque_compiler_type_t type) override; - - size_t GetNumMemberFunctions(lldb::opaque_compiler_type_t type) override; - - TypeMemberFunctionImpl - GetMemberFunctionAtIndex(lldb::opaque_compiler_type_t type, - size_t idx) override; - - CompilerType GetPointeeType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetPointerType(lldb::opaque_compiler_type_t type) override; - - uint64_t GetBitSize(lldb::opaque_compiler_type_t type, - ExecutionContextScope *exe_scope) override; - - lldb::Encoding GetEncoding(lldb::opaque_compiler_type_t type, - uint64_t &count) override; - - lldb::Format GetFormat(lldb::opaque_compiler_type_t type) override; - - uint32_t GetNumChildren(lldb::opaque_compiler_type_t type, - bool omit_empty_base_classes) override; - - lldb::BasicType - GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) override; - - CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, - size_t bit_size) override; - - uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override; - - CompilerType GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, - std::string &name, uint64_t *bit_offset_ptr, - uint32_t *bitfield_bit_size_ptr, - bool *is_bitfield_ptr) override; - - uint32_t GetNumDirectBaseClasses(lldb::opaque_compiler_type_t type) override { - return 0; - } - - uint32_t - GetNumVirtualBaseClasses(lldb::opaque_compiler_type_t type) override { - return 0; - } - - CompilerType GetDirectBaseClassAtIndex(lldb::opaque_compiler_type_t type, - size_t idx, - uint32_t *bit_offset_ptr) override { - return CompilerType(); - } - - CompilerType GetVirtualBaseClassAtIndex(lldb::opaque_compiler_type_t type, - size_t idx, - uint32_t *bit_offset_ptr) override { - return CompilerType(); - } - - CompilerType GetChildCompilerTypeAtIndex( - lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx, - bool transparent_pointers, bool omit_empty_base_classes, - bool ignore_array_bounds, std::string &child_name, - uint32_t &child_byte_size, int32_t &child_byte_offset, - uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class, bool &child_is_deref_of_parent, - ValueObject *valobj, uint64_t &language_flags) override; - - uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, - const char *name, - bool omit_empty_base_classes) override; - - size_t - GetIndexOfChildMemberWithName(lldb::opaque_compiler_type_t type, - const char *name, bool omit_empty_base_classes, - std::vector<uint32_t> &child_indexes) override; - - size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) override { - return 0; - } - - void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, - Stream *s, lldb::Format format, const DataExtractor &data, - lldb::offset_t data_offset, size_t data_byte_size, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, - bool show_types, bool show_summary, bool verbose, - uint32_t depth) override; - - bool DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s, - lldb::Format format, const DataExtractor &data, - lldb::offset_t data_offset, size_t data_byte_size, - uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, - ExecutionContextScope *exe_scope) override; - - void DumpTypeDescription(lldb::opaque_compiler_type_t type) override; - - void DumpTypeDescription(lldb::opaque_compiler_type_t type, - Stream *s) override; - - bool IsRuntimeGeneratedType(lldb::opaque_compiler_type_t type) override; - - void DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, - Stream *s, const DataExtractor &data, - lldb::offset_t data_offset, size_t data_byte_size) override; - - size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, - const char *s, uint8_t *dst, - size_t dst_size) override; - - bool IsPointerOrReferenceType(lldb::opaque_compiler_type_t type, - CompilerType *pointee_type = nullptr) override; - - unsigned GetTypeQualifiers(lldb::opaque_compiler_type_t type) override; - - bool IsCStringType(lldb::opaque_compiler_type_t type, - uint32_t &length) override; - - size_t GetTypeBitAlign(lldb::opaque_compiler_type_t type) override; - - CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) override; - - bool IsBeingDefined(lldb::opaque_compiler_type_t type) override; - - bool IsConst(lldb::opaque_compiler_type_t type) override; - - uint32_t IsHomogeneousAggregate(lldb::opaque_compiler_type_t type, - CompilerType *base_type_ptr) override; - - bool IsPolymorphicClass(lldb::opaque_compiler_type_t type) override; - - bool IsTypedefType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetTypedefedType(lldb::opaque_compiler_type_t type) override; - - bool IsVectorType(lldb::opaque_compiler_type_t type, - CompilerType *element_type, uint64_t *size) override; - - CompilerType - GetFullyUnqualifiedType(lldb::opaque_compiler_type_t type) override; - - CompilerType GetNonReferenceType(lldb::opaque_compiler_type_t type) override; - - bool IsReferenceType(lldb::opaque_compiler_type_t type, - CompilerType *pointee_type = nullptr, - bool *is_rvalue = nullptr) override; - - CompilerType CreateBaseType(const ConstString &name, uint64_t); - -private: - int m_pointer_byte_size; - std::unique_ptr<DWARFASTParser> m_dwarf_ast_parser_ap; - OCamlTypeMap m_base_type_map; - - OCamlASTContext(const OCamlASTContext &) = delete; - const OCamlASTContext &operator=(const OCamlASTContext &) = delete; -}; - -class OCamlASTContextForExpr : public OCamlASTContext { -public: - OCamlASTContextForExpr(lldb::TargetSP target) : m_target_wp(target) {} - -private: - lldb::TargetWP m_target_wp; -}; -} -#endif // liblldb_OCamlASTContext_h_ diff --git a/include/lldb/Symbol/ObjectContainer.h b/include/lldb/Symbol/ObjectContainer.h index 2138d22808c3..1e14856ea6ea 100644 --- a/include/lldb/Symbol/ObjectContainer.h +++ b/include/lldb/Symbol/ObjectContainer.h @@ -10,10 +10,6 @@ #ifndef liblldb_ObjectContainer_h_ #define liblldb_ObjectContainer_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/DataExtractor.h" diff --git a/include/lldb/Symbol/ObjectFile.h b/include/lldb/Symbol/ObjectFile.h index 1e9ae8b45417..c6bafcecb6f6 100644 --- a/include/lldb/Symbol/ObjectFile.h +++ b/include/lldb/Symbol/ObjectFile.h @@ -40,7 +40,7 @@ public: virtual void PopulateSectionList(lldb_private::ObjectFile *obj_file, lldb_private::SectionList §ion_list) = 0; - virtual bool GetArchitecture(lldb_private::ArchSpec &arch) = 0; + virtual ArchSpec GetArchitecture() = 0; }; //---------------------------------------------------------------------- @@ -305,19 +305,13 @@ public: virtual const FileSpec &GetFileSpec() const { return m_file; } //------------------------------------------------------------------ - /// Get the name of the cpu, vendor and OS for this object file. - /// - /// This value is a string that represents the target triple where the cpu - /// type, the vendor and the OS are encoded into a string. - /// - /// @param[out] target_triple - /// The string value of the target triple. + /// Get the ArchSpec for this object file. /// /// @return - /// \b True if the target triple was able to be computed, \b - /// false otherwise. + /// The ArchSpec of this object file. In case of error, an invalid + /// ArchSpec object is returned. //------------------------------------------------------------------ - virtual bool GetArchitecture(ArchSpec &arch) = 0; + virtual ArchSpec GetArchitecture() = 0; //------------------------------------------------------------------ /// Gets the section list for the currently selected architecture (and @@ -551,18 +545,16 @@ public: virtual lldb_private::Address GetEntryPointAddress() { return Address(); } //------------------------------------------------------------------ - /// Returns the address that represents the header of this object file. + /// Returns base address of this object file. /// - /// The header address is defined as where the header for the object file is - /// that describes the content of the file. If the header doesn't appear in - /// a section that is defined in the object file, an address with no section - /// is returned that has the file offset set in the m_file_offset member of - /// the lldb_private::Address object. - /// - /// @return - /// Returns the entry address for this module. + /// This also sometimes referred to as the "preferred load address" or the + /// "image base address". Addresses within object files are often expressed + /// relative to this base. If this address corresponds to a specific section + /// (usually the first byte of the first section) then the returned address + /// will have this section set. Otherwise, the address will just have the + /// offset member filled in, indicating that this represents a file address. //------------------------------------------------------------------ - virtual lldb_private::Address GetHeaderAddress() { + virtual lldb_private::Address GetBaseAddress() { return Address(m_memory_addr); } @@ -817,4 +809,16 @@ private: } // namespace lldb_private +namespace llvm { +template <> struct format_provider<lldb_private::ObjectFile::Type> { + static void format(const lldb_private::ObjectFile::Type &type, + raw_ostream &OS, StringRef Style); +}; + +template <> struct format_provider<lldb_private::ObjectFile::Strata> { + static void format(const lldb_private::ObjectFile::Strata &strata, + raw_ostream &OS, StringRef Style); +}; +} // namespace llvm + #endif // liblldb_ObjectFile_h_ diff --git a/include/lldb/Symbol/SymbolContext.h b/include/lldb/Symbol/SymbolContext.h index 0ec0006f193a..a7afffb705d2 100644 --- a/include/lldb/Symbol/SymbolContext.h +++ b/include/lldb/Symbol/SymbolContext.h @@ -10,14 +10,10 @@ #ifndef liblldb_SymbolContext_h_ #define liblldb_SymbolContext_h_ -// C Includes -// C++ Includes #include <memory> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/Address.h" #include "lldb/Core/Mangled.h" #include "lldb/Symbol/LineEntry.h" @@ -232,7 +228,7 @@ public: bool GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range, Status &error); - + //------------------------------------------------------------------ /// Find the best global data symbol visible from this context. /// @@ -469,10 +465,6 @@ public: bool AppendIfUnique(const SymbolContext &sc, bool merge_symbol_into_function); - bool MergeSymbolContextIntoFunctionContext(const SymbolContext &symbol_sc, - uint32_t start_idx = 0, - uint32_t stop_idx = UINT32_MAX); - uint32_t AppendIfUnique(const SymbolContextList &sc_list, bool merge_symbol_into_function); @@ -531,18 +523,6 @@ public: return m_symbol_contexts[idx]; } - //------------------------------------------------------------------ - /// Get accessor for the last symbol context in the list. - /// - /// @param[out] sc - /// A reference to the symbol context to fill in. - /// - /// @return - /// Returns \b true if \a sc was filled in, \b false if the - /// list is empty. - //------------------------------------------------------------------ - bool GetLastContext(SymbolContext &sc) const; - bool RemoveContextAtIndex(size_t idx); //------------------------------------------------------------------ diff --git a/include/lldb/Symbol/SymbolContextScope.h b/include/lldb/Symbol/SymbolContextScope.h index c2fbb5272fc0..85718b9bba4f 100644 --- a/include/lldb/Symbol/SymbolContextScope.h +++ b/include/lldb/Symbol/SymbolContextScope.h @@ -10,10 +10,6 @@ #ifndef liblldb_SymbolContextScope_h_ #define liblldb_SymbolContextScope_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Symbol/SymbolFile.h b/include/lldb/Symbol/SymbolFile.h index 7b77c60a3c3d..433c20da99e2 100644 --- a/include/lldb/Symbol/SymbolFile.h +++ b/include/lldb/Symbol/SymbolFile.h @@ -14,11 +14,20 @@ #include "lldb/Symbol/CompilerDecl.h" #include "lldb/Symbol/CompilerDeclContext.h" #include "lldb/Symbol/CompilerType.h" +#include "lldb/Symbol/Function.h" #include "lldb/Symbol/Type.h" #include "lldb/lldb-private.h" #include "llvm/ADT/DenseSet.h" +#include <mutex> + +#if defined(LLDB_CONFIGURATION_DEBUG) +#define ASSERT_MODULE_LOCK(expr) (expr->AssertModuleLock()) +#else +#define ASSERT_MODULE_LOCK(expr) ((void)0) +#endif + namespace lldb_private { class SymbolFile : public PluginInterface { @@ -93,6 +102,12 @@ public: virtual uint32_t CalculateAbilities() = 0; //------------------------------------------------------------------ + /// Symbols file subclasses should override this to return the Module that + /// owns the TypeSystem that this symbol file modifies type information in. + //------------------------------------------------------------------ + virtual std::recursive_mutex &GetModuleMutex() const; + + //------------------------------------------------------------------ /// Initialize the SymbolFile object. /// /// The SymbolFile object with the best set of abilities (detected @@ -110,24 +125,38 @@ public: virtual uint32_t GetNumCompileUnits() = 0; virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) = 0; - virtual lldb::LanguageType - ParseCompileUnitLanguage(const SymbolContext &sc) = 0; - virtual size_t ParseCompileUnitFunctions(const SymbolContext &sc) = 0; - virtual bool ParseCompileUnitLineTable(const SymbolContext &sc) = 0; - virtual bool ParseCompileUnitDebugMacros(const SymbolContext &sc) = 0; - virtual bool ParseCompileUnitSupportFiles(const SymbolContext &sc, - FileSpecList &support_files) = 0; - virtual bool - ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) { - return false; - } + virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) = 0; + virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0; + virtual bool ParseLineTable(CompileUnit &comp_unit) = 0; + virtual bool ParseDebugMacros(CompileUnit &comp_unit) = 0; + virtual bool ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) = 0; + virtual size_t ParseTypes(CompileUnit &comp_unit) = 0; + virtual bool ParseIsOptimized(CompileUnit &comp_unit) { return false; } + virtual bool ParseImportedModules(const SymbolContext &sc, std::vector<ConstString> &imported_modules) = 0; - virtual size_t ParseFunctionBlocks(const SymbolContext &sc) = 0; - virtual size_t ParseTypes(const SymbolContext &sc) = 0; + virtual size_t ParseBlocksRecursive(Function &func) = 0; virtual size_t ParseVariablesForContext(const SymbolContext &sc) = 0; virtual Type *ResolveTypeUID(lldb::user_id_t type_uid) = 0; + + + /// The characteristics of an array type. + struct ArrayInfo { + int64_t first_index; + llvm::SmallVector<uint64_t, 1> element_orders; + uint32_t byte_stride; + uint32_t bit_stride; + }; + /// If \c type_uid points to an array type, return its characteristics. + /// To support variable-length array types, this function takes an + /// optional \p ExtecutionContext. If \c exe_ctx is non-null, the + /// dynamic characteristics for that context are returned. + virtual llvm::Optional<ArrayInfo> + GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, + const lldb_private::ExecutionContext *exe_ctx) = 0; + virtual bool CompleteType(CompilerType &compiler_type) = 0; virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx) {} virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) { @@ -140,12 +169,14 @@ public: return CompilerDeclContext(); } virtual uint32_t ResolveSymbolContext(const Address &so_addr, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContext &sc) = 0; virtual uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); + + virtual void DumpClangAST(Stream &s) {} virtual uint32_t FindGlobalVariables(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, @@ -155,15 +186,15 @@ public: VariableList &variables); virtual uint32_t FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool include_inlines, - bool append, SymbolContextList &sc_list); + lldb::FunctionNameType name_type_mask, + bool include_inlines, bool append, + SymbolContextList &sc_list); virtual uint32_t FindFunctions(const RegularExpression ®ex, bool include_inlines, bool append, SymbolContextList &sc_list); virtual uint32_t - FindTypes(const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - uint32_t max_matches, + FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); virtual size_t FindTypes(const std::vector<CompilerContext> &context, @@ -177,7 +208,7 @@ public: // types) = 0; virtual TypeList *GetTypeList(); virtual size_t GetTypes(lldb_private::SymbolContextScope *sc_scope, - uint32_t type_mask, + lldb::TypeClass type_mask, lldb_private::TypeList &type_list) = 0; virtual void PreloadSymbols(); @@ -186,7 +217,7 @@ public: GetTypeSystemForLanguage(lldb::LanguageType language); virtual CompilerDeclContext - FindNamespace(const SymbolContext &sc, const ConstString &name, + FindNamespace(const ConstString &name, const CompilerDeclContext *parent_decl_ctx) { return CompilerDeclContext(); } @@ -194,6 +225,12 @@ public: ObjectFile *GetObjectFile() { return m_obj_file; } const ObjectFile *GetObjectFile() const { return m_obj_file; } + virtual std::vector<CallEdge> ParseCallEdgesInFunction(UserID func_id) { + return {}; + } + + virtual void AddSymbols(Symtab &symtab) {} + //------------------------------------------------------------------ /// Notify the SymbolFile that the file addresses in the Sections /// for this module have been changed. @@ -203,6 +240,8 @@ public: virtual void Dump(Stream &s) {} protected: + void AssertModuleLock(); + ObjectFile *m_obj_file; // The object file that symbols can be extracted from. uint32_t m_abilities; bool m_calculated_abilities; diff --git a/include/lldb/Symbol/SymbolVendor.h b/include/lldb/Symbol/SymbolVendor.h index 312b146f2970..d48f646d52cd 100644 --- a/include/lldb/Symbol/SymbolVendor.h +++ b/include/lldb/Symbol/SymbolVendor.h @@ -46,37 +46,37 @@ public: virtual void Dump(Stream *s); - virtual lldb::LanguageType ParseCompileUnitLanguage(const SymbolContext &sc); + virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit); - virtual size_t ParseCompileUnitFunctions(const SymbolContext &sc); + virtual size_t ParseFunctions(CompileUnit &comp_unit); - virtual bool ParseCompileUnitLineTable(const SymbolContext &sc); + virtual bool ParseLineTable(CompileUnit &comp_unit); - virtual bool ParseCompileUnitDebugMacros(const SymbolContext &sc); + virtual bool ParseDebugMacros(CompileUnit &comp_unit); - virtual bool ParseCompileUnitSupportFiles(const SymbolContext &sc, - FileSpecList &support_files); + virtual bool ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files); - virtual bool ParseCompileUnitIsOptimized(const SymbolContext &sc); + virtual bool ParseIsOptimized(CompileUnit &comp_unit); + + virtual size_t ParseTypes(CompileUnit &comp_unit); virtual bool ParseImportedModules(const SymbolContext &sc, std::vector<ConstString> &imported_modules); - virtual size_t ParseFunctionBlocks(const SymbolContext &sc); - - virtual size_t ParseTypes(const SymbolContext &sc); + virtual size_t ParseBlocksRecursive(Function &func); virtual size_t ParseVariablesForContext(const SymbolContext &sc); virtual Type *ResolveTypeUID(lldb::user_id_t type_uid); virtual uint32_t ResolveSymbolContext(const Address &so_addr, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContext &sc); virtual uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line, bool check_inlines, - uint32_t resolve_scope, + lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list); virtual size_t FindGlobalVariables(const ConstString &name, @@ -90,17 +90,17 @@ public: virtual size_t FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool include_inlines, - bool append, SymbolContextList &sc_list); + lldb::FunctionNameType name_type_mask, + bool include_inlines, bool append, + SymbolContextList &sc_list); virtual size_t FindFunctions(const RegularExpression ®ex, bool include_inlines, bool append, SymbolContextList &sc_list); virtual size_t - FindTypes(const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - size_t max_matches, + FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, size_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types); @@ -108,7 +108,7 @@ public: bool append, TypeMap &types); virtual CompilerDeclContext - FindNamespace(const SymbolContext &sc, const ConstString &name, + FindNamespace(const ConstString &name, const CompilerDeclContext *parent_decl_ctx); virtual size_t GetNumCompileUnits(); @@ -122,8 +122,8 @@ public: const TypeList &GetTypeList() const { return m_type_list; } - virtual size_t GetTypes(SymbolContextScope *sc_scope, uint32_t type_mask, - TypeList &type_list); + virtual size_t GetTypes(SymbolContextScope *sc_scope, + lldb::TypeClass type_mask, TypeList &type_list); SymbolFile *GetSymbolFile() { return m_sym_file_ap.get(); } @@ -164,6 +164,8 @@ protected: // file) std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses // can add more of these if needed. + Symtab *m_symtab; // Save a symtab once to not pass it through `AddSymbols` of + // the symbol file each time when it is needed private: //------------------------------------------------------------------ diff --git a/include/lldb/Symbol/Symtab.h b/include/lldb/Symbol/Symtab.h index 3d24862af365..286e4f48c2e8 100644 --- a/include/lldb/Symbol/Symtab.h +++ b/include/lldb/Symbol/Symtab.h @@ -168,12 +168,12 @@ private: Visibility symbol_visibility) const { switch (symbol_debug_type) { case eDebugNo: - if (m_symbols[idx].IsDebug() == true) + if (m_symbols[idx].IsDebug()) return false; break; case eDebugYes: - if (m_symbols[idx].IsDebug() == false) + if (!m_symbols[idx].IsDebug()) return false; break; @@ -197,6 +197,15 @@ private: void SymbolIndicesToSymbolContextList(std::vector<uint32_t> &symbol_indexes, SymbolContextList &sc_list); + void RegisterMangledNameEntry( + NameToIndexMap::Entry &entry, std::set<const char *> &class_contexts, + std::vector<std::pair<NameToIndexMap::Entry, const char *>> &backlog, + RichManglingContext &rmc); + + void RegisterBacklogEntry(const NameToIndexMap::Entry &entry, + const char *decl_context, + const std::set<const char *> &class_contexts); + DISALLOW_COPY_AND_ASSIGN(Symtab); }; diff --git a/include/lldb/Symbol/TypeSystem.h b/include/lldb/Symbol/TypeSystem.h index 94d1b9cdf3fd..6afbd188a234 100644 --- a/include/lldb/Symbol/TypeSystem.h +++ b/include/lldb/Symbol/TypeSystem.h @@ -10,18 +10,14 @@ #ifndef liblldb_TypeSystem_h_ #define liblldb_TypeSystem_h_ -// C Includes -// C++ Includes #include <functional> #include <map> #include <mutex> #include <string> -// Other libraries and framework includes #include "llvm/ADT/APSInt.h" #include "llvm/Support/Casting.h" -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Expression/Expression.h" #include "lldb/Symbol/CompilerDecl.h" @@ -72,8 +68,6 @@ public: enum LLVMCastKind { eKindClang, eKindSwift, - eKindGo, - eKindJava, eKindOCaml, kNumKinds }; @@ -286,7 +280,8 @@ public: virtual lldb::Format GetFormat(lldb::opaque_compiler_type_t type) = 0; virtual uint32_t GetNumChildren(lldb::opaque_compiler_type_t type, - bool omit_empty_base_classes) = 0; + bool omit_empty_base_classes, + const ExecutionContext *exe_ctx) = 0; virtual CompilerType GetBuiltinTypeByName(const ConstString &name); @@ -347,7 +342,7 @@ public: const char *name, bool omit_empty_base_classes, std::vector<uint32_t> &child_indexes) = 0; - virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type) = 0; + virtual size_t GetNumTemplateArguments(lldb::opaque_compiler_type_t type); virtual lldb::TemplateArgumentKind GetTemplateArgumentKind(lldb::opaque_compiler_type_t type, size_t idx); diff --git a/include/lldb/Symbol/UnwindPlan.h b/include/lldb/Symbol/UnwindPlan.h index a76ea23b46bc..7a5cf7f02a67 100644 --- a/include/lldb/Symbol/UnwindPlan.h +++ b/include/lldb/Symbol/UnwindPlan.h @@ -10,14 +10,10 @@ #ifndef liblldb_UnwindPlan_h #define liblldb_UnwindPlan_h -// C Includes -// C++ Includes #include <map> #include <memory> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/AddressRange.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Stream.h" @@ -28,14 +24,22 @@ namespace lldb_private { // The UnwindPlan object specifies how to unwind out of a function - where this // function saves the caller's register values before modifying them (for non- // volatile aka saved registers) and how to find this frame's Canonical Frame -// Address (CFA). +// Address (CFA) or Aligned Frame Address (AFA). +// CFA is a DWARF's Canonical Frame Address. // Most commonly, registers are saved on the stack, offset some bytes from the // Canonical Frame Address, or CFA, which is the starting address of this // function's stack frame (the CFA is same as the eh_frame's CFA, whatever that // may be on a given architecture). The CFA address for the stack frame does // not change during the lifetime of the function. +// AFA is an artificially introduced Aligned Frame Address. +// It is used only for stack frames with realignment (e.g. when some of the +// locals has an alignment requirement higher than the stack alignment right +// after the function call). It is used to access register values saved on the +// stack after the realignment (and so they are inaccessible through the CFA). +// AFA usually equals the stack pointer value right after the realignment. + // Internally, the UnwindPlan is structured as a vector of register locations // organized by code address in the function, showing which registers have been // saved at that point and where they are saved. It can be thought of as the @@ -61,6 +65,8 @@ public: same, // reg is unchanged atCFAPlusOffset, // reg = deref(CFA + offset) isCFAPlusOffset, // reg = CFA + offset + atAFAPlusOffset, // reg = deref(AFA + offset) + isAFAPlusOffset, // reg = AFA + offset inOtherRegister, // reg = other reg atDWARFExpression, // reg = deref(eval(dwarf_expr)) isDWARFExpression // reg = eval(dwarf_expr) @@ -90,6 +96,10 @@ public: bool IsAtCFAPlusOffset() const { return m_type == atCFAPlusOffset; } + bool IsAFAPlusOffset() const { return m_type == isAFAPlusOffset; } + + bool IsAtAFAPlusOffset() const { return m_type == atAFAPlusOffset; } + bool IsInOtherRegister() const { return m_type == inOtherRegister; } bool IsAtDWARFExpression() const { return m_type == atDWARFExpression; } @@ -106,6 +116,16 @@ public: m_location.offset = offset; } + void SetAtAFAPlusOffset(int32_t offset) { + m_type = atAFAPlusOffset; + m_location.offset = offset; + } + + void SetIsAFAPlusOffset(int32_t offset) { + m_type = isAFAPlusOffset; + m_location.offset = offset; + } + void SetInRegister(uint32_t reg_num) { m_type = inOtherRegister; m_location.reg_num = reg_num; @@ -120,9 +140,16 @@ public: RestoreType GetLocationType() const { return m_type; } int32_t GetOffset() const { - if (m_type == atCFAPlusOffset || m_type == isCFAPlusOffset) + switch(m_type) + { + case atCFAPlusOffset: + case isCFAPlusOffset: + case atAFAPlusOffset: + case isAFAPlusOffset: return m_location.offset; - return 0; + default: + return 0; + } } void GetDWARFExpr(const uint8_t **opcodes, uint16_t &len) const { @@ -169,20 +196,20 @@ public: } m_location; }; - class CFAValue { + class FAValue { public: enum ValueType { unspecified, // not specified - isRegisterPlusOffset, // CFA = register + offset - isRegisterDereferenced, // CFA = [reg] - isDWARFExpression // CFA = eval(dwarf_expr) + isRegisterPlusOffset, // FA = register + offset + isRegisterDereferenced, // FA = [reg] + isDWARFExpression // FA = eval(dwarf_expr) }; - CFAValue() : m_type(unspecified), m_value() {} + FAValue() : m_type(unspecified), m_value() {} - bool operator==(const CFAValue &rhs) const; + bool operator==(const FAValue &rhs) const; - bool operator!=(const CFAValue &rhs) const { return !(*this == rhs); } + bool operator!=(const FAValue &rhs) const { return !(*this == rhs); } void SetUnspecified() { m_type = unspecified; } @@ -279,7 +306,7 @@ public: uint16_t length; } expr; } m_value; - }; // class CFAValue + }; // class FAValue public: Row(); @@ -302,7 +329,9 @@ public: void SlideOffset(lldb::addr_t offset) { m_offset += offset; } - CFAValue &GetCFAValue() { return m_cfa_value; } + FAValue &GetCFAValue() { return m_cfa_value; } + + FAValue &GetAFAValue() { return m_afa_value; } bool SetRegisterLocationToAtCFAPlusOffset(uint32_t reg_num, int32_t offset, bool can_replace); @@ -329,7 +358,8 @@ public: typedef std::map<uint32_t, RegisterLocation> collection; lldb::addr_t m_offset; // Offset into the function for this row - CFAValue m_cfa_value; + FAValue m_cfa_value; + FAValue m_afa_value; collection m_register_locations; }; // class Row diff --git a/include/lldb/Symbol/UnwindTable.h b/include/lldb/Symbol/UnwindTable.h index 5c83e3003192..061e7ddc0f99 100644 --- a/include/lldb/Symbol/UnwindTable.h +++ b/include/lldb/Symbol/UnwindTable.h @@ -50,7 +50,7 @@ public: GetUncachedFuncUnwindersContainingAddress(const Address &addr, SymbolContext &sc); - bool GetArchitecture(lldb_private::ArchSpec &arch); + ArchSpec GetArchitecture(); private: void Dump(Stream &s); diff --git a/include/lldb/Target/ABI.h b/include/lldb/Target/ABI.h index 343b3a749597..24fff1caf6c4 100644 --- a/include/lldb/Target/ABI.h +++ b/include/lldb/Target/ABI.h @@ -10,10 +10,6 @@ #ifndef liblldb_ABI_h_ #define liblldb_ABI_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Symbol/UnwindPlan.h" #include "lldb/Utility/Status.h" diff --git a/include/lldb/Target/CPPLanguageRuntime.h b/include/lldb/Target/CPPLanguageRuntime.h index aae85f420ef7..e96ee168389b 100644 --- a/include/lldb/Target/CPPLanguageRuntime.h +++ b/include/lldb/Target/CPPLanguageRuntime.h @@ -11,11 +11,7 @@ #ifndef liblldb_CPPLanguageRuntime_h_ #define liblldb_CPPLanguageRuntime_h_ -// C Includes -// C++ Includes #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/lldb-private.h" @@ -24,6 +20,25 @@ namespace lldb_private { class CPPLanguageRuntime : public LanguageRuntime { public: + enum class LibCppStdFunctionCallableCase { + Lambda = 0, + CallableObject, + FreeOrMemberFunction, + Invalid + }; + + struct LibCppStdFunctionCallableInfo { + Symbol callable_symbol; + Address callable_address; + LineEntry callable_line_entry; + lldb::addr_t member__f_pointer_value = 0u; + LibCppStdFunctionCallableCase callable_case = + LibCppStdFunctionCallableCase::Invalid; + }; + + LibCppStdFunctionCallableInfo + FindLibCppStdFunctionCallableInfo(lldb::ValueObjectSP &valobj_sp); + ~CPPLanguageRuntime() override; lldb::LanguageType GetLanguageType() const override { @@ -37,6 +52,19 @@ public: bool GetObjectDescription(Stream &str, Value &value, ExecutionContextScope *exe_scope) override; + /// Obtain a ThreadPlan to get us into C++ constructs such as std::function. + /// + /// @param[in] thread + /// Curent thrad of execution. + /// + /// @param[in] stop_others + /// True if other threads should pause during execution. + /// + /// @return + /// A ThreadPlan Shared pointer + lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread, + bool stop_others); + protected: //------------------------------------------------------------------ // Classes that inherit from CPPLanguageRuntime can see and modify these diff --git a/include/lldb/Target/DynamicLoader.h b/include/lldb/Target/DynamicLoader.h index de9c4e233b0c..fe04f94aa31b 100644 --- a/include/lldb/Target/DynamicLoader.h +++ b/include/lldb/Target/DynamicLoader.h @@ -10,18 +10,17 @@ #ifndef liblldb_DynamicLoader_h_ #define liblldb_DynamicLoader_h_ -// Project includes #include "lldb/Core/PluginInterface.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/UUID.h" -#include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-forward.h" // for ModuleSP, ThreadPlanSP -#include "lldb/lldb-private-enumerations.h" // for LazyBool, LazyBool::eLaz... -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private-enumerations.h" +#include "lldb/lldb-types.h" -#include <stddef.h> // for size_t -#include <stdint.h> // for int64_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class ModuleList; } diff --git a/include/lldb/Target/ExecutionContext.h b/include/lldb/Target/ExecutionContext.h index 70eba3654dec..167189c3a837 100644 --- a/include/lldb/Target/ExecutionContext.h +++ b/include/lldb/Target/ExecutionContext.h @@ -10,12 +10,8 @@ #ifndef liblldb_ExecutionContext_h_ #define liblldb_ExecutionContext_h_ -// C Includes -// C++ Includes #include <mutex> -// Other libraries and framework includes -// Project includes #include "lldb/Target/StackID.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/ExecutionContextScope.h b/include/lldb/Target/ExecutionContextScope.h index b73ca576bd8a..3e787584be0b 100644 --- a/include/lldb/Target/ExecutionContextScope.h +++ b/include/lldb/Target/ExecutionContextScope.h @@ -10,10 +10,6 @@ #ifndef liblldb_ExecutionContextScope_h_ #define liblldb_ExecutionContextScope_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Target/InstrumentationRuntime.h b/include/lldb/Target/InstrumentationRuntime.h index 21d66d5766a9..ba905cb8535d 100644 --- a/include/lldb/Target/InstrumentationRuntime.h +++ b/include/lldb/Target/InstrumentationRuntime.h @@ -10,13 +10,9 @@ #ifndef liblldb_InstrumentationRuntime_h_ #define liblldb_InstrumentationRuntime_h_ -// C Includes -// C++ Includes #include <map> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-forward.h" diff --git a/include/lldb/Target/InstrumentationRuntimeStopInfo.h b/include/lldb/Target/InstrumentationRuntimeStopInfo.h index b11231960ac1..7c72c9524eca 100644 --- a/include/lldb/Target/InstrumentationRuntimeStopInfo.h +++ b/include/lldb/Target/InstrumentationRuntimeStopInfo.h @@ -10,12 +10,8 @@ #ifndef liblldb_InstrumentationRuntimeStopInfo_h_ #define liblldb_InstrumentationRuntimeStopInfo_h_ -// C Includes -// C++ Includes #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/Target/StopInfo.h" #include "lldb/Utility/StructuredData.h" diff --git a/include/lldb/Target/Language.h b/include/lldb/Target/Language.h index dd7db26f3ba6..27f40fd1ba83 100644 --- a/include/lldb/Target/Language.h +++ b/include/lldb/Target/Language.h @@ -11,15 +11,12 @@ #ifndef liblldb_Language_h_ #define liblldb_Language_h_ -// C Includes -// C++ Includes #include <functional> #include <memory> #include <set> #include <vector> -// Other libraries and framework includes -// Project includes +#include "lldb/Core/Highlighter.h" #include "lldb/Core/PluginInterface.h" #include "lldb/DataFormatters/DumpValueObjectOptions.h" #include "lldb/DataFormatters/FormatClasses.h" @@ -152,6 +149,13 @@ public: static Language *FindPlugin(lldb::LanguageType language); + /// Returns the Language associated with the given file path or a nullptr + /// if there is no known language. + static Language *FindPlugin(llvm::StringRef file_path); + + static Language *FindPlugin(lldb::LanguageType language, + llvm::StringRef file_path); + // return false from callback to stop iterating static void ForEach(std::function<bool(Language *)> callback); @@ -159,6 +163,10 @@ public: virtual bool IsTopLevelFunction(Function &function); + virtual bool IsSourceFile(llvm::StringRef file_path) const = 0; + + virtual const Highlighter *GetHighlighter() const { return nullptr; } + virtual lldb::TypeCategoryImplSP GetFormatters(); virtual HardcodedFormatters::HardcodedFormatFinder GetHardcodedFormats(); diff --git a/include/lldb/Target/LanguageRuntime.h b/include/lldb/Target/LanguageRuntime.h index 6537a8f6dd55..2a2f47b85359 100644 --- a/include/lldb/Target/LanguageRuntime.h +++ b/include/lldb/Target/LanguageRuntime.h @@ -11,10 +11,6 @@ #ifndef liblldb_LanguageRuntime_h_ #define liblldb_LanguageRuntime_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointResolver.h" #include "lldb/Breakpoint/BreakpointResolverName.h" #include "lldb/Core/PluginInterface.h" @@ -123,6 +119,17 @@ public: static Breakpoint::BreakpointPreconditionSP CreateExceptionPrecondition(lldb::LanguageType language, bool catch_bp, bool throw_bp); + + virtual lldb::ValueObjectSP GetExceptionObjectForThread( + lldb::ThreadSP thread_sp) { + return lldb::ValueObjectSP(); + } + + virtual lldb::ThreadSP GetBacktraceThreadFromException( + lldb::ValueObjectSP thread_sp) { + return lldb::ThreadSP(); + } + Process *GetProcess() { return m_process; } Target &GetTargetRef() { return m_process->GetTarget(); } diff --git a/include/lldb/Target/Memory.h b/include/lldb/Target/Memory.h index 16d7b256a78e..d5e6c105f76d 100644 --- a/include/lldb/Target/Memory.h +++ b/include/lldb/Target/Memory.h @@ -10,15 +10,11 @@ #ifndef liblldb_Memory_h_ #define liblldb_Memory_h_ -// C Includes -// C++ Includes #include <map> #include <mutex> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/RangeMap.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/MemoryHistory.h b/include/lldb/Target/MemoryHistory.h index acc36ffe2eb4..cb3e90053357 100644 --- a/include/lldb/Target/MemoryHistory.h +++ b/include/lldb/Target/MemoryHistory.h @@ -11,12 +11,8 @@ #ifndef liblldb_MemoryHistory_h_ #define liblldb_MemoryHistory_h_ -// C Includes -// C++ Includes #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/lldb-private.h" #include "lldb/lldb-types.h" diff --git a/include/lldb/Target/MemoryRegionInfo.h b/include/lldb/Target/MemoryRegionInfo.h index 505ecfcfc5ae..a57c4678bb37 100644 --- a/include/lldb/Target/MemoryRegionInfo.h +++ b/include/lldb/Target/MemoryRegionInfo.h @@ -14,7 +14,6 @@ #include "lldb/Core/RangeMap.h" #include "llvm/Support/FormatProviders.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/Range.h" namespace lldb_private { class MemoryRegionInfo { @@ -109,6 +108,26 @@ protected: OptionalBool m_flash; lldb::offset_t m_blocksize; }; + +inline bool operator<(const MemoryRegionInfo &lhs, + const MemoryRegionInfo &rhs) { + return lhs.GetRange() < rhs.GetRange(); +} + +inline bool operator<(const MemoryRegionInfo &lhs, lldb::addr_t rhs) { + return lhs.GetRange().GetRangeBase() < rhs; +} + +inline bool operator<(lldb::addr_t lhs, const MemoryRegionInfo &rhs) { + return lhs < rhs.GetRange().GetRangeBase(); +} + +// Forward-declarable wrapper. +class MemoryRegionInfos : public std::vector<lldb_private::MemoryRegionInfo> { +public: + using std::vector<lldb_private::MemoryRegionInfo>::vector; +}; + } namespace llvm { diff --git a/include/lldb/Target/ObjCLanguageRuntime.h b/include/lldb/Target/ObjCLanguageRuntime.h index 6f8354ea3a27..9eebf9463043 100644 --- a/include/lldb/Target/ObjCLanguageRuntime.h +++ b/include/lldb/Target/ObjCLanguageRuntime.h @@ -10,17 +10,13 @@ #ifndef liblldb_ObjCLanguageRuntime_h_ #define liblldb_ObjCLanguageRuntime_h_ -// C Includes -// C++ Includes #include <functional> #include <map> #include <memory> #include <unordered_set> -// Other libraries and framework includes #include "llvm/Support/Casting.h" -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Core/ThreadSafeDenseMap.h" #include "lldb/Symbol/CompilerType.h" diff --git a/include/lldb/Target/OperatingSystem.h b/include/lldb/Target/OperatingSystem.h index fe4fdee182f4..4d73bb3906ee 100644 --- a/include/lldb/Target/OperatingSystem.h +++ b/include/lldb/Target/OperatingSystem.h @@ -11,9 +11,6 @@ #ifndef liblldb_OperatingSystem_h_ #define liblldb_OperatingSystem_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes #include "lldb/Core/PluginInterface.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/PathMappingList.h b/include/lldb/Target/PathMappingList.h index a5ee3265a223..29e6ef191e27 100644 --- a/include/lldb/Target/PathMappingList.h +++ b/include/lldb/Target/PathMappingList.h @@ -10,14 +10,10 @@ #ifndef liblldb_PathMappingList_h_ #define liblldb_PathMappingList_h_ -// C Includes -// C++ Includes #include <map> #include <vector> -// Other libraries and framework includes #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Status.h" -// Project includes namespace lldb_private { diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h index 217b945d29cd..3dbeef73f0ab 100644 --- a/include/lldb/Target/Platform.h +++ b/include/lldb/Target/Platform.h @@ -10,8 +10,6 @@ #ifndef liblldb_Platform_h_ #define liblldb_Platform_h_ -// C Includes -// C++ Includes #include <functional> #include <map> #include <memory> @@ -19,8 +17,6 @@ #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Interpreter/Options.h" @@ -1131,10 +1127,6 @@ public: llvm::ArrayRef<OptionDefinition> GetDefinitions() override; - // 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; @@ -1160,10 +1152,6 @@ public: llvm::ArrayRef<OptionDefinition> GetDefinitions() override; - // 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; @@ -1187,10 +1175,6 @@ public: llvm::ArrayRef<OptionDefinition> GetDefinitions() override; - // 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; diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h index 66ac5a692522..be72b9a9c747 100644 --- a/include/lldb/Target/Process.h +++ b/include/lldb/Target/Process.h @@ -12,10 +12,8 @@ #include "lldb/Host/Config.h" -// C Includes #include <limits.h> -// C++ Includes #include <chrono> #include <list> #include <memory> @@ -24,13 +22,8 @@ #include <unordered_set> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointSiteList.h" -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Communication.h" -#include "lldb/Core/Event.h" -#include "lldb/Core/Listener.h" #include "lldb/Core/LoadedModuleInfoList.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Core/ThreadSafeValue.h" @@ -47,6 +40,9 @@ #include "lldb/Target/QueueList.h" #include "lldb/Target/ThreadList.h" #include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/Event.h" +#include "lldb/Utility/Listener.h" #include "lldb/Utility/NameMatches.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StructuredData.h" @@ -319,7 +315,7 @@ public: NameMatch process_name_match_type) : m_match_info(), m_name_match_type(process_name_match_type), m_match_all_users(false) { - m_match_info.GetExecutableFile().SetFile(process_name, false, + m_match_info.GetExecutableFile().SetFile(process_name, FileSpec::Style::native); } @@ -402,7 +398,8 @@ class ProcessModID { public: ProcessModID() : m_stop_id(0), m_last_natural_stop_id(0), m_resume_id(0), m_memory_id(0), - m_last_user_expression_resume(0), m_running_user_expression(false) {} + m_last_user_expression_resume(0), m_running_user_expression(false), + m_running_utility_function(0) {} ProcessModID(const ProcessModID &rhs) : m_stop_id(rhs.m_stop_id), m_memory_id(rhs.m_memory_id) {} @@ -431,6 +428,10 @@ public: m_last_user_expression_resume = m_resume_id; } + bool IsRunningUtilityFunction() const { + return m_running_utility_function > 0; + } + uint32_t GetStopID() const { return m_stop_id; } uint32_t GetLastNaturalStopID() const { return m_last_natural_stop_id; } uint32_t GetMemoryID() const { return m_memory_id; } @@ -467,6 +468,17 @@ public: m_running_user_expression--; } + void SetRunningUtilityFunction(bool on) { + if (on) + m_running_utility_function++; + else { + assert(m_running_utility_function > 0 && + "Called SetRunningUtilityFunction(false) without calling " + "SetRunningUtilityFunction(true) before?"); + m_running_utility_function--; + } + } + void SetStopEventForLastNaturalStopID(lldb::EventSP event_sp) { m_last_natural_stop_event = event_sp; } @@ -484,6 +496,7 @@ private: uint32_t m_memory_id; uint32_t m_last_user_expression_resume; uint32_t m_running_user_expression; + uint32_t m_running_utility_function; lldb::EventSP m_last_natural_stop_event; }; @@ -2068,7 +2081,7 @@ public: /// An error value. //------------------------------------------------------------------ virtual Status - GetMemoryRegions(std::vector<lldb::MemoryRegionInfoSP> ®ion_list); + GetMemoryRegions(lldb_private::MemoryRegionInfos ®ion_list); virtual Status GetWatchpointSupportInfo(uint32_t &num) { Status error; @@ -2554,6 +2567,7 @@ public: virtual bool StopNoticingNewThreads() { return true; } void SetRunningUserExpression(bool on); + void SetRunningUtilityFunction(bool on); //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions @@ -3225,6 +3239,24 @@ private: DISALLOW_COPY_AND_ASSIGN(Process); }; +//------------------------------------------------------------------ +/// RAII guard that should be aquired when an utility function is called within +/// a given process. +//------------------------------------------------------------------ +class UtilityFunctionScope { + Process *m_process; + +public: + UtilityFunctionScope(Process *p) : m_process(p) { + if (m_process) + m_process->SetRunningUtilityFunction(true); + } + ~UtilityFunctionScope() { + if (m_process) + m_process->SetRunningUtilityFunction(false); + } +}; + } // namespace lldb_private #endif // liblldb_Process_h_ diff --git a/include/lldb/Target/ProcessLaunchInfo.h b/include/lldb/Target/ProcessLaunchInfo.h index 92c517a3e460..ef1d63035b18 100644 --- a/include/lldb/Target/ProcessLaunchInfo.h +++ b/include/lldb/Target/ProcessLaunchInfo.h @@ -52,7 +52,10 @@ public: bool AppendSuppressFileAction(int fd, bool read, bool write); - void FinalizeFileActions(Target *target, bool default_to_use_pty); + // Redirect stdin/stdout/stderr to a pty, if no action for the respective file + // descriptor is specified. (So if stdin and stdout already have file actions, + // but stderr doesn't, then only stderr will be redirected to a pty.) + llvm::Error SetUpPtyRedirection(); size_t GetNumFileActions() const { return m_file_actions.size(); } @@ -131,8 +134,6 @@ public: m_listener_sp = listener_sp; } - lldb::ListenerSP GetListenerForProcess(Debugger &debugger); - lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; } void SetHijackListener(const lldb::ListenerSP &listener_sp) { diff --git a/include/lldb/Target/ProcessStructReader.h b/include/lldb/Target/ProcessStructReader.h index 8f1445ae8c1b..79f0b4cccd45 100644 --- a/include/lldb/Target/ProcessStructReader.h +++ b/include/lldb/Target/ProcessStructReader.h @@ -60,18 +60,20 @@ public: return; auto size = field_type.GetByteSize(nullptr); // no support for things larger than a uint64_t (yet) - if (size > 8) + if (!size || *size > 8) return; ConstString const_name = ConstString(name.c_str()); size_t byte_index = static_cast<size_t>(bit_offset / 8); m_fields[const_name] = - FieldImpl{field_type, byte_index, static_cast<size_t>(size)}; + FieldImpl{field_type, byte_index, static_cast<size_t>(*size)}; } - size_t total_size = struct_type.GetByteSize(nullptr); - lldb::DataBufferSP buffer_sp(new DataBufferHeap(total_size, 0)); + auto total_size = struct_type.GetByteSize(nullptr); + if (!total_size) + return; + lldb::DataBufferSP buffer_sp(new DataBufferHeap(*total_size, 0)); Status error; process->ReadMemoryFromInferior(base_addr, buffer_sp->GetBytes(), - total_size, error); + *total_size, error); if (error.Fail()) return; m_data = DataExtractor(buffer_sp, m_byte_order, m_addr_byte_size); diff --git a/include/lldb/Target/QueueItem.h b/include/lldb/Target/QueueItem.h index 76bcea36a2fa..3fd331ca525a 100644 --- a/include/lldb/Target/QueueItem.h +++ b/include/lldb/Target/QueueItem.h @@ -10,14 +10,10 @@ #ifndef liblldb_QueueItem_h_ #define liblldb_QueueItem_h_ -// C Includes -// C++ Includes #include <memory> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/RegisterContext.h b/include/lldb/Target/RegisterContext.h index 73a2930fd2b5..a24c270a1e5e 100644 --- a/include/lldb/Target/RegisterContext.h +++ b/include/lldb/Target/RegisterContext.h @@ -10,10 +10,6 @@ #ifndef liblldb_RegisterContext_h_ #define liblldb_RegisterContext_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ExecutionContextScope.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/SectionLoadHistory.h b/include/lldb/Target/SectionLoadHistory.h index 0ed335a9d040..0a14fc05c458 100644 --- a/include/lldb/Target/SectionLoadHistory.h +++ b/include/lldb/Target/SectionLoadHistory.h @@ -10,12 +10,9 @@ #ifndef liblldb_SectionLoadHistory_h_ #define liblldb_SectionLoadHistory_h_ -// C Includes -// C++ Includes #include <map> #include <mutex> -// Project includes #include "lldb/lldb-public.h" namespace lldb_private { diff --git a/include/lldb/Target/SectionLoadList.h b/include/lldb/Target/SectionLoadList.h index 1156c686df17..2a321e7a2545 100644 --- a/include/lldb/Target/SectionLoadList.h +++ b/include/lldb/Target/SectionLoadList.h @@ -11,14 +11,10 @@ #ifndef liblldb_SectionLoadList_h_ #define liblldb_SectionLoadList_h_ -// C Includes -// C++ Includes #include <map> #include <mutex> -// Other libraries and framework includes #include "llvm/ADT/DenseMap.h" -// Project includes #include "lldb/Core/Section.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/Target/StackFrame.h b/include/lldb/Target/StackFrame.h index ce9b16227672..a4e31a567440 100644 --- a/include/lldb/Target/StackFrame.h +++ b/include/lldb/Target/StackFrame.h @@ -10,20 +10,16 @@ #ifndef liblldb_StackFrame_h_ #define liblldb_StackFrame_h_ -// C Includes -// C++ Includes #include <memory> #include <mutex> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Flags.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/StackID.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/UserID.h" @@ -35,9 +31,9 @@ namespace lldb_private { /// 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. +/// A frame may have a plain pc value or it may 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. @@ -54,14 +50,27 @@ public: eExpressionPathOptionsInspectAnonymousUnions = (1u << 5) }; + enum class Kind { + /// A regular stack frame with access to registers and local variables. + Regular, + + /// A historical stack frame -- possibly without CFA or registers or + /// local variables. + History, + + /// An artificial stack frame (e.g. a synthesized result of inferring + /// missing tail call frames from a backtrace) with limited support for + /// local variables. + Artificial + }; + //------------------------------------------------------------------ /// 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, + /// point in the past. We may only have pc values. We may have a CFA, /// or more likely, we won't. /// /// @param [in] thread_sp @@ -92,23 +101,7 @@ public: /// @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] frame_kind /// /// @param [in] sc_ptr /// Optionally seed the StackFrame with the SymbolContext information that @@ -117,8 +110,7 @@ public: //------------------------------------------------------------------ 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, + bool cfa_is_valid, lldb::addr_t pc, Kind frame_kind, const SymbolContext *sc_ptr); StackFrame(const lldb::ThreadSP &thread_sp, lldb::user_id_t frame_idx, @@ -177,7 +169,7 @@ public: /// A SymbolContext reference which includes the types of information /// requested by resolve_scope, if they are available. //------------------------------------------------------------------ - const SymbolContext &GetSymbolContext(uint32_t resolve_scope); + const SymbolContext &GetSymbolContext(lldb::SymbolContextItem resolve_scope); //------------------------------------------------------------------ /// Return the Canonical Frame Address (DWARF term) for this frame. @@ -403,6 +395,18 @@ public: bool IsInlined(); //------------------------------------------------------------------ + /// Query whether this frame is part of a historical backtrace. + //------------------------------------------------------------------ + bool IsHistorical() const; + + //------------------------------------------------------------------ + /// Query whether this frame is artificial (e.g a synthesized result of + /// inferring missing tail call frames from a backtrace). Artificial frames + /// may have limited support for inspecting variables. + //------------------------------------------------------------------ + bool IsArtificial() const; + + //------------------------------------------------------------------ /// Query this frame to find what frame it is in this Thread's /// StackFrameList. /// @@ -413,6 +417,11 @@ public: uint32_t GetFrameIndex() const; //------------------------------------------------------------------ + /// Set this frame's synthetic frame index. + //------------------------------------------------------------------ + void SetFrameIndex(uint32_t index) { m_frame_index = index; } + + //------------------------------------------------------------------ /// Query this frame to find what frame it is in this Thread's /// StackFrameList, not counting inlined frames. /// @@ -504,6 +513,21 @@ public: int64_t offset); //------------------------------------------------------------------ + /// Attempt to reconstruct the ValueObject for a variable with a given \a name + /// from within the current StackFrame, within the current block. The search + /// for the variable starts in the deepest block corresponding to the current + /// PC in the stack frame and traverse through all parent blocks stopping at + /// inlined function boundaries. + /// + /// @params [in] name + /// The name of the variable. + /// + /// @return + /// The ValueObject if found. + //------------------------------------------------------------------ + lldb::ValueObjectSP FindVariable(ConstString name); + + //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions //------------------------------------------------------------------ lldb::TargetSP CalculateTarget() override; @@ -516,6 +540,8 @@ public: void CalculateExecutionContext(ExecutionContext &exe_ctx) override; + lldb::RecognizedStackFrameSP GetRecognizedFrame(); + protected: friend class StackFrameList; @@ -545,14 +571,12 @@ private: Status 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; + Kind m_stack_frame_kind; lldb::VariableListSP m_variable_list_sp; ValueObjectList m_variable_list_value_objects; // Value objects for each // variable in // m_variable_list_sp + lldb::RecognizedStackFrameSP m_recognized_frame_sp; StreamString m_disassembly; std::recursive_mutex m_mutex; diff --git a/include/lldb/Target/StackFrameList.h b/include/lldb/Target/StackFrameList.h index cb9fb136fb4e..0de90b3ba4ac 100644 --- a/include/lldb/Target/StackFrameList.h +++ b/include/lldb/Target/StackFrameList.h @@ -10,14 +10,10 @@ #ifndef liblldb_StackFrameList_h_ #define liblldb_StackFrameList_h_ -// C Includes -// C++ Includes #include <memory> #include <mutex> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Target/StackFrame.h" namespace lldb_private { @@ -32,22 +28,33 @@ public: ~StackFrameList(); + /// Get the number of visible frames. Frames may be created if \p can_create + /// is true. Synthetic (inline) frames expanded from the concrete frame #0 + /// (aka invisible frames) are not included in this count. uint32_t GetNumFrames(bool can_create = true); + /// Get the frame at index \p idx. Invisible frames cannot be indexed. lldb::StackFrameSP GetFrameAtIndex(uint32_t idx); + /// Get the first concrete frame with index greater than or equal to \p idx. + /// Unlike \ref GetFrameAtIndex, this cannot return a synthetic frame. lldb::StackFrameSP GetFrameWithConcreteFrameIndex(uint32_t unwind_idx); + /// Retrieve the stack frame with the given ID \p stack_id. lldb::StackFrameSP GetFrameWithStackID(const StackID &stack_id); - // Mark a stack frame as the current frame + /// Mark a stack frame as the currently selected frame and return its index. uint32_t SetSelectedFrame(lldb_private::StackFrame *frame); + /// Get the currently selected frame index. uint32_t GetSelectedFrameIndex() const; - // Mark a stack frame as the current frame using the frame index + /// Mark a stack frame as the currently selected frame using the frame index + /// \p idx. Like \ref GetFrameAtIndex, invisible frames cannot be selected. bool SetSelectedFrameByIndex(uint32_t idx); + /// If the current inline depth (i.e the number of invisible frames) is valid, + /// subtract it from \p idx. Otherwise simply return \p idx. uint32_t GetVisibleStackFrameIndex(uint32_t idx) { if (m_current_inlined_depth < UINT32_MAX) return idx - m_current_inlined_depth; @@ -55,16 +62,23 @@ public: return idx; } + /// Calculate and set the current inline depth. This may be used to update + /// the StackFrameList's set of inline frames when execution stops, e.g when + /// a breakpoint is hit. void CalculateCurrentInlinedDepth(); + /// If the currently selected frame comes from the currently selected thread, + /// point the default file and line of the thread's target to the location + /// specified by the frame. void SetDefaultFileAndLineToSelectedFrame(); + /// Clear the cache of frames. void Clear(); - void InvalidateFrames(uint32_t start_idx); - void Dump(Stream *s); + /// If \p stack_frame_ptr is contained in this StackFrameList, return its + /// wrapping shared pointer. lldb::StackFrameSP GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr); @@ -83,6 +97,10 @@ protected: void GetFramesUpTo(uint32_t end_idx); + void GetOnlyConcreteFramesUpTo(uint32_t end_idx, Unwind *unwinder); + + void SynthesizeTailCallFrames(StackFrame &next_frame); + bool GetAllFramesFetched() { return m_concrete_frames_fetched == UINT32_MAX; } void SetAllFramesFetched() { m_concrete_frames_fetched = UINT32_MAX; } @@ -99,15 +117,45 @@ protected: typedef collection::iterator iterator; typedef collection::const_iterator const_iterator; + /// The thread this frame list describes. Thread &m_thread; + + /// The old stack frame list. + // TODO: The old stack frame list is used to fill in missing frame info + // heuristically when it's otherwise unavailable (say, because the unwinder + // fails). We should have stronger checks to make sure that this is a valid + // source of information. lldb::StackFrameListSP m_prev_frames_sp; + + /// A mutex for this frame list. + // TODO: This mutex may not always be held when required. In particular, uses + // of the StackFrameList APIs in lldb_private::Thread look suspect. Consider + // passing around a lock_guard reference to enforce proper locking. mutable std::recursive_mutex m_mutex; + + /// A cache of frames. This may need to be updated when the program counter + /// changes. collection m_frames; + + /// The currently selected frame. uint32_t m_selected_frame_idx; + + /// The number of concrete frames fetched while filling the frame list. This + /// is only used when synthetic frames are enabled. uint32_t m_concrete_frames_fetched; + + /// The number of synthetic function activations (invisible frames) expanded + /// from the concrete frame #0 activation. + // TODO: Use an optional instead of UINT32_MAX to denote invalid values. uint32_t m_current_inlined_depth; + + /// The program counter value at the currently selected synthetic activation. + /// This is only valid if m_current_inlined_depth is valid. + // TODO: Use an optional instead of UINT32_MAX to denote invalid values. lldb::addr_t m_current_inlined_pc; - bool m_show_inlined_frames; + + /// Whether or not to show synthetic (inline) frames. Immutable. + const bool m_show_inlined_frames; private: DISALLOW_COPY_AND_ASSIGN(StackFrameList); diff --git a/include/lldb/Target/StackFrameRecognizer.h b/include/lldb/Target/StackFrameRecognizer.h new file mode 100644 index 000000000000..35ec23b754f3 --- /dev/null +++ b/include/lldb/Target/StackFrameRecognizer.h @@ -0,0 +1,129 @@ +//===-- StackFrameRecognizer.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_StackFrameRecognizer_h_ +#define liblldb_StackFrameRecognizer_h_ + +#include "lldb/Core/ValueObjectList.h" +#include "lldb/Symbol/VariableList.h" +#include "lldb/Utility/StructuredData.h" +#include "lldb/lldb-private-forward.h" +#include "lldb/lldb-public.h" + +namespace lldb_private { + +/// @class RecognizedStackFrame +/// +/// This class provides extra information about a stack frame that was +/// provided by a specific stack frame recognizer. Right now, this class only +/// holds recognized arguments (via GetRecognizedArguments). + +class RecognizedStackFrame + : public std::enable_shared_from_this<RecognizedStackFrame> { +public: + virtual lldb::ValueObjectListSP GetRecognizedArguments() { + return m_arguments; + } + virtual lldb::ValueObjectSP GetExceptionObject() { + return lldb::ValueObjectSP(); + } + virtual ~RecognizedStackFrame(){}; + +protected: + lldb::ValueObjectListSP m_arguments; +}; + +/// @class StackFrameRecognizer +/// +/// A base class for frame recognizers. Subclasses (actual frame recognizers) +/// should implement RecognizeFrame to provide a RecognizedStackFrame for a +/// given stack frame. + +class StackFrameRecognizer + : public std::enable_shared_from_this<StackFrameRecognizer> { +public: + virtual lldb::RecognizedStackFrameSP RecognizeFrame( + lldb::StackFrameSP frame) { + return lldb::RecognizedStackFrameSP(); + }; + virtual std::string GetName() { + return ""; + } + + virtual ~StackFrameRecognizer(){}; +}; + +#ifndef LLDB_DISABLE_PYTHON + +/// @class ScriptedStackFrameRecognizer +/// +/// Python implementation for frame recognizers. An instance of this class +/// tracks a particular Python classobject, which will be asked to recognize +/// stack frames. + +class ScriptedStackFrameRecognizer : public StackFrameRecognizer { + lldb_private::ScriptInterpreter *m_interpreter; + lldb_private::StructuredData::ObjectSP m_python_object_sp; + std::string m_python_class; + +public: + ScriptedStackFrameRecognizer(lldb_private::ScriptInterpreter *interpreter, + const char *pclass); + ~ScriptedStackFrameRecognizer() {} + + std::string GetName() override { + return GetPythonClassName(); + } + + const char *GetPythonClassName() { return m_python_class.c_str(); } + + lldb::RecognizedStackFrameSP RecognizeFrame( + lldb::StackFrameSP frame) override; + +private: + DISALLOW_COPY_AND_ASSIGN(ScriptedStackFrameRecognizer); +}; + +#endif + +/// @class StackFrameRecognizerManager +/// +/// Static class that provides a registry of known stack frame recognizers. +/// Has static methods to add, enumerate, remove, query and invoke recognizers. + +class StackFrameRecognizerManager { +public: + static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, + const ConstString &module, + const ConstString &symbol, + bool first_instruction_only = true); + + static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, + lldb::RegularExpressionSP module, + lldb::RegularExpressionSP symbol, + bool first_instruction_only = true); + + static void ForEach( + std::function<void(uint32_t recognizer_id, std::string recognizer_name, + std::string module, std::string symbol, + bool regexp)> const &callback); + + static bool RemoveRecognizerWithID(uint32_t recognizer_id); + + static void RemoveAllRecognizers(); + + static lldb::StackFrameRecognizerSP GetRecognizerForFrame( + lldb::StackFrameSP frame); + + static lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame); +}; + +} // namespace lldb_private + +#endif // liblldb_StackFrameRecognizer_h_ diff --git a/include/lldb/Target/StackID.h b/include/lldb/Target/StackID.h index 51e51a6c0741..871f39c463a9 100644 --- a/include/lldb/Target/StackID.h +++ b/include/lldb/Target/StackID.h @@ -10,10 +10,6 @@ #ifndef liblldb_StackID_h_ #define liblldb_StackID_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/AddressRange.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/StopInfo.h b/include/lldb/Target/StopInfo.h index b25bf7dd3d5d..1a9f5b8480db 100644 --- a/include/lldb/Target/StopInfo.h +++ b/include/lldb/Target/StopInfo.h @@ -10,12 +10,8 @@ #ifndef liblldb_StopInfo_h_ #define liblldb_StopInfo_h_ -// C Includes -// C++ Includes #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/Utility/StructuredData.h" #include "lldb/lldb-public.h" diff --git a/include/lldb/Target/SystemRuntime.h b/include/lldb/Target/SystemRuntime.h index 06cc3ec2d012..328dbe231078 100644 --- a/include/lldb/Target/SystemRuntime.h +++ b/include/lldb/Target/SystemRuntime.h @@ -10,10 +10,6 @@ #ifndef liblldb_SystemRuntime_h_ #define liblldb_SystemRuntime_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include <vector> #include "lldb/Core/ModuleList.h" diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h index 75af8e80d2e5..90df1f4929b7 100644 --- a/include/lldb/Target/Target.h +++ b/include/lldb/Target/Target.h @@ -10,21 +10,16 @@ #ifndef liblldb_Target_h_ #define liblldb_Target_h_ -// C Includes -// C++ Includes #include <list> #include <map> #include <memory> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Breakpoint/BreakpointList.h" #include "lldb/Breakpoint/BreakpointName.h" #include "lldb/Breakpoint/WatchpointList.h" #include "lldb/Core/Architecture.h" -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/UserSettingsController.h" @@ -35,13 +30,14 @@ #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/SectionLoadHistory.h" #include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Timeout.h" #include "lldb/lldb-public.h" namespace lldb_private { -extern OptionEnumValueElement g_dynamic_value_types[]; +OptionEnumValues GetDynamicValueTypes(); typedef enum InlineStrategy { eInlineBreakpointsNever = 0, @@ -61,6 +57,12 @@ typedef enum LoadCWDlldbinitFile { eLoadCWDlldbinitWarn } LoadCWDlldbinitFile; +typedef enum LoadDependentFiles { + eLoadDependentsDefault, + eLoadDependentsYes, + eLoadDependentsNo, +} LoadDependentFiles; + //---------------------------------------------------------------------- // TargetProperties //---------------------------------------------------------------------- @@ -186,6 +188,10 @@ public: void SetDisplayRuntimeSupportValues(bool b); + bool GetDisplayRecognizedArguments() const; + + void SetDisplayRecognizedArguments(bool b); + const ProcessLaunchInfo &GetProcessLaunchInfo(); void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info); @@ -196,6 +202,10 @@ public: bool GetUseModernTypeLookup() const; + void SetRequireHardwareBreakpoints(bool b); + + bool GetRequireHardwareBreakpoints() const; + private: //------------------------------------------------------------------ // Callbacks for m_launch_info. @@ -375,6 +385,10 @@ public: bool GetAutoApplyFixIts() const { return m_auto_apply_fixits; } + bool IsForUtilityExpr() const { return m_running_utility_expression; } + + void SetIsForUtilityExpr(bool b) { m_running_utility_expression = b; } + private: ExecutionPolicy m_execution_policy = default_execution_policy; lldb::LanguageType m_language = lldb::eLanguageTypeUnknown; @@ -392,6 +406,10 @@ private: bool m_ansi_color_errors = false; bool m_result_is_internal = false; bool m_auto_apply_fixits = true; + /// True if the executed code should be treated as utility code that is only + /// used by LLDB internally. + bool m_running_utility_expression = false; + lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues; Timeout<std::micro> m_timeout = default_timeout; Timeout<std::micro> m_one_thread_timeout = llvm::None; @@ -515,7 +533,9 @@ public: //------------------------------------------------------------------ void Dump(Stream *s, lldb::DescriptionLevel description_level); - const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener, + // If listener_sp is null, the listener of the owning Debugger object will be + // used. + const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener_sp, llvm::StringRef plugin_name, const FileSpec *crash_file); @@ -549,7 +569,7 @@ public: // module it is nullptr lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, - lldb::addr_t offset, + uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, @@ -594,14 +614,12 @@ public: // eLazyBoolCalculate, we use the current target setting, else we use the // values passed in. func_name_type_mask is or'ed values from the // FunctionNameType enum. - lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, - const FileSpecList *containingSourceFiles, - const char *func_name, - uint32_t func_name_type_mask, - lldb::LanguageType language, - lldb::addr_t offset, - LazyBool skip_prologue, bool internal, - bool request_hardware); + lldb::BreakpointSP CreateBreakpoint( + const FileSpecList *containingModules, + const FileSpecList *containingSourceFiles, const char *func_name, + lldb::FunctionNameType func_name_type_mask, lldb::LanguageType language, + lldb::addr_t offset, LazyBool skip_prologue, bool internal, + bool request_hardware); lldb::BreakpointSP CreateExceptionBreakpoint(enum lldb::LanguageType language, bool catch_bp, @@ -609,25 +627,34 @@ public: Args *additional_args = nullptr, Status *additional_args_error = nullptr); + lldb::BreakpointSP + CreateScriptedBreakpoint(const llvm::StringRef class_name, + const FileSpecList *containingModules, + const FileSpecList *containingSourceFiles, + bool internal, + bool request_hardware, + StructuredData::ObjectSP extra_args_sp, + Status *creation_error = nullptr); + // 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 you // already know. func_name_type_mask is or'ed values from the // FunctionNameType enum. - lldb::BreakpointSP - CreateBreakpoint(const FileSpecList *containingModules, - const FileSpecList *containingSourceFiles, - const char *func_names[], size_t num_names, - uint32_t func_name_type_mask, lldb::LanguageType language, - lldb::addr_t offset, LazyBool skip_prologue, bool internal, - bool request_hardware); + lldb::BreakpointSP CreateBreakpoint( + const FileSpecList *containingModules, + const FileSpecList *containingSourceFiles, const char *func_names[], + size_t num_names, lldb::FunctionNameType func_name_type_mask, + lldb::LanguageType language, lldb::addr_t offset, 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, lldb::LanguageType language, - lldb::addr_t m_offset, LazyBool skip_prologue, bool internal, + lldb::FunctionNameType func_name_type_mask, + lldb::LanguageType language, lldb::addr_t m_offset, + LazyBool skip_prologue, bool internal, bool request_hardware); // Use this to create a general breakpoint: @@ -665,7 +692,6 @@ public: const BreakpointOptions &options, const BreakpointName::Permissions &permissions); void ApplyNameToBreakpoints(BreakpointName &bp_name); - // This takes ownership of the name obj passed in. void AddBreakpointName(BreakpointName *bp_name); @@ -753,9 +779,9 @@ public: /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be /// returned. //------------------------------------------------------------------ - lldb::addr_t GetOpcodeLoadAddress( - lldb::addr_t load_addr, - AddressClass addr_class = AddressClass::eInvalid) const; + lldb::addr_t + GetOpcodeLoadAddress(lldb::addr_t load_addr, + AddressClass addr_class = AddressClass::eInvalid) const; // Get load_addr as breakable load address for this target. Take a addr and // check if for any reason there is a better address than this to put a @@ -826,14 +852,16 @@ public: /// A shared pointer reference to the module that will become /// the main executable for this process. /// - /// @param[in] get_dependent_files + /// @param[in] load_dependent_files /// If \b true then ask the object files to track down any /// known dependent files. /// /// @see ObjectFile::GetDependentModules (FileSpecList&) /// @see Process::GetImages() //------------------------------------------------------------------ - void SetExecutableModule(lldb::ModuleSP &module_sp, bool get_dependent_files); + void SetExecutableModule( + lldb::ModuleSP &module_sp, + LoadDependentFiles load_dependent_files = eLoadDependentsDefault); bool LoadScriptingResources(std::list<Status> &errors, Stream *feedback_stream = nullptr, @@ -913,28 +941,30 @@ public: /// Set the architecture for this target. /// /// If the current target has no Images read in, then this just sets the - /// architecture, which will - /// be used to select the architecture of the ExecutableModule when that is - /// set. - /// If the current target has an ExecutableModule, then calling - /// SetArchitecture with a different + /// architecture, which will be used to select the architecture of the + /// ExecutableModule when that is set. If the current target has an + /// ExecutableModule, then calling SetArchitecture with a different /// architecture from the currently selected one will reset the - /// ExecutableModule to that slice - /// of the file backing the ExecutableModule. If the file backing the - /// ExecutableModule does not - /// contain a fork of this architecture, then this code will return false, and - /// the architecture - /// won't be changed. - /// If the input arch_spec is the same as the already set architecture, this - /// is a no-op. + /// ExecutableModule to that slice of the file backing the ExecutableModule. + /// If the file backing the ExecutableModule does not contain a fork of this + /// architecture, then this code will return false, and the architecture + /// won't be changed. If the input arch_spec is the same as the already set + /// architecture, this is a no-op. /// /// @param[in] arch_spec /// The new architecture. /// + /// @param[in] set_platform + /// If \b true, then the platform will be adjusted if the currently + /// selected platform is not compatible with the archicture being set. + /// If \b false, then just the architecture will be set even if the + /// currently selected platform isn't compatible (in case it might be + /// manually set following this function call). + /// /// @return /// \b true if the architecture was successfully set, \bfalse otherwise. //------------------------------------------------------------------ - bool SetArchitecture(const ArchSpec &arch_spec); + bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false); bool MergeArchitecture(const ArchSpec &arch_spec); @@ -1324,6 +1354,8 @@ private: void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal); + void FinalizeFileActions(ProcessLaunchInfo &info); + DISALLOW_COPY_AND_ASSIGN(Target); }; diff --git a/include/lldb/Target/TargetList.h b/include/lldb/Target/TargetList.h index 43f4520369b6..90c480745a0c 100644 --- a/include/lldb/Target/TargetList.h +++ b/include/lldb/Target/TargetList.h @@ -10,15 +10,11 @@ #ifndef liblldb_TargetList_h_ #define liblldb_TargetList_h_ -// C Includes -// C++ Includes #include <mutex> #include <vector> -// Other libraries and framework includes -// Project includes -#include "lldb/Core/Broadcaster.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Broadcaster.h" namespace lldb_private { @@ -92,7 +88,8 @@ public: /// An error object that indicates success or failure //------------------------------------------------------------------ Status CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path, - llvm::StringRef triple_str, bool get_dependent_modules, + llvm::StringRef triple_str, + LoadDependentFiles get_dependent_modules, const OptionGroupPlatform *platform_options, lldb::TargetSP &target_sp); @@ -103,7 +100,8 @@ public: /// platform you will be using //------------------------------------------------------------------ Status CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path, - const ArchSpec &arch, bool get_dependent_modules, + const ArchSpec &arch, + LoadDependentFiles get_dependent_modules, lldb::PlatformSP &platform_sp, lldb::TargetSP &target_sp); //------------------------------------------------------------------ @@ -217,12 +215,13 @@ private: Status CreateTargetInternal(Debugger &debugger, llvm::StringRef user_exe_path, llvm::StringRef triple_str, - bool get_dependent_files, + LoadDependentFiles load_dependent_files, const OptionGroupPlatform *platform_options, lldb::TargetSP &target_sp, bool is_dummy_target); Status CreateTargetInternal(Debugger &debugger, llvm::StringRef user_exe_path, - const ArchSpec &arch, bool get_dependent_modules, + const ArchSpec &arch, + LoadDependentFiles get_dependent_modules, lldb::PlatformSP &platform_sp, lldb::TargetSP &target_sp, bool is_dummy_target); diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h index 9ce73e0cbeff..0d14b10c651f 100644 --- a/include/lldb/Target/Thread.h +++ b/include/lldb/Target/Thread.h @@ -10,21 +10,17 @@ #ifndef liblldb_Thread_h_ #define liblldb_Thread_h_ -// C Includes -// C++ Includes #include <memory> #include <mutex> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes -#include "lldb/Core/Broadcaster.h" -#include "lldb/Core/Event.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/RegisterCheckpoint.h" #include "lldb/Target/StackFrameList.h" +#include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-private.h" @@ -57,6 +53,8 @@ public: bool GetStepInAvoidsNoDebug() const; bool GetStepOutAvoidsNoDebug() const; + + uint64_t GetMaxBacktraceDepth() const; }; typedef std::shared_ptr<ThreadProperties> ThreadPropertiesSP; @@ -282,7 +280,7 @@ public: /// message). //------------------------------------------------------------------ StructuredData::ObjectSP GetExtendedInfo() { - if (m_extended_info_fetched == false) { + if (!m_extended_info_fetched) { m_extended_info = FetchThreadExtendedInfo(); m_extended_info_fetched = true; } @@ -496,9 +494,9 @@ public: // If stop_format is true, this will be the form used when we print stop // info. If false, it will be the form we use for thread list and co. - void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx, + void DumpUsingSettingsFormat(Stream &strm, uint32_t frame_idx, bool stop_format); - + bool GetDescription(Stream &s, lldb::DescriptionLevel level, bool print_json_thread, bool print_json_stopinfo); @@ -655,12 +653,16 @@ public: /// @param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// + /// @param[out] status + /// A status with an error if queuing failed. + /// /// @return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepSingleInstruction( - bool step_over, bool abort_other_plans, bool stop_other_threads); + bool step_over, bool abort_other_plans, bool stop_other_threads, + Status &status); //------------------------------------------------------------------ /// Queues the plan used to step through an address range, stepping over @@ -690,6 +692,9 @@ public: /// @param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// + /// @param[out] status + /// A status with an error if queuing failed. + /// /// @param[in] step_out_avoids_code_without_debug_info /// If eLazyBoolYes, if the step over steps out it will continue to step /// out till it comes to a frame with debug info. @@ -702,6 +707,7 @@ public: virtual lldb::ThreadPlanSP QueueThreadPlanForStepOverRange( bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, lldb::RunMode stop_other_threads, + Status &status, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); // Helper function that takes a LineEntry to step, insted of an AddressRange. @@ -710,6 +716,7 @@ public: virtual lldb::ThreadPlanSP QueueThreadPlanForStepOverRange( bool abort_other_plans, const LineEntry &line_entry, const SymbolContext &addr_context, lldb::RunMode stop_other_threads, + Status &status, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); //------------------------------------------------------------------ @@ -744,6 +751,9 @@ public: /// @param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// + /// @param[out] status + /// A status with an error if queuing failed. + /// /// @param[in] step_in_avoids_code_without_debug_info /// If eLazyBoolYes we will step out if we step into code with no debug /// info. @@ -761,7 +771,7 @@ public: virtual lldb::ThreadPlanSP QueueThreadPlanForStepInRange( bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, const char *step_in_target, - lldb::RunMode stop_other_threads, + lldb::RunMode stop_other_threads, Status &status, LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); @@ -771,7 +781,7 @@ public: virtual lldb::ThreadPlanSP QueueThreadPlanForStepInRange( bool abort_other_plans, const LineEntry &line_entry, const SymbolContext &addr_context, const char *step_in_target, - lldb::RunMode stop_other_threads, + lldb::RunMode stop_other_threads, Status &status, LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); @@ -803,6 +813,9 @@ public: /// @param[in] run_vote /// See standard meanings for the stop & run votes in ThreadPlan.h. /// + /// @param[out] status + /// A status with an error if queuing failed. + /// /// @param[in] step_out_avoids_code_without_debug_info /// If eLazyBoolYes, if the step over steps out it will continue to step /// out till it comes to a frame with debug info. @@ -814,10 +827,8 @@ public: //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepOut( bool abort_other_plans, SymbolContext *addr_context, bool first_insn, - bool stop_other_threads, - Vote stop_vote, // = eVoteYes, - Vote run_vote, // = eVoteNoOpinion); - uint32_t frame_idx, + bool stop_other_threads, Vote stop_vote, Vote run_vote, + uint32_t frame_idx, Status &status, LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); //------------------------------------------------------------------ @@ -848,9 +859,15 @@ public: /// \b true if we will stop other threads while we single step this one. /// /// @param[in] stop_vote + /// /// @param[in] run_vote /// See standard meanings for the stop & run votes in ThreadPlan.h. /// + /// @param[in] frame_idx + /// + /// @param[out] status + /// A status with an error if queuing failed. + /// /// @param[in] continue_to_next_branch /// Normally this will enqueue a plan that will put a breakpoint on the /// return address and continue @@ -874,16 +891,13 @@ public: //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepOutNoShouldStop( bool abort_other_plans, SymbolContext *addr_context, bool first_insn, - bool stop_other_threads, - Vote stop_vote, // = eVoteYes, - Vote run_vote, // = eVoteNoOpinion); - uint32_t frame_idx, bool continue_to_next_branch = false); + bool stop_other_threads, Vote stop_vote, Vote run_vote, + uint32_t frame_idx, Status &status, bool continue_to_next_branch = false); //------------------------------------------------------------------ /// Gets the plan used to step through the code that steps from a function /// call site at the current PC into the actual function call. /// - /// /// @param[in] return_stack_id /// The stack id that we will return to (by setting backstop breakpoints on /// the return @@ -897,14 +911,17 @@ public: /// @param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// + /// @param[out] status + /// A status with an error if queuing failed. + /// /// @return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForStepThrough(StackID &return_stack_id, - bool abort_other_plans, - bool stop_other_threads); + bool abort_other_plans, bool stop_other_threads, + Status &status); //------------------------------------------------------------------ /// Gets the plan used to continue from the current PC. @@ -922,22 +939,24 @@ public: /// @param[in] stop_other_threads /// \b true if we will stop other threads while we single step this one. /// + /// @param[out] status + /// A status with an error if queuing failed. + /// /// @return /// A shared pointer to the newly queued thread plan, or nullptr if the /// plan could not be queued. //------------------------------------------------------------------ virtual lldb::ThreadPlanSP QueueThreadPlanForRunToAddress(bool abort_other_plans, Address &target_addr, - bool stop_other_threads); + bool stop_other_threads, Status &status); - virtual lldb::ThreadPlanSP - QueueThreadPlanForStepUntil(bool abort_other_plans, - lldb::addr_t *address_list, size_t num_addresses, - bool stop_others, uint32_t frame_idx); + virtual lldb::ThreadPlanSP QueueThreadPlanForStepUntil( + bool abort_other_plans, lldb::addr_t *address_list, size_t num_addresses, + bool stop_others, uint32_t frame_idx, Status &status); virtual lldb::ThreadPlanSP QueueThreadPlanForStepScripted(bool abort_other_plans, const char *class_name, - bool stop_other_threads); + bool stop_other_threads, Status &status); //------------------------------------------------------------------ // Thread Plan accessors: @@ -1023,7 +1042,7 @@ public: /// false otherwise. //------------------------------------------------------------------ bool CompletedPlanOverridesBreakpoint(); - + //------------------------------------------------------------------ /// Queues a generic thread plan. /// @@ -1038,7 +1057,7 @@ public: /// @return /// A pointer to the last completed plan. //------------------------------------------------------------------ - void QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans); + Status QueueThreadPlan(lldb::ThreadPlanSP &plan_sp, bool abort_other_plans); //------------------------------------------------------------------ /// Discards the plans queued on the plan stack of the current thread. This @@ -1234,6 +1253,10 @@ public: //---------------------------------------------------------------------- virtual uint64_t GetExtendedBacktraceToken() { return LLDB_INVALID_ADDRESS; } + lldb::ValueObjectSP GetCurrentException(); + + lldb::ThreadSP GetCurrentExceptionBacktrace(); + protected: friend class ThreadPlan; friend class ThreadList; diff --git a/include/lldb/Target/ThreadPlan.h b/include/lldb/Target/ThreadPlan.h index 7591fa9c9d07..15bc4c7656c3 100644 --- a/include/lldb/Target/ThreadPlan.h +++ b/include/lldb/Target/ThreadPlan.h @@ -10,13 +10,9 @@ #ifndef liblldb_ThreadPlan_h_ #define liblldb_ThreadPlan_h_ -// C Includes -// C++ Includes #include <mutex> #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" @@ -600,10 +596,12 @@ protected: bool IsUsuallyUnexplainedStopReason(lldb::StopReason); + Status m_status; Thread &m_thread; Vote m_stop_vote; Vote m_run_vote; - bool m_takes_iteration_count = false; + bool m_takes_iteration_count; + bool m_could_not_resolve_hw_bp; int32_t m_iteration_count = 1; private: @@ -655,6 +653,8 @@ public: bool OkayToDiscard() override { return false; } + const Status &GetStatus() { return m_status; } + protected: bool DoPlanExplainsStop(Event *event_ptr) override; diff --git a/include/lldb/Target/ThreadPlanBase.h b/include/lldb/Target/ThreadPlanBase.h index 7a8b7eb20bb2..bcf20c5544bc 100644 --- a/include/lldb/Target/ThreadPlanBase.h +++ b/include/lldb/Target/ThreadPlanBase.h @@ -10,10 +10,6 @@ #ifndef liblldb_ThreadPlanFundamental_h_ #define liblldb_ThreadPlanFundamental_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" diff --git a/include/lldb/Target/ThreadPlanCallFunction.h b/include/lldb/Target/ThreadPlanCallFunction.h index 56bfc819320c..3bec86e370d1 100644 --- a/include/lldb/Target/ThreadPlanCallFunction.h +++ b/include/lldb/Target/ThreadPlanCallFunction.h @@ -10,10 +10,6 @@ #ifndef liblldb_ThreadPlanCallFunction_h_ #define liblldb_ThreadPlanCallFunction_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h index d58f7f050dbe..9b75da5fd2f8 100644 --- a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h +++ b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h @@ -11,10 +11,6 @@ #ifndef liblldb_ThreadPlanCallFunctionUsingABI_h_ #define liblldb_ThreadPlanCallFunctionUsingABI_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ABI.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlanCallFunction.h" diff --git a/include/lldb/Target/ThreadPlanCallUserExpression.h b/include/lldb/Target/ThreadPlanCallUserExpression.h index 5fe80927ca21..ba1001ce5e91 100644 --- a/include/lldb/Target/ThreadPlanCallUserExpression.h +++ b/include/lldb/Target/ThreadPlanCallUserExpression.h @@ -11,10 +11,6 @@ #ifndef liblldb_ThreadPlanCallUserExpression_h_ #define liblldb_ThreadPlanCallUserExpression_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanCallFunction.h" diff --git a/include/lldb/Target/ThreadPlanPython.h b/include/lldb/Target/ThreadPlanPython.h index 973c935b7c79..fc4cfb3bf0b4 100644 --- a/include/lldb/Target/ThreadPlanPython.h +++ b/include/lldb/Target/ThreadPlanPython.h @@ -11,12 +11,8 @@ #ifndef liblldb_ThreadPlan_Python_h_ #define liblldb_ThreadPlan_Python_h_ -// C Includes -// C++ Includes #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/Target/Process.h" #include "lldb/Target/StopInfo.h" #include "lldb/Target/Target.h" @@ -63,6 +59,7 @@ protected: private: std::string m_class_name; StructuredData::ObjectSP m_implementation_sp; + bool m_did_push; DISALLOW_COPY_AND_ASSIGN(ThreadPlanPython); }; diff --git a/include/lldb/Target/ThreadPlanRunToAddress.h b/include/lldb/Target/ThreadPlanRunToAddress.h index 8e91fb9472a7..58608864d463 100644 --- a/include/lldb/Target/ThreadPlanRunToAddress.h +++ b/include/lldb/Target/ThreadPlanRunToAddress.h @@ -10,12 +10,8 @@ #ifndef liblldb_ThreadPlanRunToAddress_h_ #define liblldb_ThreadPlanRunToAddress_h_ -// C Includes -// C++ Includes #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlan.h" #include "lldb/lldb-private.h" diff --git a/include/lldb/Target/ThreadPlanShouldStopHere.h b/include/lldb/Target/ThreadPlanShouldStopHere.h index 030d5e434bd9..d3aca3e6f5c0 100644 --- a/include/lldb/Target/ThreadPlanShouldStopHere.h +++ b/include/lldb/Target/ThreadPlanShouldStopHere.h @@ -10,10 +10,6 @@ #ifndef liblldb_ThreadPlanShouldStopHere_h_ #define liblldb_ThreadPlanShouldStopHere_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/ThreadPlan.h" namespace lldb_private { @@ -101,10 +97,12 @@ public: void ClearShouldStopHereCallbacks() { m_callbacks.Clear(); } - bool InvokeShouldStopHereCallback(lldb::FrameComparison operation); + bool InvokeShouldStopHereCallback(lldb::FrameComparison operation, + Status &status); lldb::ThreadPlanSP - CheckShouldStopHereAndQueueStepOut(lldb::FrameComparison operation); + CheckShouldStopHereAndQueueStepOut(lldb::FrameComparison operation, + Status &status); lldb_private::Flags &GetFlags() { return m_flags; } @@ -114,14 +112,16 @@ protected: static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, - void *baton); + Status &status, void *baton); static lldb::ThreadPlanSP DefaultStepFromHereCallback(ThreadPlan *current_plan, Flags &flags, - lldb::FrameComparison operation, void *baton); + lldb::FrameComparison operation, Status &status, + void *baton); virtual lldb::ThreadPlanSP - QueueStepOutFromHerePlan(Flags &flags, lldb::FrameComparison operation); + QueueStepOutFromHerePlan(Flags &flags, lldb::FrameComparison operation, + Status &status); // Implement this, and call it in the plan's constructor to set the default // flags. diff --git a/include/lldb/Target/ThreadPlanStepInRange.h b/include/lldb/Target/ThreadPlanStepInRange.h index c3116eac81b5..c13b3533af1c 100644 --- a/include/lldb/Target/ThreadPlanStepInRange.h +++ b/include/lldb/Target/ThreadPlanStepInRange.h @@ -10,10 +10,6 @@ #ifndef liblldb_ThreadPlanStepInRange_h_ #define liblldb_ThreadPlanStepInRange_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/AddressRange.h" #include "lldb/Target/StackID.h" #include "lldb/Target/Thread.h" @@ -58,7 +54,7 @@ protected: static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, - void *baton); + Status &status, void *baton); bool DoWillResume(lldb::StateType resume_state, bool current_plan) override; @@ -80,11 +76,11 @@ private: friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepOverRange( bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, lldb::RunMode stop_others, - LazyBool avoid_code_without_debug_info); + Status &status, LazyBool avoid_code_without_debug_info); friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepInRange( bool abort_other_plans, const AddressRange &range, const SymbolContext &addr_context, const char *step_in_target, - lldb::RunMode stop_others, + lldb::RunMode stop_others, Status &status, LazyBool step_in_avoids_code_without_debug_info, LazyBool step_out_avoids_code_without_debug_info); diff --git a/include/lldb/Target/ThreadPlanStepInstruction.h b/include/lldb/Target/ThreadPlanStepInstruction.h index 8b56e41ad64f..ea5d93fa4944 100644 --- a/include/lldb/Target/ThreadPlanStepInstruction.h +++ b/include/lldb/Target/ThreadPlanStepInstruction.h @@ -10,10 +10,6 @@ #ifndef liblldb_ThreadPlanStepInstruction_h_ #define liblldb_ThreadPlanStepInstruction_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/lldb-private.h" @@ -43,7 +39,8 @@ protected: private: friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepSingleInstruction( - bool step_over, bool abort_other_plans, bool stop_other_threads); + bool step_over, bool abort_other_plans, bool stop_other_threads, + Status &status); lldb::addr_t m_instruction_addr; bool m_stop_other_threads; diff --git a/include/lldb/Target/ThreadPlanStepOut.h b/include/lldb/Target/ThreadPlanStepOut.h index 285f4cab13a2..8ef9f95d4f96 100644 --- a/include/lldb/Target/ThreadPlanStepOut.h +++ b/include/lldb/Target/ThreadPlanStepOut.h @@ -10,10 +10,6 @@ #ifndef liblldb_ThreadPlanStepOut_h_ #define liblldb_ThreadPlanStepOut_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanShouldStopHere.h" @@ -74,13 +70,14 @@ private: // if ShouldStopHere told us // to. Function *m_immediate_step_from_function; + std::vector<lldb::StackFrameSP> m_stepped_past_frames; lldb::ValueObjectSP m_return_valobj_sp; bool m_calculate_return_value; friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepOut( bool abort_other_plans, SymbolContext *addr_context, bool first_insn, bool stop_others, Vote stop_vote, Vote run_vote, uint32_t frame_idx, - LazyBool step_out_avoids_code_without_debug_info); + Status &status, LazyBool step_out_avoids_code_without_debug_info); void SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info); // Need an appropriate marker for the current stack so we can tell step out diff --git a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h index e799ec5a44ff..7aaf56ed7c0b 100644 --- a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h +++ b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h @@ -10,10 +10,6 @@ #ifndef liblldb_ThreadPlanStepOverBreakpoint_h_ #define liblldb_ThreadPlanStepOverBreakpoint_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" diff --git a/include/lldb/Target/ThreadPlanStepOverRange.h b/include/lldb/Target/ThreadPlanStepOverRange.h index 84fdb0ddcf99..2eeb2bb96022 100644 --- a/include/lldb/Target/ThreadPlanStepOverRange.h +++ b/include/lldb/Target/ThreadPlanStepOverRange.h @@ -10,10 +10,6 @@ #ifndef liblldb_ThreadPlanStepOverRange_h_ #define liblldb_ThreadPlanStepOverRange_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/AddressRange.h" #include "lldb/Target/StackID.h" #include "lldb/Target/Thread.h" diff --git a/include/lldb/Target/ThreadPlanStepRange.h b/include/lldb/Target/ThreadPlanStepRange.h index 65bc1671cb1e..b3e267a0827b 100644 --- a/include/lldb/Target/ThreadPlanStepRange.h +++ b/include/lldb/Target/ThreadPlanStepRange.h @@ -10,10 +10,6 @@ #ifndef liblldb_ThreadPlanStepRange_h_ #define liblldb_ThreadPlanStepRange_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Core/AddressRange.h" #include "lldb/Target/StackID.h" #include "lldb/Target/Thread.h" diff --git a/include/lldb/Target/ThreadPlanStepThrough.h b/include/lldb/Target/ThreadPlanStepThrough.h index 41aa7b21abe0..1bff541e7df6 100644 --- a/include/lldb/Target/ThreadPlanStepThrough.h +++ b/include/lldb/Target/ThreadPlanStepThrough.h @@ -10,10 +10,6 @@ #ifndef liblldb_ThreadPlanStepThrough_h_ #define liblldb_ThreadPlanStepThrough_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" @@ -45,10 +41,9 @@ protected: private: friend lldb::ThreadPlanSP - Thread::QueueThreadPlanForStepThrough(StackID &return_stack_id, bool abort_other_plans, - bool stop_others); + bool stop_others, Status &status); void ClearBackstopBreakpoint(); diff --git a/include/lldb/Target/ThreadPlanStepUntil.h b/include/lldb/Target/ThreadPlanStepUntil.h index bdc630bcf8de..33ccc0fa0d54 100644 --- a/include/lldb/Target/ThreadPlanStepUntil.h +++ b/include/lldb/Target/ThreadPlanStepUntil.h @@ -10,10 +10,6 @@ #ifndef liblldb_ThreadPlanStepUntil_h_ #define liblldb_ThreadPlanStepUntil_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" @@ -59,7 +55,7 @@ private: friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepUntil( bool abort_other_plans, lldb::addr_t *address_list, size_t num_addresses, - bool stop_others, uint32_t frame_idx); + bool stop_others, uint32_t frame_idx, Status &status); // Need an appropriate marker for the current stack so we can tell step out // from step in. diff --git a/include/lldb/Target/ThreadPlanTracer.h b/include/lldb/Target/ThreadPlanTracer.h index 65115383efaa..21f9023f8d57 100644 --- a/include/lldb/Target/ThreadPlanTracer.h +++ b/include/lldb/Target/ThreadPlanTracer.h @@ -11,13 +11,9 @@ #ifndef liblldb_ThreadPlanTracer_h_ #define liblldb_ThreadPlanTracer_h_ -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Core/RegisterValue.h" #include "lldb/Symbol/TaggedASTType.h" #include "lldb/Target/Thread.h" +#include "lldb/Utility/RegisterValue.h" #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Target/UnixSignals.h b/include/lldb/Target/UnixSignals.h index 7ec683585f8e..8774139371f0 100644 --- a/include/lldb/Target/UnixSignals.h +++ b/include/lldb/Target/UnixSignals.h @@ -10,14 +10,10 @@ #ifndef lldb_UnixSignals_h_ #define lldb_UnixSignals_h_ -// C Includes -// C++ Includes #include <map> #include <string> #include <vector> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/ConstString.h" #include "lldb/lldb-private.h" #include "llvm/ADT/Optional.h" diff --git a/include/lldb/Target/Unwind.h b/include/lldb/Target/Unwind.h index a50e8d4a7bdd..9e0da9ed553b 100644 --- a/include/lldb/Target/Unwind.h +++ b/include/lldb/Target/Unwind.h @@ -10,12 +10,8 @@ #ifndef liblldb_Unwind_h_ #define liblldb_Unwind_h_ -// C Includes -// C++ Includes #include <mutex> -// Other libraries and framework includes -// Project includes #include "lldb/lldb-private.h" namespace lldb_private { diff --git a/include/lldb/Utility/ArchSpec.h b/include/lldb/Utility/ArchSpec.h index 680e9b1b9ea6..e84cbbbe5efa 100644 --- a/include/lldb/Utility/ArchSpec.h +++ b/include/lldb/Utility/ArchSpec.h @@ -15,11 +15,11 @@ #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" #include "lldb/lldb-private-enumerations.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" -#include <cstddef> // for size_t -#include <cstdint> // for uint32_t -#include <string> // for string +#include <cstddef> +#include <cstdint> +#include <string> namespace lldb_private { @@ -371,6 +371,7 @@ public: bool IsValid() const { return m_core >= eCore_arm_generic && m_core < kNumCores; } + explicit operator bool() const { return IsValid(); } bool TripleVendorWasSpecified() const { return !m_triple.getVendorName().empty(); diff --git a/include/lldb/Utility/Baton.h b/include/lldb/Utility/Baton.h index 59999e4697fa..7477846be48b 100644 --- a/include/lldb/Utility/Baton.h +++ b/include/lldb/Utility/Baton.h @@ -10,10 +10,10 @@ #ifndef lldb_Baton_h_ #define lldb_Baton_h_ -#include "lldb/lldb-enumerations.h" // for DescriptionLevel +#include "lldb/lldb-enumerations.h" #include "lldb/lldb-public.h" -#include <memory> // for unique_ptr +#include <memory> namespace lldb_private { class Stream; diff --git a/include/lldb/Core/Broadcaster.h b/include/lldb/Utility/Broadcaster.h index 4851007c9a2a..8763a63b0d5e 100644 --- a/include/lldb/Core/Broadcaster.h +++ b/include/lldb/Utility/Broadcaster.h @@ -7,22 +7,22 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Broadcaster_h_ -#define liblldb_Broadcaster_h_ +#ifndef LLDB_UTILITY_BROADCASTER_H +#define LLDB_UTILITY_BROADCASTER_H #include "lldb/Utility/ConstString.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for ListenerSP, EventSP, Broadcast... +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" #include "llvm/ADT/SmallVector.h" -#include <cstdint> // for uint32_t, UINT32_MAX +#include <cstdint> #include <map> -#include <memory> // for shared_ptr, operator==, enable... +#include <memory> #include <mutex> -#include <set> // for set +#include <set> #include <string> -#include <utility> // for pair +#include <utility> #include <vector> namespace lldb_private { @@ -223,7 +223,7 @@ private: }; //---------------------------------------------------------------------- -/// @class Broadcaster Broadcaster.h "lldb/Core/Broadcaster.h" An event +/// @class Broadcaster Broadcaster.h "lldb/Utility/Broadcaster.h" An event /// broadcasting class. /// /// The Broadcaster class is designed to be subclassed by objects that wish to @@ -595,4 +595,4 @@ private: } // namespace lldb_private -#endif // liblldb_Broadcaster_h_ +#endif // LLDB_UTILITY_BROADCASTER_H diff --git a/include/lldb/Utility/CompletionRequest.h b/include/lldb/Utility/CompletionRequest.h index ef75474813e0..38d8d5c587e2 100644 --- a/include/lldb/Utility/CompletionRequest.h +++ b/include/lldb/Utility/CompletionRequest.h @@ -11,11 +11,50 @@ #define LLDB_UTILITY_COMPLETIONREQUEST_H #include "lldb/Utility/Args.h" +#include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/StringList.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" namespace lldb_private { +class CompletionResult { + //---------------------------------------------------------- + /// A single completion and all associated data. + //---------------------------------------------------------- + struct Completion { + Completion(llvm::StringRef completion, llvm::StringRef description) + : m_completion(completion.str()), m_descripton(description.str()) {} + + std::string m_completion; + std::string m_descripton; + + /// Generates a string that uniquely identifies this completion result. + std::string GetUniqueKey() const; + }; + std::vector<Completion> m_results; + + /// List of added completions so far. Used to filter out duplicates. + llvm::StringSet<> m_added_values; + +public: + void AddResult(llvm::StringRef completion, llvm::StringRef description); + + //---------------------------------------------------------- + /// Adds all collected completion matches to the given list. + /// The list will be cleared before the results are added. The number of + /// results here is guaranteed to be equal to GetNumberOfResults(). + //---------------------------------------------------------- + void GetMatches(StringList &matches) const; + + //---------------------------------------------------------- + /// Adds all collected completion descriptions to the given list. + /// The list will be cleared before the results are added. The number of + /// results here is guaranteed to be equal to GetNumberOfResults(). + //---------------------------------------------------------- + void GetDescriptions(StringList &descriptions) const; + + std::size_t GetNumberOfResults() const { return m_results.size(); } +}; //---------------------------------------------------------------------- /// @class CompletionRequest CompletionRequest.h @@ -46,13 +85,13 @@ public: /// completion from match_start_point, and return match_return_elements /// elements. /// - /// @param [out] matches - /// A list of matches that will be filled by the different completion - /// handlers. + /// @param [out] result + /// The CompletionResult that will be filled with the results after this + /// request has been handled. //---------------------------------------------------------- CompletionRequest(llvm::StringRef command_line, unsigned raw_cursor_pos, int match_start_point, int max_return_elements, - StringList &matches); + CompletionResult &result); llvm::StringRef GetRawLine() const { return m_command; } @@ -84,10 +123,11 @@ public: /// afterwards. /// /// @param match The suggested completion. - void AddCompletion(llvm::StringRef completion) { - // Add the completion if we haven't seen the same value before. - if (m_match_set.insert(completion).second) - m_matches->AppendString(completion); + /// @param match An optional description of the completion string. The + /// description will be displayed to the user alongside the completion. + void AddCompletion(llvm::StringRef completion, + llvm::StringRef description = "") { + m_result.AddResult(completion, description); } /// Adds multiple possible completion strings. @@ -100,7 +140,25 @@ public: AddCompletion(completions.GetStringAtIndex(i)); } - std::size_t GetNumberOfMatches() const { return m_matches->GetSize(); } + /// Adds multiple possible completion strings alongside their descriptions. + /// + /// The number of completions and descriptions must be identical. + /// + /// \param completions The list of completions. + /// \param completions The list of descriptions. + /// + /// @see AddCompletion + void AddCompletions(const StringList &completions, + const StringList &descriptions) { + lldbassert(completions.GetSize() == descriptions.GetSize()); + for (std::size_t i = 0; i < completions.GetSize(); ++i) + AddCompletion(completions.GetStringAtIndex(i), + descriptions.GetStringAtIndex(i)); + } + + std::size_t GetNumberOfMatches() const { + return m_result.GetNumberOfResults(); + } llvm::StringRef GetCursorArgument() const { return GetParsedLine().GetArgumentAtIndex(GetCursorIndex()); @@ -134,14 +192,11 @@ private: /// after the completion.) \bfalse otherwise. bool m_word_complete = false; - // Note: This list is kept private. This is by design to prevent that any - // completion depends on any already computed completion from another backend. - // Note: We don't own the list. It's owned by the creator of the - // CompletionRequest object. - StringList *m_matches; - - /// List of added completions so far. Used to filter out duplicates. - llvm::StringSet<> m_match_set; + /// The result this request is supposed to fill out. + /// We keep this object private to ensure that no backend can in any way + /// depend on already calculated completions (which would make debugging and + /// testing them much more complicated). + CompletionResult &m_result; }; } // namespace lldb_private diff --git a/include/lldb/Utility/Connection.h b/include/lldb/Utility/Connection.h index 1b0801378f84..074b44b36865 100644 --- a/include/lldb/Utility/Connection.h +++ b/include/lldb/Utility/Connection.h @@ -10,16 +10,16 @@ #ifndef liblldb_Connection_h_ #define liblldb_Connection_h_ -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ConnectionStatus -#include "lldb/lldb-forward.h" // for IOObjectSP +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" -#include <ratio> // for micro +#include <ratio> #include <string> -#include <stddef.h> // for size_t +#include <stddef.h> namespace lldb_private { class Status; diff --git a/include/lldb/Utility/ConstString.h b/include/lldb/Utility/ConstString.h index 98b3447abe3e..41f6717edee9 100644 --- a/include/lldb/Utility/ConstString.h +++ b/include/lldb/Utility/ConstString.h @@ -11,9 +11,9 @@ #define liblldb_ConstString_h_ #include "llvm/ADT/StringRef.h" -#include "llvm/Support/FormatVariadic.h" // for format_provider +#include "llvm/Support/FormatVariadic.h" -#include <stddef.h> // for size_t +#include <stddef.h> namespace lldb_private { class Stream; @@ -253,7 +253,7 @@ public: //------------------------------------------------------------------ /// Clear this object's state. /// - /// Clear any contained string and reset the value to the an empty string + /// Clear any contained string and reset the value to the empty string /// value. //------------------------------------------------------------------ void Clear() { m_string = nullptr; } @@ -346,6 +346,15 @@ public: bool IsEmpty() const { return m_string == nullptr || m_string[0] == '\0'; } //------------------------------------------------------------------ + /// Test for null string. + /// + /// @return + /// @li \b true if there is no string associated with this instance. + /// @li \b false if there is a string associated with this instance. + //------------------------------------------------------------------ + bool IsNull() const { return m_string == nullptr; } + + //------------------------------------------------------------------ /// Set the C string value. /// /// Set the string value in the object by uniquing the \a cstr string value @@ -373,15 +382,14 @@ public: /// them. /// /// @param[in] demangled - /// The demangled C string to correlate with the \a mangled - /// name. + /// The demangled string to correlate with the \a mangled name. /// /// @param[in] mangled /// The already uniqued mangled ConstString to correlate the /// soon to be uniqued version of \a demangled. //------------------------------------------------------------------ - void SetCStringWithMangledCounterpart(const char *demangled, - const ConstString &mangled); + void SetStringWithMangledCounterpart(llvm::StringRef demangled, + const ConstString &mangled); //------------------------------------------------------------------ /// Retrieve the mangled or demangled counterpart for a mangled or demangled diff --git a/include/lldb/Utility/DataBufferHeap.h b/include/lldb/Utility/DataBufferHeap.h index d64e5b7563a9..5a1e98803f0a 100644 --- a/include/lldb/Utility/DataBufferHeap.h +++ b/include/lldb/Utility/DataBufferHeap.h @@ -11,10 +11,10 @@ #define liblldb_DataBufferHeap_h_ #include "lldb/Utility/DataBuffer.h" -#include "lldb/lldb-types.h" // for offset_t -#include "llvm/ADT/StringRef.h" // for StringRef +#include "lldb/lldb-types.h" +#include "llvm/ADT/StringRef.h" -#include <cstdint> // for uint8_t, uint64_t +#include <cstdint> #include <vector> namespace lldb_private { @@ -90,7 +90,8 @@ public: /// Set the number of bytes in the data buffer. /// /// Sets the number of bytes that this object should be able to contain. - /// This can be used prior to copying data into the buffer. + /// This can be used prior to copying data into the buffer. Note that this + /// zero-initializes up to \p byte_size bytes. /// /// @param[in] byte_size /// The new size in bytes that this data buffer should attempt diff --git a/include/lldb/Utility/DataBufferLLVM.h b/include/lldb/Utility/DataBufferLLVM.h index d76582cbf47c..947ddb54da4a 100644 --- a/include/lldb/Utility/DataBufferLLVM.h +++ b/include/lldb/Utility/DataBufferLLVM.h @@ -11,10 +11,10 @@ #define LLDB_CORE_DATABUFFERLLVM_H #include "lldb/Utility/DataBuffer.h" -#include "lldb/lldb-types.h" // for offset_t +#include "lldb/lldb-types.h" #include <memory> -#include <stdint.h> // for uint8_t, uint64_t +#include <stdint.h> namespace llvm { class WritableMemoryBuffer; @@ -23,16 +23,11 @@ class Twine; namespace lldb_private { +class FileSystem; class DataBufferLLVM : public DataBuffer { public: ~DataBufferLLVM(); - static std::shared_ptr<DataBufferLLVM> - CreateSliceFromPath(const llvm::Twine &Path, uint64_t Size, uint64_t Offset); - - static std::shared_ptr<DataBufferLLVM> - CreateFromPath(const llvm::Twine &Path); - uint8_t *GetBytes() override; const uint8_t *GetBytes() const override; lldb::offset_t GetByteSize() const override; @@ -40,6 +35,7 @@ public: char *GetChars() { return reinterpret_cast<char *>(GetBytes()); } private: + friend FileSystem; /// Construct a DataBufferLLVM from \p Buffer. \p Buffer must be a valid /// pointer. explicit DataBufferLLVM(std::unique_ptr<llvm::WritableMemoryBuffer> Buffer); diff --git a/include/lldb/Utility/DataEncoder.h b/include/lldb/Utility/DataEncoder.h index c1214705c726..b1ee5a599983 100644 --- a/include/lldb/Utility/DataEncoder.h +++ b/include/lldb/Utility/DataEncoder.h @@ -12,12 +12,12 @@ #if defined(__cplusplus) -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for ByteOrder -#include "lldb/lldb-forward.h" // for DataBufferSP -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-types.h" -#include <stddef.h> // for size_t +#include <stddef.h> #include <stdint.h> namespace lldb_private { diff --git a/include/lldb/Utility/DataExtractor.h b/include/lldb/Utility/DataExtractor.h index 50c88db8e358..f1e15e6d00e3 100644 --- a/include/lldb/Utility/DataExtractor.h +++ b/include/lldb/Utility/DataExtractor.h @@ -11,9 +11,10 @@ #define LLDB_UTILITY_DATAEXTRACTOR_H #include "lldb/lldb-defines.h" -#include "lldb/lldb-enumerations.h" // for ByteOrder -#include "lldb/lldb-forward.h" // for DataBufferSP +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" +#include "llvm/ADT/ArrayRef.h" #include <cassert> #include <stdint.h> @@ -29,7 +30,6 @@ namespace llvm { template <typename T> class SmallVectorImpl; } -// C++ Includes namespace lldb_private { @@ -1095,6 +1095,10 @@ public: void Checksum(llvm::SmallVectorImpl<uint8_t> &dest, uint64_t max_data = 0); + llvm::ArrayRef<uint8_t> GetData() const { + return {GetDataStart(), size_t(GetByteSize())}; + } + protected: //------------------------------------------------------------------ // Member variables diff --git a/include/lldb/Utility/Either.h b/include/lldb/Utility/Either.h deleted file mode 100644 index 0dc340b64e86..000000000000 --- a/include/lldb/Utility/Either.h +++ /dev/null @@ -1,126 +0,0 @@ -//===-- Either.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_Either_h_ -#define liblldb_Either_h_ - -#include "llvm/ADT/Optional.h" - -#include <functional> - -namespace lldb_utility { -template <typename T1, typename T2> class Either { -private: - enum class Selected { One, Two }; - - Selected m_selected; - union { - T1 m_t1; - T2 m_t2; - }; - -public: - Either(const T1 &t1) { - m_t1 = t1; - m_selected = Selected::One; - } - - Either(const T2 &t2) { - m_t2 = t2; - m_selected = Selected::Two; - } - - Either(const Either<T1, T2> &rhs) { - switch (rhs.m_selected) { - case Selected::One: - m_t1 = rhs.GetAs<T1>().getValue(); - m_selected = Selected::One; - break; - case Selected::Two: - m_t2 = rhs.GetAs<T2>().getValue(); - m_selected = Selected::Two; - break; - } - } - - template <class X, typename std::enable_if<std::is_same<T1, X>::value>::type - * = nullptr> - llvm::Optional<T1> GetAs() const { - switch (m_selected) { - case Selected::One: - return m_t1; - default: - return llvm::Optional<T1>(); - } - } - - template <class X, typename std::enable_if<std::is_same<T2, X>::value>::type - * = nullptr> - llvm::Optional<T2> GetAs() const { - switch (m_selected) { - case Selected::Two: - return m_t2; - default: - return llvm::Optional<T2>(); - } - } - - template <class ResultType> - ResultType Apply(std::function<ResultType(T1)> if_T1, - std::function<ResultType(T2)> if_T2) const { - switch (m_selected) { - case Selected::One: - return if_T1(m_t1); - case Selected::Two: - return if_T2(m_t2); - } - } - - bool operator==(const Either<T1, T2> &rhs) { - return (GetAs<T1>() == rhs.GetAs<T1>()) && (GetAs<T2>() == rhs.GetAs<T2>()); - } - - explicit operator bool() { - switch (m_selected) { - case Selected::One: - return (bool)m_t1; - case Selected::Two: - return (bool)m_t2; - } - } - - Either<T1, T2> &operator=(const Either<T1, T2> &rhs) { - switch (rhs.m_selected) { - case Selected::One: - m_t1 = rhs.GetAs<T1>().getValue(); - m_selected = Selected::One; - break; - case Selected::Two: - m_t2 = rhs.GetAs<T2>().getValue(); - m_selected = Selected::Two; - break; - } - return *this; - } - - ~Either() { - switch (m_selected) { - case Selected::One: - m_t1.T1::~T1(); - break; - case Selected::Two: - m_t2.T2::~T2(); - break; - } - } -}; - -} // namespace lldb_utility - -#endif // #ifndef liblldb_Either_h_ diff --git a/include/lldb/Core/Event.h b/include/lldb/Utility/Event.h index fa3017057675..d65043f564fb 100644 --- a/include/lldb/Core/Event.h +++ b/include/lldb/Utility/Event.h @@ -7,24 +7,24 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Event_h_ -#define liblldb_Event_h_ +#ifndef LLDB_UTILITY_EVENT_H +#define LLDB_UTILITY_EVENT_H -#include "lldb/Core/Broadcaster.h" -#include "lldb/Host/Predicate.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Predicate.h" #include "lldb/Utility/StructuredData.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for EventDataSP, ProcessSP, Struct... +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #include <chrono> #include <memory> #include <string> -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class Event; @@ -271,4 +271,4 @@ private: } // namespace lldb_private -#endif // liblldb_Event_h_ +#endif // LLDB_UTILITY_EVENT_H diff --git a/include/lldb/Utility/FastDemangle.h b/include/lldb/Utility/FastDemangle.h deleted file mode 100644 index f779aaa04606..000000000000 --- a/include/lldb/Utility/FastDemangle.h +++ /dev/null @@ -1,26 +0,0 @@ -//===-- FastDemangle.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_FastDemangle_h_ -#define liblldb_FastDemangle_h_ - -#include <cstddef> - -#include <functional> - -namespace lldb_private { - -char *FastDemangle(const char *mangled_name); - -char * -FastDemangle(const char *mangled_name, size_t mangled_name_length, - std::function<void(const char *s)> primitive_type_hook = nullptr); -} - -#endif diff --git a/include/lldb/Utility/FileSpec.h b/include/lldb/Utility/FileSpec.h index d062ba598ccc..0699ab7b5c90 100644 --- a/include/lldb/Utility/FileSpec.h +++ b/include/lldb/Utility/FileSpec.h @@ -10,13 +10,9 @@ #ifndef liblldb_FileSpec_h_ #define liblldb_FileSpec_h_ -// C Includes -// C++ Includes #include <functional> #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/ConstString.h" #include "llvm/ADT/StringRef.h" @@ -24,8 +20,8 @@ #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/Path.h" -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class Stream; @@ -70,23 +66,19 @@ public: /// /// Takes a path to a file which can be just a filename, or a full path. If /// \a path is not nullptr or empty, this function will call - /// FileSpec::SetFile (const char *path, bool resolve). + /// FileSpec::SetFile (const char *path). /// /// @param[in] path /// The full or partial path to a file. /// - /// @param[in] resolve_path - /// If \b true, then we resolve the path, removing stray ../.. and so - /// forth, - /// if \b false we trust the path is in canonical form already. + /// @param[in] style + /// The style of the path /// - /// @see FileSpec::SetFile (const char *path, bool resolve) + /// @see FileSpec::SetFile (const char *path) //------------------------------------------------------------------ - explicit FileSpec(llvm::StringRef path, bool resolve_path, - Style style = Style::native); + explicit FileSpec(llvm::StringRef path, Style style = Style::native); - explicit FileSpec(llvm::StringRef path, bool resolve_path, - const llvm::Triple &Triple); + explicit FileSpec(llvm::StringRef path, const llvm::Triple &Triple); //------------------------------------------------------------------ /// Copy constructor @@ -272,47 +264,6 @@ public: //------------------------------------------------------------------ void Dump(Stream *s) const; - //------------------------------------------------------------------ - /// Existence test. - /// - /// @return - /// \b true if the file exists on disk, \b false otherwise. - //------------------------------------------------------------------ - bool Exists() const; - - //------------------------------------------------------------------ - /// Check if a file is readable by the current user - /// - /// @return - /// \b true if the file exists on disk and is readable, \b false - /// otherwise. - //------------------------------------------------------------------ - bool Readable() const; - - //------------------------------------------------------------------ - /// Expanded existence test. - /// - /// Call into the Host to see if it can help find the file (e.g. by - /// searching paths set in the environment, etc.). - /// - /// If found, sets the value of m_directory to the directory where the file - /// was found. - /// - /// @return - /// \b true if was able to find the file using expanded search - /// methods, \b false otherwise. - //------------------------------------------------------------------ - bool ResolveExecutableLocation(); - - //------------------------------------------------------------------ - /// Canonicalize this file path (basically running the static - /// FileSpec::Resolve method on it). Useful if you asked us not to resolve - /// the file path when you set the file. - //------------------------------------------------------------------ - bool ResolvePath(); - - uint64_t GetByteSize() const; - Style GetPathStyle() const; //------------------------------------------------------------------ @@ -375,6 +326,9 @@ public: //------------------------------------------------------------------ bool IsAbsolute() const; + /// Temporary helper for FileSystem change. + void SetPath(llvm::StringRef p) { SetFile(p); } + //------------------------------------------------------------------ /// Extract the full path to the file. /// @@ -450,19 +404,6 @@ public: ConstString GetFileNameStrippingExtension() const; //------------------------------------------------------------------ - /// Return the current permissions of the path. - /// - /// Returns a bitmask for the current permissions of the file ( zero or more - /// of the permission bits defined in File::Permissions). - /// - /// @return - /// Zero if the file doesn't exist or we are unable to get - /// information for the file, otherwise one or more permission - /// bits from the File::Permissions enumeration. - //------------------------------------------------------------------ - uint32_t GetPermissions() const; - - //------------------------------------------------------------------ /// Get the memory cost of this object. /// /// Return the size in bytes that this object takes in memory. This returns @@ -490,10 +431,9 @@ public: /// If \b true, then we will try to resolve links the path using /// the static FileSpec::Resolve. //------------------------------------------------------------------ - void SetFile(llvm::StringRef path, bool resolve_path, Style style); + void SetFile(llvm::StringRef path, Style style); - void SetFile(llvm::StringRef path, bool resolve_path, - const llvm::Triple &Triple); + void SetFile(llvm::StringRef path, const llvm::Triple &Triple); bool IsResolved() const { return m_is_resolved; } @@ -512,16 +452,6 @@ public: //------------------------------------------------------------------ void SetIsResolved(bool is_resolved) { m_is_resolved = is_resolved; } - //------------------------------------------------------------------ - /// Resolves user name and links in \a path, and overwrites the input - /// argument with the resolved path. - /// - /// @param[in] path - /// Input path to be resolved, in the form of a llvm::SmallString or - /// similar. - //------------------------------------------------------------------ - static void Resolve(llvm::SmallVectorImpl<char> &path); - FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const; FileSpec CopyByRemovingLastPathComponent() const; @@ -542,32 +472,11 @@ public: ConstString GetLastPathComponent() const; - enum EnumerateDirectoryResult { - eEnumerateDirectoryResultNext, // Enumerate next entry in the current - // directory - eEnumerateDirectoryResultEnter, // Recurse into the current entry if it is a - // directory or symlink, or next if not - eEnumerateDirectoryResultQuit // Stop directory enumerations at any level - }; - - typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType)( - void *baton, llvm::sys::fs::file_type file_type, const FileSpec &spec); - - static void EnumerateDirectory(llvm::StringRef dir_path, - bool find_directories, bool find_files, - bool find_other, - EnumerateDirectoryCallbackType callback, - void *callback_baton); - - typedef std::function<EnumerateDirectoryResult( - llvm::sys::fs::file_type file_type, const FileSpec &spec)> - DirectoryCallback; - protected: //------------------------------------------------------------------ // Convenience method for setting the file without changing the style. //------------------------------------------------------------------ - void SetFile(llvm::StringRef path, bool resolve_path); + void SetFile(llvm::StringRef path); //------------------------------------------------------------------ // Member variables diff --git a/include/lldb/Utility/Iterable.h b/include/lldb/Utility/Iterable.h index dcb340a05ef1..1b7ec89d6cf5 100644 --- a/include/lldb/Utility/Iterable.h +++ b/include/lldb/Utility/Iterable.h @@ -10,12 +10,8 @@ #ifndef liblldb_Iterable_h_ #define liblldb_Iterable_h_ -// C Includes -// C++ Includes #include <utility> -// Other libraries and framework includes -// Project includes namespace lldb_private { diff --git a/include/lldb/Utility/LLDBAssert.h b/include/lldb/Utility/LLDBAssert.h index 9d9f3ceefab0..e7448cdac545 100644 --- a/include/lldb/Utility/LLDBAssert.h +++ b/include/lldb/Utility/LLDBAssert.h @@ -14,7 +14,8 @@ #define lldbassert(x) assert(x) #else #define lldbassert(x) \ - lldb_private::lldb_assert(x, #x, __FUNCTION__, __FILE__, __LINE__) + lldb_private::lldb_assert(static_cast<bool>(x), #x, __FUNCTION__, __FILE__, \ + __LINE__) #endif namespace lldb_private { diff --git a/include/lldb/Core/Listener.h b/include/lldb/Utility/Listener.h index 3d12f8fb3391..11f89d7aeec2 100644 --- a/include/lldb/Core/Listener.h +++ b/include/lldb/Utility/Listener.h @@ -7,25 +7,25 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Select_h_ -#define liblldb_Select_h_ +#ifndef LLDB_UTILITY_LISTENER_H +#define LLDB_UTILITY_LISTENER_H -#include "lldb/Core/Broadcaster.h" // for Broadcaster::BroadcasterImplWP +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/Timeout.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for BroadcasterManagerWP, EventSP +#include "lldb/lldb-defines.h" +#include "lldb/lldb-forward.h" #include <condition_variable> #include <list> #include <map> -#include <memory> // for owner_less, enable_shared_from_this +#include <memory> #include <mutex> -#include <ratio> // for micro +#include <ratio> #include <string> #include <vector> -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { class ConstString; @@ -158,4 +158,4 @@ private: } // namespace lldb_private -#endif // liblldb_Select_h_ +#endif // LLDB_UTILITY_LISTENER_H diff --git a/include/lldb/Utility/Log.h b/include/lldb/Utility/Log.h index 62776bdb281b..30b97f0137ef 100644 --- a/include/lldb/Utility/Log.h +++ b/include/lldb/Utility/Log.h @@ -15,8 +15,8 @@ #include "lldb/lldb-defines.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringMap.h" // for StringMap -#include "llvm/ADT/StringRef.h" // for StringRef, StringLiteral +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/ManagedStatic.h" @@ -25,9 +25,9 @@ #include <atomic> #include <cstdarg> #include <cstdint> -#include <memory> // for shared_ptr -#include <string> // for string -#include <type_traits> // for forward +#include <memory> +#include <string> +#include <type_traits> namespace llvm { class raw_ostream; diff --git a/include/lldb/Host/Predicate.h b/include/lldb/Utility/Predicate.h index d8128e71c53e..d05f17131c68 100644 --- a/include/lldb/Host/Predicate.h +++ b/include/lldb/Utility/Predicate.h @@ -10,16 +10,12 @@ #ifndef liblldb_Predicate_h_ #define liblldb_Predicate_h_ -// C Includes #include <stdint.h> #include <time.h> -// C++ Includes #include <condition_variable> #include <mutex> -// Other libraries and framework includes -// Project includes #include "lldb/Utility/Timeout.h" #include "lldb/lldb-defines.h" @@ -34,11 +30,11 @@ typedef enum { eBroadcastNever, ///< No broadcast will be sent when the value is modified. eBroadcastAlways, ///< Always send a broadcast when the value is modified. eBroadcastOnChange ///< Only broadcast if the value changes when the value is - ///modified. + /// modified. } PredicateBroadcastType; //---------------------------------------------------------------------- -/// @class Predicate Predicate.h "lldb/Host/Predicate.h" +/// @class Predicate Predicate.h "lldb/Utility/Predicate.h" /// A C++ wrapper class for providing threaded access to a value of /// type T. /// @@ -220,8 +216,8 @@ protected: T m_value; ///< The templatized value T that we are protecting access to mutable std::mutex m_mutex; ///< The mutex to use when accessing the data std::condition_variable m_condition; ///< The pthread condition variable to - ///use for signaling that data available - ///or changed. + /// use for signaling that data available + /// or changed. private: //------------------------------------------------------------------ diff --git a/include/lldb/Utility/Range.h b/include/lldb/Utility/Range.h deleted file mode 100644 index 60880dbdbc87..000000000000 --- a/include/lldb/Utility/Range.h +++ /dev/null @@ -1,60 +0,0 @@ -//===--------------------- Range.h ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef utility_Range_h_ -#define utility_Range_h_ - -#include <stdint.h> - -namespace lldb_utility { - -class Range { -public: - typedef uint64_t ValueType; - - static const ValueType OPEN_END = UINT64_MAX; - - Range(const Range &rng); - - Range(ValueType low = 0, ValueType high = OPEN_END); - - Range &operator=(const Range &rhs); - - ValueType GetLow() { return m_low; } - - ValueType GetHigh() { return m_high; } - - void SetLow(ValueType low) { m_low = low; } - - void SetHigh(ValueType high) { m_high = high; } - - void Flip(); - - void Intersection(const Range &other); - - void Union(const Range &other); - - typedef bool (*RangeCallback)(ValueType index); - - void Iterate(RangeCallback callback); - - ValueType GetSize(); - - bool IsEmpty(); - -private: - void InitRange(); - - ValueType m_low; - ValueType m_high; -}; - -} // namespace lldb_private - -#endif // #ifndef utility_Range_h_ diff --git a/include/lldb/Core/RegisterValue.h b/include/lldb/Utility/RegisterValue.h index b369c3dff9a9..c025a26fb25a 100644 --- a/include/lldb/Core/RegisterValue.h +++ b/include/lldb/Utility/RegisterValue.h @@ -7,31 +7,23 @@ // //===----------------------------------------------------------------------===// -#ifndef lldb_RegisterValue_h -#define lldb_RegisterValue_h +#ifndef LLDB_UTILITY_REGISTERVALUE_H +#define LLDB_UTILITY_REGISTERVALUE_H -#include "lldb/Core/Scalar.h" #include "lldb/Utility/Endian.h" -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-enumerations.h" // for ByteOrder, Format -#include "lldb/lldb-types.h" // for offset_t - +#include "lldb/Utility/Scalar.h" +#include "lldb/Utility/Status.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-types.h" #include "llvm/ADT/APInt.h" -#include "llvm/ADT/StringRef.h" // for StringRef - -#include <stdint.h> // for uint32_t, uint8_t, uint64_t, uin... -#include <string.h> +#include "llvm/ADT/StringRef.h" +#include <cstdint> +#include <cstring> namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class Stream; -} -namespace lldb_private { struct RegisterInfo; -} -namespace lldb_private { class RegisterValue { public: @@ -276,4 +268,4 @@ protected: } // namespace lldb_private -#endif // lldb_RegisterValue_h +#endif // LLDB_UTILITY_REGISTERVALUE_H diff --git a/include/lldb/Utility/RegularExpression.h b/include/lldb/Utility/RegularExpression.h index 6048fcc610a3..b379c6e8bea1 100644 --- a/include/lldb/Utility/RegularExpression.h +++ b/include/lldb/Utility/RegularExpression.h @@ -40,7 +40,7 @@ inline void regfree(llvm_regex_t *a) { llvm_regfree(a); } #include <string> #include <vector> -#include <stddef.h> // for size_t +#include <stddef.h> #include <stdint.h> namespace llvm { diff --git a/include/lldb/Utility/Reproducer.h b/include/lldb/Utility/Reproducer.h new file mode 100644 index 000000000000..ea315ad771a6 --- /dev/null +++ b/include/lldb/Utility/Reproducer.h @@ -0,0 +1,215 @@ +//===-- Reproducer.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_UTILITY_REPRODUCER_H +#define LLDB_UTILITY_REPRODUCER_H + +#include "lldb/Utility/FileSpec.h" + +#include "llvm/ADT/DenseMap.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/YAMLTraits.h" + +#include <mutex> +#include <string> +#include <vector> + +namespace lldb_private { +namespace repro { + +class Reproducer; + +enum class ReproducerMode { + Capture, + Replay, + Off, +}; + +/// Abstraction for information associated with a provider. This information +/// is serialized into an index which is used by the loader. +struct ProviderInfo { + std::string name; + std::vector<std::string> files; +}; + +/// The provider defines an interface for generating files needed for +/// reproducing. The provider must populate its ProviderInfo to communicate +/// its name and files to the index, before registering with the generator, +/// i.e. in the constructor. +/// +/// Different components will implement different providers. +class ProviderBase { +public: + virtual ~ProviderBase() = default; + + const ProviderInfo &GetInfo() const { return m_info; } + const FileSpec &GetRoot() const { return m_root; } + + /// The Keep method is called when it is decided that we need to keep the + /// data in order to provide a reproducer. + virtual void Keep(){}; + + /// The Discard method is called when it is decided that we do not need to + /// keep any information and will not generate a reproducer. + virtual void Discard(){}; + + // Returns the class ID for this type. + static const void *ClassID() { return &ID; } + + // Returns the class ID for the dynamic type of this Provider instance. + virtual const void *DynamicClassID() const = 0; + +protected: + ProviderBase(const FileSpec &root) : m_root(root) {} + + /// Every provider keeps track of its own files. + ProviderInfo m_info; +private: + /// Every provider knows where to dump its potential files. + FileSpec m_root; + + virtual void anchor(); + static char ID; +}; + +template <typename ThisProviderT> class Provider : public ProviderBase { +public: + static const void *ClassID() { return &ThisProviderT::ID; } + + const void *DynamicClassID() const override { return &ThisProviderT::ID; } + +protected: + using ProviderBase::ProviderBase; // Inherit constructor. +}; + +/// The generator is responsible for the logic needed to generate a +/// reproducer. For doing so it relies on providers, who serialize data that +/// is necessary for reproducing a failure. +class Generator final { +public: + Generator(const FileSpec &root); + ~Generator(); + + /// Method to indicate we want to keep the reproducer. If reproducer + /// generation is disabled, this does nothing. + void Keep(); + + /// Method to indicate we do not want to keep the reproducer. This is + /// unaffected by whether or not generation reproduction is enabled, as we + /// might need to clean up files already written to disk. + void Discard(); + + /// Create and register a new provider. + template <typename T> T *Create() { + std::unique_ptr<ProviderBase> provider = llvm::make_unique<T>(m_root); + return static_cast<T *>(Register(std::move(provider))); + } + + /// Get an existing provider. + template <typename T> T *Get() { + auto it = m_providers.find(T::ClassID()); + if (it == m_providers.end()) + return nullptr; + return static_cast<T *>(it->second.get()); + } + + /// Get a provider if it exists, otherwise create it. + template <typename T> T &GetOrCreate() { + auto *provider = Get<T>(); + if (provider) + return *provider; + return *Create<T>(); + } + + const FileSpec &GetRoot() const; + +private: + friend Reproducer; + + ProviderBase *Register(std::unique_ptr<ProviderBase> provider); + + /// Builds and index with provider info. + void AddProvidersToIndex(); + + /// Map of provider IDs to provider instances. + llvm::DenseMap<const void *, std::unique_ptr<ProviderBase>> m_providers; + std::mutex m_providers_mutex; + + /// The reproducer root directory. + FileSpec m_root; + + /// Flag to ensure that we never call both keep and discard. + bool m_done; +}; + +class Loader final { +public: + Loader(const FileSpec &root); + + llvm::Optional<ProviderInfo> GetProviderInfo(llvm::StringRef name); + llvm::Error LoadIndex(); + + const FileSpec &GetRoot() const { return m_root; } + +private: + llvm::StringMap<ProviderInfo> m_provider_info; + FileSpec m_root; + bool m_loaded; +}; + +/// The reproducer enables clients to obtain access to the Generator and +/// Loader. +class Reproducer { +public: + static Reproducer &Instance(); + static llvm::Error Initialize(ReproducerMode mode, + llvm::Optional<FileSpec> root); + static void Terminate(); + + Reproducer() = default; + + Generator *GetGenerator(); + Loader *GetLoader(); + + const Generator *GetGenerator() const; + const Loader *GetLoader() const; + + FileSpec GetReproducerPath() const; + +protected: + llvm::Error SetCapture(llvm::Optional<FileSpec> root); + llvm::Error SetReplay(llvm::Optional<FileSpec> root); + +private: + static llvm::Optional<Reproducer> &InstanceImpl(); + + llvm::Optional<Generator> m_generator; + llvm::Optional<Loader> m_loader; + + mutable std::mutex m_mutex; +}; + +} // namespace repro +} // namespace lldb_private + +LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(lldb_private::repro::ProviderInfo) + +namespace llvm { +namespace yaml { + +template <> struct MappingTraits<lldb_private::repro::ProviderInfo> { + static void mapping(IO &io, lldb_private::repro::ProviderInfo &info) { + io.mapRequired("name", info.name); + io.mapOptional("files", info.files); + } +}; +} // namespace yaml +} // namespace llvm + +#endif // LLDB_UTILITY_REPRODUCER_H diff --git a/include/lldb/Core/Scalar.h b/include/lldb/Utility/Scalar.h index 40671a242ec3..c23b2f8be25e 100644 --- a/include/lldb/Core/Scalar.h +++ b/include/lldb/Utility/Scalar.h @@ -7,25 +7,21 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Scalar_h_ -#define liblldb_Scalar_h_ - -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-enumerations.h" // for Encoding, ByteOrder -#include "lldb/lldb-private-types.h" // for type128 +#ifndef LLDB_UTILITY_SCALAR_H +#define LLDB_UTILITY_SCALAR_H +#include "lldb/Utility/Status.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-private-types.h" #include "llvm/ADT/APFloat.h" #include "llvm/ADT/APInt.h" - -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t, int64_t +#include <cstddef> +#include <cstdint> namespace lldb_private { class DataExtractor; -} -namespace lldb_private { class Stream; -} +} // namespace lldb_private #define NUM_OF_WORDS_INT128 2 #define BITWIDTH_INT128 128 @@ -375,4 +371,4 @@ bool operator>=(const Scalar &lhs, const Scalar &rhs); } // namespace lldb_private -#endif // liblldb_Scalar_h_ +#endif // LLDB_UTILITY_SCALAR_H diff --git a/include/lldb/Utility/SelectHelper.h b/include/lldb/Utility/SelectHelper.h index 004952f1c598..f2dac7cf53da 100644 --- a/include/lldb/Utility/SelectHelper.h +++ b/include/lldb/Utility/SelectHelper.h @@ -10,8 +10,8 @@ #ifndef liblldb_SelectHelper_h_ #define liblldb_SelectHelper_h_ -#include "lldb/Utility/Status.h" // for Status -#include "lldb/lldb-types.h" // for socket_t +#include "lldb/Utility/Status.h" +#include "lldb/lldb-types.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" diff --git a/include/lldb/Utility/SharingPtr.h b/include/lldb/Utility/SharingPtr.h index 691c92afaaae..7eaa049f4d18 100644 --- a/include/lldb/Utility/SharingPtr.h +++ b/include/lldb/Utility/SharingPtr.h @@ -10,8 +10,6 @@ #ifndef utility_SharingPtr_h_ #define utility_SharingPtr_h_ -// C Includes -// C++ Includes #include <memory> // Microsoft Visual C++ currently does not enable std::atomic to work in CLR @@ -25,8 +23,6 @@ #include <stddef.h> -// Other libraries and framework includes -// Project includes //#define ENABLE_SP_LOGGING 1 // DON'T CHECK THIS LINE IN UNLESS COMMENTED OUT #if defined(ENABLE_SP_LOGGING) diff --git a/include/lldb/Core/State.h b/include/lldb/Utility/State.h index 68f0fee254b3..7b3c0f1c17ab 100644 --- a/include/lldb/Core/State.h +++ b/include/lldb/Utility/State.h @@ -7,16 +7,14 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_State_h_ -#define liblldb_State_h_ +#ifndef LLDB_UTILITY_STATE_H +#define LLDB_UTILITY_STATE_H +#include "lldb/lldb-enumerations.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/FormatProviders.h" - -#include "lldb/lldb-enumerations.h" // for StateType -#include "llvm/ADT/StringRef.h" // for StringRef -#include "llvm/Support/raw_ostream.h" // for raw_ostream - -#include <stdint.h> // for uint32_t +#include "llvm/Support/raw_ostream.h" +#include <cstdint> namespace lldb_private { @@ -80,6 +78,6 @@ template <> struct format_provider<lldb::StateType> { Stream << lldb_private::StateAsCString(state); } }; -} +} // namespace llvm -#endif // liblldb_State_h_ +#endif // LLDB_UTILITY_STATE_H diff --git a/include/lldb/Utility/Status.h b/include/lldb/Utility/Status.h index 3bd2cd5b3b41..9395ea86090b 100644 --- a/include/lldb/Utility/Status.h +++ b/include/lldb/Utility/Status.h @@ -11,15 +11,15 @@ #define LLDB_UTILITY_STATUS_H #include "lldb/lldb-defines.h" -#include "lldb/lldb-enumerations.h" // for ErrorType, ErrorType... -#include "llvm/ADT/StringRef.h" // for StringRef +#include "lldb/lldb-enumerations.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/Error.h" #include "llvm/Support/FormatVariadic.h" #include <cstdarg> -#include <stdint.h> // for uint32_t +#include <stdint.h> #include <string> -#include <system_error> // for error_code -#include <type_traits> // for forward +#include <system_error> +#include <type_traits> namespace llvm { class raw_ostream; diff --git a/include/lldb/Utility/Stream.h b/include/lldb/Utility/Stream.h index 4930521d9497..bd4283edf8a9 100644 --- a/include/lldb/Utility/Stream.h +++ b/include/lldb/Utility/Stream.h @@ -12,14 +12,15 @@ #include "lldb/Utility/Flags.h" #include "lldb/lldb-defines.h" -#include "lldb/lldb-enumerations.h" // for ByteOrder::eByteOrderInvalid -#include "llvm/ADT/StringRef.h" // for StringRef +#include "lldb/lldb-enumerations.h" +#include "llvm/ADT/StringRef.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/raw_ostream.h" #include <stdarg.h> -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t, uint64_t, uint8_t -#include <type_traits> // for forward +#include <stddef.h> +#include <stdint.h> +#include <type_traits> namespace lldb_private { @@ -37,6 +38,25 @@ public: /// string mode. }; + /// Utility class for counting the bytes that were written to a stream in a + /// certain time span. + /// @example + /// ByteDelta delta(*this); + /// WriteDataToStream("foo"); + /// return *delta; + /// @endcode + class ByteDelta { + Stream *m_stream; + /// Bytes we have written so far when ByteDelta was created. + size_t m_start; + + public: + ByteDelta(Stream &s) : m_stream(&s), m_start(s.GetWrittenBytes()) {} + /// Returns the number of bytes written to the given Stream since this + /// ByteDelta object was created. + size_t operator*() const { return m_stream->GetWrittenBytes() - m_start; } + }; + //------------------------------------------------------------------ /// Construct with flags and address size and byte order. /// @@ -52,6 +72,17 @@ public: //------------------------------------------------------------------ Stream(); + // FIXME: Streams should not be copyable. + Stream(const Stream &other) : m_forwarder(*this) { (*this) = other; } + + Stream &operator=(const Stream &rhs) { + m_flags = rhs.m_flags; + m_addr_size = rhs.m_addr_size; + m_byte_order = rhs.m_byte_order; + m_indent_level = rhs.m_indent_level; + return *this; + } + //------------------------------------------------------------------ /// Destructor //------------------------------------------------------------------ @@ -83,7 +114,13 @@ public: /// @return /// The number of bytes that were appended to the stream. //------------------------------------------------------------------ - virtual size_t Write(const void *src, size_t src_len) = 0; + size_t Write(const void *src, size_t src_len) { + size_t appended_byte_count = WriteImpl(src, src_len); + m_bytes_written += appended_byte_count; + return appended_byte_count; + } + + size_t GetWrittenBytes() const { return m_bytes_written; } //------------------------------------------------------------------ // Member functions @@ -121,14 +158,10 @@ public: __attribute__((__format__(__printf__, 2, 3))); //------------------------------------------------------------------ - /// Format a C string from a printf style format and variable arguments and - /// encode and append the resulting C string as hex bytes. + /// Append an uint8_t value in the hexadecimal format to the stream. /// - /// @param[in] format - /// A printf style format string. - /// - /// @param[in] ... - /// Any additional arguments needed for the printf format string. + /// @param[in] uvalue + /// The value to append. /// /// @return /// The number of bytes that were appended to the stream. @@ -504,9 +537,6 @@ public: /// /// @param[in] uval /// A uint64_t value that was extracted as a SLEB128 value. - /// - /// @param[in] format - /// The optional printf format that can be overridden. //------------------------------------------------------------------ size_t PutSLEB128(int64_t uval); @@ -518,12 +548,16 @@ public: /// /// @param[in] uval /// A uint64_t value that was extracted as a ULEB128 value. - /// - /// @param[in] format - /// The optional printf format that can be overridden. //------------------------------------------------------------------ size_t PutULEB128(uint64_t uval); + //------------------------------------------------------------------ + /// Returns a raw_ostream that forwards the data to this Stream object. + //------------------------------------------------------------------ + llvm::raw_ostream &AsRawOstream() { + return m_forwarder; + } + protected: //------------------------------------------------------------------ // Member variables @@ -533,8 +567,53 @@ protected: lldb::ByteOrder m_byte_order; ///< Byte order to use when encoding scalar types. int m_indent_level; ///< Indention level. + std::size_t m_bytes_written = 0; ///< Number of bytes written so far. - size_t _PutHex8(uint8_t uvalue, bool add_prefix); + void _PutHex8(uint8_t uvalue, bool add_prefix); + + //------------------------------------------------------------------ + /// Output character bytes to the stream. + /// + /// Appends \a src_len characters from the buffer \a src to the stream. + /// + /// @param[in] src + /// A buffer containing at least \a src_len bytes of data. + /// + /// @param[in] src_len + /// A number of bytes to append to the stream. + /// + /// @return + /// The number of bytes that were appended to the stream. + //------------------------------------------------------------------ + virtual size_t WriteImpl(const void *src, size_t src_len) = 0; + + //---------------------------------------------------------------------- + /// @class RawOstreamForward Stream.h "lldb/Utility/Stream.h" + /// This is a wrapper class that exposes a raw_ostream interface that just + /// forwards to an LLDB stream, allowing to reuse LLVM algorithms that take + /// a raw_ostream within the LLDB code base. + //---------------------------------------------------------------------- + class RawOstreamForward : public llvm::raw_ostream { + // Note: This stream must *not* maintain its own buffer, but instead + // directly write everything to the internal Stream class. Without this, + // we would run into the problem that the Stream written byte count would + // differ from the actually written bytes by the size of the internal + // raw_ostream buffer. + + Stream &m_target; + void write_impl(const char *Ptr, size_t Size) override { + m_target.Write(Ptr, Size); + } + + uint64_t current_pos() const override { + return m_target.GetWrittenBytes(); + } + + public: + RawOstreamForward(Stream &target) + : llvm::raw_ostream(/*unbuffered*/ true), m_target(target) {} + }; + RawOstreamForward m_forwarder; }; } // namespace lldb_private diff --git a/include/lldb/Utility/StreamCallback.h b/include/lldb/Utility/StreamCallback.h index 0aa9d5d57b2f..63a86eeece73 100644 --- a/include/lldb/Utility/StreamCallback.h +++ b/include/lldb/Utility/StreamCallback.h @@ -13,8 +13,8 @@ #include "lldb/lldb-types.h" #include "llvm/Support/raw_ostream.h" -#include <stddef.h> // for size_t -#include <stdint.h> // for uint64_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { diff --git a/include/lldb/Utility/StreamGDBRemote.h b/include/lldb/Utility/StreamGDBRemote.h index 79234cc03d86..dfc4a39de791 100644 --- a/include/lldb/Utility/StreamGDBRemote.h +++ b/include/lldb/Utility/StreamGDBRemote.h @@ -10,11 +10,11 @@ #ifndef liblldb_StreamGDBRemote_h_ #define liblldb_StreamGDBRemote_h_ -#include "lldb/Utility/StreamString.h" // for StreamString -#include "lldb/lldb-enumerations.h" // for ByteOrder +#include "lldb/Utility/StreamString.h" +#include "lldb/lldb-enumerations.h" -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { diff --git a/include/lldb/Utility/StreamString.h b/include/lldb/Utility/StreamString.h index 0ae3e82a3498..dd2f9f67466e 100644 --- a/include/lldb/Utility/StreamString.h +++ b/include/lldb/Utility/StreamString.h @@ -10,14 +10,14 @@ #ifndef liblldb_StreamString_h_ #define liblldb_StreamString_h_ -#include "lldb/Utility/Stream.h" // for Stream -#include "lldb/lldb-enumerations.h" // for ByteOrder -#include "llvm/ADT/StringRef.h" // for StringRef +#include "lldb/Utility/Stream.h" +#include "lldb/lldb-enumerations.h" +#include "llvm/ADT/StringRef.h" -#include <string> // for string +#include <string> -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t +#include <stddef.h> +#include <stdint.h> namespace lldb_private { @@ -31,8 +31,6 @@ public: void Flush() override; - size_t Write(const void *s, size_t length) override; - void Clear(); bool Empty() const; @@ -49,6 +47,7 @@ public: protected: std::string m_packet; + size_t WriteImpl(const void *s, size_t length) override; }; } // namespace lldb_private diff --git a/include/lldb/Utility/StreamTee.h b/include/lldb/Utility/StreamTee.h index 569ba1979978..4f8e6ab1f002 100644 --- a/include/lldb/Utility/StreamTee.h +++ b/include/lldb/Utility/StreamTee.h @@ -70,29 +70,6 @@ public: } } - size_t Write(const void *s, size_t length) override { - std::lock_guard<std::recursive_mutex> guard(m_streams_mutex); - if (m_streams.empty()) - return 0; - - size_t min_bytes_written = SIZE_MAX; - collection::iterator pos, end; - for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) { - // Allow for our collection to contain NULL streams. This allows the - // StreamTee to be used with hard coded indexes for clients that might - // want N total streams with only a few that are set to valid values. - Stream *strm = pos->get(); - if (strm) { - const size_t bytes_written = strm->Write(s, length); - if (min_bytes_written > bytes_written) - min_bytes_written = bytes_written; - } - } - if (min_bytes_written == SIZE_MAX) - return 0; - return min_bytes_written; - } - size_t AppendStream(const lldb::StreamSP &stream_sp) { size_t new_idx = m_streams.size(); std::lock_guard<std::recursive_mutex> guard(m_streams_mutex); @@ -131,6 +108,29 @@ protected: typedef std::vector<lldb::StreamSP> collection; mutable std::recursive_mutex m_streams_mutex; collection m_streams; + + size_t WriteImpl(const void *s, size_t length) override { + std::lock_guard<std::recursive_mutex> guard(m_streams_mutex); + if (m_streams.empty()) + return 0; + + size_t min_bytes_written = SIZE_MAX; + collection::iterator pos, end; + for (pos = m_streams.begin(), end = m_streams.end(); pos != end; ++pos) { + // Allow for our collection to contain NULL streams. This allows the + // StreamTee to be used with hard coded indexes for clients that might + // want N total streams with only a few that are set to valid values. + Stream *strm = pos->get(); + if (strm) { + const size_t bytes_written = strm->Write(s, length); + if (min_bytes_written > bytes_written) + min_bytes_written = bytes_written; + } + } + if (min_bytes_written == SIZE_MAX) + return 0; + return min_bytes_written; + } }; } // namespace lldb_private diff --git a/include/lldb/Utility/StringExtractor.h b/include/lldb/Utility/StringExtractor.h index 4b75d5c5484d..bc24c153bae6 100644 --- a/include/lldb/Utility/StringExtractor.h +++ b/include/lldb/Utility/StringExtractor.h @@ -10,12 +10,10 @@ #ifndef utility_StringExtractor_h_ #define utility_StringExtractor_h_ -// Other libraries and framework includes -// Project includes #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" -#include <stddef.h> // for size_t +#include <stddef.h> #include <stdint.h> #include <string> diff --git a/include/lldb/Utility/StringExtractorGDBRemote.h b/include/lldb/Utility/StringExtractorGDBRemote.h index 93e760b88112..8c2eca898e64 100644 --- a/include/lldb/Utility/StringExtractorGDBRemote.h +++ b/include/lldb/Utility/StringExtractorGDBRemote.h @@ -12,12 +12,12 @@ #include "lldb/Utility/Status.h" #include "lldb/Utility/StringExtractor.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #include <string> -#include <stddef.h> // for size_t -#include <stdint.h> // for uint8_t +#include <stddef.h> +#include <stdint.h> class StringExtractorGDBRemote : public StringExtractor { public: diff --git a/include/lldb/Utility/StringLexer.h b/include/lldb/Utility/StringLexer.h index e4fc81a85e0d..32cfa4e3f6f2 100644 --- a/include/lldb/Utility/StringLexer.h +++ b/include/lldb/Utility/StringLexer.h @@ -1,5 +1,4 @@ -//===--------------------- StringLexer.h -------------------------*- C++ -//-*-===// +//===--------------------- StringLexer.h ------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -11,9 +10,9 @@ #ifndef utility_StringLexer_h_ #define utility_StringLexer_h_ -#include <initializer_list> // for initializer_list -#include <string> // for string -#include <utility> // for pair +#include <initializer_list> +#include <string> +#include <utility> namespace lldb_utility { diff --git a/include/lldb/Utility/StringList.h b/include/lldb/Utility/StringList.h index 1cb68885e771..c080230249dd 100644 --- a/include/lldb/Utility/StringList.h +++ b/include/lldb/Utility/StringList.h @@ -12,7 +12,7 @@ #include "llvm/ADT/StringRef.h" -#include <stddef.h> // for size_t +#include <stddef.h> #include <string> #include <vector> diff --git a/include/lldb/Utility/StructuredData.h b/include/lldb/Utility/StructuredData.h index d3ebab16f51d..100b4fa98ae1 100644 --- a/include/lldb/Utility/StructuredData.h +++ b/include/lldb/Utility/StructuredData.h @@ -13,17 +13,17 @@ #include "llvm/ADT/StringRef.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/lldb-enumerations.h" // for StructuredDataType +#include "lldb/Utility/FileSpec.h" +#include "lldb/lldb-enumerations.h" -#include <cassert> // for assert -#include <cstddef> // for size_t -#include <cstdint> // for uint64_t +#include <cassert> +#include <cstddef> +#include <cstdint> #include <functional> #include <map> #include <memory> #include <string> -#include <type_traits> // for move +#include <type_traits> #include <utility> #include <vector> @@ -170,7 +170,7 @@ public: bool ForEach(std::function<bool(Object *object)> const &foreach_callback) const { for (const auto &object_sp : m_items) { - if (foreach_callback(object_sp.get()) == false) + if (!foreach_callback(object_sp.get())) return false; } return true; @@ -359,7 +359,7 @@ public: void ForEach(std::function<bool(ConstString key, Object *object)> const &callback) const { for (const auto &pair : m_dict) { - if (callback(pair.first, pair.second.get()) == false) + if (!callback(pair.first, pair.second.get())) break; } } diff --git a/include/lldb/Utility/Timer.h b/include/lldb/Utility/Timer.h index 2c1e984837c2..7c41c6257254 100644 --- a/include/lldb/Utility/Timer.h +++ b/include/lldb/Utility/Timer.h @@ -10,10 +10,10 @@ #ifndef liblldb_Timer_h_ #define liblldb_Timer_h_ -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/lldb-defines.h" #include "llvm/Support/Chrono.h" #include <atomic> -#include <stdint.h> // for uint32_t +#include <stdint.h> namespace lldb_private { class Stream; diff --git a/include/lldb/Utility/UUID.h b/include/lldb/Utility/UUID.h index d42c88862bfa..e082db572e46 100644 --- a/include/lldb/Utility/UUID.h +++ b/include/lldb/Utility/UUID.h @@ -10,8 +10,6 @@ #ifndef LLDB_UTILITY_UUID_H #define LLDB_UTILITY_UUID_H -// C Includes -// C++ Includes #include <stddef.h> #include <stdint.h> #include <string> diff --git a/include/lldb/Utility/UserID.h b/include/lldb/Utility/UserID.h index 9e15e6a43c6c..8560274bdeac 100644 --- a/include/lldb/Utility/UserID.h +++ b/include/lldb/Utility/UserID.h @@ -10,8 +10,8 @@ #ifndef liblldb_UserID_h_ #define liblldb_UserID_h_ -#include "lldb/lldb-defines.h" // for LLDB_INVALID_UID -#include "lldb/lldb-types.h" // for user_id_t +#include "lldb/lldb-defines.h" +#include "lldb/lldb-types.h" namespace lldb_private { class Stream; } diff --git a/include/lldb/Utility/VMRange.h b/include/lldb/Utility/VMRange.h index f03a1b0c1f97..a70b0cb6118c 100644 --- a/include/lldb/Utility/VMRange.h +++ b/include/lldb/Utility/VMRange.h @@ -10,10 +10,10 @@ #ifndef liblldb_VMRange_h_ #define liblldb_VMRange_h_ -#include "lldb/lldb-types.h" // for addr_t +#include "lldb/lldb-types.h" -#include <stddef.h> // for size_t -#include <stdint.h> // for uint32_t +#include <stddef.h> +#include <stdint.h> #include <vector> namespace lldb_private { @@ -87,24 +87,6 @@ public: void Dump(Stream *s, lldb::addr_t base_addr = 0, uint32_t addr_width = 8) const; - class ValueInRangeUnaryPredicate { - public: - ValueInRangeUnaryPredicate(lldb::addr_t value) : _value(value) {} - bool operator()(const VMRange &range) const { - return range.Contains(_value); - } - lldb::addr_t _value; - }; - - class RangeInRangeUnaryPredicate { - public: - RangeInRangeUnaryPredicate(VMRange range) : _range(range) {} - bool operator()(const VMRange &range) const { - return range.Contains(_range); - } - const VMRange &_range; - }; - static bool ContainsValue(const VMRange::collection &coll, lldb::addr_t value); diff --git a/include/lldb/lldb-defines.h b/include/lldb/lldb-defines.h index edb70be09fd9..8a54b4c44364 100644 --- a/include/lldb/lldb-defines.h +++ b/include/lldb/lldb-defines.h @@ -135,6 +135,7 @@ #define LLDB_OPT_SET_8 (1U << 7) #define LLDB_OPT_SET_9 (1U << 8) #define LLDB_OPT_SET_10 (1U << 9) +#define LLDB_OPT_SET_11 (1U << 10) #define LLDB_OPT_SET_FROM_TO(A, B) \ (((1U << (B)) - 1) ^ (((1U << (A)) - 1) >> 1)) diff --git a/include/lldb/lldb-enumerations.h b/include/lldb/lldb-enumerations.h index a1f730379534..1c4d6f509a2a 100644 --- a/include/lldb/lldb-enumerations.h +++ b/include/lldb/lldb-enumerations.h @@ -10,6 +10,42 @@ #ifndef LLDB_lldb_enumerations_h_ #define LLDB_lldb_enumerations_h_ +#include <type_traits> + +#ifndef SWIG +// Macro to enable bitmask operations on an enum. Without this, Enum | Enum +// gets promoted to an int, so you have to say Enum a = Enum(eFoo | eBar). If +// you mark Enum with LLDB_MARK_AS_BITMASK_ENUM(Enum), however, you can simply +// write Enum a = eFoo | eBar. +// Unfortunately, swig<3.0 doesn't recognise the constexpr keyword, so remove +// this entire block, as it is not necessary for swig processing. +#define LLDB_MARK_AS_BITMASK_ENUM(Enum) \ + constexpr Enum operator|(Enum a, Enum b) { \ + return static_cast<Enum>( \ + static_cast<std::underlying_type<Enum>::type>(a) | \ + static_cast<std::underlying_type<Enum>::type>(b)); \ + } \ + constexpr Enum operator&(Enum a, Enum b) { \ + return static_cast<Enum>( \ + static_cast<std::underlying_type<Enum>::type>(a) & \ + static_cast<std::underlying_type<Enum>::type>(b)); \ + } \ + constexpr Enum operator~(Enum a) { \ + return static_cast<Enum>( \ + ~static_cast<std::underlying_type<Enum>::type>(a)); \ + } \ + inline Enum &operator|=(Enum &a, Enum b) { \ + a = a | b; \ + return a; \ + } \ + inline Enum &operator&=(Enum &a, Enum b) { \ + a = a & b; \ + return a; \ + } +#else +#define LLDB_MARK_AS_BITMASK_ENUM(Enum) +#endif + #ifndef SWIG // With MSVC, the default type of an enum is always signed, even if one of the // enumerator values is too large to fit into a signed integer but would @@ -54,9 +90,10 @@ enum StateType { eStateCrashed, ///< Process or thread has crashed and can be examined. eStateDetached, ///< Process has been detached and can't be examined. eStateExited, ///< Process has exited and can't be examined. - eStateSuspended ///< Process or thread is in a suspended state as far + eStateSuspended, ///< Process or thread is in a suspended state as far ///< as the debugger is concerned while other processes ///< or threads get the chance to run. + kLastStateType = eStateSuspended }; //---------------------------------------------------------------------- @@ -256,6 +293,17 @@ enum ExpressionResults { eExpressionStoppedForDebug }; +enum SearchDepth { + eSearchDepthInvalid = 0, + eSearchDepthTarget, + eSearchDepthModule, + eSearchDepthCompUnit, + eSearchDepthFunction, + eSearchDepthBlock, + eSearchDepthAddress, + kLastSearchDepthKind = eSearchDepthAddress +}; + //---------------------------------------------------------------------- // Connection Status Types //---------------------------------------------------------------------- @@ -315,43 +363,45 @@ enum InputReaderGranularity { //------------------------------------------------------------------ FLAGS_ENUM(SymbolContextItem){ eSymbolContextTarget = (1u << 0), ///< Set when \a target is requested from - ///a query, or was located in query - ///results + /// a query, or was located in query + /// results eSymbolContextModule = (1u << 1), ///< Set when \a module is requested from - ///a query, or was located in query - ///results + /// a query, or was located in query + /// results eSymbolContextCompUnit = (1u << 2), ///< Set when \a comp_unit is requested - ///from a query, or was located in query - ///results + /// from a query, or was located in + /// query results eSymbolContextFunction = (1u << 3), ///< Set when \a function is requested - ///from a query, or was located in query - ///results + /// from a query, or was located in + /// query results eSymbolContextBlock = (1u << 4), ///< Set when the deepest \a block is - ///requested from a query, or was located - ///in query results + /// requested from a query, or was located + /// in query results eSymbolContextLineEntry = (1u << 5), ///< Set when \a line_entry is - ///requested from a query, or was - ///located in query results + /// requested from a query, or was + /// located in query results eSymbolContextSymbol = (1u << 6), ///< Set when \a symbol is requested from - ///a query, or was located in query - ///results + /// a query, or was located in query + /// results eSymbolContextEverything = ((eSymbolContextSymbol << 1) - 1u), ///< Indicates to try and lookup everything - ///up during a routine symbol context - ///query. - eSymbolContextVariable = (1u << 7) ///< Set when \a global or static - ///variable is requested from a query, or - ///was located in query results. + /// up during a routine symbol context + /// query. + eSymbolContextVariable = (1u << 7), ///< Set when \a global or static + /// variable is requested from a query, + /// or was located in query results. ///< eSymbolContextVariable is potentially expensive to lookup so it isn't - ///included in + /// included in ///< eSymbolContextEverything which stops it from being used during frame PC - ///lookups and + /// lookups and ///< many other potential address to symbol context lookups. }; +LLDB_MARK_AS_BITMASK_ENUM(SymbolContextItem) FLAGS_ENUM(Permissions){ePermissionsWritable = (1u << 0), ePermissionsReadable = (1u << 1), ePermissionsExecutable = (1u << 2)}; +LLDB_MARK_AS_BITMASK_ENUM(Permissions) enum InputReaderAction { eInputReaderActivate, // reader is newly pushed onto the reader stack @@ -661,7 +711,14 @@ enum SectionType { eSectionTypeDWARFGNUDebugAltLink, eSectionTypeDWARFDebugTypes, // DWARF .debug_types section eSectionTypeDWARFDebugNames, // DWARF v5 .debug_names - eSectionTypeOther + eSectionTypeOther, + eSectionTypeDWARFDebugLineStr, // DWARF v5 .debug_line_str + eSectionTypeDWARFDebugRngLists, // DWARF v5 .debug_rnglists + eSectionTypeDWARFDebugLocLists, // DWARF v5 .debug_loclists + eSectionTypeDWARFDebugAbbrevDwo, + eSectionTypeDWARFDebugInfoDwo, + eSectionTypeDWARFDebugStrDwo, + eSectionTypeDWARFDebugStrOffsetsDwo, }; FLAGS_ENUM(EmulateInstructionOptions){ @@ -689,6 +746,7 @@ FLAGS_ENUM(FunctionNameType){ eFunctionNameTypeAny = eFunctionNameTypeAuto // DEPRECATED: use eFunctionNameTypeAuto }; +LLDB_MARK_AS_BITMASK_ENUM(FunctionNameType) //---------------------------------------------------------------------- // Basic types enumeration for the public API SBType::GetBasicType() @@ -763,6 +821,7 @@ FLAGS_ENUM(TypeClass){ eTypeClassOther = (1u << 31), // Define a mask that can be used for any type when finding types eTypeClassAny = (0xffffffffu)}; +LLDB_MARK_AS_BITMASK_ENUM(TypeClass) enum TemplateArgumentKind { eTemplateArgumentKindNull = 0, @@ -1071,7 +1130,6 @@ enum TypeSummaryCapping { eTypeSummaryCapped = true, eTypeSummaryUncapped = false }; - } // namespace lldb #endif // LLDB_lldb_enumerations_h_ diff --git a/include/lldb/lldb-forward.h b/include/lldb/lldb-forward.h index e3964268dfda..92aa5bb611c3 100644 --- a/include/lldb/lldb-forward.h +++ b/include/lldb/lldb-forward.h @@ -107,7 +107,6 @@ class File; class FileSpec; class FileSpecList; class Flags; -class GoASTContext; class TypeCategoryImpl; class FormatManager; class FormattersMatchCandidate; @@ -126,13 +125,14 @@ class JITLoaderList; class Language; class LanguageCategory; class LanguageRuntime; -class MemoryRegionInfo; class LineTable; class Listener; class Log; class Mangled; class Materializer; class MemoryHistory; +class MemoryRegionInfo; +class MemoryRegionInfos; class Module; class ModuleList; class ModuleSpec; @@ -184,6 +184,7 @@ class ProcessInstanceInfoMatch; class ProcessLaunchInfo; class Property; struct PropertyDefinition; +class RecognizedStackFrame; class RegisterCheckpoint; class RegisterContext; class RegisterLocation; @@ -191,6 +192,7 @@ class RegisterLocationList; class RegisterValue; class RegularExpression; class REPL; +class RichManglingContext; class Scalar; class ScriptInterpreter; class ScriptInterpreterLocker; @@ -207,6 +209,8 @@ class SourceManagerImpl; class StackFrame; class StackFrameImpl; class StackFrameList; +class StackFrameRecognizer; +class StackFrameRecognizerManager; class StackID; class StopInfo; class Stoppoint; @@ -350,7 +354,6 @@ typedef std::shared_ptr<lldb_private::File> FileSP; typedef std::shared_ptr<lldb_private::Function> FunctionSP; typedef std::shared_ptr<lldb_private::FunctionCaller> FunctionCallerSP; typedef std::shared_ptr<lldb_private::FuncUnwinders> FuncUnwindersSP; -typedef std::unique_ptr<lldb_private::GoASTContext> GoASTContextUP; typedef std::shared_ptr<lldb_private::InlineFunctionInfo> InlineFunctionInfoSP; typedef std::shared_ptr<lldb_private::Instruction> InstructionSP; typedef std::shared_ptr<lldb_private::InstrumentationRuntime> @@ -367,7 +370,6 @@ typedef std::shared_ptr<lldb_private::LineTable> LineTableSP; typedef std::shared_ptr<lldb_private::Listener> ListenerSP; typedef std::weak_ptr<lldb_private::Listener> ListenerWP; typedef std::shared_ptr<lldb_private::MemoryHistory> MemoryHistorySP; -typedef std::shared_ptr<lldb_private::MemoryRegionInfo> MemoryRegionInfoSP; typedef std::unique_ptr<lldb_private::MemoryRegionInfo> MemoryRegionInfoUP; typedef std::shared_ptr<lldb_private::Module> ModuleSP; typedef std::weak_ptr<lldb_private::Module> ModuleWP; @@ -413,6 +415,8 @@ typedef std::shared_ptr<lldb_private::Queue> QueueSP; typedef std::weak_ptr<lldb_private::Queue> QueueWP; typedef std::shared_ptr<lldb_private::QueueItem> QueueItemSP; typedef std::shared_ptr<lldb_private::REPL> REPLSP; +typedef std::shared_ptr<lldb_private::RecognizedStackFrame> + RecognizedStackFrameSP; typedef std::shared_ptr<lldb_private::ScriptSummaryFormat> ScriptSummaryFormatSP; typedef std::shared_ptr<lldb_private::ScriptInterpreter> ScriptInterpreterSP; @@ -428,6 +432,8 @@ typedef std::shared_ptr<lldb_private::StackFrame> StackFrameSP; typedef std::unique_ptr<lldb_private::StackFrame> StackFrameUP; typedef std::weak_ptr<lldb_private::StackFrame> StackFrameWP; typedef std::shared_ptr<lldb_private::StackFrameList> StackFrameListSP; +typedef std::shared_ptr<lldb_private::StackFrameRecognizer> + StackFrameRecognizerSP; typedef std::shared_ptr<lldb_private::StopInfo> StopInfoSP; typedef std::shared_ptr<lldb_private::StoppointLocation> StoppointLocationSP; typedef std::shared_ptr<lldb_private::Stream> StreamSP; @@ -492,5 +498,15 @@ typedef std::shared_ptr<lldb_private::Watchpoint> WatchpointSP; } // namespace lldb +//---------------------------------------------------------------------- +// llvm forward declarations +//---------------------------------------------------------------------- +namespace llvm { + +struct ItaniumPartialDemangler; +class StringRef; + +} // namespace llvm + #endif // #if defined(__cplusplus) #endif // LLDB_lldb_forward_h_ diff --git a/include/lldb/lldb-private-forward.h b/include/lldb/lldb-private-forward.h index 65d303281164..975d92d95727 100644 --- a/include/lldb/lldb-private-forward.h +++ b/include/lldb/lldb-private-forward.h @@ -10,26 +10,15 @@ #ifndef LLDB_lldb_private_forward_h_ #define LLDB_lldb_private_forward_h_ -#if defined(__cplusplus) - -#include <memory> - namespace lldb_private { // --------------------------------------------------------------- Class // forward decls. // --------------------------------------------------------------- -class NativeBreakpoint; -class NativeBreakpointList; class NativeProcessProtocol; class NativeRegisterContext; class NativeThreadProtocol; class ResumeActionList; class UnixSignals; - -// --------------------------------------------------------------- SP/WP decls. -// --------------------------------------------------------------- -typedef std::shared_ptr<NativeBreakpoint> NativeBreakpointSP; } -#endif // #if defined(__cplusplus) #endif // #ifndef LLDB_lldb_private_forward_h_ diff --git a/include/lldb/lldb-private-interfaces.h b/include/lldb/lldb-private-interfaces.h index 806068ece7b6..76a9fad9f135 100644 --- a/include/lldb/lldb-private-interfaces.h +++ b/include/lldb/lldb-private-interfaces.h @@ -84,10 +84,10 @@ typedef void (*OptionValueChangedCallback)(void *baton, OptionValue *option_value); typedef bool (*ThreadPlanShouldStopHereCallback)( ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, - void *baton); + Status &status, void *baton); typedef lldb::ThreadPlanSP (*ThreadPlanStepFromHereCallback)( ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, - void *baton); + Status &status, void *baton); typedef UnwindAssembly *(*UnwindAssemblyCreateInstance)(const ArchSpec &arch); typedef lldb::MemoryHistorySP (*MemoryHistoryCreateInstance)( const lldb::ProcessSP &process_sp); diff --git a/include/lldb/lldb-private-types.h b/include/lldb/lldb-private-types.h index 7ba7350e868c..e0f0e413cef4 100644 --- a/include/lldb/lldb-private-types.h +++ b/include/lldb/lldb-private-types.h @@ -95,6 +95,8 @@ struct OptionEnumValueElement { const char *usage; }; +using OptionEnumValues = llvm::ArrayRef<OptionEnumValueElement>; + struct OptionValidator { virtual ~OptionValidator() {} virtual bool IsValid(Platform &platform, @@ -112,9 +114,8 @@ struct OptionDefinition { int short_option; // Single character for this option. int option_has_arg; // no_argument, required_argument or optional_argument OptionValidator *validator; // If non-NULL, option is valid iff - // |validator->IsValid()|, otherwise always - // valid. - OptionEnumValueElement *enum_values; // If non-NULL an array of enum values. + // |validator->IsValid()|, otherwise always valid. + OptionEnumValues enum_values; // If not empty, an array of enum values. uint32_t completion_type; // Cookie the option class can use to do define the // argument completion. lldb::CommandArgumentType argument_type; // Type of argument this option takes diff --git a/include/lldb/lldb-types.h b/include/lldb/lldb-types.h index 79f441569304..09dfc5c8a5ed 100644 --- a/include/lldb/lldb-types.h +++ b/include/lldb/lldb-types.h @@ -47,7 +47,8 @@ typedef unsigned int __w64 socket_t; // Host socket type 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 *pipe_t; // Host pipe type is HANDLE +} // namespace lldb #else @@ -65,6 +66,7 @@ typedef int socket_t; // Host socket type 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 +typedef int pipe_t; // Host pipe type } // namespace lldb #endif @@ -76,10 +78,11 @@ typedef bool (*CommandOverrideCallbackWithResult)( void *baton, const char **argv, lldb_private::CommandReturnObject &result); typedef bool (*ExpressionCancelCallback)(ExpressionEvaluationPhase phase, void *baton); -} +} // namespace lldb #define LLDB_INVALID_PROCESS ((lldb::process_t)-1) #define LLDB_INVALID_HOST_THREAD ((lldb::thread_t)NULL) +#define LLDB_INVALID_PIPE ((lldb::pipe_t)-1) namespace lldb { typedef uint64_t addr_t; @@ -91,6 +94,6 @@ typedef int32_t break_id_t; typedef int32_t watch_id_t; typedef void *opaque_compiler_type_t; typedef uint64_t queue_id_t; -} +} // namespace lldb #endif // LLDB_lldb_types_h_ diff --git a/include/lldb/module.modulemap b/include/lldb/module.modulemap index cec0428c1840..9c7f3e6f58e5 100644 --- a/include/lldb/module.modulemap +++ b/include/lldb/module.modulemap @@ -38,10 +38,10 @@ module lldb_Host { module PipeBase { header "Host/PipeBase.h" export * } module Pipe { header "Host/Pipe.h" export * } module PosixApi { header "Host/PosixApi.h" export * } - module Predicate { header "Host/Predicate.h" export * } module ProcessLauncher { header "Host/ProcessLauncher.h" export * } module ProcessRunLock { header "Host/ProcessRunLock.h" export * } module PseudoTerminal { header "Host/PseudoTerminal.h" export * } + module SafeMachO { header "Host/SafeMachO.h" export * } module SocketAddress { header "Host/SocketAddress.h" export * } module Socket { header "Host/Socket.h" export * } module StringConvert { header "Host/StringConvert.h" export * } |