diff options
Diffstat (limited to 'include')
282 files changed, 6190 insertions, 6909 deletions
diff --git a/include/lldb/API/SBAddress.h b/include/lldb/API/SBAddress.h index 9e697beffdd1d..02e847b97aa11 100644 --- a/include/lldb/API/SBAddress.h +++ b/include/lldb/API/SBAddress.h @@ -54,9 +54,9 @@ public: lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope); // The following functions grab individual objects for a given address and - // are less efficient if you want more than one symbol related objects. - // Use one of the following when you want multiple debug symbol related - // objects for an address: + // are less efficient if you want more than one symbol related objects. Use + // one of the following when you want multiple debug symbol related objects + // for an address: // lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t // resolve_scope); // lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const @@ -80,8 +80,6 @@ public: lldb::SBLineEntry GetLineEntry(); - lldb::AddressClass GetAddressClass(); - protected: friend class SBBlock; friend class SBBreakpointLocation; @@ -103,7 +101,7 @@ protected: const lldb_private::Address *operator->() const; - friend bool operator==(const SBAddress &lhs, const SBAddress &rhs); + friend bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs); lldb_private::Address *get(); @@ -119,7 +117,7 @@ private: std::unique_ptr<lldb_private::Address> m_opaque_ap; }; -bool operator==(const SBAddress &lhs, const SBAddress &rhs); +bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs); } // namespace lldb diff --git a/include/lldb/API/SBBroadcaster.h b/include/lldb/API/SBBroadcaster.h index 3fc47af655139..dc6c50ec0a8a5 100644 --- a/include/lldb/API/SBBroadcaster.h +++ b/include/lldb/API/SBBroadcaster.h @@ -46,17 +46,17 @@ public: bool RemoveListener(const lldb::SBListener &listener, uint32_t event_mask = UINT32_MAX); - // This comparison is checking if the internal opaque pointer value - // is equal to that in "rhs". + // This comparison is checking if the internal opaque pointer value is equal + // to that in "rhs". bool operator==(const lldb::SBBroadcaster &rhs) const; - // This comparison is checking if the internal opaque pointer value - // is not equal to that in "rhs". + // This comparison is checking if the internal opaque pointer value is not + // equal to that in "rhs". bool operator!=(const lldb::SBBroadcaster &rhs) const; - // This comparison is checking if the internal opaque pointer value - // is less than that in "rhs" so SBBroadcaster objects can be contained - // in ordered containers. + // This comparison is checking if the internal opaque pointer value is less + // than that in "rhs" so SBBroadcaster objects can be contained in ordered + // containers. bool operator<(const lldb::SBBroadcaster &rhs) const; protected: diff --git a/include/lldb/API/SBCommandInterpreter.h b/include/lldb/API/SBCommandInterpreter.h index 80f24ceca7b41..8b9f065993666 100644 --- a/include/lldb/API/SBCommandInterpreter.h +++ b/include/lldb/API/SBCommandInterpreter.h @@ -138,23 +138,20 @@ public: lldb::SBCommandReturnObject result); // The pointer based interface is not useful in SWIG, since the cursor & - // last_char arguments are string pointers INTO current_line - // and you can't do that in a scripting language interface in general... + // last_char arguments are string pointers INTO current_line and you can't do + // that in a scripting language interface in general... // In either case, the way this works is that the you give it a line and - // cursor position in the line. The function - // will return the number of completions. The matches list will contain - // number_of_completions + 1 elements. The first - // element is the common substring after the cursor position for all the - // matches. The rest of the elements are the - // matches. The first element is useful if you are emulating the common shell - // behavior where the tab completes - // to the string that is common among all the matches, then you should first - // check if the first element is non-empty, + // cursor position in the line. The function will return the number of + // completions. The matches list will contain number_of_completions + 1 + // elements. The first element is the common substring after the cursor + // position for all the matches. The rest of the elements are the matches. + // The first element is useful if you are emulating the common shell behavior + // where the tab completes to the string that is common among all the + // matches, then you should first check if the first element is non-empty, // and if so just insert it and move the cursor to the end of the insertion. - // The next tab will return an empty - // common substring, and a list of choices (if any), at which point you should - // display the choices and let the user + // The next tab will return an empty common substring, and a list of choices + // (if any), at which point you should display the choices and let the user // type further to disambiguate. int HandleCompletion(const char *current_line, const char *cursor, @@ -167,9 +164,9 @@ public: bool WasInterrupted() const; - // Catch commands before they execute by registering a callback that will - // get called when the command gets executed. This allows GUI or command - // line interfaces to intercept a command and stop it from happening + // Catch commands before they execute by registering a callback that will get + // called when the command gets executed. This allows GUI or command line + // interfaces to intercept a command and stop it from happening bool SetCommandOverrideCallback(const char *command_name, lldb::CommandOverrideCallback callback, void *baton); @@ -211,6 +208,25 @@ public: void SetPromptOnQuit(bool b); //---------------------------------------------------------------------- + /// Sets whether the command interpreter should allow custom exit codes + /// for the 'quit' command. + //---------------------------------------------------------------------- + void AllowExitCodeOnQuit(bool allow); + + //---------------------------------------------------------------------- + /// Returns true if the user has called the 'quit' command with a custom exit + /// code. + //---------------------------------------------------------------------- + bool HasCustomQuitExitCode(); + + //---------------------------------------------------------------------- + /// Returns the exit code that the user has specified when running the + /// 'quit' command. Returns 0 if the user hasn't called 'quit' at all or + /// without a custom exit code. + //---------------------------------------------------------------------- + int GetQuitStatus(); + + //---------------------------------------------------------------------- /// Resolve the command just as HandleCommand would, expanding abbreviations /// and aliases. If successful, result->GetOutput has the full expansion. //---------------------------------------------------------------------- diff --git a/include/lldb/API/SBCommandReturnObject.h b/include/lldb/API/SBCommandReturnObject.h index c73e3f7cf1f27..a372ea2ad9ee2 100644 --- a/include/lldb/API/SBCommandReturnObject.h +++ b/include/lldb/API/SBCommandReturnObject.h @@ -67,8 +67,7 @@ public: bool GetDescription(lldb::SBStream &description); - // deprecated, these two functions do not take - // ownership of file handle + // deprecated, these two functions do not take ownership of file handle void SetImmediateOutputFile(FILE *fh); void SetImmediateErrorFile(FILE *fh); diff --git a/include/lldb/API/SBData.h b/include/lldb/API/SBData.h index 7aa4ea0ff8d05..7ff619e68667b 100644 --- a/include/lldb/API/SBData.h +++ b/include/lldb/API/SBData.h @@ -71,11 +71,10 @@ public: lldb::addr_t base_addr = LLDB_INVALID_ADDRESS); // it would be nice to have SetData(SBError, const void*, size_t) when - // endianness and address size can be - // inferred from the existing DataExtractor, but having two SetData() - // signatures triggers a SWIG bug where - // the typemap isn't applied before resolving the overload, and thus the right - // function never gets called + // endianness and address size can be inferred from the existing + // DataExtractor, but having two SetData() signatures triggers a SWIG bug + // where the typemap isn't applied before resolving the overload, and thus + // the right function never gets called void SetData(lldb::SBError &error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size); @@ -87,9 +86,8 @@ public: const char *data); // in the following CreateData*() and SetData*() prototypes, the two - // parameters array and array_len - // should not be renamed or rearranged, because doing so will break the SWIG - // typemap + // parameters array and array_len should not be renamed or rearranged, + // because doing so will break the SWIG typemap static lldb::SBData CreateDataFromUInt64Array(lldb::ByteOrder endian, uint32_t addr_byte_size, uint64_t *array, diff --git a/include/lldb/API/SBDebugger.h b/include/lldb/API/SBDebugger.h index 8379a6911afc9..a416b460f3186 100644 --- a/include/lldb/API/SBDebugger.h +++ b/include/lldb/API/SBDebugger.h @@ -181,6 +181,8 @@ public: static const char *StateAsCString(lldb::StateType state); + static SBStructuredData GetBuildConfiguration(); + static bool StateIsRunningState(lldb::StateType state); static bool StateIsStoppedState(lldb::StateType state); diff --git a/include/lldb/API/SBExpressionOptions.h b/include/lldb/API/SBExpressionOptions.h index 370811d0c3557..1459ba6fee2aa 100644 --- a/include/lldb/API/SBExpressionOptions.h +++ b/include/lldb/API/SBExpressionOptions.h @@ -51,10 +51,8 @@ public: uint32_t GetOneThreadTimeoutInMicroSeconds() const; // Set the timeout for running on one thread, 0 means use the default - // behavior. - // If you set this higher than the overall timeout, you'll get an error when - // you - // try to run the expression. + // behavior. If you set this higher than the overall timeout, you'll get an + // error when you try to run the expression. void SetOneThreadTimeoutInMicroSeconds(uint32_t timeout = 0); bool GetTryAllThreads() const; diff --git a/include/lldb/API/SBFrame.h b/include/lldb/API/SBFrame.h index 58339750def65..b8953dd132368 100644 --- a/include/lldb/API/SBFrame.h +++ b/include/lldb/API/SBFrame.h @@ -153,10 +153,10 @@ public: lldb::DynamicValueType use_dynamic); // Find a value for a variable expression path like "rect.origin.x" or - // "pt_ptr->x", "*self", "*this->obj_ptr". The returned value is _not_ - // and expression result and is not a constant object like - // SBFrame::EvaluateExpression(...) returns, but a child object of - // the variable value. + // "pt_ptr->x", "*self", "*this->obj_ptr". The returned value is _not_ and + // expression result and is not a constant object like + // SBFrame::EvaluateExpression(...) returns, but a child object of the + // variable value. lldb::SBValue GetValueForVariablePath(const char *var_expr_cstr, DynamicValueType use_dynamic); diff --git a/include/lldb/API/SBInstruction.h b/include/lldb/API/SBInstruction.h index 23daf1c566377..5ef02b8f696ad 100644 --- a/include/lldb/API/SBInstruction.h +++ b/include/lldb/API/SBInstruction.h @@ -16,8 +16,7 @@ #include <stdio.h> // There's a lot to be fixed here, but need to wait for underlying insn -// implementation -// to be revised & settle down first. +// implementation to be revised & settle down first. class InstructionImpl; @@ -37,8 +36,6 @@ public: SBAddress GetAddress(); - lldb::AddressClass GetAddressClass(); - const char *GetMnemonic(lldb::SBTarget target); const char *GetOperands(lldb::SBTarget target); diff --git a/include/lldb/API/SBInstructionList.h b/include/lldb/API/SBInstructionList.h index 0323a3c80c05d..c8fed5c83192b 100644 --- a/include/lldb/API/SBInstructionList.h +++ b/include/lldb/API/SBInstructionList.h @@ -33,8 +33,8 @@ public: lldb::SBInstruction GetInstructionAtIndex(uint32_t idx); // ---------------------------------------------------------------------- - // Returns the number of instructions between the start and end address. - // If canSetBreakpoint is true then the count will be the number of + // Returns the number of instructions between the start and end address. If + // canSetBreakpoint is true then the count will be the number of // instructions on which a breakpoint can be set. // ---------------------------------------------------------------------- size_t GetInstructionsCount(const SBAddress &start, diff --git a/include/lldb/API/SBLaunchInfo.h b/include/lldb/API/SBLaunchInfo.h index 1cece235127f2..80eea7e429212 100644 --- a/include/lldb/API/SBLaunchInfo.h +++ b/include/lldb/API/SBLaunchInfo.h @@ -12,6 +12,10 @@ #include "lldb/API/SBDefines.h" +namespace lldb_private { +class SBLaunchInfoImpl; +} + namespace lldb { class SBPlatform; @@ -141,11 +145,10 @@ protected: friend class SBPlatform; friend class SBTarget; - lldb_private::ProcessLaunchInfo &ref(); - const lldb_private::ProcessLaunchInfo &ref() const; + void set_ref(const lldb_private::ProcessLaunchInfo &info); - ProcessLaunchInfoSP m_opaque_sp; + std::shared_ptr<lldb_private::SBLaunchInfoImpl> m_opaque_sp; }; } // namespace lldb diff --git a/include/lldb/API/SBModule.h b/include/lldb/API/SBModule.h index bcc3997a275b8..d73267f8af507 100644 --- a/include/lldb/API/SBModule.h +++ b/include/lldb/API/SBModule.h @@ -129,6 +129,21 @@ public: lldb::SBCompileUnit GetCompileUnitAtIndex(uint32_t); + //------------------------------------------------------------------ + /// Find compile units related to *this module and passed source + /// file. + /// + /// @param[in] sb_file_spec + /// A lldb::SBFileSpec object that contains source file + /// specification. + /// + /// @return + /// A lldb::SBSymbolContextList that gets filled in with all of + /// the symbol contexts for all the matches. + //------------------------------------------------------------------ + lldb::SBSymbolContextList + FindCompileUnits(const lldb::SBFileSpec &sb_file_spec); + size_t GetNumSymbols(); lldb::SBSymbol GetSymbolAtIndex(size_t idx); diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h index 2e8925941fb74..4ad24f63f0762 100644 --- a/include/lldb/API/SBProcess.h +++ b/include/lldb/API/SBProcess.h @@ -98,10 +98,10 @@ public: lldb::SBThread GetSelectedThread() const; //------------------------------------------------------------------ - // Function for lazily creating a thread using the current OS - // plug-in. This function will be removed in the future when there - // are APIs to create SBThread objects through the interface and add - // them to the process through the SBProcess API. + // Function for lazily creating a thread using the current OS plug-in. This + // function will be removed in the future when there are APIs to create + // SBThread objects through the interface and add them to the process through + // the SBProcess API. //------------------------------------------------------------------ lldb::SBThread CreateOSPluginThread(lldb::tid_t tid, lldb::addr_t context); @@ -313,6 +313,40 @@ public: const lldb::SBFileSpec &remote_image_spec, lldb::SBError &error); + //------------------------------------------------------------------ + /// Load a shared library into this process, starting with a + /// library name and a list of paths, searching along the list of + /// paths till you find a matching library. + /// + /// @param[in] local_spec + /// The name of the shared library that you want to load. + /// If local_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. + /// + /// @param[in] paths + /// A list of paths to search for the library whose basename is + /// local_spec. + /// + /// @param[out] loaded_path + /// If the library was found along the paths, this will store the + /// full path to the found library. + /// + /// @param[out] error + /// An error object that gets filled in with any errors that + /// might occur when trying to search for the shared library. + /// + /// @return + /// A token that represents the shared library that can be + /// later passed to UnloadImage. A value of + /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared + /// library can't be opened. + //------------------------------------------------------------------ + uint32_t LoadImageUsingPaths(const lldb::SBFileSpec &image_spec, + SBStringList &paths, + lldb::SBFileSpec &loaded_path, + lldb::SBError &error); + lldb::SBError UnloadImage(uint32_t image_token); lldb::SBError SendEventData(const char *data); diff --git a/include/lldb/API/SBStream.h b/include/lldb/API/SBStream.h index a75afc7ee375a..7364ca7797f89 100644 --- a/include/lldb/API/SBStream.h +++ b/include/lldb/API/SBStream.h @@ -26,13 +26,12 @@ public: bool IsValid() const; - // If this stream is not redirected to a file, it will maintain a local - // cache for the stream data which can be accessed using this accessor. + // If this stream is not redirected to a file, it will maintain a local cache + // for the stream data which can be accessed using this accessor. const char *GetData(); - // If this stream is not redirected to a file, it will maintain a local - // cache for the stream output whose length can be accessed using this - // accessor. + // If this stream is not redirected to a file, it will maintain a local cache + // for the stream output whose length can be accessed using this accessor. size_t GetSize(); void Printf(const char *format, ...) __attribute__((format(printf, 2, 3))); @@ -44,8 +43,8 @@ public: void RedirectToFileDescriptor(int fd, bool transfer_fh_ownership); // If the stream is redirected to a file, forget about the file and if - // ownership of the file was transferred to this object, close the file. - // If the stream is backed by a local cache, clear this cache. + // ownership of the file was transferred to this object, close the file. If + // the stream is backed by a local cache, clear this cache. void Clear(); protected: diff --git a/include/lldb/API/SBStructuredData.h b/include/lldb/API/SBStructuredData.h index f3baaf7c48013..ca8229a574dfc 100644 --- a/include/lldb/API/SBStructuredData.h +++ b/include/lldb/API/SBStructuredData.h @@ -99,6 +99,7 @@ public: protected: friend class SBTraceOptions; friend class SBDebugger; + friend class SBTarget; StructuredDataImplUP m_impl_up; }; diff --git a/include/lldb/API/SBSymbol.h b/include/lldb/API/SBSymbol.h index d17a4ccffe02e..a29ac61d2912b 100644 --- a/include/lldb/API/SBSymbol.h +++ b/include/lldb/API/SBSymbol.h @@ -55,8 +55,8 @@ public: bool GetDescription(lldb::SBStream &description); //---------------------------------------------------------------------- - // Returns true if the symbol is externally visible in the module that - // it is defined in + // Returns true if the symbol is externally visible in the module that it is + // defined in //---------------------------------------------------------------------- bool IsExternal(); diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h index 4085a16b43fbc..8d99545902fe2 100644 --- a/include/lldb/API/SBTarget.h +++ b/include/lldb/API/SBTarget.h @@ -75,6 +75,8 @@ public: lldb::SBProcess GetProcess(); + lldb::SBStructuredData GetStatistics(); + //------------------------------------------------------------------ /// Return the platform object associated with the target. /// @@ -163,6 +165,7 @@ public: bool stop_at_entry, lldb::SBError &error); SBProcess LoadCore(const char *core_file); + SBProcess LoadCore(const char *core_file, lldb::SBError &error); //------------------------------------------------------------------ /// Launch a new process with sensible defaults. @@ -289,6 +292,21 @@ public: lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec); + //------------------------------------------------------------------ + /// Find compile units related to *this target and passed source + /// file. + /// + /// @param[in] sb_file_spec + /// A lldb::SBFileSpec object that contains source file + /// specification. + /// + /// @return + /// A lldb::SBSymbolContextList that gets filled in with all of + /// the symbol contexts for all the matches. + //------------------------------------------------------------------ + lldb::SBSymbolContextList + FindCompileUnits(const lldb::SBFileSpec &sb_file_spec); + lldb::ByteOrder GetByteOrder(); uint32_t GetAddressByteSize(); @@ -716,9 +734,9 @@ public: // Finds all breakpoints by name, returning the list in bkpt_list. Returns // false if the name is not a valid breakpoint name, true otherwise. bool FindBreakpointsByName(const char *name, SBBreakpointList &bkpt_list); - + void GetBreakpointNames(SBStringList &names); - + void DeleteBreakpointName(const char *name); bool EnableAllBreakpoints(); @@ -773,8 +791,7 @@ public: const void *buf, size_t size); // The "WithFlavor" is necessary to keep SWIG from getting confused about - // overloaded arguments when - // using the buf + size -> Python Object magic. + // overloaded arguments when using the buf + size -> Python Object magic. lldb::SBInstructionList GetInstructionsWithFlavor(lldb::SBAddress base_addr, const char *flavor_string, @@ -827,8 +844,8 @@ protected: friend class SBValue; //------------------------------------------------------------------ - // Constructors are private, use static Target::Create function to - // create an instance of this class. + // Constructors are private, use static Target::Create function to create an + // instance of this class. //------------------------------------------------------------------ lldb::TargetSP GetSP() const; diff --git a/include/lldb/API/SBThread.h b/include/lldb/API/SBThread.h index 7f1cf10cc456b..afc05d2c61ade 100644 --- a/include/lldb/API/SBThread.h +++ b/include/lldb/API/SBThread.h @@ -93,6 +93,8 @@ public: void StepOver(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); + void StepOver(lldb::RunMode stop_other_threads, SBError &error); + void StepInto(lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); void StepInto(const char *target_name, @@ -103,10 +105,16 @@ public: void StepOut(); - void StepOutOfFrame(lldb::SBFrame &frame); + void StepOut(SBError &error); + + void StepOutOfFrame(SBFrame &frame); + + void StepOutOfFrame(SBFrame &frame, SBError &error); void StepInstruction(bool step_over); + void StepInstruction(bool step_over, SBError &error); + SBError StepOverUntil(lldb::SBFrame &frame, lldb::SBFileSpec &file_spec, uint32_t line); @@ -119,6 +127,8 @@ public: void RunToAddress(lldb::addr_t addr); + void RunToAddress(lldb::addr_t addr, SBError &error); + SBError ReturnFromFrame(SBFrame &frame, SBValue &return_value); SBError UnwindInnermostExpression(); @@ -146,8 +156,12 @@ public: //-------------------------------------------------------------------------- bool Suspend(); + bool Suspend(SBError &error); + bool Resume(); + bool Resume(SBError &error); + bool IsSuspended(); bool IsStopped(); diff --git a/include/lldb/API/SBValue.h b/include/lldb/API/SBValue.h index 5ef8915b58f9a..ab5bdfea993dd 100644 --- a/include/lldb/API/SBValue.h +++ b/include/lldb/API/SBValue.h @@ -134,8 +134,7 @@ public: lldb::SBType type); // this has no address! GetAddress() and GetLoadAddress() as well as - // AddressOf() - // on the return of this call all return invalid + // AddressOf() on the return of this call all return invalid lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data, lldb::SBType type); diff --git a/include/lldb/API/SBValueList.h b/include/lldb/API/SBValueList.h index 495b0140cad0d..0242dd7f71a27 100644 --- a/include/lldb/API/SBValueList.h +++ b/include/lldb/API/SBValueList.h @@ -43,8 +43,8 @@ public: const lldb::SBValueList &operator=(const lldb::SBValueList &rhs); protected: - // only useful for visualizing the pointer or comparing two SBValueLists - // to see if they are backed by the same underlying Impl. + // only useful for visualizing the pointer or comparing two SBValueLists to + // see if they are backed by the same underlying Impl. void *opaque_ptr(); private: diff --git a/include/lldb/API/SystemInitializerFull.h b/include/lldb/API/SystemInitializerFull.h deleted file mode 100644 index 9cfc6896da61e..0000000000000 --- a/include/lldb/API/SystemInitializerFull.h +++ /dev/null @@ -1,38 +0,0 @@ -//===-- SystemInitializerFull.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_API_SYSTEM_INITIALIZER_FULL_H -#define LLDB_API_SYSTEM_INITIALIZER_FULL_H - -#include "lldb/Initialization/SystemInitializerCommon.h" - -namespace lldb_private { -//------------------------------------------------------------------ -/// Initializes lldb. -/// -/// This class is responsible for initializing all of lldb system -/// services needed to use the full LLDB application. This class is -/// not intended to be used externally, but is instead used -/// internally by SBDebugger to initialize the system. -//------------------------------------------------------------------ -class SystemInitializerFull : public SystemInitializerCommon { -public: - SystemInitializerFull(); - ~SystemInitializerFull() override; - - void Initialize() override; - void Terminate() override; - -private: - void InitializeSWIG(); -}; - -} // namespace lldb_private - -#endif // LLDB_API_SYSTEM_INITIALIZER_FULL_H diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h index 9a798090a59fb..ec4bc946280fb 100644 --- a/include/lldb/Breakpoint/Breakpoint.h +++ b/include/lldb/Breakpoint/Breakpoint.h @@ -33,8 +33,8 @@ namespace lldb_private { //---------------------------------------------------------------------- -/// @class Breakpoint Breakpoint.h "lldb/Breakpoint/Breakpoint.h" -/// @brief Class that manages logical breakpoint setting. +/// @class Breakpoint Breakpoint.h "lldb/Breakpoint/Breakpoint.h" Class that +/// manages logical breakpoint setting. //---------------------------------------------------------------------- //---------------------------------------------------------------------- @@ -42,33 +42,28 @@ namespace lldb_private { /// A breakpoint has four main parts, a filter, a resolver, the list of /// breakpoint /// locations that have been determined for the filter/resolver pair, and -/// finally -/// a set of options for the breakpoint. +/// finally a set of options for the breakpoint. /// /// \b Filter: -/// This is an object derived from SearchFilter. It manages the search -/// for breakpoint location matches through the symbols in the module list of -/// the target -/// that owns it. It also filters out locations based on whatever logic it -/// wants. +/// This is an object derived from SearchFilter. It manages the search for +/// breakpoint location matches through the symbols in the module list of the +/// target that owns it. It also filters out locations based on whatever +/// logic it wants. /// /// \b Resolver: -/// This is an object derived from BreakpointResolver. It provides a -/// callback to the filter that will find breakpoint locations. How it does -/// this is +/// This is an object derived from BreakpointResolver. It provides a callback +/// to the filter that will find breakpoint locations. How it does this is /// determined by what kind of resolver it is. /// /// The Breakpoint class also provides constructors for the common breakpoint -/// cases -/// which make the appropriate filter and resolver for you. +/// cases which make the appropriate filter and resolver for you. /// /// \b Location List: -/// This stores the breakpoint locations that have been determined -/// to date. For a given breakpoint, there will be only one location with a -/// given -/// address. Adding a location at an already taken address will just return the -/// location -/// already at that address. Locations can be looked up by ID, or by address. +/// This stores the breakpoint locations that have been determined to date. +/// For a given breakpoint, there will be only one location with a given +/// address. Adding a location at an already taken address will just return +/// the location already at that address. Locations can be looked up by ID, +/// or by address. /// /// \b Options: /// This includes: @@ -77,25 +72,17 @@ namespace lldb_private { /// \b Callback /// \b Condition /// Note, these options can be set on the breakpoint, and they can also be set -/// on the -/// individual locations. The options set on the breakpoint take precedence -/// over the -/// options set on the individual location. -/// So for instance disabling the breakpoint will cause NONE of the locations to -/// get hit. -/// But if the breakpoint is enabled, then the location's enabled state will be -/// checked -/// to determine whether to insert that breakpoint location. +/// on the individual locations. The options set on the breakpoint take +/// precedence over the options set on the individual location. So for +/// instance disabling the breakpoint will cause NONE of the locations to get +/// hit. But if the breakpoint is enabled, then the location's enabled state +/// will be checked to determine whether to insert that breakpoint location. /// Similarly, if the breakpoint condition says "stop", we won't check the -/// location's condition. -/// But if the breakpoint condition says "continue", then we will check the -/// location for whether -/// to actually stop or not. -/// One subtle point worth observing here is that you don't actually stop at a -/// Breakpoint, you -/// always stop at one of its locations. So the "should stop" tests are done by -/// the location, -/// not by the breakpoint. +/// location's condition. But if the breakpoint condition says "continue", +/// then we will check the location for whether to actually stop or not. One +/// subtle point worth observing here is that you don't actually stop at a +/// Breakpoint, you always stop at one of its locations. So the "should stop" +/// tests are done by the location, not by the breakpoint. //---------------------------------------------------------------------- class Breakpoint : public std::enable_shared_from_this<Breakpoint>, public Stoppoint { @@ -103,8 +90,8 @@ public: static const ConstString &GetEventIdentifier(); //------------------------------------------------------------------ - /// An enum specifying the match style for breakpoint settings. At - /// present only used for function name style breakpoints. + /// An enum specifying the match style for breakpoint settings. At present + /// only used for function name style breakpoints. //------------------------------------------------------------------ typedef enum { Exact, Regexp, Glob } MatchType; @@ -191,9 +178,9 @@ public: //------------------------------------------------------------------ /// Destructor. /// - /// The destructor is not virtual since there should be no reason to subclass - /// breakpoints. The varieties of breakpoints are specified instead by - /// providing different resolvers & filters. + /// The destructor is not virtual since there should be no reason to + /// subclass breakpoints. The varieties of breakpoints are specified + /// instead by providing different resolvers & filters. //------------------------------------------------------------------ ~Breakpoint() override; @@ -202,8 +189,7 @@ public: //------------------------------------------------------------------ //------------------------------------------------------------------ - /// Tell whether this breakpoint is an "internal" breakpoint. - /// @return + /// Tell whether this breakpoint is an "internal" breakpoint. @return /// Returns \b true if this is an internal breakpoint, \b false otherwise. //------------------------------------------------------------------ bool IsInternal() const; @@ -214,13 +200,13 @@ public: void Dump(Stream *s) override; //------------------------------------------------------------------ - // The next set of methods provide ways to tell the breakpoint to update - // it's location list - usually done when modules appear or disappear. + // The next set of methods provide ways to tell the breakpoint to update it's + // location list - usually done when modules appear or disappear. //------------------------------------------------------------------ //------------------------------------------------------------------ - /// Tell this breakpoint to clear all its breakpoint sites. Done - /// when the process holding the breakpoint sites is destroyed. + /// Tell this breakpoint to clear all its breakpoint sites. Done when the + /// process holding the breakpoint sites is destroyed. //------------------------------------------------------------------ void ClearAllBreakpointSites(); @@ -231,8 +217,8 @@ public: void ResolveBreakpoint(); //------------------------------------------------------------------ - /// Tell this breakpoint to scan a given module list and resolve any - /// new locations that match the breakpoint's specifications. + /// Tell this breakpoint to scan a given module list and resolve any new + /// locations that match the breakpoint's specifications. /// /// @param[in] module_list /// The list of modules to look in for new locations. @@ -245,8 +231,8 @@ public: bool send_event = true); //------------------------------------------------------------------ - /// Tell this breakpoint to scan a given module list and resolve any - /// new locations that match the breakpoint's specifications. + /// Tell this breakpoint to scan a given module list and resolve any new + /// locations that match the breakpoint's specifications. /// /// @param[in] changed_modules /// The list of modules to look in for new locations. @@ -274,9 +260,9 @@ public: bool delete_locations = false); //------------------------------------------------------------------ - /// Tells the breakpoint the old module \a old_module_sp has been - /// replaced by new_module_sp (usually because the underlying file has been - /// rebuilt, and the old version is gone.) + /// Tells the breakpoint the old module \a old_module_sp has been replaced + /// by new_module_sp (usually because the underlying file has been rebuilt, + /// and the old version is gone.) /// /// @param[in] old_module_sp /// The old module that is going away. @@ -287,13 +273,13 @@ public: lldb::ModuleSP new_module_sp); //------------------------------------------------------------------ - // The next set of methods provide access to the breakpoint locations - // for this breakpoint. + // The next set of methods provide access to the breakpoint locations for + // this breakpoint. //------------------------------------------------------------------ //------------------------------------------------------------------ - /// Add a location to the breakpoint's location list. This is only meant - /// to be called by the breakpoint's resolver. FIXME: how do I ensure that? + /// Add a location to the breakpoint's location list. This is only meant to + /// be called by the breakpoint's resolver. FIXME: how do I ensure that? /// /// @param[in] addr /// The Address specifying the new location. @@ -359,12 +345,12 @@ public: /// Removes all invalid breakpoint locations. /// /// Removes all breakpoint locations with architectures that aren't - /// compatible with \a arch. Also remove any breakpoint locations - /// with whose locations have address where the section has been - /// deleted (module and object files no longer exist). + /// compatible with \a arch. Also remove any breakpoint locations with whose + /// locations have address where the section has been deleted (module and + /// object files no longer exist). /// - /// This is typically used after the process calls exec, or anytime - /// the architecture of the target changes. + /// This is typically used after the process calls exec, or anytime the + /// architecture of the target changes. /// /// @param[in] arch /// If valid, check the module in each breakpoint to make sure @@ -403,8 +389,7 @@ public: uint32_t GetIgnoreCount() const; //------------------------------------------------------------------ - /// Return the current hit count for all locations. - /// @return + /// Return the current hit count for all locations. @return /// The current hit count for all locations. //------------------------------------------------------------------ uint32_t GetHitCount() const; @@ -422,7 +407,8 @@ public: bool IsOneShot() const; //------------------------------------------------------------------ - /// If \a auto_continue is \b true, breakpoint will auto-continue when on hit. + /// If \a auto_continue is \b true, breakpoint will auto-continue when on + /// hit. //------------------------------------------------------------------ void SetAutoContinue(bool auto_continue); @@ -508,8 +494,8 @@ public: //------------------------------------------------------------------ //------------------------------------------------------------------ - /// Return the number of breakpoint locations that have resolved to - /// actual breakpoint sites. + /// Return the number of breakpoint locations that have resolved to actual + /// breakpoint sites. /// /// @return /// The number locations resolved breakpoint sites. @@ -541,10 +527,9 @@ public: //------------------------------------------------------------------ /// Set the "kind" description for a breakpoint. If the breakpoint is hit - /// the stop info will show this "kind" description instead of the breakpoint - /// number. Mostly useful for internal breakpoints, where the breakpoint - /// number - /// doesn't have meaning to the user. + /// the stop info will show this "kind" description instead of the + /// breakpoint number. Mostly useful for internal breakpoints, where the + /// breakpoint number doesn't have meaning to the user. /// /// @param[in] kind /// New "kind" description. @@ -574,10 +559,9 @@ public: //------------------------------------------------------------------ /// Find breakpoint locations which match the (filename, line_number) - /// description. - /// The breakpoint location collection is to be filled with the matching - /// locations. - /// It should be initialized with 0 size by the API client. + /// description. The breakpoint location collection is to be filled with the + /// matching locations. It should be initialized with 0 size by the API + /// client. /// /// @return /// True if there is a match @@ -661,13 +645,12 @@ public: /// Set a pre-condition filter that overrides all user provided /// filters/callbacks etc. /// - /// Used to define fancy breakpoints that can do dynamic hit detection without - /// taking up the condition slot - - /// which really belongs to the user anyway... + /// Used to define fancy breakpoints that can do dynamic hit detection + /// without taking up the condition slot - which really belongs to the user + /// anyway... /// - /// The Precondition should not continue the target, it should return true if - /// the condition says to stop and - /// false otherwise. + /// The Precondition should not continue the target, it should return true + /// if the condition says to stop and false otherwise. /// //------------------------------------------------------------------ void SetPrecondition(BreakpointPreconditionSP precondition_sp) { @@ -706,10 +689,9 @@ protected: //------------------------------------------------------------------ /// Constructors and Destructors /// Only the Target can make a breakpoint, and it owns the breakpoint - /// lifespans. - /// The constructor takes a filter and a resolver. Up in Target there are - /// convenience - /// variants that make breakpoints for some common cases. + /// lifespans. The constructor takes a filter and a resolver. Up in Target + /// there are convenience variants that make breakpoints for some common + /// cases. /// /// @param[in] target /// The target in which the breakpoint will be set. @@ -744,10 +726,10 @@ protected: void DecrementIgnoreCount(); // BreakpointLocation::IgnoreCountShouldStop & - // Breakpoint::IgnoreCountShouldStop can only be called once per stop, - // and BreakpointLocation::IgnoreCountShouldStop should be tested first, and - // if it returns false we should - // continue, otherwise we should test Breakpoint::IgnoreCountShouldStop. + // Breakpoint::IgnoreCountShouldStop can only be called once per stop, and + // BreakpointLocation::IgnoreCountShouldStop should be tested first, and if + // it returns false we should continue, otherwise we should test + // Breakpoint::IgnoreCountShouldStop. bool IgnoreCountShouldStop(); @@ -760,8 +742,7 @@ protected: private: // This one should only be used by Target to copy breakpoints from target to - // target - primarily from the dummy - // target to prime new targets. + // target - primarily from the dummy target to prime new targets. Breakpoint(Target &new_target, Breakpoint &bp_to_copy_from); //------------------------------------------------------------------ @@ -782,9 +763,9 @@ private: BreakpointPreconditionSP m_precondition_sp; // The precondition is a // breakpoint-level hit filter // that can be used - // to skip certain breakpoint hits. For instance, exception breakpoints - // use this to limit the stop to certain exception classes, while leaving - // the condition & callback free for user specification. + // to skip certain breakpoint hits. For instance, exception breakpoints use + // this to limit the stop to certain exception classes, while leaving the + // condition & callback free for user specification. std::unique_ptr<BreakpointOptions> m_options_up; // Settable breakpoint options BreakpointLocationList diff --git a/include/lldb/Breakpoint/BreakpointID.h b/include/lldb/Breakpoint/BreakpointID.h index 57411b3163170..bbad45ca2d8b7 100644 --- a/include/lldb/Breakpoint/BreakpointID.h +++ b/include/lldb/Breakpoint/BreakpointID.h @@ -57,7 +57,7 @@ public: //------------------------------------------------------------------ /// Takes an input string containing the description of a breakpoint or - /// breakpoint and location and returns the a BreakpointID filled out with + /// breakpoint and location and returns a BreakpointID filled out with /// the proper id and location. /// /// @param[in] input diff --git a/include/lldb/Breakpoint/BreakpointIDList.h b/include/lldb/Breakpoint/BreakpointIDList.h index 5877b6c551ad2..ec305583e8d9c 100644 --- a/include/lldb/Breakpoint/BreakpointIDList.h +++ b/include/lldb/Breakpoint/BreakpointIDList.h @@ -55,7 +55,7 @@ public: bool FindBreakpointID(const char *bp_id, size_t *position) const; - void InsertStringArray(const char **string_array, size_t array_size, + void InsertStringArray(llvm::ArrayRef<const char *> string_array, CommandReturnObject &result); // Returns a pair consisting of the beginning and end of a breakpoint diff --git a/include/lldb/Breakpoint/BreakpointList.h b/include/lldb/Breakpoint/BreakpointList.h index 9f38f8aa120d5..f4c013d41cc23 100644 --- a/include/lldb/Breakpoint/BreakpointList.h +++ b/include/lldb/Breakpoint/BreakpointList.h @@ -23,7 +23,7 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class BreakpointList BreakpointList.h "lldb/Breakpoint/BreakpointList.h" -/// @brief This class manages a list of breakpoints. +/// This class manages a list of breakpoints. //---------------------------------------------------------------------- //---------------------------------------------------------------------- @@ -91,7 +91,8 @@ public: lldb::BreakpointSP GetBreakpointAtIndex(size_t i); //------------------------------------------------------------------ - /// Returns a shared pointer to the breakpoint with index \a i, const version + /// Returns a shared pointer to the breakpoint with index \a i, const + /// version /// /// @param[in] i /// The breakpoint index to seek for. @@ -138,13 +139,13 @@ public: //------------------------------------------------------------------ /// Removes all invalid breakpoint locations. /// - /// Removes all breakpoint locations in the list with architectures - /// that aren't compatible with \a arch. Also remove any breakpoint - /// locations with whose locations have address where the section - /// has been deleted (module and object files no longer exist). + /// Removes all breakpoint locations in the list with architectures that + /// aren't compatible with \a arch. Also remove any breakpoint locations + /// with whose locations have address where the section has been deleted + /// (module and object files no longer exist). /// - /// This is typically used after the process calls exec, or anytime - /// the architecture of the target changes. + /// This is typically used after the process calls exec, or anytime the + /// architecture of the target changes. /// /// @param[in] arch /// If valid, check the module in each breakpoint to make sure @@ -163,8 +164,8 @@ public: //------------------------------------------------------------------ /// Removes all the breakpoints from this list - first checking the - /// ePermDelete on the breakpoints. This call should be used unless you - /// are shutting down and need to actually clear them all. + /// ePermDelete on the breakpoints. This call should be used unless you are + /// shutting down and need to actually clear them all. //------------------------------------------------------------------ void RemoveAllowed(bool notify); diff --git a/include/lldb/Breakpoint/BreakpointLocation.h b/include/lldb/Breakpoint/BreakpointLocation.h index b68a9ffad04c4..c5911085e61b3 100644 --- a/include/lldb/Breakpoint/BreakpointLocation.h +++ b/include/lldb/Breakpoint/BreakpointLocation.h @@ -27,22 +27,20 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class BreakpointLocation BreakpointLocation.h -/// "lldb/Breakpoint/BreakpointLocation.h" -/// @brief Class that manages one unique (by address) instance of a logical -/// breakpoint. +/// "lldb/Breakpoint/BreakpointLocation.h" Class that manages one unique (by +/// address) instance of a logical breakpoint. //---------------------------------------------------------------------- //---------------------------------------------------------------------- /// General Outline: /// A breakpoint location is defined by the breakpoint that produces it, -/// and the address that resulted in this particular instantiation. -/// Each breakpoint location also may have a breakpoint site if its -/// address has been loaded into the program. -/// Finally it has a settable options object. +/// and the address that resulted in this particular instantiation. Each +/// breakpoint location also may have a breakpoint site if its address has +/// been loaded into the program. Finally it has a settable options object. /// /// FIXME: Should we also store some fingerprint for the location, so -/// we can map one location to the "equivalent location" on rerun? This -/// would be useful if you've set options on the locations. +/// we can map one location to the "equivalent location" on rerun? This would +/// be useful if you've set options on the locations. //---------------------------------------------------------------------- class BreakpointLocation @@ -52,22 +50,19 @@ public: ~BreakpointLocation() override; //------------------------------------------------------------------ - /// Gets the load address for this breakpoint location - /// @return + /// Gets the load address for this breakpoint location @return /// Returns breakpoint location load address, \b /// LLDB_INVALID_ADDRESS if not yet set. //------------------------------------------------------------------ lldb::addr_t GetLoadAddress() const override; //------------------------------------------------------------------ - /// Gets the Address for this breakpoint location - /// @return + /// Gets the Address for this breakpoint location @return /// Returns breakpoint location Address. //------------------------------------------------------------------ Address &GetAddress(); //------------------------------------------------------------------ - /// Gets the Breakpoint that created this breakpoint location - /// @return + /// Gets the Breakpoint that created this breakpoint location @return /// Returns the owning breakpoint. //------------------------------------------------------------------ Breakpoint &GetBreakpoint(); @@ -75,12 +70,11 @@ public: Target &GetTarget(); //------------------------------------------------------------------ - /// Determines whether we should stop due to a hit at this - /// breakpoint location. + /// Determines whether we should stop due to a hit at this breakpoint + /// location. /// - /// Side Effects: This may evaluate the breakpoint condition, and - /// run the callback. So this command may do a considerable amount - /// of work. + /// Side Effects: This may evaluate the breakpoint condition, and run the + /// callback. So this command may do a considerable amount of work. /// /// @return /// \b true if this breakpoint location thinks we should stop, @@ -93,8 +87,7 @@ public: //------------------------------------------------------------------ //------------------------------------------------------------------ - /// If \a enable is \b true, enable the breakpoint, if \b false - /// disable it. + /// If \a enable is \b true, enable the breakpoint, if \b false disable it. //------------------------------------------------------------------ void SetEnabled(bool enabled); @@ -138,8 +131,8 @@ public: //------------------------------------------------------------------ /// Set the callback action invoked when the breakpoint is hit. /// - /// The callback will return a bool indicating whether the target - /// should stop at this breakpoint or not. + /// The callback will return a bool indicating whether the target should + /// stop at this breakpoint or not. /// /// @param[in] callback /// The method that will get called when the breakpoint is hit. @@ -213,8 +206,8 @@ public: bool ResolveBreakpointSite(); //------------------------------------------------------------------ - /// Clear this breakpoint location's breakpoint site - for instance - /// when disabling the breakpoint. + /// Clear this breakpoint location's breakpoint site - for instance when + /// disabling the breakpoint. /// /// @return /// \b true if there was a breakpoint site to be cleared, \b false @@ -223,8 +216,7 @@ public: bool ClearBreakpointSite(); //------------------------------------------------------------------ - /// Return whether this breakpoint location has a breakpoint site. - /// @return + /// Return whether this breakpoint location has a breakpoint site. @return /// \b true if there was a breakpoint site for this breakpoint /// location, \b false otherwise. //------------------------------------------------------------------ @@ -237,8 +229,7 @@ public: //------------------------------------------------------------------ //------------------------------------------------------------------ - /// Print a description of this breakpoint location to the stream - /// \a s. + /// Print a description of this breakpoint location to the stream \a s. /// /// @param[in] s /// The stream to which to print the description. @@ -259,8 +250,8 @@ public: //------------------------------------------------------------------ /// Use this to set location specific breakpoint options. /// - /// It will create a copy of the containing breakpoint's options if - /// that hasn't been done already + /// It will create a copy of the containing breakpoint's options if that + /// hasn't been done already /// /// @return /// A pointer to the breakpoint options. @@ -302,8 +293,7 @@ public: //------------------------------------------------------------------ /// Returns whether we should resolve Indirect functions in setting the - /// breakpoint site - /// for this location. + /// breakpoint site for this location. /// /// @return /// \b true if the breakpoint SITE for this location should be set on the @@ -315,8 +305,7 @@ public: //------------------------------------------------------------------ /// Returns whether the address set in the breakpoint site for this location - /// was found by resolving - /// an indirect symbol. + /// was found by resolving an indirect symbol. /// /// @return /// \b true or \b false as given in the description above. @@ -327,8 +316,7 @@ public: //------------------------------------------------------------------ /// Returns whether the address set in the breakpoint location was re-routed - /// to the target of a - /// re-exported symbol. + /// to the target of a re-exported symbol. /// /// @return /// \b true or \b false as given in the description above. @@ -339,10 +327,8 @@ public: //------------------------------------------------------------------ /// Returns whether the two breakpoint locations might represent "equivalent - /// locations". - /// This is used when modules changed to determine if a Location in the old - /// module might - /// be the "same as" the input location. + /// locations". This is used when modules changed to determine if a Location + /// in the old module might be the "same as" the input location. /// /// @param[in] location /// The location to compare against. @@ -384,8 +370,7 @@ private: //------------------------------------------------------------------ // Constructors and Destructors // - // Only the Breakpoint can make breakpoint locations, and it owns - // them. + // Only the Breakpoint can make breakpoint locations, and it owns them. //------------------------------------------------------------------ //------------------------------------------------------------------ diff --git a/include/lldb/Breakpoint/BreakpointLocationCollection.h b/include/lldb/Breakpoint/BreakpointLocationCollection.h index 4b2d9d4b344d0..579d468647f3e 100644 --- a/include/lldb/Breakpoint/BreakpointLocationCollection.h +++ b/include/lldb/Breakpoint/BreakpointLocationCollection.h @@ -178,8 +178,8 @@ public: protected: //------------------------------------------------------------------ - // Classes that inherit from BreakpointLocationCollection can see - // and modify these + // Classes that inherit from BreakpointLocationCollection can see and modify + // these //------------------------------------------------------------------ private: diff --git a/include/lldb/Breakpoint/BreakpointLocationList.h b/include/lldb/Breakpoint/BreakpointLocationList.h index 46eb2612bbe8e..4e61abb2838e2 100644 --- a/include/lldb/Breakpoint/BreakpointLocationList.h +++ b/include/lldb/Breakpoint/BreakpointLocationList.h @@ -26,21 +26,16 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class BreakpointLocationList BreakpointLocationList.h -/// "lldb/Breakpoint/BreakpointLocationList.h" -/// @brief This class is used by Breakpoint to manage a list of breakpoint -/// locations, -// each breakpoint location in the list -/// has a unique ID, and is unique by Address as well. +/// "lldb/Breakpoint/BreakpointLocationList.h" This class is used by +/// Breakpoint to manage a list of breakpoint locations, each breakpoint +/// location in the list has a unique ID, and is unique by Address as well. //---------------------------------------------------------------------- - class BreakpointLocationList { - // Only Breakpoints can make the location list, or add elements to it. - // This is not just some random collection of locations. Rather, the act of - // adding the location - // to this list sets its ID, and implicitly all the locations have the same - // breakpoint ID as - // well. If you need a generic container for breakpoint locations, use - // BreakpointLocationCollection. + // Only Breakpoints can make the location list, or add elements to it. This + // is not just some random collection of locations. Rather, the act of + // adding the location to this list sets its ID, and implicitly all the + // locations have the same breakpoint ID as well. If you need a generic + // container for breakpoint locations, use BreakpointLocationCollection. friend class Breakpoint; public: @@ -52,8 +47,8 @@ public: void Dump(Stream *s) const; //------------------------------------------------------------------ - /// Returns a shared pointer to the breakpoint location at address - /// \a addr - const version. + /// Returns a shared pointer to the breakpoint location at address \a addr - + /// const version. /// /// @param[in] addr /// The address to look for. @@ -65,8 +60,8 @@ public: const lldb::BreakpointLocationSP FindByAddress(const Address &addr) const; //------------------------------------------------------------------ - /// Returns a shared pointer to the breakpoint location with id - /// \a breakID, const version. + /// Returns a shared pointer to the breakpoint location with id \a breakID, + /// const version. /// /// @param[in] breakID /// The breakpoint location ID to seek for. @@ -78,8 +73,8 @@ public: lldb::BreakpointLocationSP FindByID(lldb::break_id_t breakID) const; //------------------------------------------------------------------ - /// Returns the breakpoint location id to the breakpoint location - /// at address \a addr. + /// Returns the breakpoint location id to the breakpoint location at address + /// \a addr. /// /// @param[in] addr /// The address to match. @@ -90,9 +85,8 @@ public: lldb::break_id_t FindIDByAddress(const Address &addr); //------------------------------------------------------------------ - /// Returns a breakpoint location list of the breakpoint locations - /// in the module \a module. This list is allocated, and owned by - /// the caller. + /// Returns a breakpoint location list of the breakpoint locations in the + /// module \a module. This list is allocated, and owned by the caller. /// /// @param[in] module /// The module to seek in. @@ -108,8 +102,7 @@ public: BreakpointLocationCollection &bp_loc_list); //------------------------------------------------------------------ - /// Returns a shared pointer to the breakpoint location with - /// index \a i. + /// Returns a shared pointer to the breakpoint location with index \a i. /// /// @param[in] i /// The breakpoint location index to seek for. @@ -121,8 +114,8 @@ public: lldb::BreakpointLocationSP GetByIndex(size_t i); //------------------------------------------------------------------ - /// Returns a shared pointer to the breakpoint location with index - /// \a i, const version. + /// Returns a shared pointer to the breakpoint location with index \a i, + /// const version. /// /// @param[in] i /// The breakpoint location index to seek for. @@ -134,20 +127,20 @@ public: const lldb::BreakpointLocationSP GetByIndex(size_t i) const; //------------------------------------------------------------------ - /// Removes all the locations in this list from their breakpoint site - /// owners list. + /// Removes all the locations in this list from their breakpoint site owners + /// list. //------------------------------------------------------------------ void ClearAllBreakpointSites(); //------------------------------------------------------------------ - /// Tells all the breakpoint locations in this list to attempt to - /// resolve any possible breakpoint sites. + /// Tells all the breakpoint locations in this list to attempt to resolve + /// any possible breakpoint sites. //------------------------------------------------------------------ void ResolveAllBreakpointSites(); //------------------------------------------------------------------ - /// Returns the number of breakpoint locations in this list with - /// resolved breakpoints. + /// Returns the number of breakpoint locations in this list with resolved + /// breakpoints. /// /// @result /// Number of qualifying breakpoint locations. @@ -163,8 +156,8 @@ public: uint32_t GetHitCount() const; //------------------------------------------------------------------ - /// Enquires of the breakpoint location in this list with ID \a - /// breakID whether we should stop. + /// Enquires of the breakpoint location in this list with ID \a breakID + /// whether we should stop. /// /// @param[in] context /// This contains the information about this stop. @@ -186,8 +179,8 @@ public: size_t GetSize() const { return m_locations.size(); } //------------------------------------------------------------------ - /// Print a description of the breakpoint locations in this list to - /// the stream \a s. + /// Print a description of the breakpoint locations in this list to the + /// stream \a s. /// /// @param[in] s /// The stream to which to print the description. @@ -204,9 +197,9 @@ protected: //------------------------------------------------------------------ /// This is the standard constructor. /// - /// It creates an empty breakpoint location list. It is protected - /// here because only Breakpoints are allowed to create the - /// breakpoint location list. + /// It creates an empty breakpoint location list. It is protected here + /// because only Breakpoints are allowed to create the breakpoint location + /// list. //------------------------------------------------------------------ BreakpointLocationList(Breakpoint &owner); @@ -235,6 +228,8 @@ protected: lldb::BreakpointLocationSP from_location_sp); bool RemoveLocation(const lldb::BreakpointLocationSP &bp_loc_sp); + + void RemoveLocationByIndex(size_t idx); void RemoveInvalidLocations(const ArchSpec &arch); diff --git a/include/lldb/Breakpoint/BreakpointName.h b/include/lldb/Breakpoint/BreakpointName.h index 1cfa141011a0b..292a0de4f48b4 100644 --- a/include/lldb/Breakpoint/BreakpointName.h +++ b/include/lldb/Breakpoint/BreakpointName.h @@ -80,8 +80,8 @@ public: *this = Permissions(); } - // Merge the permissions from incoming into this set of permissions. - // Only merge set permissions, and most restrictive permission wins. + // Merge the permissions from incoming into this set of permissions. Only + // merge set permissions, and most restrictive permission wins. void MergeInto(const Permissions &incoming) { MergePermission(incoming, listPerm); diff --git a/include/lldb/Breakpoint/BreakpointOptions.h b/include/lldb/Breakpoint/BreakpointOptions.h index 0229d52df4710..84821817f9800 100644 --- a/include/lldb/Breakpoint/BreakpointOptions.h +++ b/include/lldb/Breakpoint/BreakpointOptions.h @@ -27,9 +27,8 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class BreakpointOptions BreakpointOptions.h -/// "lldb/Breakpoint/BreakpointOptions.h" -/// @brief Class that manages the options on a breakpoint or breakpoint -/// location. +/// "lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a +/// breakpoint or breakpoint location. //---------------------------------------------------------------------- class BreakpointOptions { @@ -106,9 +105,8 @@ public: //------------------------------------------------------------------ //------------------------------------------------------------------ - /// This constructor allows you to specify all the breakpoint options - /// except the callback. That one is more complicated, and better - /// to do by hand. + /// This constructor allows you to specify all the breakpoint options except + /// the callback. That one is more complicated, and better to do by hand. /// /// @param[in] condition /// The expression which if it evaluates to \b true if we are to stop @@ -125,8 +123,8 @@ public: bool auto_continue = false); //------------------------------------------------------------------ - /// Breakpoints make options with all flags set. Locations and Names make options - /// with no flags set. + /// Breakpoints make options with all flags set. Locations and Names make + /// options with no flags set. //------------------------------------------------------------------ BreakpointOptions(bool all_flags_set); BreakpointOptions(const BreakpointOptions &rhs); @@ -156,18 +154,16 @@ public: // Callbacks // // Breakpoint callbacks come in two forms, synchronous and asynchronous. - // Synchronous callbacks will get - // run before any of the thread plans are consulted, and if they return false - // the target will continue - // "under the radar" of the thread plans. There are a couple of restrictions - // to synchronous callbacks: - // 1) They should NOT resume the target themselves. Just return false if you - // want the target to restart. - // 2) Breakpoints with synchronous callbacks can't have conditions (or rather, - // they can have them, but they - // won't do anything. Ditto with ignore counts, etc... You are supposed - // to control that all through the - // callback. + // Synchronous callbacks will get run before any of the thread plans are + // consulted, and if they return false the target will continue "under the + // radar" of the thread plans. There are a couple of restrictions to + // synchronous callbacks: + // 1) They should NOT resume the target themselves. + // Just return false if you want the target to restart. + // 2) Breakpoints with synchronous callbacks can't have conditions + // (or rather, they can have them, but they won't do anything. + // Ditto with ignore counts, etc... You are supposed to control that all + // through the callback. // Asynchronous callbacks get run as part of the "ShouldStop" logic in the // thread plan. The logic there is: // a) If the breakpoint is thread specific and not for this thread, continue @@ -181,12 +177,10 @@ public: // b) If the ignore count says we shouldn't stop, then ditto. // c) If the condition says we shouldn't stop, then ditto. // d) Otherwise, the callback will get run, and if it returns true we will - // stop, and if false we won't. + // stop, and if false we won't. // The asynchronous callback can run the target itself, but at present that - // should be the last action the - // callback does. We will relax this condition at some point, but it will - // take a bit of plumbing to get - // that to work. + // should be the last action the callback does. We will relax this condition + // at some point, but it will take a bit of plumbing to get that to work. // //------------------------------------------------------------------ @@ -227,8 +221,8 @@ public: //------------------------------------------------------------------ void ClearCallback(); - // The rest of these functions are meant to be used only within the breakpoint - // handling mechanism. + // The rest of these functions are meant to be used only within the + // breakpoint handling mechanism. //------------------------------------------------------------------ /// Use this function to invoke the callback for a specific stop. @@ -367,8 +361,7 @@ public: //------------------------------------------------------------------ /// Return the current thread spec for this option. This will return nullptr - /// if the no thread - /// specifications have been set for this Option yet. + /// if the no thread specifications have been set for this Option yet. /// @return /// The thread specification pointer for this option, or nullptr if none /// has @@ -377,8 +370,8 @@ public: const ThreadSpec *GetThreadSpecNoCreate() const; //------------------------------------------------------------------ - /// Returns a pointer to the ThreadSpec for this option, creating it. - /// if it hasn't been created already. This API is used for setting the + /// Returns a pointer to the ThreadSpec for this option, creating it. if it + /// hasn't been created already. This API is used for setting the /// ThreadSpec items for this option. //------------------------------------------------------------------ ThreadSpec *GetThreadSpec(); @@ -400,8 +393,8 @@ public: lldb::user_id_t break_loc_id); //------------------------------------------------------------------ - /// Set a callback based on BreakpointOptions::CommandData. - /// @param[in] cmd_data + /// Set a callback based on BreakpointOptions::CommandData. @param[in] + /// cmd_data /// A UP holding the new'ed CommandData object. /// The breakpoint will take ownership of pointer held by this object. //------------------------------------------------------------------ diff --git a/include/lldb/Breakpoint/BreakpointResolver.h b/include/lldb/Breakpoint/BreakpointResolver.h index 7bcd889ce78b0..944741308da6a 100644 --- a/include/lldb/Breakpoint/BreakpointResolver.h +++ b/include/lldb/Breakpoint/BreakpointResolver.h @@ -26,24 +26,19 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class BreakpointResolver BreakpointResolver.h -/// "lldb/Breakpoint/BreakpointResolver.h" -/// @brief This class works with SearchFilter to resolve logical breakpoints to -/// their -/// of concrete breakpoint locations. +/// "lldb/Breakpoint/BreakpointResolver.h" This class works with SearchFilter +/// to resolve logical breakpoints to their of concrete breakpoint locations. //---------------------------------------------------------------------- //---------------------------------------------------------------------- /// General Outline: -/// The BreakpointResolver is a Searcher. In that protocol, -/// the SearchFilter asks the question "At what depth of the symbol context -/// descent do you want your callback to get called?" of the filter. The -/// resolver -/// answers this question (in the GetDepth method) and provides the resolution -/// callback. +/// The BreakpointResolver is a Searcher. In that protocol, the SearchFilter +/// asks the question "At what depth of the symbol context descent do you want +/// your callback to get called?" of the filter. The resolver answers this +/// question (in the GetDepth method) and provides the resolution callback. /// Each Breakpoint has a BreakpointResolver, and it calls either -/// ResolveBreakpoint -/// or ResolveBreakpointInModules to tell it to look for new breakpoint -/// locations. +/// ResolveBreakpoint or ResolveBreakpointInModules to tell it to look for new +/// breakpoint locations. //---------------------------------------------------------------------- class BreakpointResolver : public Searcher { @@ -53,8 +48,7 @@ public: //------------------------------------------------------------------ /// The breakpoint resolver need to have a breakpoint for "ResolveBreakpoint /// to make sense. It can be constructed without a breakpoint, but you have - /// to - /// call SetBreakpoint before ResolveBreakpoint. + /// to call SetBreakpoint before ResolveBreakpoint. /// /// @param[in] bkpt /// The breakpoint that owns this resolver. @@ -82,9 +76,9 @@ public: void SetBreakpoint(Breakpoint *bkpt); //------------------------------------------------------------------ - /// This updates the offset for this breakpoint. All the locations currently - /// set for this breakpoint will have their offset adjusted when this is - /// called. + /// This updates the offset for this breakpoint. All the locations + /// currently set for this breakpoint will have their offset adjusted when + /// this is called. /// /// @param[in] offset /// The offset to add to all locations. @@ -92,9 +86,9 @@ public: void SetOffset(lldb::addr_t offset); //------------------------------------------------------------------ - /// This updates the offset for this breakpoint. All the locations currently - /// set for this breakpoint will have their offset adjusted when this is - /// called. + /// This updates the offset for this breakpoint. All the locations + /// currently set for this breakpoint will have their offset adjusted when + /// this is called. /// /// @param[in] offset /// The offset to add to all locations. @@ -103,8 +97,7 @@ public: //------------------------------------------------------------------ /// In response to this method the resolver scans all the modules in the - /// breakpoint's - /// target, and adds any new locations it finds. + /// breakpoint's target, and adds any new locations it finds. /// /// @param[in] filter /// The filter that will manage the search for this resolver. @@ -113,8 +106,7 @@ public: //------------------------------------------------------------------ /// In response to this method the resolver scans the modules in the module - /// list - /// \a modules, and adds any new locations it finds. + /// list \a modules, and adds any new locations it finds. /// /// @param[in] filter /// The filter that will manage the search for this resolver. @@ -157,8 +149,8 @@ public: //------------------------------------------------------------------ //------------------------------------------------------------------ - /// An enumeration for keeping track of the concrete subclass that - /// is actually instantiated. Values of this enumeration are kept in the + /// An enumeration for keeping track of the concrete subclass that is + /// actually instantiated. Values of this enumeration are kept in the /// BreakpointResolver's SubclassID field. They are used for concrete type /// identification. enum ResolverTy { @@ -171,8 +163,8 @@ public: UnknownResolver }; - // Translate the Ty to name for serialization, - // the "+2" is one for size vrs. index, and one for UnknownResolver. + // Translate the Ty to name for serialization, the "+2" is one for size vrs. + // index, and one for UnknownResolver. static const char *g_ty_to_name[LastKnownResolverType + 2]; //------------------------------------------------------------------ @@ -199,8 +191,8 @@ public: protected: // Used for serializing resolver options: - // The options in this enum and the strings in the - // g_option_names must be kept in sync. + // The options in this enum and the strings in the g_option_names must be + // kept in sync. enum class OptionNames : uint32_t { AddressOffset = 0, ExactMatch, @@ -227,12 +219,10 @@ public: protected: //------------------------------------------------------------------ - /// SetSCMatchesByLine - Takes a symbol context list of matches which - /// supposedly represent the same file and - /// line number in a CU, and find the nearest actual line number that matches, - /// and then filter down the - /// matching addresses to unique entries, and skip the prologue if asked to do - /// so, and then set + /// Takes a symbol context list of matches which supposedly represent the + /// same file and line number in a CU, and find the nearest actual line + /// number that matches, and then filter down the matching addresses to + /// unique entries, and skip the prologue if asked to do so, and then set /// breakpoint locations in this breakpoint for all the resultant addresses. void SetSCMatchesByLine(SearchFilter &filter, SymbolContextList &sc_list, bool skip_prologue, llvm::StringRef log_ident); diff --git a/include/lldb/Breakpoint/BreakpointResolverAddress.h b/include/lldb/Breakpoint/BreakpointResolverAddress.h index 9d757c8853b9e..5845fe7cabed5 100644 --- a/include/lldb/Breakpoint/BreakpointResolverAddress.h +++ b/include/lldb/Breakpoint/BreakpointResolverAddress.h @@ -21,10 +21,9 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class BreakpointResolverAddress BreakpointResolverAddress.h -/// "lldb/Breakpoint/BreakpointResolverAddress.h" -/// @brief This class sets breakpoints on a given Address. This breakpoint only -/// takes -/// once, and then it won't attempt to reset itself. +/// "lldb/Breakpoint/BreakpointResolverAddress.h" This class sets breakpoints +/// on a given Address. This breakpoint only takes once, and then it won't +/// attempt to reset itself. //---------------------------------------------------------------------- class BreakpointResolverAddress : public BreakpointResolver { @@ -74,8 +73,7 @@ protected: FileSpec m_module_filespec; // If this filespec is Valid, and m_addr is an // offset, then it will be converted // to a Section+Offset address in this module, whenever that module gets - // around to - // being loaded. + // around to being loaded. private: DISALLOW_COPY_AND_ASSIGN(BreakpointResolverAddress); }; diff --git a/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/include/lldb/Breakpoint/BreakpointResolverFileLine.h index f7bba3d4ccb45..3464f8ea80d82 100644 --- a/include/lldb/Breakpoint/BreakpointResolverFileLine.h +++ b/include/lldb/Breakpoint/BreakpointResolverFileLine.h @@ -20,10 +20,9 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class BreakpointResolverFileLine BreakpointResolverFileLine.h -/// "lldb/Breakpoint/BreakpointResolverFileLine.h" -/// @brief This class sets breakpoints by file and line. Optionally, it will -/// look for inlined -/// instances of the file and line specification. +/// "lldb/Breakpoint/BreakpointResolverFileLine.h" This class sets breakpoints +/// by file and line. Optionally, it will look for inlined instances of the +/// file and line specification. //---------------------------------------------------------------------- class BreakpointResolverFileLine : public BreakpointResolver { @@ -63,7 +62,7 @@ public: lldb::BreakpointResolverSP CopyForBreakpoint(Breakpoint &breakpoint) override; protected: - void FilterContexts(SymbolContextList &sc_list); + void FilterContexts(SymbolContextList &sc_list, bool is_relative); friend class Breakpoint; FileSpec m_file_spec; // This is the file spec we are looking for. diff --git a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h index d620e99ffc605..c1a7a15566a51 100644 --- a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h +++ b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h @@ -23,9 +23,8 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class BreakpointResolverFileRegex BreakpointResolverFileRegex.h -/// "lldb/Breakpoint/BreakpointResolverFileRegex.h" -/// @brief This class sets breakpoints by file and line. Optionally, it will -/// look for inlined +/// "lldb/Breakpoint/BreakpointResolverFileRegex.h" This class sets +/// breakpoints by file and line. Optionally, it will look for inlined /// instances of the file and line specification. //---------------------------------------------------------------------- diff --git a/include/lldb/Breakpoint/BreakpointResolverName.h b/include/lldb/Breakpoint/BreakpointResolverName.h index c7716d5146efa..794ea67bb721c 100644 --- a/include/lldb/Breakpoint/BreakpointResolverName.h +++ b/include/lldb/Breakpoint/BreakpointResolverName.h @@ -24,10 +24,8 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class BreakpointResolverName BreakpointResolverName.h -/// "lldb/Breakpoint/BreakpointResolverName.h" -/// @brief This class sets breakpoints on a given function name, either by exact -/// match -/// or by regular expression. +/// "lldb/Breakpoint/BreakpointResolverName.h" This class sets breakpoints on +/// a given function name, either by exact match or by regular expression. //---------------------------------------------------------------------- class BreakpointResolverName : public BreakpointResolver { @@ -48,8 +46,8 @@ public: uint32_t 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. + // Creates a function breakpoint by regular expression. Takes over control + // of the lifespan of func_regex. BreakpointResolverName(Breakpoint *bkpt, RegularExpression &func_regex, lldb::LanguageType language, lldb::addr_t offset, bool skip_prologue); diff --git a/include/lldb/Breakpoint/BreakpointSite.h b/include/lldb/Breakpoint/BreakpointSite.h index 6e9875615fd9f..c9bd883ca7384 100644 --- a/include/lldb/Breakpoint/BreakpointSite.h +++ b/include/lldb/Breakpoint/BreakpointSite.h @@ -28,15 +28,15 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class BreakpointSite BreakpointSite.h "lldb/Breakpoint/BreakpointSite.h" -/// @brief Class that manages the actual breakpoint that will be inserted -/// into the running program. +/// Class that manages the actual breakpoint that will be inserted into the +/// running program. /// -/// The BreakpointSite class handles the physical breakpoint that is -/// actually inserted in the target program. As such, it is also the -/// one that gets hit, when the program stops. It keeps a list of all -/// BreakpointLocations that share this physical site. When the -/// breakpoint is hit, all the locations are informed by the breakpoint -/// site. Breakpoint sites are owned by the process. +/// The BreakpointSite class handles the physical breakpoint that is actually +/// inserted in the target program. As such, it is also the one that gets +/// hit, when the program stops. It keeps a list of all BreakpointLocations +/// that share this physical site. When the breakpoint is hit, all the +/// locations are informed by the breakpoint site. Breakpoint sites are owned +/// by the process. //---------------------------------------------------------------------- class BreakpointSite : public std::enable_shared_from_this<BreakpointSite>, @@ -101,10 +101,9 @@ public: /// Tells whether the current breakpoint site is enabled or not /// /// This is a low-level enable bit for the breakpoint sites. If a - /// breakpoint site has no enabled owners, it should just get - /// removed. This enable/disable is for the low-level target code - /// to enable and disable breakpoint sites when single stepping, - /// etc. + /// breakpoint site has no enabled owners, it should just get removed. This + /// enable/disable is for the low-level target code to enable and disable + /// breakpoint sites when single stepping, etc. //------------------------------------------------------------------ bool IsEnabled() const; @@ -118,8 +117,7 @@ public: //------------------------------------------------------------------ /// Enquires of the breakpoint locations that produced this breakpoint site - /// whether - /// we should stop at this location. + /// whether we should stop at this location. /// /// @param[in] context /// This contains the information about this stop. @@ -138,9 +136,8 @@ public: void Dump(Stream *s) const override; //------------------------------------------------------------------ - /// The "Owners" are the breakpoint locations that share this - /// breakpoint site. The method adds the \a owner to this breakpoint - /// site's owner list. + /// The "Owners" are the breakpoint locations that share this breakpoint + /// site. The method adds the \a owner to this breakpoint site's owner list. /// /// @param[in] context /// \a owner is the Breakpoint Location to add. @@ -148,8 +145,8 @@ public: void AddOwner(const lldb::BreakpointLocationSP &owner); //------------------------------------------------------------------ - /// This method returns the number of breakpoint locations currently - /// located at this breakpoint site. + /// This method returns the number of breakpoint locations currently located + /// at this breakpoint site. /// /// @return /// The number of owners. @@ -157,10 +154,10 @@ public: size_t GetNumberOfOwners(); //------------------------------------------------------------------ - /// This method returns the breakpoint location at index \a index - /// located at this breakpoint site. The owners are listed ordinally - /// from 0 to GetNumberOfOwners() - 1 so you can use this method to iterate - /// over the owners + /// This method returns the breakpoint location at index \a index located at + /// this breakpoint site. The owners are listed ordinally from 0 to + /// GetNumberOfOwners() - 1 so you can use this method to iterate over the + /// owners /// /// @param[in] index /// The index in the list of owners for which you wish the owner location. @@ -183,9 +180,9 @@ public: size_t CopyOwnersList(BreakpointLocationCollection &out_collection); //------------------------------------------------------------------ - /// Check whether the owners of this breakpoint site have any - /// thread specifiers, and if yes, is \a thread contained in any - /// of these specifiers. + /// Check whether the owners of this breakpoint site have any thread + /// specifiers, and if yes, is \a thread contained in any of these + /// specifiers. /// /// @param[in] thread /// The thread against which to test. @@ -198,9 +195,9 @@ public: //------------------------------------------------------------------ /// Print a description of this breakpoint site to the stream \a s. - /// GetDescription tells you about the breakpoint site's owners. - /// Use BreakpointSite::Dump(Stream *) to get information about the - /// breakpoint site itself. + /// GetDescription tells you about the breakpoint site's owners. Use + /// BreakpointSite::Dump(Stream *) to get information about the breakpoint + /// site itself. /// /// @param[in] s /// The stream to which to print the description. @@ -226,7 +223,8 @@ public: bool IsBreakpointAtThisSite(lldb::break_id_t bp_id); //------------------------------------------------------------------ - /// Tell whether ALL the breakpoints in the location collection are internal. + /// Tell whether ALL the breakpoints in the location collection are + /// internal. /// /// @result /// \b true if all breakpoint locations are owned by internal breakpoints, @@ -241,15 +239,16 @@ public: private: friend class Process; friend class BreakpointLocation; - // The StopInfoBreakpoint knows when it is processing a hit for a thread for a - // site, so let it be the - // one to manage setting the location hit count once and only once. + // The StopInfoBreakpoint knows when it is processing a hit for a thread for + // a site, so let it be the one to manage setting the location hit count once + // and only once. friend class StopInfoBreakpoint; void BumpHitCounts(); //------------------------------------------------------------------ - /// The method removes the owner at \a break_loc_id from this breakpoint list. + /// The method removes the owner at \a break_loc_id from this breakpoint + /// list. /// /// @param[in] context /// \a break_loc_id is the Breakpoint Location to remove. @@ -264,8 +263,8 @@ private: bool m_enabled; ///< Boolean indicating if this breakpoint site enabled or not. - // Consider adding an optimization where if there is only one - // owner, we don't store a list. The usual case will be only one owner... + // Consider adding an optimization where if there is only one owner, we don't + // store a list. The usual case will be only one owner... BreakpointLocationCollection m_owners; ///< This has the BreakpointLocations ///that share this breakpoint site. std::recursive_mutex diff --git a/include/lldb/Breakpoint/BreakpointSiteList.h b/include/lldb/Breakpoint/BreakpointSiteList.h index 1431fe7996759..d6530c170430b 100644 --- a/include/lldb/Breakpoint/BreakpointSiteList.h +++ b/include/lldb/Breakpoint/BreakpointSiteList.h @@ -24,8 +24,8 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class BreakpointSiteList BreakpointSiteList.h -/// "lldb/Breakpoint/BreakpointSiteList.h" -/// @brief Class that manages lists of BreakpointSite shared pointers. +/// "lldb/Breakpoint/BreakpointSiteList.h" Class that manages lists of +/// BreakpointSite shared pointers. //---------------------------------------------------------------------- class BreakpointSiteList { // At present Process directly accesses the map of BreakpointSites so it can @@ -56,15 +56,13 @@ public: lldb::break_id_t Add(const lldb::BreakpointSiteSP &bp_site_sp); //------------------------------------------------------------------ - /// Standard Dump routine, doesn't do anything at present. - /// @param[in] s + /// Standard Dump routine, doesn't do anything at present. @param[in] s /// Stream into which to dump the description. //------------------------------------------------------------------ void Dump(Stream *s) const; //------------------------------------------------------------------ - /// Returns a shared pointer to the breakpoint site at address - /// \a addr. + /// Returns a shared pointer to the breakpoint site at address \a addr. /// /// @param[in] addr /// The address to look for. @@ -89,8 +87,8 @@ public: lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID); //------------------------------------------------------------------ - /// Returns a shared pointer to the breakpoint site with id \a breakID - const - /// version. + /// Returns a shared pointer to the breakpoint site with id \a breakID - + /// const version. /// /// @param[in] breakID /// The breakpoint site ID to seek for. @@ -103,7 +101,8 @@ public: const lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID) const; //------------------------------------------------------------------ - /// Returns the breakpoint site id to the breakpoint site at address \a addr. + /// Returns the breakpoint site id to the breakpoint site at address \a + /// addr. /// /// @param[in] addr /// The address to match. @@ -161,8 +160,8 @@ public: void *baton); //------------------------------------------------------------------ - /// Enquires of the breakpoint site on in this list with ID \a breakID whether - /// we should stop for the breakpoint or not. + /// Enquires of the breakpoint site on in this list with ID \a breakID + /// whether we should stop for the breakpoint or not. /// /// @param[in] context /// This contains the information about this stop. diff --git a/include/lldb/Breakpoint/StoppointCallbackContext.h b/include/lldb/Breakpoint/StoppointCallbackContext.h index 2680584845d7b..1dac342d33255 100644 --- a/include/lldb/Breakpoint/StoppointCallbackContext.h +++ b/include/lldb/Breakpoint/StoppointCallbackContext.h @@ -17,18 +17,15 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class StoppointCallbackContext StoppointCallbackContext.h -/// "lldb/Breakpoint/StoppointCallbackContext.h" -/// @brief Class holds the information that a breakpoint callback needs to -/// evaluate this stop. +/// "lldb/Breakpoint/StoppointCallbackContext.h" Class holds the information +/// that a breakpoint callback needs to evaluate this stop. //---------------------------------------------------------------------- //---------------------------------------------------------------------- /// General Outline: /// When we hit a breakpoint we need to package up whatever information is -/// needed -/// to evaluate breakpoint commands and conditions. This class is the container -/// of -/// that information. +/// needed to evaluate breakpoint commands and conditions. This class is the +/// container of that information. //---------------------------------------------------------------------- class StoppointCallbackContext { diff --git a/include/lldb/Breakpoint/StoppointLocation.h b/include/lldb/Breakpoint/StoppointLocation.h index f64035bbb9416..5c717bbc3b0f2 100644 --- a/include/lldb/Breakpoint/StoppointLocation.h +++ b/include/lldb/Breakpoint/StoppointLocation.h @@ -77,8 +77,8 @@ protected: // breakpoint/watchpoint uint32_t m_byte_size; // The size in bytes of stop location. e.g. the length // of the trap opcode for - // software breakpoints, or the optional length in bytes for - // hardware breakpoints, or the length of the watchpoint. + // software breakpoints, or the optional length in bytes for hardware + // breakpoints, or the length of the watchpoint. uint32_t m_hit_count; // Number of times this breakpoint/watchpoint has been hit diff --git a/include/lldb/Breakpoint/Watchpoint.h b/include/lldb/Breakpoint/Watchpoint.h index 69067a5676211..10df18a5c2663 100644 --- a/include/lldb/Breakpoint/Watchpoint.h +++ b/include/lldb/Breakpoint/Watchpoint.h @@ -71,9 +71,9 @@ public: bool IsEnabled() const; - // This doesn't really enable/disable the watchpoint. - // It is currently just for use in the Process plugin's - // {Enable,Disable}Watchpoint, which should be used instead. + // This doesn't really enable/disable the watchpoint. It is currently just + // for use in the Process plugin's {Enable,Disable}Watchpoint, which should + // be used instead. void SetEnabled(bool enabled, bool notify = true); @@ -197,10 +197,8 @@ private: uint32_t m_disabled_count; // Keep track of the count that the watchpoint is // disabled while in ephemeral mode. // At the end of the ephemeral mode when the watchpoint is to be enabled - // again, - // we check the count, if it is more than 1, it means the user-supplied - // actions - // actually want the watchpoint to be disabled! + // again, we check the count, if it is more than 1, it means the user- + // supplied actions actually want the watchpoint to be disabled! uint32_t m_watch_read : 1, // 1 if we stop when the watched data is read from m_watch_write : 1, // 1 if we stop when the watched data is written to m_watch_was_read : 1, // Set to 1 when watchpoint is hit for a read access diff --git a/include/lldb/Breakpoint/WatchpointList.h b/include/lldb/Breakpoint/WatchpointList.h index 9abac9167b0bc..d5e0da444afb1 100644 --- a/include/lldb/Breakpoint/WatchpointList.h +++ b/include/lldb/Breakpoint/WatchpointList.h @@ -25,15 +25,15 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class WatchpointList WatchpointList.h "lldb/Breakpoint/WatchpointList.h" -/// @brief This class is used by Watchpoint to manage a list of watchpoints, +/// This class is used by Watchpoint to manage a list of watchpoints, // each watchpoint in the list has a unique ID, and is unique by Address as // well. //---------------------------------------------------------------------- class WatchpointList { - // Only Target can make the watchpoint list, or add elements to it. - // This is not just some random collection of watchpoints. Rather, the act of - // adding the watchpoint to this list sets its ID. + // Only Target can make the watchpoint list, or add elements to it. This is + // not just some random collection of watchpoints. Rather, the act of adding + // the watchpoint to this list sets its ID. friend class Watchpoint; friend class Target; @@ -70,9 +70,8 @@ public: void DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const; //------------------------------------------------------------------ - /// Returns a shared pointer to the watchpoint at address - /// \a addr - - /// const version. + /// Returns a shared pointer to the watchpoint at address \a addr - const + /// version. /// /// @param[in] addr /// The address to look for. @@ -84,9 +83,8 @@ public: const lldb::WatchpointSP FindByAddress(lldb::addr_t addr) const; //------------------------------------------------------------------ - /// Returns a shared pointer to the watchpoint with watchpoint spec - /// \a spec - - /// const version. + /// Returns a shared pointer to the watchpoint with watchpoint spec \a spec + /// - const version. /// /// @param[in] spec /// The watchpoint spec to look for. @@ -98,8 +96,7 @@ public: const lldb::WatchpointSP FindBySpec(std::string spec) const; //------------------------------------------------------------------ - /// Returns a shared pointer to the watchpoint with id - /// \a watchID, const + /// Returns a shared pointer to the watchpoint with id \a watchID, const /// version. /// /// @param[in] watchID @@ -112,8 +109,7 @@ public: lldb::WatchpointSP FindByID(lldb::watch_id_t watchID) const; //------------------------------------------------------------------ - /// Returns the watchpoint id to the watchpoint - /// at address \a addr. + /// Returns the watchpoint id to the watchpoint at address \a addr. /// /// @param[in] addr /// The address to match. @@ -124,8 +120,8 @@ public: lldb::watch_id_t FindIDByAddress(lldb::addr_t addr); //------------------------------------------------------------------ - /// Returns the watchpoint id to the watchpoint - /// with watchpoint spec \a spec. + /// Returns the watchpoint id to the watchpoint with watchpoint spec \a + /// spec. /// /// @param[in] spec /// The watchpoint spec to match. diff --git a/include/lldb/Breakpoint/WatchpointOptions.h b/include/lldb/Breakpoint/WatchpointOptions.h index 6ab1264a1c7ff..8cb3b97f3a628 100644 --- a/include/lldb/Breakpoint/WatchpointOptions.h +++ b/include/lldb/Breakpoint/WatchpointOptions.h @@ -25,8 +25,8 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class WatchpointOptions WatchpointOptions.h -/// "lldb/Breakpoint/WatchpointOptions.h" -/// @brief Class that manages the options on a watchpoint. +/// "lldb/Breakpoint/WatchpointOptions.h" Class that manages the options on a +/// watchpoint. //---------------------------------------------------------------------- class WatchpointOptions { @@ -69,15 +69,13 @@ public: // Callbacks // // Watchpoint callbacks come in two forms, synchronous and asynchronous. - // Synchronous callbacks will get - // run before any of the thread plans are consulted, and if they return false - // the target will continue - // "under the radar" of the thread plans. There are a couple of restrictions - // to synchronous callbacks: - // 1) They should NOT resume the target themselves. Just return false if you - // want the target to restart. - // 2) Watchpoints with synchronous callbacks can't have conditions (or rather, - // they can have them, but they + // Synchronous callbacks will get run before any of the thread plans are + // consulted, and if they return false the target will continue "under the + // radar" of the thread plans. There are a couple of restrictions to + // synchronous callbacks: 1) They should NOT resume the target themselves. + // Just return false if you want the target to restart. 2) Watchpoints with + // synchronous callbacks can't have conditions (or rather, they can have + // them, but they // won't do anything. Ditto with ignore counts, etc... You are supposed // to control that all through the // callback. @@ -118,8 +116,8 @@ public: //------------------------------------------------------------------ void ClearCallback(); - // The rest of these functions are meant to be used only within the watchpoint - // handling mechanism. + // The rest of these functions are meant to be used only within the + // watchpoint handling mechanism. //------------------------------------------------------------------ /// Use this function to invoke the callback for a specific stop. @@ -168,8 +166,7 @@ public: //------------------------------------------------------------------ /// Return the current thread spec for this option. This will return nullptr - /// if the no thread - /// specifications have been set for this Option yet. + /// if the no thread specifications have been set for this Option yet. /// @return /// The thread specification pointer for this option, or nullptr if none /// has @@ -178,8 +175,8 @@ public: const ThreadSpec *GetThreadSpecNoCreate() const; //------------------------------------------------------------------ - /// Returns a pointer to the ThreadSpec for this option, creating it. - /// if it hasn't been created already. This API is used for setting the + /// Returns a pointer to the ThreadSpec for this option, creating it. if it + /// hasn't been created already. This API is used for setting the /// ThreadSpec items for this option. //------------------------------------------------------------------ ThreadSpec *GetThreadSpec(); diff --git a/include/lldb/Core/Address.h b/include/lldb/Core/Address.h index 4c77458061d0e..617aaefe91c9e 100644 --- a/include/lldb/Core/Address.h +++ b/include/lldb/Core/Address.h @@ -11,8 +11,8 @@ #define liblldb_Address_h_ #include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS -#include "lldb/lldb-enumerations.h" // for AddressClass::eAddressClassInvalid #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 <stddef.h> // for size_t @@ -53,54 +53,50 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class Address Address.h "lldb/Core/Address.h" -/// @brief A section + offset based address class. +/// A section + offset based address class. /// -/// The Address class allows addresses to be relative to a section -/// that can move during runtime due to images (executables, shared -/// libraries, bundles, frameworks) being loaded at different -/// addresses than the addresses found in the object file that -/// represents them on disk. There are currently two types of addresses -/// for a section: +/// The Address class allows addresses to be relative to a section that can +/// move during runtime due to images (executables, shared libraries, bundles, +/// frameworks) being loaded at different addresses than the addresses found +/// in the object file that represents them on disk. There are currently two +/// types of addresses for a section: /// @li file addresses /// @li load addresses /// -/// File addresses represent the virtual addresses that are in the "on -/// disk" object files. These virtual addresses are converted to be -/// relative to unique sections scoped to the object file so that -/// when/if the addresses slide when the images are loaded/unloaded -/// in memory, we can easily track these changes without having to -/// update every object (compile unit ranges, line tables, function -/// address ranges, lexical block and inlined subroutine address -/// ranges, global and static variables) each time an image is loaded or -/// unloaded. +/// File addresses represent the virtual addresses that are in the "on disk" +/// object files. These virtual addresses are converted to be relative to +/// unique sections scoped to the object file so that when/if the addresses +/// slide when the images are loaded/unloaded in memory, we can easily track +/// these changes without having to update every object (compile unit ranges, +/// line tables, function address ranges, lexical block and inlined subroutine +/// address ranges, global and static variables) each time an image is loaded +/// or unloaded. /// -/// Load addresses represent the virtual addresses where each section -/// ends up getting loaded at runtime. Before executing a program, it -/// is common for all of the load addresses to be unresolved. When a -/// DynamicLoader plug-in receives notification that shared libraries -/// have been loaded/unloaded, the load addresses of the main executable -/// and any images (shared libraries) will be resolved/unresolved. When -/// this happens, breakpoints that are in one of these sections can be -/// set/cleared. +/// Load addresses represent the virtual addresses where each section ends up +/// getting loaded at runtime. Before executing a program, it is common for +/// all of the load addresses to be unresolved. When a DynamicLoader plug-in +/// receives notification that shared libraries have been loaded/unloaded, the +/// load addresses of the main executable and any images (shared libraries) +/// will be resolved/unresolved. When this happens, breakpoints that are in +/// one of these sections can be set/cleared. //---------------------------------------------------------------------- class Address { public: //------------------------------------------------------------------ - /// Dump styles allow the Address::Dump(Stream *,DumpStyle) const - /// function to display Address contents in a variety of ways. + /// Dump styles allow the Address::Dump(Stream *,DumpStyle) const function + /// to display Address contents in a variety of ways. //------------------------------------------------------------------ typedef enum { DumpStyleInvalid, ///< Invalid dump style DumpStyleSectionNameOffset, ///< Display as the section name + offset. ///< \code /// // address for printf in libSystem.B.dylib as a section name + offset - /// libSystem.B.dylib.__TEXT.__text + 0x0005cfdf - /// \endcode + /// libSystem.B.dylib.__TEXT.__text + 0x0005cfdf \endcode DumpStyleSectionPointerOffset, ///< Display as the section pointer + offset ///(debug output). ///< \code - /// // address for printf in libSystem.B.dylib as a section pointer + offset - /// (lldb::Section *)0x35cc50 + 0x000000000005cfdf \endcode + /// // address for printf in libSystem.B.dylib as a section pointer + + /// offset (lldb::Section *)0x35cc50 + 0x000000000005cfdf \endcode DumpStyleFileAddress, ///< Display as the file address (if any). ///< \code /// // address for printf in libSystem.B.dylib as a file address @@ -135,8 +131,8 @@ public: //------------------------------------------------------------------ /// Default constructor. /// - /// Initialize with a invalid section (NULL) and an invalid - /// offset (LLDB_INVALID_ADDRESS). + /// Initialize with a invalid section (NULL) and an invalid offset + /// (LLDB_INVALID_ADDRESS). //------------------------------------------------------------------ Address() : m_section_wp(), m_offset(LLDB_INVALID_ADDRESS) {} @@ -154,8 +150,7 @@ public: //------------------------------------------------------------------ /// Construct with a section pointer and offset. /// - /// Initialize the address with the supplied \a section and \a - /// offset. + /// Initialize the address with the supplied \a section and \a offset. /// /// @param[in] section /// A section pointer to a valid lldb::Section, or NULL if the @@ -175,8 +170,8 @@ public: //------------------------------------------------------------------ /// Construct with a virtual address and section list. /// - /// Initialize and resolve the address with the supplied virtual - /// address \a file_addr. + /// Initialize and resolve the address with the supplied virtual address \a + /// file_addr. /// /// @param[in] file_addr /// A virtual file address. @@ -191,8 +186,8 @@ public: //------------------------------------------------------------------ /// Assignment operator. /// -/// Copies the address value from another Address object \a rhs -/// into \a this object. +/// Copies the address value from another Address object \a rhs into \a this +/// object. /// /// @param[in] rhs /// A const Address object reference to copy. @@ -207,8 +202,8 @@ public: //------------------------------------------------------------------ /// Clear the object's state. /// - /// Sets the section to an invalid value (NULL) and an invalid - /// offset (LLDB_INVALID_ADDRESS). + /// Sets the section to an invalid value (NULL) and an invalid offset + /// (LLDB_INVALID_ADDRESS). //------------------------------------------------------------------ void Clear() { m_section_wp.reset(); @@ -250,9 +245,9 @@ public: //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// - /// Dump a description of the contents of this object to the - /// supplied stream \a s. There are many ways to display a section - /// offset based address, and \a style lets the user choose. + /// Dump a description of the contents of this object to the supplied stream + /// \a s. There are many ways to display a section offset based address, and + /// \a style lets the user choose. /// /// @param[in] s /// The stream to which to dump the object description. @@ -275,14 +270,14 @@ public: DumpStyle fallback_style = DumpStyleInvalid, uint32_t addr_byte_size = UINT32_MAX) const; - lldb::AddressClass GetAddressClass() const; + AddressClass GetAddressClass() const; //------------------------------------------------------------------ /// Get the file address. /// - /// If an address comes from a file on disk that has section - /// relative addresses, then it has a virtual address that is - /// relative to unique section in the object file. + /// If an address comes from a file on disk that has section relative + /// addresses, then it has a virtual address that is relative to unique + /// section in the object file. /// /// @return /// The valid file virtual address, or LLDB_INVALID_ADDRESS if @@ -294,12 +289,12 @@ public: //------------------------------------------------------------------ /// Get the load address. /// - /// If an address comes from a file on disk that has section - /// relative addresses, then it has a virtual address that is - /// relative to unique section in the object file. Sections get - /// resolved at runtime by DynamicLoader plug-ins as images - /// (executables and shared libraries) get loaded/unloaded. If a - /// section is loaded, then the load address can be resolved. + /// If an address comes from a file on disk that has section relative + /// addresses, then it has a virtual address that is relative to unique + /// section in the object file. Sections get resolved at runtime by + /// DynamicLoader plug-ins as images (executables and shared libraries) get + /// loaded/unloaded. If a section is loaded, then the load address can be + /// resolved. /// /// @return /// The valid load virtual address, or LLDB_INVALID_ADDRESS if @@ -310,12 +305,12 @@ public: //------------------------------------------------------------------ /// Get the load address as a callable code load address. /// - /// This function will first resolve its address to a load address. - /// Then, if the address turns out to be in code address, return the - /// load address that would be required to call or return to. The - /// address might have extra bits set (bit zero will be set to Thumb - /// functions for an ARM target) that are required when changing the - /// program counter to setting a return address. + /// This function will first resolve its address to a load address. Then, if + /// the address turns out to be in code address, return the load address + /// that would be required to call or return to. The address might have + /// extra bits set (bit zero will be set to Thumb functions for an ARM + /// target) that are required when changing the program counter to setting a + /// return address. /// /// @return /// The valid load virtual address, or LLDB_INVALID_ADDRESS if @@ -327,14 +322,14 @@ public: //------------------------------------------------------------------ /// Get the load address as an opcode load address. /// - /// This function will first resolve its address to a load address. - /// Then, if the address turns out to be in code address, return the - /// load address for an opcode. This address object might have - /// extra bits set (bit zero will be set to Thumb functions for an + /// This function will first resolve its address to a load address. Then, if + /// the address turns out to be in code address, return the load address for + /// an opcode. This address object might have extra bits set (bit zero will + /// be set to Thumb functions for an /// ARM target) that are required for changing the program counter - /// and this function will remove any bits that are intended for - /// these special purposes. The result of this function can be used - /// to safely write a software breakpoint trap to memory. + /// and this function will remove any bits that are intended for these + /// special purposes. The result of this function can be used to safely + /// write a software breakpoint trap to memory. /// /// @return /// The valid load virtual address with extra callable bits @@ -343,7 +338,7 @@ public: //------------------------------------------------------------------ lldb::addr_t GetOpcodeLoadAddress( Target *target, - lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const; + AddressClass addr_class = AddressClass::eInvalid) const; //------------------------------------------------------------------ /// Get the section relative offset value. @@ -357,11 +352,11 @@ public: //------------------------------------------------------------------ /// Check if an address is section offset. /// - /// When converting a virtual file or load address into a section - /// offset based address, we often need to know if, given a section - /// list, if the address was able to be converted to section offset. - /// This function returns true if the current value contained in - /// this object is section offset based. + /// When converting a virtual file or load address into a section offset + /// based address, we often need to know if, given a section list, if the + /// address was able to be converted to section offset. This function + /// returns true if the current value contained in this object is section + /// offset based. /// /// @return /// Returns \b true if the address has a valid section and @@ -375,8 +370,8 @@ public: /// Check if the object state is valid. /// /// A valid Address object contains either a section pointer and - /// and offset (for section offset based addresses), or just a valid - /// offset (for absolute addresses that have no section). + /// offset (for section offset based addresses), or just a valid offset + /// (for absolute addresses that have no section). /// /// @return /// Returns \b true if the offset is valid, \b false @@ -395,8 +390,8 @@ public: //------------------------------------------------------------------ /// Resolve a file virtual address using a section list. /// - /// Given a list of sections, attempt to resolve \a addr as a - /// an offset into one of the file sections. + /// Given a list of sections, attempt to resolve \a addr as an offset into + /// one of the file sections. /// /// @return /// Returns \b true if \a addr was able to be resolved, \b false @@ -408,11 +403,10 @@ public: //------------------------------------------------------------------ /// Set the address to represent \a load_addr. /// - /// The address will attempt to find a loaded section within - /// \a target that contains \a load_addr. If successful, this - /// address object will have a valid section and offset. Else this - /// address object will have no section (NULL) and the offset will - /// be \a load_addr. + /// The address will attempt to find a loaded section within \a target that + /// contains \a load_addr. If successful, this address object will have a + /// valid section and offset. Else this address object will have no section + /// (NULL) and the offset will be \a load_addr. /// /// @param[in] load_addr /// A load address from a current process. @@ -438,7 +432,7 @@ public: bool SetOpcodeLoadAddress( lldb::addr_t load_addr, Target *target, - lldb::AddressClass addr_class = lldb::eAddressClassInvalid, + AddressClass addr_class = AddressClass::eInvalid, bool allow_section_end = false); bool SetCallableLoadAddress(lldb::addr_t load_addr, Target *target); @@ -507,10 +501,10 @@ public: //------------------------------------------------------------------ /// Reconstruct a symbol context from an address. /// - /// This class doesn't inherit from SymbolContextScope because many - /// address objects have short lifespans. Address objects that are - /// section offset can reconstruct their symbol context by looking - /// up the address in the module found in the section. + /// This class doesn't inherit from SymbolContextScope because many address + /// objects have short lifespans. Address objects that are section offset + /// can reconstruct their symbol context by looking up the address in the + /// module found in the section. /// /// @see SymbolContextScope::CalculateSymbolContext(SymbolContext*) //------------------------------------------------------------------ @@ -531,11 +525,11 @@ public: bool CalculateSymbolContextLineEntry(LineEntry &line_entry) const; //------------------------------------------------------------------ - // Returns true if the section should be valid, but isn't because - // the shared pointer to the section can't be reconstructed from - // a weak pointer that contains a valid weak reference to a section. - // Returns false if the section weak pointer has no reference to - // a section, or if the section is still valid + // Returns true if the section should be valid, but isn't because the shared + // pointer to the section can't be reconstructed from a weak pointer that + // contains a valid weak reference to a section. Returns false if the section + // weak pointer has no reference to a section, or if the section is still + // valid //------------------------------------------------------------------ bool SectionWasDeleted() const; @@ -547,29 +541,27 @@ protected: lldb::addr_t m_offset; ///< Offset into section if \a m_section_wp is valid... //------------------------------------------------------------------ - // Returns true if the m_section_wp once had a reference to a valid - // section shared pointer, but no longer does. This can happen if - // we have an address from a module that gets unloaded and deleted. - // This function should only be called if GetSection() returns an - // empty shared pointer and you want to know if this address used to - // have a valid section. + // Returns true if the m_section_wp once had a reference to a valid section + // shared pointer, but no longer does. This can happen if we have an address + // from a module that gets unloaded and deleted. This function should only be + // called if GetSection() returns an empty shared pointer and you want to + // know if this address used to have a valid section. //------------------------------------------------------------------ bool SectionWasDeletedPrivate() const; }; //---------------------------------------------------------------------- // NOTE: Be careful using this operator. It can correctly compare two -// addresses from the same Module correctly. It can't compare two -// addresses from different modules in any meaningful way, but it will -// compare the module pointers. +// addresses from the same Module correctly. It can't compare two addresses +// from different modules in any meaningful way, but it will compare the module +// pointers. // // To sum things up: -// - works great for addresses within the same module -// - it works for addresses across multiple modules, but don't expect the +// - works great for addresses within the same module - it works for addresses +// across multiple modules, but don't expect the // address results to make much sense // -// This basically lets Address objects be used in ordered collection -// classes. +// This basically lets Address objects be used in ordered collection classes. //---------------------------------------------------------------------- bool operator<(const Address &lhs, const Address &rhs); bool operator>(const Address &lhs, const Address &rhs); diff --git a/include/lldb/Core/AddressRange.h b/include/lldb/Core/AddressRange.h index e787d1d5740d6..9f69c87ee3545 100644 --- a/include/lldb/Core/AddressRange.h +++ b/include/lldb/Core/AddressRange.h @@ -30,23 +30,23 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class AddressRange AddressRange.h "lldb/Core/AddressRange.h" -/// @brief A section + offset based address range class. +/// A section + offset based address range class. //---------------------------------------------------------------------- class AddressRange { public: //------------------------------------------------------------------ /// Default constructor. /// - /// Initialize with a invalid section (NULL), an invalid - /// offset (LLDB_INVALID_ADDRESS), and zero byte size. + /// Initialize with a invalid section (NULL), an invalid offset + /// (LLDB_INVALID_ADDRESS), and zero byte size. //------------------------------------------------------------------ AddressRange(); //------------------------------------------------------------------ /// Construct with a section pointer, offset, and byte_size. /// - /// Initialize the address with the supplied \a section, \a - /// offset and \a byte_size. + /// Initialize the address with the supplied \a section, \a offset and \a + /// byte_size. /// /// @param[in] section /// A section pointer to a valid lldb::Section, or NULL if the @@ -64,8 +64,8 @@ public: //------------------------------------------------------------------ /// Construct with a virtual address, section list and byte size. /// - /// Initialize and resolve the address with the supplied virtual - /// address \a file_addr, and byte size \a byte_size. + /// Initialize and resolve the address with the supplied virtual address \a + /// file_addr, and byte size \a byte_size. /// /// @param[in] file_addr /// A virtual address. @@ -82,8 +82,8 @@ public: //------------------------------------------------------------------ /// Construct with a Address object address and byte size. /// - /// Initialize by copying the section offset address in \a so_addr, - /// and setting the byte size to \a byte_size. + /// Initialize by copying the section offset address in \a so_addr, and + /// setting the byte size to \a byte_size. /// /// @param[in] so_addr /// A section offset address object. @@ -135,8 +135,8 @@ public: // Contains (const Address *so_addr_ptr) const; //------------------------------------------------------------------ - /// Check if a section offset \a so_addr when represented as a file - /// address is contained within this object's file address range. + /// Check if a section offset \a so_addr when represented as a file address + /// is contained within this object's file address range. /// /// @param[in] so_addr /// A section offset address object reference. @@ -149,8 +149,8 @@ public: bool ContainsFileAddress(const Address &so_addr) const; //------------------------------------------------------------------ - /// Check if the resolved file address \a file_addr is contained - /// within this object's file address range. + /// Check if the resolved file address \a file_addr is contained within this + /// object's file address range. /// /// @param[in] so_addr /// A section offset address object reference. @@ -163,8 +163,8 @@ public: bool ContainsFileAddress(lldb::addr_t file_addr) const; //------------------------------------------------------------------ - /// Check if a section offset \a so_addr when represented as a load - /// address is contained within this object's load address range. + /// Check if a section offset \a so_addr when represented as a load address + /// is contained within this object's load address range. /// /// @param[in] so_addr /// A section offset address object reference. @@ -177,8 +177,8 @@ public: bool ContainsLoadAddress(const Address &so_addr, Target *target) const; //------------------------------------------------------------------ - /// Check if the resolved load address \a load_addr is contained - /// within this object's load address range. + /// Check if the resolved load address \a load_addr is contained within this + /// object's load address range. /// /// @param[in] so_addr /// A section offset address object reference. @@ -193,10 +193,10 @@ public: //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// - /// Dump a description of the contents of this object to the - /// supplied stream \a s. There are many ways to display a section - /// offset based address range, and \a style lets the user choose - /// how the base address gets displayed. + /// Dump a description of the contents of this object to the supplied stream + /// \a s. There are many ways to display a section offset based address + /// range, and \a style lets the user choose how the base address gets + /// displayed. /// /// @param[in] s /// The stream to which to dump the object description. @@ -219,11 +219,11 @@ public: //------------------------------------------------------------------ /// Dump a debug description of this object to a Stream. /// - /// Dump a debug description of the contents of this object to the - /// supplied stream \a s. + /// Dump a debug description of the contents of this object to the supplied + /// stream \a s. /// - /// The debug description contains verbose internal state such - /// and pointer values, reference counts, etc. + /// The debug description contains verbose internal state such and pointer + /// values, reference counts, etc. /// /// @param[in] s /// The stream to which to dump the object description. @@ -261,8 +261,8 @@ public: /// The number of bytes that this object occupies in memory. //------------------------------------------------------------------ size_t MemorySize() const { - // Noting special for the memory size of a single AddressRange object, - // it is just the size of itself. + // Noting special for the memory size of a single AddressRange object, it + // is just the size of itself. return sizeof(AddressRange); } diff --git a/include/lldb/Core/AddressResolver.h b/include/lldb/Core/AddressResolver.h index 432268e497b4f..cfd103e0be019 100644 --- a/include/lldb/Core/AddressResolver.h +++ b/include/lldb/Core/AddressResolver.h @@ -27,18 +27,16 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class AddressResolver AddressResolver.h "lldb/Core/AddressResolver.h" -/// @brief This class works with SearchFilter to resolve function names and -/// source file locations to their concrete addresses. +/// This class works with SearchFilter to resolve function names and source +/// file locations to their concrete addresses. //---------------------------------------------------------------------- //---------------------------------------------------------------------- /// General Outline: -/// The AddressResolver is a Searcher. In that protocol, -/// the SearchFilter asks the question "At what depth of the symbol context -/// descent do you want your callback to get called?" of the filter. The -/// resolver -/// answers this question (in the GetDepth method) and provides the resolution -/// callback. +/// The AddressResolver is a Searcher. In that protocol, the SearchFilter +/// asks the question "At what depth of the symbol context descent do you want +/// your callback to get called?" of the filter. The resolver answers this +/// question (in the GetDepth method) and provides the resolution callback. //---------------------------------------------------------------------- class AddressResolver : public Searcher { diff --git a/include/lldb/Core/AddressResolverFileLine.h b/include/lldb/Core/AddressResolverFileLine.h index ec15cc76d8876..e434a62e03191 100644 --- a/include/lldb/Core/AddressResolverFileLine.h +++ b/include/lldb/Core/AddressResolverFileLine.h @@ -31,10 +31,9 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class AddressResolverFileLine AddressResolverFileLine.h -/// "lldb/Core/AddressResolverFileLine.h" -/// @brief This class finds address for source file and line. Optionally, it -/// will look for inlined -/// instances of the file and line specification. +/// "lldb/Core/AddressResolverFileLine.h" This class finds address for source +/// file and line. Optionally, it will look for inlined instances of the file +/// and line specification. //---------------------------------------------------------------------- class AddressResolverFileLine : public AddressResolver { diff --git a/include/lldb/Core/AddressResolverName.h b/include/lldb/Core/AddressResolverName.h index aadc054959998..49a805f2115a1 100644 --- a/include/lldb/Core/AddressResolverName.h +++ b/include/lldb/Core/AddressResolverName.h @@ -30,10 +30,8 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class AddressResolverName AddressResolverName.h -/// "lldb/Core/AddressResolverName.h" -/// @brief This class finds addresses for a given function name, either by exact -/// match -/// or by regular expression. +/// "lldb/Core/AddressResolverName.h" This class finds addresses for a given +/// function name, either by exact match or by regular expression. //---------------------------------------------------------------------- class AddressResolverName : public AddressResolver { @@ -41,8 +39,8 @@ public: AddressResolverName(const char *func_name, AddressResolver::MatchType type = Exact); - // Creates a function breakpoint by regular expression. Takes over control of - // the lifespan of func_regex. + // Creates a function breakpoint by regular expression. Takes over control + // of the lifespan of func_regex. AddressResolverName(RegularExpression &func_regex); AddressResolverName(const char *class_name, const char *method, diff --git a/include/lldb/Core/Architecture.h b/include/lldb/Core/Architecture.h index af774ecdaf9c6..3a5a9789223d1 100644 --- a/include/lldb/Core/Architecture.h +++ b/include/lldb/Core/Architecture.h @@ -31,7 +31,41 @@ public: /// stopped at the current PC. The code is generic and applies to all /// ARM CPUs. //------------------------------------------------------------------ - virtual void OverrideStopInfo(Thread &thread) = 0; + virtual void OverrideStopInfo(Thread &thread) const = 0; + + //------------------------------------------------------------------ + /// This method is used to get the number of bytes that should be + /// skipped, from function start address, to reach the first + /// instruction after the prologue. If overrode, it must return + /// non-zero only if the current address matches one of the known + /// function entry points. + /// + /// This method is called only if the standard platform-independent + /// code fails to get the number of bytes to skip, giving the plugin + /// a chance to try to find the missing info. + /// + /// This is specifically used for PPC64, where functions may have + /// more than one entry point, global and local, so both should + /// be compared with current address, in order to find out the + /// number of bytes that should be skipped, in case we are stopped + /// at either function entry point. + //------------------------------------------------------------------ + virtual size_t GetBytesToSkip(Symbol &func, const Address &curr_addr) const { + return 0; + } + + //------------------------------------------------------------------ + /// Adjust function breakpoint address, if needed. In some cases, + /// the function start address is not the right place to set the + /// breakpoint, specially in functions with multiple entry points. + /// + /// This is specifically used for PPC64, for functions that have + /// both a global and a local entry point. In this case, the + /// breakpoint is adjusted to the first function address reached + /// by both entry points. + //------------------------------------------------------------------ + virtual void AdjustBreakpointAddress(const Symbol &func, + Address &addr) const {} private: Architecture(const Architecture &) = delete; diff --git a/include/lldb/Core/Broadcaster.h b/include/lldb/Core/Broadcaster.h index 825287db5984f..4851007c9a2a7 100644 --- a/include/lldb/Core/Broadcaster.h +++ b/include/lldb/Core/Broadcaster.h @@ -59,10 +59,9 @@ public: uint32_t GetEventBits() const { return m_event_bits; } - // Tell whether this BroadcastEventSpec is contained in in_spec. - // That is: - // (a) the two spec's share the same broadcaster class - // (b) the event bits of this spec are wholly contained in those of in_spec. + // Tell whether this BroadcastEventSpec is contained in in_spec. That is: (a) + // the two spec's share the same broadcaster class (b) the event bits of this + // spec are wholly contained in those of in_spec. bool IsContainedIn(BroadcastEventSpec in_spec) const { if (m_broadcaster_class != in_spec.GetBroadcasterClass()) return false; @@ -224,21 +223,21 @@ private: }; //---------------------------------------------------------------------- -/// @class Broadcaster Broadcaster.h "lldb/Core/Broadcaster.h" -/// @brief An event broadcasting class. +/// @class Broadcaster Broadcaster.h "lldb/Core/Broadcaster.h" An event +/// broadcasting class. /// -/// The Broadcaster class is designed to be subclassed by objects that -/// wish to vend events in a multi-threaded environment. Broadcaster -/// objects can each vend 32 events. Each event is represented by a bit -/// in a 32 bit value and these bits can be set: +/// The Broadcaster class is designed to be subclassed by objects that wish to +/// vend events in a multi-threaded environment. Broadcaster objects can each +/// vend 32 events. Each event is represented by a bit in a 32 bit value and +/// these bits can be set: /// @see Broadcaster::SetEventBits(uint32_t) /// or cleared: /// @see Broadcaster::ResetEventBits(uint32_t) -/// When an event gets set the Broadcaster object will notify the -/// Listener object that is listening for the event (if there is one). +/// When an event gets set the Broadcaster object will notify the Listener +/// object that is listening for the event (if there is one). /// -/// Subclasses should provide broadcast bit definitions for any events -/// they vend, typically using an enumeration: +/// Subclasses should provide broadcast bit definitions for any events they +/// vend, typically using an enumeration: /// \code /// class Foo : public Broadcaster /// { @@ -324,12 +323,11 @@ public: //------------------------------------------------------------------ /// Listen for any events specified by \a event_mask. /// - /// Only one listener can listen to each event bit in a given - /// Broadcaster. Once a listener has acquired an event bit, no - /// other broadcaster will have access to it until it is - /// relinquished by the first listener that gets it. The actual - /// event bits that get acquired by \a listener may be different - /// from what is requested in \a event_mask, and to track this the + /// Only one listener can listen to each event bit in a given Broadcaster. + /// Once a listener has acquired an event bit, no other broadcaster will + /// have access to it until it is relinquished by the first listener that + /// gets it. The actual event bits that get acquired by \a listener may be + /// different from what is requested in \a event_mask, and to track this the /// actual event bits that are acquired get returned. /// /// @param[in] listener @@ -349,8 +347,7 @@ public: } //------------------------------------------------------------------ - /// Get the NULL terminated C string name of this Broadcaster - /// object. + /// Get the NULL terminated C string name of this Broadcaster object. /// /// @return /// The NULL terminated C string name of this Broadcaster. @@ -395,10 +392,10 @@ public: } //------------------------------------------------------------------ - /// Removes a Listener from this broadcasters list and frees the - /// event bits specified by \a event_mask that were previously - /// acquired by \a listener (assuming \a listener was listening to - /// this object) for other listener objects to use. + /// Removes a Listener from this broadcasters list and frees the event bits + /// specified by \a event_mask that were previously acquired by \a listener + /// (assuming \a listener was listening to this object) for other listener + /// objects to use. /// /// @param[in] listener /// A Listener object that previously called AddListener. @@ -420,10 +417,9 @@ public: //------------------------------------------------------------------ /// Provides a simple mechanism to temporarily redirect events from /// broadcaster. When you call this function passing in a listener and - /// event type mask, all events from the broadcaster matching the mask - /// will now go to the hijacking listener. - /// Only one hijack can occur at a time. If we need more than this we - /// will have to implement a Listener stack. + /// event type mask, all events from the broadcaster matching the mask will + /// now go to the hijacking listener. Only one hijack can occur at a time. + /// If we need more than this we will have to implement a Listener stack. /// /// @param[in] listener /// A Listener object. You do not need to call StartListeningForEvents @@ -454,8 +450,7 @@ public: void RestoreBroadcaster() { m_broadcaster_sp->RestoreBroadcaster(); } // This needs to be filled in if you are going to register the broadcaster - // with the broadcaster - // manager and do broadcaster class matching. + // with the broadcaster manager and do broadcaster class matching. // FIXME: Probably should make a ManagedBroadcaster subclass with all the bits // needed to work // with the BroadcasterManager, so that it is clearer how to add one. @@ -465,21 +460,17 @@ public: protected: // BroadcasterImpl contains the actual Broadcaster implementation. The - // Broadcaster makes a BroadcasterImpl - // which lives as long as it does. The Listeners & the Events hold a weak - // pointer to the BroadcasterImpl, - // so that they can survive if a Broadcaster they were listening to is - // destroyed w/o their being able to - // unregister from it (which can happen if the Broadcasters & Listeners are - // being destroyed on separate threads - // simultaneously. - // The Broadcaster itself can't be shared out as a weak pointer, because some - // things that are broadcasters - // (e.g. the Target and the Process) are shared in their own right. + // Broadcaster makes a BroadcasterImpl which lives as long as it does. The + // Listeners & the Events hold a weak pointer to the BroadcasterImpl, so that + // they can survive if a Broadcaster they were listening to is destroyed w/o + // their being able to unregister from it (which can happen if the + // Broadcasters & Listeners are being destroyed on separate threads + // simultaneously. The Broadcaster itself can't be shared out as a weak + // pointer, because some things that are broadcasters (e.g. the Target and + // the Process) are shared in their own right. // // For the most part, the Broadcaster functions dispatch to the - // BroadcasterImpl, and are documented in the - // public Broadcaster API above. + // BroadcasterImpl, and are documented in the public Broadcaster API above. class BroadcasterImpl { friend class Listener; @@ -557,7 +548,7 @@ protected: llvm::SmallVector<std::pair<lldb::ListenerSP, uint32_t &>, 4> GetListeners(); - Broadcaster &m_broadcaster; ///< The broadcsater that this implements + Broadcaster &m_broadcaster; ///< The broadcaster that this implements event_names_map m_event_names; ///< Optionally define event names for ///readability and logging for each event bit collection m_listeners; ///< A list of Listener / event_mask pairs that are diff --git a/include/lldb/Core/Communication.h b/include/lldb/Core/Communication.h index 57fa483bd3a39..3e29307039e40 100644 --- a/include/lldb/Core/Communication.h +++ b/include/lldb/Core/Communication.h @@ -39,60 +39,57 @@ class Status; namespace lldb_private { //---------------------------------------------------------------------- -/// @class Communication Communication.h "lldb/Core/Communication.h" -/// @brief An abstract communications class. +/// @class Communication Communication.h "lldb/Core/Communication.h" An +/// abstract communications class. /// -/// Communication is an class that handles data communication -/// between two data sources. It uses a Connection class to do the -/// real communication. This approach has a couple of advantages: it -/// allows a single instance of this class to be used even though its -/// connection can change. Connections could negotiate for different -/// connections based on abilities like starting with Bluetooth and -/// negotiating up to WiFi if available. It also allows this class to be -/// subclassed by any interfaces that don't want to give bytes but want -/// to validate and give out packets. This can be done by overriding: +/// Communication is an class that handles data communication between two data +/// sources. It uses a Connection class to do the real communication. This +/// approach has a couple of advantages: it allows a single instance of this +/// class to be used even though its connection can change. Connections could +/// negotiate for different connections based on abilities like starting with +/// Bluetooth and negotiating up to WiFi if available. It also allows this +/// class to be subclassed by any interfaces that don't want to give bytes but +/// want to validate and give out packets. This can be done by overriding: /// /// AppendBytesToCache (const uint8_t *src, size_t src_len, bool broadcast); /// -/// Communication inherits from Broadcaster which means it can be -/// used in conjunction with Listener to wait for multiple broadcaster -/// objects and multiple events from each of those objects. -/// Communication defines a set of pre-defined event bits (see -/// enumerations definitions that start with "eBroadcastBit" below). +/// Communication inherits from Broadcaster which means it can be used in +/// conjunction with Listener to wait for multiple broadcaster objects and +/// multiple events from each of those objects. Communication defines a set of +/// pre-defined event bits (see enumerations definitions that start with +/// "eBroadcastBit" below). /// /// There are two modes in which communications can occur: /// @li single-threaded /// @li multi-threaded /// -/// In single-threaded mode, all reads and writes happen synchronously -/// on the calling thread. +/// In single-threaded mode, all reads and writes happen synchronously on the +/// calling thread. /// -/// In multi-threaded mode, a read thread is spawned that continually -/// reads data and caches any received bytes. To start the read thread -/// clients call: +/// In multi-threaded mode, a read thread is spawned that continually reads +/// data and caches any received bytes. To start the read thread clients call: /// /// bool Communication::StartReadThread (Status *); /// -/// If true is returned a read thread has been spawned that will -/// continually execute a call to the pure virtual DoRead function: +/// If true is returned a read thread has been spawned that will continually +/// execute a call to the pure virtual DoRead function: /// /// size_t Communication::ReadFromConnection (void *, size_t, uint32_t); /// -/// When bytes are received the data gets cached in \a m_bytes and this -/// class will broadcast a \b eBroadcastBitReadThreadGotBytes event. -/// Clients that want packet based communication should override -/// AppendBytesToCache. The subclasses can choose to call the -/// built in AppendBytesToCache with the \a broadcast parameter set to -/// false. This will cause the \b eBroadcastBitReadThreadGotBytes event -/// not get broadcast, and then the subclass can post a \b -/// eBroadcastBitPacketAvailable event when a full packet of data has -/// been received. +/// When bytes are received the data gets cached in \a m_bytes and this class +/// will broadcast a \b eBroadcastBitReadThreadGotBytes event. Clients that +/// want packet based communication should override AppendBytesToCache. The +/// subclasses can choose to call the built in AppendBytesToCache with the \a +/// broadcast parameter set to false. This will cause the \b +/// eBroadcastBitReadThreadGotBytes event not get broadcast, and then the +/// subclass can post a \b eBroadcastBitPacketAvailable event when a full +/// packet of data has been received. /// -/// If the connection is disconnected a \b eBroadcastBitDisconnected -/// event gets broadcast. If the read thread exits a \b -/// eBroadcastBitReadThreadDidExit event will be broadcast. Clients -/// can also post a \b eBroadcastBitReadThreadShouldExit event to this -/// object which will cause the read thread to exit. +/// If the connection is disconnected a \b eBroadcastBitDisconnected event +/// gets broadcast. If the read thread exits a \b +/// eBroadcastBitReadThreadDidExit event will be broadcast. Clients can also +/// post a \b eBroadcastBitReadThreadShouldExit event to this object which +/// will cause the read thread to exit. //---------------------------------------------------------------------- class Communication : public Broadcaster { public: @@ -120,8 +117,8 @@ public: size_t src_len); //------------------------------------------------------------------ - /// Construct the Communication object with the specified name for - /// the Broadcaster that this object inherits from. + /// Construct the Communication object with the specified name for the + /// Broadcaster that this object inherits from. /// /// @param[in] broadcaster_name /// The name of the broadcaster object. This name should be as @@ -141,9 +138,8 @@ public: void Clear(); //------------------------------------------------------------------ - /// Connect using the current connection by passing \a url to its - /// connect function. - /// string. + /// Connect using the current connection by passing \a url to its connect + /// function. string. /// /// @param[in] url /// A string that contains all information needed by the @@ -160,8 +156,7 @@ public: lldb::ConnectionStatus Connect(const char *url, Status *error_ptr); //------------------------------------------------------------------ - /// Disconnect the communications connection if one is currently - /// connected. + /// Disconnect the communications connection if one is currently connected. /// /// @return /// \b True if the disconnect succeeded, \b false otherwise. The @@ -189,16 +184,15 @@ public: //------------------------------------------------------------------ /// Read bytes from the current connection. /// - /// If no read thread is running, this function call the - /// connection's Connection::Read(...) function to get any available. + /// If no read thread is running, this function call the connection's + /// Connection::Read(...) function to get any available. /// - /// If a read thread has been started, this function will check for - /// any cached bytes that have already been read and return any - /// currently available bytes. If no bytes are cached, it will wait - /// for the bytes to become available by listening for the \a - /// eBroadcastBitReadThreadGotBytes event. If this function consumes - /// all of the bytes in the cache, it will reset the - /// \a eBroadcastBitReadThreadGotBytes event bit. + /// If a read thread has been started, this function will check for any + /// cached bytes that have already been read and return any currently + /// available bytes. If no bytes are cached, it will wait for the bytes to + /// become available by listening for the \a eBroadcastBitReadThreadGotBytes + /// event. If this function consumes all of the bytes in the cache, it will + /// reset the \a eBroadcastBitReadThreadGotBytes event bit. /// /// @param[in] dst /// A destination buffer that must be at least \a dst_len bytes @@ -220,8 +214,8 @@ public: lldb::ConnectionStatus &status, Status *error_ptr); //------------------------------------------------------------------ - /// The actual write function that attempts to write to the - /// communications protocol. + /// The actual write function that attempts to write to the communications + /// protocol. /// /// Subclasses must override this function. /// @@ -242,11 +236,10 @@ public: //------------------------------------------------------------------ /// Sets the connection that it to be used by this class. /// - /// By making a communication class that uses different connections - /// it allows a single communication interface to negotiate and - /// change its connection without any interruption to the client. - /// It also allows the Communication class to be subclassed for - /// packet based communication. + /// By making a communication class that uses different connections it + /// allows a single communication interface to negotiate and change its + /// connection without any interruption to the client. It also allows the + /// Communication class to be subclassed for packet based communication. /// /// @param[in] connection /// A connection that this class will own and destroy. @@ -257,19 +250,19 @@ public: void SetConnection(Connection *connection); //------------------------------------------------------------------ - /// Starts a read thread whose sole purpose it to read bytes from - /// the current connection. This function will call connection's - /// read function: + /// Starts a read thread whose sole purpose it to read bytes from the + /// current connection. This function will call connection's read function: /// /// size_t Connection::Read (void *, size_t); /// /// When bytes are read and cached, this function will call: /// - /// Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, bool + /// Communication::AppendBytesToCache (const uint8_t * bytes, size_t len, + /// bool /// broadcast); /// - /// Subclasses should override this function if they wish to override - /// the default action of caching the bytes and broadcasting a \b + /// Subclasses should override this function if they wish to override the + /// default action of caching the bytes and broadcasting a \b /// eBroadcastBitReadThreadGotBytes event. /// /// @return @@ -277,8 +270,8 @@ public: /// false otherwise. /// /// @see size_t Connection::Read (void *, size_t); - /// @see void Communication::AppendBytesToCache (const uint8_t * bytes, size_t - /// len, bool broadcast); + /// @see void Communication::AppendBytesToCache (const uint8_t * bytes, + /// size_t len, bool broadcast); //------------------------------------------------------------------ virtual bool StartReadThread(Status *error_ptr = nullptr); @@ -301,11 +294,10 @@ public: bool ReadThreadIsRunning(); //------------------------------------------------------------------ - /// The static read thread function. This function will call - /// the "DoRead" function continuously and wait for data to become - /// available. When data is received it will append the available - /// data to the internal cache and broadcast a - /// \b eBroadcastBitReadThreadGotBytes event. + /// The static read thread function. This function will call the "DoRead" + /// function continuously and wait for data to become available. When data + /// is received it will append the available data to the internal cache and + /// broadcast a \b eBroadcastBitReadThreadGotBytes event. /// /// @param[in] comm_ptr /// A pointer to an instance of this class. @@ -364,18 +356,17 @@ protected: lldb::ConnectionStatus &status, Status *error_ptr); //------------------------------------------------------------------ - /// Append new bytes that get read from the read thread into the - /// internal object byte cache. This will cause a \b - /// eBroadcastBitReadThreadGotBytes event to be broadcast if \a - /// broadcast is true. + /// Append new bytes that get read from the read thread into the internal + /// object byte cache. This will cause a \b eBroadcastBitReadThreadGotBytes + /// event to be broadcast if \a broadcast is true. /// - /// Subclasses can override this function in order to inspect the - /// received data and check if a packet is available. + /// Subclasses can override this function in order to inspect the received + /// data and check if a packet is available. /// - /// Subclasses can also still call this function from the - /// overridden method to allow the caching to correctly happen and - /// suppress the broadcasting of the \a eBroadcastBitReadThreadGotBytes - /// event by setting \a broadcast to false. + /// Subclasses can also still call this function from the overridden method + /// to allow the caching to correctly happen and suppress the broadcasting + /// of the \a eBroadcastBitReadThreadGotBytes event by setting \a broadcast + /// to false. /// /// @param[in] src /// A source buffer that must be at least \a src_len bytes @@ -389,9 +380,9 @@ protected: lldb::ConnectionStatus status); //------------------------------------------------------------------ - /// Get any available bytes from our data cache. If this call - /// empties the data cache, the \b eBroadcastBitReadThreadGotBytes event - /// will be reset to signify no more bytes are available. + /// Get any available bytes from our data cache. If this call empties the + /// data cache, the \b eBroadcastBitReadThreadGotBytes event will be reset + /// to signify no more bytes are available. /// /// @param[in] dst /// A destination buffer that must be at least \a dst_len bytes diff --git a/include/lldb/Core/Debugger.h b/include/lldb/Core/Debugger.h index 34d35ffe7c80f..cc7176e5c95d0 100644 --- a/include/lldb/Core/Debugger.h +++ b/include/lldb/Core/Debugger.h @@ -76,7 +76,7 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class Debugger Debugger.h "lldb/Core/Debugger.h" -/// @brief A class to manage flag bits. +/// A class to manage flag bits. /// /// Provides a global root objects for the debugger core. //---------------------------------------------------------------------- @@ -156,11 +156,9 @@ public: lldb::ListenerSP GetListener() { return m_listener_sp; } // This returns the Debugger's scratch source manager. It won't be able to - // look up files in debug - // information, but it can look up files by absolute path and display them to - // you. - // To get the target's source manager, call GetSourceManager on the target - // instead. + // look up files in debug information, but it can look up files by absolute + // path and display them to you. To get the target's source manager, call + // GetSourceManager on the target instead. SourceManager &GetSourceManager(); lldb::TargetSP GetSelectedTarget() { @@ -171,10 +169,9 @@ public: //------------------------------------------------------------------ /// Get accessor for the target list. /// - /// The target list is part of the global debugger object. This - /// the single debugger shared instance to control where targets - /// get created and to allow for tracking and searching for targets - /// based on certain criteria. + /// The target list is part of the global debugger object. This the single + /// debugger shared instance to control where targets get created and to + /// allow for tracking and searching for targets based on certain criteria. /// /// @return /// A global shared target list. @@ -188,9 +185,8 @@ public: void DispatchInputEndOfFile(); //------------------------------------------------------------------ - // If any of the streams are not set, set them to the in/out/err - // stream of the top most input reader to ensure they at least have - // something + // If any of the streams are not set, set them to the in/out/err stream of + // the top most input reader to ensure they at least have something //------------------------------------------------------------------ void AdoptTopIOHandlerFilesIfInvalid(lldb::StreamFileSP &in, lldb::StreamFileSP &out, @@ -323,9 +319,8 @@ public: Status RunREPL(lldb::LanguageType language, const char *repl_options); // This is for use in the command interpreter, when you either want the - // selected target, or if no target - // is present you want to prime the dummy target with entities that will be - // copied over to new targets. + // selected target, or if no target is present you want to prime the dummy + // target with entities that will be copied over to new targets. Target *GetSelectedOrDummyTarget(bool prefer_dummy = false); Target *GetDummyTarget(); @@ -378,8 +373,8 @@ protected: lldb::BroadcasterManagerSP m_broadcaster_manager_sp; // The debugger acts as a // broadcaster manager of // last resort. - // It needs to get constructed before the target_list or any other - // member that might want to broadcast through the debugger. + // It needs to get constructed before the target_list or any other member + // that might want to broadcast through the debugger. TerminalState m_terminal_state; TargetList m_target_list; @@ -418,8 +413,8 @@ protected: }; private: - // Use Debugger::CreateInstance() to get a shared pointer to a new - // debugger object + // Use Debugger::CreateInstance() to get a shared pointer to a new debugger + // object Debugger(lldb::LogOutputCallback m_log_callback, void *baton); DISALLOW_COPY_AND_ASSIGN(Debugger); diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h index fa5e6a636aaf2..ef1f2ee54dd19 100644 --- a/include/lldb/Core/Disassembler.h +++ b/include/lldb/Core/Disassembler.h @@ -22,8 +22,8 @@ #include "lldb/Utility/ConstString.h" // for ConstString #include "lldb/Utility/FileSpec.h" #include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-enumerations.h" // for AddressClass, AddressClass... #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 "llvm/ADT/StringRef.h" // for StringRef @@ -78,7 +78,7 @@ namespace lldb_private { class Instruction { public: Instruction(const Address &address, - lldb::AddressClass addr_class = lldb::eAddressClassInvalid); + AddressClass addr_class = AddressClass::eInvalid); virtual ~Instruction(); @@ -102,12 +102,11 @@ public: virtual void CalculateMnemonicOperandsAndComment(const ExecutionContext *exe_ctx) = 0; - lldb::AddressClass GetAddressClass(); + AddressClass GetAddressClass(); void SetAddress(const Address &addr) { - // Invalidate the address class to lazily discover - // it if we need to. - m_address_class = lldb::eAddressClassInvalid; + // Invalidate the address class to lazily discover it if we need to. + m_address_class = AddressClass::eInvalid; m_address = addr; } @@ -235,14 +234,15 @@ public: protected: Address m_address; // The section offset address of this instruction // We include an address class in the Instruction class to - // allow the instruction specify the eAddressClassCodeAlternateISA - // (currently used for thumb), and also to specify data (eAddressClassData). - // The usual value will be eAddressClassCode, but often when - // disassembling memory, you might run into data. This can - // help us to disassemble appropriately. + // allow the instruction specify the + // AddressClass::eCodeAlternateISA (currently used for + // thumb), and also to specify data (AddressClass::eData). + // The usual value will be AddressClass::eCode, but often + // when disassembling memory, you might run into data. + // This can help us to disassemble appropriately. private: - lldb::AddressClass - m_address_class; // Use GetAddressClass () accessor function! + AddressClass m_address_class; // Use GetAddressClass () accessor function! + protected: Opcode m_opcode; // The opcode for this instruction std::string m_opcode_name; @@ -365,12 +365,10 @@ public: }; // FindPlugin should be lax about the flavor string (it is too annoying to - // have various internal uses of the - // disassembler fail because the global flavor string gets set wrong. - // Instead, if you get a flavor string you + // have various internal uses of the disassembler fail because the global + // flavor string gets set wrong. Instead, if you get a flavor string you // don't understand, use the default. Folks who care to check can use the - // FlavorValidForArchSpec method on the - // disassembler they got back. + // FlavorValidForArchSpec method on the disassembler they got back. static lldb::DisassemblerSP FindPlugin(const ArchSpec &arch, const char *flavor, const char *plugin_name); @@ -470,8 +468,8 @@ public: const char *flavor) = 0; protected: - // SourceLine and SourceLinesToDisplay structures are only used in - // the mixed source and assembly display methods internal to this class. + // SourceLine and SourceLinesToDisplay structures are only used in the mixed + // source and assembly display methods internal to this class. struct SourceLine { FileSpec file; @@ -494,9 +492,9 @@ protected: struct SourceLinesToDisplay { std::vector<SourceLine> lines; - // index of the "current" source line, if we want to highlight that - // when displaying the source lines. (as opposed to the surrounding - // source lines provided to give context) + // index of the "current" source line, if we want to highlight that when + // displaying the source lines. (as opposed to the surrounding source + // lines provided to give context) size_t current_source_line; // Whether to print a blank line at the end of the source lines. @@ -507,8 +505,8 @@ protected: } }; - // Get the function's declaration line number, hopefully a line number earlier - // than the opening curly brace at the start of the function body. + // Get the function's declaration line number, hopefully a line number + // earlier than the opening curly brace at the start of the function body. static SourceLine GetFunctionDeclLineEntry(const SymbolContext &sc); // Add the provided SourceLine to the map of filenames-to-source-lines-seen. @@ -517,14 +515,13 @@ protected: std::map<FileSpec, std::set<uint32_t>> &source_lines_seen); // Given a source line, determine if we should print it when we're doing - // mixed source & assembly output. - // We're currently using the target.process.thread.step-avoid-regexp setting - // (which is used for stepping over inlined STL functions by default) to - // determine what source lines to avoid showing. + // mixed source & assembly output. We're currently using the + // target.process.thread.step-avoid-regexp setting (which is used for + // stepping over inlined STL functions by default) to determine what source + // lines to avoid showing. // // Returns true if this source line should be elided (if the source line - // should - // not be displayed). + // should not be displayed). static bool ElideMixedSourceAndDisassemblyLine(const ExecutionContext &exe_ctx, const SymbolContext &sc, SourceLine &line); diff --git a/include/lldb/Core/DumpRegisterValue.h b/include/lldb/Core/DumpRegisterValue.h new file mode 100644 index 0000000000000..bc4860fbc0e5a --- /dev/null +++ b/include/lldb/Core/DumpRegisterValue.h @@ -0,0 +1,31 @@ +//===-- DumpRegisterValue.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_CORE_DUMPREGISTERVALUE_H +#define LLDB_CORE_DUMPREGISTERVALUE_H + +#include "lldb/lldb-enumerations.h" +#include <cstdint> + +namespace lldb_private { + +class RegisterValue; +struct RegisterInfo; +class Stream; + +// The default value of 0 for reg_name_right_align_at means no alignment at +// all. +bool DumpRegisterValue(const RegisterValue ®_val, Stream *s, + const RegisterInfo *reg_info, bool prefix_with_name, + bool prefix_with_alt_name, lldb::Format format, + uint32_t reg_name_right_align_at = 0); + +} // namespace lldb_private + +#endif // LLDB_CORE_DUMPREGISTERVALUE_H diff --git a/include/lldb/Core/EmulateInstruction.h b/include/lldb/Core/EmulateInstruction.h index b0a4267a00a20..5d23bcd7b96e6 100644 --- a/include/lldb/Core/EmulateInstruction.h +++ b/include/lldb/Core/EmulateInstruction.h @@ -48,62 +48,61 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class EmulateInstruction EmulateInstruction.h /// "lldb/Core/EmulateInstruction.h" -/// @brief A class that allows emulation of CPU opcodes. +/// A class that allows emulation of CPU opcodes. /// -/// This class is a plug-in interface that is accessed through the -/// standard static FindPlugin function call in the EmulateInstruction -/// class. The FindPlugin takes a target triple and returns a new object -/// if there is a plug-in that supports the architecture and OS. Four -/// callbacks and a baton are provided. The four callbacks are read -/// register, write register, read memory and write memory. +/// This class is a plug-in interface that is accessed through the standard +/// static FindPlugin function call in the EmulateInstruction class. The +/// FindPlugin takes a target triple and returns a new object if there is a +/// plug-in that supports the architecture and OS. Four callbacks and a baton +/// are provided. The four callbacks are read register, write register, read +/// memory and write memory. /// -/// This class is currently designed for these main use cases: -/// - Auto generation of Call Frame Information (CFI) from assembly code -/// - Predicting single step breakpoint locations -/// - Emulating instructions for breakpoint traps +/// This class is currently designed for these main use cases: - Auto +/// generation of Call Frame Information (CFI) from assembly code - Predicting +/// single step breakpoint locations - Emulating instructions for breakpoint +/// traps /// -/// Objects can be asked to read an instruction which will cause a call -/// to the read register callback to get the PC, followed by a read -/// memory call to read the opcode. If ReadInstruction () returns true, -/// then a call to EmulateInstruction::EvaluateInstruction () can be -/// made. At this point the EmulateInstruction subclass will use all of -/// the callbacks to emulate an instruction. +/// Objects can be asked to read an instruction which will cause a call to the +/// read register callback to get the PC, followed by a read memory call to +/// read the opcode. If ReadInstruction () returns true, then a call to +/// EmulateInstruction::EvaluateInstruction () can be made. At this point the +/// EmulateInstruction subclass will use all of the callbacks to emulate an +/// instruction. /// /// Clients that provide the callbacks can either do the read/write -/// registers/memory to actually emulate the instruction on a real or -/// virtual CPU, or watch for the EmulateInstruction::Context which -/// is context for the read/write register/memory which explains why -/// the callback is being called. Examples of a context are: -/// "pushing register 3 onto the stack at offset -12", or "adjusting -/// stack pointer by -16". This extra context allows the generation of +/// registers/memory to actually emulate the instruction on a real or virtual +/// CPU, or watch for the EmulateInstruction::Context which is context for the +/// read/write register/memory which explains why the callback is being +/// called. Examples of a context are: "pushing register 3 onto the stack at +/// offset -12", or "adjusting stack pointer by -16". This extra context +/// allows the generation of /// CFI information from assembly code without having to actually do /// the read/write register/memory. /// -/// Clients must be prepared that not all instructions for an -/// Instruction Set Architecture (ISA) will be emulated. +/// Clients must be prepared that not all instructions for an Instruction Set +/// Architecture (ISA) will be emulated. /// -/// Subclasses at the very least should implement the instructions that -/// save and restore registers onto the stack and adjustment to the stack -/// pointer. By just implementing a few instructions for an ISA that are -/// the typical prologue opcodes, you can then generate CFI using a -/// class that will soon be available. +/// Subclasses at the very least should implement the instructions that save +/// and restore registers onto the stack and adjustment to the stack pointer. +/// By just implementing a few instructions for an ISA that are the typical +/// prologue opcodes, you can then generate CFI using a class that will soon +/// be available. /// -/// Implementing all of the instructions that affect the PC can then -/// allow single step prediction support. +/// Implementing all of the instructions that affect the PC can then allow +/// single step prediction support. /// -/// Implementing all of the instructions allows for emulation of opcodes -/// for breakpoint traps and will pave the way for "thread centric" -/// debugging. The current debugging model is "process centric" where -/// all threads must be stopped when any thread is stopped; when -/// hitting software breakpoints we must disable the breakpoint by -/// restoring the original breakpoint opcode, single stepping and -/// restoring the breakpoint trap. If all threads were allowed to run -/// then other threads could miss the breakpoint. +/// Implementing all of the instructions allows for emulation of opcodes for +/// breakpoint traps and will pave the way for "thread centric" debugging. The +/// current debugging model is "process centric" where all threads must be +/// stopped when any thread is stopped; when hitting software breakpoints we +/// must disable the breakpoint by restoring the original breakpoint opcode, +/// single stepping and restoring the breakpoint trap. If all threads were +/// allowed to run then other threads could miss the breakpoint. /// -/// This class centralizes the code that usually is done in separate -/// code paths in a debugger (single step prediction, finding save -/// restore locations of registers for unwinding stack frame variables) -/// and emulating the instruction is just a bonus. +/// This class centralizes the code that usually is done in separate code +/// paths in a debugger (single step prediction, finding save restore +/// locations of registers for unwinding stack frame variables) and emulating +/// the instruction is just a bonus. //---------------------------------------------------------------------- class EmulateInstruction : public PluginInterface { @@ -125,8 +124,8 @@ public: // prologue eContextPushRegisterOnStack, - // Exclusively used when restoring a register off the stack as part of - // the epilogue + // Exclusively used when restoring a register off the stack as part of the + // epilogue eContextPopRegisterOffStack, // Add or subtract a value from the stack @@ -135,8 +134,8 @@ public: // Adjust the frame pointer for the current frame eContextSetFramePointer, - // Typically in an epilogue sequence. Copy the frame pointer back - // into the stack pointer, use SP for CFA calculations again. + // Typically in an epilogue sequence. Copy the frame pointer back into the + // stack pointer, use SP for CFA calculations again. eContextRestoreStackPointer, // Add or subtract a value from a base address register (other than SP) @@ -159,8 +158,8 @@ public: // Used when performing an absolute branch where the eContextAbsoluteBranchRegister, - // Used when performing a supervisor call to an operating system to - // provide a service: + // Used when performing a supervisor call to an operating system to provide + // a service: eContextSupervisorCall, // Used when performing a MemU operation to read the PC-relative offset @@ -360,9 +359,8 @@ public: const RegisterValue ®_value); // Type to represent the condition of an instruction. The UINT32 value is - // reserved for the - // unconditional case and all other value can be used in an architecture - // dependent way. + // reserved for the unconditional case and all other value can be used in an + // architecture dependent way. typedef uint32_t InstructionCondition; static const InstructionCondition UnconditionalCondition = UINT32_MAX; diff --git a/include/lldb/Core/Event.h b/include/lldb/Core/Event.h index f4c7f4769a372..fa3017057675f 100644 --- a/include/lldb/Core/Event.h +++ b/include/lldb/Core/Event.h @@ -121,10 +121,8 @@ public: const ConstString &GetFlavor() const override { return GetFlavorString(); } - bool WaitForEventReceived( - const std::chrono::microseconds &abstime = std::chrono::microseconds(0), - bool *timed_out = nullptr) { - return m_predicate.WaitForValueEqualTo(true, abstime, timed_out); + bool WaitForEventReceived(const Timeout<std::micro> &timeout = llvm::None) { + return m_predicate.WaitForValueEqualTo(true, timeout); } private: diff --git a/include/lldb/Core/FileLineResolver.h b/include/lldb/Core/FileLineResolver.h index 54bce4fd2f417..855d749ed5d45 100644 --- a/include/lldb/Core/FileLineResolver.h +++ b/include/lldb/Core/FileLineResolver.h @@ -28,9 +28,8 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class FileLineResolver FileLineResolver.h "lldb/Core/FileLineResolver.h" -/// @brief This class finds address for source file and line. Optionally, it -/// will look for inlined -/// instances of the file and line specification. +/// This class finds address for source file and line. Optionally, it will +/// look for inlined instances of the file and line specification. //---------------------------------------------------------------------- class FileLineResolver : public Searcher { diff --git a/include/lldb/Core/FileSpecList.h b/include/lldb/Core/FileSpecList.h index 3cbffca44f698..713ed2aaffc6d 100644 --- a/include/lldb/Core/FileSpecList.h +++ b/include/lldb/Core/FileSpecList.h @@ -25,7 +25,7 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class FileSpecList FileSpecList.h "lldb/Core/FileSpecList.h" -/// @brief A file collection class. +/// A file collection class. /// /// A class that contains a mutable list of FileSpec objects. //---------------------------------------------------------------------- @@ -56,8 +56,7 @@ public: //------------------------------------------------------------------ /// Assignment operator. /// - /// Replace the file list in this object with the file list from - /// \a rhs. + /// Replace the file list in this object with the file list from \a rhs. /// /// @param[in] rhs /// A file list object to copy. @@ -80,8 +79,8 @@ public: //------------------------------------------------------------------ /// Append a FileSpec object if unique. /// - /// Appends \a file to the end of the file list if it doesn't - /// already exist in the file list. + /// Appends \a file to the end of the file list if it doesn't already exist + /// in the file list. /// /// @param[in] file /// A new file to append to this file list. @@ -107,8 +106,8 @@ public: //------------------------------------------------------------------ /// Find a file index. /// - /// Find the index of the file in the file spec list that matches - /// \a file starting \a idx entries into the file spec list. + /// Find the index of the file in the file spec list that matches \a file + /// starting \a idx entries into the file spec list. /// /// @param[in] idx /// An index into the file list. @@ -119,24 +118,18 @@ public: /// @param[in] full /// Should FileSpec::Equal be called with "full" true or false. /// - /// @param[in] remove_backup_dots - /// Should FileSpec::Equal be called with "remove_backup_dots" true or - /// false. - /// /// @return /// The index of the file that matches \a file if it is found, /// else UINT32_MAX is returned. //------------------------------------------------------------------ - size_t FindFileIndex(size_t idx, const FileSpec &file, bool full, - bool remove_backup_dots = false) const; + size_t FindFileIndex(size_t idx, const FileSpec &file, bool full) const; //------------------------------------------------------------------ /// Get file at index. /// - /// Gets a file from the file list. If \a idx is not a valid index, - /// an empty FileSpec object will be returned. The file objects - /// that are returned can be tested using - /// FileSpec::operator void*(). + /// Gets a file from the file list. If \a idx is not a valid index, an empty + /// FileSpec object will be returned. The file objects that are returned can + /// be tested using FileSpec::operator void*(). /// /// @param[in] idx /// An index into the file list. @@ -151,8 +144,8 @@ public: //------------------------------------------------------------------ /// Get file specification pointer at index. /// - /// Gets a file from the file list. The file objects that are - /// returned can be tested using FileSpec::operator void*(). + /// Gets a file from the file list. The file objects that are returned can + /// be tested using FileSpec::operator void*(). /// /// @param[in] idx /// An index into the file list. @@ -166,9 +159,9 @@ public: //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// Return the size in bytes that this object takes in memory. This - /// returns the size in bytes of this object, not any shared string - /// values it may refer to. + /// Return the size in bytes that this object takes in memory. This returns + /// the size in bytes of this object, not any shared string values it may + /// refer to. /// /// @return /// The number of bytes that this object occupies in memory. diff --git a/include/lldb/Core/FormatEntity.h b/include/lldb/Core/FormatEntity.h index aa5ccb48e56a7..93c7b3a94e4e7 100644 --- a/include/lldb/Core/FormatEntity.h +++ b/include/lldb/Core/FormatEntity.h @@ -10,6 +10,7 @@ #ifndef liblldb_FormatEntity_h_ #define liblldb_FormatEntity_h_ +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/FileSpec.h" // for FileSpec #include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" // for Format::eFormatDefault, Format @@ -211,17 +212,15 @@ public: llvm::StringRef &variable_name, llvm::StringRef &variable_format); - static size_t AutoComplete(llvm::StringRef s, int match_start_point, - int max_return_elements, bool &word_complete, - StringList &matches); + static size_t AutoComplete(lldb_private::CompletionRequest &request); //---------------------------------------------------------------------- // Format the current elements into the stream \a s. // - // The root element will be stripped off and the format str passed in - // will be either an empty string (print a description of this object), - // or contain a . separated series like a domain name that identifies - // further sub elements to display. + // The root element will be stripped off and the format str passed in will be + // either an empty string (print a description of this object), or contain a + // `.`-separated series like a domain name that identifies further + // sub-elements to display. //---------------------------------------------------------------------- static bool FormatFileSpec(const FileSpec &file, Stream &s, llvm::StringRef elements, diff --git a/include/lldb/Core/IOHandler.h b/include/lldb/Core/IOHandler.h index e8cfbade5c61e..2170ad10674eb 100644 --- a/include/lldb/Core/IOHandler.h +++ b/include/lldb/Core/IOHandler.h @@ -63,14 +63,13 @@ public: virtual ~IOHandler(); - // Each IOHandler gets to run until it is done. It should read data - // from the "in" and place output into "out" and "err and return - // when done. + // Each IOHandler gets to run until it is done. It should read data from the + // "in" and place output into "out" and "err and return when done. virtual void Run() = 0; - // Called when an input reader should relinquish its control so another - // can be pushed onto the IO handler stack, or so the current IO - // handler can pop itself off the stack + // Called when an input reader should relinquish its control so another can + // be pushed onto the IO handler stack, or so the current IO handler can pop + // itself off the stack virtual void Cancel() = 0; @@ -273,8 +272,8 @@ public: //------------------------------------------------------------------ virtual bool IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) { - // Impose no requirements for input to be considered - // complete. subclasses should do something more intelligent. + // Impose no requirements for input to be considered complete. subclasses + // should do something more intelligent. return true; } @@ -289,8 +288,8 @@ public: //------------------------------------------------------------------ // Intercept the IOHandler::Interrupt() calls and do something. // - // Return true if the interrupt was handled, false if the IOHandler - // should continue to try handle the interrupt itself. + // Return true if the interrupt was handled, false if the IOHandler should + // continue to try handle the interrupt itself. //------------------------------------------------------------------ virtual bool IOHandlerInterrupt(IOHandler &io_handler) { return false; } @@ -302,8 +301,7 @@ protected: // IOHandlerDelegateMultiline // // A IOHandlerDelegate that handles terminating multi-line input when -// the last line is equal to "end_line" which is specified in the -// constructor. +// the last line is equal to "end_line" which is specified in the constructor. //---------------------------------------------------------------------- class IOHandlerDelegateMultiline : public IOHandlerDelegate { public: @@ -325,9 +323,8 @@ public: // Determine whether the end of input signal has been entered const size_t num_lines = lines.GetSize(); if (num_lines > 0 && lines[num_lines - 1] == m_end_line) { - // Remove the terminal line from "lines" so it doesn't appear in - // the resulting input and return true to indicate we are done - // getting lines + // Remove the terminal line from "lines" so it doesn't appear in the + // resulting input and return true to indicate we are done getting lines lines.PopBack(); return true; } @@ -454,8 +451,7 @@ protected: }; // The order of base classes is important. Look at the constructor of -// IOHandlerConfirm -// to see how. +// IOHandlerConfirm to see how. class IOHandlerConfirm : public IOHandlerDelegate, public IOHandlerEditline { public: IOHandlerConfirm(Debugger &debugger, llvm::StringRef prompt, diff --git a/include/lldb/Core/LoadedModuleInfoList.h b/include/lldb/Core/LoadedModuleInfoList.h index ecbe3548d6879..6554c64fa870c 100644 --- a/include/lldb/Core/LoadedModuleInfoList.h +++ b/include/lldb/Core/LoadedModuleInfoList.h @@ -13,10 +13,14 @@ // 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" namespace lldb_private { class LoadedModuleInfoList { diff --git a/include/lldb/Core/Mangled.h b/include/lldb/Core/Mangled.h index 22778fabe63dd..d263297ecfc60 100644 --- a/include/lldb/Core/Mangled.h +++ b/include/lldb/Core/Mangled.h @@ -28,15 +28,15 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class Mangled Mangled.h "lldb/Core/Mangled.h" -/// @brief A class that handles mangled names. +/// A class that handles mangled names. /// -/// Designed to handle mangled names. The demangled version of any names -/// will be computed when the demangled name is accessed through the -/// Demangled() acccessor. This class can also tokenize the demangled -/// version of the name for powerful searches. Functions and symbols -/// could make instances of this class for their mangled names. Uniqued -/// string pools are used for the mangled, demangled, and token string -/// values to allow for faster comparisons and for efficient memory use. +/// Designed to handle mangled names. The demangled version of any names will +/// be computed when the demangled name is accessed through the Demangled() +/// acccessor. This class can also tokenize the demangled version of the name +/// for powerful searches. Functions and symbols could make instances of this +/// class for their mangled names. Uniqued string pools are used for the +/// mangled, demangled, and token string values to allow for faster +/// comparisons and for efficient memory use. //---------------------------------------------------------------------- class Mangled { public: @@ -91,16 +91,16 @@ public: //---------------------------------------------------------------------- /// Destructor /// - /// Releases its ref counts on the mangled and demangled strings that - /// live in the global string pool. + /// Releases its ref counts on the mangled and demangled strings that live + /// in the global string pool. //---------------------------------------------------------------------- ~Mangled(); //---------------------------------------------------------------------- /// Convert to pointer operator. /// - /// This allows code to check a Mangled object to see if it contains - /// a valid mangled name using code such as: + /// This allows code to check a Mangled object to see if it contains a valid + /// mangled name using code such as: /// /// @code /// Mangled mangled(...); @@ -117,8 +117,8 @@ public: //---------------------------------------------------------------------- /// Logical NOT operator. /// - /// This allows code to check a Mangled object to see if it contains - /// an empty mangled name using code such as: + /// This allows code to check a Mangled object to see if it contains an + /// empty mangled name using code such as: /// /// @code /// Mangled mangled(...); @@ -158,8 +158,8 @@ public: //---------------------------------------------------------------------- /// Dump a description of this object to a Stream \a s. /// - /// Dump a Mangled object to stream \a s. We don't force our - /// demangled name to be computed currently (we don't use the accessor). + /// Dump a Mangled object to stream \a s. We don't force our demangled name + /// to be computed currently (we don't use the accessor). /// /// @param[in] s /// The stream to which to dump the object description. @@ -245,9 +245,9 @@ public: //---------------------------------------------------------------------- /// Get the memory cost of this object. /// - /// Return the size in bytes that this object takes in memory. This - /// returns the size in bytes of this object, not any shared string - /// values it may refer to. + /// Return the size in bytes that this object takes in memory. This returns + /// the size in bytes of this object, not any shared string values it may + /// refer to. /// /// @return /// The number of bytes that this object occupies in memory. @@ -259,8 +259,8 @@ public: //---------------------------------------------------------------------- /// Set the string value in this object. /// - /// If \a is_mangled is \b true, then the mangled named is set to \a - /// name, else the demangled name is set to \a name. + /// If \a is_mangled is \b true, then the mangled named is set to \a name, + /// else the demangled name is set to \a name. /// /// @param[in] name /// The already const version of the name for this object. @@ -285,14 +285,14 @@ public: //---------------------------------------------------------------------- /// Try to guess the language from the mangling. /// - /// For a mangled name to have a language it must have both a mangled - /// and a demangled name and it can be guessed from the mangling what - /// the language is. Note: this will return C++ for any language that - /// uses Itanium ABI mangling. + /// For a mangled name to have a language it must have both a mangled and a + /// demangled name and it can be guessed from the mangling what the language + /// is. Note: this will return C++ for any language that uses Itanium ABI + /// mangling. /// - /// Standard C function names will return eLanguageTypeUnknown because - /// they aren't mangled and it isn't clear what language the name - /// represents (there will be no mangled name). + /// Standard C function names will return eLanguageTypeUnknown because they + /// aren't mangled and it isn't clear what language the name represents + /// (there will be no mangled name). /// /// @return /// The language for the mangled/demangled name, eLanguageTypeUnknown diff --git a/include/lldb/Core/MappedHash.h b/include/lldb/Core/MappedHash.h index d56a6d537868b..1bdf59c736493 100644 --- a/include/lldb/Core/MappedHash.h +++ b/include/lldb/Core/MappedHash.h @@ -24,6 +24,7 @@ // Project includes #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Stream.h" +#include "llvm/Support/DJB.h" class MappedHash { public: @@ -32,22 +33,10 @@ public: // by the ELF GNU_HASH sections }; - static uint32_t HashStringUsingDJB(const char *s) { - uint32_t h = 5381; - - for (unsigned char c = *s; c; c = *++s) - h = ((h << 5) + h) + c; - - return h; - } - - static uint32_t HashString(uint32_t hash_function, const char *s) { - if (!s) - return 0; - + static uint32_t HashString(uint32_t hash_function, llvm::StringRef s) { switch (hash_function) { case MappedHash::eHashFunctionDJB: - return HashStringUsingDJB(s); + return llvm::djbHash(s); default: break; @@ -152,164 +141,6 @@ public: // Write (int fd); }; - template <typename __KeyType, class __HeaderDataType, class __ValueType> - class ExportTable { - public: - typedef __HeaderDataType HeaderDataType; - typedef Header<HeaderDataType> HeaderType; - typedef __KeyType KeyType; - typedef __ValueType ValueType; - - struct Entry { - uint32_t hash; - KeyType key; - ValueType value; - }; - - typedef std::vector<ValueType> ValueArrayType; - - typedef std::map<KeyType, ValueArrayType> HashData; - // Map a name hash to one or more name infos - typedef std::map<uint32_t, HashData> HashToHashData; - - virtual KeyType GetKeyForStringType(const char *cstr) const = 0; - - virtual size_t GetByteSize(const HashData &key_to_key_values) = 0; - - virtual bool WriteHashData(const HashData &hash_data, - lldb_private::Stream &ostrm) = 0; - // - void AddEntry(const char *cstr, const ValueType &value) { - Entry entry; - entry.hash = MappedHash::HashString(eHashFunctionDJB, cstr); - entry.key = GetKeyForStringType(cstr); - entry.value = value; - m_entries.push_back(entry); - } - - void Save(const HeaderDataType &header_data, lldb_private::Stream &ostrm) { - if (m_entries.empty()) - return; - - const uint32_t num_entries = m_entries.size(); - uint32_t i = 0; - - HeaderType header; - - header.magic = HASH_MAGIC; - header.version = 1; - header.hash_function = eHashFunctionDJB; - header.bucket_count = 0; - header.hashes_count = 0; - header.prologue_length = header_data.GetByteSize(); - - // We need to figure out the number of unique hashes first before we can - // calculate the number of buckets we want to use. - typedef std::vector<uint32_t> hash_coll; - hash_coll unique_hashes; - unique_hashes.resize(num_entries); - for (i = 0; i < num_entries; ++i) - unique_hashes[i] = m_entries[i].hash; - std::sort(unique_hashes.begin(), unique_hashes.end()); - hash_coll::iterator pos = - std::unique(unique_hashes.begin(), unique_hashes.end()); - const size_t num_unique_hashes = - std::distance(unique_hashes.begin(), pos); - - if (num_unique_hashes > 1024) - header.bucket_count = num_unique_hashes / 4; - else if (num_unique_hashes > 16) - header.bucket_count = num_unique_hashes / 2; - else - header.bucket_count = num_unique_hashes; - if (header.bucket_count == 0) - header.bucket_count = 1; - - std::vector<HashToHashData> hash_buckets; - std::vector<uint32_t> hash_indexes(header.bucket_count, 0); - std::vector<uint32_t> hash_values; - std::vector<uint32_t> hash_offsets; - hash_buckets.resize(header.bucket_count); - uint32_t bucket_entry_empties = 0; - // StreamString hash_file_data(Stream::eBinary, - // dwarf->GetObjectFile()->GetAddressByteSize(), - // dwarf->GetObjectFile()->GetByteSize()); - - // Push all of the hashes into their buckets and create all bucket - // entries all populated with data. - for (i = 0; i < num_entries; ++i) { - const uint32_t hash = m_entries[i].hash; - const uint32_t bucket_idx = hash % header.bucket_count; - const uint32_t strp_offset = m_entries[i].str_offset; - const uint32_t die_offset = m_entries[i].die_offset; - hash_buckets[bucket_idx][hash][strp_offset].push_back(die_offset); - } - - // Now for each bucket we write the bucket value which is the - // number of hashes and the hash index encoded into a single - // 32 bit unsigned integer. - for (i = 0; i < header.bucket_count; ++i) { - HashToHashData &bucket_entry = hash_buckets[i]; - - if (bucket_entry.empty()) { - // Empty bucket - ++bucket_entry_empties; - hash_indexes[i] = UINT32_MAX; - } else { - const uint32_t hash_value_index = hash_values.size(); - uint32_t hash_count = 0; - typename HashToHashData::const_iterator pos, end = bucket_entry.end(); - for (pos = bucket_entry.begin(); pos != end; ++pos) { - hash_values.push_back(pos->first); - hash_offsets.push_back(GetByteSize(pos->second)); - ++hash_count; - } - - hash_indexes[i] = hash_value_index; - } - } - header.hashes_count = hash_values.size(); - - // Write the header out now that we have the hash_count - header.Write(ostrm); - - // Now for each bucket we write the start index of the hashes - // for the current bucket, or UINT32_MAX if the bucket is empty - for (i = 0; i < header.bucket_count; ++i) { - ostrm.PutHex32(hash_indexes[i]); - } - - // Now we need to write out all of the hash values - for (i = 0; i < header.hashes_count; ++i) { - ostrm.PutHex32(hash_values[i]); - } - - // Now we need to write out all of the hash data offsets, - // there is an offset for each hash in the hashes array - // that was written out above - for (i = 0; i < header.hashes_count; ++i) { - ostrm.PutHex32(hash_offsets[i]); - } - - // Now we write the data for each hash and verify we got the offset - // correct above... - for (i = 0; i < header.bucket_count; ++i) { - HashToHashData &bucket_entry = hash_buckets[i]; - - typename HashToHashData::const_iterator pos, end = bucket_entry.end(); - for (pos = bucket_entry.begin(); pos != end; ++pos) { - if (!bucket_entry.empty()) { - WriteHashData(pos->second); - } - } - } - } - - protected: - typedef std::vector<Entry> collection; - collection m_entries; - }; - // A class for reading and using a saved hash table from a block of data // in memory template <typename __KeyType, class __HeaderType, class __HashData> @@ -377,8 +208,8 @@ public: return result; } - bool Find(const char *name, Pair &pair) const { - if (!name || !name[0]) + bool Find(llvm::StringRef name, Pair &pair) const { + if (name.empty()) return false; if (IsValid()) { @@ -425,13 +256,12 @@ public: return false; } - // This method must be implemented in any subclasses. - // The KeyType is user specified and must somehow result in a string - // value. For example, the KeyType might be a string offset in a string - // table and subclasses can store their string table as a member of the - // subclass and return a valie "const char *" given a "key". The value - // could also be a C string pointer, in which case just returning "key" - // will suffice. + // This method must be implemented in any subclasses. The KeyType is user + // specified and must somehow result in a string value. For example, the + // KeyType might be a string offset in a string table and subclasses can + // store their string table as a member of the subclass and return a valie + // "const char *" given a "key". The value could also be a C string + // pointer, in which case just returning "key" will suffice. virtual const char *GetStringForKeyType(KeyType key) const = 0; virtual bool ReadHashData(uint32_t hash_data_offset, @@ -439,20 +269,19 @@ public: // This method must be implemented in any subclasses and it must try to // read one "Pair" at the offset pointed to by the "hash_data_offset_ptr" - // parameter. This offset should be updated as bytes are consumed and - // a value "Result" enum should be returned. If the "name" matches the - // full name for the "pair.key" (which must be filled in by this call), - // then the HashData in the pair ("pair.value") should be extracted and - // filled in and "eResultKeyMatch" should be returned. If "name" doesn't - // match this string for the key, then "eResultKeyMismatch" should be - // returned and all data for the current HashData must be consumed or - // skipped and the "hash_data_offset_ptr" offset needs to be updated to - // point to the next HashData. If the end of the HashData objects for - // a given hash value have been reached, then "eResultEndOfHashData" - // should be returned. If anything else goes wrong during parsing, - // return "eResultError" and the corresponding "Find()" function will - // be canceled and return false. - virtual Result GetHashDataForName(const char *name, + // parameter. This offset should be updated as bytes are consumed and a + // value "Result" enum should be returned. If the "name" matches the full + // name for the "pair.key" (which must be filled in by this call), then the + // HashData in the pair ("pair.value") should be extracted and filled in + // and "eResultKeyMatch" should be returned. If "name" doesn't match this + // string for the key, then "eResultKeyMismatch" should be returned and all + // data for the current HashData must be consumed or skipped and the + // "hash_data_offset_ptr" offset needs to be updated to point to the next + // HashData. If the end of the HashData objects for a given hash value have + // been reached, then "eResultEndOfHashData" should be returned. If + // anything else goes wrong during parsing, return "eResultError" and the + // corresponding "Find()" function will be canceled and return false. + virtual Result GetHashDataForName(llvm::StringRef name, lldb::offset_t *hash_data_offset_ptr, Pair &pair) const = 0; diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h index da981ade78ba1..83d5f519f0862 100644 --- a/include/lldb/Core/Module.h +++ b/include/lldb/Core/Module.h @@ -12,6 +12,7 @@ #include "lldb/Core/Address.h" // for Address #include "lldb/Core/ModuleSpec.h" // for ModuleSpec +#include "lldb/Symbol/ObjectFile.h" // for ObjectFile #include "lldb/Symbol/SymbolContextScope.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/PathMappingList.h" @@ -93,33 +94,30 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class Module Module.h "lldb/Core/Module.h" -/// @brief A class that describes an executable image and its associated +/// A class that describes an executable image and its associated /// object and symbol files. /// /// The module is designed to be able to select a single slice of an -/// executable image as it would appear on disk and during program -/// execution. +/// executable image as it would appear on disk and during program execution. /// /// Modules control when and if information is parsed according to which /// accessors are called. For example the object file (ObjectFile) -/// representation will only be parsed if the object file is requested -/// using the Module::GetObjectFile() is called. The debug symbols -/// will only be parsed if the symbol vendor (SymbolVendor) is -/// requested using the Module::GetSymbolVendor() is called. +/// representation will only be parsed if the object file is requested using +/// the Module::GetObjectFile() is called. The debug symbols will only be +/// parsed if the symbol vendor (SymbolVendor) is requested using the +/// Module::GetSymbolVendor() is called. /// -/// The module will parse more detailed information as more queries are -/// made. +/// The module will parse more detailed information as more queries are made. //---------------------------------------------------------------------- class Module : public std::enable_shared_from_this<Module>, public SymbolContextScope { public: - // Static functions that can track the lifetime of module objects. - // This is handy because we might have Module objects that are in - // shared pointers that aren't in the global module list (from - // ModuleList). If this is the case we need to know about it. - // The modules in the global list maintained by these functions - // can be viewed using the "target modules list" command using the - // "--global" (-g for short). + // Static functions that can track the lifetime of module objects. This is + // handy because we might have Module objects that are in shared pointers + // that aren't in the global module list (from ModuleList). If this is the + // case we need to know about it. The modules in the global list maintained + // by these functions can be viewed using the "target modules list" command + // using the "--global" (-g for short). static size_t GetNumberAllocatedModules(); static Module *GetAllocatedModuleAtIndex(size_t idx); @@ -129,8 +127,8 @@ public: //------------------------------------------------------------------ /// Construct with file specification and architecture. /// - /// Clients that wish to share modules with other targets should - /// use ModuleList::GetSharedModule(). + /// Clients that wish to share modules with other targets should use + /// ModuleList::GetSharedModule(). /// /// @param[in] file_spec /// The file specification for the on disk representation of @@ -158,8 +156,23 @@ public: Module(const ModuleSpec &module_spec); - static lldb::ModuleSP - CreateJITModule(const lldb::ObjectFileJITDelegateSP &delegate_sp); + template <typename ObjFilePlugin, typename... Args> + static lldb::ModuleSP CreateModuleFromObjectFile(Args &&... args) { + // Must create a module and place it into a shared pointer before we can + // create an object file since it has a std::weak_ptr back to the module, + // so we need to control the creation carefully in this static function + lldb::ModuleSP module_sp(new Module()); + module_sp->m_objfile_sp = + std::make_shared<ObjFilePlugin>(module_sp, std::forward<Args>(args)...); + + // 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; + } //------------------------------------------------------------------ /// Destructor. @@ -169,13 +182,13 @@ public: bool MatchesModuleSpec(const ModuleSpec &module_ref); //------------------------------------------------------------------ - /// Set the load address for all sections in a module to be the - /// file address plus \a slide. + /// Set the load address for all sections in a module to be the file address + /// plus \a slide. /// - /// Many times a module will be loaded in a target with a constant - /// offset applied to all top level sections. This function can - /// set the load address for all top level sections to be the - /// section file address + offset. + /// Many times a module will be loaded in a target with a constant offset + /// applied to all top level sections. This function can set the load + /// address for all top level sections to be the section file address + + /// offset. /// /// @param[in] target /// The target in which to apply the section load addresses. @@ -225,19 +238,18 @@ public: //------------------------------------------------------------------ /// Get the module path and object name. /// - /// Modules can refer to object files. In this case the specification - /// is simple and would return the path to the file: + /// Modules can refer to object files. In this case the specification is + /// simple and would return the path to the file: /// /// "/usr/lib/foo.dylib" /// - /// Modules can be .o files inside of a BSD archive (.a file). In - /// this case, the object specification will look like: + /// Modules can be .o files inside of a BSD archive (.a file). In this case, + /// the object specification will look like: /// /// "/usr/lib/foo.a(bar.o)" /// - /// There are many places where logging wants to log this fully - /// qualified specification, so we centralize this functionality - /// here. + /// There are many places where logging wants to log this fully qualified + /// specification, so we centralize this functionality here. /// /// @return /// The object path + object name if there is one. @@ -247,11 +259,10 @@ public: //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// - /// Dump a description of the contents of this object to the - /// supplied stream \a s. The dumped content will be only what has - /// been loaded or parsed up to this point at which this function - /// is called, so this is a good way to see what has been parsed - /// in a module. + /// Dump a description of the contents of this object to the supplied stream + /// \a s. The dumped content will be only what has been loaded or parsed up + /// to this point at which this function is called, so this is a good way to + /// see what has been parsed in a module. /// /// @param[in] s /// The stream to which to dump the object description. @@ -316,8 +327,8 @@ public: //------------------------------------------------------------------ /// Find compile units by partial or full path. /// - /// Finds all compile units that match \a path in all of the modules - /// and returns the results in \a sc_list. + /// Finds all compile units that match \a path in all of the modules and + /// returns the results in \a sc_list. /// /// @param[in] path /// The name of the function we are looking for. @@ -342,8 +353,7 @@ public: /// /// If the function is an inlined function, it will have a block, /// representing the inlined function, and the function will be the - /// containing function. If it is not inlined, then the block will - /// be NULL. + /// containing function. If it is not inlined, then the block will be NULL. /// /// @param[in] name /// The name of the compile unit we are looking for. @@ -379,8 +389,7 @@ public: /// /// If the function is an inlined function, it will have a block, /// representing the inlined function, and the function will be the - /// containing function. If it is not inlined, then the block will - /// be NULL. + /// containing function. If it is not inlined, then the block will be NULL. /// /// @param[in] regex /// A regular expression to use when matching the name. @@ -438,26 +447,19 @@ public: /// @param[in] parent_decl_ctx /// If valid, a decl context that results must exist within /// - /// @param[in] append - /// If \b true, any matches will be appended to \a - /// variable_list, else matches replace the contents of - /// \a variable_list. - /// /// @param[in] max_matches /// Allow the number of matches to be limited to \a /// max_matches. Specify UINT32_MAX to get all possible matches. /// /// @param[in] variable_list - /// A list of variables that gets the matches appended to (if - /// \a append it \b true), or replace (if \a append is \b false). + /// A list of variables that gets the matches appended to. /// /// @return /// The number of matches added to \a variable_list. //------------------------------------------------------------------ size_t FindGlobalVariables(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - bool append, size_t max_matches, - VariableList &variable_list); + size_t max_matches, VariableList &variable_list); //------------------------------------------------------------------ /// Find global and static variables by regular expression. @@ -465,44 +467,36 @@ public: /// @param[in] regex /// A regular expression to use when matching the name. /// - /// @param[in] append - /// If \b true, any matches will be appended to \a - /// variable_list, else matches replace the contents of - /// \a variable_list. - /// /// @param[in] max_matches /// Allow the number of matches to be limited to \a /// max_matches. Specify UINT32_MAX to get all possible matches. /// /// @param[in] variable_list - /// A list of variables that gets the matches appended to (if - /// \a append it \b true), or replace (if \a append is \b false). + /// A list of variables that gets the matches appended to. /// /// @return /// The number of matches added to \a variable_list. //------------------------------------------------------------------ - size_t FindGlobalVariables(const RegularExpression ®ex, bool append, - size_t max_matches, VariableList &variable_list); + size_t FindGlobalVariables(const RegularExpression ®ex, size_t max_matches, + VariableList &variable_list); //------------------------------------------------------------------ /// Find types by name. /// - /// Type lookups in modules go through the SymbolVendor (which will - /// use one or more SymbolFile subclasses). The SymbolFile needs to - /// be able to lookup types by basename and not the fully qualified - /// typename. This allows the type accelerator tables to stay small, - /// even with heavily templatized C++. The type search will then - /// narrow down the search results. If "exact_match" is true, then - /// the type search will only match exact type name matches. If - /// "exact_match" is false, the type will match as long as the base - /// typename matches and as long as any immediate containing - /// namespaces/class scopes that are specified match. So to search - /// for a type "d" in "b::c", the name "b::c::d" can be specified - /// and it will match any class/namespace "b" which contains a - /// class/namespace "c" which contains type "d". We do this to - /// allow users to not always have to specify complete scoping on - /// all expressions, but it also allows for exact matching when - /// required. + /// Type lookups in modules go through the SymbolVendor (which will use one + /// or more SymbolFile subclasses). The SymbolFile needs to be able to + /// lookup types by basename and not the fully qualified typename. This + /// allows the type accelerator tables to stay small, even with heavily + /// templatized C++. The type search will then narrow down the search + /// results. If "exact_match" is true, then the type search will only match + /// exact type name matches. If "exact_match" is false, the type will match + /// as long as the base typename matches and as long as any immediate + /// containing namespaces/class scopes that are specified match. So to + /// search for a type "d" in "b::c", the name "b::c::d" can be specified and + /// it will match any class/namespace "b" which contains a class/namespace + /// "c" which contains type "d". We do this to allow users to not always + /// 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 @@ -535,9 +529,9 @@ public: const ConstString &type_name, bool exact_match); //------------------------------------------------------------------ - /// Find types by name that are in a namespace. This function is - /// used by the expression parser when searches need to happen in - /// an exact namespace scope. + /// Find types by name that are in a namespace. This function is used by the + /// 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 @@ -572,9 +566,9 @@ public: //------------------------------------------------------------------ /// Get const accessor for the module file specification. /// - /// This function returns the file for the module on the host system - /// that is running LLDB. This can differ from the path on the - /// platform since we might be doing remote debugging. + /// This function returns the file for the module on the host system that is + /// running LLDB. This can differ from the path on the platform since we + /// might be doing remote debugging. /// /// @return /// A const reference to the file specification object. @@ -584,14 +578,13 @@ public: //------------------------------------------------------------------ /// Get accessor for the module platform file specification. /// - /// Platform file refers to the path of the module as it is known on - /// the remote system on which it is being debugged. For local - /// debugging this is always the same as Module::GetFileSpec(). But - /// remote debugging might mention a file "/usr/lib/liba.dylib" - /// which might be locally downloaded and cached. In this case the - /// platform file could be something like: - /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib" - /// The file could also be cached in a local developer kit directory. + /// Platform file refers to the path of the module as it is known on the + /// remote system on which it is being debugged. For local debugging this is + /// always the same as Module::GetFileSpec(). But remote debugging might + /// mention a file "/usr/lib/liba.dylib" which might be locally downloaded + /// and cached. In this case the platform file could be something like: + /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib" The + /// file could also be cached in a local developer kit directory. /// /// @return /// A const reference to the file specification object. @@ -631,8 +624,8 @@ public: } //------------------------------------------------------------------ - /// Tells whether this module is capable of being the main executable - /// for a process. + /// Tells whether this module is capable of being the main executable for a + /// process. /// /// @return /// \b true if it is, \b false otherwise. @@ -640,9 +633,9 @@ public: bool IsExecutable(); //------------------------------------------------------------------ - /// Tells whether this module has been loaded in the target passed in. - /// This call doesn't distinguish between whether the module is loaded - /// by the dynamic loader, or by a "target module add" type call. + /// Tells whether this module has been loaded in the target passed in. This + /// call doesn't distinguish between whether the module is loaded by the + /// dynamic loader, or by a "target module add" type call. /// /// @param[in] target /// The target to check whether this is loaded in. @@ -673,9 +666,8 @@ public: //------------------------------------------------------------------ /// Get the object file representation for the current architecture. /// - /// If the object file has not been located or parsed yet, this - /// function will find the best ObjectFile plug-in that can parse - /// Module::m_file. + /// If the object file has not been located or parsed yet, this function + /// will find the best ObjectFile plug-in that can parse Module::m_file. /// /// @return /// If Module::m_file does not exist, or no plug-in was found @@ -688,12 +680,12 @@ public: virtual ObjectFile *GetObjectFile(); //------------------------------------------------------------------ - /// Get the unified section list for the module. This is the section - /// list created by the module's object file and any debug info and - /// symbol files created by the symbol vendor. + /// Get the unified section list for the module. This is the section list + /// created by the module's object file and any debug info and symbol files + /// created by the symbol vendor. /// - /// If the symbol vendor has not been loaded yet, this function - /// will return the section list for the object file. + /// If the symbol vendor has not been loaded yet, this function will return + /// the section list for the object file. /// /// @return /// Unified module section list. @@ -701,27 +693,26 @@ public: virtual SectionList *GetSectionList(); //------------------------------------------------------------------ - /// Notify the module that the file addresses for the Sections have - /// been updated. + /// Notify the module that the file addresses for the Sections have been + /// updated. /// - /// If the Section file addresses for a module are updated, this - /// method should be called. Any parts of the module, object file, - /// or symbol file that has cached those file addresses must invalidate - /// or update its cache. + /// If the Section file addresses for a module are updated, this method + /// should be called. Any parts of the module, object file, or symbol file + /// that has cached those file addresses must invalidate or update its + /// cache. //------------------------------------------------------------------ virtual void SectionFileAddressesChanged(); - uint32_t GetVersion(uint32_t *versions, uint32_t num_versions); + llvm::VersionTuple GetVersion(); //------------------------------------------------------------------ /// Load an object file from memory. /// - /// If available, the size of the object file in memory may be - /// passed to avoid additional round trips to process memory. - /// If the size is not provided, a default value is used. This - /// value should be large enough to enable the ObjectFile plugins - /// to read the header of the object file without going back to the - /// process. + /// If available, the size of the object file in memory may be passed to + /// avoid additional round trips to process memory. If the size is not + /// provided, a default value is used. This value should be large enough to + /// enable the ObjectFile plugins to read the header of the object file + /// without going back to the process. /// /// @return /// The object file loaded from memory or nullptr, if the operation @@ -733,9 +724,8 @@ public: //------------------------------------------------------------------ /// Get the symbol vendor interface for the current architecture. /// - /// If the symbol vendor file has not been located yet, this - /// function will find the best SymbolVendor plug-in that can - /// use the current object file. + /// If the symbol vendor file has not been located yet, this function will + /// find the best SymbolVendor plug-in that can use the current object file. /// /// @return /// If this module does not have a valid object file, or no @@ -758,11 +748,11 @@ public: TypeList *GetTypeList(); //------------------------------------------------------------------ - /// Get a pointer to the UUID value contained in this object. + /// Get a reference to the UUID value contained in this object. /// - /// If the executable image file doesn't not have a UUID value built - /// into the file format, an MD5 checksum of the entire file, or - /// slice of the file for the current architecture should be used. + /// If the executable image file doesn't not have a UUID value built into + /// the file format, an MD5 checksum of the entire file, or slice of the + /// file for the current architecture should be used. /// /// @return /// A const pointer to the internal copy of the UUID value in @@ -775,14 +765,13 @@ public: /// A debugging function that will cause everything in a module to /// be parsed. /// - /// All compile units will be parsed, along with all globals and - /// static variables and all functions for those compile units. - /// All types, scopes, local variables, static variables, global - /// variables, and line tables will be parsed. This can be used - /// prior to dumping a module to see a complete list of the - /// resulting debug information that gets parsed, or as a debug - /// function to ensure that the module can consume all of the - /// debug data the symbol vendor provides. + /// All compile units will be parsed, along with all globals and static + /// variables and all functions for those compile units. All types, scopes, + /// local variables, static variables, global variables, and line tables + /// will be parsed. This can be used prior to dumping a module to see a + /// complete list of the resulting debug information that gets parsed, or as + /// a debug function to ensure that the module can consume all of the debug + /// data the symbol vendor provides. //------------------------------------------------------------------ void ParseAllDebugSymbols(); @@ -791,17 +780,16 @@ public: //------------------------------------------------------------------ /// Resolve the symbol context for the given address. /// - /// Tries to resolve the matching symbol context based on a lookup - /// from the current symbol vendor. If the lazy lookup fails, - /// an attempt is made to parse the eh_frame section to handle - /// stripped symbols. If this fails, an attempt is made to resolve - /// the symbol to the previous address to handle the case of a - /// function with a tail call. + /// Tries to resolve the matching symbol context based on a lookup from the + /// current symbol vendor. If the lazy lookup fails, an attempt is made to + /// parse the eh_frame section to handle stripped symbols. If this fails, + /// an attempt is made to resolve the symbol to the previous address to + /// handle the case of a function with a tail call. /// - /// Use properties of the modified SymbolContext to inspect any - /// resolved target, module, compilation unit, symbol, function, - /// function block or line entry. Use the return value to determine - /// which of these properties have been modified. + /// Use properties of the modified SymbolContext to inspect any resolved + /// target, module, compilation unit, symbol, function, function block or + /// line entry. Use the return value to determine which of these properties + /// have been modified. /// /// @param[in] so_addr /// A load address to resolve. @@ -836,15 +824,14 @@ public: //------------------------------------------------------------------ /// Resolve items in the symbol context for a given file and line. /// - /// Tries to resolve \a file_path and \a line to a list of matching - /// symbol contexts. + /// Tries to resolve \a file_path and \a line to a list of matching symbol + /// contexts. /// - /// The line table entries contains addresses that can be used to - /// further resolve the values in each match: the function, block, - /// symbol. Care should be taken to minimize the amount of - /// information that is requested to only what is needed -- - /// typically the module, compile unit, line table and line table - /// entry are sufficient. + /// The line table entries contains addresses that can be used to further + /// resolve the values in each match: the function, block, symbol. Care + /// should be taken to minimize the amount of information that is requested + /// to only what is needed -- typically the module, compile unit, line table + /// and line table entry are sufficient. /// /// @param[in] file_path /// A path to a source file to match. If \a file_path does not @@ -883,15 +870,14 @@ public: //------------------------------------------------------------------ /// Resolve items in the symbol context for a given file and line. /// - /// Tries to resolve \a file_spec and \a line to a list of matching - /// symbol contexts. + /// Tries to resolve \a file_spec and \a line to a list of matching symbol + /// contexts. /// - /// The line table entries contains addresses that can be used to - /// further resolve the values in each match: the function, block, - /// symbol. Care should be taken to minimize the amount of - /// information that is requested to only what is needed -- - /// typically the module, compile unit, line table and line table - /// entry are sufficient. + /// The line table entries contains addresses that can be used to further + /// resolve the values in each match: the function, block, symbol. Care + /// should be taken to minimize the amount of information that is requested + /// to only what is needed -- typically the module, compile unit, line table + /// and line table entry are sufficient. /// /// @param[in] file_spec /// A file spec to a source file to match. If \a file_path does @@ -936,12 +922,10 @@ public: TypeSystem *GetTypeSystemForLanguage(lldb::LanguageType language); // Special error functions that can do printf style formatting that will - // prepend the message with - // something appropriate for this module (like the architecture, path and - // object name (if any)). - // This centralizes code so that everyone doesn't need to format their error - // and log messages on - // their own and keeps the output a bit more consistent. + // prepend the message with something appropriate for this module (like the + // architecture, path and object name (if any)). This centralizes code so + // that everyone doesn't need to format their error and log messages on their + // own and keeps the output a bit more consistent. void LogMessage(Log *log, const char *format, ...) __attribute__((format(printf, 3, 4))); @@ -960,15 +944,15 @@ public: __attribute__((format(printf, 2, 3))); //------------------------------------------------------------------ - // Return true if the file backing this module has changed since the - // module was originally created since we saved the initial file - // modification time when the module first gets created. + // Return true if the file backing this module has changed since the module + // was originally created since we saved the initial file modification time + // when the module first gets created. //------------------------------------------------------------------ bool FileHasChanged() const; //------------------------------------------------------------------ - // SymbolVendor, SymbolFile and ObjectFile member objects should - // lock the module mutex to avoid deadlocks. + // SymbolVendor, SymbolFile and ObjectFile member objects should lock the + // module mutex to avoid deadlocks. //------------------------------------------------------------------ std::recursive_mutex &GetMutex() const { return m_mutex; } @@ -979,14 +963,13 @@ public: } //------------------------------------------------------------------ - /// Finds a source file given a file spec using the module source - /// path remappings (if any). + /// Finds a source file given a file spec using the module source path + /// remappings (if any). /// /// Tries to resolve \a orig_spec by checking the module source path - /// remappings. It makes sure the file exists, so this call can be - /// expensive if the remappings are on a network file system, so - /// use this function sparingly (not in a tight debug info parsing - /// loop). + /// remappings. It makes sure the file exists, so this call can be expensive + /// if the remappings are on a network file system, so use this function + /// sparingly (not in a tight debug info parsing loop). /// /// @param[in] orig_spec /// The original source file path to try and remap. @@ -1004,9 +987,9 @@ public: //------------------------------------------------------------------ /// Remaps a source file given \a path into \a new_path. /// - /// Remaps \a path if any source remappings match. This function - /// does NOT stat the file system so it can be used in tight loops - /// where debug info is being parsed. + /// Remaps \a path if any source remappings match. This function does NOT + /// stat the file system so it can be used in tight loops where debug info + /// is being parsed. /// /// @param[in] path /// The original source file path to try and remap. @@ -1021,43 +1004,28 @@ public: bool RemapSourceFile(llvm::StringRef path, std::string &new_path) const; bool RemapSourceFile(const char *, std::string &) const = delete; - //------------------------------------------------------------------ - /// Loads this module to memory. - /// - /// Loads the bits needed to create an executable image to the memory. - /// It is useful with bare-metal targets where target does not have the - /// ability to start a process itself. - /// - /// @param[in] target - /// Target where to load the module. - /// - /// @return - //------------------------------------------------------------------ - Status LoadInMemory(Target &target, bool set_pc); - //---------------------------------------------------------------------- /// @class LookupInfo Module.h "lldb/Core/Module.h" - /// @brief A class that encapsulates name lookup information. + /// A class that encapsulates name lookup information. /// - /// Users can type a wide variety of partial names when setting - /// breakpoints by name or when looking for functions by name. - /// SymbolVendor and SymbolFile objects are only required to implement - /// name lookup for function basenames and for fully mangled names. - /// This means if the user types in a partial name, we must reduce this - /// to a name lookup that will work with all SymbolFile objects. So we - /// might reduce a name lookup to look for a basename, and then prune - /// out any results that don't match. + /// Users can type a wide variety of partial names when setting breakpoints + /// by name or when looking for functions by name. SymbolVendor and + /// SymbolFile objects are only required to implement name lookup for + /// function basenames and for fully mangled names. This means if the user + /// types in a partial name, we must reduce this to a name lookup that will + /// work with all SymbolFile objects. So we might reduce a name lookup to + /// look for a basename, and then prune out any results that don't match. /// - /// The "m_name" member variable represents the name as it was typed - /// by the user. "m_lookup_name" will be the name we actually search - /// for through the symbol or objects files. Lanaguage is included in - /// case we need to filter results by language at a later date. The - /// "m_name_type_mask" member variable tells us what kinds of names we - /// are looking for and can help us prune out unwanted results. + /// The "m_name" member variable represents the name as it was typed by the + /// user. "m_lookup_name" will be the name we actually search for through + /// the symbol or objects files. Lanaguage is included in case we need to + /// filter results by language at a later date. The "m_name_type_mask" + /// member variable tells us what kinds of names we are looking for and can + /// help us prune out unwanted results. /// /// Function lookups are done in Module.cpp, ModuleList.cpp and in - /// BreakpointResolverName.cpp and they all now use this class to do - /// lookups correctly. + /// BreakpointResolverName.cpp and they all now use this class to do lookups + /// correctly. //---------------------------------------------------------------------- class LookupInfo { public: @@ -1146,7 +1114,7 @@ protected: std::atomic<bool> m_did_load_objfile{false}; std::atomic<bool> m_did_load_symbol_vendor{false}; - std::atomic<bool> m_did_parse_uuid{false}; + std::atomic<bool> m_did_set_uuid{false}; mutable bool m_file_has_changed : 1, m_first_file_changed_log : 1; /// See if the module was modified after it /// was initially opened. @@ -1156,9 +1124,9 @@ protected: /// /// Tries to resolve \a vm_addr as a file address (if \a /// vm_addr_is_file_addr is true) or as a load address if \a - /// vm_addr_is_file_addr is false) in the symbol vendor. - /// \a resolve_scope indicates what clients wish to resolve - /// and can be used to limit the scope of what is parsed. + /// vm_addr_is_file_addr is false) in the symbol vendor. \a resolve_scope + /// indicates what clients wish to resolve and can be used to limit the + /// scope of what is parsed. /// /// @param[in] vm_addr /// The load virtual address to resolve. @@ -1196,6 +1164,8 @@ protected: bool SetArchitecture(const ArchSpec &new_arch); + void SetUUID(const lldb_private::UUID &uuid); + SectionList *GetUnifiedSectionList(); friend class ModuleList; diff --git a/include/lldb/Core/ModuleChild.h b/include/lldb/Core/ModuleChild.h index 8f2985c8185b2..73438040c3595 100644 --- a/include/lldb/Core/ModuleChild.h +++ b/include/lldb/Core/ModuleChild.h @@ -16,7 +16,7 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class ModuleChild ModuleChild.h "lldb/Core/ModuleChild.h" -/// @brief A mix in class that contains a pointer back to the module +/// A mix in class that contains a pointer back to the module /// that owns the object which inherits from it. //---------------------------------------------------------------------- class ModuleChild { diff --git a/include/lldb/Core/ModuleList.h b/include/lldb/Core/ModuleList.h index 4b637c9b0427c..e1d8a9a7fb859 100644 --- a/include/lldb/Core/ModuleList.h +++ b/include/lldb/Core/ModuleList.h @@ -12,6 +12,7 @@ #include "lldb/Core/Address.h" // for Address #include "lldb/Core/ModuleSpec.h" // for ModuleSpec +#include "lldb/Core/UserSettingsController.h" #include "lldb/Utility/FileSpec.h" // for FileSpec #include "lldb/Utility/Iterable.h" #include "lldb/Utility/Status.h" // for Status @@ -74,12 +75,21 @@ class VariableList; namespace lldb_private { +class ModuleListProperties : public Properties { +public: + ModuleListProperties(); + + FileSpec GetClangModulesCachePath() const; + bool SetClangModulesCachePath(llvm::StringRef path); + bool GetEnableExternalLookup() const; +}; + //---------------------------------------------------------------------- /// @class ModuleList ModuleList.h "lldb/Core/ModuleList.h" -/// @brief A collection class for Module objects. +/// A collection class for Module objects. /// -/// Modules in the module collection class are stored as reference -/// counted shared pointers to Module objects. +/// Modules in the module collection class are stored as reference counted +/// shared pointers to Module objects. //---------------------------------------------------------------------- class ModuleList { public: @@ -107,8 +117,7 @@ public: //------------------------------------------------------------------ /// Copy Constructor. /// - /// Creates a new module list object with a copy of the modules from - /// \a rhs. + /// Creates a new module list object with a copy of the modules from \a rhs. /// /// @param[in] rhs /// Another module list object. @@ -146,9 +155,9 @@ public: void Append(const lldb::ModuleSP &module_sp); //------------------------------------------------------------------ - /// Append a module to the module list and remove any equivalent - /// modules. Equivalent modules are ones whose file, platform file - /// and architecture matches. + /// Append a module to the module list and remove any equivalent modules. + /// Equivalent modules are ones whose file, platform file and architecture + /// matches. /// /// Replaces the module to the collection. /// @@ -169,27 +178,27 @@ public: //------------------------------------------------------------------ /// Clear the object's state. /// - /// Clears the list of modules and releases a reference to each - /// module object and if the reference count goes to zero, the - /// module will be deleted. + /// Clears the list of modules and releases a reference to each module + /// object and if the reference count goes to zero, the module will be + /// deleted. //------------------------------------------------------------------ void Clear(); //------------------------------------------------------------------ /// Clear the object's state. /// - /// Clears the list of modules and releases a reference to each - /// module object and if the reference count goes to zero, the - /// module will be deleted. Also release all memory that might be - /// held by any collection classes (like std::vector) + /// Clears the list of modules and releases a reference to each module + /// object and if the reference count goes to zero, the module will be + /// deleted. Also release all memory that might be held by any collection + /// classes (like std::vector) //------------------------------------------------------------------ void Destroy(); //------------------------------------------------------------------ /// Dump the description of each module contained in this list. /// - /// Dump the description of each module contained in this list to - /// the supplied stream \a s. + /// Dump the description of each module contained in this list to the + /// supplied stream \a s. /// /// @param[in] s /// The stream to which to dump the object description. @@ -220,8 +229,8 @@ public: //------------------------------------------------------------------ /// Get the module shared pointer for the module at index \a idx without - /// acquiring the ModuleList mutex. This MUST already have been - /// acquired with ModuleList::GetMutex and locked for this call to be safe. + /// acquiring the ModuleList mutex. This MUST already have been acquired + /// with ModuleList::GetMutex and locked for this call to be safe. /// /// @param[in] idx /// An index into this module collection. @@ -249,9 +258,9 @@ public: Module *GetModulePointerAtIndex(size_t idx) const; //------------------------------------------------------------------ - /// Get the module pointer for the module at index \a idx without - /// acquiring the ModuleList mutex. This MUST already have been - /// acquired with ModuleList::GetMutex and locked for this call to be safe. + /// Get the module pointer for the module at index \a idx without acquiring + /// the ModuleList mutex. This MUST already have been acquired with + /// ModuleList::GetMutex and locked for this call to be safe. /// /// @param[in] idx /// An index into this module collection. @@ -267,8 +276,8 @@ public: //------------------------------------------------------------------ /// Find compile units by partial or full path. /// - /// Finds all compile units that match \a path in all of the modules - /// and returns the results in \a sc_list. + /// Finds all compile units that match \a path in all of the modules and + /// returns the results in \a sc_list. /// /// @param[in] path /// The name of the compile unit we are looking for. @@ -315,24 +324,17 @@ public: /// The name of the global or static variable we are looking /// for. /// - /// @param[in] append - /// If \b true, any matches will be appended to \a - /// variable_list, else matches replace the contents of - /// \a variable_list. - /// /// @param[in] max_matches /// Allow the number of matches to be limited to \a /// max_matches. Specify UINT32_MAX to get all possible matches. /// /// @param[in] variable_list - /// A list of variables that gets the matches appended to (if - /// \a append it \b true), or replace (if \a append is \b false). + /// A list of variables that gets the matches appended to. /// /// @return /// The number of matches added to \a variable_list. //------------------------------------------------------------------ - size_t FindGlobalVariables(const ConstString &name, bool append, - size_t max_matches, + size_t FindGlobalVariables(const ConstString &name, size_t max_matches, VariableList &variable_list) const; //------------------------------------------------------------------ @@ -341,29 +343,21 @@ public: /// @param[in] regex /// A regular expression to use when matching the name. /// - /// @param[in] append - /// If \b true, any matches will be appended to \a - /// variable_list, else matches replace the contents of - /// \a variable_list. - /// /// @param[in] max_matches /// Allow the number of matches to be limited to \a /// max_matches. Specify UINT32_MAX to get all possible matches. /// /// @param[in] variable_list - /// A list of variables that gets the matches appended to (if - /// \a append it \b true), or replace (if \a append is \b false). + /// A list of variables that gets the matches appended to. /// /// @return /// The number of matches added to \a variable_list. //------------------------------------------------------------------ - size_t FindGlobalVariables(const RegularExpression ®ex, bool append, - size_t max_matches, + size_t FindGlobalVariables(const RegularExpression ®ex, size_t max_matches, VariableList &variable_list) const; //------------------------------------------------------------------ - /// Finds the first module whose file specification matches \a - /// file_spec. + /// Finds the first module whose file specification matches \a file_spec. /// /// @param[in] file_spec_ptr /// A file specification object to match against the Module's @@ -400,9 +394,9 @@ public: //------------------------------------------------------------------ // Find a module by UUID // - // The UUID value for a module is extracted from the ObjectFile and - // is the MD5 checksum, or a smarter object file equivalent, so - // finding modules by UUID values is very efficient and accurate. + // The UUID value for a module is extracted from the ObjectFile and is the + // MD5 checksum, or a smarter object file equivalent, so finding modules by + // UUID values is very efficient and accurate. //------------------------------------------------------------------ lldb::ModuleSP FindModule(const UUID &uuid) const; @@ -534,6 +528,8 @@ public: Stream *feedback_stream = nullptr, bool continue_on_error = true); + static ModuleListProperties &GetGlobalModuleListProperties(); + static bool ModuleIsInCache(const Module *module_ptr); static Status GetSharedModule(const ModuleSpec &module_spec, @@ -551,7 +547,7 @@ public: static size_t RemoveOrphanSharedModules(bool mandatory); static bool RemoveSharedModuleIfOrphaned(const Module *module_ptr); - + void ForEach(std::function<bool(const lldb::ModuleSP &module_sp)> const &callback) const; diff --git a/include/lldb/Core/ModuleSpec.h b/include/lldb/Core/ModuleSpec.h index cc95bd0a06385..16a35a1877801 100644 --- a/include/lldb/Core/ModuleSpec.h +++ b/include/lldb/Core/ModuleSpec.h @@ -34,9 +34,9 @@ public: m_object_name(), m_object_offset(0), m_object_size(0), m_source_mappings() {} - ModuleSpec(const FileSpec &file_spec) + ModuleSpec(const FileSpec &file_spec, const UUID& uuid = UUID()) : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(), - m_uuid(), m_object_name(), m_object_offset(0), + m_uuid(uuid), m_object_name(), m_object_offset(0), m_object_size(file_spec.GetByteSize()), m_source_mappings() {} ModuleSpec(const FileSpec &file_spec, const ArchSpec &arch) @@ -341,8 +341,8 @@ public: m_specs.insert(m_specs.end(), rhs.m_specs.begin(), rhs.m_specs.end()); } - // The index "i" must be valid and this can't be used in - // multi-threaded code as no mutex lock is taken. + // The index "i" must be valid and this can't be used in multi-threaded code + // as no mutex lock is taken. ModuleSpec &GetModuleSpecRefAtIndex(size_t i) { return m_specs[i]; } bool GetModuleSpecAtIndex(size_t i, ModuleSpec &module_spec) const { diff --git a/include/lldb/Core/PluginManager.h b/include/lldb/Core/PluginManager.h index 68e6ca20b2662..b782294f1f607 100644 --- a/include/lldb/Core/PluginManager.h +++ b/include/lldb/Core/PluginManager.h @@ -477,11 +477,11 @@ public: const ConstString &name); //------------------------------------------------------------------ - // Some plug-ins might register a DebuggerInitializeCallback - // callback when registering the plug-in. After a new Debugger - // instance is created, this DebuggerInitialize function will get - // called. This allows plug-ins to install Properties and do any - // other initialization that requires a debugger instance. + // Some plug-ins might register a DebuggerInitializeCallback callback when + // registering the plug-in. After a new Debugger instance is created, this + // DebuggerInitialize function will get called. This allows plug-ins to + // install Properties and do any other initialization that requires a + // debugger instance. //------------------------------------------------------------------ static void DebuggerInitialize(Debugger &debugger); diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Core/RangeMap.h index 91fd409fb4eda..45bda26e26592 100644 --- a/include/lldb/Core/RangeMap.h +++ b/include/lldb/Core/RangeMap.h @@ -27,9 +27,8 @@ namespace lldb_private { //---------------------------------------------------------------------- -// Templatized classes for dealing with generic ranges and also -// collections of ranges, or collections of ranges that have associated -// data. +// Templatized classes for dealing with generic ranges and also collections of +// ranges, or collections of ranges that have associated data. //---------------------------------------------------------------------- //---------------------------------------------------------------------- @@ -214,8 +213,8 @@ public: 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 + // 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); } @@ -228,8 +227,8 @@ public: #endif if (m_entries.empty()) return fail_value; - // m_entries must be sorted, so if we aren't empty, we grab the - // first range's base + // m_entries must be sorted, so if we aren't empty, we grab the first + // range's base return m_entries.front().GetRangeBase(); } @@ -239,8 +238,8 @@ public: #endif if (m_entries.empty()) return fail_value; - // m_entries must be sorted, so if we aren't empty, we grab the - // last range's end + // m_entries must be sorted, so if we aren't empty, we grab the last + // range's end return m_entries.back().GetRangeEnd(); } @@ -446,8 +445,8 @@ public: 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 + // 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); } @@ -460,8 +459,8 @@ public: #endif if (m_entries.empty()) return fail_value; - // m_entries must be sorted, so if we aren't empty, we grab the - // first range's base + // m_entries must be sorted, so if we aren't empty, we grab the first + // range's base return m_entries.front().GetRangeBase(); } @@ -471,8 +470,8 @@ public: #endif if (m_entries.empty()) return fail_value; - // m_entries must be sorted, so if we aren't empty, we grab the - // last range's end + // m_entries must be sorted, so if we aren't empty, we grab the last + // range's end return m_entries.back().GetRangeEnd(); } @@ -604,8 +603,8 @@ protected: //---------------------------------------------------------------------- // A simple range with data class where you get to define the type of -// the range base "B", the type used for the range byte size "S", and -// the type for the associated data "T". +// the range base "B", the type used for the range byte size "S", and the type +// for the associated data "T". //---------------------------------------------------------------------- template <typename B, typename S, typename T> struct RangeData : public Range<B, S> { @@ -688,8 +687,8 @@ public: } } - // We we can combine at least one entry, then we make a new collection - // and populate it accordingly, and then swap it into place. + // 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; @@ -699,9 +698,9 @@ public: 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. + // 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); } } @@ -828,8 +827,8 @@ protected: Collection m_entries; }; -// Same as RangeDataArray, but uses std::vector as to not -// require static storage of N items in the class itself +// 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; @@ -878,8 +877,8 @@ public: } } - // We we can combine at least one entry, then we make a new collection - // and populate it accordingly, and then swap it into place. + // 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; @@ -889,15 +888,15 @@ public: 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. + // 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); } } - // Calculate the byte size of ranges with zero byte sizes by finding - // the next entry with a base address > the current base address + // 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()); @@ -907,9 +906,9 @@ public: 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 + // 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(); @@ -1060,8 +1059,8 @@ public: } // This method will return the entry that contains the given address, or the - // entry following that address. If you give it an address of 0 and the first - // entry starts at address 0x100, you will get the entry at 0x100. + // entry following that address. If you give it an address of 0 and the + // first entry starts at address 0x100, you will get the entry at 0x100. // // For most uses, FindEntryThatContains is the correct one to use, this is a // less commonly needed behavior. It was added for core file memory regions, @@ -1102,8 +1101,8 @@ protected: //---------------------------------------------------------------------- // A simple range with data class where you get to define the type of -// the range base "B", the type used for the range byte size "S", and -// the type for the associated data "T". +// the range base "B", the type used for the range byte size "S", and the type +// for the associated data "T". //---------------------------------------------------------------------- template <typename B, typename T> struct AddressData { typedef B BaseType; diff --git a/include/lldb/Core/RegisterValue.h b/include/lldb/Core/RegisterValue.h index a45db00fb76ed..b369c3dff9a95 100644 --- a/include/lldb/Core/RegisterValue.h +++ b/include/lldb/Core/RegisterValue.h @@ -35,7 +35,7 @@ namespace lldb_private { class RegisterValue { public: - enum { kMaxRegisterByteSize = 32u }; + enum { kMaxRegisterByteSize = 64u }; enum Type { eTypeInvalid, @@ -95,14 +95,13 @@ public: bool GetData(DataExtractor &data) const; - // Copy the register value from this object into a buffer in "dst" - // and obey the "dst_byte_order" when copying the data. Also watch out - // in case "dst_len" is longer or shorter than the register value - // described by "reg_info" and only copy the least significant bytes - // of the register value, or pad the destination with zeroes if the - // register byte size is shorter that "dst_len" (all while correctly - // abiding the "dst_byte_order"). Returns the number of bytes copied - // into "dst". + // Copy the register value from this object into a buffer in "dst" and obey + // the "dst_byte_order" when copying the data. Also watch out in case + // "dst_len" is longer or shorter than the register value described by + // "reg_info" and only copy the least significant bytes of the register + // value, or pad the destination with zeroes if the register byte size is + // shorter that "dst_len" (all while correctly abiding the "dst_byte_order"). + // Returns the number of bytes copied into "dst". uint32_t GetAsMemoryData(const RegisterInfo *reg_info, void *dst, uint32_t dst_len, lldb::ByteOrder dst_byte_order, Status &error) const; @@ -249,12 +248,6 @@ public: Status SetValueFromData(const RegisterInfo *reg_info, DataExtractor &data, lldb::offset_t offset, bool partial_data_ok); - // The default value of 0 for reg_name_right_align_at means no alignment at - // all. - bool Dump(Stream *s, const RegisterInfo *reg_info, bool prefix_with_name, - bool prefix_with_alt_name, lldb::Format format, - uint32_t reg_name_right_align_at = 0) const; - const void *GetBytes() const; lldb::ByteOrder GetByteOrder() const { diff --git a/include/lldb/Core/STLUtils.h b/include/lldb/Core/STLUtils.h index d851ed5464c9d..55f1ac05c975e 100644 --- a/include/lldb/Core/STLUtils.h +++ b/include/lldb/Core/STLUtils.h @@ -40,8 +40,8 @@ struct CStringEqualBinaryPredicate { }; //---------------------------------------------------------------------- -// Templated type for finding an entry in a std::map<F,S> whose value -// is equal to something +// Templated type for finding an entry in a std::map<F,S> whose value is equal +// to something //---------------------------------------------------------------------- template <class F, class S> class ValueEquals { public: diff --git a/include/lldb/Core/Scalar.h b/include/lldb/Core/Scalar.h index 943398b88020c..40671a242ec3f 100644 --- a/include/lldb/Core/Scalar.h +++ b/include/lldb/Core/Scalar.h @@ -36,9 +36,9 @@ namespace lldb_private { //---------------------------------------------------------------------- // A class designed to hold onto values and their corresponding types. -// Operators are defined and Scalar objects will correctly promote -// their types and values before performing these operations. Type -// promotion currently follows the ANSI C type promotion rules. +// Operators are defined and Scalar objects will correctly promote their types +// and values before performing these operations. Type promotion currently +// follows the ANSI C type promotion rules. //---------------------------------------------------------------------- class Scalar { public: @@ -50,13 +50,13 @@ public: e_ulong, e_slonglong, e_ulonglong, - e_float, - e_double, - e_long_double, - e_uint128, e_sint128, + e_uint128, + e_sint256, e_uint256, - e_sint256 + e_float, + e_double, + e_long_double }; //------------------------------------------------------------------ @@ -165,8 +165,6 @@ public: bool Promote(Scalar::Type type); - bool Cast(Scalar::Type type); - bool MakeSigned(); bool MakeUnsigned(); @@ -182,10 +180,10 @@ public: static Scalar::Type GetValueTypeForFloatWithByteSize(size_t byte_size); //---------------------------------------------------------------------- - // All operators can benefits from the implicit conversions that will - // happen automagically by the compiler, so no temporary objects will - // need to be created. As a result, we currently don't need a variety of - // overloaded set value accessors. + // All operators can benefits from the implicit conversions that will happen + // automagically by the compiler, so no temporary objects will need to be + // created. As a result, we currently don't need a variety of overloaded set + // value accessors. //---------------------------------------------------------------------- Scalar &operator=(const int i); Scalar &operator=(unsigned int v); @@ -204,27 +202,27 @@ public: Scalar &operator&=(const Scalar &rhs); //---------------------------------------------------------------------- - // Shifts the current value to the right without maintaining the current - // sign of the value (if it is signed). + // Shifts the current value to the right without maintaining the current sign + // of the value (if it is signed). //---------------------------------------------------------------------- bool ShiftRightLogical(const Scalar &rhs); // Returns true on success //---------------------------------------------------------------------- - // Takes the absolute value of the current value if it is signed, else - // the value remains unchanged. - // Returns false if the contained value has a void type. + // Takes the absolute value of the current value if it is signed, else the + // value remains unchanged. Returns false if the contained value has a void + // type. //---------------------------------------------------------------------- bool AbsoluteValue(); // Returns true on success //---------------------------------------------------------------------- - // Negates the current value (even for unsigned values). - // Returns false if the contained value has a void type. + // Negates the current value (even for unsigned values). Returns false if the + // contained value has a void type. //---------------------------------------------------------------------- bool UnaryNegate(); // Returns true on success //---------------------------------------------------------------------- - // Inverts all bits in the current value as long as it isn't void or - // a float/double/long double type. - // Returns false if the contained value has a void/float/double/long - // double type, else the value is inverted and true is returned. + // Inverts all bits in the current value as long as it isn't void or a + // float/double/long double type. Returns false if the contained value has a + // void/float/double/long double type, else the value is inverted and true is + // returned. //---------------------------------------------------------------------- bool OnesComplement(); // Returns true on success @@ -234,9 +232,9 @@ public: Scalar::Type GetType() const { return m_type; } //---------------------------------------------------------------------- - // Returns a casted value of the current contained data without - // modifying the current value. FAIL_VALUE will be returned if the type - // of the value is void or invalid. + // Returns a casted value of the current contained data without modifying the + // current value. FAIL_VALUE will be returned if the type of the value is + // void or invalid. //---------------------------------------------------------------------- int SInt(int fail_value = 0) const; @@ -344,8 +342,8 @@ private: }; //---------------------------------------------------------------------- -// Split out the operators into a format where the compiler will be able -// to implicitly convert numbers into Scalar objects. +// Split out the operators into a format where the compiler will be able to +// implicitly convert numbers into Scalar objects. // // This allows code like: // Scalar two(2); diff --git a/include/lldb/Core/SearchFilter.h b/include/lldb/Core/SearchFilter.h index 5861afc801cb7..2e641983dc737 100644 --- a/include/lldb/Core/SearchFilter.h +++ b/include/lldb/Core/SearchFilter.h @@ -52,9 +52,9 @@ class Target; namespace lldb_private { //---------------------------------------------------------------------- -/// @class Searcher SearchFilter.h "lldb/Core/SearchFilter.h" -/// @brief Class that is driven by the SearchFilter to search the -/// SymbolContext space of the target program. +/// @class Searcher SearchFilter.h "lldb/Core/SearchFilter.h" Class that is +/// driven by the SearchFilter to search the SymbolContext space of the target +/// program. //---------------------------------------------------------------------- //---------------------------------------------------------------------- @@ -99,10 +99,10 @@ public: }; //---------------------------------------------------------------------- -/// @class SearchFilter SearchFilter.h "lldb/Core/SearchFilter.h" -/// @brief Class descends through the SymbolContext space of the target, -/// applying a filter at each stage till it reaches the depth specified by -/// the GetDepth method of the searcher, and calls its callback at that point. +/// @class SearchFilter SearchFilter.h "lldb/Core/SearchFilter.h" Class +/// descends through the SymbolContext space of the target, applying a filter +/// at each stage till it reaches the depth specified by the GetDepth method +/// of the searcher, and calls its callback at that point. //---------------------------------------------------------------------- //---------------------------------------------------------------------- @@ -110,15 +110,12 @@ public: /// Provides the callback and search depth for the SearchFilter search. /// /// The search is done by cooperation between the search filter and the -/// searcher. -/// The search filter does the heavy work of recursing through the SymbolContext -/// space of the target program's symbol space. The Searcher specifies the -/// depth -/// at which it wants its callback to be invoked. Note that since the -/// resolution -/// of the Searcher may be greater than that of the SearchFilter, before the -/// Searcher qualifies an address it should pass it to "AddressPasses." -/// The default implementation is "Everything Passes." +/// searcher. The search filter does the heavy work of recursing through the +/// SymbolContext space of the target program's symbol space. The Searcher +/// specifies the depth at which it wants its callback to be invoked. Note +/// that since the resolution of the Searcher may be greater than that of the +/// SearchFilter, before the Searcher qualifies an address it should pass it +/// to "AddressPasses." The default implementation is "Everything Passes." //---------------------------------------------------------------------- class SearchFilter { @@ -172,8 +169,8 @@ public: virtual bool AddressPasses(Address &addr); //------------------------------------------------------------------ - /// Call this method with a FileSpec to see if \a file spec passes the filter - /// as the name of a compilation unit. + /// Call this method with a FileSpec to see if \a file spec passes the + /// filter as the name of a compilation unit. /// /// @param[in] fileSpec /// The file spec to check against the filter. @@ -218,11 +215,10 @@ public: virtual void SearchInModuleList(Searcher &searcher, ModuleList &modules); //------------------------------------------------------------------ - /// This determines which items are REQUIRED for the filter to pass. - /// For instance, if you are filtering by Compilation Unit, obviously - /// symbols that have no compilation unit can't pass So return - /// eSymbolContextCU - /// and search callbacks can then short cut the search to avoid looking at + /// This determines which items are REQUIRED for the filter to pass. For + /// instance, if you are filtering by Compilation Unit, obviously symbols + /// that have no compilation unit can't pass So return eSymbolContextCU and + /// search callbacks can then short cut the search to avoid looking at /// things that obviously won't pass. /// /// @return @@ -303,8 +299,7 @@ protected: OptionNames name, FileSpecList &file_list); // These are utility functions to assist with the search iteration. They are - // used by the - // default Search method. + // used by the default Search method. Searcher::CallbackReturn DoModuleIteration(const SymbolContext &context, Searcher &searcher); @@ -333,9 +328,9 @@ private: //---------------------------------------------------------------------- /// @class SearchFilterForUnconstrainedSearches SearchFilter.h -/// "lldb/Core/SearchFilter.h" -/// @brief This is a SearchFilter that searches through all modules. It also -/// consults the Target::ModuleIsExcludedForUnconstrainedSearches. +/// "lldb/Core/SearchFilter.h" This is a SearchFilter that searches through +/// all modules. It also consults the +/// Target::ModuleIsExcludedForUnconstrainedSearches. //---------------------------------------------------------------------- class SearchFilterForUnconstrainedSearches : public SearchFilter { public: @@ -360,8 +355,8 @@ protected: }; //---------------------------------------------------------------------- -/// @class SearchFilterByModule SearchFilter.h "lldb/Core/SearchFilter.h" -/// @brief This is a SearchFilter that restricts the search to a given module. +/// @class SearchFilterByModule SearchFilter.h "lldb/Core/SearchFilter.h" This +/// is a SearchFilter that restricts the search to a given module. //---------------------------------------------------------------------- class SearchFilterByModule : public SearchFilter { diff --git a/include/lldb/Core/Section.h b/include/lldb/Core/Section.h index 2d5d6443ba7f4..8e275ce3199e9 100644 --- a/include/lldb/Core/Section.h +++ b/include/lldb/Core/Section.h @@ -182,6 +182,8 @@ public: lldb::SectionType GetType() const { return m_type; } + const char *GetTypeAsCString() const; + lldb::SectionSP GetParent() const { return m_parent_wp.lock(); } bool IsThreadSpecific() const { return m_thread_specific; } @@ -270,10 +272,9 @@ protected: SectionList m_children; // Child sections bool m_fake : 1, // If true, then this section only can contain the address if // one of its - // children contains an address. This allows for gaps between the children - // that are contained in the address range for this section, but do not - // produce - // hits unless the children contain the address. + // children contains an address. This allows for gaps between the + // children that are contained in the address range for this section, but + // do not produce hits unless the children contain the address. m_encrypted : 1, // Set to true if the contents are encrypted m_thread_specific : 1, // This section is thread specific m_readable : 1, // If this section has read permissions diff --git a/include/lldb/Core/SourceManager.h b/include/lldb/Core/SourceManager.h index 053badf64ddc0..ef652531244dd 100644 --- a/include/lldb/Core/SourceManager.h +++ b/include/lldb/Core/SourceManager.h @@ -106,9 +106,8 @@ public: #ifndef SWIG // The SourceFileCache class separates the source manager from the cache of - // source files, so the - // cache can be stored in the Debugger, but the source managers can be per - // target. + // source files, so the cache can be stored in the Debugger, but the source + // managers can be per target. class SourceFileCache { public: SourceFileCache() = default; diff --git a/include/lldb/Core/StreamBuffer.h b/include/lldb/Core/StreamBuffer.h index 3b18573021b34..307dc7e18a5ed 100644 --- a/include/lldb/Core/StreamBuffer.h +++ b/include/lldb/Core/StreamBuffer.h @@ -39,9 +39,8 @@ public: void Clear() { m_packet.clear(); } // Beware, this might not be NULL terminated as you can expect from - // StringString as there may be random bits in the llvm::SmallVector. If - // you are using this class to create a C string, be sure the call PutChar - // ('\0') + // StringString as there may be random bits in the llvm::SmallVector. If you + // are using this class to create a C string, be sure the call PutChar ('\0') // after you have created your string, or use StreamString. const char *GetData() const { return m_packet.data(); } diff --git a/include/lldb/Core/ThreadSafeDenseSet.h b/include/lldb/Core/ThreadSafeDenseSet.h index 49c55e96abe1c..44ec2464385f2 100644 --- a/include/lldb/Core/ThreadSafeDenseSet.h +++ b/include/lldb/Core/ThreadSafeDenseSet.h @@ -46,7 +46,7 @@ public: } void Clear() { - stds::lock_guard<_MutexType> guard(m_mutex); + std::lock_guard<_MutexType> guard(m_mutex); m_set.clear(); } diff --git a/include/lldb/Core/ThreadSafeValue.h b/include/lldb/Core/ThreadSafeValue.h index 60eaf91c4f028..10ef8fa41d0cb 100644 --- a/include/lldb/Core/ThreadSafeValue.h +++ b/include/lldb/Core/ThreadSafeValue.h @@ -17,6 +17,7 @@ // 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 e8c6c7c1353e7..fe3e831a60451 100644 --- a/include/lldb/Core/UniqueCStringMap.h +++ b/include/lldb/Core/UniqueCStringMap.h @@ -25,11 +25,10 @@ namespace lldb_private { //---------------------------------------------------------------------- // Templatized uniqued string map. // -// This map is useful for mapping unique C string names to values of -// type T. Each "const char *" name added must be unique for a given +// This map is useful for mapping unique C string names to values of type T. +// Each "const char *" name added must be unique for a given // C string value. ConstString::GetCString() can provide such strings. -// Any other string table that has guaranteed unique values can also -// be used. +// Any other string table that has guaranteed unique values can also be used. //---------------------------------------------------------------------- template <typename T> class UniqueCStringMap { public: @@ -51,9 +50,9 @@ public: }; //------------------------------------------------------------------ - // Call this function multiple times to add a bunch of entries to - // this map, then later call UniqueCStringMap<T>::Sort() before doing - // any searches by name. + // Call this function multiple times to add a bunch of entries to this map, + // then later call UniqueCStringMap<T>::Sort() before doing any searches by + // name. //------------------------------------------------------------------ void Append(ConstString unique_cstr, const T &value) { m_map.push_back(typename UniqueCStringMap<T>::Entry(unique_cstr, value)); @@ -64,8 +63,8 @@ public: void Clear() { m_map.clear(); } //------------------------------------------------------------------ - // Call this function to always keep the map sorted when putting - // entries into the map. + // Call this function to always keep the map sorted when putting entries into + // the map. //------------------------------------------------------------------ void Insert(ConstString unique_cstr, const T &value) { typename UniqueCStringMap<T>::Entry e(unique_cstr, value); @@ -79,8 +78,8 @@ public: //------------------------------------------------------------------ // Get an entries by index in a variety of forms. // - // The caller is responsible for ensuring that the collection does - // not change during while using the returned values. + // The caller is responsible for ensuring that the collection does not change + // during while using the returned values. //------------------------------------------------------------------ bool GetValueAtIndex(uint32_t idx, T &value) const { if (idx < m_map.size()) { @@ -94,12 +93,12 @@ public: return m_map[idx].cstring; } - // Use this function if you have simple types in your map that you - // can easily copy when accessing values by index. + // Use this function if you have simple types in your map that you can easily + // copy when accessing values by index. T GetValueAtIndexUnchecked(uint32_t idx) const { return m_map[idx].value; } - // Use this function if you have complex types in your map that you - // don't want to copy when accessing values by index. + // Use this function if you have complex types in your map that you don't + // want to copy when accessing values by index. const T &GetValueRefAtIndexUnchecked(uint32_t idx) const { return m_map[idx].value; } @@ -111,8 +110,8 @@ public: //------------------------------------------------------------------ // Find the value for the unique string in the map. // - // Return the value for \a unique_cstr if one is found, return - // \a fail_value otherwise. This method works well for simple type + // Return the value for \a unique_cstr if one is found, return \a fail_value + // otherwise. This method works well for simple type // T values and only if there is a sensible failure value that can // be returned and that won't match any existing values. //------------------------------------------------------------------ @@ -128,11 +127,11 @@ public: } //------------------------------------------------------------------ - // Get a pointer to the first entry that matches "name". nullptr will - // be returned if there is no entry that matches "name". + // Get a pointer to the first entry that matches "name". nullptr will be + // returned if there is no entry that matches "name". // - // The caller is responsible for ensuring that the collection does - // not change during while using the returned pointer. + // The caller is responsible for ensuring that the collection does not change + // during while using the returned pointer. //------------------------------------------------------------------ const Entry *FindFirstValueForName(ConstString unique_cstr) const { Entry search_entry(unique_cstr); @@ -144,12 +143,12 @@ public: } //------------------------------------------------------------------ - // Get a pointer to the next entry that matches "name" from a - // previously returned Entry pointer. nullptr will be returned if there - // is no subsequent entry that matches "name". + // Get a pointer to the next entry that matches "name" from a previously + // returned Entry pointer. nullptr will be returned if there is no subsequent + // entry that matches "name". // - // The caller is responsible for ensuring that the collection does - // not change during while using the returned pointer. + // The caller is responsible for ensuring that the collection does not change + // during while using the returned pointer. //------------------------------------------------------------------ const Entry *FindNextValueForName(const Entry *entry_ptr) const { if (!m_map.empty()) { @@ -204,16 +203,15 @@ public: bool IsEmpty() const { return m_map.empty(); } //------------------------------------------------------------------ - // Reserve memory for at least "n" entries in the map. This is - // useful to call when you know you will be adding a lot of entries - // using UniqueCStringMap::Append() (which should be followed by a - // call to UniqueCStringMap::Sort()) or to UniqueCStringMap::Insert(). + // Reserve memory for at least "n" entries in the map. This is useful to call + // when you know you will be adding a lot of entries using + // UniqueCStringMap::Append() (which should be followed by a call to + // UniqueCStringMap::Sort()) or to UniqueCStringMap::Insert(). //------------------------------------------------------------------ void Reserve(size_t n) { m_map.reserve(n); } //------------------------------------------------------------------ - // Sort the unsorted contents in this map. A typical code flow would - // be: + // Sort the unsorted contents in this map. A typical code flow would be: // size_t approximate_num_entries = .... // UniqueCStringMap<uint32_t> my_map; // my_map.Reserve (approximate_num_entries); @@ -226,12 +224,11 @@ public: void Sort() { std::sort(m_map.begin(), m_map.end()); } //------------------------------------------------------------------ - // Since we are using a vector to contain our items it will always - // double its memory consumption as things are added to the vector, - // so if you intend to keep a UniqueCStringMap around and have - // a lot of entries in the map, you will want to call this function - // to create a new vector and copy _only_ the exact size needed as - // part of the finalization of the string map. + // Since we are using a vector to contain our items it will always double its + // memory consumption as things are added to the vector, so if you intend to + // keep a UniqueCStringMap around and have a lot of entries in the map, you + // will want to call this function to create a new vector and copy _only_ the + // exact size needed as part of the finalization of the string map. //------------------------------------------------------------------ void SizeToFit() { if (m_map.size() < m_map.capacity()) { diff --git a/include/lldb/Core/UserSettingsController.h b/include/lldb/Core/UserSettingsController.h index 67bc9b2c07131..aefd42e751ab1 100644 --- a/include/lldb/Core/UserSettingsController.h +++ b/include/lldb/Core/UserSettingsController.h @@ -49,8 +49,8 @@ public: virtual ~Properties() {} virtual lldb::OptionValuePropertiesSP GetValueProperties() const { - // This function is virtual in case subclasses want to lazily - // implement creating the properties. + // This function is virtual in case subclasses want to lazily implement + // creating the properties. return m_collection_sp; } @@ -82,16 +82,11 @@ public: // We sometimes need to introduce a setting to enable experimental features, // but then we don't want the setting for these to cause errors when the - // setting - // goes away. Add a sub-topic of the settings using this experimental name, - // and - // two things will happen. One is that settings that don't find the name will - // not - // be treated as errors. Also, if you decide to keep the settings just move - // them into - // the containing properties, and we will auto-forward the experimental - // settings to the - // real one. + // setting goes away. Add a sub-topic of the settings using this + // experimental name, and two things will happen. One is that settings that + // don't find the name will not be treated as errors. Also, if you decide to + // keep the settings just move them into the containing properties, and we + // will auto-forward the experimental settings to the real one. static const char *GetExperimentalSettingsName(); static bool IsSettingExperimental(llvm::StringRef setting); diff --git a/include/lldb/Core/Value.h b/include/lldb/Core/Value.h index 678b56fc49f51..801e818c6f5c5 100644 --- a/include/lldb/Core/Value.h +++ b/include/lldb/Core/Value.h @@ -48,8 +48,8 @@ namespace lldb_private { class Value { public: - // Values Less than zero are an error, greater than or equal to zero - // returns what the Scalar result is. + // Values Less than zero are an error, greater than or equal to zero returns + // what the Scalar result is. enum ValueType { // m_value contains... // ============================ @@ -107,8 +107,7 @@ public: byte_order != lldb::eByteOrderInvalid); } // Casts a vector, if valid, to an unsigned int of matching or largest - // supported size. - // Truncates to the beginning of the vector if required. + // supported size. Truncates to the beginning of the vector if required. // Returns a default constructed Scalar if the Vector data is internally // inconsistent. llvm::APInt rhs = llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, @@ -229,6 +228,9 @@ public: static const char *GetContextTypeAsCString(ContextType context_type); + /// Convert this value's file address to a load address, if possible. + void ConvertToLoadAddress(Module *module, Target *target); + bool GetData(DataExtractor &data); void Clear(); diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h index fa1d14870b05e..fddc064131968 100644 --- a/include/lldb/Core/ValueObject.h +++ b/include/lldb/Core/ValueObject.h @@ -11,7 +11,6 @@ #define liblldb_ValueObject_h_ #include "lldb/Core/Value.h" -#include "lldb/DataFormatters/DumpValueObjectOptions.h" // for DumpValueObj... #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" // for TypeImpl #include "lldb/Target/ExecutionContext.h" @@ -45,6 +44,9 @@ namespace lldb_private { class Declaration; } namespace lldb_private { +class DumpValueObjectOptions; +} +namespace lldb_private { class EvaluateExpressionOptions; } namespace lldb_private { @@ -286,10 +288,10 @@ public: return m_exe_ctx_ref; } - // Set the EvaluationPoint to the values in exe_scope, - // Return true if the Evaluation Point changed. - // Since the ExecutionContextScope is always going to be valid currently, - // the Updated Context will also always be valid. + // Set the EvaluationPoint to the values in exe_scope, Return true if the + // Evaluation Point changed. Since the ExecutionContextScope is always + // going to be valid currently, the Updated Context will also always be + // valid. // bool // SetContext (ExecutionContextScope *exe_scope); @@ -327,8 +329,7 @@ public: void SetInvalid() { // Use the stop id to mark us as invalid, leave the thread id and the - // stack id around for logging and - // history purposes. + // stack id around for logging and history purposes. m_mod_id.SetInvalid(); // Can't update an invalid state. @@ -464,17 +465,16 @@ public: virtual bool SetValueFromCString(const char *value_str, Status &error); - // Return the module associated with this value object in case the - // value is from an executable file and might have its data in - // sections of the file. This can be used for variables. + // Return the module associated with this value object in case the value is + // from an executable file and might have its data in sections of the file. + // This can be used for variables. virtual lldb::ModuleSP GetModule(); ValueObject *GetRoot(); // Given a ValueObject, loop over itself and its parent, and its parent's - // parent, .. - // until either the given callback returns false, or you end up at a null - // pointer + // parent, .. until either the given callback returns false, or you end up at + // a null pointer ValueObject *FollowParentChain(std::function<bool(ValueObject *)>); virtual bool GetDeclaration(Declaration &decl); @@ -517,9 +517,9 @@ public: virtual bool ResolveValue(Scalar &scalar); - // return 'false' whenever you set the error, otherwise - // callers may assume true means everything is OK - this will - // break breakpoint conditions among potentially a few others + // return 'false' whenever you set the error, otherwise callers may assume + // true means everything is OK - this will break breakpoint conditions among + // potentially a few others virtual bool IsLogicalTrue(Status &error); virtual const char *GetLocationAsCString(); @@ -646,8 +646,8 @@ public: virtual lldb::ValueObjectSP CastPointerType(const char *name, lldb::TypeSP &type_sp); - // The backing bits of this value object were updated, clear any - // descriptive string, so we know we have to refetch them + // The backing bits of this value object were updated, clear any descriptive + // string, so we know we have to refetch them virtual void ValueUpdated() { ClearUserVisibleData(eClearUserVisibleDataItemsValue | eClearUserVisibleDataItemsSummary | @@ -694,9 +694,8 @@ public: lldb::ValueObjectSP Persist(); - // returns true if this is a char* or a char[] - // if it is a char* and check_pointer is true, - // it also checks that the pointer is valid + // returns true if this is a char* or a char[] if it is a char* and + // check_pointer is true, it also checks that the pointer is valid bool IsCStringContainer(bool check_pointer = false); std::pair<size_t, bool> @@ -776,11 +775,9 @@ public: } // Use GetParent for display purposes, but if you want to tell the parent to - // update itself - // then use m_parent. The ValueObjectDynamicValue's parent is not the correct - // parent for - // displaying, they are really siblings, so for display it needs to route - // through to its grandparent. + // update itself then use m_parent. The ValueObjectDynamicValue's parent is + // not the correct parent for displaying, they are really siblings, so for + // display it needs to route through to its grandparent. virtual ValueObject *GetParent() { return m_parent; } virtual const ValueObject *GetParent() const { return m_parent; } @@ -904,9 +901,9 @@ protected: ValueObjectManager *m_manager; // This object is managed by the root object // (any ValueObject that gets created // without a parent.) The manager gets passed through all the generations of - // dependent objects, and will keep the whole cluster of objects alive as long - // as a shared pointer to any of them has been handed out. Shared pointers to - // value objects must always be made with the GetSP method. + // dependent objects, and will keep the whole cluster of objects alive as + // long as a shared pointer to any of them has been handed out. Shared + // pointers to value objects must always be made with the GetSP method. ChildrenManager m_children; std::map<ConstString, ValueObject *> m_synthetic_children; @@ -954,21 +951,19 @@ protected: // Constructors and Destructors //------------------------------------------------------------------ - // Use the no-argument constructor to make a constant variable object (with no - // ExecutionContextScope.) + // Use the no-argument constructor to make a constant variable object (with + // no ExecutionContextScope.) ValueObject(); // Use this constructor to create a "root variable object". The ValueObject - // will be locked to this context - // through-out its lifespan. + // will be locked to this context through-out its lifespan. ValueObject(ExecutionContextScope *exe_scope, AddressType child_ptr_or_ref_addr_type = eAddressTypeLoad); // Use this constructor to create a ValueObject owned by another ValueObject. - // It will inherit the ExecutionContext - // of its parent. + // It will inherit the ExecutionContext of its parent. ValueObject(ValueObject &parent); @@ -990,8 +985,8 @@ protected: virtual void CalculateSyntheticValue(bool use_synthetic = true); - // Should only be called by ValueObject::GetChildAtIndex() - // Returns a ValueObject managed by this ValueObject's manager. + // Should only be called by ValueObject::GetChildAtIndex() Returns a + // ValueObject managed by this ValueObject's manager. virtual ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member, int32_t synthetic_index); @@ -1043,8 +1038,9 @@ private: //------------------------------------------------------------------------------ // A value object manager class that is seeded with the static variable value // and it vends the user facing value object. If the type is dynamic it can -// vend the dynamic type. If this user type also has a synthetic type associated -// with it, it will vend the synthetic type. The class watches the process' stop +// vend the dynamic type. If this user type also has a synthetic type +// associated with it, it will vend the synthetic type. The class watches the +// process' stop // ID and will update the user type when needed. //------------------------------------------------------------------------------ class ValueObjectManager { diff --git a/include/lldb/Core/ValueObjectSyntheticFilter.h b/include/lldb/Core/ValueObjectSyntheticFilter.h index e32e14030418e..b3af6c0ae827d 100644 --- a/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -39,9 +39,9 @@ namespace lldb_private { //---------------------------------------------------------------------- // A ValueObject that obtains its children from some source other than // real information -// This is currently used to implement Python-based children and filters -// but you can bind it to any source of synthetic information and have -// it behave accordingly +// This is currently used to implement Python-based children and filters but +// you can bind it to any source of synthetic information and have it behave +// accordingly //---------------------------------------------------------------------- class ValueObjectSynthetic : public ValueObject { public: diff --git a/include/lldb/DataFormatters/DataVisualization.h b/include/lldb/DataFormatters/DataVisualization.h index 343099bf2a7b1..369fa686a9ff6 100644 --- a/include/lldb/DataFormatters/DataVisualization.h +++ b/include/lldb/DataFormatters/DataVisualization.h @@ -21,15 +21,14 @@ namespace lldb_private { -// this class is the high-level front-end of LLDB Data Visualization -// code in FormatManager.h/cpp is the low-level implementation of this feature -// clients should refer to this class as the entry-point into the data -// formatters +// this class is the high-level front-end of LLDB Data Visualization code in +// FormatManager.h/cpp is the low-level implementation of this feature clients +// should refer to this class as the entry-point into the data formatters // unless they have a good reason to bypass this and go to the backend class DataVisualization { public: - // use this call to force the FM to consider itself updated even when there is - // no apparent reason for that + // use this call to force the FM to consider itself updated even when there + // is no apparent reason for that static void ForceUpdate(); static uint32_t GetCurrentRevision(); diff --git a/include/lldb/DataFormatters/FormatClasses.h b/include/lldb/DataFormatters/FormatClasses.h index c559c212c2dbb..458477578d3f7 100644 --- a/include/lldb/DataFormatters/FormatClasses.h +++ b/include/lldb/DataFormatters/FormatClasses.h @@ -160,8 +160,8 @@ public: private: bool m_is_regex; - // this works better than TypeAndOrName because the latter only wraps a TypeSP - // whereas TypePair can also be backed by a CompilerType + // this works better than TypeAndOrName because the latter only wraps a + // TypeSP whereas TypePair can also be backed by a CompilerType struct TypeOrName { std::string m_type_name; TypePair m_type_pair; diff --git a/include/lldb/DataFormatters/FormatManager.h b/include/lldb/DataFormatters/FormatManager.h index 924ef0cdf6b47..e973c8b3e8492 100644 --- a/include/lldb/DataFormatters/FormatManager.h +++ b/include/lldb/DataFormatters/FormatManager.h @@ -33,12 +33,10 @@ namespace lldb_private { // this file (and its. cpp) contain the low-level implementation of LLDB Data -// Visualization -// class DataVisualization is the high-level front-end of this feature -// clients should refer to that class as the entry-point into the data -// formatters -// unless they have a good reason to bypass it and prefer to use this file's -// objects directly +// Visualization class DataVisualization is the high-level front-end of this +// feature clients should refer to that class as the entry-point into the data +// formatters unless they have a good reason to bypass it and prefer to use +// this file's objects directly class FormatManager : public IFormatChangeListener { typedef FormatMap<ConstString, TypeSummaryImpl> NamedSummariesMap; @@ -175,24 +173,22 @@ public: static const char *GetFormatAsCString(lldb::Format format); - // if the user tries to add formatters for, say, "struct Foo" - // those will not match any type because of the way we strip qualifiers from - // typenames - // this method looks for the case where the user is adding a - // "class","struct","enum" or "union" Foo - // and strips the unnecessary qualifier + // if the user tries to add formatters for, say, "struct Foo" those will not + // match any type because of the way we strip qualifiers from typenames this + // method looks for the case where the user is adding a + // "class","struct","enum" or "union" Foo and strips the unnecessary + // qualifier static ConstString GetValidTypeName(const ConstString &type); // when DataExtractor dumps a vectorOfT, it uses a predefined format for each - // item - // this method returns it, or eFormatInvalid if vector_format is not a + // item this method returns it, or eFormatInvalid if vector_format is not a // vectorOf static lldb::Format GetSingleItemFormat(lldb::Format vector_format); - // this returns true if the ValueObjectPrinter is *highly encouraged* - // to actually represent this ValueObject in one-liner format - // If this object has a summary formatter, however, we should not - // try and do one-lining, just let the summary do the right thing + // this returns true if the ValueObjectPrinter is *highly encouraged* to + // actually represent this ValueObject in one-liner format If this object has + // a summary formatter, however, we should not try and do one-lining, just + // let the summary do the right thing bool ShouldPrintAsOneLiner(ValueObject &valobj); void Changed() override; @@ -249,15 +245,12 @@ private: TypeCategoryMap &GetCategories() { return m_categories_map; } - // These functions are meant to initialize formatters that are very - // low-level/global in nature - // and do not naturally belong in any language. The intent is that most - // formatters go in - // language-specific categories. Eventually, the runtimes should also be - // allowed to vend their - // own formatters, and then one could put formatters that depend on specific - // library load events - // in the language runtimes, on an as-needed basis + // These functions are meant to initialize formatters that are very low- + // level/global in nature and do not naturally belong in any language. The + // intent is that most formatters go in language-specific categories. + // Eventually, the runtimes should also be allowed to vend their own + // formatters, and then one could put formatters that depend on specific + // library load events in the language runtimes, on an as-needed basis void LoadSystemFormatters(); void LoadVectorFormatters(); diff --git a/include/lldb/DataFormatters/FormattersContainer.h b/include/lldb/DataFormatters/FormattersContainer.h index 2df5bf4efcfbd..df88e88011fea 100644 --- a/include/lldb/DataFormatters/FormattersContainer.h +++ b/include/lldb/DataFormatters/FormattersContainer.h @@ -43,12 +43,10 @@ public: virtual uint32_t GetCurrentRevision() = 0; }; -// if the user tries to add formatters for, say, "struct Foo" -// those will not match any type because of the way we strip qualifiers from -// typenames -// this method looks for the case where the user is adding a -// "class","struct","enum" or "union" Foo -// and strips the unnecessary qualifier +// if the user tries to add formatters for, say, "struct Foo" those will not +// match any type because of the way we strip qualifiers from typenames this +// method looks for the case where the user is adding a "class","struct","enum" +// or "union" Foo and strips the unnecessary qualifier static inline ConstString GetValidTypeName_Impl(const ConstString &type) { if (type.IsEmpty()) return type; diff --git a/include/lldb/DataFormatters/StringPrinter.h b/include/lldb/DataFormatters/StringPrinter.h index 8d4a099fbec99..18207921bb71f 100644 --- a/include/lldb/DataFormatters/StringPrinter.h +++ b/include/lldb/DataFormatters/StringPrinter.h @@ -266,8 +266,7 @@ public: // I can't use a std::unique_ptr for this because the Deleter is a template // argument there // and I want the same type to represent both pointers I want to free and - // pointers I don't need - // to free - which is what this class essentially is + // pointers I don't need to free - which is what this class essentially is // It's very specialized to the needs of this file, and not suggested for // general use template <typename T = uint8_t, typename U = char, typename S = size_t> diff --git a/include/lldb/DataFormatters/TypeFormat.h b/include/lldb/DataFormatters/TypeFormat.h index 8cfe021da3e0d..77e3542f5522d 100644 --- a/include/lldb/DataFormatters/TypeFormat.h +++ b/include/lldb/DataFormatters/TypeFormat.h @@ -146,10 +146,9 @@ public: virtual Type GetType() { return Type::eTypeUnknown; } // we are using a ValueObject* instead of a ValueObjectSP because we do not - // need to hold on to this for - // extended periods of time and we trust the ValueObject to stay around for as - // long as it is required - // for us to generate its value + // need to hold on to this for extended periods of time and we trust the + // ValueObject to stay around for as long as it is required for us to + // generate its value virtual bool FormatObject(ValueObject *valobj, std::string &dest) const = 0; virtual std::string GetDescription() = 0; diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h index 1bde565aa5c84..17cd61ae8c1e0 100644 --- a/include/lldb/DataFormatters/TypeSummary.h +++ b/include/lldb/DataFormatters/TypeSummary.h @@ -258,10 +258,9 @@ public: void SetOptions(uint32_t value) { m_flags.SetValue(value); } // we are using a ValueObject* instead of a ValueObjectSP because we do not - // need to hold on to this for - // extended periods of time and we trust the ValueObject to stay around for as - // long as it is required - // for us to generate its summary + // need to hold on to this for extended periods of time and we trust the + // ValueObject to stay around for as long as it is required for us to + // generate its summary virtual bool FormatObject(ValueObject *valobj, std::string &dest, const TypeSummaryOptions &options) = 0; @@ -311,8 +310,8 @@ private: // summaries implemented via a C++ function struct CXXFunctionSummaryFormat : public TypeSummaryImpl { - // we should convert these to SBValue and SBStream if we ever cross - // the boundary towards the external world + // we should convert these to SBValue and SBStream if we ever cross the + // boundary towards the external world typedef std::function<bool(ValueObject &, Stream &, const TypeSummaryOptions &)> Callback; diff --git a/include/lldb/DataFormatters/TypeSynthetic.h b/include/lldb/DataFormatters/TypeSynthetic.h index 59fb6d3fcdbb9..07dacd670a62a 100644 --- a/include/lldb/DataFormatters/TypeSynthetic.h +++ b/include/lldb/DataFormatters/TypeSynthetic.h @@ -55,34 +55,29 @@ public: virtual size_t GetIndexOfChildWithName(const ConstString &name) = 0; // this function is assumed to always succeed and it if fails, the front-end - // should know to deal - // with it in the correct way (most probably, by refusing to return any - // children) - // the return value of Update() should actually be interpreted as - // "ValueObjectSyntheticFilter cache is good/bad" - // if =true, ValueObjectSyntheticFilter is allowed to use the children it - // fetched previously and cached - // if =false, ValueObjectSyntheticFilter must throw away its cache, and query - // again for children + // should know to deal with it in the correct way (most probably, by refusing + // to return any children) the return value of Update() should actually be + // interpreted as "ValueObjectSyntheticFilter cache is good/bad" if =true, + // ValueObjectSyntheticFilter is allowed to use the children it fetched + // previously and cached if =false, ValueObjectSyntheticFilter must throw + // away its cache, and query again for children virtual bool Update() = 0; // if this function returns false, then CalculateNumChildren() MUST return 0 - // since UI frontends - // might validly decide not to inquire for children given a false return value - // from this call - // if it returns true, then CalculateNumChildren() can return any number >= 0 - // (0 being valid) - // it should if at all possible be more efficient than CalculateNumChildren() + // since UI frontends might validly decide not to inquire for children given + // a false return value from this call if it returns true, then + // CalculateNumChildren() can return any number >= 0 (0 being valid) it + // should if at all possible be more efficient than CalculateNumChildren() virtual bool MightHaveChildren() = 0; // if this function returns a non-null ValueObject, then the returned - // ValueObject will stand - // for this ValueObject whenever a "value" request is made to this ValueObject + // ValueObject will stand for this ValueObject whenever a "value" request is + // made to this ValueObject virtual lldb::ValueObjectSP GetSyntheticValue() { return nullptr; } - // if this function returns a non-empty ConstString, then clients are expected - // to use the return - // as the name of the type of this ValueObject for display purposes + // if this function returns a non-empty ConstString, then clients are + // expected to use the return as the name of the type of this ValueObject for + // display purposes virtual ConstString GetSyntheticTypeName() { return ConstString(); } typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer; @@ -212,6 +207,19 @@ public: return *this; } + bool GetFrontEndWantsDereference() const { + return (m_flags & lldb::eTypeOptionFrontEndWantsDereference) == + lldb::eTypeOptionFrontEndWantsDereference; + } + + Flags &SetFrontEndWantsDereference(bool value = true) { + if (value) + m_flags |= lldb::eTypeOptionFrontEndWantsDereference; + else + m_flags &= ~lldb::eTypeOptionFrontEndWantsDereference; + return *this; + } + uint32_t GetValue() { return m_flags; } void SetValue(uint32_t value) { m_flags = value; } @@ -231,6 +239,8 @@ public: bool SkipsReferences() const { return m_flags.GetSkipReferences(); } bool NonCacheable() const { return m_flags.GetNonCacheable(); } + + bool WantsDereference() const { return m_flags.GetFrontEndWantsDereference();} void SetCascades(bool value) { m_flags.SetCascades(value); } diff --git a/include/lldb/DataFormatters/TypeValidator.h b/include/lldb/DataFormatters/TypeValidator.h index 3c414e39353f9..fa2a891481187 100644 --- a/include/lldb/DataFormatters/TypeValidator.h +++ b/include/lldb/DataFormatters/TypeValidator.h @@ -147,10 +147,9 @@ public: virtual Type GetType() { return Type::eTypeUnknown; } // we are using a ValueObject* instead of a ValueObjectSP because we do not - // need to hold on to this for - // extended periods of time and we trust the ValueObject to stay around for as - // long as it is required - // for us to generate its value + // need to hold on to this for extended periods of time and we trust the + // ValueObject to stay around for as long as it is required for us to + // generate its value virtual ValidationResult FormatObject(ValueObject *valobj) const = 0; virtual std::string GetDescription() = 0; diff --git a/include/lldb/DataFormatters/ValueObjectPrinter.h b/include/lldb/DataFormatters/ValueObjectPrinter.h index 41851436873d6..67048a4932cfb 100644 --- a/include/lldb/DataFormatters/ValueObjectPrinter.h +++ b/include/lldb/DataFormatters/ValueObjectPrinter.h @@ -47,16 +47,16 @@ protected: InstancePointersSetSP m_printed_instance_pointers; - // only this class (and subclasses, if any) should ever be concerned with - // the depth mechanism + // only this class (and subclasses, if any) should ever be concerned with the + // depth mechanism ValueObjectPrinter(ValueObject *valobj, Stream *s, const DumpValueObjectOptions &options, const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth, InstancePointersSetSP printed_instance_pointers); - // we should actually be using delegating constructors here - // but some versions of GCC still have trouble with those + // we should actually be using delegating constructors here but some versions + // of GCC still have trouble with those void Init(ValueObject *valobj, Stream *s, const DumpValueObjectOptions &options, const DumpValueObjectOptions::PointerDepth &ptr_depth, diff --git a/include/lldb/DataFormatters/VectorIterator.h b/include/lldb/DataFormatters/VectorIterator.h index fcf5aba6ecbee..f695d22905024 100644 --- a/include/lldb/DataFormatters/VectorIterator.h +++ b/include/lldb/DataFormatters/VectorIterator.h @@ -13,6 +13,7 @@ #include "lldb/lldb-forward.h" +#include "lldb/DataFormatters/TypeSynthetic.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Utility/ConstString.h" diff --git a/include/lldb/Expression/DWARFExpression.h b/include/lldb/Expression/DWARFExpression.h index c85aaa5c1f9a8..b4bd9697da58a 100644 --- a/include/lldb/Expression/DWARFExpression.h +++ b/include/lldb/Expression/DWARFExpression.h @@ -18,22 +18,22 @@ #include "lldb/lldb-private.h" #include <functional> -class DWARFCompileUnit; +class DWARFUnit; namespace lldb_private { //---------------------------------------------------------------------- -/// @class DWARFExpression DWARFExpression.h "lldb/Expression/DWARFExpression.h" -/// @brief Encapsulates a DWARF location expression and interprets it. +/// @class DWARFExpression DWARFExpression.h +/// "lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location +/// expression and interprets it. /// /// DWARF location expressions are used in two ways by LLDB. The first -/// use is to find entities specified in the debug information, since -/// their locations are specified in precisely this language. The second -/// is to interpret expressions without having to run the target in cases -/// where the overhead from copying JIT-compiled code into the target is -/// too high or where the target cannot be run. This class encapsulates -/// a single DWARF location expression or a location list and interprets -/// it. +/// use is to find entities specified in the debug information, since their +/// locations are specified in precisely this language. The second is to +/// interpret expressions without having to run the target in cases where the +/// overhead from copying JIT-compiled code into the target is too high or +/// where the target cannot be run. This class encapsulates a single DWARF +/// location expression or a location list and interprets it. //---------------------------------------------------------------------- class DWARFExpression { public: @@ -46,7 +46,7 @@ public: //------------------------------------------------------------------ /// Constructor //------------------------------------------------------------------ - explicit DWARFExpression(DWARFCompileUnit *dwarf_cu); + explicit DWARFExpression(DWARFUnit *dwarf_cu); //------------------------------------------------------------------ /// Constructor @@ -62,7 +62,7 @@ public: /// The byte length of the location expression. //------------------------------------------------------------------ DWARFExpression(lldb::ModuleSP module, const DataExtractor &data, - DWARFCompileUnit *dwarf_cu, lldb::offset_t data_offset, + DWARFUnit *dwarf_cu, lldb::offset_t data_offset, lldb::offset_t data_length); //------------------------------------------------------------------ @@ -130,12 +130,12 @@ public: //------------------------------------------------------------------ /// If a location is not a location list, return true if the location - /// contains a DW_OP_addr () opcode in the stream that matches \a - /// file_addr. If file_addr is LLDB_INVALID_ADDRESS, the this - /// function will return true if the variable there is any DW_OP_addr - /// in a location that (yet still is NOT a location list). This helps - /// us detect if a variable is a global or static variable since - /// there is no other indication from DWARF debug info. + /// contains a DW_OP_addr () opcode in the stream that matches \a file_addr. + /// If file_addr is LLDB_INVALID_ADDRESS, the this function will return true + /// if the variable there is any DW_OP_addr in a location that (yet still is + /// NOT a location list). This helps us detect if a variable is a global or + /// static variable since there is no other indication from DWARF debug + /// info. /// /// @param[in] op_addr_idx /// The DW_OP_addr index to retrieve in case there is more than @@ -161,8 +161,8 @@ public: &link_address_callback); //------------------------------------------------------------------ - /// Make the expression parser read its location information from a - /// given data source. Does not change the offset and length + /// Make the expression parser read its location information from a given + /// data source. Does not change the offset and length /// /// @param[in] data /// A data extractor configured to read the DWARF location expression's @@ -171,8 +171,8 @@ public: void SetOpcodeData(const DataExtractor &data); //------------------------------------------------------------------ - /// Make the expression parser read its location information from a - /// given data source + /// Make the expression parser read its location information from a given + /// data source /// /// @param[in] module_sp /// The module that defines the DWARF expression. @@ -193,16 +193,15 @@ public: //------------------------------------------------------------------ /// Copy the DWARF location expression into a local buffer. /// - /// It is a good idea to copy the data so we don't keep the entire - /// object file worth of data around just for a few bytes of location - /// expression. LLDB typically will mmap the entire contents of debug - /// information files, and if we use SetOpcodeData, it will get a - /// shared reference to all of this data for the and cause the object - /// file to have to stay around. Even worse, a very very large ".a" - /// that contains one or more .o files could end up being referenced. - /// Location lists are typically small so even though we are copying - /// the data, it shouldn't amount to that much for the variables we - /// end up parsing. + /// It is a good idea to copy the data so we don't keep the entire object + /// file worth of data around just for a few bytes of location expression. + /// LLDB typically will mmap the entire contents of debug information files, + /// and if we use SetOpcodeData, it will get a shared reference to all of + /// this data for the and cause the object file to have to stay around. Even + /// worse, a very very large ".a" that contains one or more .o files could + /// end up being referenced. Location lists are typically small so even + /// though we are copying the data, it shouldn't amount to that much for the + /// variables we end up parsing. /// /// @param[in] module_sp /// The module that defines the DWARF expression. @@ -254,8 +253,8 @@ public: //------------------------------------------------------------------ /// Wrapper for the static evaluate function that accepts an - /// ExecutionContextScope instead of an ExecutionContext and uses - /// member variables to populate many operands + /// ExecutionContextScope instead of an ExecutionContext and uses member + /// variables to populate many operands //------------------------------------------------------------------ bool Evaluate(ExecutionContextScope *exe_scope, lldb::addr_t loclist_base_load_addr, @@ -263,8 +262,8 @@ public: Value &result, Status *error_ptr) const; //------------------------------------------------------------------ - /// Wrapper for the static evaluate function that uses member - /// variables to populate many operands + /// Wrapper for the static evaluate function that uses member variables to + /// populate many operands //------------------------------------------------------------------ bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::addr_t loclist_base_load_addr, @@ -332,7 +331,7 @@ public: //------------------------------------------------------------------ static bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::ModuleSP opcode_ctx, const DataExtractor &opcodes, - DWARFCompileUnit *dwarf_cu, const lldb::offset_t offset, + DWARFUnit *dwarf_cu, const lldb::offset_t offset, const lldb::offset_t length, const lldb::RegisterKind reg_set, const Value *initial_value_ptr, @@ -348,7 +347,7 @@ public: lldb::addr_t loclist_base_load_addr, lldb::addr_t address, ABI *abi); - static size_t LocationListSize(const DWARFCompileUnit *dwarf_cu, + static size_t LocationListSize(const DWARFUnit *dwarf_cu, const DataExtractor &debug_loc_data, lldb::offset_t offset); @@ -356,7 +355,7 @@ public: int address_size, int dwarf_ref_size, bool location_expression); - static void PrintDWARFLocationList(Stream &s, const DWARFCompileUnit *cu, + static void PrintDWARFLocationList(Stream &s, const DWARFUnit *cu, const DataExtractor &debug_loc_data, lldb::offset_t offset); @@ -389,7 +388,7 @@ protected: lldb::offset_t &offset, lldb::offset_t &len); static bool AddressRangeForLocationListEntry( - const DWARFCompileUnit *dwarf_cu, const DataExtractor &debug_loc_data, + const DWARFUnit *dwarf_cu, const DataExtractor &debug_loc_data, lldb::offset_t *offset_ptr, lldb::addr_t &low_pc, lldb::addr_t &high_pc); bool GetOpAndEndOffsets(StackFrame &frame, lldb::offset_t &op_offset, @@ -401,7 +400,7 @@ protected: lldb::ModuleWP m_module_wp; ///< Module which defined this expression. DataExtractor m_data; ///< A data extractor capable of reading opcode bytes - DWARFCompileUnit *m_dwarf_cu; ///< The DWARF compile unit this expression + DWARFUnit *m_dwarf_cu; ///< The DWARF compile unit this expression ///belongs to. It is used ///< to evaluate values indexing into the .debug_addr section (e.g. ///< DW_OP_GNU_addr_index, DW_OP_GNU_const_index) diff --git a/include/lldb/Expression/Expression.h b/include/lldb/Expression/Expression.h index 860444e9c2c2e..6b9363864722e 100644 --- a/include/lldb/Expression/Expression.h +++ b/include/lldb/Expression/Expression.h @@ -28,14 +28,14 @@ namespace lldb_private { class RecordingMemoryManager; //---------------------------------------------------------------------- -/// @class Expression Expression.h "lldb/Expression/Expression.h" -/// @brief Encapsulates a single expression for use in lldb +/// @class Expression Expression.h "lldb/Expression/Expression.h" Encapsulates +/// a single expression for use in lldb /// /// LLDB uses expressions for various purposes, notably to call functions -/// and as a backend for the expr command. Expression encapsulates -/// the objects needed to parse and interpret or JIT an expression. It -/// uses the expression parser appropriate to the language of the expression -/// to produce LLVM IR from the expression. +/// and as a backend for the expr command. Expression encapsulates the +/// objects needed to parse and interpret or JIT an expression. It uses the +/// expression parser appropriate to the language of the expression to produce +/// LLVM IR from the expression. //---------------------------------------------------------------------- class Expression { public: @@ -58,20 +58,19 @@ public: //------------------------------------------------------------------ /// Return the function name that should be used for executing the - /// expression. Text() should contain the definition of this - /// function. + /// expression. Text() should contain the definition of this function. //------------------------------------------------------------------ virtual const char *FunctionName() = 0; //------------------------------------------------------------------ - /// Return the language that should be used when parsing. To use - /// the default, return eLanguageTypeUnknown. + /// Return the language that should be used when parsing. To use the + /// default, return eLanguageTypeUnknown. //------------------------------------------------------------------ virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; } //------------------------------------------------------------------ - /// Return the desired result type of the function, or - /// eResultTypeAny if indifferent. + /// Return the desired result type of the function, or eResultTypeAny if + /// indifferent. //------------------------------------------------------------------ virtual ResultType DesiredResultType() { return eResultTypeAny; } @@ -80,14 +79,12 @@ public: //------------------------------------------------------------------ //------------------------------------------------------------------ - /// Return true if validation code should be inserted into the - /// expression. + /// Return true if validation code should be inserted into the expression. //------------------------------------------------------------------ virtual bool NeedsValidation() = 0; //------------------------------------------------------------------ - /// Return true if external variables in the expression should be - /// resolved. + /// Return true if external variables in the expression should be resolved. //------------------------------------------------------------------ virtual bool NeedsVariableResolution() = 0; diff --git a/include/lldb/Expression/ExpressionParser.h b/include/lldb/Expression/ExpressionParser.h index a550d576f4376..66957926650a0 100644 --- a/include/lldb/Expression/ExpressionParser.h +++ b/include/lldb/Expression/ExpressionParser.h @@ -20,8 +20,8 @@ class IRExecutionUnit; //---------------------------------------------------------------------- /// @class ExpressionParser ExpressionParser.h -/// "lldb/Expression/ExpressionParser.h" -/// @brief Encapsulates an instance of a compiler that can parse expressions. +/// "lldb/Expression/ExpressionParser.h" Encapsulates an instance of a +/// compiler that can parse expressions. /// /// ExpressionParser is the base class for llvm based Expression parsers. //---------------------------------------------------------------------- @@ -50,8 +50,8 @@ public: virtual ~ExpressionParser(){}; //------------------------------------------------------------------ - /// Parse a single expression and convert it to IR using Clang. Don't - /// wrap the expression in anything at all. + /// Parse a single expression and convert it to IR using Clang. Don't wrap + /// the expression in anything at all. /// /// @param[in] diagnostic_manager /// The diagnostic manager in which to store the errors and warnings. @@ -64,8 +64,8 @@ public: //------------------------------------------------------------------ /// Try to use the FixIts in the diagnostic_manager to rewrite the - /// expression. If successful, the rewritten expression is stored - /// in the diagnostic_manager, get it out with GetFixedExpression. + /// expression. If successful, the rewritten expression is stored in the + /// diagnostic_manager, get it out with GetFixedExpression. /// /// @param[in] diagnostic_manager /// The diagnostic manager containing fixit's to apply. @@ -78,8 +78,8 @@ public: } //------------------------------------------------------------------ - /// Ready an already-parsed expression for execution, possibly - /// evaluating it statically. + /// Ready an already-parsed expression for execution, possibly evaluating it + /// statically. /// /// @param[out] func_addr /// The address to which the function has been written. diff --git a/include/lldb/Expression/ExpressionSourceCode.h b/include/lldb/Expression/ExpressionSourceCode.h index 02fc72aaf2515..b5a6187bf3c5f 100644 --- a/include/lldb/Expression/ExpressionSourceCode.h +++ b/include/lldb/Expression/ExpressionSourceCode.h @@ -40,9 +40,8 @@ public: bool static_method, ExecutionContext &exe_ctx) const; // Given a string returned by GetText, find the beginning and end of the body - // passed to CreateWrapped. - // Return true if the bounds could be found. This will also work on text with - // FixItHints applied. + // passed to CreateWrapped. Return true if the bounds could be found. This + // will also work on text with FixItHints applied. static bool GetOriginalBodyBounds(std::string transformed_text, lldb::LanguageType wrapping_language, size_t &start_loc, size_t &end_loc); diff --git a/include/lldb/Expression/ExpressionTypeSystemHelper.h b/include/lldb/Expression/ExpressionTypeSystemHelper.h index 20a5e67cf9b7f..ffcad54fb9f9b 100644 --- a/include/lldb/Expression/ExpressionTypeSystemHelper.h +++ b/include/lldb/Expression/ExpressionTypeSystemHelper.h @@ -18,11 +18,11 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class ExpressionTypeSystemHelper ExpressionTypeSystemHelper.h /// "lldb/Expression/ExpressionTypeSystemHelper.h" -/// @brief A helper object that the Expression can pass to its ExpressionParser +/// A helper object that the Expression can pass to its ExpressionParser /// to provide generic information that /// any type of expression will need to supply. It's only job is to support -/// dyn_cast so that the expression parser -/// can cast it back to the requisite specific type. +/// dyn_cast so that the expression parser can cast it back to the requisite +/// specific type. /// //---------------------------------------------------------------------- diff --git a/include/lldb/Expression/ExpressionVariable.h b/include/lldb/Expression/ExpressionVariable.h index c7570932c15ab..89b0500faf9cc 100644 --- a/include/lldb/Expression/ExpressionVariable.h +++ b/include/lldb/Expression/ExpressionVariable.h @@ -69,15 +69,12 @@ public: void SetName(const ConstString &name) { m_frozen_sp->SetName(name); } // this function is used to copy the address-of m_live_sp into m_frozen_sp - // this is necessary because the results of certain cast and - // pointer-arithmetic - // operations (such as those described in bugzilla issues 11588 and 11618) - // generate - // frozen objects that do not have a valid address-of, which can be - // troublesome when - // using synthetic children providers. Transferring the address-of the live - // object - // solves these issues and provides the expected user-level behavior + // this is necessary because the results of certain cast and pointer- + // arithmetic operations (such as those described in bugzilla issues 11588 + // and 11618) generate frozen objects that do not have a valid address-of, + // which can be troublesome when using synthetic children providers. + // Transferring the address-of the live object solves these issues and + // provides the expected user-level behavior void TransferAddress(bool force = false) { if (m_live_sp.get() == nullptr) return; @@ -129,7 +126,7 @@ public: //---------------------------------------------------------------------- /// @class ExpressionVariableList ExpressionVariable.h /// "lldb/Expression/ExpressionVariable.h" -/// @brief A list of variable references. +/// A list of variable references. /// /// This class stores variables internally, acting as the permanent store. //---------------------------------------------------------------------- @@ -242,7 +239,12 @@ public: lldb::ByteOrder byte_order, uint32_t addr_byte_size) = 0; - virtual ConstString GetNextPersistentVariableName() = 0; + /// Return a new persistent variable name with the specified prefix. + ConstString GetNextPersistentVariableName(Target &target, + llvm::StringRef prefix); + + virtual llvm::StringRef + GetPersistentVariablePrefix(bool is_error = false) const = 0; virtual void RemovePersistentVariable(lldb::ExpressionVariableSP variable) = 0; diff --git a/include/lldb/Expression/FunctionCaller.h b/include/lldb/Expression/FunctionCaller.h index 56305d5181bd5..c36263e342406 100644 --- a/include/lldb/Expression/FunctionCaller.h +++ b/include/lldb/Expression/FunctionCaller.h @@ -29,7 +29,7 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class FunctionCaller FunctionCaller.h "lldb/Expression/FunctionCaller.h" -/// @brief Encapsulates a function that can be called. +/// Encapsulates a function that can be called. /// /// A given FunctionCaller object can handle a single function signature. /// Once constructed, it can set up any number of concurrent calls to @@ -42,8 +42,8 @@ namespace lldb_private { /// struct with the written arguments. This method lets Clang handle the /// vagaries of function calling conventions. /// -/// The simplest use of the FunctionCaller is to construct it with a -/// function representative of the signature you want to use, then call +/// The simplest use of the FunctionCaller is to construct it with a function +/// representative of the signature you want to use, then call /// ExecuteFunction(ExecutionContext &, Stream &, Value &). /// /// If you need to reuse the arguments for several calls, you can call @@ -53,8 +53,8 @@ namespace lldb_private { /// If you need to call the function on the thread plan stack, you can also /// call InsertFunction() followed by GetThreadPlanToCallFunction(). /// -/// Any of the methods that take arg_addr_ptr or arg_addr_ref can be passed -/// a pointer set to LLDB_INVALID_ADDRESS and new structure will be allocated +/// Any of the methods that take arg_addr_ptr or arg_addr_ref can be passed a +/// pointer set to LLDB_INVALID_ADDRESS and new structure will be allocated /// and its address returned in that variable. /// /// Any of the methods that take arg_addr_ptr can be passed nullptr, and the @@ -170,8 +170,8 @@ public: DiagnosticManager &diagnostic_manager); //------------------------------------------------------------------ - /// Insert an argument struct with a non-default function address and - /// non-default argument values + /// Insert an argument struct with a non-default function address and non- + /// default argument values /// /// @param[in] exe_ctx /// The execution context to insert the function and its arguments @@ -308,28 +308,25 @@ public: //------------------------------------------------------------------ /// Return the function name that should be used for executing the - /// expression. Text() should contain the definition of this - /// function. + /// expression. Text() should contain the definition of this function. //------------------------------------------------------------------ const char *FunctionName() override { return m_wrapper_function_name.c_str(); } //------------------------------------------------------------------ - /// Return the object that the parser should use when registering - /// local variables. May be nullptr if the Expression doesn't care. + /// Return the object that the parser should use when registering local + /// variables. May be nullptr if the Expression doesn't care. //------------------------------------------------------------------ ExpressionVariableList *LocalVariables() { return nullptr; } //------------------------------------------------------------------ - /// Return true if validation code should be inserted into the - /// expression. + /// Return true if validation code should be inserted into the expression. //------------------------------------------------------------------ bool NeedsValidation() override { return false; } //------------------------------------------------------------------ - /// Return true if external variables in the expression should be - /// resolved. + /// Return true if external variables in the expression should be resolved. //------------------------------------------------------------------ bool NeedsVariableResolution() override { return false; } diff --git a/include/lldb/Expression/IRDynamicChecks.h b/include/lldb/Expression/IRDynamicChecks.h index b793a60585bb0..f31c03cfb9efa 100644 --- a/include/lldb/Expression/IRDynamicChecks.h +++ b/include/lldb/Expression/IRDynamicChecks.h @@ -33,17 +33,18 @@ class Stream; //---------------------------------------------------------------------- /// @class DynamicCheckerFunctions IRDynamicChecks.h -/// "lldb/Expression/IRDynamicChecks.h" -/// @brief Encapsulates dynamic check functions used by expressions. +/// "lldb/Expression/IRDynamicChecks.h" Encapsulates dynamic check functions +/// used by expressions. /// /// Each of the utility functions encapsulated in this class is responsible -/// for validating some data that an expression is about to use. Examples are: +/// for validating some data that an expression is about to use. Examples +/// are: /// -/// a = *b; // check that b is a valid pointer -/// [b init]; // check that b is a valid object to send "init" to +/// a = *b; // check that b is a valid pointer [b init]; // check that b +/// is a valid object to send "init" to /// -/// The class installs each checker function into the target process and -/// makes it available to IRDynamicChecks to use. +/// The class installs each checker function into the target process and makes +/// it available to IRDynamicChecks to use. //---------------------------------------------------------------------- class DynamicCheckerFunctions { public: @@ -58,8 +59,8 @@ public: ~DynamicCheckerFunctions(); //------------------------------------------------------------------ - /// Install the utility functions into a process. This binds the - /// instance of DynamicCheckerFunctions to that process. + /// Install the utility functions into a process. This binds the instance + /// of DynamicCheckerFunctions to that process. /// /// @param[in] diagnostic_manager /// A diagnostic manager to report errors to. @@ -81,16 +82,16 @@ public: }; //---------------------------------------------------------------------- -/// @class IRDynamicChecks IRDynamicChecks.h "lldb/Expression/IRDynamicChecks.h" -/// @brief Adds dynamic checks to a user-entered expression to reduce its -/// likelihood of crashing +/// @class IRDynamicChecks IRDynamicChecks.h +/// "lldb/Expression/IRDynamicChecks.h" Adds dynamic checks to a user-entered +/// expression to reduce its likelihood of crashing /// /// When an IR function is executed in the target process, it may cause -/// crashes or hangs by dereferencing NULL pointers, trying to call Objective-C -/// methods on objects that do not respond to them, and so forth. +/// crashes or hangs by dereferencing NULL pointers, trying to call +/// Objective-C methods on objects that do not respond to them, and so forth. /// -/// IRDynamicChecks adds calls to the functions in DynamicCheckerFunctions -/// to appropriate locations in an expression's IR. +/// IRDynamicChecks adds calls to the functions in DynamicCheckerFunctions to +/// appropriate locations in an expression's IR. //---------------------------------------------------------------------- class IRDynamicChecks : public llvm::ModulePass { public: diff --git a/include/lldb/Expression/IRExecutionUnit.h b/include/lldb/Expression/IRExecutionUnit.h index 703fcd152af41..e73f8956d9556 100644 --- a/include/lldb/Expression/IRExecutionUnit.h +++ b/include/lldb/Expression/IRExecutionUnit.h @@ -42,23 +42,23 @@ namespace lldb_private { class Status; //---------------------------------------------------------------------- -/// @class IRExecutionUnit IRExecutionUnit.h "lldb/Expression/IRExecutionUnit.h" -/// @brief Contains the IR and, optionally, JIT-compiled code for a module. +/// @class IRExecutionUnit IRExecutionUnit.h +/// "lldb/Expression/IRExecutionUnit.h" Contains the IR and, optionally, JIT- +/// compiled code for a module. /// -/// This class encapsulates the compiled version of an expression, in IR -/// form (for interpretation purposes) and in raw machine code form (for -/// execution in the target). +/// This class encapsulates the compiled version of an expression, in IR form +/// (for interpretation purposes) and in raw machine code form (for execution +/// in the target). /// -/// This object wraps an IR module that comes from the expression parser, -/// and knows how to use the JIT to make it into executable code. It can -/// then be used as input to the IR interpreter, or the address of the -/// executable code can be passed to a thread plan to run in the target. +/// This object wraps an IR module that comes from the expression parser, and +/// knows how to use the JIT to make it into executable code. It can then be +/// used as input to the IR interpreter, or the address of the executable code +/// can be passed to a thread plan to run in the target. /// /// This class creates a subclass of LLVM's SectionMemoryManager, because that -/// is -/// how the JIT emits code. Because LLDB needs to move JIT-compiled code -/// into the target process, the IRExecutionUnit knows how to copy the -/// emitted code into the target process. +/// is how the JIT emits code. Because LLDB needs to move JIT-compiled code +/// into the target process, the IRExecutionUnit knows how to copy the emitted +/// code into the target process. //---------------------------------------------------------------------- class IRExecutionUnit : public std::enable_shared_from_this<IRExecutionUnit>, public IRMemoryMap, @@ -90,9 +90,9 @@ public: lldb::addr_t &func_end); //------------------------------------------------------------------ - /// Accessors for IRForTarget and other clients that may want binary - /// data placed on their behalf. The binary data is owned by the - /// IRExecutionUnit unless the client explicitly chooses to free it. + /// Accessors for IRForTarget and other clients that may want binary data + /// placed on their behalf. The binary data is owned by the IRExecutionUnit + /// unless the client explicitly chooses to free it. //------------------------------------------------------------------ lldb::addr_t WriteNow(const uint8_t *bytes, size_t size, Status &error); @@ -123,7 +123,7 @@ public: //---------------------------------------------------------------------- /// @class JittedFunction IRExecutionUnit.h /// "lldb/Expression/IRExecutionUnit.h" - /// @brief Encapsulates a single function that has been generated by the JIT. + /// Encapsulates a single function that has been generated by the JIT. /// /// Functions that have been generated by the JIT are first resident in the /// local process, and then placed in the target process. JittedFunction @@ -182,9 +182,9 @@ public: private: //------------------------------------------------------------------ - /// Look up the object in m_address_map that contains a given address, - /// find where it was copied to, and return the remote address at the - /// same offset into the copied entity + /// Look up the object in m_address_map that contains a given address, find + /// where it was copied to, and return the remote address at the same offset + /// into the copied entity /// /// @param[in] local_address /// The address in the debugger. @@ -195,9 +195,9 @@ private: lldb::addr_t GetRemoteAddressForLocal(lldb::addr_t local_address); //------------------------------------------------------------------ - /// Look up the object in m_address_map that contains a given address, - /// find where it was copied to, and return its address range in the - /// target process + /// Look up the object in m_address_map that contains a given address, find + /// where it was copied to, and return its address range in the target + /// process /// /// @param[in] local_address /// The address in the debugger. @@ -272,8 +272,8 @@ private: ~MemoryManager() override; //------------------------------------------------------------------ - /// Allocate space for executable code, and add it to the - /// m_spaceBlocks map + /// Allocate space for executable code, and add it to the m_spaceBlocks + /// map /// /// @param[in] Size /// The size of the area. @@ -315,8 +315,8 @@ private: bool IsReadOnly) override; //------------------------------------------------------------------ - /// Called when object loading is complete and section page - /// permissions can be applied. Currently unimplemented for LLDB. + /// Called when object loading is complete and section page permissions + /// can be applied. Currently unimplemented for LLDB. /// /// @param[out] ErrMsg /// The error that prevented the page protection from succeeding. @@ -355,11 +355,11 @@ private: //---------------------------------------------------------------------- /// @class AllocationRecord IRExecutionUnit.h - /// "lldb/Expression/IRExecutionUnit.h" - /// @brief Encapsulates a single allocation request made by the JIT. + /// "lldb/Expression/IRExecutionUnit.h" Encapsulates a single allocation + /// request made by the JIT. /// - /// Allocations made by the JIT are first queued up and then applied in - /// bulk to the underlying process. + /// Allocations made by the JIT are first queued up and then applied in bulk + /// to the underlying process. //---------------------------------------------------------------------- enum class AllocationKind { Stub, Code, Data, Global, Bytes }; diff --git a/include/lldb/Expression/IRInterpreter.h b/include/lldb/Expression/IRInterpreter.h index 36e03c6fc4f61..2d87346b70663 100644 --- a/include/lldb/Expression/IRInterpreter.h +++ b/include/lldb/Expression/IRInterpreter.h @@ -29,12 +29,12 @@ class IRMemoryMap; //---------------------------------------------------------------------- /// @class IRInterpreter IRInterpreter.h "lldb/Expression/IRInterpreter.h" -/// @brief Attempt to interpret the function's code if it does not require +/// Attempt to interpret the function's code if it does not require /// running the target. /// -/// In some cases, the IR for an expression can be evaluated entirely -/// in the debugger, manipulating variables but not executing any code -/// in the target. The IRInterpreter attempts to do this. +/// In some cases, the IR for an expression can be evaluated entirely in the +/// debugger, manipulating variables but not executing any code in the target. +/// The IRInterpreter attempts to do this. //---------------------------------------------------------------------- class IRInterpreter { public: diff --git a/include/lldb/Expression/IRMemoryMap.h b/include/lldb/Expression/IRMemoryMap.h index abb5cd745053a..df8a03f4763f5 100644 --- a/include/lldb/Expression/IRMemoryMap.h +++ b/include/lldb/Expression/IRMemoryMap.h @@ -20,19 +20,19 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class IRMemoryMap IRMemoryMap.h "lldb/Expression/IRMemoryMap.h" -/// @brief Encapsulates memory that may exist in the process but must +/// Encapsulates memory that may exist in the process but must /// also be available in the host process. /// -/// This class encapsulates a group of memory objects that must be readable -/// or writable from the host process regardless of whether the process -/// exists. This allows the IR interpreter as well as JITted code to access -/// the same memory. All allocations made by this class are represented as -/// disjoint intervals. +/// This class encapsulates a group of memory objects that must be readable or +/// writable from the host process regardless of whether the process exists. +/// This allows the IR interpreter as well as JITted code to access the same +/// memory. All allocations made by this class are represented as disjoint +/// intervals. /// /// Point queries against this group of memory objects can be made by the -/// address in the tar at which they reside. If the inferior does not -/// exist, allocations still get made-up addresses. If an inferior appears -/// at some point, then those addresses need to be re-mapped. +/// address in the tar at which they reside. If the inferior does not exist, +/// allocations still get made-up addresses. If an inferior appears at some +/// point, then those addresses need to be re-mapped. //---------------------------------------------------------------------- class IRMemoryMap { public: @@ -83,8 +83,8 @@ public: lldb::TargetSP GetTarget() { return m_target_wp.lock(); } protected: - // This function should only be used if you know you are using the JIT. - // Any other cases should use GetBestExecutionContextScope(). + // This function should only be used if you know you are using the JIT. Any + // other cases should use GetBestExecutionContextScope(). lldb::ProcessWP &GetProcessWP() { return m_process_wp; } diff --git a/include/lldb/Expression/LLVMUserExpression.h b/include/lldb/Expression/LLVMUserExpression.h index 745d413e077be..a2f87e8a6e251 100644 --- a/include/lldb/Expression/LLVMUserExpression.h +++ b/include/lldb/Expression/LLVMUserExpression.h @@ -26,25 +26,24 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class LLVMUserExpression LLVMUserExpression.h -/// "lldb/Expression/LLVMUserExpression.h" -/// @brief Encapsulates a one-time expression for use in lldb. +/// "lldb/Expression/LLVMUserExpression.h" Encapsulates a one-time expression +/// for use in lldb. /// /// LLDB uses expressions for various purposes, notably to call functions -/// and as a backend for the expr command. LLVMUserExpression is a virtual base -/// class that encapsulates the objects needed to parse and JIT an expression. -/// The actual parsing part will be provided by the specific implementations -/// of LLVMUserExpression - which will be vended through the appropriate -/// TypeSystem. +/// and as a backend for the expr command. LLVMUserExpression is a virtual +/// base class that encapsulates the objects needed to parse and JIT an +/// expression. The actual parsing part will be provided by the specific +/// implementations of LLVMUserExpression - which will be vended through the +/// appropriate TypeSystem. //---------------------------------------------------------------------- class LLVMUserExpression : public UserExpression { public: // The IRPasses struct is filled in by a runtime after an expression is - // compiled and can be used to to run - // fixups/analysis passes as required. EarlyPasses are run on the generated - // module before lldb runs its own IR + // compiled and can be used to to run fixups/analysis passes as required. + // EarlyPasses are run on the generated module before lldb runs its own IR // fixups and inserts instrumentation code/pointer checks. LatePasses are run - // after the module has been processed by - // llvm, before the module is assembled and run in the ThreadPlan. + // after the module has been processed by llvm, before the module is + // assembled and run in the ThreadPlan. struct IRPasses { IRPasses() : EarlyPasses(nullptr), LatePasses(nullptr){}; std::shared_ptr<llvm::legacy::PassManager> EarlyPasses; diff --git a/include/lldb/Expression/UserExpression.h b/include/lldb/Expression/UserExpression.h index ced5cb2bf2b7d..96ca80c882e5e 100644 --- a/include/lldb/Expression/UserExpression.h +++ b/include/lldb/Expression/UserExpression.h @@ -30,7 +30,7 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class UserExpression UserExpression.h "lldb/Expression/UserExpression.h" -/// @brief Encapsulates a one-time expression for use in lldb. +/// Encapsulates a one-time expression for use in lldb. /// /// LLDB uses expressions for various purposes, notably to call functions /// and as a backend for the expr command. UserExpression is a virtual base @@ -103,8 +103,8 @@ public: bool MatchesContext(ExecutionContext &exe_ctx); //------------------------------------------------------------------ - /// Execute the parsed expression by callinng the derived class's - /// DoExecute method. + /// Execute the parsed expression by callinng the derived class's DoExecute + /// method. /// /// @param[in] diagnostic_manager /// A diagnostic manager to report errors to. @@ -177,32 +177,29 @@ public: //------------------------------------------------------------------ /// Return the function name that should be used for executing the - /// expression. Text() should contain the definition of this - /// function. + /// expression. Text() should contain the definition of this function. //------------------------------------------------------------------ const char *FunctionName() override { return "$__lldb_expr"; } //------------------------------------------------------------------ - /// Return the language that should be used when parsing. To use - /// the default, return eLanguageTypeUnknown. + /// Return the language that should be used when parsing. To use the + /// default, return eLanguageTypeUnknown. //------------------------------------------------------------------ lldb::LanguageType Language() override { return m_language; } //------------------------------------------------------------------ - /// Return the desired result type of the function, or - /// eResultTypeAny if indifferent. + /// Return the desired result type of the function, or eResultTypeAny if + /// indifferent. //------------------------------------------------------------------ ResultType DesiredResultType() override { return m_desired_type; } //------------------------------------------------------------------ - /// Return true if validation code should be inserted into the - /// expression. + /// Return true if validation code should be inserted into the expression. //------------------------------------------------------------------ bool NeedsValidation() override { return true; } //------------------------------------------------------------------ - /// Return true if external variables in the expression should be - /// resolved. + /// Return true if external variables in the expression should be resolved. //------------------------------------------------------------------ bool NeedsVariableResolution() override { return true; } @@ -216,8 +213,8 @@ public: virtual lldb::ModuleSP GetJITModule() { return lldb::ModuleSP(); } //------------------------------------------------------------------ - /// Evaluate one expression in the scratch context of the - /// target passed in the exe_ctx and return its result. + /// Evaluate one expression in the scratch context of the target passed in + /// the exe_ctx and return its result. /// /// @param[in] exe_ctx /// The execution context to use when evaluating the expression. diff --git a/include/lldb/Expression/UtilityFunction.h b/include/lldb/Expression/UtilityFunction.h index 9c54db35fa371..5d4bc8676b95b 100644 --- a/include/lldb/Expression/UtilityFunction.h +++ b/include/lldb/Expression/UtilityFunction.h @@ -25,13 +25,13 @@ namespace lldb_private { //---------------------------------------------------------------------- -/// @class UtilityFunction UtilityFunction.h "lldb/Expression/UtilityFunction.h" -/// @brief Encapsulates a bit of source code that provides a function that is -/// callable +/// @class UtilityFunction UtilityFunction.h +/// "lldb/Expression/UtilityFunction.h" Encapsulates a bit of source code that +/// provides a function that is callable /// /// LLDB uses expressions for various purposes, notably to call functions -/// and as a backend for the expr command. UtilityFunction encapsulates -/// a self-contained function meant to be used from other code. Utility +/// and as a backend for the expr command. UtilityFunction encapsulates a +/// self-contained function meant to be used from other code. Utility /// functions can perform error-checking for ClangUserExpressions, //---------------------------------------------------------------------- class UtilityFunction : public Expression { @@ -69,8 +69,7 @@ public: /// Check whether the given PC is inside the function /// /// Especially useful if the function dereferences nullptr to indicate a - /// failed - /// assert. + /// failed assert. /// /// @param[in] pc /// The program counter to check. @@ -80,8 +79,8 @@ public: /// false if not (or the function is not JIT compiled) //------------------------------------------------------------------ bool ContainsAddress(lldb::addr_t address) { - // nothing is both >= LLDB_INVALID_ADDRESS and < LLDB_INVALID_ADDRESS, - // so this always returns false if the function is not JIT compiled yet + // nothing is both >= LLDB_INVALID_ADDRESS and < LLDB_INVALID_ADDRESS, so + // this always returns false if the function is not JIT compiled yet return (address >= m_jit_start_addr && address < m_jit_end_addr); } @@ -93,33 +92,29 @@ public: //------------------------------------------------------------------ /// Return the function name that should be used for executing the - /// expression. Text() should contain the definition of this - /// function. + /// expression. Text() should contain the definition of this function. //------------------------------------------------------------------ const char *FunctionName() override { return m_function_name.c_str(); } //------------------------------------------------------------------ - /// Return the object that the parser should use when registering - /// local variables. May be nullptr if the Expression doesn't care. + /// Return the object that the parser should use when registering local + /// variables. May be nullptr if the Expression doesn't care. //------------------------------------------------------------------ ExpressionVariableList *LocalVariables() { return nullptr; } //------------------------------------------------------------------ - /// Return true if validation code should be inserted into the - /// expression. + /// Return true if validation code should be inserted into the expression. //------------------------------------------------------------------ bool NeedsValidation() override { return false; } //------------------------------------------------------------------ - /// Return true if external variables in the expression should be - /// resolved. + /// Return true if external variables in the expression should be resolved. //------------------------------------------------------------------ bool NeedsVariableResolution() override { return false; } - // This makes the function caller function. - // Pass in the ThreadSP if you have one available, compilation can end up - // calling code (e.g. to look up indirect - // functions) and we don't want this to wander onto another thread. + // This makes the function caller function. Pass in the ThreadSP if you have + // one available, compilation can end up calling code (e.g. to look up + // indirect functions) and we don't want this to wander onto another thread. FunctionCaller *MakeFunctionCaller(const CompilerType &return_type, const ValueList &arg_value_list, lldb::ThreadSP compilation_thread, diff --git a/include/lldb/Host/Config.h b/include/lldb/Host/Config.h index 3fa19e77452d3..771937498b329 100644 --- a/include/lldb/Host/Config.h +++ b/include/lldb/Host/Config.h @@ -16,6 +16,10 @@ // absence of a configuration step. #define LLDB_CONFIG_TERMIOS_SUPPORTED 1 +#define LLDB_EDITLINE_USE_WCHAR 1 + +#define LLDB_HAVE_EL_RFUNC_T 1 + #define HAVE_SYS_EVENT_H 1 #define HAVE_PPOLL 0 diff --git a/include/lldb/Host/Config.h.cmake b/include/lldb/Host/Config.h.cmake index 73f4b8f6cc4ab..02a57ad8ca921 100644 --- a/include/lldb/Host/Config.h.cmake +++ b/include/lldb/Host/Config.h.cmake @@ -12,8 +12,14 @@ #cmakedefine LLDB_CONFIG_TERMIOS_SUPPORTED +#cmakedefine01 LLDB_EDITLINE_USE_WCHAR + +#cmakedefine01 LLDB_HAVE_EL_RFUNC_T + #cmakedefine LLDB_DISABLE_POSIX +#define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" + #cmakedefine01 HAVE_SYS_EVENT_H #cmakedefine01 HAVE_PPOLL @@ -24,6 +30,8 @@ #cmakedefine01 HAVE_NR_PROCESS_VM_READV +#ifndef HAVE_LIBCOMPRESSION #cmakedefine HAVE_LIBCOMPRESSION +#endif #endif // #ifndef LLDB_HOST_CONFIG_H diff --git a/include/lldb/Host/Debug.h b/include/lldb/Host/Debug.h index fc190a4eca8f2..ed8e633c113fe 100644 --- a/include/lldb/Host/Debug.h +++ b/include/lldb/Host/Debug.h @@ -25,7 +25,8 @@ namespace lldb_private { //------------------------------------------------------------------ struct ResumeAction { lldb::tid_t tid; // The thread ID that this action applies to, - // LLDB_INVALID_THREAD_ID for the default thread action + // LLDB_INVALID_THREAD_ID for the default thread + // action lldb::StateType state; // Valid values are eStateStopped/eStateSuspended, // eStateRunning, and eStateStepping. int signal; // When resuming this thread, resume it with this signal if this @@ -34,10 +35,9 @@ struct ResumeAction { //------------------------------------------------------------------ // A class that contains instructions for all threads for -// NativeProcessProtocol::Resume(). Each thread can either run, stay -// suspended, or step when the process is resumed. We optionally -// have the ability to also send a signal to the thread when the -// action is run or step. +// NativeProcessProtocol::Resume(). Each thread can either run, stay suspended, +// or step when the process is resumed. We optionally have the ability to also +// send a signal to the thread when the action is run or step. //------------------------------------------------------------------ class ResumeActionList { public: diff --git a/include/lldb/Host/Editline.h b/include/lldb/Host/Editline.h index 0b75e9c923cab..beb96e7c49241 100644 --- a/include/lldb/Host/Editline.h +++ b/include/lldb/Host/Editline.h @@ -23,8 +23,8 @@ // broken, which is why we're // working around it here. // c) When resizing the terminal window, if the cursor moves between rows -// libedit will get confused. -// d) The incremental search uses escape to cancel input, so it's confused by +// libedit will get confused. d) The incremental search uses escape to cancel +// input, so it's confused by // ANSI sequences starting with escape. // e) Emoji support is fairly terrible, presumably it doesn't understand // composed characters? @@ -33,24 +33,13 @@ #define liblldb_Editline_h_ #if defined(__cplusplus) +#if LLDB_EDITLINE_USE_WCHAR +#include <codecvt> +#endif #include <locale> #include <sstream> #include <vector> -// components needed to handle wide characters ( <codecvt>, codecvt_utf8, -// libedit built with '--enable-widec' ) -// are available on some platforms. The wchar_t versions of libedit functions -// will only be -// used in cases where this is true. This is a compile time dependecy, for now -// selected per target Platform -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \ - defined(__OpenBSD__) -#define LLDB_EDITLINE_USE_WCHAR 1 -#include <codecvt> -#else -#define LLDB_EDITLINE_USE_WCHAR 0 -#endif - #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/lldb-private.h" @@ -82,7 +71,11 @@ using EditLineStringStreamType = std::stringstream; using EditLineCharType = char; #endif -#ifdef EL_CLIENTDATA /* editline with wide support + wide char read function */ +// At one point the callback type of el_set getchar callback changed from char +// to wchar_t. It is not possible to detect differentiate between the two +// versions exactly, but this is a pretty good approximation and allows us to +// build against almost any editline version out there. +#if LLDB_EDITLINE_USE_WCHAR || defined(EL_CLIENTDATA) || LLDB_HAVE_EL_RFUNC_T using EditLineGetCharType = wchar_t; #else using EditLineGetCharType = char; diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h index 1dfa12ea593d6..d240f810bc8b9 100644 --- a/include/lldb/Host/File.h +++ b/include/lldb/Host/File.h @@ -23,7 +23,7 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class File File.h "lldb/Host/File.h" -/// @brief A file class. +/// A file class. /// /// A file class that divides abstracts the LLDB core from host file /// functionality. @@ -65,9 +65,9 @@ public: //------------------------------------------------------------------ /// 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). + /// 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. @@ -78,7 +78,8 @@ public: /// @param[in] permissions /// Options to use when opening (see File::Permissions) /// - /// @see File::Open (const char *path, uint32_t options, uint32_t 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); @@ -87,8 +88,7 @@ public: /// 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 + /// 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 @@ -100,7 +100,8 @@ public: /// @param[in] permissions /// Options to use when opening (see File::Permissions) /// - /// @see File::Open (const char *path, uint32_t options, uint32_t 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); @@ -125,8 +126,8 @@ public: //------------------------------------------------------------------ /// Convert to pointer operator. /// - /// This allows code to check a File object to see if it - /// contains anything valid using code such as: + /// This allows code to check a File object to see if it contains anything + /// valid using code such as: /// /// @code /// File file(...); @@ -143,8 +144,8 @@ public: //------------------------------------------------------------------ /// Logical NOT operator. /// - /// This allows code to check a File object to see if it is - /// invalid using code such as: + /// This allows code to check a File object to see if it is invalid using + /// code such as: /// /// @code /// File file(...); @@ -169,8 +170,7 @@ public: //------------------------------------------------------------------ /// 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. + /// 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. @@ -202,8 +202,8 @@ public: /// Read bytes from a file from the current file position. /// /// NOTE: This function is NOT thread safe. Use the read function - /// that takes an "off_t &offset" to ensure correct operation in - /// multi-threaded environments. + /// that takes an "off_t &offset" to ensure correct operation in multi- + /// threaded environments. /// /// @param[in] buf /// A buffer where to put the bytes that are read. @@ -222,8 +222,8 @@ public: /// Write bytes to a file at the current file position. /// /// NOTE: This function is NOT thread safe. Use the write function - /// that takes an "off_t &offset" to ensure correct operation in - /// multi-threaded environments. + /// that takes an "off_t &offset" to ensure correct operation in multi- + /// threaded environments. /// /// @param[in] buf /// A buffer where to put the bytes that are read. @@ -243,10 +243,10 @@ public: /// Seek to an offset relative to the beginning of the file. /// /// NOTE: This function is NOT thread safe, other threads that - /// access this object might also change the current file position. - /// For thread safe reads and writes see the following functions: - /// @see File::Read (void *, size_t, off_t &) - /// @see File::Write (const void *, size_t, off_t &) + /// access this object might also change the current file position. For + /// thread safe reads and writes see the following functions: @see + /// File::Read (void *, size_t, off_t &) @see File::Write (const void *, + /// size_t, off_t &) /// /// @param[in] offset /// The offset to seek to within the file relative to the @@ -265,10 +265,10 @@ public: /// Seek to an offset relative to the current file position. /// /// NOTE: This function is NOT thread safe, other threads that - /// access this object might also change the current file position. - /// For thread safe reads and writes see the following functions: - /// @see File::Read (void *, size_t, off_t &) - /// @see File::Write (const void *, size_t, off_t &) + /// access this object might also change the current file position. For + /// thread safe reads and writes see the following functions: @see + /// File::Read (void *, size_t, off_t &) @see File::Write (const void *, + /// size_t, off_t &) /// /// @param[in] offset /// The offset to seek to within the file relative to the @@ -287,10 +287,10 @@ public: /// Seek to an offset relative to the end of the file. /// /// NOTE: This function is NOT thread safe, other threads that - /// access this object might also change the current file position. - /// For thread safe reads and writes see the following functions: - /// @see File::Read (void *, size_t, off_t &) - /// @see File::Write (const void *, size_t, off_t &) + /// access this object might also change the current file position. For + /// thread safe reads and writes see the following functions: @see + /// File::Read (void *, size_t, off_t &) @see File::Write (const void *, + /// size_t, off_t &) /// /// @param[in,out] offset /// The offset to seek to within the file relative to the @@ -310,8 +310,8 @@ public: /// Read bytes from a file from the specified file offset. /// /// NOTE: This function is thread safe in that clients manager their - /// own file position markers and reads on other threads won't mess - /// up the current read. + /// own file position markers and reads on other threads won't mess up the + /// current read. /// /// @param[in] dst /// A buffer where to put the bytes that are read. @@ -335,8 +335,8 @@ public: /// Read bytes from a file from the specified file offset. /// /// NOTE: This function is thread safe in that clients manager their - /// own file position markers and reads on other threads won't mess - /// up the current read. + /// own file position markers and reads on other threads won't mess up the + /// current read. /// /// @param[in,out] num_bytes /// The number of bytes to read form the current file position @@ -367,9 +367,9 @@ public: /// Write bytes to a file at the specified file offset. /// /// NOTE: This function is thread safe in that clients manager their - /// own file position markers, though clients will need to implement - /// their own locking externally to avoid multiple people writing - /// to the file at the same time. + /// own file position markers, though clients will need to implement their + /// own locking externally to avoid multiple people writing to the file at + /// the same time. /// /// @param[in] src /// A buffer containing the bytes to write. @@ -431,10 +431,9 @@ public: //------------------------------------------------------------------ /// Return true if this file from a real terminal. /// - /// Just knowing a file is a interactive isn't enough, we also need - /// to know if the terminal has a width and height so we can do - /// cursor movement and other terminal manipulations by sending - /// escape sequences. + /// Just knowing a file is a interactive isn't enough, we also need to know + /// if the terminal has a width and height so we can do cursor movement and + /// other terminal manipulations by sending escape sequences. /// /// @return /// True if this file is a terminal (tty, not a pty) that has diff --git a/include/lldb/Host/Host.h b/include/lldb/Host/Host.h index f099c72381be7..459e9f563d1ee 100644 --- a/include/lldb/Host/Host.h +++ b/include/lldb/Host/Host.h @@ -12,8 +12,9 @@ #include "lldb/Host/File.h" #include "lldb/Host/HostThread.h" +#include "lldb/Utility/Environment.h" #include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/StringList.h" +#include "lldb/Utility/Timeout.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-private.h" #include <cerrno> @@ -56,10 +57,9 @@ inline bool operator!=(WaitStatus a, WaitStatus b) { return !(a == b); } //---------------------------------------------------------------------- /// @class Host Host.h "lldb/Host/Host.h" -/// @brief A class that provides host computer information. +/// A class that provides host computer information. /// -/// Host is a class that answers information about the host operating -/// system. +/// Host is a class that answers information about the host operating system. //---------------------------------------------------------------------- class Host { public: @@ -72,18 +72,17 @@ public: //------------------------------------------------------------------ /// Start monitoring a child process. /// - /// Allows easy monitoring of child processes. \a callback will be - /// called when the child process exits or if it gets a signal. The - /// callback will only be called with signals if \a monitor_signals - /// is \b true. \a callback will usually be called from another - /// thread so the callback function must be thread safe. + /// Allows easy monitoring of child processes. \a callback will be called + /// when the child process exits or if it gets a signal. The callback will + /// only be called with signals if \a monitor_signals is \b true. \a + /// callback will usually be called from another thread so the callback + /// function must be thread safe. /// - /// When the callback gets called, the return value indicates if - /// monitoring should stop. If \b true is returned from \a callback - /// the information will be removed. If \b false is returned then - /// monitoring will continue. If the child process exits, the - /// monitoring will automatically stop after the callback returned - /// regardless of the callback return value. + /// When the callback gets called, the return value indicates if monitoring + /// should stop. If \b true is returned from \a callback the information + /// will be removed. If \b false is returned then monitoring will continue. + /// If the child process exits, the monitoring will automatically stop after + /// the callback returned regardless of the callback return value. /// /// @param[in] callback /// A function callback to call when a child receives a signal @@ -126,9 +125,8 @@ public: static void Kill(lldb::pid_t pid, int signo); //------------------------------------------------------------------ - /// Get the thread token (the one returned by ThreadCreate when the thread was - /// created) for the - /// calling thread in the current process. + /// Get the thread token (the one returned by ThreadCreate when the thread + /// was created) for the calling thread in the current process. /// /// @return /// The thread token for the calling thread in the current process. @@ -138,11 +136,11 @@ public: static const char *GetSignalAsCString(int signo); //------------------------------------------------------------------ - /// Given an address in the current process (the process that - /// is running the LLDB code), return the name of the module that - /// it comes from. This can be useful when you need to know the - /// path to the shared library that your code is running in for - /// loading resources that are relative to your binary. + /// Given an address in the current process (the process that is running the + /// LLDB code), return the name of the module that it comes from. This can + /// be useful when you need to know the path to the shared library that your + /// code is running in for loading resources that are relative to your + /// binary. /// /// @param[in] host_addr /// The pointer to some code in the current process. @@ -155,10 +153,9 @@ public: static FileSpec GetModuleFileSpecForHostAddress(const void *host_addr); //------------------------------------------------------------------ - /// If you have an executable that is in a bundle and want to get - /// back to the bundle directory from the path itself, this - /// function will change a path to a file within a bundle to the - /// bundle directory itself. + /// If you have an executable that is in a bundle and want to get back to + /// the bundle directory from the path itself, this function will change a + /// path to a file within a bundle to the bundle directory itself. /// /// @param[in] file /// A file spec that might point to a file in a bundle. @@ -176,10 +173,9 @@ public: FileSpec &bundle_directory); //------------------------------------------------------------------ - /// When executable files may live within a directory, where the - /// directory represents an executable bundle (like the MacOSX - /// app bundles), then locate the executable within the containing - /// bundle. + /// When executable files may live within a directory, where the directory + /// represents an executable bundle (like the MacOSX app bundles), then + /// locate the executable within the containing bundle. /// /// @param[in,out] file /// A file spec that currently points to the bundle that will @@ -203,11 +199,14 @@ public: static const lldb::UnixSignalsSP &GetUnixSignals(); + /// Launch the process specified in launch_info. The monitoring callback in + /// launch_info must be set, and it will be called when the process + /// terminates. static Status LaunchProcess(ProcessLaunchInfo &launch_info); //------------------------------------------------------------------ - /// Perform expansion of the command-line for this launch info - /// This can potentially involve wildcard expansion + /// Perform expansion of the command-line for this launch info This can + /// potentially involve wildcard expansion // environment variable replacement, and whatever other // argument magic the platform defines as part of its typical // user experience @@ -224,8 +223,7 @@ public: // process to exit std::string *command_output, // Pass NULL if you don't want the command output - uint32_t timeout_sec, - bool run_in_default_shell = true); + const Timeout<std::micro> &timeout, bool run_in_default_shell = true); static Status RunShellCommand( const Args &args, @@ -236,13 +234,12 @@ public: // process to exit std::string *command_output, // Pass NULL if you don't want the command output - uint32_t timeout_sec, - bool run_in_default_shell = true); + const Timeout<std::micro> &timeout, bool run_in_default_shell = true); static bool OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no); - static size_t GetEnvironment(StringList &env); + static Environment GetEnvironment(); static std::unique_ptr<Connection> CreateDefaultConnection(llvm::StringRef url); @@ -252,8 +249,8 @@ public: namespace llvm { template <> struct format_provider<lldb_private::WaitStatus> { - /// Options = "" gives a human readable description of the status - /// Options = "g" gives a gdb-remote protocol status (e.g., X09) + /// Options = "" gives a human readable description of the status Options = + /// "g" gives a gdb-remote protocol status (e.g., X09) static void format(const lldb_private::WaitStatus &WS, raw_ostream &OS, llvm::StringRef Options); }; diff --git a/include/lldb/Host/HostInfo.h b/include/lldb/Host/HostInfo.h index b4a2f8baf37fc..df762d7160e05 100644 --- a/include/lldb/Host/HostInfo.h +++ b/include/lldb/Host/HostInfo.h @@ -12,7 +12,7 @@ //---------------------------------------------------------------------- /// @class HostInfo HostInfo.h "lldb/Host/HostInfo.h" -/// @brief A class that provides host computer information. +/// A class that provides host computer information. /// /// HostInfo is a class that answers information about the host operating /// system. Note that HostInfo is NOT intended to be used to manipulate or @@ -22,15 +22,16 @@ /// HostInfoWindows) in a separate file, and then typedefed to HostInfo here. /// Users of the class reference it as HostInfo::method(). /// -/// Not all hosts provide the same functionality. It is important that methods -/// only be implemented at the lowest level at which they make sense. It should -/// be up to the clients of the class to ensure that they not attempt to call a -/// method which doesn't make sense for a particular platform. For example, -/// when implementing a method that only makes sense on a posix-compliant -/// system, implement it on HostInfoPosix, and not on HostInfoBase with a -/// default implementation. This way, users of HostInfo are required to think -/// about the implications of calling a particular method and if used in a -/// context where the method doesn't make sense, will generate a compiler error. +/// Not all hosts provide the same functionality. It is important that +/// methods only be implemented at the lowest level at which they make sense. +/// It should be up to the clients of the class to ensure that they not +/// attempt to call a method which doesn't make sense for a particular +/// platform. For example, when implementing a method that only makes sense +/// on a posix-compliant system, implement it on HostInfoPosix, and not on +/// HostInfoBase with a default implementation. This way, users of HostInfo +/// are required to think about the implications of calling a particular +/// method and if used in a context where the method doesn't make sense, will +/// generate a compiler error. /// //---------------------------------------------------------------------- diff --git a/include/lldb/Host/HostInfoBase.h b/include/lldb/Host/HostInfoBase.h index 52648d2031fce..b2567b2962778 100644 --- a/include/lldb/Host/HostInfoBase.h +++ b/include/lldb/Host/HostInfoBase.h @@ -63,25 +63,39 @@ public: static llvm::Optional<ArchitectureKind> ParseArchitectureKind(llvm::StringRef kind); - //------------------------------------------------------------------ - /// Find a resource files that are related to LLDB. - /// - /// Operating systems have different ways of storing shared - /// libraries and related resources. This function abstracts the - /// access to these paths. - /// - /// @param[in] path_type - /// The type of LLDB resource path you are looking for. If the - /// enumeration ends with "Dir", then only the \a file_spec's - /// directory member gets filled in. - /// - /// @param[in] file_spec - /// A file spec that gets filled in with the appropriate path. - /// - /// @return - /// \b true if \a resource_path was resolved, \a false otherwise. - //------------------------------------------------------------------ - static bool GetLLDBPath(lldb::PathType type, FileSpec &file_spec); + /// Returns the directory containing the lldb shared library. Only the + /// directory member of the FileSpec is filled in. + static FileSpec GetShlibDir(); + + /// Returns the directory containing the support executables (debugserver, + /// ...). Only the directory member of the FileSpec is filled in. + static FileSpec GetSupportExeDir(); + + /// Returns the directory containing the lldb headers. Only the directory + /// 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(); + + /// Returns the directory containing the user plugins. Only the directory + /// member of the FileSpec is filled in. + static FileSpec GetUserPluginDir(); + + /// Returns the proces temporary directory. This directory will be cleaned up + /// when this process exits. Only the directory member of the FileSpec is + /// filled in. + static FileSpec GetProcessTempDir(); + + /// Returns the global temporary directory. This directory will **not** be + /// cleaned up when this process exits. Only the directory member of the + /// FileSpec is filled in. + static FileSpec GetGlobalTempDir(); //--------------------------------------------------------------------------- /// If the triple does not specify the vendor, os, and environment parts, we @@ -98,7 +112,6 @@ protected: static bool ComputeTempFileBaseDirectory(FileSpec &file_spec); static bool ComputeHeaderDirectory(FileSpec &file_spec); static bool ComputeSystemPluginsDirectory(FileSpec &file_spec); - static bool ComputeClangDirectory(FileSpec &file_spec); static bool ComputeUserPluginsDirectory(FileSpec &file_spec); static void ComputeHostArchitectureSupport(ArchSpec &arch_32, diff --git a/include/lldb/Host/HostProcess.h b/include/lldb/Host/HostProcess.h index dfc997bd81f72..626ebab7ce686 100644 --- a/include/lldb/Host/HostProcess.h +++ b/include/lldb/Host/HostProcess.h @@ -15,17 +15,17 @@ //---------------------------------------------------------------------- /// @class HostInfo HostInfo.h "lldb/Host/HostProcess.h" -/// @brief A class that represents a running process on the host machine. +/// A class that represents a running process on the host machine. /// /// HostProcess allows querying and manipulation of processes running on the -/// host machine. It is not intended to be represent a process which is -/// being debugged, although the native debug engine of a platform may likely -/// back inferior processes by a HostProcess. +/// host machine. It is not intended to be represent a process which is being +/// debugged, although the native debug engine of a platform may likely back +/// inferior processes by a HostProcess. /// /// HostProcess is implemented using static polymorphism so that on any given -/// platform, an instance of HostProcess will always be able to bind statically -/// to the concrete Process implementation for that platform. See HostInfo -/// for more details. +/// platform, an instance of HostProcess will always be able to bind +/// statically to the concrete Process implementation for that platform. See +/// HostInfo for more details. /// //---------------------------------------------------------------------- diff --git a/include/lldb/Host/HostThread.h b/include/lldb/Host/HostThread.h index 0d2fbe6045af0..120776283aa42 100644 --- a/include/lldb/Host/HostThread.h +++ b/include/lldb/Host/HostThread.h @@ -22,7 +22,7 @@ class HostNativeThreadBase; //---------------------------------------------------------------------- /// @class HostInfo HostInfo.h "lldb/Host/HostThread.h" -/// @brief A class that represents a thread running inside of a process on the +/// A class that represents a thread running inside of a process on the /// local machine. /// /// HostThread allows querying and manipulation of threads running on the host diff --git a/include/lldb/Host/MainLoop.h b/include/lldb/Host/MainLoop.h index c59a5aa5b0e83..13d1ff0212fa4 100644 --- a/include/lldb/Host/MainLoop.h +++ b/include/lldb/Host/MainLoop.h @@ -21,12 +21,12 @@ namespace lldb_private { -// Implementation of the MainLoopBase class. It can monitor file descriptors for -// readability using ppoll, kqueue, poll or WSAPoll. On Windows it only supports -// polling sockets, and will not work on generic file handles or pipes. On -// systems without kqueue or ppoll handling singnals is not supported. In -// addition to the common base, this class provides the ability to invoke a -// given handler when a signal is received. +// Implementation of the MainLoopBase class. It can monitor file descriptors +// for readability using ppoll, kqueue, poll or WSAPoll. On Windows it only +// supports polling sockets, and will not work on generic file handles or +// pipes. On systems without kqueue or ppoll handling singnals is not +// supported. In addition to the common base, this class provides the ability +// to invoke a given handler when a signal is received. // // Since this class is primarily intended to be used for single-threaded // processing, it does not attempt to perform any internal synchronisation and @@ -49,13 +49,13 @@ public: const Callback &callback, Status &error) override; - // Listening for signals from multiple MainLoop instances is perfectly safe as - // long as they don't try to listen for the same signal. The callback function - // is invoked when the control returns to the Run() function, not when the - // hander is executed. This mean that you can treat the callback as a normal - // function and perform things which would not be safe in a signal handler. - // However, since the callback is not invoked synchronously, you cannot use - // this mechanism to handle SIGSEGV and the like. + // Listening for signals from multiple MainLoop instances is perfectly safe + // as long as they don't try to listen for the same signal. The callback + // function is invoked when the control returns to the Run() function, not + // when the hander is executed. This mean that you can treat the callback as + // a normal function and perform things which would not be safe in a signal + // handler. However, since the callback is not invoked synchronously, you + // cannot use this mechanism to handle SIGSEGV and the like. SignalHandleUP RegisterSignal(int signo, const Callback &callback, Status &error); diff --git a/include/lldb/Host/MainLoopBase.h b/include/lldb/Host/MainLoopBase.h index a87d262e94525..bf01ba16db0ec 100644 --- a/include/lldb/Host/MainLoopBase.h +++ b/include/lldb/Host/MainLoopBase.h @@ -18,21 +18,17 @@ namespace lldb_private { // The purpose of this class is to enable multiplexed processing of data from -// different sources -// without resorting to multi-threading. Clients can register IOObjects, which -// will be monitored -// for readability, and when they become ready, the specified callback will be -// invoked. -// Monitoring for writability is not supported, but can be easily added if -// needed. +// different sources without resorting to multi-threading. Clients can register +// IOObjects, which will be monitored for readability, and when they become +// ready, the specified callback will be invoked. Monitoring for writability is +// not supported, but can be easily added if needed. // // The RegisterReadObject function return a handle, which controls the duration -// of the monitoring. When -// this handle is destroyed, the callback is deregistered. +// of the monitoring. When this handle is destroyed, the callback is +// deregistered. // // This class simply defines the interface common for all platforms, actual -// implementations are -// platform-specific. +// implementations are platform-specific. class MainLoopBase { private: class ReadHandle; @@ -52,8 +48,7 @@ public: } // Waits for registered events and invoke the proper callbacks. Returns when - // all callbacks - // deregister themselves or when someone requests termination. + // all callbacks deregister themselves or when someone requests termination. virtual Status Run() { llvm_unreachable("Not implemented"); } // Requests the exit of the Run() function. diff --git a/include/lldb/Host/MonitoringProcessLauncher.h b/include/lldb/Host/MonitoringProcessLauncher.h index 9ad36e90a7790..341284800a4e5 100644 --- a/include/lldb/Host/MonitoringProcessLauncher.h +++ b/include/lldb/Host/MonitoringProcessLauncher.h @@ -24,6 +24,9 @@ public: explicit MonitoringProcessLauncher( std::unique_ptr<ProcessLauncher> delegate_launcher); + /// Launch the process specified in launch_info. The monitoring callback in + /// launch_info must be set, and it will be called when the process + /// terminates. HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info, Status &error) override; diff --git a/include/lldb/Host/PosixApi.h b/include/lldb/Host/PosixApi.h index d5c48dd6d1705..dae2bb4800916 100644 --- a/include/lldb/Host/PosixApi.h +++ b/include/lldb/Host/PosixApi.h @@ -11,13 +11,14 @@ #define liblldb_Host_PosixApi_h // This file defines platform specific functions, macros, and types necessary -// to provide a minimum level of compatibility across all platforms to rely -// on various posix api functionality. +// to provide a minimum level of compatibility across all platforms to rely on +// various posix api functionality. #if defined(_WIN32) #include "lldb/Host/windows/PosixApi.h" #else #include <unistd.h> +#include <csignal> #endif #endif diff --git a/include/lldb/Host/Predicate.h b/include/lldb/Host/Predicate.h index 3ee27e74b4ba9..d8128e71c53e1 100644 --- a/include/lldb/Host/Predicate.h +++ b/include/lldb/Host/Predicate.h @@ -20,6 +20,7 @@ // Other libraries and framework includes // Project includes +#include "lldb/Utility/Timeout.h" #include "lldb/lldb-defines.h" //#define DB_PTHREAD_LOG_EVENTS @@ -38,8 +39,8 @@ typedef enum { //---------------------------------------------------------------------- /// @class Predicate Predicate.h "lldb/Host/Predicate.h" -/// @brief A C++ wrapper class for providing threaded access to a value -/// of type T. +/// A C++ wrapper class for providing threaded access to a value of +/// type T. /// /// A templatized class that provides multi-threaded access to a value /// of type T. Threads can efficiently wait for bits within T to be set @@ -118,169 +119,39 @@ public: } //------------------------------------------------------------------ - /// Set some bits in \a m_value. + /// Wait for Cond(m_value) to be true. /// - /// Logically set the bits \a bits in the contained \a m_value in a - /// thread safe way and broadcast if needed. + /// Waits in a thread safe way for Cond(m_value) to be true. If Cond(m_value) + /// is already true, this function will return without waiting. /// - /// @param[in] bits - /// The bits to set in \a m_value. + /// It is possible for the value to be changed between the time the value is + /// set and the time the waiting thread wakes up. If the value no longer + /// satisfies the condition when the waiting thread wakes up, it will go back + /// into a wait state. It may be necessary for the calling code to use + /// additional thread synchronization methods to detect transitory states. /// - /// @param[in] broadcast_type - /// A value indicating when and if to broadcast. See the - /// PredicateBroadcastType enumeration for details. - /// - /// @see Predicate::Broadcast() - //------------------------------------------------------------------ - void SetValueBits(T bits, PredicateBroadcastType broadcast_type) { - std::lock_guard<std::mutex> guard(m_mutex); -#ifdef DB_PTHREAD_LOG_EVENTS - printf("%s (bits = 0x%8.8x, broadcast_type = %i)\n", __FUNCTION__, bits, - broadcast_type); -#endif - const T old_value = m_value; - m_value |= bits; - - Broadcast(old_value, broadcast_type); - } - - //------------------------------------------------------------------ - /// Reset some bits in \a m_value. - /// - /// Logically reset (clear) the bits \a bits in the contained - /// \a m_value in a thread safe way and broadcast if needed. - /// - /// @param[in] bits - /// The bits to clear in \a m_value. - /// - /// @param[in] broadcast_type - /// A value indicating when and if to broadcast. See the - /// PredicateBroadcastType enumeration for details. - /// - /// @see Predicate::Broadcast() - //------------------------------------------------------------------ - void ResetValueBits(T bits, PredicateBroadcastType broadcast_type) { - std::lock_guard<std::mutex> guard(m_mutex); -#ifdef DB_PTHREAD_LOG_EVENTS - printf("%s (bits = 0x%8.8x, broadcast_type = %i)\n", __FUNCTION__, bits, - broadcast_type); -#endif - const T old_value = m_value; - m_value &= ~bits; - - Broadcast(old_value, broadcast_type); - } - - //------------------------------------------------------------------ - /// Wait for bits to be set in \a m_value. - /// - /// Waits in a thread safe way for any bits in \a bits to get - /// logically set in \a m_value. If any bits are already set in - /// \a m_value, this function will return without waiting. - /// - /// It is possible for the value to be changed between the time - /// the bits are set and the time the waiting thread wakes up. - /// If the bits are no longer set when the waiting thread wakes - /// up, it will go back into a wait state. It may be necessary - /// for the calling code to use additional thread synchronization - /// methods to detect transitory states. - /// - /// @param[in] bits - /// The bits we are waiting to be set in \a m_value. - /// - /// @param[in] abstime - /// If non-nullptr, the absolute time at which we should stop - /// waiting, else wait an infinite amount of time. - /// - /// @return - /// Any bits of the requested bits that actually were set within - /// the time specified. Zero if a timeout or unrecoverable error - /// occurred. - //------------------------------------------------------------------ - T WaitForSetValueBits(T bits, const std::chrono::microseconds &timeout = - std::chrono::microseconds(0)) { - // pthread_cond_timedwait() or pthread_cond_wait() will atomically - // unlock the mutex and wait for the condition to be set. When either - // function returns, they will re-lock the mutex. We use an auto lock/unlock - // class (std::lock_guard) to allow us to return at any point in this - // function and not have to worry about unlocking the mutex. - std::unique_lock<std::mutex> lock(m_mutex); -#ifdef DB_PTHREAD_LOG_EVENTS - printf("%s (bits = 0x%8.8x, timeout = %llu), m_value = 0x%8.8x\n", - __FUNCTION__, bits, timeout.count(), m_value); -#endif - while ((m_value & bits) == 0) { - if (timeout == std::chrono::microseconds(0)) { - m_condition.wait(lock); - } else { - std::cv_status result = m_condition.wait_for(lock, timeout); - if (result == std::cv_status::timeout) - break; - } - } -#ifdef DB_PTHREAD_LOG_EVENTS - printf("%s (bits = 0x%8.8x), m_value = 0x%8.8x, returning 0x%8.8x\n", - __FUNCTION__, bits, m_value, m_value & bits); -#endif - - return m_value & bits; - } - - //------------------------------------------------------------------ - /// Wait for bits to be reset in \a m_value. - /// - /// Waits in a thread safe way for any bits in \a bits to get - /// logically reset in \a m_value. If all bits are already reset in - /// \a m_value, this function will return without waiting. - /// - /// It is possible for the value to be changed between the time - /// the bits are reset and the time the waiting thread wakes up. - /// If the bits are no set when the waiting thread wakes up, it will - /// go back into a wait state. It may be necessary for the calling - /// code to use additional thread synchronization methods to detect - /// transitory states. - /// - /// @param[in] bits - /// The bits we are waiting to be reset in \a m_value. + /// @param[in] Cond + /// The condition we want \a m_value satisfy. /// - /// @param[in] abstime - /// If non-nullptr, the absolute time at which we should stop - /// waiting, else wait an infinite amount of time. + /// @param[in] timeout + /// How long to wait for the condition to hold. /// /// @return - /// Zero on successful waits, or non-zero if a timeout or - /// unrecoverable error occurs. + /// @li m_value if Cond(m_value) is true. + /// @li None otherwise (timeout occurred). //------------------------------------------------------------------ - T WaitForResetValueBits(T bits, const std::chrono::microseconds &timeout = - std::chrono::microseconds(0)) { - // pthread_cond_timedwait() or pthread_cond_wait() will atomically - // unlock the mutex and wait for the condition to be set. When either - // function returns, they will re-lock the mutex. We use an auto lock/unlock - // class (std::lock_guard) to allow us to return at any point in this - // function and not have to worry about unlocking the mutex. + template <typename C> + llvm::Optional<T> WaitFor(C Cond, const Timeout<std::micro> &timeout) { std::unique_lock<std::mutex> lock(m_mutex); - -#ifdef DB_PTHREAD_LOG_EVENTS - printf("%s (bits = 0x%8.8x, timeout = %llu), m_value = 0x%8.8x\n", - __FUNCTION__, bits, timeout.count(), m_value); -#endif - while ((m_value & bits) != 0) { - if (timeout == std::chrono::microseconds(0)) { - m_condition.wait(lock); - } else { - std::cv_status result = m_condition.wait_for(lock, timeout); - if (result == std::cv_status::timeout) - break; - } + auto RealCond = [&] { return Cond(m_value); }; + if (!timeout) { + m_condition.wait(lock, RealCond); + return m_value; } - -#ifdef DB_PTHREAD_LOG_EVENTS - printf("%s (bits = 0x%8.8x), m_value = 0x%8.8x, returning 0x%8.8x\n", - __FUNCTION__, bits, m_value, m_value & bits); -#endif - return m_value & bits; + if (m_condition.wait_for(lock, *timeout, RealCond)) + return m_value; + return llvm::None; } - //------------------------------------------------------------------ /// Wait for \a m_value to be equal to \a value. /// @@ -298,124 +169,17 @@ public: /// @param[in] value /// The value we want \a m_value to be equal to. /// - /// @param[in] abstime - /// If non-nullptr, the absolute time at which we should stop - /// waiting, else wait an infinite amount of time. - /// - /// @param[out] timed_out - /// If not null, set to true if we return because of a time out, - /// and false if the value was set. + /// @param[in] timeout + /// How long to wait for the condition to hold. /// /// @return /// @li \b true if the \a m_value is equal to \a value - /// @li \b false otherwise + /// @li \b false otherwise (timeout occurred) //------------------------------------------------------------------ - bool WaitForValueEqualTo(T value, const std::chrono::microseconds &timeout = - std::chrono::microseconds(0), - bool *timed_out = nullptr) { - // pthread_cond_timedwait() or pthread_cond_wait() will atomically - // unlock the mutex and wait for the condition to be set. When either - // function returns, they will re-lock the mutex. We use an auto lock/unlock - // class (std::lock_guard) to allow us to return at any point in this - // function and not have to worry about unlocking the mutex. - std::unique_lock<std::mutex> lock(m_mutex); - -#ifdef DB_PTHREAD_LOG_EVENTS - printf("%s (value = 0x%8.8x, timeout = %llu), m_value = 0x%8.8x\n", - __FUNCTION__, value, timeout.count(), m_value); -#endif - if (timed_out) - *timed_out = false; - - while (m_value != value) { - if (timeout == std::chrono::microseconds(0)) { - m_condition.wait(lock); - } else { - std::cv_status result = m_condition.wait_for(lock, timeout); - if (result == std::cv_status::timeout) { - if (timed_out) - *timed_out = true; - break; - } - } - } - - return m_value == value; - } - - //------------------------------------------------------------------ - /// Wait for \a m_value to be equal to \a value and then set it to - /// a new value. - /// - /// Waits in a thread safe way for \a m_value to be equal to \a - /// value and then sets \a m_value to \a new_value. If \a m_value - /// is already equal to \a value, this function will immediately - /// set \a m_value to \a new_value and return without waiting. - /// - /// It is possible for the value to be changed between the time - /// the value is set and the time the waiting thread wakes up. - /// If the value no longer matches the requested value when the - /// waiting thread wakes up, it will go back into a wait state. It - /// may be necessary for the calling code to use additional thread - /// synchronization methods to detect transitory states. - /// - /// @param[in] value - /// The value we want \a m_value to be equal to. - /// - /// @param[in] new_value - /// The value to which \a m_value will be set if \b true is - /// returned. - /// - /// @param[in] abstime - /// If non-nullptr, the absolute time at which we should stop - /// waiting, else wait an infinite amount of time. - /// - /// @param[out] timed_out - /// If not null, set to true if we return because of a time out, - /// and false if the value was set. - /// - /// @return - /// @li \b true if the \a m_value became equal to \a value - /// @li \b false otherwise - //------------------------------------------------------------------ - bool WaitForValueEqualToAndSetValueTo( - T wait_value, T new_value, - const std::chrono::microseconds &timeout = std::chrono::microseconds(0), - bool *timed_out = nullptr) { - // pthread_cond_timedwait() or pthread_cond_wait() will atomically - // unlock the mutex and wait for the condition to be set. When either - // function returns, they will re-lock the mutex. We use an auto lock/unlock - // class (std::lock_guard) to allow us to return at any point in this - // function and not have to worry about unlocking the mutex. - std::unique_lock<std::mutex> lock(m_mutex); - -#ifdef DB_PTHREAD_LOG_EVENTS - printf("%s (wait_value = 0x%8.8x, new_value = 0x%8.8x, timeout = %llu), " - "m_value = 0x%8.8x\n", - __FUNCTION__, wait_value, new_value, timeout.count(), m_value); -#endif - if (timed_out) - *timed_out = false; - - while (m_value != wait_value) { - if (timeout == std::chrono::microseconds(0)) { - m_condition.wait(lock); - } else { - std::cv_status result = m_condition.wait_for(lock, timeout); - if (result == std::cv_status::timeout) { - if (timed_out) - *timed_out = true; - break; - } - } - } - - if (m_value == wait_value) { - m_value = new_value; - return true; - } - - return false; + bool WaitForValueEqualTo(T value, + const Timeout<std::micro> &timeout = llvm::None) { + return WaitFor([&value](T current) { return value == current; }, timeout) != + llvm::None; } //------------------------------------------------------------------ @@ -435,51 +199,23 @@ public: /// @param[in] value /// The value we want \a m_value to not be equal to. /// - /// @param[out] new_value - /// The new value if \b true is returned. - /// - /// @param[in] abstime - /// If non-nullptr, the absolute time at which we should stop - /// waiting, else wait an infinite amount of time. + /// @param[in] timeout + /// How long to wait for the condition to hold. /// /// @return - /// @li \b true if the \a m_value is equal to \a value - /// @li \b false otherwise + /// @li m_value if m_value != value + /// @li None otherwise (timeout occurred). //------------------------------------------------------------------ - bool WaitForValueNotEqualTo( - T value, T &new_value, - const std::chrono::microseconds &timeout = std::chrono::microseconds(0)) { - // pthread_cond_timedwait() or pthread_cond_wait() will atomically - // unlock the mutex and wait for the condition to be set. When either - // function returns, they will re-lock the mutex. We use an auto lock/unlock - // class (std::lock_guard) to allow us to return at any point in this - // function and not have to worry about unlocking the mutex. - std::unique_lock<std::mutex> lock(m_mutex); -#ifdef DB_PTHREAD_LOG_EVENTS - printf("%s (value = 0x%8.8x, timeout = %llu), m_value = 0x%8.8x\n", - __FUNCTION__, value, timeout.count(), m_value); -#endif - while (m_value == value) { - if (timeout == std::chrono::microseconds(0)) { - m_condition.wait(lock); - } else { - std::cv_status result = m_condition.wait_for(lock, timeout); - if (result == std::cv_status::timeout) - break; - } - } - - if (m_value != value) { - new_value = m_value; - return true; - } - return false; + llvm::Optional<T> + WaitForValueNotEqualTo(T value, + const Timeout<std::micro> &timeout = llvm::None) { + return WaitFor([&value](T current) { return value != current; }, timeout); } protected: //---------------------------------------------------------------------- - // pthread condition and mutex variable to control access and allow - // blocking between the main thread and the spotlight index thread. + // pthread condition and mutex variable to control access and allow blocking + // between the main thread and the spotlight index thread. //---------------------------------------------------------------------- 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 diff --git a/include/lldb/Host/ProcessRunLock.h b/include/lldb/Host/ProcessRunLock.h index 7044fdbd9ef92..6f39eea716e88 100644 --- a/include/lldb/Host/ProcessRunLock.h +++ b/include/lldb/Host/ProcessRunLock.h @@ -26,9 +26,9 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class ProcessRunLock ProcessRunLock.h "lldb/Host/ProcessRunLock.h" -/// @brief A class used to prevent the process from starting while other -/// threads are accessing its data, and prevent access to its data while -/// it is running. +/// A class used to prevent the process from starting while other +/// threads are accessing its data, and prevent access to its data while it is +/// running. //---------------------------------------------------------------------- class ProcessRunLock { diff --git a/include/lldb/Host/PseudoTerminal.h b/include/lldb/Host/PseudoTerminal.h index 00c0da6f33154..858bd35f73a6a 100644 --- a/include/lldb/Host/PseudoTerminal.h +++ b/include/lldb/Host/PseudoTerminal.h @@ -19,10 +19,10 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class PseudoTerminal PseudoTerminal.h "lldb/Host/PseudoTerminal.h" -/// @brief A pseudo terminal helper class. +/// A pseudo terminal helper class. /// -/// The pseudo terminal class abstracts the use of pseudo terminals on -/// the host system. +/// The pseudo terminal class abstracts the use of pseudo terminals on the +/// host system. //---------------------------------------------------------------------- class PseudoTerminal { public: @@ -33,19 +33,17 @@ public: //------------------------------------------------------------------ /// Default constructor /// - /// Constructs this object with invalid master and slave file - /// descriptors. + /// Constructs this object with invalid master and slave file descriptors. //------------------------------------------------------------------ PseudoTerminal(); //------------------------------------------------------------------ /// Destructor /// - /// The destructor will close the master and slave file descriptors - /// if they are valid and ownership has not been released using - /// one of: - /// @li PseudoTerminal::ReleaseMasterFileDescriptor() - /// @li PseudoTerminal::ReleaseSaveFileDescriptor() + /// The destructor will close the master and slave file descriptors if they + /// are valid and ownership has not been released using one of: @li + /// PseudoTerminal::ReleaseMasterFileDescriptor() @li + /// PseudoTerminal::ReleaseSaveFileDescriptor() //------------------------------------------------------------------ ~PseudoTerminal(); @@ -62,20 +60,18 @@ public: //------------------------------------------------------------------ /// Fork a child process that uses pseudo terminals for its stdio. /// - /// In the parent process, a call to this function results in a pid - /// being returned. If the pid is valid, the master file descriptor - /// can be used for read/write access to stdio of the child process. + /// In the parent process, a call to this function results in a pid being + /// returned. If the pid is valid, the master file descriptor can be used + /// for read/write access to stdio of the child process. /// - /// In the child process the stdin/stdout/stderr will already be - /// routed to the slave pseudo terminal and the master file - /// descriptor will be closed as it is no longer needed by the child - /// process. + /// In the child process the stdin/stdout/stderr will already be routed to + /// the slave pseudo terminal and the master file descriptor will be closed + /// as it is no longer needed by the child process. /// - /// This class will close the file descriptors for the master/slave - /// when the destructor is called. The file handles can be released - /// using either: - /// @li PseudoTerminal::ReleaseMasterFileDescriptor() - /// @li PseudoTerminal::ReleaseSaveFileDescriptor() + /// This class will close the file descriptors for the master/slave when the + /// destructor is called. The file handles can be released using either: @li + /// PseudoTerminal::ReleaseMasterFileDescriptor() @li + /// PseudoTerminal::ReleaseSaveFileDescriptor() /// /// @param[out] error /// An pointer to an error that can describe any errors that @@ -91,10 +87,10 @@ public: //------------------------------------------------------------------ /// The master file descriptor accessor. /// - /// This object retains ownership of the master file descriptor when - /// this accessor is used. Users can call the member function - /// PseudoTerminal::ReleaseMasterFileDescriptor() if this - /// object should release ownership of the slave file descriptor. + /// This object retains ownership of the master file descriptor when this + /// accessor is used. Users can call the member function + /// PseudoTerminal::ReleaseMasterFileDescriptor() if this object should + /// release ownership of the slave file descriptor. /// /// @return /// The master file descriptor, or PseudoTerminal::invalid_fd @@ -107,10 +103,10 @@ public: //------------------------------------------------------------------ /// The slave file descriptor accessor. /// - /// This object retains ownership of the slave file descriptor when - /// this accessor is used. Users can call the member function - /// PseudoTerminal::ReleaseSlaveFileDescriptor() if this - /// object should release ownership of the slave file descriptor. + /// This object retains ownership of the slave file descriptor when this + /// accessor is used. Users can call the member function + /// PseudoTerminal::ReleaseSlaveFileDescriptor() if this object should + /// release ownership of the slave file descriptor. /// /// @return /// The slave file descriptor, or PseudoTerminal::invalid_fd @@ -146,12 +142,12 @@ public: /// Open the first available pseudo terminal. /// /// Opens the first available pseudo terminal with \a oflag as the - /// permissions. The opened master file descriptor is stored in this - /// object and can be accessed by calling the - /// PseudoTerminal::GetMasterFileDescriptor() accessor. Clients - /// can call the PseudoTerminal::ReleaseMasterFileDescriptor() - /// accessor function if they wish to use the master file descriptor - /// beyond the lifespan of this object. + /// permissions. The opened master file descriptor is stored in this object + /// and can be accessed by calling the + /// PseudoTerminal::GetMasterFileDescriptor() accessor. Clients can call the + /// PseudoTerminal::ReleaseMasterFileDescriptor() accessor function if they + /// wish to use the master file descriptor beyond the lifespan of this + /// object. /// /// If this object still has a valid master file descriptor when its /// destructor is called, it will close it. @@ -169,8 +165,8 @@ public: /// successfully opened. /// @li \b false if anything goes wrong. /// - /// @see PseudoTerminal::GetMasterFileDescriptor() - /// @see PseudoTerminal::ReleaseMasterFileDescriptor() + /// @see PseudoTerminal::GetMasterFileDescriptor() @see + /// PseudoTerminal::ReleaseMasterFileDescriptor() //------------------------------------------------------------------ bool OpenFirstAvailableMaster(int oflag, char *error_str, size_t error_len); @@ -178,12 +174,12 @@ public: /// Open the slave for the current master pseudo terminal. /// /// A master pseudo terminal should already be valid prior to - /// calling this function. The opened slave file descriptor is - /// stored in this object and can be accessed by calling the - /// PseudoTerminal::GetSlaveFileDescriptor() accessor. Clients - /// can call the PseudoTerminal::ReleaseSlaveFileDescriptor() - /// accessor function if they wish to use the slave file descriptor - /// beyond the lifespan of this object. + /// calling this function. The opened slave file descriptor is stored in + /// this object and can be accessed by calling the + /// PseudoTerminal::GetSlaveFileDescriptor() accessor. Clients can call the + /// PseudoTerminal::ReleaseSlaveFileDescriptor() accessor function if they + /// wish to use the slave file descriptor beyond the lifespan of this + /// object. /// /// If this object still has a valid slave file descriptor when its /// destructor is called, it will close it. @@ -200,19 +196,19 @@ public: /// successfully opened. /// @li \b false if anything goes wrong. /// - /// @see PseudoTerminal::OpenFirstAvailableMaster() - /// @see PseudoTerminal::GetSlaveFileDescriptor() - /// @see PseudoTerminal::ReleaseSlaveFileDescriptor() + /// @see PseudoTerminal::OpenFirstAvailableMaster() @see + /// PseudoTerminal::GetSlaveFileDescriptor() @see + /// PseudoTerminal::ReleaseSlaveFileDescriptor() //------------------------------------------------------------------ bool OpenSlave(int oflag, char *error_str, size_t error_len); //------------------------------------------------------------------ /// Release the master file descriptor. /// - /// Releases ownership of the master pseudo terminal file descriptor - /// without closing it. The destructor for this class will close the - /// master file descriptor if the ownership isn't released using this - /// call and the master file descriptor has been opened. + /// Releases ownership of the master pseudo terminal file descriptor without + /// closing it. The destructor for this class will close the master file + /// descriptor if the ownership isn't released using this call and the + /// master file descriptor has been opened. /// /// @return /// The master file descriptor, or PseudoTerminal::invalid_fd @@ -223,10 +219,10 @@ public: //------------------------------------------------------------------ /// Release the slave file descriptor. /// - /// Release ownership of the slave pseudo terminal file descriptor - /// without closing it. The destructor for this class will close the - /// slave file descriptor if the ownership isn't released using this - /// call and the slave file descriptor has been opened. + /// Release ownership of the slave pseudo terminal file descriptor without + /// closing it. The destructor for this class will close the slave file + /// descriptor if the ownership isn't released using this call and the slave + /// file descriptor has been opened. /// /// @return /// The slave file descriptor, or PseudoTerminal::invalid_fd diff --git a/include/lldb/Host/Socket.h b/include/lldb/Host/Socket.h index 37f468f23ce0b..f6e51fd456797 100644 --- a/include/lldb/Host/Socket.h +++ b/include/lldb/Host/Socket.h @@ -60,10 +60,8 @@ public: virtual Status Accept(Socket *&socket) = 0; // Initialize a Tcp Socket object in listening mode. listen and accept are - // implemented - // separately because the caller may wish to manipulate or query the socket - // after it is - // initialized, but before entering a blocking accept. + // implemented separately because the caller may wish to manipulate or query + // the socket after it is initialized, but before entering a blocking accept. static Status TcpListen(llvm::StringRef host_and_port, bool child_processes_inherit, Socket *&socket, Predicate<uint16_t> *predicate, int backlog = 5); diff --git a/include/lldb/Host/SocketAddress.h b/include/lldb/Host/SocketAddress.h index ebc6f4e57ee8a..749a9c664c81b 100644 --- a/include/lldb/Host/SocketAddress.h +++ b/include/lldb/Host/SocketAddress.h @@ -111,17 +111,16 @@ public: uint16_t GetPort() const; //------------------------------------------------------------------ - // Set the port if the socket address for the family has a port. - // The family must be set correctly prior to calling this function. + // Set the port if the socket address for the family has a port. The family + // must be set correctly prior to calling this function. //------------------------------------------------------------------ bool SetPort(uint16_t port); //------------------------------------------------------------------ - // Set the socket address according to the first match from a call - // to getaddrinfo() (or equivalent functions for systems that don't - // have getaddrinfo(). If "addr_info_ptr" is not NULL, it will get - // filled in with the match that was used to populate this socket - // address. + // Set the socket address according to the first match from a call to + // getaddrinfo() (or equivalent functions for systems that don't have + // getaddrinfo(). If "addr_info_ptr" is not NULL, it will get filled in with + // the match that was used to populate this socket address. //------------------------------------------------------------------ bool getaddrinfo(const char *host, // Hostname ("foo.bar.com" or "foo" or IP @@ -133,9 +132,9 @@ public: int ai_protocol = 0, int ai_flags = 0); //------------------------------------------------------------------ - // Quick way to set the SocketAddress to localhost given the family. - // Returns true if successful, false if "family" doesn't support - // localhost or if "family" is not supported by this class. + // Quick way to set the SocketAddress to localhost given the family. Returns + // true if successful, false if "family" doesn't support localhost or if + // "family" is not supported by this class. //------------------------------------------------------------------ bool SetToLocalhost(sa_family_t family, uint16_t port); @@ -190,11 +189,10 @@ public: } //------------------------------------------------------------------ - // Conversion operators to allow getting the contents of this class - // as a pointer to the appropriate structure. This allows an instance - // of this class to be used in calls that take one of the sockaddr - // structure variants without having to manually use the correct - // accessor function. + // Conversion operators to allow getting the contents of this class as a + // pointer to the appropriate structure. This allows an instance of this + // class to be used in calls that take one of the sockaddr structure variants + // without having to manually use the correct accessor function. //------------------------------------------------------------------ operator struct sockaddr *() { return &m_socket_addr.sa; } diff --git a/include/lldb/Host/StringConvert.h b/include/lldb/Host/StringConvert.h index 05bd7808ecd49..d197df10d79eb 100644 --- a/include/lldb/Host/StringConvert.h +++ b/include/lldb/Host/StringConvert.h @@ -24,7 +24,7 @@ namespace StringConvert { //---------------------------------------------------------------------- /// @namespace StringConvert StringConvert.h "lldb/Host/StringConvert.h" -/// @brief Utility classes for converting strings into Integers +/// Utility classes for converting strings into Integers //---------------------------------------------------------------------- int32_t ToSInt32(const char *s, int32_t fail_value = 0, int base = 0, diff --git a/include/lldb/Host/Symbols.h b/include/lldb/Host/Symbols.h index 5f8632d221f7b..ce95d91497f80 100644 --- a/include/lldb/Host/Symbols.h +++ b/include/lldb/Host/Symbols.h @@ -29,16 +29,16 @@ public: //---------------------------------------------------------------------- // Locate the executable file given a module specification. // - // Locating the file should happen only on the local computer or using - // the current computers global settings. + // Locating the file should happen only on the local computer or using the + // current computers global settings. //---------------------------------------------------------------------- static ModuleSpec LocateExecutableObjectFile(const ModuleSpec &module_spec); //---------------------------------------------------------------------- // Locate the symbol file given a module specification. // - // Locating the file should happen only on the local computer or using - // the current computers global settings. + // Locating the file should happen only on the local computer or using the + // current computers global settings. //---------------------------------------------------------------------- static FileSpec LocateExecutableSymbolFile(const ModuleSpec &module_spec); @@ -51,10 +51,10 @@ public: // // Locating the file can try to download the file from a corporate build // repository, or using any other means necessary to locate both the - // unstripped object file and the debug symbols. - // The force_lookup argument controls whether the external program is called - // unconditionally to find the symbol file, or if the user's settings are - // checked to see if they've enabled the external program before calling. + // unstripped object file and the debug symbols. The force_lookup argument + // controls whether the external program is called unconditionally to find + // the symbol file, or if the user's settings are checked to see if they've + // enabled the external program before calling. // //---------------------------------------------------------------------- static bool DownloadObjectAndSymbolFile(ModuleSpec &module_spec, diff --git a/include/lldb/Host/TaskPool.h b/include/lldb/Host/TaskPool.h index 13076e7eb70bd..fe17141510761 100644 --- a/include/lldb/Host/TaskPool.h +++ b/include/lldb/Host/TaskPool.h @@ -20,32 +20,27 @@ namespace lldb_private { -// Global TaskPool class for running tasks in parallel on a set of worker thread -// created the first -// time the task pool is used. The TaskPool provide no guarantee about the order -// the task will be run -// and about what tasks will run in parallel. None of the task added to the task -// pool should block -// on something (mutex, future, condition variable) what will be set only by the -// completion of an -// other task on the task pool as they may run on the same thread sequentally. +// Global TaskPool class for running tasks in parallel on a set of worker +// thread created the first time the task pool is used. The TaskPool provide no +// guarantee about the order the task will be run and about what tasks will run +// in parallel. None of the task added to the task pool should block on +// something (mutex, future, condition variable) what will be set only by the +// completion of an other task on the task pool as they may run on the same +// thread sequentally. class TaskPool { public: // Add a new task to the task pool and return a std::future belonging to the - // newly created task. - // The caller of this function has to wait on the future for this task to - // complete. + // newly created task. The caller of this function has to wait on the future + // for this task to complete. template <typename F, typename... Args> static std::future<typename std::result_of<F(Args...)>::type> AddTask(F &&f, Args &&... args); // Run all of the specified tasks on the task pool and wait until all of them - // are finished - // before returning. This method is intended to be used for small number tasks - // where listing - // them as function arguments is acceptable. For running large number of tasks - // you should use - // AddTask for each task and then call wait() on each returned future. + // are finished before returning. This method is intended to be used for + // small number tasks where listing them as function arguments is acceptable. + // For running large number of tasks you should use AddTask for each task and + // then call wait() on each returned future. template <typename... T> static void RunTasks(T &&... tasks); private: diff --git a/include/lldb/Host/Terminal.h b/include/lldb/Host/Terminal.h index f0d93ad24ed63..193b6d21d51e5 100644 --- a/include/lldb/Host/Terminal.h +++ b/include/lldb/Host/Terminal.h @@ -44,7 +44,7 @@ protected: //---------------------------------------------------------------------- /// @class State Terminal.h "lldb/Host/Terminal.h" -/// @brief A terminal state saving/restoring class. +/// A terminal state saving/restoring class. /// /// This class can be used to remember the terminal state for a file /// descriptor and later restore that state as it originally was. @@ -64,9 +64,9 @@ public: //------------------------------------------------------------------ /// Save the TTY state for \a fd. /// - /// Save the current state of the TTY for the file descriptor "fd" - /// and if "save_process_group" is true, attempt to save the process - /// group info for the TTY. + /// Save the current state of the TTY for the file descriptor "fd" and if + /// "save_process_group" is true, attempt to save the process group info for + /// the TTY. /// /// @param[in] fd /// The file descriptor to save the state of. @@ -84,8 +84,8 @@ public: //------------------------------------------------------------------ /// Restore the TTY state to the cached state. /// - /// Restore the state of the TTY using the cached values from a - /// previous call to TerminalState::Save(int,bool). + /// Restore the state of the TTY using the cached values from a previous + /// call to TerminalState::Save(int,bool). /// /// @return /// Returns \b true if the TTY state was successfully restored, @@ -147,7 +147,7 @@ protected: //---------------------------------------------------------------------- /// @class TerminalStateSwitcher Terminal.h "lldb/Host/Terminal.h" -/// @brief A TTY state switching class. +/// A TTY state switching class. /// /// This class can be used to remember 2 TTY states for a given file /// descriptor and switch between the two states. @@ -182,10 +182,9 @@ public: bool Restore(uint32_t idx) const; //------------------------------------------------------------------ - /// Save the TTY state information for the state at index \a idx. - /// The TTY state is saved for the file descriptor \a fd and - /// the process group information will also be saved if requested - /// by \a save_process_group. + /// Save the TTY state information for the state at index \a idx. The TTY + /// state is saved for the file descriptor \a fd and the process group + /// information will also be saved if requested by \a save_process_group. /// /// @param[in] idx /// The index into the state array where the state should be diff --git a/include/lldb/Host/XML.h b/include/lldb/Host/XML.h index 96b5227305e1b..5088f1f25b0df 100644 --- a/include/lldb/Host/XML.h +++ b/include/lldb/Host/XML.h @@ -82,6 +82,9 @@ public: llvm::StringRef GetAttributeValue(const char *name, const char *fail_value = nullptr) const; + bool GetAttributeValueAsUnsigned(const char *name, uint64_t &value, + uint64_t fail_value = 0, int base = 0) const; + XMLNode FindFirstChildElementWithName(const char *name) const; XMLNode GetElementForPath(const NamePath &path); @@ -97,8 +100,8 @@ public: void ForEachSiblingElement(NodeCallback const &callback) const; //---------------------------------------------------------------------- - // Iterate through only the sibling nodes that are elements and whose - // name matches \a name. + // Iterate through only the sibling nodes that are elements and whose name + // matches \a name. //---------------------------------------------------------------------- void ForEachSiblingElementWithName(const char *name, NodeCallback const &callback) const; @@ -134,8 +137,8 @@ public: const char *url = "untitled.xml"); //---------------------------------------------------------------------- - // If \a name is nullptr, just get the root element node, else only return - // a value XMLNode if the name of the root element matches \a name. + // If \a name is nullptr, just get the root element node, else only return a + // value XMLNode if the name of the root element matches \a name. //---------------------------------------------------------------------- XMLNode GetRootElement(const char *required_name = nullptr); @@ -173,12 +176,11 @@ public: StructuredData::ObjectSP GetStructuredData(); protected: - // Using a node returned from GetValueNode() extract its value as a - // string (if possible). Array and dictionary nodes will return false - // as they have no string value. Boolean nodes will return true and - // \a value will be "true" or "false" as the string value comes from - // the element name itself. All other nodes will return the text - // content of the XMLNode. + // Using a node returned from GetValueNode() extract its value as a string + // (if possible). Array and dictionary nodes will return false as they have + // no string value. Boolean nodes will return true and \a value will be + // "true" or "false" as the string value comes from the element name itself. + // All other nodes will return the text content of the XMLNode. static bool ExtractStringFromValueNode(const XMLNode &node, std::string &value); diff --git a/include/lldb/Host/common/GetOptInc.h b/include/lldb/Host/common/GetOptInc.h index 4d5cab5cbec23..c69f7227a5cf8 100644 --- a/include/lldb/Host/common/GetOptInc.h +++ b/include/lldb/Host/common/GetOptInc.h @@ -19,8 +19,8 @@ // option structure struct option { const char *name; - // has_arg can't be an enum because some compilers complain about - // type mismatches in all the code that assumes it is an int. + // has_arg can't be an enum because some compilers complain about type + // mismatches in all the code that assumes it is an int. int has_arg; int *flag; int val; diff --git a/include/lldb/Host/common/NativeBreakpoint.h b/include/lldb/Host/common/NativeBreakpoint.h index 73639d64c9e8a..681570aadef0c 100644 --- a/include/lldb/Host/common/NativeBreakpoint.h +++ b/include/lldb/Host/common/NativeBreakpoint.h @@ -45,8 +45,8 @@ protected: private: bool m_enabled; - // ----------------------------------------------------------- - // interface for NativeBreakpointList + // ----------------------------------------------------------- interface for + // NativeBreakpointList // ----------------------------------------------------------- void AddRef(); int32_t DecRef(); diff --git a/include/lldb/Host/common/NativeProcessProtocol.h b/include/lldb/Host/common/NativeProcessProtocol.h index bd8b8744b115d..d96835d75839a 100644 --- a/include/lldb/Host/common/NativeProcessProtocol.h +++ b/include/lldb/Host/common/NativeProcessProtocol.h @@ -69,8 +69,8 @@ public: virtual Status Kill() = 0; //------------------------------------------------------------------ - // Tells a process not to stop the inferior on given signals - // and just reinject them back. + // Tells a process not to stop the inferior on given signals and just + // reinject them back. //------------------------------------------------------------------ virtual Status IgnoreSignals(llvm::ArrayRef<int> signals); @@ -421,33 +421,30 @@ protected: int m_terminal_fd; uint32_t m_stop_id = 0; - // Set of signal numbers that LLDB directly injects back to inferior - // without stopping it. + // Set of signal numbers that LLDB directly injects back to inferior without + // stopping it. llvm::DenseSet<int> m_signals_to_ignore; // lldb_private::Host calls should be used to launch a process for debugging, - // and - // then the process should be attached to. When attaching to a process - // lldb_private::Host calls should be used to locate the process to attach to, - // and then this function should be called. + // and then the process should be attached to. When attaching to a process + // lldb_private::Host calls should be used to locate the process to attach + // to, and then this function should be called. NativeProcessProtocol(lldb::pid_t pid, int terminal_fd, NativeDelegate &delegate); - // ----------------------------------------------------------- - // Internal interface for state handling + // ----------------------------------------------------------- Internal + // interface for state handling // ----------------------------------------------------------- void SetState(lldb::StateType state, bool notify_delegates = true); - // Derived classes need not implement this. It can be used as a - // hook to clear internal caches that should be invalidated when - // stop ids change. + // Derived classes need not implement this. It can be used as a hook to + // clear internal caches that should be invalidated when stop ids change. // - // Note this function is called with the state mutex obtained - // by the caller. + // Note this function is called with the state mutex obtained by the caller. virtual void DoStopIDBumped(uint32_t newBumpId); - // ----------------------------------------------------------- - // Internal interface for software breakpoints + // ----------------------------------------------------------- Internal + // interface for software breakpoints // ----------------------------------------------------------- Status SetSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint); @@ -466,11 +463,6 @@ protected: NativeThreadProtocol *GetThreadByIDUnlocked(lldb::tid_t tid); - // ----------------------------------------------------------- - // Static helper methods for derived classes. - // ----------------------------------------------------------- - static Status ResolveProcessArchitecture(lldb::pid_t pid, ArchSpec &arch); - private: void SynchronouslyNotifyProcessStateChanged(lldb::StateType state); }; diff --git a/include/lldb/Host/common/NativeRegisterContext.h b/include/lldb/Host/common/NativeRegisterContext.h index a8c5fa17e2643..26458db153c18 100644 --- a/include/lldb/Host/common/NativeRegisterContext.h +++ b/include/lldb/Host/common/NativeRegisterContext.h @@ -98,17 +98,14 @@ public: virtual lldb::addr_t GetWatchpointAddress(uint32_t wp_index); // MIPS Linux kernel returns a masked address (last 3bits are masked) - // when a HW watchpoint is hit. However user may not have set a watchpoint - // on this address. This function emulates the instruction at PC and - // finds the base address used in the load/store instruction. This gives the - // exact address used to read/write the variable being watched. - // For example: - // 'n' is at 0x120010d00 and 'm' is 0x120010d04. When a watchpoint is set at - // 'm', + // when a HW watchpoint is hit. However user may not have set a watchpoint on + // this address. This function emulates the instruction at PC and finds the + // base address used in the load/store instruction. This gives the exact + // address used to read/write the variable being watched. For example: 'n' is + // at 0x120010d00 and 'm' is 0x120010d04. When a watchpoint is set at 'm', // then watch exception is generated even when 'n' is read/written. This - // function - // returns address of 'n' so that client can check whether a watchpoint is set - // on this address or not. + // function returns address of 'n' so that client can check whether a + // watchpoint is set on this address or not. virtual lldb::addr_t GetWatchpointHitAddress(uint32_t wp_index); virtual bool HardwareSingleStep(bool enable); diff --git a/include/lldb/Host/common/NativeThreadProtocol.h b/include/lldb/Host/common/NativeThreadProtocol.h index 5609cdda4eeab..6f4452c688e71 100644 --- a/include/lldb/Host/common/NativeThreadProtocol.h +++ b/include/lldb/Host/common/NativeThreadProtocol.h @@ -32,14 +32,6 @@ public: virtual NativeRegisterContext &GetRegisterContext() = 0; - virtual Status ReadRegister(uint32_t reg, RegisterValue ®_value); - - virtual Status WriteRegister(uint32_t reg, const RegisterValue ®_value); - - virtual Status SaveAllRegisters(lldb::DataBufferSP &data_sp); - - virtual Status RestoreAllRegisters(lldb::DataBufferSP &data_sp); - virtual bool GetStopReason(ThreadStopInfo &stop_info, std::string &description) = 0; diff --git a/include/lldb/Host/freebsd/HostInfoFreeBSD.h b/include/lldb/Host/freebsd/HostInfoFreeBSD.h index 945ec835f7783..5b3a18d21079a 100644 --- a/include/lldb/Host/freebsd/HostInfoFreeBSD.h +++ b/include/lldb/Host/freebsd/HostInfoFreeBSD.h @@ -12,12 +12,13 @@ #include "lldb/Host/posix/HostInfoPosix.h" #include "lldb/Utility/FileSpec.h" +#include "llvm/Support/VersionTuple.h" namespace lldb_private { class HostInfoFreeBSD : public HostInfoPosix { public: - static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update); + static llvm::VersionTuple GetOSVersion(); static bool GetOSBuildString(std::string &s); static bool GetOSKernelDescription(std::string &s); static FileSpec GetProgramFileSpec(); diff --git a/include/lldb/Host/linux/HostInfoLinux.h b/include/lldb/Host/linux/HostInfoLinux.h index d1f2e747b1172..820d3bd17a2e6 100644 --- a/include/lldb/Host/linux/HostInfoLinux.h +++ b/include/lldb/Host/linux/HostInfoLinux.h @@ -12,8 +12,8 @@ #include "lldb/Host/posix/HostInfoPosix.h" #include "lldb/Utility/FileSpec.h" - #include "llvm/ADT/StringRef.h" +#include "llvm/Support/VersionTuple.h" #include <string> @@ -30,7 +30,7 @@ private: public: static void Initialize(); - static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update); + static llvm::VersionTuple GetOSVersion(); static bool GetOSBuildString(std::string &s); static bool GetOSKernelDescription(std::string &s); static llvm::StringRef GetDistributionId(); diff --git a/include/lldb/Host/macosx/HostInfoMacOSX.h b/include/lldb/Host/macosx/HostInfoMacOSX.h index eee842beec87b..d5b0bfd861c0f 100644 --- a/include/lldb/Host/macosx/HostInfoMacOSX.h +++ b/include/lldb/Host/macosx/HostInfoMacOSX.h @@ -12,6 +12,7 @@ #include "lldb/Host/posix/HostInfoPosix.h" #include "lldb/Utility/FileSpec.h" +#include "llvm/Support/VersionTuple.h" namespace lldb_private { @@ -26,7 +27,7 @@ private: ~HostInfoMacOSX(); public: - static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update); + static llvm::VersionTuple GetOSVersion(); static bool GetOSBuildString(std::string &s); static bool GetOSKernelDescription(std::string &s); static FileSpec GetProgramFileSpec(); @@ -36,8 +37,6 @@ protected: static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64); static bool ComputeHeaderDirectory(FileSpec &file_spec); - static bool ComputePythonDirectory(FileSpec &file_spec); - static bool ComputeClangDirectory(FileSpec &file_spec); static bool ComputeSystemPluginsDirectory(FileSpec &file_spec); static bool ComputeUserPluginsDirectory(FileSpec &file_spec); }; diff --git a/include/lldb/Host/netbsd/HostInfoNetBSD.h b/include/lldb/Host/netbsd/HostInfoNetBSD.h index 9ebff6ba6b0e7..0d4de79d03b1f 100644 --- a/include/lldb/Host/netbsd/HostInfoNetBSD.h +++ b/include/lldb/Host/netbsd/HostInfoNetBSD.h @@ -12,12 +12,13 @@ #include "lldb/Host/posix/HostInfoPosix.h" #include "lldb/Utility/FileSpec.h" +#include "llvm/Support/VersionTuple.h" namespace lldb_private { class HostInfoNetBSD : public HostInfoPosix { public: - static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update); + static llvm::VersionTuple GetOSVersion(); static bool GetOSBuildString(std::string &s); static bool GetOSKernelDescription(std::string &s); static FileSpec GetProgramFileSpec(); diff --git a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h index b7e08eb33af7b..0d125ca2c8133 100644 --- a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h +++ b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h @@ -72,7 +72,7 @@ public: lldb::IOObjectSP GetReadObject() override { return m_read_sp; } - uint16_t GetListeningPort(uint32_t timeout_sec); + uint16_t GetListeningPort(const Timeout<std::micro> &timeout); bool GetChildProcessesInherit() const; void SetChildProcessesInherit(bool child_processes_inherit); @@ -104,8 +104,8 @@ protected: Predicate<uint16_t> m_port_predicate; // Used when binding to port zero to wait for the thread - // that creates the socket, binds and listens to resolve - // the port number. + // that creates the socket, binds and listens to + // resolve the port number. Pipe m_pipe; std::recursive_mutex m_mutex; diff --git a/include/lldb/Host/posix/HostInfoPosix.h b/include/lldb/Host/posix/HostInfoPosix.h index 34994aea44fe2..dda70f9f5a96a 100644 --- a/include/lldb/Host/posix/HostInfoPosix.h +++ b/include/lldb/Host/posix/HostInfoPosix.h @@ -33,13 +33,12 @@ public: static bool GetEnvironmentVar(const std::string &var_name, std::string &var); + static bool ComputePathRelativeToLibrary(FileSpec &file_spec, + llvm::StringRef dir); + protected: static bool ComputeSupportExeDirectory(FileSpec &file_spec); static bool ComputeHeaderDirectory(FileSpec &file_spec); - static bool ComputePythonDirectory(FileSpec &file_spec); - static bool ComputeClangDirectory(FileSpec &file_spec); - static bool ComputePathRelativeToLibrary(FileSpec &file_spec, - llvm::StringRef dir); }; } diff --git a/include/lldb/Host/posix/PipePosix.h b/include/lldb/Host/posix/PipePosix.h index 8208b1b8bd6bf..bb65a56abd007 100644 --- a/include/lldb/Host/posix/PipePosix.h +++ b/include/lldb/Host/posix/PipePosix.h @@ -17,7 +17,7 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class PipePosix PipePosix.h "lldb/Host/posix/PipePosix.h" -/// @brief A posix-based implementation of Pipe, a class that abtracts +/// A posix-based implementation of Pipe, a class that abtracts /// unix style pipes. /// /// A class that abstracts the LLDB core from host pipe functionality. diff --git a/include/lldb/Host/windows/HostInfoWindows.h b/include/lldb/Host/windows/HostInfoWindows.h index 9dfbf93591edc..24949e6001f7f 100644 --- a/include/lldb/Host/windows/HostInfoWindows.h +++ b/include/lldb/Host/windows/HostInfoWindows.h @@ -12,6 +12,7 @@ #include "lldb/Host/HostInfoBase.h" #include "lldb/Utility/FileSpec.h" +#include "llvm/Support/VersionTuple.h" namespace lldb_private { @@ -29,7 +30,7 @@ public: static size_t GetPageSize(); - static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update); + static llvm::VersionTuple GetOSVersion(); static bool GetOSBuildString(std::string &s); static bool GetOSKernelDescription(std::string &s); static bool GetHostname(std::string &s); @@ -38,9 +39,6 @@ public: static bool GetEnvironmentVar(const std::string &var_name, std::string &var); -protected: - static bool ComputePythonDirectory(FileSpec &file_spec); - private: static FileSpec m_program_filespec; }; diff --git a/include/lldb/Host/windows/PipeWindows.h b/include/lldb/Host/windows/PipeWindows.h index 86dec5a79d8e4..e309c421a71c9 100644 --- a/include/lldb/Host/windows/PipeWindows.h +++ b/include/lldb/Host/windows/PipeWindows.h @@ -17,7 +17,7 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class Pipe PipeWindows.h "lldb/Host/windows/PipeWindows.h" -/// @brief A windows-based implementation of Pipe, a class that abtracts +/// A windows-based implementation of Pipe, a class that abtracts /// unix style pipes. /// /// A class that abstracts the LLDB core from host pipe functionality. diff --git a/include/lldb/Host/windows/PosixApi.h b/include/lldb/Host/windows/PosixApi.h index de70266a5efb4..801107dadcebd 100644 --- a/include/lldb/Host/windows/PosixApi.h +++ b/include/lldb/Host/windows/PosixApi.h @@ -11,7 +11,7 @@ #define liblldb_Host_windows_PosixApi_h #include "llvm/Support/Compiler.h" -#if !defined(LLVM_ON_WIN32) +#if !defined(_WIN32) #error "windows/PosixApi.h being #included on non Windows system!" #endif diff --git a/include/lldb/Interpreter/CommandAlias.h b/include/lldb/Interpreter/CommandAlias.h index 4658a1e444f49..01522bd6eceaa 100644 --- a/include/lldb/Interpreter/CommandAlias.h +++ b/include/lldb/Interpreter/CommandAlias.h @@ -16,8 +16,9 @@ // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandObject.h" +#include "lldb/Utility/Args.h" +#include "lldb/Utility/CompletionRequest.h" #include "lldb/lldb-forward.h" namespace lldb_private { @@ -40,17 +41,11 @@ public: bool WantsCompletion() override; - int HandleCompletion(Args &input, int &cursor_index, - int &cursor_char_position, int match_start_point, - int max_return_elements, bool &word_complete, - StringList &matches) override; + int HandleCompletion(CompletionRequest &request) override; - int HandleArgumentCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, int max_return_elements, - bool &word_complete, - StringList &matches) override; + int HandleArgumentCompletion( + CompletionRequest &request, + OptionElementVector &opt_element_vector) override; Options *GetOptions() override; @@ -74,8 +69,8 @@ public: OptionArgVectorSP GetOptionArguments() const { return m_option_args_sp; } const char *GetOptionString() { return m_option_string.c_str(); } - // this takes an alias - potentially nested (i.e. an alias to an alias) - // and expands it all the way to a non-alias command + // this takes an alias - potentially nested (i.e. an alias to an alias) and + // expands it all the way to a non-alias command std::pair<lldb::CommandObjectSP, OptionArgVectorSP> Desugar(); protected: diff --git a/include/lldb/Interpreter/CommandCompletions.h b/include/lldb/Interpreter/CommandCompletions.h index 8bac3e8639d7e..d17864e05f3e2 100644 --- a/include/lldb/Interpreter/CommandCompletions.h +++ b/include/lldb/Interpreter/CommandCompletions.h @@ -18,6 +18,7 @@ // Project includes #include "lldb/Core/FileSpecList.h" #include "lldb/Core/SearchFilter.h" +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/lldb-private.h" @@ -29,20 +30,13 @@ class CommandCompletions { public: //---------------------------------------------------------------------- // This is the command completion callback that is used to complete the - // argument of the option - // it is bound to (in the OptionDefinition table below). Return the total - // number of matches. + // argument of the option it is bound to (in the OptionDefinition table + // below). Return the total number of matches. //---------------------------------------------------------------------- - typedef int (*CompletionCallback)( - CommandInterpreter &interpreter, - llvm::StringRef completion_str, // This is the argument we are completing - int match_start_point, // This is the point in the list of matches that - // you should start returning elements - int max_return_elements, // This is the number of matches requested. - lldb_private::SearchFilter - *searcher, // A search filter to limit the search... - bool &word_complete, - lldb_private::StringList &matches); // The array of matches we return. + typedef int (*CompletionCallback)(CommandInterpreter &interpreter, + CompletionRequest &request, + // A search filter to limit the search... + lldb_private::SearchFilter *searcher); typedef enum { eNoCompletion = 0u, eSourceFileCompletion = (1u << 0), @@ -54,9 +48,9 @@ public: ePlatformPluginCompletion = (1u << 6), eArchitectureCompletion = (1u << 7), eVariablePathCompletion = (1u << 8), - // This item serves two purposes. It is the last element in the enum, - // so you can add custom enums starting from here in your Option class. - // Also if you & in this bit the base code will not process the option. + // This item serves two purposes. It is the last element in the enum, so + // you can add custom enums starting from here in your Option class. Also + // if you & in this bit the base code will not process the option. eCustomCompletion = (1u << 9) } CommonCompletionTypes; @@ -67,81 +61,55 @@ public: static bool InvokeCommonCompletionCallbacks( CommandInterpreter &interpreter, uint32_t completion_mask, - llvm::StringRef completion_str, int match_start_point, - int max_return_elements, SearchFilter *searcher, bool &word_complete, - StringList &matches); + lldb_private::CompletionRequest &request, SearchFilter *searcher); //---------------------------------------------------------------------- // These are the generic completer functions: //---------------------------------------------------------------------- static int DiskFiles(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, int match_start_point, - int max_return_elements, SearchFilter *searcher, - bool &word_complete, StringList &matches); + CompletionRequest &request, SearchFilter *searcher); static int DiskFiles(const llvm::Twine &partial_file_name, StringList &matches, TildeExpressionResolver &Resolver); static int DiskDirectories(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, - int match_start_point, int max_return_elements, - SearchFilter *searcher, bool &word_complete, - StringList &matches); + CompletionRequest &request, + SearchFilter *searcher); static int DiskDirectories(const llvm::Twine &partial_file_name, StringList &matches, TildeExpressionResolver &Resolver); static int SourceFiles(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, - int match_start_point, int max_return_elements, - SearchFilter *searcher, bool &word_complete, - StringList &matches); + CompletionRequest &request, SearchFilter *searcher); static int Modules(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, int match_start_point, - int max_return_elements, SearchFilter *searcher, - bool &word_complete, lldb_private::StringList &matches); + CompletionRequest &request, SearchFilter *searcher); static int Symbols(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, int match_start_point, - int max_return_elements, SearchFilter *searcher, - bool &word_complete, lldb_private::StringList &matches); + CompletionRequest &request, SearchFilter *searcher); static int SettingsNames(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, - int match_start_point, int max_return_elements, - SearchFilter *searcher, bool &word_complete, - lldb_private::StringList &matches); + CompletionRequest &request, SearchFilter *searcher); static int PlatformPluginNames(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, - int match_start_point, int max_return_elements, - SearchFilter *searcher, bool &word_complete, - lldb_private::StringList &matches); + CompletionRequest &request, + SearchFilter *searcher); static int ArchitectureNames(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, - int match_start_point, int max_return_elements, - SearchFilter *searcher, bool &word_complete, - lldb_private::StringList &matches); + CompletionRequest &request, + SearchFilter *searcher); static int VariablePath(CommandInterpreter &interpreter, - llvm::StringRef partial_file_name, - int match_start_point, int max_return_elements, - SearchFilter *searcher, bool &word_complete, - lldb_private::StringList &matches); + CompletionRequest &request, SearchFilter *searcher); //---------------------------------------------------------------------- - // The Completer class is a convenient base class for building searchers - // that go along with the SearchFilter passed to the standard Completer - // functions. + // The Completer class is a convenient base class for building searchers that + // go along with the SearchFilter passed to the standard Completer functions. //---------------------------------------------------------------------- class Completer : public Searcher { public: - Completer(CommandInterpreter &interpreter, llvm::StringRef completion_str, - int match_start_point, int max_return_elements, - StringList &matches); + Completer(CommandInterpreter &interpreter, CompletionRequest &request); ~Completer() override; @@ -154,10 +122,7 @@ public: protected: CommandInterpreter &m_interpreter; - std::string m_completion_str; - int m_match_start_point; - int m_max_return_elements; - StringList &m_matches; + CompletionRequest &m_request; private: DISALLOW_COPY_AND_ASSIGN(Completer); @@ -169,9 +134,7 @@ public: class SourceFileCompleter : public Completer { public: SourceFileCompleter(CommandInterpreter &interpreter, - bool include_support_files, - llvm::StringRef completion_str, int match_start_point, - int max_return_elements, StringList &matches); + bool include_support_files, CompletionRequest &request); Searcher::Depth GetDepth() override; @@ -197,8 +160,7 @@ public: class ModuleCompleter : public Completer { public: ModuleCompleter(CommandInterpreter &interpreter, - llvm::StringRef completion_str, int match_start_point, - int max_return_elements, StringList &matches); + CompletionRequest &request); Searcher::Depth GetDepth() override; @@ -222,8 +184,7 @@ public: class SymbolCompleter : public Completer { public: SymbolCompleter(CommandInterpreter &interpreter, - llvm::StringRef completion_str, int match_start_point, - int max_return_elements, StringList &matches); + CompletionRequest &request); Searcher::Depth GetDepth() override; diff --git a/include/lldb/Interpreter/CommandInterpreter.h b/include/lldb/Interpreter/CommandInterpreter.h index 5e561f47946d7..78f505c247545 100644 --- a/include/lldb/Interpreter/CommandInterpreter.h +++ b/include/lldb/Interpreter/CommandInterpreter.h @@ -19,11 +19,12 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Event.h" #include "lldb/Core/IOHandler.h" -#include "lldb/Interpreter/Args.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/CompletionRequest.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StringList.h" #include "lldb/lldb-forward.h" @@ -86,11 +87,10 @@ public: m_add_to_history = value; } // These return the default behaviors if the behavior is not - // eLazyBoolCalculate. - // But I've also left the ivars public since for different ways of running the - // interpreter you might want to force different defaults... In that case, - // just grab - // the LazyBool ivars directly and do what you want with eLazyBoolCalculate. + // eLazyBoolCalculate. But I've also left the ivars public since for + // different ways of running the interpreter you might want to force + // different defaults... In that case, just grab the LazyBool ivars directly + // and do what you want with eLazyBoolCalculate. bool GetStopOnContinue() const { return DefaultToNo(m_stop_on_continue); } void SetStopOnContinue(bool stop_on_continue) { @@ -293,26 +293,19 @@ public: CommandObject *GetCommandObjectForCommand(llvm::StringRef &command_line); // This handles command line completion. You are given a pointer to the - // command string buffer, to the current cursor, - // and to the end of the string (in case it is not NULL terminated). - // You also passed in an StringList object to fill with the returns. - // The first element of the array will be filled with the string that you - // would need to insert at - // the cursor point to complete the cursor point to the longest common - // matching prefix. - // If you want to limit the number of elements returned, set - // max_return_elements to the number of elements - // you want returned. Otherwise set max_return_elements to -1. - // If you want to start some way into the match list, then set - // match_start_point to the desired start - // point. - // Returns: - // -1 if the completion character should be inserted - // -2 if the entire command line should be deleted and replaced with - // matches.GetStringAtIndex(0) + // command string buffer, to the current cursor, and to the end of the string + // (in case it is not NULL terminated). You also passed in an StringList + // object to fill with the returns. The first element of the array will be + // filled with the string that you would need to insert at the cursor point + // to complete the cursor point to the longest common matching prefix. If you + // want to limit the number of elements returned, set max_return_elements to + // the number of elements you want returned. Otherwise set + // max_return_elements to -1. If you want to start some way into the match + // list, then set match_start_point to the desired start point. Returns: -1 + // if the completion character should be inserted -2 if the entire command + // line should be deleted and replaced with matches.GetStringAtIndex(0) // INT_MAX if the number of matches is > max_return_elements, but it is - // expensive to compute. - // Otherwise, returns the number of matches. + // expensive to compute. Otherwise, returns the number of matches. // // FIXME: Only max_return_elements == -1 is supported at present. int HandleCompletion(const char *current_line, const char *cursor, @@ -320,15 +313,9 @@ public: int max_return_elements, StringList &matches); // 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. - // word_complete tells whether the completions are considered a "complete" - // response (so the - // completer should complete the quote & put a space after the word. - int HandleCompletionMatches(Args &input, int &cursor_index, - int &cursor_char_position, int match_start_point, - int max_return_elements, bool &word_complete, - StringList &matches); + // is here so the Help command can call it for the first argument. It uses + // a CompletionRequest for simplicity reasons. + int HandleCompletionMatches(CompletionRequest &request); int GetCommandNamesMatchingPartialString(const char *cmd_cstr, bool include_aliases, @@ -469,6 +456,30 @@ public: void SetPromptOnQuit(bool b); + //------------------------------------------------------------------ + /// Specify if the command interpreter should allow that the user can + /// specify a custom exit code when calling 'quit'. + //------------------------------------------------------------------ + void AllowExitCodeOnQuit(bool allow); + + //------------------------------------------------------------------ + /// Sets the exit code for the quit command. + /// @param[in] exit_code + /// The exit code that the driver should return on exit. + /// @return True if the exit code was successfully set; false if the + /// interpreter doesn't allow custom exit codes. + /// @see AllowExitCodeOnQuit + //------------------------------------------------------------------ + LLVM_NODISCARD bool SetQuitExitCode(int exit_code); + + //------------------------------------------------------------------ + /// Returns the exit code that the user has specified when running the + /// 'quit' command. + /// @param[out] exited + /// Set to true if the user has called quit with a custom exit code. + //------------------------------------------------------------------ + int GetQuitExitCode(bool &exited) const; + void ResolveCommand(const char *command_line, CommandReturnObject &result); bool GetStopCmdSourceOnError() const; @@ -572,6 +583,12 @@ private: uint32_t m_num_errors; bool m_quit_requested; bool m_stopped_for_crash; + + // The exit code the user has requested when calling the 'quit' command. + // No value means the user hasn't set a custom exit code so far. + llvm::Optional<int> m_quit_exit_code; + // If the driver is accepts custom exit codes for the 'quit' command. + bool m_allow_exit_code = false; }; } // namespace lldb_private diff --git a/include/lldb/Interpreter/CommandObject.h b/include/lldb/Interpreter/CommandObject.h index ff4c829e5c706..7afb18b2f598f 100644 --- a/include/lldb/Interpreter/CommandObject.h +++ b/include/lldb/Interpreter/CommandObject.h @@ -20,9 +20,11 @@ // Project includes #include "lldb/Utility/Flags.h" -#include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandCompletions.h" +#include "lldb/Interpreter/Options.h" #include "lldb/Target/ExecutionContext.h" +#include "lldb/Utility/Args.h" +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/StringList.h" #include "lldb/lldb-private.h" @@ -31,9 +33,8 @@ namespace lldb_private { // This function really deals with CommandObjectLists, but we didn't make a // CommandObjectList class, so I'm sticking it here. But we really should have // such a class. Anyway, it looks up the commands in the map that match the -// partial -// string cmd_str, inserts the matches into matches, and returns the number -// added. +// partial string cmd_str, inserts the matches into matches, and returns the +// number added. template <typename ValueType> int AddNamesMatchingPartialString(const std::map<std::string, ValueType> &in_map, @@ -137,8 +138,8 @@ public: void SetSyntax(llvm::StringRef str); - // override this to return true if you want to enable the user to delete - // the Command object from the Command dictionary (aliases have their own + // override this to return true if you want to enable the user to delete the + // Command object from the Command dictionary (aliases have their own // deletion scheme, so they do not need to care about this) virtual bool IsRemovable() const { return false; } @@ -148,9 +149,9 @@ public: virtual bool IsAlias() { return false; } - // override this to return true if your command is somehow a "dash-dash" - // form of some other command (e.g. po is expr -O --); this is a powerful - // hint to the help system that one cannot pass options to this command + // override this to return true if your command is somehow a "dash-dash" form + // of some other command (e.g. po is expr -O --); this is a powerful hint to + // the help system that one cannot pass options to this command virtual bool IsDashDashCommand() { return false; } virtual lldb::CommandObjectSP GetSubcommandSP(llvm::StringRef sub_cmd, @@ -174,10 +175,9 @@ public: virtual void GenerateHelpText(Stream &result); - // this is needed in order to allow the SBCommand class to - // transparently try and load subcommands - it will fail on - // anything but a multiword command, but it avoids us doing - // type checkings and casts + // this is needed in order to allow the SBCommand class to transparently try + // and load subcommands - it will fail on anything but a multiword command, + // but it avoids us doing type checkings and casts virtual bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) { return false; @@ -185,9 +185,9 @@ public: virtual bool WantsRawCommandString() = 0; - // By default, WantsCompletion = !WantsRawCommandString. - // Subclasses who want raw command string but desire, for example, - // argument completion should override this method to return true. + // By default, WantsCompletion = !WantsRawCommandString. Subclasses who want + // raw command string but desire, for example, argument completion should + // override this method to return true. virtual bool WantsCompletion() { return !WantsRawCommandString(); } virtual Options *GetOptions(); @@ -209,10 +209,10 @@ public: static const char *GetArgumentName(lldb::CommandArgumentType arg_type); // Generates a nicely formatted command args string for help command output. - // By default, all possible args are taken into account, for example, - // '<expr | variable-name>'. This can be refined by passing a second arg - // specifying which option set(s) we are interested, which could then, for - // example, produce either '<expr>' or '<variable-name>'. + // By default, all possible args are taken into account, for example, '<expr + // | variable-name>'. This can be refined by passing a second arg specifying + // which option set(s) we are interested, which could then, for example, + // produce either '<expr>' or '<variable-name>'. void GetFormattedCommandArguments(Stream &str, uint32_t opt_set_mask = LLDB_OPT_SET_ALL); @@ -223,44 +223,13 @@ public: void SetCommandName(llvm::StringRef name); //------------------------------------------------------------------ - /// The input array contains a parsed version of the line. The insertion - /// point is given by cursor_index (the index in input of the word containing - /// the cursor) and cursor_char_position (the position of the cursor in that - /// word.) /// This default version handles calling option argument completions and then - /// calls - /// HandleArgumentCompletion if the cursor is on an argument, not an option. - /// Don't override this method, override HandleArgumentCompletion instead - /// unless - /// you have special reasons. - /// - /// @param[in] interpreter - /// The command interpreter doing the completion. - /// - /// @param[in] input - /// The command line parsed into words - /// - /// @param[in] cursor_index - /// The index in \ainput of the word in which the cursor lies. - /// - /// @param[in] cursor_char_pos - /// The character position of the cursor in its argument word. - /// - /// @param[in] match_start_point - /// @param[in] match_return_elements - /// FIXME: Not yet implemented... If there is a match that is expensive - /// to compute, these are - /// here to allow you to compute the completions in batches. Start the - /// completion from \amatch_start_point, - /// and return \amatch_return_elements elements. + /// calls HandleArgumentCompletion if the cursor is on an argument, not an + /// option. Don't override this method, override HandleArgumentCompletion + /// instead unless you have special reasons. /// - /// @param[out] word_complete - /// \btrue if this is a complete option value (a space will be inserted - /// after the - /// completion.) \bfalse otherwise. - /// - /// @param[out] matches - /// The array of matches returned. + /// @param[in/out] request + /// The completion request that needs to be answered. /// /// FIXME: This is the wrong return value, since we also need to make a /// distinction between @@ -269,10 +238,7 @@ public: /// @return /// \btrue if we were in an option, \bfalse otherwise. //------------------------------------------------------------------ - virtual int HandleCompletion(Args &input, int &cursor_index, - int &cursor_char_position, int match_start_point, - int max_return_elements, bool &word_complete, - StringList &matches); + virtual int HandleCompletion(CompletionRequest &request); //------------------------------------------------------------------ /// The input array contains a parsed version of the line. The insertion @@ -280,36 +246,10 @@ public: /// the cursor) and cursor_char_position (the position of the cursor in that /// word.) /// We've constructed the map of options and their arguments as well if that - /// is - /// helpful for the completion. - /// - /// @param[in] interpreter - /// The command interpreter doing the completion. - /// - /// @param[in] input - /// The command line parsed into words - /// - /// @param[in] cursor_index - /// The index in \ainput of the word in which the cursor lies. - /// - /// @param[in] cursor_char_pos - /// The character position of the cursor in its argument word. + /// is helpful for the completion. /// - /// @param[in] opt_element_vector - /// The results of the options parse of \a input. - /// - /// @param[in] match_start_point - /// @param[in] match_return_elements - /// See CommandObject::HandleCompletions for a description of how these - /// work. - /// - /// @param[out] word_complete - /// \btrue if this is a complete option value (a space will be inserted - /// after the - /// completion.) \bfalse otherwise. - /// - /// @param[out] matches - /// The array of matches returned. + /// @param[in/out] request + /// The completion request that needs to be answered. /// /// FIXME: This is the wrong return value, since we also need to make a /// distinction between @@ -318,10 +258,9 @@ public: /// @return /// The number of completions. //------------------------------------------------------------------ - virtual int HandleArgumentCompletion( - Args &input, int &cursor_index, int &cursor_char_position, - OptionElementVector &opt_element_vector, int match_start_point, - int max_return_elements, bool &word_complete, StringList &matches) { + virtual int + HandleArgumentCompletion(CompletionRequest &request, + OptionElementVector &opt_element_vector) { return 0; } @@ -397,6 +336,10 @@ public: CommandReturnObject &result) = 0; protected: + bool ParseOptionsAndNotify(Args &args, CommandReturnObject &result, + OptionGroupOptions &group_options, + ExecutionContext &exe_ctx); + virtual const char *GetInvalidTargetDescription() { return "invalid target, create a target using the 'target create' command"; } @@ -414,18 +357,16 @@ protected: } // This is for use in the command interpreter, when you either want the - // selected target, or if no target - // is present you want to prime the dummy target with entities that will be - // copied over to new targets. + // selected target, or if no target is present you want to prime the dummy + // target with entities that will be copied over to new targets. Target *GetSelectedOrDummyTarget(bool prefer_dummy = false); Target *GetDummyTarget(); - // If a command needs to use the "current" thread, use this call. - // Command objects will have an ExecutionContext to use, and that may or may - // not have a thread in it. If it - // does, you should use that by default, if not, then use the - // ExecutionContext's target's selected thread, etc... - // This call insulates you from the details of this calculation. + // If a command needs to use the "current" thread, use this call. Command + // objects will have an ExecutionContext to use, and that may or may not have + // a thread in it. If it does, you should use that by default, if not, then + // use the ExecutionContext's target's selected thread, etc... This call + // insulates you from the details of this calculation. Thread *GetDefaultThread(); //------------------------------------------------------------------ @@ -492,7 +433,8 @@ public: bool Execute(const char *args_string, CommandReturnObject &result) override; protected: - virtual bool DoExecute(const char *command, CommandReturnObject &result) = 0; + virtual bool DoExecute(llvm::StringRef command, + CommandReturnObject &result) = 0; bool WantsRawCommandString() override { return true; } }; diff --git a/include/lldb/Interpreter/CommandObjectMultiword.h b/include/lldb/Interpreter/CommandObjectMultiword.h index 947272f4212e8..d9eff9a6e545f 100644 --- a/include/lldb/Interpreter/CommandObjectMultiword.h +++ b/include/lldb/Interpreter/CommandObjectMultiword.h @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/CommandObject.h" +#include "lldb/Utility/CompletionRequest.h" namespace lldb_private { @@ -56,10 +57,7 @@ public: bool WantsRawCommandString() override { return false; } - int HandleCompletion(Args &input, int &cursor_index, - int &cursor_char_position, int match_start_point, - int max_return_elements, bool &word_complete, - StringList &matches) override; + int HandleCompletion(CompletionRequest &request) override; const char *GetRepeatCommand(Args ¤t_command_args, uint32_t index) override; @@ -87,8 +85,8 @@ public: ~CommandObjectProxy() override; - // Subclasses must provide a command object that will be transparently - // used for this object. + // Subclasses must provide a command object that will be transparently used + // for this object. virtual CommandObject *GetProxyCommandObject() = 0; llvm::StringRef GetHelpLong() override; @@ -121,17 +119,11 @@ public: Options *GetOptions() override; - int HandleCompletion(Args &input, int &cursor_index, - int &cursor_char_position, int match_start_point, - int max_return_elements, bool &word_complete, - StringList &matches) override; + int HandleCompletion(CompletionRequest &request) override; - int HandleArgumentCompletion(Args &input, int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, int max_return_elements, - bool &word_complete, - StringList &matches) override; + int HandleArgumentCompletion( + CompletionRequest &request, + OptionElementVector &opt_element_vector) override; const char *GetRepeatCommand(Args ¤t_command_args, uint32_t index) override; diff --git a/include/lldb/Interpreter/CommandObjectRegexCommand.h b/include/lldb/Interpreter/CommandObjectRegexCommand.h index 50dbebc21b1d7..36c3f068bdf3d 100644 --- a/include/lldb/Interpreter/CommandObjectRegexCommand.h +++ b/include/lldb/Interpreter/CommandObjectRegexCommand.h @@ -17,6 +17,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/CommandObject.h" +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/RegularExpression.h" namespace lldb_private { @@ -40,13 +41,10 @@ public: bool HasRegexEntries() const { return !m_entries.empty(); } - int HandleCompletion(Args &input, int &cursor_index, - int &cursor_char_position, int match_start_point, - int max_return_elements, bool &word_complete, - StringList &matches) override; + int HandleCompletion(CompletionRequest &request) override; protected: - bool DoExecute(const char *command, CommandReturnObject &result) override; + bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override; struct Entry { RegularExpression regex; diff --git a/include/lldb/Interpreter/OptionArgParser.h b/include/lldb/Interpreter/OptionArgParser.h new file mode 100644 index 0000000000000..5ace7e5d0250e --- /dev/null +++ b/include/lldb/Interpreter/OptionArgParser.h @@ -0,0 +1,43 @@ +//===-- OptionArgParser.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_INTERPRETER_OPTIONARGPARSER_H +#define LLDB_INTERPRETER_OPTIONARGPARSER_H + +#include "lldb/lldb-private-types.h" + +namespace lldb_private { + +struct OptionArgParser { + static lldb::addr_t ToAddress(const ExecutionContext *exe_ctx, + llvm::StringRef s, lldb::addr_t fail_value, + Status *error); + + static bool ToBoolean(llvm::StringRef s, bool fail_value, bool *success_ptr); + + static char ToChar(llvm::StringRef s, char fail_value, bool *success_ptr); + + static int64_t ToOptionEnum(llvm::StringRef s, + OptionEnumValueElement *enum_values, + int32_t fail_value, Status &error); + + static lldb::ScriptLanguage ToScriptLanguage(llvm::StringRef s, + lldb::ScriptLanguage fail_value, + bool *success_ptr); + + // TODO: Use StringRef + static Status ToFormat(const char *s, lldb::Format &format, + size_t *byte_size_ptr); // If non-NULL, then a + // byte size can precede + // the format character +}; + +} // namespace lldb_private + +#endif // LLDB_INTERPRETER_OPTIONARGPARSER_H diff --git a/include/lldb/Interpreter/OptionGroupBoolean.h b/include/lldb/Interpreter/OptionGroupBoolean.h index 53d08d79d67a6..2489a648dd7ed 100644 --- a/include/lldb/Interpreter/OptionGroupBoolean.h +++ b/include/lldb/Interpreter/OptionGroupBoolean.h @@ -24,9 +24,9 @@ namespace lldb_private { class OptionGroupBoolean : public OptionGroup { public: - // When 'no_argument_toggle_default' is true, then setting the option - // value does NOT require an argument, it sets the boolean value to the - // inverse of the default value + // When 'no_argument_toggle_default' is true, then setting the option value + // does NOT require an argument, it sets the boolean value to the inverse of + // the default value OptionGroupBoolean(uint32_t usage_mask, bool required, const char *long_option, int short_option, const char *usage_text, bool default_value, diff --git a/include/lldb/Interpreter/OptionGroupPlatform.h b/include/lldb/Interpreter/OptionGroupPlatform.h index e796624002796..cda4246f1b01c 100644 --- a/include/lldb/Interpreter/OptionGroupPlatform.h +++ b/include/lldb/Interpreter/OptionGroupPlatform.h @@ -16,6 +16,7 @@ // Project includes #include "lldb/Interpreter/Options.h" #include "lldb/Utility/ConstString.h" +#include "llvm/Support/VersionTuple.h" namespace lldb_private { @@ -28,8 +29,6 @@ class OptionGroupPlatform : public OptionGroup { public: OptionGroupPlatform(bool include_platform_option) : OptionGroup(), m_platform_name(), m_sdk_sysroot(), - m_os_version_major(UINT32_MAX), m_os_version_minor(UINT32_MAX), - m_os_version_update(UINT32_MAX), m_include_platform_option(include_platform_option) {} ~OptionGroupPlatform() override = default; @@ -72,9 +71,7 @@ protected: std::string m_platform_name; ConstString m_sdk_sysroot; ConstString m_sdk_build; - uint32_t m_os_version_major; - uint32_t m_os_version_minor; - uint32_t m_os_version_update; + llvm::VersionTuple m_os_version; bool m_include_platform_option; }; diff --git a/include/lldb/Interpreter/OptionValue.h b/include/lldb/Interpreter/OptionValue.h index 6008e1ea44114..4748e309c77e7 100644 --- a/include/lldb/Interpreter/OptionValue.h +++ b/include/lldb/Interpreter/OptionValue.h @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/FormatEntity.h" +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-defines.h" @@ -76,8 +77,8 @@ public: //----------------------------------------------------------------- virtual Type GetType() const = 0; - // If this value is always hidden, the avoid showing any info on this - // value, just show the info for the child values. + // If this value is always hidden, the avoid showing any info on this value, + // just show the info for the child values. virtual bool ValueIsTransparent() const { return GetType() == eTypeProperties; } @@ -100,9 +101,7 @@ public: virtual lldb::OptionValueSP DeepCopy() const = 0; virtual size_t AutoComplete(CommandInterpreter &interpreter, - llvm::StringRef s, int match_start_point, - int max_return_elements, bool &word_complete, - StringList &matches); + CompletionRequest &request); //----------------------------------------------------------------- // Subclasses can override these functions @@ -126,8 +125,8 @@ public: virtual bool DumpQualifiedName(Stream &strm) const; //----------------------------------------------------------------- - // Subclasses should NOT override these functions as they use the - // above functions to implement functionality + // Subclasses should NOT override these functions as they use the above + // functions to implement functionality //----------------------------------------------------------------- uint32_t GetTypeAsMask() { return 1u << GetType(); } @@ -183,9 +182,8 @@ public: CreateValueFromCStringForTypeMask(const char *value_cstr, uint32_t type_mask, Status &error); - // Get this value as a uint64_t value if it is encoded as a boolean, - // uint64_t or int64_t. Other types will cause "fail_value" to be - // returned + // Get this value as a uint64_t value if it is encoded as a boolean, uint64_t + // or int64_t. Other types will cause "fail_value" to be returned uint64_t GetUInt64Value(uint64_t fail_value, bool *success_ptr); OptionValueArch *GetAsArch(); @@ -339,10 +337,10 @@ protected: void *m_baton; bool m_value_was_set; // This can be used to see if a value has been set // by a call to SetValueFromCString(). It is often - // handy to know if an option value was set from - // the command line or as a setting, versus if we - // just have the default value that was already - // populated in the option value. + // handy to know if an option value was set from the + // command line or as a setting, versus if we just have + // the default value that was already populated in the + // option value. }; } // namespace lldb_private diff --git a/include/lldb/Interpreter/OptionValueArch.h b/include/lldb/Interpreter/OptionValueArch.h index d66448aa2bedf..15b74ad178930 100644 --- a/include/lldb/Interpreter/OptionValueArch.h +++ b/include/lldb/Interpreter/OptionValueArch.h @@ -12,6 +12,7 @@ #include "lldb/Interpreter/OptionValue.h" #include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/CompletionRequest.h" namespace lldb_private { @@ -57,9 +58,8 @@ public: lldb::OptionValueSP DeepCopy() const override; - size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s, - int match_start_point, int max_return_elements, - bool &word_complete, StringList &matches) override; + size_t AutoComplete(CommandInterpreter &interpreter, + lldb_private::CompletionRequest &request) override; //--------------------------------------------------------------------- // Subclass specific functions diff --git a/include/lldb/Interpreter/OptionValueArray.h b/include/lldb/Interpreter/OptionValueArray.h index bbf4e371a893b..44709d00763f1 100644 --- a/include/lldb/Interpreter/OptionValueArray.h +++ b/include/lldb/Interpreter/OptionValueArray.h @@ -78,8 +78,8 @@ public: } bool AppendValue(const lldb::OptionValueSP &value_sp) { - // Make sure the value_sp object is allowed to contain - // values of the type passed in... + // Make sure the value_sp object is allowed to contain values of the type + // passed in... if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) { m_values.push_back(value_sp); return true; @@ -88,8 +88,8 @@ public: } bool InsertValue(size_t idx, const lldb::OptionValueSP &value_sp) { - // Make sure the value_sp object is allowed to contain - // values of the type passed in... + // Make sure the value_sp object is allowed to contain values of the type + // passed in... if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) { if (idx < m_values.size()) m_values.insert(m_values.begin() + idx, value_sp); @@ -101,8 +101,8 @@ public: } bool ReplaceValue(size_t idx, const lldb::OptionValueSP &value_sp) { - // Make sure the value_sp object is allowed to contain - // values of the type passed in... + // Make sure the value_sp object is allowed to contain values of the type + // passed in... if (value_sp && (m_type_mask & value_sp->GetTypeAsMask())) { if (idx < m_values.size()) { m_values[idx] = value_sp; diff --git a/include/lldb/Interpreter/OptionValueBoolean.h b/include/lldb/Interpreter/OptionValueBoolean.h index 1ff84dd3367d7..6d2a16e595974 100644 --- a/include/lldb/Interpreter/OptionValueBoolean.h +++ b/include/lldb/Interpreter/OptionValueBoolean.h @@ -50,9 +50,8 @@ public: return true; } - size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s, - int match_start_point, int max_return_elements, - bool &word_complete, StringList &matches) override; + size_t AutoComplete(CommandInterpreter &interpreter, + CompletionRequest &request) override; //--------------------------------------------------------------------- // Subclass specific functions diff --git a/include/lldb/Interpreter/OptionValueEnumeration.h b/include/lldb/Interpreter/OptionValueEnumeration.h index 4aa8823e620f7..08d6ac70de522 100644 --- a/include/lldb/Interpreter/OptionValueEnumeration.h +++ b/include/lldb/Interpreter/OptionValueEnumeration.h @@ -59,9 +59,8 @@ public: lldb::OptionValueSP DeepCopy() const override; - size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s, - int match_start_point, int max_return_elements, - bool &word_complete, StringList &matches) override; + size_t AutoComplete(CommandInterpreter &interpreter, + CompletionRequest &request) override; //--------------------------------------------------------------------- // Subclass specific functions diff --git a/include/lldb/Interpreter/OptionValueFileSpec.h b/include/lldb/Interpreter/OptionValueFileSpec.h index 293ecd0d80544..41a479e2fc9e4 100644 --- a/include/lldb/Interpreter/OptionValueFileSpec.h +++ b/include/lldb/Interpreter/OptionValueFileSpec.h @@ -54,9 +54,8 @@ public: lldb::OptionValueSP DeepCopy() const override; - size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s, - int match_start_point, int max_return_elements, - bool &word_complete, StringList &matches) override; + size_t AutoComplete(CommandInterpreter &interpreter, + CompletionRequest &request) override; //--------------------------------------------------------------------- // Subclass specific functions diff --git a/include/lldb/Interpreter/OptionValueFormatEntity.h b/include/lldb/Interpreter/OptionValueFormatEntity.h index e5a65b7e7eb60..880e434dc5c00 100644 --- a/include/lldb/Interpreter/OptionValueFormatEntity.h +++ b/include/lldb/Interpreter/OptionValueFormatEntity.h @@ -45,9 +45,8 @@ public: lldb::OptionValueSP DeepCopy() const override; - size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s, - int match_start_point, int max_return_elements, - bool &word_complete, StringList &matches) override; + size_t AutoComplete(CommandInterpreter &interpreter, + CompletionRequest &request) override; //--------------------------------------------------------------------- // Subclass specific functions diff --git a/include/lldb/Interpreter/OptionValueProperties.h b/include/lldb/Interpreter/OptionValueProperties.h index 16d31aa4ea902..96bd93ab3d7be 100644 --- a/include/lldb/Interpreter/OptionValueProperties.h +++ b/include/lldb/Interpreter/OptionValueProperties.h @@ -75,15 +75,15 @@ public: //--------------------------------------------------------------------- // Get the index of a property given its exact name in this property - // collection, "name" can't be a path to a property path that refers - // to a property within a property + // collection, "name" can't be a path to a property path that refers to a + // property within a property //--------------------------------------------------------------------- virtual uint32_t GetPropertyIndex(const ConstString &name) const; //--------------------------------------------------------------------- - // Get a property by exact name exists in this property collection, name - // can not be a path to a property path that refers to a property within - // a property + // Get a property by exact name exists in this property collection, name can + // not be a path to a property path that refers to a property within a + // property //--------------------------------------------------------------------- virtual const Property *GetProperty(const ExecutionContext *exe_ctx, bool will_modify, diff --git a/include/lldb/Interpreter/OptionValueUInt64.h b/include/lldb/Interpreter/OptionValueUInt64.h index be13ff073721a..96404bed8e676 100644 --- a/include/lldb/Interpreter/OptionValueUInt64.h +++ b/include/lldb/Interpreter/OptionValueUInt64.h @@ -34,9 +34,9 @@ public: //--------------------------------------------------------------------- // Decode a uint64_t from "value_cstr" return a OptionValueUInt64 object - // inside of a lldb::OptionValueSP object if all goes well. If the - // string isn't a uint64_t value or any other error occurs, return an - // empty lldb::OptionValueSP and fill error in with the correct stuff. + // inside of a lldb::OptionValueSP object if all goes well. If the string + // isn't a uint64_t value or any other error occurs, return an empty + // lldb::OptionValueSP and fill error in with the correct stuff. //--------------------------------------------------------------------- static lldb::OptionValueSP Create(const char *, Status &) = delete; static lldb::OptionValueSP Create(llvm::StringRef value_str, Status &error); diff --git a/include/lldb/Interpreter/OptionValueUUID.h b/include/lldb/Interpreter/OptionValueUUID.h index 6e0aeebb0e994..950efb518d5ad 100644 --- a/include/lldb/Interpreter/OptionValueUUID.h +++ b/include/lldb/Interpreter/OptionValueUUID.h @@ -61,9 +61,8 @@ public: void SetCurrentValue(const UUID &value) { m_uuid = value; } - size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s, - int match_start_point, int max_return_elements, - bool &word_complete, StringList &matches) override; + size_t AutoComplete(CommandInterpreter &interpreter, + CompletionRequest &request) override; protected: UUID m_uuid; diff --git a/include/lldb/Interpreter/Options.h b/include/lldb/Interpreter/Options.h index 87121005575a9..316bf568fd92b 100644 --- a/include/lldb/Interpreter/Options.h +++ b/include/lldb/Interpreter/Options.h @@ -17,7 +17,9 @@ // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/Args.h" +#include "lldb/Utility/Args.h" +#include "lldb/Utility/CompletionRequest.h" +#include "lldb/Utility/Status.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-private.h" @@ -25,6 +27,24 @@ namespace lldb_private { +struct Option; + +typedef std::vector<std::tuple<std::string, int, std::string>> OptionArgVector; +typedef std::shared_ptr<OptionArgVector> OptionArgVectorSP; + +struct OptionArgElement { + enum { eUnrecognizedArg = -1, eBareDash = -2, eBareDoubleDash = -3 }; + + OptionArgElement(int defs_index, int pos, int arg_pos) + : opt_defs_index(defs_index), opt_pos(pos), opt_arg_pos(arg_pos) {} + + int opt_defs_index; + int opt_pos; + int opt_arg_pos; +}; + +typedef std::vector<OptionArgElement> OptionElementVector; + static inline bool isprint8(int ch) { if (ch & 0xffffff00u) return false; @@ -33,90 +53,18 @@ static inline bool isprint8(int ch) { //---------------------------------------------------------------------- /// @class Options Options.h "lldb/Interpreter/Options.h" -/// @brief A command line option parsing protocol class. +/// A command line option parsing protocol class. /// -/// Options is designed to be subclassed to contain all needed -/// options for a given command. The options can be parsed by calling: -/// \code -/// Status Args::ParseOptions (Options &); -/// \endcode +/// Options is designed to be subclassed to contain all needed options for a +/// given command. The options can be parsed by calling the Parse function. /// -/// The options are specified using the format defined for the libc -/// options parsing function getopt_long_only: -/// \code +/// The options are specified using the format defined for the libc options +/// parsing function getopt_long_only: \code /// #include <getopt.h> /// int getopt_long_only(int argc, char * const *argv, const char /// *optstring, const struct option *longopts, int *longindex); /// \endcode /// -/// Example code: -/// \code -/// #include <getopt.h> -/// #include <string> -/// -/// class CommandOptions : public Options -/// { -/// public: -/// virtual struct option * -/// GetLongOptions() { -/// return g_options; -/// } -/// -/// virtual Status -/// SetOptionValue (uint32_t option_idx, int option_val, const char -/// *option_arg) -/// { -/// Status error; -/// switch (option_val) -/// { -/// case 'g': debug = true; break; -/// case 'v': verbose = true; break; -/// case 'l': log_file = option_arg; break; -/// case 'f': log_flags = strtoull(option_arg, nullptr, 0); break; -/// default: -/// error.SetErrorStringWithFormat("unrecognized short option -/// %c", option_val); -/// break; -/// } -/// -/// return error; -/// } -/// -/// CommandOptions (CommandInterpreter &interpreter) : debug (true), -/// verbose (false), log_file (), log_flags (0) -/// {} -/// -/// bool debug; -/// bool verbose; -/// std::string log_file; -/// uint32_t log_flags; -/// -/// static struct option g_options[]; -/// -/// }; -/// -/// struct option CommandOptions::g_options[] = -/// { -/// { "debug", no_argument, nullptr, 'g' }, -/// { "log-file", required_argument, nullptr, 'l' }, -/// { "log-flags", required_argument, nullptr, 'f' }, -/// { "verbose", no_argument, nullptr, 'v' }, -/// { nullptr, 0, nullptr, 0 } -/// }; -/// -/// int main (int argc, const char **argv, const char **envp) -/// { -/// CommandOptions options; -/// Args main_command; -/// main_command.SetArguments(argc, argv, false); -/// main_command.ParseOptions(options); -/// -/// if (options.verbose) -/// { -/// std::cout << "verbose is on" << std::endl; -/// } -/// } -/// \endcode //---------------------------------------------------------------------- class Options { public: @@ -143,9 +91,9 @@ public: bool VerifyOptions(CommandReturnObject &result); - // Verify that the options given are in the options table and can - // be used together, but there may be some required options that are - // missing (used to verify options that get folded into command aliases). + // Verify that the options given are in the options table and can be used + // together, but there may be some required options that are missing (used to + // verify options that get folded into command aliases). bool VerifyPartialOptions(CommandReturnObject &result); void OutputFormattedUsageText(Stream &strm, @@ -157,20 +105,50 @@ public: bool SupportsLongOption(const char *long_option); - // The following two pure virtual functions must be defined by every - // class that inherits from this class. + // The following two pure virtual functions must be defined by every class + // that inherits from this class. virtual llvm::ArrayRef<OptionDefinition> GetDefinitions() { return llvm::ArrayRef<OptionDefinition>(); } - // Call this prior to parsing any options. This call will call the - // subclass OptionParsingStarting() and will avoid the need for all + // Call this prior to parsing any options. This call will call the subclass + // OptionParsingStarting() and will avoid the need for all // OptionParsingStarting() function instances from having to call the - // Option::OptionParsingStarting() like they did before. This was error - // prone and subclasses shouldn't have to do it. + // Option::OptionParsingStarting() like they did before. This was error prone + // and subclasses shouldn't have to do it. void NotifyOptionParsingStarting(ExecutionContext *execution_context); + //------------------------------------------------------------------ + /// Parse the provided arguments. + /// + /// The parsed options are set via calls to SetOptionValue. In case of a + /// successful parse, the function returns a copy of the input arguments + /// with the parsed options removed. Otherwise, it returns an error. + /// + /// param[in] platform_sp + /// The platform used for option validation. This is necessary + /// because an empty execution_context is not enough to get us + /// to a reasonable platform. If the platform isn't given, + /// we'll try to get it from the execution context. If we can't + /// get it from the execution context, we'll skip validation. + /// + /// param[in] require_validation + /// When true, it will fail option parsing if validation could + /// not occur due to not having a platform. + //------------------------------------------------------------------ + llvm::Expected<Args> Parse(const Args &args, + ExecutionContext *execution_context, + lldb::PlatformSP platform_sp, + bool require_validation); + + llvm::Expected<Args> ParseAlias(const Args &args, + OptionArgVector *option_arg_vector, + std::string &input_line); + + OptionElementVector ParseForCompletion(const Args &args, + uint32_t cursor_index); + Status NotifyOptionParsingFinished(ExecutionContext *execution_context); //------------------------------------------------------------------ @@ -196,99 +174,48 @@ public: ExecutionContext *execution_context) = 0; //------------------------------------------------------------------ - /// Handles the generic bits of figuring out whether we are in an - /// option, and if so completing it. + /// Handles the generic bits of figuring out whether we are in an option, + /// and if so completing it. /// - /// @param[in] input - /// The command line parsed into words - /// - /// @param[in] cursor_index - /// The index in \ainput of the word in which the cursor lies. - /// - /// @param[in] char_pos - /// The character position of the cursor in its argument word. - /// - /// @param[in] match_start_point - /// @param[in] match_return_elements - /// See CommandObject::HandleCompletions for a description of - /// how these work. + /// @param[in/out] request + /// The completion request that we need to act upon. /// /// @param[in] interpreter /// The interpreter that's doing the completing. /// - /// @param[out] word_complete - /// \btrue if this is a complete option value (a space will be - /// inserted after the completion.) \b false otherwise. - /// - /// @param[out] matches - /// The array of matches returned. - /// /// FIXME: This is the wrong return value, since we also need to - /// make a distinction between total number of matches, and the - /// window the user wants returned. + /// make a distinction between total number of matches, and the window the + /// user wants returned. /// /// @return /// \btrue if we were in an option, \bfalse otherwise. //------------------------------------------------------------------ - bool HandleOptionCompletion(Args &input, OptionElementVector &option_map, - int cursor_index, int char_pos, - int match_start_point, int max_return_elements, - CommandInterpreter &interpreter, - bool &word_complete, - lldb_private::StringList &matches); + bool HandleOptionCompletion(lldb_private::CompletionRequest &request, + OptionElementVector &option_map, + CommandInterpreter &interpreter); //------------------------------------------------------------------ - /// Handles the generic bits of figuring out whether we are in an - /// option, and if so completing it. + /// Handles the generic bits of figuring out whether we are in an option, + /// and if so completing it. /// - /// @param[in] interpreter - /// The command interpreter doing the completion. - /// - /// @param[in] input - /// The command line parsed into words - /// - /// @param[in] cursor_index - /// The index in \ainput of the word in which the cursor lies. - /// - /// @param[in] char_pos - /// The character position of the cursor in its argument word. - /// - /// @param[in] opt_element_vector - /// The results of the options parse of \a input. - /// - /// @param[in] opt_element_index - /// The position in \a opt_element_vector of the word in \a - /// input containing the cursor. - /// - /// @param[in] match_start_point - /// @param[in] match_return_elements - /// See CommandObject::HandleCompletions for a description of - /// how these work. + /// @param[in/out] request + /// The completion request that we need to act upon. /// /// @param[in] interpreter - /// The command interpreter in which we're doing completion. - /// - /// @param[out] word_complete - /// \btrue if this is a complete option value (a space will - /// be inserted after the completion.) \bfalse otherwise. - /// - /// @param[out] matches - /// The array of matches returned. + /// The command interpreter doing the completion. /// /// FIXME: This is the wrong return value, since we also need to - /// make a distinction between total number of matches, and the - /// window the user wants returned. + /// make a distinction between total number of matches, and the window the + /// user wants returned. /// /// @return /// \btrue if we were in an option, \bfalse otherwise. //------------------------------------------------------------------ virtual bool - HandleOptionArgumentCompletion(Args &input, int cursor_index, int char_pos, + HandleOptionArgumentCompletion(lldb_private::CompletionRequest &request, OptionElementVector &opt_element_vector, - int opt_element_index, int match_start_point, - int max_return_elements, - CommandInterpreter &interpreter, - bool &word_complete, StringList &matches); + int opt_element_index, + CommandInterpreter &interpreter); protected: // This is a set of options expressed as indexes into the options table for @@ -319,14 +246,14 @@ protected: void OptionsSetUnion(const OptionSet &set_a, const OptionSet &set_b, OptionSet &union_set); - // Subclasses must reset their option values prior to starting a new - // option parse. Each subclass must override this function and revert - // all option settings to default values. + // Subclasses must reset their option values prior to starting a new option + // parse. Each subclass must override this function and revert all option + // settings to default values. virtual void OptionParsingStarting(ExecutionContext *execution_context) = 0; virtual Status OptionParsingFinished(ExecutionContext *execution_context) { - // If subclasses need to know when the options are done being parsed - // they can implement this function to do extra checking + // If subclasses need to know when the options are done being parsed they + // can implement this function to do extra checking Status error; return error; } @@ -347,8 +274,8 @@ public: virtual void OptionParsingStarting(ExecutionContext *execution_context) = 0; virtual Status OptionParsingFinished(ExecutionContext *execution_context) { - // If subclasses need to know when the options are done being parsed - // they can implement this function to do extra checking + // If subclasses need to know when the options are done being parsed they + // can implement this function to do extra checking Status error; return error; } @@ -364,8 +291,8 @@ public: //---------------------------------------------------------------------- /// Append options from a OptionGroup class. /// - /// Append all options from \a group using the exact same option groups - /// that each option is defined with. + /// Append all options from \a group using the exact same option groups that + /// each option is defined with. /// /// @param[in] group /// A group of options to take option values from and copy their @@ -376,9 +303,9 @@ public: //---------------------------------------------------------------------- /// Append options from a OptionGroup class. /// - /// Append options from \a group that have a usage mask that has any bits - /// in "src_mask" set. After the option definition is copied into the - /// options definitions in this class, set the usage_mask to "dst_mask". + /// Append options from \a group that have a usage mask that has any bits in + /// "src_mask" set. After the option definition is copied into the options + /// definitions in this class, set the usage_mask to "dst_mask". /// /// @param[in] group /// A group of options to take option values from and copy their diff --git a/include/lldb/Interpreter/ScriptInterpreter.h b/include/lldb/Interpreter/ScriptInterpreter.h index 335231cb29ec9..d2189edd04a63 100644 --- a/include/lldb/Interpreter/ScriptInterpreter.h +++ b/include/lldb/Interpreter/ScriptInterpreter.h @@ -96,13 +96,13 @@ public: virtual bool Interrupt() { return false; } virtual bool ExecuteOneLine( - const char *command, CommandReturnObject *result, + llvm::StringRef command, CommandReturnObject *result, const ExecuteScriptOptions &options = ExecuteScriptOptions()) = 0; virtual void ExecuteInterpreterLoop() = 0; virtual bool ExecuteOneLineWithReturn( - const char *in_string, ScriptReturnType return_type, void *ret_value, + llvm::StringRef in_string, ScriptReturnType return_type, void *ret_value, const ExecuteScriptOptions &options = ExecuteScriptOptions()) { return true; } @@ -343,7 +343,7 @@ public: } virtual bool - RunScriptBasedCommand(const char *impl_function, const char *args, + RunScriptBasedCommand(const char *impl_function, llvm::StringRef args, ScriptedCommandSynchronicity synchronicity, lldb_private::CommandReturnObject &cmd_retobj, Status &error, @@ -351,12 +351,11 @@ public: return false; } - virtual bool - RunScriptBasedCommand(StructuredData::GenericSP impl_obj_sp, const char *args, - ScriptedCommandSynchronicity synchronicity, - lldb_private::CommandReturnObject &cmd_retobj, - Status &error, - const lldb_private::ExecutionContext &exe_ctx) { + virtual bool RunScriptBasedCommand( + StructuredData::GenericSP impl_obj_sp, llvm::StringRef args, + ScriptedCommandSynchronicity synchronicity, + lldb_private::CommandReturnObject &cmd_retobj, Status &error, + const lldb_private::ExecutionContext &exe_ctx) { return false; } diff --git a/include/lldb/Symbol/Block.h b/include/lldb/Symbol/Block.h index a5387cca21c5e..1664362431f91 100644 --- a/include/lldb/Symbol/Block.h +++ b/include/lldb/Symbol/Block.h @@ -30,21 +30,21 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class Block Block.h "lldb/Symbol/Block.h" -/// @brief A class that describes a single lexical block. +/// A class that describes a single lexical block. /// /// A Function object owns a BlockList object which owns one or more -/// Block objects. The BlockList object contains a section offset -/// address range, and Block objects contain one or more ranges -/// which are offsets into that range. Blocks are can have discontiguous -/// ranges within the BlockList address range, and each block can -/// contain child blocks each with their own sets of ranges. +/// Block objects. The BlockList object contains a section offset address +/// range, and Block objects contain one or more ranges which are offsets into +/// that range. Blocks are can have discontiguous ranges within the BlockList +/// address range, and each block can contain child blocks each with their own +/// sets of ranges. /// -/// Each block has a variable list that represents local, argument, and -/// static variables that are scoped to the block. +/// Each block has a variable list that represents local, argument, and static +/// variables that are scoped to the block. /// -/// Inlined functions are represented by attaching a -/// InlineFunctionInfo shared pointer object to a block. Inlined -/// functions are represented as named blocks. +/// Inlined functions are represented by attaching a InlineFunctionInfo shared +/// pointer object to a block. Inlined functions are represented as named +/// blocks. //---------------------------------------------------------------------- class Block : public UserID, public SymbolContextScope { public: @@ -54,10 +54,9 @@ public: //------------------------------------------------------------------ /// Construct with a User ID \a uid, \a depth. /// - /// Initialize this block with the specified UID \a uid. The - /// \a depth in the \a block_list is used to represent the parent, - /// sibling, and child block information and also allows for partial - /// parsing at the block level. + /// Initialize this block with the specified UID \a uid. The \a depth in the + /// \a block_list is used to represent the parent, sibling, and child block + /// information and also allows for partial parsing at the block level. /// /// @param[in] uid /// The UID for a given block. This value is given by the @@ -146,8 +145,7 @@ public: bool Contains(const Range &range) const; //------------------------------------------------------------------ - /// Check if this object contains "block" as a child block at any - /// depth. + /// Check if this object contains "block" as a child block at any depth. /// /// @param[in] block /// A potential child block. @@ -256,8 +254,8 @@ public: lldb::VariableListSP GetBlockVariableList(bool can_create); //------------------------------------------------------------------ - /// Get the variable list for this block and optionally all child - /// blocks if \a get_child_variables is \b true. + /// Get the variable list for this block and optionally all child blocks if + /// \a get_child_variables is \b true. /// /// @param[in] get_child_variables /// If \b true, all variables from all child blocks will be @@ -286,8 +284,8 @@ public: VariableList *variable_list); //------------------------------------------------------------------ - /// Appends the variables from this block, and optionally from all - /// parent blocks, to \a variable_list. + /// Appends the variables from this block, and optionally from all parent + /// blocks, to \a variable_list. /// /// @param[in] can_create /// If \b true, the variables can be parsed if they already @@ -334,8 +332,8 @@ public: //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// Returns the cost of this object plus any owned objects from the - /// ranges, variables, and inline function information. + /// Returns the cost of this object plus any owned objects from the ranges, + /// variables, and inline function information. /// /// @return /// The number of bytes that this object occupies in memory. @@ -374,9 +372,8 @@ public: //------------------------------------------------------------------ /// Set accessor for the variable list. /// - /// Called by the SymbolFile plug-ins after they have parsed the - /// variable lists and are ready to hand ownership of the list over - /// to this object. + /// Called by the SymbolFile plug-ins after they have parsed the variable + /// lists and are ready to hand ownership of the list over to this object. /// /// @param[in] variable_list_sp /// A shared pointer to a VariableList. @@ -403,8 +400,8 @@ public: uint32_t GetRangeIndexContainingAddress(const Address &addr); //------------------------------------------------------------------ - // Since blocks might have multiple discontiguous address ranges, - // we need to be able to get at any of the address ranges in a block. + // Since blocks might have multiple discontiguous address ranges, we need to + // be able to get at any of the address ranges in a block. //------------------------------------------------------------------ bool GetRangeAtIndex(uint32_t range_idx, AddressRange &range); diff --git a/include/lldb/Symbol/ClangASTContext.h b/include/lldb/Symbol/ClangASTContext.h index 2d2c804eb0250..9364149d98e71 100644 --- a/include/lldb/Symbol/ClangASTContext.h +++ b/include/lldb/Symbol/ClangASTContext.h @@ -253,6 +253,9 @@ public: &type_fields, bool packed = false); + static bool IsOperator(const char *name, + clang::OverloadedOperatorKind &op_kind); + //------------------------------------------------------------------ // Structure, Unions, Classes //------------------------------------------------------------------ @@ -302,6 +305,9 @@ public: lldb::AccessType access_type, const char *class_name, int kind, const TemplateParameterInfos &infos); + clang::TemplateTemplateParmDecl * + CreateTemplateTemplateParmDecl(const char *template_name); + clang::ClassTemplateSpecializationDecl *CreateClassTemplateSpecializationDecl( clang::DeclContext *decl_ctx, clang::ClassTemplateDecl *class_template_decl, int kind, @@ -632,8 +638,7 @@ public: //---------------------------------------------------------------------- // Using the current type, create a new typedef to that type using - // "typedef_name" - // as the name and "decl_ctx" as the decl context. + // "typedef_name" as the name and "decl_ctx" as the decl context. static CompilerType CreateTypedefType(const CompilerType &type, const char *typedef_name, const CompilerDeclContext &compiler_decl_ctx); @@ -650,8 +655,7 @@ public: GetFullyUnqualifiedType(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. + // 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, @@ -763,8 +767,8 @@ public: 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. + // 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; @@ -794,8 +798,8 @@ public: CompilerType GetTypeForFormatters(void *type) override; #define LLDB_INVALID_DECL_LEVEL UINT32_MAX - // LLDB_INVALID_DECL_LEVEL is returned by CountDeclLevels if - // child_decl_ctx could not be found in decl_ctx. + // LLDB_INVALID_DECL_LEVEL is returned by CountDeclLevels if child_decl_ctx + // could not be found in decl_ctx. uint32_t CountDeclLevels(clang::DeclContext *frame_decl_ctx, clang::DeclContext *child_decl_ctx, ConstString *child_name = nullptr, @@ -821,6 +825,7 @@ public: clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, const char *name, + const char *mangled_name, const CompilerType &method_type, lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, @@ -885,13 +890,13 @@ public: // Pointers & References //------------------------------------------------------------------ - // Call this function using the class type when you want to make a - // member pointer type to pointee_type. + // Call this function using the class type when you want to make a member + // pointer type to pointee_type. static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type); - // Converts "s" to a floating point value and place resulting floating - // point bytes in the "dst" buffer. + // 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; diff --git a/include/lldb/Symbol/ClangASTImporter.h b/include/lldb/Symbol/ClangASTImporter.h index 6823ad748282b..52a164a1d2dd2 100644 --- a/include/lldb/Symbol/ClangASTImporter.h +++ b/include/lldb/Symbol/ClangASTImporter.h @@ -250,13 +250,12 @@ private: // recorded and placed into the decls_to_deport set. // // A call to "ExecuteDeportWorkQueues" completes all the Decls that - // are in decls_to_deport, adding any Decls it sees along the way that - // it hasn't already deported. It proceeds until decls_to_deport is - // empty. + // are in decls_to_deport, adding any Decls it sees along the way that it + // hasn't already deported. It proceeds until decls_to_deport is empty. // - // These calls must be paired. Leaving a minion in deport mode or - // trying to start deport minion with a new pair of queues will result - // in an assertion failure. + // These calls must be paired. Leaving a minion in deport mode or trying + // to start deport minion with a new pair of queues will result in an + // assertion failure. void InitDeportWorkQueues(std::set<clang::NamedDecl *> *decls_to_deport, diff --git a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h index 61bbc122dd5fc..ef0010314e1db 100644 --- a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h +++ b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h @@ -60,21 +60,21 @@ public: //------------------------------------------------------------------ clang::Decl *GetExternalDecl(uint32_t ID) override { - // This method only needs to be implemented if the AST source ever - // passes back decl sets as VisibleDeclaration objects. + // This method only needs to be implemented if the AST source ever passes + // back decl sets as VisibleDeclaration objects. return nullptr; } clang::Stmt *GetExternalDeclStmt(uint64_t Offset) override { - // This operation is meant to be used via a LazyOffsetPtr. It only - // needs to be implemented if the AST source uses methods like + // This operation is meant to be used via a LazyOffsetPtr. It only needs + // to be implemented if the AST source uses methods like // FunctionDecl::setLazyBody when building decls. return nullptr; } clang::Selector GetExternalSelector(uint32_t ID) override { - // This operation only needs to be implemented if the AST source - // returns non-zero for GetNumKnownSelectors(). + // This operation only needs to be implemented if the AST source returns + // non-zero for GetNumKnownSelectors(). return clang::Selector(); } diff --git a/include/lldb/Symbol/CompactUnwindInfo.h b/include/lldb/Symbol/CompactUnwindInfo.h index 630067241735c..711420f66a465 100644 --- a/include/lldb/Symbol/CompactUnwindInfo.h +++ b/include/lldb/Symbol/CompactUnwindInfo.h @@ -22,23 +22,18 @@ namespace lldb_private { // Compact Unwind info is an unwind format used on Darwin. The unwind -// instructions -// for typical compiler-generated functions can be expressed in a 32-bit -// encoding. -// The format includes a two-level index so the unwind information for a -// function -// can be found by two binary searches in the section. It can represent both -// stack frames that use a frame-pointer register and frameless functions, on -// i386/x86_64 for instance. When a function is too complex to be represented -// in -// the compact unwind format, it calls out to eh_frame unwind instructions. +// instructions for typical compiler-generated functions can be expressed in a +// 32-bit encoding. The format includes a two-level index so the unwind +// information for a function can be found by two binary searches in the +// section. It can represent both stack frames that use a frame-pointer +// register and frameless functions, on i386/x86_64 for instance. When a +// function is too complex to be represented in the compact unwind format, it +// calls out to eh_frame unwind instructions. // On Mac OS X / iOS, a function will have either a compact unwind -// representation -// or an eh_frame representation. If lldb is going to benefit from the -// compiler's -// description about saved register locations, it must be able to read both -// sources of information. +// representation or an eh_frame representation. If lldb is going to benefit +// from the compiler's description about saved register locations, it must be +// able to read both sources of information. class CompactUnwindInfo { public: @@ -54,9 +49,8 @@ private: // The top level index entries of the compact unwind info // (internal representation of struct // unwind_info_section_header_index_entry) - // There are relatively few of these (one per 500/1000 functions, depending on - // format) so - // creating them on first scan will not be too costly. + // There are relatively few of these (one per 500/1000 functions, depending + // on format) so creating them on first scan will not be too costly. struct UnwindIndex { uint32_t function_offset; // The offset of the first function covered by // this index @@ -84,8 +78,7 @@ private: }; // An internal object used to store the information we retrieve about a - // function -- - // the encoding bits and possibly the LSDA/personality function. + // function -- the encoding bits and possibly the LSDA/personality function. struct FunctionInfo { uint32_t encoding; // compact encoding 32-bit value for this function Address lsda_address; // the address of the LSDA data for this function diff --git a/include/lldb/Symbol/CompileUnit.h b/include/lldb/Symbol/CompileUnit.h index e7a1ebc8c00f7..b816439cee135 100644 --- a/include/lldb/Symbol/CompileUnit.h +++ b/include/lldb/Symbol/CompileUnit.h @@ -21,16 +21,16 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h" -/// @brief A class that describes a compilation unit. +/// A class that describes a compilation unit. /// /// A representation of a compilation unit, or compiled source file. -/// The UserID of the compile unit is specified by the SymbolFile -/// plug-in and can have any value as long as the value is unique -/// within the Module that owns this compile units. +/// The UserID of the compile unit is specified by the SymbolFile plug-in and +/// can have any value as long as the value is unique within the Module that +/// owns this compile units. /// -/// Each compile unit has a list of functions, global and static -/// variables, support file list (include files and inlined source -/// files), and a line table. +/// Each compile unit has a list of functions, global and static variables, +/// support file list (include files and inlined source files), and a line +/// table. //---------------------------------------------------------------------- class CompileUnit : public std::enable_shared_from_this<CompileUnit>, public ModuleChild, @@ -41,9 +41,9 @@ public: //------------------------------------------------------------------ /// Construct with a module, path, UID and language. /// - /// Initialize the compile unit given the owning \a module, a path - /// to convert into a FileSpec, the SymbolFile plug-in supplied - /// \a uid, and the source language type. + /// Initialize the compile unit given the owning \a module, a path to + /// convert into a FileSpec, the SymbolFile plug-in supplied \a uid, and the + /// source language type. /// /// @param[in] module /// The parent module that owns this compile unit. This value @@ -81,9 +81,9 @@ public: //------------------------------------------------------------------ /// Construct with a module, file spec, UID and language. /// - /// Initialize the compile unit given the owning \a module, a path - /// to convert into a FileSpec, the SymbolFile plug-in supplied - /// \a uid, and the source language type. + /// Initialize the compile unit given the owning \a module, a path to + /// convert into a FileSpec, the SymbolFile plug-in supplied \a uid, and the + /// source language type. /// /// @param[in] module /// The parent module that owns this compile unit. This value @@ -127,8 +127,8 @@ public: //------------------------------------------------------------------ /// Add a function to this compile unit. /// - /// Typically called by the SymbolFile plug-ins as they partially - /// parse the debug information. + /// Typically called by the SymbolFile plug-ins as they partially parse the + /// debug information. /// /// @param[in] function_sp /// A shared pointer to the Function object. @@ -163,13 +163,12 @@ public: void GetDescription(Stream *s, lldb::DescriptionLevel level) const; //------------------------------------------------------------------ - /// Get a shared pointer to a function in this compile unit by - /// index. + /// Get a shared pointer to a function in this compile unit by index. /// - /// 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. + /// 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. /// /// @param[in] idx /// An index into the function list. @@ -195,16 +194,15 @@ public: //------------------------------------------------------------------ /// Find the line entry by line and optional inlined file spec. /// - /// Finds the first line entry that has an index greater than - /// \a start_idx that matches \a line. If \a file_spec_ptr - /// is NULL, then the search matches line entries whose file matches - /// the file for the compile unit. If \a file_spec_ptr is - /// not NULL, line entries must match the specified file spec (for - /// inlined line table entries). + /// Finds the first line entry that has an index greater than \a start_idx + /// that matches \a line. If \a file_spec_ptr is NULL, then the search + /// matches line entries whose file matches the file for the compile unit. + /// If \a file_spec_ptr is not NULL, line entries must match the specified + /// file spec (for inlined line table entries). /// - /// Multiple calls to this function can find all entries that match - /// a given file and line by starting with \a start_idx equal to zero, - /// and calling this function back with the return value + 1. + /// Multiple calls to this function can find all entries that match a given + /// file and line by starting with \a start_idx equal to zero, and calling + /// this function back with the return value + 1. /// /// @param[in] start_idx /// The zero based index at which to start looking for matches. @@ -237,10 +235,9 @@ public: //------------------------------------------------------------------ /// Get the line table for the compile unit. /// - /// Called by clients and the SymbolFile plug-in. The SymbolFile - /// plug-ins use this function to determine if the line table has - /// be parsed yet. Clients use this function to get the line table - /// from a compile unit. + /// Called by clients and the SymbolFile plug-in. The SymbolFile plug-ins + /// use this function to determine if the line table has be parsed yet. + /// Clients use this function to get the line table from a compile unit. /// /// @return /// The line table object pointer, or NULL if this line table @@ -253,8 +250,8 @@ public: //------------------------------------------------------------------ /// Get the compile unit's support file list. /// - /// The support file list is used by the line table, and any objects - /// that have valid Declaration objects. + /// The support file list is used by the line table, and any objects that + /// have valid Declaration objects. /// /// @return /// A support file list object. @@ -264,8 +261,8 @@ public: //------------------------------------------------------------------ /// Get the compile unit's imported module list. /// - /// This reports all the imports that the compile unit made, - /// including the current module. + /// This reports all the imports that the compile unit made, including the + /// current module. /// /// @return /// A list of imported module names. @@ -275,9 +272,8 @@ public: //------------------------------------------------------------------ /// Get the SymbolFile plug-in user data. /// - /// SymbolFile plug-ins can store user data to internal state or - /// objects to quickly allow them to parse more information for a - /// given object. + /// SymbolFile plug-ins can store user data to internal state or objects to + /// quickly allow them to parse more information for a given object. /// /// @return /// The user data stored with the CompileUnit when it was @@ -288,9 +284,9 @@ public: //------------------------------------------------------------------ /// Get the variable list for a compile unit. /// - /// Called by clients to get the variable list for a compile unit. - /// The variable list will contain all global and static variables - /// that were defined at the compile unit level. + /// Called by clients to get the variable list for a compile unit. The + /// variable list will contain all global and static variables that were + /// defined at the compile unit level. /// /// @param[in] can_create /// If \b true, the variable list will be parsed on demand. If @@ -309,9 +305,8 @@ public: //------------------------------------------------------------------ /// Finds a function by user ID. /// - /// Typically used by SymbolFile plug-ins when partially parsing - /// the debug information to see if the function has been parsed - /// yet. + /// Typically used by SymbolFile plug-ins when partially parsing the debug + /// information to see if the function has been parsed yet. /// /// @param[in] uid /// The user ID of the function to find. This value is supplied @@ -328,10 +323,9 @@ public: //------------------------------------------------------------------ /// Set the line table for the compile unit. /// - /// Called by the SymbolFile plug-in when if first parses the line - /// table and hands ownership of the line table to this object. The - /// compile unit owns the line table object and will delete the - /// object when it is deleted. + /// Called by the SymbolFile plug-in when if first parses the line table and + /// hands ownership of the line table to this object. The compile unit owns + /// the line table object and will delete the object when it is deleted. /// /// @param[in] line_table /// A line table object pointer that this object now owns. @@ -343,9 +337,8 @@ public: //------------------------------------------------------------------ /// Set accessor for the variable list. /// - /// Called by the SymbolFile plug-ins after they have parsed the - /// variable lists and are ready to hand ownership of the list over - /// to this object. + /// Called by the SymbolFile plug-ins after they have parsed the variable + /// lists and are ready to hand ownership of the list over to this object. /// /// @param[in] variable_list_sp /// A shared pointer to a VariableList. @@ -355,9 +348,8 @@ public: //------------------------------------------------------------------ /// Resolve symbol contexts by file and line. /// - /// Given a file in \a file_spec, and a line number, find all - /// instances and append them to the supplied symbol context list - /// \a sc_list. + /// Given a file in \a file_spec, and a line number, find all instances and + /// append them to the supplied symbol context list \a sc_list. /// /// @param[in] file_spec /// A file specification. If \a file_spec contains no directory @@ -405,10 +397,10 @@ public: //------------------------------------------------------------------ /// Get whether compiler optimizations were enabled for this compile unit /// - /// "optimized" means that the debug experience may be difficult - /// for the user to understand. Variables may not be available when - /// the developer would expect them, stepping through the source lines - /// in the function may appear strange, etc. + /// "optimized" means that the debug experience may be difficult for the + /// user to understand. Variables may not be available when the developer + /// would expect them, stepping through the source lines in the function may + /// appear strange, etc. /// /// @return /// Returns 'true' if this compile unit was compiled with diff --git a/include/lldb/Symbol/CompilerType.h b/include/lldb/Symbol/CompilerType.h index 70d56db7fc21b..1170832a7396e 100644 --- a/include/lldb/Symbol/CompilerType.h +++ b/include/lldb/Symbol/CompilerType.h @@ -28,13 +28,12 @@ class DataExtractor; //---------------------------------------------------------------------- // A class that can carry around a clang ASTContext and a opaque clang -// QualType. A clang::QualType can be easily reconstructed from an -// opaque clang type and often the ASTContext is needed when doing -// various type related tasks, so this class allows both items to travel -// in a single very lightweight class that can be used. There are many -// static equivalents of the member functions that allow the ASTContext -// and the opaque clang QualType to be specified for ease of use and -// to avoid code duplication. +// QualType. A clang::QualType can be easily reconstructed from an opaque clang +// type and often the ASTContext is needed when doing various type related +// tasks, so this class allows both items to travel in a single very +// lightweight class that can be used. There are many static equivalents of the +// member functions that allow the ASTContext and the opaque clang QualType to +// be specified for ease of use and to avoid code duplication. //---------------------------------------------------------------------- class CompilerType { public: @@ -206,8 +205,7 @@ public: CompilerType GetFullyUnqualifiedType() const; // 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. + // prototype Returns a value >= 0 if there is a prototype. int GetFunctionArgumentCount() const; CompilerType GetFunctionArgumentTypeAtIndex(size_t idx) const; @@ -220,14 +218,14 @@ public: //---------------------------------------------------------------------- // If this type is a reference to a type (L value or R value reference), - // return a new type with the reference removed, else return the current - // type itself. + // return a new type with the reference removed, else return the current type + // itself. //---------------------------------------------------------------------- CompilerType GetNonReferenceType() const; //---------------------------------------------------------------------- - // If this type is a pointer type, return the type that the pointer - // points to, else return an invalid type. + // If this type is a pointer type, return the type that the pointer points + // to, else return an invalid type. //---------------------------------------------------------------------- CompilerType GetPointeeType() const; @@ -237,44 +235,44 @@ public: CompilerType GetPointerType() const; //---------------------------------------------------------------------- - // Return a new CompilerType that is a L value reference to this type if - // this type is valid and the type system supports L value references, - // else return an invalid type. + // Return a new CompilerType that is a L value reference to this type if this + // type is valid and the type system supports L value references, else return + // an invalid type. //---------------------------------------------------------------------- CompilerType GetLValueReferenceType() const; //---------------------------------------------------------------------- - // Return a new CompilerType that is a R value reference to this type if - // this type is valid and the type system supports R value references, - // else return an invalid type. + // Return a new CompilerType that is a R value reference to this type if this + // type is valid and the type system supports R value references, else return + // an invalid type. //---------------------------------------------------------------------- CompilerType GetRValueReferenceType() const; //---------------------------------------------------------------------- - // Return a new CompilerType adds a const modifier to this type if - // this type is valid and the type system supports const modifiers, - // else return an invalid type. + // Return a new CompilerType adds a const modifier to this type if this type + // is valid and the type system supports const modifiers, else return an + // invalid type. //---------------------------------------------------------------------- CompilerType AddConstModifier() const; //---------------------------------------------------------------------- - // Return a new CompilerType adds a volatile modifier to this type if - // this type is valid and the type system supports volatile modifiers, - // else return an invalid type. + // Return a new CompilerType adds a volatile modifier to this type if this + // type is valid and the type system supports volatile modifiers, else return + // an invalid type. //---------------------------------------------------------------------- CompilerType AddVolatileModifier() const; //---------------------------------------------------------------------- - // Return a new CompilerType adds a restrict modifier to this type if - // this type is valid and the type system supports restrict modifiers, - // else return an invalid type. + // Return a new CompilerType adds a restrict modifier to this type if this + // type is valid and the type system supports restrict modifiers, else return + // an invalid type. //---------------------------------------------------------------------- CompilerType AddRestrictModifier() const; //---------------------------------------------------------------------- - // Create a typedef to this type using "name" as the name of the typedef - // this type is valid and the type system supports typedefs, else return - // an invalid type. + // Create a typedef to this type using "name" as the name of the typedef this + // type is valid and the type system supports typedefs, else return an + // invalid type. //---------------------------------------------------------------------- CompilerType CreateTypedef(const char *name, const CompilerDeclContext &decl_ctx) const; @@ -311,8 +309,8 @@ public: //---------------------------------------------------------------------- // If this type is an enumeration, iterate through all of its enumerators - // using a callback. If the callback returns true, keep iterating, else - // abort the iteration. + // using a callback. If the callback returns true, keep iterating, else abort + // the iteration. //---------------------------------------------------------------------- void ForEachEnumerator( std::function<bool(const CompilerType &integer_type, @@ -351,8 +349,8 @@ public: bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) const; - // Lookup a child given a name. This function will match base class names - // and member member names in "clang_type" only, not descendants. + // 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(const char *name, bool omit_empty_base_classes) const; @@ -385,8 +383,8 @@ public: // Pointers & References //------------------------------------------------------------------ - // Converts "s" to a floating point value and place resulting floating - // point bytes in the "dst" buffer. + // Converts "s" to a floating point value and place resulting floating point + // bytes in the "dst" buffer. size_t ConvertStringToFloatValue(const char *s, uint8_t *dst, size_t dst_size) const; diff --git a/include/lldb/Symbol/DWARFCallFrameInfo.h b/include/lldb/Symbol/DWARFCallFrameInfo.h index a1bd1bc8b1c9a..133c66d4ae4f0 100644 --- a/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -25,12 +25,12 @@ namespace lldb_private { -// DWARFCallFrameInfo is a class which can read eh_frame and DWARF -// Call Frame Information FDEs. It stores little information internally. -// Only two APIs are exported - one to find the high/low pc values -// of a function given a text address via the information in the -// eh_frame / debug_frame, and one to generate an UnwindPlan based -// on the FDE in the eh_frame / debug_frame section. +// DWARFCallFrameInfo is a class which can read eh_frame and DWARF Call Frame +// Information FDEs. It stores little information internally. Only two APIs +// are exported - one to find the high/low pc values of a function given a text +// address via the information in the eh_frame / debug_frame, and one to +// generate an UnwindPlan based on the FDE in the eh_frame / debug_frame +// section. class DWARFCallFrameInfo { public: @@ -40,13 +40,13 @@ public: ~DWARFCallFrameInfo() = default; - // Locate an AddressRange that includes the provided Address in this - // object's eh_frame/debug_info - // Returns true if a range is found to cover that address. + // Locate an AddressRange that includes the provided Address in this object's + // eh_frame/debug_info Returns true if a range is found to cover that + // address. bool GetAddressRange(Address addr, AddressRange &range); - // Return an UnwindPlan based on the call frame information encoded - // in the FDE of this DWARFCallFrameInfo section. + // Return an UnwindPlan based on the call frame information encoded in the + // FDE of this DWARFCallFrameInfo section. bool GetUnwindPlan(Address addr, UnwindPlan &unwind_plan); typedef RangeVector<lldb::addr_t, uint32_t> FunctionAddressAndSizeVector; @@ -55,12 +55,11 @@ public: // Build a vector of file address and size for all functions in this Module // based on the eh_frame FDE entries. // - // The eh_frame information can be a useful source of file address and size of - // the functions in a Module. Often a binary's non-exported symbols are - // stripped - // before shipping so lldb won't know the start addr / size of many functions - // in the Module. But the eh_frame can help to give the addresses of these - // stripped symbols, at least. + // The eh_frame information can be a useful source of file address and size + // of the functions in a Module. Often a binary's non-exported symbols are + // stripped before shipping so lldb won't know the start addr / size of many + // functions in the Module. But the eh_frame can help to give the addresses + // of these stripped symbols, at least. // // @param[out] function_info // A vector provided by the caller is filled out. May be empty if no @@ -112,10 +111,9 @@ private: typedef std::map<dw_offset_t, CIESP> cie_map_t; - // Start address (file address), size, offset of FDE location - // used for finding an FDE for a given File address; the start address field - // is - // an offset into an individual Module. + // Start address (file address), size, offset of FDE location used for + // finding an FDE for a given File address; the start address field is an + // offset into an individual Module. typedef RangeDataVector<lldb::addr_t, uint32_t, dw_offset_t> FDEEntryMap; bool IsEHFrame() const; @@ -133,8 +131,8 @@ private: void GetCFIData(); // Applies the specified DWARF opcode to the given row. This function handle - // the commands - // operates only on a single row (these are the ones what can appear both in + // the commands operates only on a single row (these are the ones what can + // appear both in // CIE and in FDE). // Returns true if the opcode is handled and false otherwise. bool HandleCommonDwarfOpcode(uint8_t primary_opcode, uint8_t extended_opcode, diff --git a/include/lldb/Symbol/DeclVendor.h b/include/lldb/Symbol/DeclVendor.h index f0ce9157cfa5c..d1ccb4191cbc6 100644 --- a/include/lldb/Symbol/DeclVendor.h +++ b/include/lldb/Symbol/DeclVendor.h @@ -20,9 +20,8 @@ namespace lldb_private { //---------------------------------------------------------------------- -// The Decl vendor class is intended as a generic interface to search -// for named declarations that are not necessarily backed by a specific -// symbol file. +// The Decl vendor class is intended as a generic interface to search for named +// declarations that are not necessarily backed by a specific symbol file. //---------------------------------------------------------------------- class DeclVendor { public: diff --git a/include/lldb/Symbol/Declaration.h b/include/lldb/Symbol/Declaration.h index 581176e23961f..b654988bccd28 100644 --- a/include/lldb/Symbol/Declaration.h +++ b/include/lldb/Symbol/Declaration.h @@ -17,13 +17,12 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class Declaration Declaration.h "lldb/Symbol/Declaration.h" -/// @brief A class that describes the declaration location of a +/// A class that describes the declaration location of a /// lldb object. /// -/// The declarations include the file specification, line number, and -/// the column info and can help track where functions, blocks, inlined -/// functions, types, variables, any many other debug core objects were -/// declared. +/// The declarations include the file specification, line number, and the +/// column info and can help track where functions, blocks, inlined functions, +/// types, variables, any many other debug core objects were declared. //---------------------------------------------------------------------- class Declaration { public: @@ -92,8 +91,8 @@ public: //------------------------------------------------------------------ /// Clear the object's state. /// - /// Sets the file specification to be empty, and the line and column - /// to zero. + /// Sets the file specification to be empty, and the line and column to + /// zero. //------------------------------------------------------------------ void Clear() { m_file.Clear(); @@ -106,9 +105,9 @@ public: //------------------------------------------------------------------ /// Compare two declaration objects. /// - /// Compares the two file specifications from \a lhs and \a rhs. If - /// the file specifications are equal, then continue to compare the - /// line number and column numbers respectively. + /// Compares the two file specifications from \a lhs and \a rhs. If the file + /// specifications are equal, then continue to compare the line number and + /// column numbers respectively. /// /// @param[in] lhs /// The Left Hand Side const Declaration object reference. @@ -126,8 +125,8 @@ public: //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// - /// Dump a description of the contents of this object to the - /// supplied stream \a s. + /// Dump a description of the contents of this object to the supplied stream + /// \a s. /// /// @param[in] s /// The stream to which to dump the object description. diff --git a/include/lldb/Symbol/FuncUnwinders.h b/include/lldb/Symbol/FuncUnwinders.h index 27f42cf425b2e..ae8bcc892ce43 100644 --- a/include/lldb/Symbol/FuncUnwinders.h +++ b/include/lldb/Symbol/FuncUnwinders.h @@ -12,8 +12,8 @@ class UnwindTable; class FuncUnwinders { public: - // FuncUnwinders objects are used to track UnwindPlans for a function - // (named or not - really just an address range) + // FuncUnwinders objects are used to track UnwindPlans for a function (named + // or not - really just an address range) // We'll record four different UnwindPlans for each address range: // @@ -28,8 +28,8 @@ public: // available for some reason. // Additionally, FuncUnwinds object can be asked where the prologue - // instructions are finished for migrating breakpoints past the - // stack frame setup instructions when we don't have line table information. + // instructions are finished for migrating breakpoints past the stack frame + // setup instructions when we don't have line table information. FuncUnwinders(lldb_private::UnwindTable &unwind_table, AddressRange range); @@ -38,10 +38,8 @@ public: // current_offset is the byte offset into the function. // 0 means no instructions have executed yet. -1 means the offset is unknown. // On architectures where the pc points to the next instruction that will - // execute, this - // offset value will have already been decremented by 1 to stay within the - // bounds of the - // correct function body. + // execute, this offset value will have already been decremented by 1 to stay + // within the bounds of the correct function body. lldb::UnwindPlanSP GetUnwindPlanAtCallSite(Target &target, int current_offset); @@ -69,24 +67,19 @@ public: // A function may have a Language Specific Data Area specified -- a block of // data in // the object file which is used in the processing of an exception throw / - // catch. - // If any of the UnwindPlans have the address of the LSDA region for this - // function, - // this will return it. + // catch. If any of the UnwindPlans have the address of the LSDA region for + // this function, this will return it. Address GetLSDAAddress(Target &target); // A function may have a Personality Routine associated with it -- used in the // processing of throwing an exception. If any of the UnwindPlans have the - // address of the personality routine, this will return it. Read the - // target-pointer - // at this address to get the personality function address. + // address of the personality routine, this will return it. Read the target- + // pointer at this address to get the personality function address. Address GetPersonalityRoutinePtrAddress(Target &target); // The following methods to retrieve specific unwind plans should rarely be - // used. - // Instead, clients should ask for the *behavior* they are looking for, using - // one - // of the above UnwindPlan retrieval methods. + // used. Instead, clients should ask for the *behavior* they are looking for, + // using one of the above UnwindPlan retrieval methods. lldb::UnwindPlanSP GetAssemblyUnwindPlan(Target &target, Thread &thread, int current_offset); @@ -116,11 +109,11 @@ public: private: lldb::UnwindAssemblySP GetUnwindAssemblyProfiler(Target &target); - // Do a simplistic comparison for the register restore rule for getting - // the caller's pc value on two UnwindPlans -- returns LazyBoolYes if - // they have the same unwind rule for the pc, LazyBoolNo if they do not - // have the same unwind rule for the pc, and LazyBoolCalculate if it was - // unable to determine this for some reason. + // Do a simplistic comparison for the register restore rule for getting the + // caller's pc value on two UnwindPlans -- returns LazyBoolYes if they have + // the same unwind rule for the pc, LazyBoolNo if they do not have the same + // unwind rule for the pc, and LazyBoolCalculate if it was unable to + // determine this for some reason. lldb_private::LazyBool CompareUnwindPlansForIdenticalInitialPCLocation( Thread &thread, const lldb::UnwindPlanSP &a, const lldb::UnwindPlanSP &b); @@ -143,8 +136,8 @@ private: lldb::UnwindPlanSP m_unwind_plan_arch_default_sp; lldb::UnwindPlanSP m_unwind_plan_arch_default_at_func_entry_sp; - // Fetching the UnwindPlans can be expensive - if we've already attempted - // to get one & failed, don't try again. + // Fetching the UnwindPlans can be expensive - if we've already attempted to + // get one & failed, don't try again. bool m_tried_unwind_plan_assembly : 1, m_tried_unwind_plan_eh_frame : 1, m_tried_unwind_plan_debug_frame : 1, m_tried_unwind_plan_eh_frame_augmented : 1, diff --git a/include/lldb/Symbol/Function.h b/include/lldb/Symbol/Function.h index 9d376007a4119..28c6b4857b10a 100644 --- a/include/lldb/Symbol/Function.h +++ b/include/lldb/Symbol/Function.h @@ -21,10 +21,10 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class FunctionInfo Function.h "lldb/Symbol/Function.h" -/// @brief A class that contains generic function information. +/// A class that contains generic function information. /// -/// This provides generic function information that gets reused between -/// inline functions and function types. +/// This provides generic function information that gets reused between inline +/// functions and function types. //---------------------------------------------------------------------- class FunctionInfo { public: @@ -67,8 +67,8 @@ public: //------------------------------------------------------------------ /// Compare two function information objects. /// - /// First compares the method names, and if equal, then compares - /// the declaration information. + /// First compares the method names, and if equal, then compares the + /// declaration information. /// /// @param[in] lhs /// The Left Hand Side const FunctionInfo object reference. @@ -86,8 +86,8 @@ public: //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// - /// Dump a description of the contents of this object to the - /// supplied stream \a s. + /// Dump a description of the contents of this object to the supplied stream + /// \a s. /// /// @param[in] s /// The stream to which to dump the object description. @@ -141,13 +141,13 @@ protected: //---------------------------------------------------------------------- /// @class InlineFunctionInfo Function.h "lldb/Symbol/Function.h" -/// @brief A class that describes information for an inlined function. +/// A class that describes information for an inlined function. //---------------------------------------------------------------------- class InlineFunctionInfo : public FunctionInfo { public: //------------------------------------------------------------------ - /// Construct with the function method name, mangled name, and - /// optional declaration information. + /// Construct with the function method name, mangled name, and optional + /// declaration information. /// /// @param[in] name /// A C string name for the method name for this function. This @@ -171,8 +171,8 @@ public: const Declaration *call_decl_ptr); //------------------------------------------------------------------ - /// Construct with the function method name, mangled name, and - /// optional declaration information. + /// Construct with the function method name, mangled name, and optional + /// declaration information. /// /// @param[in] name /// A name for the method name for this function. This value @@ -202,8 +202,8 @@ public: //------------------------------------------------------------------ /// Compare two inlined function information objects. /// - /// First compares the FunctionInfo objects, and if equal, - /// compares the mangled names. + /// First compares the FunctionInfo objects, and if equal, compares the + /// mangled names. /// /// @param[in] lhs /// The Left Hand Side const InlineFunctionInfo object @@ -223,8 +223,8 @@ public: //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// - /// Dump a description of the contents of this object to the - /// supplied stream \a s. + /// Dump a description of the contents of this object to the supplied stream + /// \a s. /// /// @param[in] s /// The stream to which to dump the object description. @@ -292,17 +292,15 @@ private: //---------------------------------------------------------------------- /// @class Function Function.h "lldb/Symbol/Function.h" -/// @brief A class that describes a function. +/// A class that describes a function. /// -/// Functions belong to CompileUnit objects (Function::m_comp_unit), -/// have unique user IDs (Function::UserID), know how to reconstruct -/// their symbol context (Function::SymbolContextScope), have a -/// specific function type (Function::m_type_uid), have a simple -/// method name (FunctionInfo::m_name), be declared at a specific -/// location (FunctionInfo::m_declaration), possibly have mangled -/// names (Function::m_mangled), an optional return type -/// (Function::m_type), and contains lexical blocks -/// (Function::m_blocks). +/// Functions belong to CompileUnit objects (Function::m_comp_unit), have +/// unique user IDs (Function::UserID), know how to reconstruct their symbol +/// context (Function::SymbolContextScope), have a specific function type +/// (Function::m_type_uid), have a simple method name (FunctionInfo::m_name), +/// be declared at a specific location (FunctionInfo::m_declaration), possibly +/// have mangled names (Function::m_mangled), an optional return type +/// (Function::m_type), and contains lexical blocks (Function::m_blocks). /// /// The function information is split into a few pieces: /// @li The concrete instance information @@ -311,15 +309,14 @@ private: /// The abstract information is found in the function type (Type) that /// describes a function information, return type and parameter types. /// -/// The concrete information is the address range information and -/// specific locations for an instance of this function. +/// The concrete information is the address range information and specific +/// locations for an instance of this function. //---------------------------------------------------------------------- class Function : public UserID, public SymbolContextScope { public: //------------------------------------------------------------------ - /// Construct with a compile unit, function UID, function type UID, - /// optional mangled name, function type, and a section offset - /// based address 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. @@ -352,9 +349,8 @@ 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. + /// 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. @@ -408,10 +404,10 @@ public: lldb::LanguageType GetLanguage() const; //------------------------------------------------------------------ - /// Find the file and line number of the source location of the start - /// of the function. This will use the declaration if present and fall - /// back on the line table if that fails. So there may NOT be a line - /// table entry for this source file/line combo. + /// Find the file and line number of the source location of the start of the + /// function. This will use the declaration if present and fall back on the + /// line table if that fails. So there may NOT be a line table entry for + /// this source file/line combo. /// /// @param[out] source_file /// The source file. @@ -422,8 +418,8 @@ public: void GetStartLineSourceInfo(FileSpec &source_file, uint32_t &line_no); //------------------------------------------------------------------ - /// Find the file and line number of the source location of the end - /// of the function. + /// Find the file and line number of the source location of the end of the + /// function. /// /// /// @param[out] source_file @@ -497,8 +493,8 @@ public: CompilerDeclContext GetDeclContext(); //------------------------------------------------------------------ - /// Get accessor for the type that describes the function - /// return value type, and parameter types. + /// Get accessor for the type that describes the function return value type, + /// and parameter types. /// /// @return /// A type object pointer. @@ -506,8 +502,8 @@ public: Type *GetType(); //------------------------------------------------------------------ - /// Get const accessor for the type that describes the function - /// return value type, and parameter types. + /// Get const accessor for the type that describes the function return value + /// type, and parameter types. /// /// @return /// A const type object pointer. @@ -518,10 +514,8 @@ public: //------------------------------------------------------------------ /// Get the size of the prologue instructions for this function. The - /// "prologue" - /// instructions include any instructions given line number 0 immediately - /// following - /// the prologue end. + /// "prologue" instructions include any instructions given line number 0 + /// immediately following the prologue end. /// /// @return /// The size of the prologue. @@ -531,8 +525,8 @@ public: //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// - /// Dump a description of the contents of this object to the - /// supplied stream \a s. + /// Dump a description of the contents of this object to the supplied stream + /// \a s. /// /// @param[in] s /// The stream to which to dump the object description. @@ -567,10 +561,10 @@ public: /// /// The debug information may provide information about whether this /// function was compiled with optimization or not. In this case, - /// "optimized" means that the debug experience may be difficult - /// for the user to understand. Variables may not be available when - /// the developer would expect them, stepping through the source lines - /// in the function may appear strange, etc. + /// "optimized" means that the debug experience may be difficult for the + /// user to understand. Variables may not be available when the developer + /// would expect them, stepping through the source lines in the function may + /// appear strange, etc. /// /// @return /// Returns 'true' if this function was compiled with @@ -582,10 +576,10 @@ public: //------------------------------------------------------------------ /// Get whether this function represents a 'top-level' function /// - /// The concept of a top-level function is language-specific, mostly - /// meant to represent the notion of scripting-style code that has - /// global visibility of the variables/symbols/functions/... - /// defined within the containing file/module + /// The concept of a top-level function is language-specific, mostly meant + /// to represent the notion of scripting-style code that has global + /// visibility of the variables/symbols/functions/... defined within the + /// containing file/module /// /// If stopped in a top-level function, LLDB will expose global variables /// as-if locals in the 'frame variable' command diff --git a/include/lldb/Symbol/GoASTContext.h b/include/lldb/Symbol/GoASTContext.h index ee111942c2052..29c8cdceacffc 100644 --- a/include/lldb/Symbol/GoASTContext.h +++ b/include/lldb/Symbol/GoASTContext.h @@ -216,8 +216,7 @@ public: 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. + // 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, @@ -294,8 +293,8 @@ public: 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. + // 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; @@ -347,8 +346,8 @@ public: 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. + // 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; diff --git a/include/lldb/Symbol/LineEntry.h b/include/lldb/Symbol/LineEntry.h index b9a1a1442d473..c1ce614609c11 100644 --- a/include/lldb/Symbol/LineEntry.h +++ b/include/lldb/Symbol/LineEntry.h @@ -18,7 +18,7 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h" -/// @brief A line table entry class. +/// A line table entry class. //---------------------------------------------------------------------- struct LineEntry { //------------------------------------------------------------------ @@ -44,8 +44,8 @@ struct LineEntry { //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// - /// Dump a description of the contents of this object to the - /// supplied stream \a s. + /// Dump a description of the contents of this object to the supplied stream + /// \a s. /// /// @param[in] s /// The stream to which to dump the object description. @@ -79,8 +79,8 @@ struct LineEntry { Target *target, bool show_address_only) const; //------------------------------------------------------------------ - /// Dumps information specific to a process that stops at this - /// line entry to the supplied stream \a s. + /// Dumps information specific to a process that stops at this line entry to + /// the supplied stream \a s. /// /// @param[in] s /// The stream to which to dump the object description. @@ -123,25 +123,25 @@ struct LineEntry { static int Compare(const LineEntry &lhs, const LineEntry &rhs); //------------------------------------------------------------------ - /// Give the range for this LineEntry + any additional LineEntries for - /// this same source line that are contiguous. + /// Give the range for this LineEntry + any additional LineEntries for this + /// same source line that are contiguous. /// /// A compiler may emit multiple line entries for a single source line, - /// e.g. to indicate subexpressions at different columns. This method - /// will get the AddressRange for all of the LineEntries for this source - /// line that are contiguous. + /// e.g. to indicate subexpressions at different columns. This method will + /// get the AddressRange for all of the LineEntries for this source line + /// that are contiguous. // - /// Line entries with a line number of 0 are treated specially - these - /// are compiler-generated line table entries that the user did not - /// write in their source code, and we want to skip past in the debugger. - /// If this LineEntry is for line 32, and the following LineEntry is for - /// line 0, we will extend the range to include the AddressRange of the - /// line 0 LineEntry (and it will include the range of the following - /// LineEntries that match either 32 or 0.) + /// Line entries with a line number of 0 are treated specially - these are + /// compiler-generated line table entries that the user did not write in + /// their source code, and we want to skip past in the debugger. If this + /// LineEntry is for line 32, and the following LineEntry is for line 0, we + /// will extend the range to include the AddressRange of the line 0 + /// LineEntry (and it will include the range of the following LineEntries + /// that match either 32 or 0.) /// - /// If the initial LineEntry this method is called on is a line #0, only - /// the range of contiuous LineEntries with line #0 will be included in - /// the complete range. + /// If the initial LineEntry this method is called on is a line #0, only the + /// range of contiuous LineEntries with line #0 will be included in the + /// complete range. /// /// @return /// The contiguous AddressRange for this source line. diff --git a/include/lldb/Symbol/LineTable.h b/include/lldb/Symbol/LineTable.h index a55e797f7b168..fe8be0c557649 100644 --- a/include/lldb/Symbol/LineTable.h +++ b/include/lldb/Symbol/LineTable.h @@ -25,8 +25,8 @@ namespace lldb_private { //---------------------------------------------------------------------- -/// @class LineSequence LineTable.h "lldb/Symbol/LineTable.h" -/// @brief An abstract base class used during symbol table creation. +/// @class LineSequence LineTable.h "lldb/Symbol/LineTable.h" An abstract base +/// class used during symbol table creation. //---------------------------------------------------------------------- class LineSequence { public: @@ -42,7 +42,7 @@ private: //---------------------------------------------------------------------- /// @class LineTable LineTable.h "lldb/Symbol/LineTable.h" -/// @brief A line table class. +/// A line table class. //---------------------------------------------------------------------- class LineTable { public: @@ -111,8 +111,7 @@ public: void GetDescription(Stream *s, Target *target, lldb::DescriptionLevel level); //------------------------------------------------------------------ - /// Find a line entry that contains the section offset address \a - /// so_addr. + /// Find a line entry that contains the section offset address \a so_addr. /// /// @param[in] so_addr /// A section offset address object containing the address we @@ -134,12 +133,12 @@ public: uint32_t *index_ptr = nullptr); //------------------------------------------------------------------ - /// Find a line entry index that has a matching file index and - /// source line number. + /// Find a line entry index that has a matching file index and source line + /// number. /// - /// Finds the next line entry that has a matching \a file_idx and - /// source line number \a line starting at the \a start_idx entries - /// into the line entry collection. + /// Finds the next line entry that has a matching \a file_idx and source + /// line number \a line starting at the \a start_idx entries into the line + /// entry collection. /// /// @param[in] start_idx /// The number of entries to skip when starting the search. @@ -224,8 +223,8 @@ public: bool append); //------------------------------------------------------------------ - /// Given a file range link map, relink the current line table - /// and return a fixed up line table. + /// Given a file range link map, relink the current line table and return a + /// fixed up line table. /// /// @param[out] file_range_map /// A collection of file ranges that maps to new file ranges diff --git a/include/lldb/Symbol/ObjectContainer.h b/include/lldb/Symbol/ObjectContainer.h index 110379234fb57..2138d22808c35 100644 --- a/include/lldb/Symbol/ObjectContainer.h +++ b/include/lldb/Symbol/ObjectContainer.h @@ -25,23 +25,23 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class ObjectContainer ObjectContainer.h "lldb/Symbol/ObjectContainer.h" -/// @brief A plug-in interface definition class for object containers. +/// A plug-in interface definition class for object containers. /// -/// Object containers contain object files from one or more -/// architectures, and also can contain one or more named objects. +/// Object containers contain object files from one or more architectures, and +/// also can contain one or more named objects. /// -/// Typical object containers are static libraries (.a files) that -/// contain multiple named object files, and universal files that contain -/// multiple architectures. +/// Typical object containers are static libraries (.a files) that contain +/// multiple named object files, and universal files that contain multiple +/// architectures. //---------------------------------------------------------------------- class ObjectContainer : public PluginInterface, public ModuleChild { public: //------------------------------------------------------------------ /// Construct with a parent module, offset, and header data. /// - /// Object files belong to modules and a valid module must be - /// supplied upon construction. The at an offset within a file for - /// objects that contain more than one architecture or object. + /// Object files belong to modules and a valid module must be supplied upon + /// construction. The at an offset within a file for objects that contain + /// more than one architecture or object. //------------------------------------------------------------------ ObjectContainer(const lldb::ModuleSP &module_sp, const FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length, @@ -58,18 +58,17 @@ public: //------------------------------------------------------------------ /// Destructor. /// - /// The destructor is virtual since this class is designed to be - /// inherited from by the plug-in instance. + /// The destructor is virtual since this class is designed to be inherited + /// from by the plug-in instance. //------------------------------------------------------------------ ~ObjectContainer() override = default; //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// - /// Dump a description of the current contents of this object - /// to the supplied stream \a s. The dumping should include the - /// section list if it has been parsed, and the symbol table - /// if it has been parsed. + /// Dump a description of the current contents of this object to the + /// supplied stream \a s. The dumping should include the section list if it + /// has been parsed, and the symbol table if it has been parsed. /// /// @param[in] s /// The stream to which to dump the object description. @@ -101,8 +100,8 @@ public: //------------------------------------------------------------------ /// Returns the offset into a file at which this object resides. /// - /// Some files contain many object files, and this function allows - /// access to an object's offset within the file. + /// Some files contain many object files, and this function allows access to + /// an object's offset within the file. /// /// @return /// The offset in bytes into the file. Defaults to zero for @@ -124,10 +123,10 @@ public: //------------------------------------------------------------------ /// Get the number of architectures in this object file. /// - /// The default implementation returns 1 as for object files that - /// contain a single architecture. ObjectContainer instances that - /// contain more than one architecture should override this function - /// and return an appropriate value. + /// The default implementation returns 1 as for object files that contain a + /// single architecture. ObjectContainer instances that contain more than + /// one architecture should override this function and return an appropriate + /// value. /// /// @return /// The number of architectures contained in this object file. @@ -137,11 +136,11 @@ public: //------------------------------------------------------------------ /// Attempts to parse the object header. /// - /// This function is used as a test to see if a given plug-in - /// instance can parse the header data already contained in - /// ObjectContainer::m_data. If an object file parser does not - /// recognize that magic bytes in a header, false should be returned - /// and the next plug-in can attempt to parse an object file. + /// This function is used as a test to see if a given plug-in instance can + /// parse the header data already contained in ObjectContainer::m_data. If + /// an object file parser does not recognize that magic bytes in a header, + /// false should be returned and the next plug-in can attempt to parse an + /// object file. /// /// @return /// Returns \b true if the header was parsed successfully, \b @@ -152,14 +151,14 @@ public: //------------------------------------------------------------------ /// Selects an architecture in an object file. /// - /// Object files that contain a single architecture should verify - /// that the specified \a arch matches the architecture in in - /// object file and return \b true or \b false accordingly. + /// Object files that contain a single architecture should verify that the + /// specified \a arch matches the architecture in in object file and return + /// \b true or \b false accordingly. /// - /// Object files that contain more than one architecture should - /// attempt to select that architecture, and if successful, clear - /// out any previous state from any previously selected architecture - /// and prepare to return information for the new architecture. + /// Object files that contain more than one architecture should attempt to + /// select that architecture, and if successful, clear out any previous + /// state from any previously selected architecture and prepare to return + /// information for the new architecture. /// /// @return /// Returns a pointer to the object file of the requested \a diff --git a/include/lldb/Symbol/ObjectFile.h b/include/lldb/Symbol/ObjectFile.h index dff802522da83..1e9ae8b45417e 100644 --- a/include/lldb/Symbol/ObjectFile.h +++ b/include/lldb/Symbol/ObjectFile.h @@ -20,6 +20,7 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/UUID.h" #include "lldb/lldb-private.h" +#include "llvm/Support/VersionTuple.h" namespace lldb_private { @@ -44,16 +45,15 @@ public: //---------------------------------------------------------------------- /// @class ObjectFile ObjectFile.h "lldb/Symbol/ObjectFile.h" -/// @brief A plug-in interface definition class for object file parsers. +/// A plug-in interface definition class for object file parsers. /// -/// Object files belong to Module objects and know how to extract -/// information from executable, shared library, and object (.o) files -/// used by operating system runtime. The symbol table and section list -/// for an object file. +/// Object files belong to Module objects and know how to extract information +/// from executable, shared library, and object (.o) files used by operating +/// system runtime. The symbol table and section list for an object file. /// -/// Object files can be represented by the entire file, or by part of a -/// file. An example of a partial file ObjectFile is one that contains -/// information for one of multiple architectures in the same file. +/// Object files can be represented by the entire file, or by part of a file. +/// An example of a partial file ObjectFile is one that contains information +/// for one of multiple architectures in the same file. /// /// Once an architecture is selected the object file information can be /// extracted from this abstract class. @@ -88,12 +88,17 @@ public: eStrataJIT } Strata; + struct LoadableData { + lldb::addr_t Dest; + llvm::ArrayRef<uint8_t> Contents; + }; + //------------------------------------------------------------------ /// Construct with a parent module, offset, and header data. /// - /// Object files belong to modules and a valid module must be - /// supplied upon construction. The at an offset within a file for - /// objects that contain more than one architecture or object. + /// Object files belong to modules and a valid module must be supplied upon + /// construction. The at an offset within a file for objects that contain + /// more than one architecture or object. //------------------------------------------------------------------ ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr, lldb::offset_t file_offset, lldb::offset_t length, @@ -105,18 +110,17 @@ public: //------------------------------------------------------------------ /// Destructor. /// - /// The destructor is virtual since this class is designed to be - /// inherited from by the plug-in instance. + /// The destructor is virtual since this class is designed to be inherited + /// from by the plug-in instance. //------------------------------------------------------------------ ~ObjectFile() override; //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// - /// Dump a description of the current contents of this object - /// to the supplied stream \a s. The dumping should include the - /// section list if it has been parsed, and the symbol table - /// if it has been parsed. + /// Dump a description of the current contents of this object to the + /// supplied stream \a s. The dumping should include the section list if it + /// has been parsed, and the symbol table if it has been parsed. /// /// @param[in] s /// The stream to which to dump the object description. @@ -126,9 +130,9 @@ public: //------------------------------------------------------------------ /// Find a ObjectFile plug-in that can parse \a file_spec. /// - /// Scans all loaded plug-in interfaces that implement versions of - /// the ObjectFile plug-in interface and returns the first - /// instance that can parse the file. + /// Scans all loaded plug-in interfaces that implement versions of the + /// ObjectFile plug-in interface and returns the first instance that can + /// parse the file. /// /// @param[in] module /// The parent module that owns this object file. @@ -156,9 +160,9 @@ public: //------------------------------------------------------------------ /// Find a ObjectFile plug-in that can parse a file in memory. /// - /// Scans all loaded plug-in interfaces that implement versions of - /// the ObjectFile plug-in interface and returns the first - /// instance that can parse the file. + /// Scans all loaded plug-in interfaces that implement versions of the + /// ObjectFile plug-in interface and returns the first instance that can + /// parse the file. /// /// @param[in] module /// The parent module that owns this object file. @@ -189,9 +193,9 @@ public: //------------------------------------------------------------------ /// Split a path into a file path with object name. /// - /// For paths like "/tmp/foo.a(bar.o)" we often need to split a path - /// up into the actual path name and into the object name so we can - /// make a valid object file from it. + /// For paths like "/tmp/foo.a(bar.o)" we often need to split a path up into + /// the actual path name and into the object name so we can make a valid + /// object file from it. /// /// @param[in] path_with_object /// A path that might contain an archive path with a .o file @@ -228,29 +232,25 @@ public: //------------------------------------------------------------------ /// Get the address type given a file address in an object file. /// - /// Many binary file formats know what kinds - /// This is primarily for ARM binaries, though it can be applied to - /// any executable file format that supports different opcode types - /// within the same binary. ARM binaries support having both ARM and - /// Thumb within the same executable container. We need to be able - /// to get - /// @return + /// Many binary file formats know what kinds This is primarily for ARM + /// binaries, though it can be applied to any executable file format that + /// supports different opcode types within the same binary. ARM binaries + /// support having both ARM and Thumb within the same executable container. + /// We need to be able to get @return /// The size of an address in bytes for the currently selected /// architecture (and object for archives). Returns zero if no /// architecture or object has been selected. //------------------------------------------------------------------ - virtual lldb::AddressClass GetAddressClass(lldb::addr_t file_addr); + virtual AddressClass GetAddressClass(lldb::addr_t file_addr); //------------------------------------------------------------------ /// Extract the dependent modules from an object file. /// - /// If an object file has information about which other images it - /// depends on (such as shared libraries), this function will - /// provide the list. Since many executables or shared libraries - /// may depend on the same files, - /// FileSpecList::AppendIfUnique(const FileSpec &) should be - /// used to make sure any files that are added are not already in - /// the list. + /// If an object file has information about which other images it depends on + /// (such as shared libraries), this function will provide the list. Since + /// many executables or shared libraries may depend on the same files, + /// FileSpecList::AppendIfUnique(const FileSpec &) should be used to make + /// sure any files that are added are not already in the list. /// /// @param[out] file_list /// A list of file specification objects that gets dependent @@ -275,8 +275,8 @@ public: //------------------------------------------------------------------ /// Returns the offset into a file at which this object resides. /// - /// Some files contain many object files, and this function allows - /// access to an object's offset within the file. + /// Some files contain many object files, and this function allows access to + /// an object's offset within the file. /// /// @return /// The offset in bytes into the file. Defaults to zero for @@ -307,8 +307,8 @@ public: //------------------------------------------------------------------ /// 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. + /// 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. @@ -320,11 +320,11 @@ public: virtual bool GetArchitecture(ArchSpec &arch) = 0; //------------------------------------------------------------------ - /// Gets the section list for the currently selected architecture - /// (and object for archives). + /// Gets the section list for the currently selected architecture (and + /// object for archives). /// - /// Section list parsing can be deferred by ObjectFile instances - /// until this accessor is called the first time. + /// Section list parsing can be deferred by ObjectFile instances until this + /// accessor is called the first time. /// /// @return /// The list of sections contained in this object file. @@ -334,17 +334,17 @@ public: virtual void CreateSections(SectionList &unified_section_list) = 0; //------------------------------------------------------------------ - /// Notify the ObjectFile that the file addresses in the Sections - /// for this module have been changed. + /// Notify the ObjectFile that the file addresses in the Sections for this + /// module have been changed. //------------------------------------------------------------------ virtual void SectionFileAddressesChanged() {} //------------------------------------------------------------------ - /// Gets the symbol table for the currently selected architecture - /// (and object for archives). + /// Gets the symbol table for the currently selected architecture (and + /// object for archives). /// - /// Symbol table parsing can be deferred by ObjectFile instances - /// until this accessor is called the first time. + /// Symbol table parsing can be deferred by ObjectFile instances until this + /// accessor is called the first time. /// /// @return /// The symbol table for this object file. @@ -360,11 +360,11 @@ public: //------------------------------------------------------------------ /// Appends a Symbol for the specified so_addr to the symbol table. /// - /// If verify_unique is false, the symbol table is not searched - /// to determine if a Symbol found at this address has already been - /// added to the symbol table. When verify_unique is true, this - /// method resolves the Symbol as the first match in the SymbolTable - /// and appends a Symbol only if required/found. + /// If verify_unique is false, the symbol table is not searched to determine + /// if a Symbol found at this address has already been added to the symbol + /// table. When verify_unique is true, this method resolves the Symbol as + /// the first match in the SymbolTable and appends a Symbol only if + /// required/found. /// /// @return /// The resolved symbol or nullptr. Returns nullptr if a @@ -372,13 +372,13 @@ public: //------------------------------------------------------------------ virtual Symbol *ResolveSymbolForAddress(const Address &so_addr, bool verify_unique) { - // Typically overridden to lazily add stripped symbols recoverable from - // the exception handling unwind information (i.e. without parsing - // the entire eh_frame section. + // Typically overridden to lazily add stripped symbols recoverable from the + // exception handling unwind information (i.e. without parsing the entire + // eh_frame section. // - // The availability of LC_FUNCTION_STARTS allows ObjectFileMachO - // to efficiently add stripped symbols when the symbol table is - // first constructed. Poorer cousins are PECoff and ELF. + // The availability of LC_FUNCTION_STARTS allows ObjectFileMachO to + // efficiently add stripped symbols when the symbol table is first + // constructed. Poorer cousins are PECoff and ELF. return nullptr; } @@ -410,10 +410,9 @@ public: //------------------------------------------------------------------ /// Gets the UUID for this object file. /// - /// If the object file format contains a UUID, the value should be - /// returned. Else ObjectFile instances should return the MD5 - /// checksum of all of the bytes for the object file (or memory for - /// memory based object files). + /// If the object file format contains a UUID, the value should be returned. + /// Else ObjectFile instances should return the MD5 checksum of all of the + /// bytes for the object file (or memory for memory based object files). /// /// @return /// Returns \b true if a UUID was successfully extracted into @@ -424,8 +423,8 @@ public: //------------------------------------------------------------------ /// Gets the symbol file spec list for this object file. /// - /// If the object file format contains a debug symbol file link, - /// the values will be returned in the FileSpecList. + /// If the object file format contains a debug symbol file link, the values + /// will be returned in the FileSpecList. /// /// @return /// Returns filespeclist. @@ -438,8 +437,8 @@ public: /// Gets the file spec list of libraries re-exported by this object file. /// /// If the object file format has the notion of one library re-exporting the - /// symbols from another, - /// the re-exported libraries will be returned in the FileSpecList. + /// symbols from another, the re-exported libraries will be returned in the + /// FileSpecList. /// /// @return /// Returns filespeclist. @@ -449,8 +448,8 @@ public: } //------------------------------------------------------------------ - /// Sets the load address for an entire module, assuming a rigid - /// slide of sections, if possible in the implementation. + /// Sets the load address for an entire module, assuming a rigid slide of + /// sections, if possible in the implementation. /// /// @return /// Returns true iff any section's load address changed. @@ -461,8 +460,8 @@ public: } //------------------------------------------------------------------ - /// Gets whether endian swapping should occur when extracting data - /// from this object file. + /// Gets whether endian swapping should occur when extracting data from this + /// object file. /// /// @return /// Returns \b true if endian swapping is needed, \b false @@ -473,11 +472,11 @@ public: //------------------------------------------------------------------ /// Attempts to parse the object header. /// - /// This function is used as a test to see if a given plug-in - /// instance can parse the header data already contained in - /// ObjectFile::m_data. If an object file parser does not - /// recognize that magic bytes in a header, false should be returned - /// and the next plug-in can attempt to parse an object file. + /// This function is used as a test to see if a given plug-in instance can + /// parse the header data already contained in ObjectFile::m_data. If an + /// object file parser does not recognize that magic bytes in a header, + /// false should be returned and the next plug-in can attempt to parse an + /// object file. /// /// @return /// Returns \b true if the header was parsed successfully, \b @@ -488,11 +487,11 @@ public: //------------------------------------------------------------------ /// Returns a reference to the UnwindTable for this ObjectFile /// - /// The UnwindTable contains FuncUnwinders objects for any function in - /// this ObjectFile. If a FuncUnwinders object hasn't been created yet - /// (i.e. the function has yet to be unwound in a stack walk), it - /// will be created when requested. Specifically, we do not create - /// FuncUnwinders objects for functions until they are needed. + /// The UnwindTable contains FuncUnwinders objects for any function in this + /// ObjectFile. If a FuncUnwinders object hasn't been created yet (i.e. the + /// function has yet to be unwound in a stack walk), it will be created when + /// requested. Specifically, we do not create FuncUnwinders objects for + /// functions until they are needed. /// /// @return /// Returns the unwind table for this object file. @@ -500,21 +499,21 @@ public: virtual lldb_private::UnwindTable &GetUnwindTable() { return m_unwind_table; } //------------------------------------------------------------------ - /// Returns if the function bounds for symbols in this symbol file - /// are likely accurate. + /// Returns if the function bounds for symbols in this symbol file are + /// likely accurate. /// /// The unwinder can emulate the instructions of functions to understand - /// prologue/epilogue code sequences, where registers are spilled on - /// the stack, etc. This feature relies on having the correct start - /// addresses of all functions. If the ObjectFile has a way to tell - /// that symbols have been stripped and there's no way to reconstruct - /// start addresses (e.g. LC_FUNCTION_STARTS on Mach-O, or eh_frame - /// unwind info), the ObjectFile should indicate that assembly emulation - /// should not be used for this module. + /// prologue/epilogue code sequences, where registers are spilled on the + /// stack, etc. This feature relies on having the correct start addresses + /// of all functions. If the ObjectFile has a way to tell that symbols have + /// been stripped and there's no way to reconstruct start addresses (e.g. + /// LC_FUNCTION_STARTS on Mach-O, or eh_frame unwind info), the ObjectFile + /// should indicate that assembly emulation should not be used for this + /// module. /// - /// It is uncommon for this to return false. An ObjectFile needs to - /// be sure that symbol start addresses are unavailable before false - /// is returned. If it is unclear, this should return true. + /// It is uncommon for this to return false. An ObjectFile needs to be sure + /// that symbol start addresses are unavailable before false is returned. + /// If it is unclear, this should return true. /// /// @return /// Returns true if assembly emulation should be used for this @@ -542,9 +541,9 @@ public: } //------------------------------------------------------------------ - /// Returns the address of the Entry Point in this object file - if - /// the object file doesn't have an entry point (because it is not an - /// executable file) then an invalid address is returned. + /// Returns the address of the Entry Point in this object file - if the + /// object file doesn't have an entry point (because it is not an executable + /// file) then an invalid address is returned. /// /// @return /// Returns the entry address for this module. @@ -552,14 +551,13 @@ public: virtual lldb_private::Address GetEntryPointAddress() { return Address(); } //------------------------------------------------------------------ - /// Returns the address that represents the header of this object - /// file. + /// Returns the address that represents the header 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. + /// 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. @@ -571,9 +569,9 @@ public: virtual uint32_t GetNumThreadContexts() { return 0; } //------------------------------------------------------------------ - /// Some object files may have an identifier string embedded in them, - /// e.g. in a Mach-O core file using the LC_IDENT load command (which - /// is obsolete, but can still be found in some old files) + /// Some object files may have an identifier string embedded in them, e.g. + /// in a Mach-O core file using the LC_IDENT load command (which is + /// obsolete, but can still be found in some old files) /// /// @return /// Returns the identifier string if one exists, else an empty @@ -584,11 +582,11 @@ public: } //------------------------------------------------------------------ - /// When the ObjectFile is a core file, lldb needs to locate the - /// "binary" in the core file. lldb can iterate over the pages looking - /// for a valid binary, but some core files may have metadata - /// describing where the main binary is exactly which removes ambiguity - /// when there are multiple binaries present in the captured memory pages. + /// When the ObjectFile is a core file, lldb needs to locate the "binary" in + /// the core file. lldb can iterate over the pages looking for a valid + /// binary, but some core files may have metadata describing where the main + /// binary is exactly which removes ambiguity when there are multiple + /// binaries present in the captured memory pages. /// /// @param[out] address /// If the address of the binary is specified, this will be set. @@ -615,13 +613,12 @@ public: } //------------------------------------------------------------------ - /// The object file should be able to calculate its type by looking - /// at its file header and possibly the sections or other data in - /// the object file. The file type is used in the debugger to help - /// select the correct plug-ins for the job at hand, so this is - /// important to get right. If any eTypeXXX definitions do not match - /// up with the type of file you are loading, please feel free to - /// add a new enumeration value. + /// The object file should be able to calculate its type by looking at its + /// file header and possibly the sections or other data in the object file. + /// The file type is used in the debugger to help select the correct plug- + /// ins for the job at hand, so this is important to get right. If any + /// eTypeXXX definitions do not match up with the type of file you are + /// loading, please feel free to add a new enumeration value. /// /// @return /// The calculated file type for the current object file. @@ -629,20 +626,19 @@ public: virtual Type CalculateType() = 0; //------------------------------------------------------------------ - /// In cases where the type can't be calculated (elf files), this - /// routine allows someone to explicitly set it. As an example, - /// SymbolVendorELF uses this routine to set eTypeDebugInfo when - /// loading debug link files. + /// In cases where the type can't be calculated (elf files), this routine + /// allows someone to explicitly set it. As an example, SymbolVendorELF uses + /// this routine to set eTypeDebugInfo when loading debug link files. virtual void SetType(Type type) { m_type = type; } //------------------------------------------------------------------ - /// The object file should be able to calculate the strata of the - /// object file. + /// The object file should be able to calculate the strata of the object + /// file. /// - /// Many object files for platforms might be for either user space - /// debugging or for kernel debugging. If your object file subclass - /// can figure this out, it will help with debugger plug-in selection - /// when it comes time to debug. + /// Many object files for platforms might be for either user space debugging + /// or for kernel debugging. If your object file subclass can figure this + /// out, it will help with debugger plug-in selection when it comes time to + /// debug. /// /// @return /// The calculated object file strata for the current object @@ -653,96 +649,31 @@ public: //------------------------------------------------------------------ /// Get the object file version numbers. /// - /// Many object files have a set of version numbers that describe - /// the version of the executable or shared library. Typically there - /// are major, minor and build, but there may be more. This function - /// will extract the versions from object files if they are available. - /// - /// If \a versions is NULL, or if \a num_versions is 0, the return - /// value will indicate how many version numbers are available in - /// this object file. Then a subsequent call can be made to this - /// function with a value of \a versions and \a num_versions that - /// has enough storage to store some or all version numbers. - /// - /// @param[out] versions - /// A pointer to an array of uint32_t types that is \a num_versions - /// long. If this value is NULL, the return value will indicate - /// how many version numbers are required for a subsequent call - /// to this function so that all versions can be retrieved. If - /// the value is non-NULL, then at most \a num_versions of the - /// existing versions numbers will be filled into \a versions. - /// If there is no version information available, \a versions - /// will be filled with \a num_versions UINT32_MAX values - /// and zero will be returned. - /// - /// @param[in] num_versions - /// The maximum number of entries to fill into \a versions. If - /// this value is zero, then the return value will indicate - /// how many version numbers there are in total so another call - /// to this function can be make with adequate storage in - /// \a versions to get all of the version numbers. If \a - /// num_versions is less than the actual number of version - /// numbers in this object file, only \a num_versions will be - /// filled into \a versions (if \a versions is non-NULL). + /// Many object files have a set of version numbers that describe the + /// version of the executable or shared library. Typically there are major, + /// minor and build, but there may be more. This function will extract the + /// versions from object files if they are available. /// /// @return - /// This function always returns the number of version numbers - /// that this object file has regardless of the number of - /// version numbers that were copied into \a versions. + /// This function returns extracted version numbers as a + /// llvm::VersionTuple. In case of error an empty VersionTuple is + /// returned. //------------------------------------------------------------------ - virtual uint32_t GetVersion(uint32_t *versions, uint32_t num_versions) { - if (versions && num_versions) { - for (uint32_t i = 0; i < num_versions; ++i) - versions[i] = UINT32_MAX; - } - return 0; - } + virtual llvm::VersionTuple GetVersion() { return llvm::VersionTuple(); } //------------------------------------------------------------------ /// Get the minimum OS version this object file can run on. /// - /// Some object files have information that specifies the minimum OS - /// version that they can be used on. - /// - /// If \a versions is NULL, or if \a num_versions is 0, the return - /// value will indicate how many version numbers are available in - /// this object file. Then a subsequent call can be made to this - /// function with a value of \a versions and \a num_versions that - /// has enough storage to store some or all version numbers. - /// - /// @param[out] versions - /// A pointer to an array of uint32_t types that is \a num_versions - /// long. If this value is NULL, the return value will indicate - /// how many version numbers are required for a subsequent call - /// to this function so that all versions can be retrieved. If - /// the value is non-NULL, then at most \a num_versions of the - /// existing versions numbers will be filled into \a versions. - /// If there is no version information available, \a versions - /// will be filled with \a num_versions UINT32_MAX values - /// and zero will be returned. - /// - /// @param[in] num_versions - /// The maximum number of entries to fill into \a versions. If - /// this value is zero, then the return value will indicate - /// how many version numbers there are in total so another call - /// to this function can be make with adequate storage in - /// \a versions to get all of the version numbers. If \a - /// num_versions is less than the actual number of version - /// numbers in this object file, only \a num_versions will be - /// filled into \a versions (if \a versions is non-NULL). + /// Some object files have information that specifies the minimum OS version + /// that they can be used on. /// /// @return - /// This function always returns the number of version numbers - /// that this object file has regardless of the number of - /// version numbers that were copied into \a versions. + /// This function returns extracted version numbers as a + /// llvm::VersionTuple. In case of error an empty VersionTuple is + /// returned. //------------------------------------------------------------------ - virtual uint32_t GetMinimumOSVersion(uint32_t *versions, - uint32_t num_versions) { - if (versions && num_versions) { - for (uint32_t i = 0; i < num_versions; ++i) - versions[i] = UINT32_MAX; - } - return 0; + virtual llvm::VersionTuple GetMinimumOSVersion() { + return llvm::VersionTuple(); } //------------------------------------------------------------------ @@ -762,12 +693,11 @@ public: //------------------------------------------------------------------ /// Return true if this file is a dynamic link editor (dyld) /// - /// Often times dyld has symbols that mirror symbols in libc and - /// other shared libraries (like "malloc" and "free") and the user - /// does _not_ want to stop in these shared libraries by default. - /// We can ask the ObjectFile if it is such a file and should be - /// avoided for things like settings breakpoints and doing function - /// lookups for expressions. + /// Often times dyld has symbols that mirror symbols in libc and other + /// shared libraries (like "malloc" and "free") and the user does _not_ want + /// to stop in these shared libraries by default. We can ask the ObjectFile + /// if it is such a file and should be avoided for things like settings + /// breakpoints and doing function lookups for expressions. //------------------------------------------------------------------ virtual bool GetIsDynamicLinkEditor() { return false; } @@ -786,10 +716,9 @@ public: return m_strata; } - // When an object file is in memory, subclasses should try and lock - // the process weak pointer. If the process weak pointer produces a - // valid ProcessSP, then subclasses can call this function to read - // memory. + // When an object file is in memory, subclasses should try and lock the + // process weak pointer. If the process weak pointer produces a valid + // ProcessSP, then subclasses can call this function to read memory. static lldb::DataBufferSP ReadMemory(const lldb::ProcessSP &process_sp, lldb::addr_t addr, size_t byte_size); @@ -809,8 +738,8 @@ public: size_t dst_len); // This function will transparently decompress section data if the section if - // compressed. Note that for compressed section the resulting data size may be - // larger than what Section::GetFileSize reports. + // compressed. Note that for compressed section the resulting data size may + // be larger than what Section::GetFileSize reports. virtual size_t ReadSectionData(Section *section, DataExtractor §ion_data); @@ -829,16 +758,16 @@ public: //------------------------------------------------------------------ /// Loads this objfile to memory. /// - /// Loads the bits needed to create an executable image to the memory. - /// It is useful with bare-metal targets where target does not have the - /// ability to start a process itself. + /// Loads the bits needed to create an executable image to the memory. It is + /// useful with bare-metal targets where target does not have the ability to + /// start a process itself. /// /// @param[in] target /// Target where to load. /// /// @return //------------------------------------------------------------------ - virtual Status LoadInMemory(Target &target, bool set_pc); + virtual std::vector<LoadableData> GetLoadableData(Target &target); protected: //------------------------------------------------------------------ @@ -864,9 +793,9 @@ protected: uint32_t m_synthetic_symbol_idx; //------------------------------------------------------------------ - /// Sets the architecture for a module. At present the architecture - /// can only be set if it is invalid. It is not allowed to switch from - /// one concrete architecture to another. + /// Sets the architecture for a module. At present the architecture can + /// only be set if it is invalid. It is not allowed to switch from one + /// concrete architecture to another. /// /// @param[in] new_arch /// The architecture this module will be set to. diff --git a/include/lldb/Symbol/Symbol.h b/include/lldb/Symbol/Symbol.h index 44c67f6f47164..9523158e0780d 100644 --- a/include/lldb/Symbol/Symbol.h +++ b/include/lldb/Symbol/Symbol.h @@ -20,11 +20,9 @@ namespace lldb_private { class Symbol : public SymbolContextScope { public: - // ObjectFile readers can classify their symbol table entries and searches can - // be made - // on specific types where the symbol values will have drastically different - // meanings - // and sorting requirements. + // ObjectFile readers can classify their symbol table entries and searches + // can be made on specific types where the symbol values will have + // drastically different meanings and sorting requirements. Symbol(); Symbol(uint32_t symID, const char *name, bool name_is_mangled, @@ -52,56 +50,53 @@ public: bool ValueIsAddress() const; //------------------------------------------------------------------ - // The GetAddressRef() accessor functions should only be called if - // you previously call ValueIsAddress() otherwise you might get an - // reference to an Address object that contains an constant integer - // value in m_addr_range.m_base_addr.m_offset which could be - // incorrectly used to represent an absolute address since it has - // no section. + // The GetAddressRef() accessor functions should only be called if you + // previously call ValueIsAddress() otherwise you might get an reference to + // an Address object that contains an constant integer value in + // m_addr_range.m_base_addr.m_offset which could be incorrectly used to + // represent an absolute address since it has no section. //------------------------------------------------------------------ Address &GetAddressRef() { return m_addr_range.GetBaseAddress(); } const Address &GetAddressRef() const { return m_addr_range.GetBaseAddress(); } //------------------------------------------------------------------ - // Makes sure the symbol's value is an address and returns the file - // address. Returns LLDB_INVALID_ADDRESS if the symbol's value isn't - // an address. + // Makes sure the symbol's value is an address and returns the file address. + // Returns LLDB_INVALID_ADDRESS if the symbol's value isn't an address. //------------------------------------------------------------------ lldb::addr_t GetFileAddress() const; //------------------------------------------------------------------ - // Makes sure the symbol's value is an address and gets the load - // address using \a target if it is. Returns LLDB_INVALID_ADDRESS - // if the symbol's value isn't an address or if the section isn't - // loaded in \a target. + // Makes sure the symbol's value is an address and gets the load address + // using \a target if it is. Returns LLDB_INVALID_ADDRESS if the symbol's + // value isn't an address or if the section isn't loaded in \a target. //------------------------------------------------------------------ lldb::addr_t GetLoadAddress(Target *target) const; //------------------------------------------------------------------ - // Access the address value. Do NOT hand out the AddressRange as an - // object as the byte size of the address range may not be filled in - // and it should be accessed via GetByteSize(). + // Access the address value. Do NOT hand out the AddressRange as an object as + // the byte size of the address range may not be filled in and it should be + // accessed via GetByteSize(). //------------------------------------------------------------------ Address GetAddress() const { - // Make sure the our value is an address before we hand a copy out. - // We use the Address inside m_addr_range to contain the value for - // symbols that are not address based symbols so we are using it - // for more than just addresses. For example undefined symbols on - // MacOSX have a nlist.n_value of 0 (zero) and this will get placed - // into m_addr_range.m_base_addr.m_offset and it will have no section. - // So in the GetAddress() accessor, we need to hand out an invalid - // address if the symbol's value isn't an address. + // Make sure the our value is an address before we hand a copy out. We use + // the Address inside m_addr_range to contain the value for symbols that + // are not address based symbols so we are using it for more than just + // addresses. For example undefined symbols on MacOSX have a nlist.n_value + // of 0 (zero) and this will get placed into + // m_addr_range.m_base_addr.m_offset and it will have no section. So in the + // GetAddress() accessor, we need to hand out an invalid address if the + // symbol's value isn't an address. if (ValueIsAddress()) return m_addr_range.GetBaseAddress(); else return Address(); } - // When a symbol's value isn't an address, we need to access the raw - // value. This function will ensure this symbol's value isn't an address - // and return the integer value if this checks out, otherwise it will - // return "fail_value" if the symbol is an address value. + // When a symbol's value isn't an address, we need to access the raw value. + // This function will ensure this symbol's value isn't an address and return + // the integer value if this checks out, otherwise it will return + // "fail_value" if the symbol is an address value. uint64_t GetIntegerValue(uint64_t fail_value = 0) const { if (ValueIsAddress()) { // This symbol's value is an address. Use Symbol::GetAddress() to get the @@ -238,9 +233,8 @@ public: protected: // This is the internal guts of ResolveReExportedSymbol, it assumes - // reexport_name is not null, and that module_spec - // is valid. We track the modules we've already seen to make sure we don't - // get caught in a cycle. + // reexport_name is not null, and that module_spec is valid. We track the + // modules we've already seen to make sure we don't get caught in a cycle. Symbol *ResolveReExportedSymbolInModuleSpec( Target &target, ConstString &reexport_name, @@ -260,8 +254,8 @@ protected: m_size_is_sibling : 1, // m_size contains the index of this symbol's // sibling m_size_is_synthesized : 1, // non-zero if this symbol's size was - // calculated using a delta between this symbol - // and the next + // calculated using a delta between this + // symbol and the next m_size_is_valid : 1, m_demangled_is_synthesized : 1, // The demangled name was created should // not be used for expressions or other diff --git a/include/lldb/Symbol/SymbolContext.h b/include/lldb/Symbol/SymbolContext.h index f84b7cf916fe5..0ec0006f193a7 100644 --- a/include/lldb/Symbol/SymbolContext.h +++ b/include/lldb/Symbol/SymbolContext.h @@ -29,14 +29,12 @@ namespace lldb_private { class SymbolContextScope; //---------------------------------------------------------------------- -/// @class SymbolContext SymbolContext.h "lldb/Symbol/SymbolContext.h" -/// @brief Defines a symbol context baton that can be handed other debug -/// core functions. +/// @class SymbolContext SymbolContext.h "lldb/Symbol/SymbolContext.h" Defines +/// a symbol context baton that can be handed other debug core functions. /// -/// Many debugger functions require a context when doing lookups. This -/// class provides a common structure that can be used as the result -/// of a query that can contain a single result. Examples of such -/// queries include +/// Many debugger functions require a context when doing lookups. This class +/// provides a common structure that can be used as the result of a query that +/// can contain a single result. Examples of such queries include /// @li Looking up a load address. //---------------------------------------------------------------------- class SymbolContext { @@ -44,14 +42,14 @@ public: //------------------------------------------------------------------ /// Default constructor. /// - /// Initialize all pointer members to nullptr and all struct members - /// to their default state. + /// Initialize all pointer members to nullptr and all struct members to + /// their default state. //------------------------------------------------------------------ SymbolContext(); //------------------------------------------------------------------ - /// Construct with an object that knows how to reconstruct its - /// symbol context. + /// Construct with an object that knows how to reconstruct its symbol + /// context. /// /// @param[in] sc_scope /// A symbol context scope object that knows how to reconstruct @@ -60,8 +58,8 @@ public: explicit SymbolContext(SymbolContextScope *sc_scope); //------------------------------------------------------------------ - /// Construct with module, and optional compile unit, function, - /// block, line table, line entry and symbol. + /// Construct with module, and optional compile unit, function, block, line + /// table, line entry and symbol. /// /// Initialize all pointer to the specified values. /// @@ -112,8 +110,8 @@ public: //------------------------------------------------------------------ /// Assignment operator. /// - /// Copies the address value from another SymbolContext object \a - /// rhs into \a this object. + /// Copies the address value from another SymbolContext object \a rhs into + /// \a this object. /// /// @param[in] rhs /// A const SymbolContext object reference to copy. @@ -126,16 +124,16 @@ public: //------------------------------------------------------------------ /// Clear the object's state. /// - /// Resets all pointer members to nullptr, and clears any class objects - /// to their default state. + /// Resets all pointer members to nullptr, and clears any class objects to + /// their default state. //------------------------------------------------------------------ void Clear(bool clear_target); //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// - /// Dump a description of the contents of this object to the - /// supplied stream \a s. + /// Dump a description of the contents of this object to the supplied stream + /// \a s. /// /// @param[in] s /// The stream to which to dump the object description. @@ -145,13 +143,12 @@ public: //------------------------------------------------------------------ /// Dump the stop context in this object to a Stream. /// - /// Dump the best description of this object to the stream. The - /// information displayed depends on the amount and quality of the - /// information in this context. If a module, function, file and - /// line number are available, they will be dumped. If only a - /// module and function or symbol name with offset is available, - /// that will be output. Else just the address at which the target - /// was stopped will be displayed. + /// Dump the best description of this object to the stream. The information + /// displayed depends on the amount and quality of the information in this + /// context. If a module, function, file and line number are available, they + /// will be dumped. If only a module and function or symbol name with offset + /// is available, that will be output. Else just the address at which the + /// target was stopped will be displayed. /// /// @param[in] s /// The stream to which to dump the object description. @@ -267,21 +264,21 @@ public: lldb::LanguageType GetLanguage() const; //------------------------------------------------------------------ - /// Find a block that defines the function represented by this - /// symbol context. + /// Find a block that defines the function represented by this symbol + /// context. /// - /// If this symbol context points to a block that is an inlined - /// function, or is contained within an inlined function, the block - /// that defines the inlined function is returned. + /// If this symbol context points to a block that is an inlined function, or + /// is contained within an inlined function, the block that defines the + /// inlined function is returned. /// - /// If this symbol context has no block in it, or the block is not - /// itself an inlined function block or contained within one, we - /// return the top level function block. + /// If this symbol context has no block in it, or the block is not itself an + /// inlined function block or contained within one, we return the top level + /// function block. /// - /// This is a handy function to call when you want to get the block - /// whose variable list will include the arguments for the function - /// that is represented by this symbol context (whether the function - /// is an inline function or not). + /// This is a handy function to call when you want to get the block whose + /// variable list will include the arguments for the function that is + /// represented by this symbol context (whether the function is an inline + /// function or not). /// /// @return /// The block object pointer that defines the function that is @@ -290,8 +287,8 @@ public: Block *GetFunctionBlock(); //------------------------------------------------------------------ - /// If this symbol context represents a function that is a method, - /// return true and provide information about the method. + /// If this symbol context represents a function that is a method, return + /// true and provide information about the method. /// /// @param[out] language /// If \b true is returned, the language for the method. @@ -313,8 +310,7 @@ public: ConstString &language_object_name); //------------------------------------------------------------------ - /// Sorts the types in TypeMap according to SymbolContext - /// to TypeList + /// Sorts the types in TypeMap according to SymbolContext to TypeList /// //------------------------------------------------------------------ void SortTypeList(TypeMap &type_map, TypeList &type_list) const; @@ -322,8 +318,8 @@ public: //------------------------------------------------------------------ /// Find a name of the innermost function for the symbol context. /// - /// For instance, if the symbol context contains an inlined block, - /// it will return the inlined function name. + /// For instance, if the symbol context contains an inlined block, it will + /// return the inlined function name. /// /// @param[in] prefer_mangled /// if \btrue, then the mangled name will be returned if there @@ -339,14 +335,13 @@ public: //------------------------------------------------------------------ /// Get the line entry that corresponds to the function. /// - /// If the symbol context contains an inlined block, the line entry - /// for the start address of the inlined function will be returned, - /// otherwise the line entry for the start address of the function - /// will be returned. This can be used after doing a - /// Module::FindFunctions(...) or ModuleList::FindFunctions(...) - /// call in order to get the correct line table information for - /// the symbol context. - /// it will return the inlined function name. + /// If the symbol context contains an inlined block, the line entry for the + /// start address of the inlined function will be returned, otherwise the + /// line entry for the start address of the function will be returned. This + /// can be used after doing a Module::FindFunctions(...) or + /// ModuleList::FindFunctions(...) call in order to get the correct line + /// table information for the symbol context. it will return the inlined + /// function name. /// /// @param[in] prefer_mangled /// if \btrue, then the mangled name will be returned if there @@ -361,8 +356,8 @@ public: //------------------------------------------------------------------ /// Find the block containing the inlined block that contains this block. /// - /// For instance, if the symbol context contains an inlined block, - /// it will return the inlined function name. + /// For instance, if the symbol context contains an inlined block, it will + /// return the inlined function name. /// /// @param[in] curr_frame_pc /// The address within the block of this object. @@ -440,11 +435,11 @@ private: //---------------------------------------------------------------------- /// @class SymbolContextList SymbolContext.h "lldb/Symbol/SymbolContext.h" -/// @brief Defines a list of symbol context objects. +/// Defines a list of symbol context objects. /// -/// This class provides a common structure that can be used to contain -/// the result of a query that can contain a multiple results. Examples -/// of such queries include: +/// This class provides a common structure that can be used to contain the +/// result of a query that can contain a multiple results. Examples of such +/// queries include: /// @li Looking up a function by name. /// @li Finding all addresses for a specified file and line number. //---------------------------------------------------------------------- @@ -491,8 +486,8 @@ public: //------------------------------------------------------------------ /// Dump a description of this object to a Stream. /// - /// Dump a description of the contents of each symbol context in - /// the list to the supplied stream \a s. + /// Dump a description of the contents of each symbol context in the list to + /// the supplied stream \a s. /// /// @param[in] s /// The stream to which to dump the object description. @@ -502,8 +497,8 @@ public: //------------------------------------------------------------------ /// Get accessor for a symbol context at index \a idx. /// - /// Dump a description of the contents of each symbol context in - /// the list to the supplied stream \a s. + /// Dump a description of the contents of each symbol context in the list to + /// the supplied stream \a s. /// /// @param[in] idx /// The zero based index into the symbol context list. @@ -521,8 +516,8 @@ public: //------------------------------------------------------------------ /// Direct reference accessor for a symbol context at index \a idx. /// - /// The index \a idx must be a valid index, no error checking will - /// be done to ensure that it is valid. + /// The index \a idx must be a valid index, no error checking will be done + /// to ensure that it is valid. /// /// @param[in] idx /// The zero based index into the symbol context list. diff --git a/include/lldb/Symbol/SymbolContextScope.h b/include/lldb/Symbol/SymbolContextScope.h index 926e34bc03a21..c2fbb5272fc04 100644 --- a/include/lldb/Symbol/SymbolContextScope.h +++ b/include/lldb/Symbol/SymbolContextScope.h @@ -20,16 +20,15 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class SymbolContextScope SymbolContextScope.h -/// "lldb/Symbol/SymbolContextScope.h" -/// @brief Inherit from this if your object is part of a symbol context +/// "lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is +/// part of a symbol context /// and can reconstruct its symbol context. /// -/// Many objects that are part of a symbol context that have pointers -/// back to parent objects that own them. Any members of a symbol -/// context that, once they are built, will not go away, can inherit -/// from this pure virtual class and can then reconstruct their symbol -/// context without having to keep a complete SymbolContext object in -/// the object. +/// Many objects that are part of a symbol context that have pointers back to +/// parent objects that own them. Any members of a symbol context that, once +/// they are built, will not go away, can inherit from this pure virtual class +/// and can then reconstruct their symbol context without having to keep a +/// complete SymbolContext object in the object. /// /// Examples of these objects include: /// @li Module @@ -38,14 +37,14 @@ namespace lldb_private { /// @li Block /// @li Symbol /// -/// Other objects can store a "SymbolContextScope *" using any pointers -/// to one of the above objects. This allows clients to hold onto a -/// pointer that uniquely will identify a symbol context. Those clients -/// can then always reconstruct the symbol context using the pointer, or -/// use it to uniquely identify a symbol context for an object. +/// Other objects can store a "SymbolContextScope *" using any pointers to one +/// of the above objects. This allows clients to hold onto a pointer that +/// uniquely will identify a symbol context. Those clients can then always +/// reconstruct the symbol context using the pointer, or use it to uniquely +/// identify a symbol context for an object. /// -/// Example objects include that currently use "SymbolContextScope *" -/// objects include: +/// Example objects include that currently use "SymbolContextScope *" objects +/// include: /// @li Variable objects that can reconstruct where they are scoped /// by making sure the SymbolContextScope * comes from the scope /// in which the variable was declared. If a variable is a global, @@ -63,11 +62,11 @@ namespace lldb_private { /// location) match within the same thread, that the stack /// frame is the same as the previous stack frame. /// -/// Objects that adhere to this protocol can reconstruct enough of a -/// symbol context to allow functions that take a symbol context to be -/// called. Lists can also be created using a SymbolContextScope* and -/// and object pairs that allow large collections of objects to be -/// passed around with minimal overhead. +/// Objects that adhere to this protocol can reconstruct enough of a symbol +/// context to allow functions that take a symbol context to be called. Lists +/// can also be created using a SymbolContextScope* and and object pairs that +/// allow large collections of objects to be passed around with minimal +/// overhead. //---------------------------------------------------------------------- class SymbolContextScope { public: @@ -76,9 +75,9 @@ public: //------------------------------------------------------------------ /// Reconstruct the object's symbol context into \a sc. /// - /// The object should fill in as much of the SymbolContext as it - /// can so function calls that require a symbol context can be made - /// for the given object. + /// The object should fill in as much of the SymbolContext as it can so + /// function calls that require a symbol context can be made for the given + /// object. /// /// @param[out] sc /// A symbol context object pointer that gets filled in. @@ -100,9 +99,9 @@ public: //------------------------------------------------------------------ /// Dump the object's symbol context to the stream \a s. /// - /// The object should dump its symbol context to the stream \a s. - /// This function is widely used in the DumpDebug and verbose output - /// for lldb objects. + /// The object should dump its symbol context to the stream \a s. This + /// function is widely used in the DumpDebug and verbose output for lldb + /// objects. /// /// @param[in] s /// The stream to which to dump the object's symbol context. diff --git a/include/lldb/Symbol/SymbolFile.h b/include/lldb/Symbol/SymbolFile.h index 69110dc68cd79..7b77c60a3c3d9 100644 --- a/include/lldb/Symbol/SymbolFile.h +++ b/include/lldb/Symbol/SymbolFile.h @@ -26,10 +26,10 @@ public: //------------------------------------------------------------------ // Symbol file ability bits. // - // Each symbol file can claim to support one or more symbol file - // abilities. These get returned from SymbolFile::GetAbilities(). - // These help us to determine which plug-in will be best to load - // the debug information found in files. + // Each symbol file can claim to support one or more symbol file abilities. + // These get returned from SymbolFile::GetAbilities(). These help us to + // determine which plug-in will be best to load the debug information found + // in files. //------------------------------------------------------------------ enum Abilities { CompileUnits = (1u << 0), @@ -148,10 +148,10 @@ public: SymbolContextList &sc_list); virtual uint32_t FindGlobalVariables(const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, + const CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, VariableList &variables); virtual uint32_t FindGlobalVariables(const RegularExpression ®ex, - bool append, uint32_t max_matches, + uint32_t max_matches, VariableList &variables); virtual uint32_t FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, @@ -200,6 +200,8 @@ public: //------------------------------------------------------------------ virtual void SectionFileAddressesChanged() {} + virtual void Dump(Stream &s) {} + protected: ObjectFile *m_obj_file; // The object file that symbols can be extracted from. uint32_t m_abilities; diff --git a/include/lldb/Symbol/SymbolVendor.h b/include/lldb/Symbol/SymbolVendor.h index 7db3de6e690ce..312b146f29703 100644 --- a/include/lldb/Symbol/SymbolVendor.h +++ b/include/lldb/Symbol/SymbolVendor.h @@ -22,14 +22,13 @@ namespace lldb_private { //---------------------------------------------------------------------- -// The symbol vendor class is designed to abstract the process of -// searching for debug information for a given module. Platforms can -// subclass this class and provide extra ways to find debug information. -// Examples would be a subclass that would allow for locating a stand -// alone debug file, parsing debug maps, or runtime data in the object -// files. A symbol vendor can use multiple sources (SymbolFile -// objects) to provide the information and only parse as deep as needed -// in order to provide the information that is requested. +// The symbol vendor class is designed to abstract the process of searching for +// debug information for a given module. Platforms can subclass this class and +// provide extra ways to find debug information. Examples would be a subclass +// that would allow for locating a stand alone debug file, parsing debug maps, +// or runtime data in the object files. A symbol vendor can use multiple +// sources (SymbolFile objects) to provide the information and only parse as +// deep as needed in order to provide the information that is requested. //---------------------------------------------------------------------- class SymbolVendor : public ModuleChild, public PluginInterface { public: @@ -82,11 +81,11 @@ public: virtual size_t FindGlobalVariables(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - bool append, size_t max_matches, + size_t max_matches, VariableList &variables); virtual size_t FindGlobalVariables(const RegularExpression ®ex, - bool append, size_t max_matches, + size_t max_matches, VariableList &variables); virtual size_t FindFunctions(const ConstString &name, diff --git a/include/lldb/Symbol/Type.h b/include/lldb/Symbol/Type.h index 9740dc25a5876..fec2578c9fec7 100644 --- a/include/lldb/Symbol/Type.h +++ b/include/lldb/Symbol/Type.h @@ -24,8 +24,8 @@ namespace lldb_private { //---------------------------------------------------------------------- -// CompilerContext allows an array of these items to be passed to -// perform detailed lookups in SymbolVendor and SymbolFile functions. +// CompilerContext allows an array of these items to be passed to perform +// detailed lookups in SymbolVendor and SymbolFile functions. //---------------------------------------------------------------------- struct CompilerContext { CompilerContext(CompilerContextKind t, const ConstString &n) @@ -82,16 +82,12 @@ public: eEncodingIsSyntheticUID } EncodingDataType; - // We must force the underlying type of the enum to be unsigned here. Not all - // compilers - // behave the same with regards to the default underlying type of an enum, but - // because - // this enum is used in an enum bitfield and integer comparisons are done with - // the value - // we need to guarantee that it's always unsigned so that, for example, - // eResolveStateFull - // doesn't compare less than eResolveStateUnresolved when used in a 2-bit - // bitfield. + // We must force the underlying type of the enum to be unsigned here. Not + // all compilers behave the same with regards to the default underlying type + // of an enum, but because this enum is used in an enum bitfield and integer + // comparisons are done with the value we need to guarantee that it's always + // unsigned so that, for example, eResolveStateFull doesn't compare less than + // eResolveStateUnresolved when used in a 2-bit bitfield. typedef enum ResolveStateTag : unsigned { eResolveStateUnresolved = 0, eResolveStateForward = 1, @@ -106,8 +102,7 @@ public: ResolveState compiler_type_resolve_state); // This makes an invalid type. Used for functions that return a Type when - // they - // get an error. + // they get an error. Type(); Type(const Type &rhs); @@ -119,7 +114,8 @@ public: void DumpTypeName(Stream *s); // Since Type instances only keep a "SymbolFile *" internally, other classes - // like TypeImpl need make sure the module is still around before playing with + // like TypeImpl need make sure the module is still around before playing + // with // Type instances. They can store a weak pointer to the Module; lldb::ModuleSP GetModule(); @@ -188,8 +184,8 @@ public: CompilerType GetFullCompilerType(); // Get the clang type, and resolve definitions enough so that the type could - // have layout performed. This allows ptrs and refs to class/struct/union/enum - // types remain forward declarations. + // have layout performed. This allows ptrs and refs to + // class/struct/union/enum types remain forward declarations. CompilerType GetLayoutCompilerType(); // Get the clang type and leave class/struct/union/enum types as forward @@ -198,8 +194,8 @@ public: static int Compare(const Type &a, const Type &b); - // From a fully qualified typename, split the type into the type basename - // and the remaining type scope (namespaces/classes). + // From a fully qualified typename, split the type into the type basename and + // the remaining type scope (namespaces/classes). static bool GetTypeScopeAndBasename(const llvm::StringRef& name, llvm::StringRef &scope, llvm::StringRef &basename, @@ -366,8 +362,8 @@ protected: lldb::TypeSP type_sp; }; -// the two classes here are used by the public API as a backend to -// the SBType and SBTypeList classes +// the two classes here are used by the public API as a backend to the SBType +// and SBTypeList classes class TypeImpl { public: diff --git a/include/lldb/Symbol/TypeSystem.h b/include/lldb/Symbol/TypeSystem.h index ff85d84287465..94d1b9cdf3fd1 100644 --- a/include/lldb/Symbol/TypeSystem.h +++ b/include/lldb/Symbol/TypeSystem.h @@ -66,8 +66,8 @@ public: // { // } // - // Then you can use the llvm casting on any "TypeSystem *" to get an - // instance of your subclass. + // Then you can use the llvm casting on any "TypeSystem *" to get an instance + // of your subclass. //---------------------------------------------------------------------- enum LLVMCastKind { eKindClang, @@ -94,8 +94,7 @@ public: Target *target); // Free up any resources associated with this TypeSystem. Done before - // removing - // all the TypeSystems from the TypeSystemMap. + // removing all the TypeSystems from the TypeSystemMap. virtual void Finalize() {} virtual DWARFASTParser *GetDWARFParser() { return nullptr; } @@ -239,8 +238,7 @@ public: virtual CompilerType GetCanonicalType(lldb::opaque_compiler_type_t type) = 0; // 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. + // prototype Returns a value >= 0 if there is a prototype. virtual int GetFunctionArgumentCount(lldb::opaque_compiler_type_t type) = 0; virtual CompilerType @@ -332,8 +330,8 @@ public: bool &child_is_base_class, bool &child_is_deref_of_parent, ValueObject *valobj, uint64_t &language_flags) = 0; - // Lookup a child given a name. This function will match base class names - // and member member names in "clang_type" only, not descendants. + // Lookup a child given a name. This function will match base class names and + // member member names in "clang_type" only, not descendants. virtual uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes) = 0; @@ -395,8 +393,8 @@ public: lldb::offset_t data_offset, size_t data_byte_size) = 0; - // Converts "s" to a floating point value and place resulting floating - // point bytes in the "dst" buffer. + // Converts "s" to a floating point value and place resulting floating point + // bytes in the "dst" buffer. virtual size_t ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, const char *s, uint8_t *dst, size_t dst_size) = 0; @@ -481,23 +479,17 @@ public: virtual LazyBool ShouldPrintAsOneLiner(void *type, ValueObject *valobj); // Type systems can have types that are placeholder types, which are meant to - // indicate - // the presence of a type, but offer no actual information about said types, - // and leave - // the burden of actually figuring type information out to dynamic type - // resolution. For instance - // a language with a generics system, can use placeholder types to indicate - // "type argument goes here", - // without promising uniqueness of the placeholder, nor attaching any actually - // idenfiable information - // to said placeholder. This API allows type systems to tell LLDB when such a - // type has been encountered - // In response, the debugger can react by not using this type as a cache entry - // in any type-specific way - // For instance, LLDB will currently not cache any formatters that are - // discovered on such a type as - // attributable to the meaningless type itself, instead preferring to use the - // dynamic type + // indicate the presence of a type, but offer no actual information about + // said types, and leave the burden of actually figuring type information out + // to dynamic type resolution. For instance a language with a generics + // system, can use placeholder types to indicate "type argument goes here", + // without promising uniqueness of the placeholder, nor attaching any + // actually idenfiable information to said placeholder. This API allows type + // systems to tell LLDB when such a type has been encountered In response, + // the debugger can react by not using this type as a cache entry in any + // type-specific way For instance, LLDB will currently not cache any + // formatters that are discovered on such a type as attributable to the + // meaningless type itself, instead preferring to use the dynamic type virtual bool IsMeaninglessWithoutDynamicResolution(void *type); protected: @@ -514,8 +506,8 @@ public: // empties the map. void Clear(); - // Iterate through all of the type systems that are created. Return true - // from callback to keep iterating, false to stop iterating. + // Iterate through all of the type systems that are created. Return true from + // callback to keep iterating, false to stop iterating. void ForEach(std::function<bool(TypeSystem *)> const &callback); TypeSystem *GetTypeSystemForLanguage(lldb::LanguageType language, diff --git a/include/lldb/Symbol/UnwindPlan.h b/include/lldb/Symbol/UnwindPlan.h index abb57a2c499d0..a76ea23b46bc2 100644 --- a/include/lldb/Symbol/UnwindPlan.h +++ b/include/lldb/Symbol/UnwindPlan.h @@ -25,28 +25,25 @@ 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). +// 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). -// 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. +// 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. // 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 expanded table form of the DWARF CFI -// encoded information. +// saved at that point and where they are saved. It can be thought of as the +// expanded table form of the DWARF CFI encoded information. // Other unwind information sources will be converted into UnwindPlans before -// being added to a FuncUnwinders object. The unwind source may be -// an eh_frame FDE, a DWARF debug_frame FDE, or assembly language based -// prologue analysis. +// being added to a FuncUnwinders object. The unwind source may be an eh_frame +// FDE, a DWARF debug_frame FDE, or assembly language based prologue analysis. // The UnwindPlan is the canonical form of this information that the unwinder // code will use when walking the stack. @@ -371,12 +368,10 @@ public: void InsertRow(const RowSP &row_sp, bool replace_existing = false); // Returns a pointer to the best row for the given offset into the function's - // instructions. - // If offset is -1 it indicates that the function start is unknown - the final - // row in the UnwindPlan is returned. - // In practice, the UnwindPlan for a function with no known start address will - // be the architectural default - // UnwindPlan which will only have one row. + // instructions. If offset is -1 it indicates that the function start is + // unknown - the final row in the UnwindPlan is returned. In practice, the + // UnwindPlan for a function with no known start address will be the + // architectural default UnwindPlan which will only have one row. UnwindPlan::RowSP GetRowForFunctionOffset(int offset) const; lldb::RegisterKind GetRegisterKind() const { return m_register_kind; } @@ -427,15 +422,13 @@ public: } // Is this UnwindPlan valid at all instructions? If not, then it is assumed - // valid at call sites, - // e.g. for exception handling. + // valid at call sites, e.g. for exception handling. lldb_private::LazyBool GetUnwindPlanValidAtAllInstructions() const { return m_plan_is_valid_at_all_instruction_locations; } // Is this UnwindPlan valid at all instructions? If not, then it is assumed - // valid at call sites, - // e.g. for exception handling. + // valid at call sites, e.g. for exception handling. void SetUnwindPlanValidAtAllInstructions( lldb_private::LazyBool valid_at_all_insn) { m_plan_is_valid_at_all_instruction_locations = valid_at_all_insn; diff --git a/include/lldb/Symbol/UnwindTable.h b/include/lldb/Symbol/UnwindTable.h index 851d24bea03b9..5c83e30031927 100644 --- a/include/lldb/Symbol/UnwindTable.h +++ b/include/lldb/Symbol/UnwindTable.h @@ -18,8 +18,8 @@ namespace lldb_private { // A class which holds all the FuncUnwinders objects for a given ObjectFile. -// The UnwindTable is populated with FuncUnwinders objects lazily during -// the debug session. +// The UnwindTable is populated with FuncUnwinders objects lazily during the +// debug session. class UnwindTable { public: @@ -39,16 +39,13 @@ public: bool GetAllowAssemblyEmulationUnwindPlans(); // Normally when we create a new FuncUnwinders object we track it in this - // UnwindTable so it can - // be reused later. But for the target modules show-unwind we want to create - // brand new - // UnwindPlans for the function of interest - so ignore any existing - // FuncUnwinders for that - // function and don't add this new one to our UnwindTable. - // This FuncUnwinders object does have a reference to the UnwindTable but the - // lifetime of this - // uncached FuncUnwinders is expected to be short so in practice this will not - // be a problem. + // UnwindTable so it can be reused later. But for the target modules show- + // unwind we want to create brand new UnwindPlans for the function of + // interest - so ignore any existing FuncUnwinders for that function and + // don't add this new one to our UnwindTable. This FuncUnwinders object does + // have a reference to the UnwindTable but the lifetime of this uncached + // FuncUnwinders is expected to be short so in practice this will not be a + // problem. lldb::FuncUnwindersSP GetUncachedFuncUnwindersContainingAddress(const Address &addr, SymbolContext &sc); diff --git a/include/lldb/Symbol/Variable.h b/include/lldb/Symbol/Variable.h index 507b41309042c..531312e635915 100644 --- a/include/lldb/Symbol/Variable.h +++ b/include/lldb/Symbol/Variable.h @@ -17,6 +17,7 @@ #include "lldb/Core/RangeMap.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/Declaration.h" +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/UserID.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-private.h" @@ -53,11 +54,11 @@ public: SymbolContextScope *GetSymbolContextScope() const { return m_owner_scope; } - // Since a variable can have a basename "i" and also a mangled - // named "_ZN12_GLOBAL__N_11iE" and a demangled mangled name - // "(anonymous namespace)::i", this function will allow a generic match - // function that can be called by commands and expression parsers to make - // sure we match anything we come across. + // Since a variable can have a basename "i" and also a mangled named + // "_ZN12_GLOBAL__N_11iE" and a demangled mangled name "(anonymous + // namespace)::i", this function will allow a generic match function that can + // be called by commands and expression parsers to make sure we match + // anything we come across. bool NameMatches(const ConstString &name) const; bool NameMatches(const RegularExpression ®ex) const; @@ -103,8 +104,7 @@ public: ValueObjectList &valobj_list); static size_t AutoComplete(const ExecutionContext &exe_ctx, - llvm::StringRef name, StringList &matches, - bool &word_complete); + CompletionRequest &request); CompilerDeclContext GetDeclContext(); diff --git a/include/lldb/Symbol/VariableList.h b/include/lldb/Symbol/VariableList.h index c9e0be89a3bc5..6729a9c108a9b 100644 --- a/include/lldb/Symbol/VariableList.h +++ b/include/lldb/Symbol/VariableList.h @@ -50,11 +50,11 @@ public: size_t AppendVariablesIfUnique(VariableList &var_list); - // Returns the actual number of unique variables that were added to the - // list. "total_matches" will get updated with the actually number of - // matches that were found regardless of whether they were unique or not - // to allow for error conditions when nothing is found, versus conditions - // where any variables that match "regex" were already in "var_list". + // Returns the actual number of unique variables that were added to the list. + // "total_matches" will get updated with the actually number of matches that + // were found regardless of whether they were unique or not to allow for + // error conditions when nothing is found, versus conditions where any + // variables that match "regex" were already in "var_list". size_t AppendVariablesIfUnique(const RegularExpression ®ex, VariableList &var_list, size_t &total_matches); @@ -66,6 +66,7 @@ public: size_t MemorySize() const; size_t GetSize() const; + bool Empty() const { return m_variables.empty(); } protected: typedef std::vector<lldb::VariableSP> collection; diff --git a/include/lldb/Target/ABI.h b/include/lldb/Target/ABI.h index 0418d683af63b..343b3a749597e 100644 --- a/include/lldb/Target/ABI.h +++ b/include/lldb/Target/ABI.h @@ -82,8 +82,7 @@ public: protected: // This is the method the ABI will call to actually calculate the return - // value. - // Don't put it in a persistent value object, that will be done by the + // value. Don't put it in a persistent value object, that will be done by the // ABI::GetReturnValueObject. virtual lldb::ValueObjectSP GetReturnValueObjectImpl(Thread &thread, CompilerType &ast_type) const = 0; @@ -118,17 +117,17 @@ public: // restrictions (4, 8 or 16 byte aligned), and zero is usually not allowed. // This function should return true if "cfa" is valid call frame address for // the ABI, and false otherwise. This is used by the generic stack frame - // unwinding - // code to help determine when a stack ends. + // unwinding code to help determine when a stack ends. virtual bool CallFrameAddressIsValid(lldb::addr_t cfa) = 0; - // Validates a possible PC value and returns true if an opcode can be at "pc". + // Validates a possible PC value and returns true if an opcode can be at + // "pc". virtual bool CodeAddressIsValid(lldb::addr_t pc) = 0; virtual lldb::addr_t FixCodeAddress(lldb::addr_t pc) { - // Some targets might use bits in a code address to indicate - // a mode switch. ARM uses bit zero to signify a code address is - // thumb, so any ARM ABI plug-ins would strip those bits. + // Some targets might use bits in a code address to indicate a mode switch. + // ARM uses bit zero to signify a code address is thumb, so any ARM ABI + // plug-ins would strip those bits. return pc; } diff --git a/include/lldb/Target/DynamicLoader.h b/include/lldb/Target/DynamicLoader.h index b5890662d4e56..de9c4e233b0c0 100644 --- a/include/lldb/Target/DynamicLoader.h +++ b/include/lldb/Target/DynamicLoader.h @@ -48,24 +48,21 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class DynamicLoader DynamicLoader.h "lldb/Target/DynamicLoader.h" -/// @brief A plug-in interface definition class for dynamic loaders. +/// A plug-in interface definition class for dynamic loaders. /// /// Dynamic loader plug-ins track image (shared library) loading and -/// unloading. The class is initialized given a live process that is -/// halted at its entry point or just after attaching. +/// unloading. The class is initialized given a live process that is halted at +/// its entry point or just after attaching. /// -/// Dynamic loader plug-ins can track the process by registering -/// callbacks using the: -/// Process::RegisterNotificationCallbacks (const Notifications&) +/// Dynamic loader plug-ins can track the process by registering callbacks +/// using the: Process::RegisterNotificationCallbacks (const Notifications&) /// function. /// -/// Breakpoints can also be set in the process which can register -/// functions that get called using: -/// Process::BreakpointSetCallback (lldb::user_id_t, BreakpointHitCallback, void -/// *). -/// These breakpoint callbacks return a boolean value that indicates if -/// the process should continue or halt and should return the global -/// setting for this using: +/// Breakpoints can also be set in the process which can register functions +/// that get called using: Process::BreakpointSetCallback (lldb::user_id_t, +/// BreakpointHitCallback, void *). These breakpoint callbacks return a +/// boolean value that indicates if the process should continue or halt and +/// should return the global setting for this using: /// DynamicLoader::StopWhenImagesChange() const. //---------------------------------------------------------------------- class DynamicLoader : public PluginInterface { @@ -73,9 +70,8 @@ public: //------------------------------------------------------------------ /// Find a dynamic loader plugin for a given process. /// - /// Scans the installed DynamicLoader plug-ins and tries to find - /// an instance that can be used to track image changes in \a - /// process. + /// Scans the installed DynamicLoader plug-ins and tries to find an instance + /// that can be used to track image changes in \a process. /// /// @param[in] process /// The process for which to try and locate a dynamic loader @@ -95,45 +91,44 @@ public: //------------------------------------------------------------------ /// Destructor. /// - /// The destructor is virtual since this class is designed to be - /// inherited from by the plug-in instance. + /// The destructor is virtual since this class is designed to be inherited + /// from by the plug-in instance. //------------------------------------------------------------------ virtual ~DynamicLoader() override; //------------------------------------------------------------------ /// Called after attaching a process. /// - /// Allow DynamicLoader plug-ins to execute some code after - /// attaching to a process. + /// Allow DynamicLoader plug-ins to execute some code after attaching to a + /// process. //------------------------------------------------------------------ virtual void DidAttach() = 0; //------------------------------------------------------------------ /// Called after launching a process. /// - /// Allow DynamicLoader plug-ins to execute some code after - /// the process has stopped for the first time on launch. + /// Allow DynamicLoader plug-ins to execute some code after the process has + /// stopped for the first time on launch. //------------------------------------------------------------------ virtual void DidLaunch() = 0; //------------------------------------------------------------------ - /// Helper function that can be used to detect when a process has - /// called exec and is now a new and different process. This can - /// be called when necessary to try and detect the exec. The process - /// might be able to answer this question, but sometimes it might - /// not be able and the dynamic loader often knows what the program - /// entry point is. So the process and the dynamic loader can work - /// together to detect this. + /// Helper function that can be used to detect when a process has called + /// exec and is now a new and different process. This can be called when + /// necessary to try and detect the exec. The process might be able to + /// answer this question, but sometimes it might not be able and the dynamic + /// loader often knows what the program entry point is. So the process and + /// the dynamic loader can work together to detect this. //------------------------------------------------------------------ virtual bool ProcessDidExec() { return false; } //------------------------------------------------------------------ /// Get whether the process should stop when images change. /// - /// When images (executables and shared libraries) get loaded or - /// unloaded, often debug sessions will want to try and resolve or - /// unresolve breakpoints that are set in these images. Any - /// breakpoints set by DynamicLoader plug-in instances should - /// return this value to ensure consistent debug session behaviour. + /// When images (executables and shared libraries) get loaded or unloaded, + /// often debug sessions will want to try and resolve or unresolve + /// breakpoints that are set in these images. Any breakpoints set by + /// DynamicLoader plug-in instances should return this value to ensure + /// consistent debug session behaviour. /// /// @return /// Returns \b true if the process should stop when images @@ -144,11 +139,11 @@ public: //------------------------------------------------------------------ /// Set whether the process should stop when images change. /// - /// When images (executables and shared libraries) get loaded or - /// unloaded, often debug sessions will want to try and resolve or - /// unresolve breakpoints that are set in these images. The default - /// is set so that the process stops when images change, but this - /// can be overridden using this function callback. + /// When images (executables and shared libraries) get loaded or unloaded, + /// often debug sessions will want to try and resolve or unresolve + /// breakpoints that are set in these images. The default is set so that the + /// process stops when images change, but this can be overridden using this + /// function callback. /// /// @param[in] stop /// Boolean value that indicates whether the process should stop @@ -157,8 +152,8 @@ public: void SetStopWhenImagesChange(bool stop); //------------------------------------------------------------------ - /// Provides a plan to step through the dynamic loader trampoline - /// for the current state of \a thread. + /// Provides a plan to step through the dynamic loader trampoline for the + /// current state of \a thread. /// /// /// @param[in] stop_others @@ -173,12 +168,9 @@ public: //------------------------------------------------------------------ /// Some dynamic loaders provide features where there are a group of symbols - /// "equivalent to" - /// a given symbol one of which will be chosen when the symbol is bound. If - /// you want to - /// set a breakpoint on one of these symbols, you really need to set it on all - /// the - /// equivalent symbols. + /// "equivalent to" a given symbol one of which will be chosen when the + /// symbol is bound. If you want to set a breakpoint on one of these + /// symbols, you really need to set it on all the equivalent symbols. /// /// /// @param[in] original_symbol @@ -201,13 +193,12 @@ public: } //------------------------------------------------------------------ - /// Ask if it is ok to try and load or unload an shared library - /// (image). + /// Ask if it is ok to try and load or unload an shared library (image). /// - /// The dynamic loader often knows when it would be ok to try and - /// load or unload a shared library. This function call allows the - /// dynamic loader plug-ins to check any current dyld state to make - /// sure it is an ok time to load a shared library. + /// The dynamic loader often knows when it would be ok to try and load or + /// unload a shared library. This function call allows the dynamic loader + /// plug-ins to check any current dyld state to make sure it is an ok time + /// to load a shared library. /// /// @return /// \b true if it is currently ok to try and load a shared @@ -216,20 +207,20 @@ public: virtual Status CanLoadImage() = 0; //------------------------------------------------------------------ - /// Ask if the eh_frame information for the given SymbolContext should - /// be relied on even when it's the first frame in a stack unwind. + /// Ask if the eh_frame information for the given SymbolContext should be + /// relied on even when it's the first frame in a stack unwind. /// - /// The CFI instructions from the eh_frame section are normally only - /// valid at call sites -- places where a program could throw an - /// exception and need to unwind out. But some Modules may be known - /// to the system as having reliable eh_frame information at all call - /// sites. This would be the case if the Module's contents are largely - /// hand-written assembly with hand-written eh_frame information. - /// Normally when unwinding from a function at the beginning of a stack - /// unwind lldb will examine the assembly instructions to understand - /// how the stack frame is set up and where saved registers are stored. - /// But with hand-written assembly this is not reliable enough -- we need - /// to consult those function's hand-written eh_frame information. + /// The CFI instructions from the eh_frame section are normally only valid + /// at call sites -- places where a program could throw an exception and + /// need to unwind out. But some Modules may be known to the system as + /// having reliable eh_frame information at all call sites. This would be + /// the case if the Module's contents are largely hand-written assembly with + /// hand-written eh_frame information. Normally when unwinding from a + /// function at the beginning of a stack unwind lldb will examine the + /// assembly instructions to understand how the stack frame is set up and + /// where saved registers are stored. But with hand-written assembly this is + /// not reliable enough -- we need to consult those function's hand-written + /// eh_frame information. /// /// @return /// \b True if the symbol context should use eh_frame instructions @@ -271,17 +262,17 @@ public: //------------------------------------------------------------------ /// Get information about the shared cache for a process, if possible. /// - /// On some systems (e.g. Darwin based systems), a set of libraries - /// that are common to most processes may be put in a single region - /// of memory and mapped into every process, this is called the - /// shared cache, as a performance optimization. + /// On some systems (e.g. Darwin based systems), a set of libraries that are + /// common to most processes may be put in a single region of memory and + /// mapped into every process, this is called the shared cache, as a + /// performance optimization. /// /// Many targets will not have the concept of a shared cache. /// - /// Depending on how the DynamicLoader gathers information about the - /// shared cache, it may be able to only return basic information - - /// like the UUID of the cache - or it may be able to return additional - /// information about the cache. + /// Depending on how the DynamicLoader gathers information about the shared + /// cache, it may be able to only return basic information - like the UUID + /// of the cache - or it may be able to return additional information about + /// the cache. /// /// @param[out] base_address /// The base address (load address) of the shared cache. @@ -356,8 +347,8 @@ protected: // Return -1 if the read fails, otherwise return the result as an int64_t. int64_t ReadUnsignedIntWithSizeInBytes(lldb::addr_t addr, int size_in_bytes); - // Read a pointer from memory at the given addr. - // Return LLDB_INVALID_ADDRESS if the read fails. + // Read a pointer from memory at the given addr. Return LLDB_INVALID_ADDRESS + // if the read fails. lldb::addr_t ReadPointer(lldb::addr_t addr); // Calls into the Process protected method LoadOperatingSystemPlugin: diff --git a/include/lldb/Target/ExecutionContext.h b/include/lldb/Target/ExecutionContext.h index 04af3ebc278d0..70eba3654decf 100644 --- a/include/lldb/Target/ExecutionContext.h +++ b/include/lldb/Target/ExecutionContext.h @@ -22,61 +22,59 @@ namespace lldb_private { //===----------------------------------------------------------------------===// -/// Execution context objects refer to objects in the execution of the -/// program that is being debugged. The consist of one or more of the -/// following objects: target, process, thread, and frame. Many objects -/// in the debugger need to track different executions contexts. For -/// example, a local function variable might have an execution context -/// that refers to a stack frame. A global or static variable might -/// refer to a target since a stack frame isn't required in order to -/// evaluate a global or static variable (a process isn't necessarily -/// needed for a global variable since we might be able to read the -/// variable value from a data section in one of the object files in +/// Execution context objects refer to objects in the execution of the program +/// that is being debugged. The consist of one or more of the following +/// objects: target, process, thread, and frame. Many objects in the debugger +/// need to track different executions contexts. For example, a local function +/// variable might have an execution context that refers to a stack frame. A +/// global or static variable might refer to a target since a stack frame +/// isn't required in order to evaluate a global or static variable (a process +/// isn't necessarily needed for a global variable since we might be able to +/// read the variable value from a data section in one of the object files in /// a target). There are two types of objects that hold onto execution -/// contexts: ExecutionContextRef and ExecutionContext. Both of these -/// objects are described below. +/// contexts: ExecutionContextRef and ExecutionContext. Both of these objects +/// are described below. /// -/// Not all objects in an ExectionContext objects will be valid. If you want -/// to refer strongly (ExectionContext) or weakly (ExectionContextRef) to -/// a process, then only the process and target references will be valid. -/// For threads, only the thread, process and target references will be -/// filled in. For frames, all of the objects will be filled in. +/// Not all objects in an ExecutionContext objects will be valid. If you want +/// to refer strongly (ExecutionContext) or weakly (ExecutionContextRef) to a +/// process, then only the process and target references will be valid. For +/// threads, only the thread, process and target references will be filled in. +/// For frames, all of the objects will be filled in. /// -/// These classes are designed to be used as baton objects that get passed -/// to a wide variety of functions that require execution contexts. +/// These classes are designed to be used as baton objects that get passed to +/// a wide variety of functions that require execution contexts. //===----------------------------------------------------------------------===// //---------------------------------------------------------------------- /// @class ExecutionContextRef ExecutionContext.h /// "lldb/Target/ExecutionContext.h" -/// @brief A class that holds a weak reference to an execution context. +/// A class that holds a weak reference to an execution context. /// -/// ExecutionContextRef objects are designed to hold onto an execution -/// context that might change over time. For example, if an object wants -/// to refer to a stack frame, it should hold onto an ExecutionContextRef -/// to a frame object. The backing object that represents the stack frame -/// might change over time and instances of this object can track the logical -/// object that refers to a frame even if it does change. +/// ExecutionContextRef objects are designed to hold onto an execution context +/// that might change over time. For example, if an object wants to refer to a +/// stack frame, it should hold onto an ExecutionContextRef to a frame object. +/// The backing object that represents the stack frame might change over time +/// and instances of this object can track the logical object that refers to a +/// frame even if it does change. /// /// These objects also don't keep execution objects around longer than they -/// should since they use weak pointers. For example if an object refers -/// to a stack frame and a stack frame is no longer in a thread, then a -/// ExecutionContextRef object that refers to that frame will not be able -/// to get a shared pointer to those objects since they are no longer around. +/// should since they use weak pointers. For example if an object refers to a +/// stack frame and a stack frame is no longer in a thread, then a +/// ExecutionContextRef object that refers to that frame will not be able to +/// get a shared pointer to those objects since they are no longer around. /// -/// ExecutionContextRef objects can also be used as objects in classes -/// that want to track a "previous execution context". Since the weak -/// references to the execution objects (target, process, thread and frame) -/// don't keep these objects around, they are safe to keep around. +/// ExecutionContextRef objects can also be used as objects in classes that +/// want to track a "previous execution context". Since the weak references to +/// the execution objects (target, process, thread and frame) don't keep these +/// objects around, they are safe to keep around. /// -/// The general rule of thumb is all long lived objects that want to -/// refer to execution contexts should use ExecutionContextRef objects. -/// The ExecutionContext class is used to temporarily get shared -/// pointers to any execution context objects that are still around -/// so they are guaranteed to exist during a function that requires the -/// objects. ExecutionContext objects should NOT be used for long term -/// storage since they will keep objects alive with extra shared pointer -/// references to these objects. +/// The general rule of thumb is all long lived objects that want to refer to +/// execution contexts should use ExecutionContextRef objects. The +/// ExecutionContext class is used to temporarily get shared pointers to any +/// execution context objects that are still around so they are guaranteed to +/// exist during a function that requires the objects. ExecutionContext +/// objects should NOT be used for long term storage since they will keep +/// objects alive with extra shared pointer references to these objects. //---------------------------------------------------------------------- class ExecutionContextRef { public: @@ -93,9 +91,9 @@ public: //------------------------------------------------------------------ /// Construct using an ExecutionContext object that might be nullptr. /// - /// If \a exe_ctx_ptr is valid, then make weak references to any - /// valid objects in the ExecutionContext, otherwise no weak - /// references to any execution context objects will be made. + /// If \a exe_ctx_ptr is valid, then make weak references to any valid + /// objects in the ExecutionContext, otherwise no weak references to any + /// execution context objects will be made. //------------------------------------------------------------------ ExecutionContextRef(const ExecutionContext *exe_ctx_ptr); @@ -107,38 +105,37 @@ public: ExecutionContextRef(const ExecutionContext &exe_ctx); //------------------------------------------------------------------ - /// Construct using the target and all the selected items inside of it - /// (the process and its selected thread, and the thread's selected - /// frame). If there is no selected thread, default to the first thread - /// If there is no selected frame, default to the first frame. + /// Construct using the target and all the selected items inside of it (the + /// process and its selected thread, and the thread's selected frame). If + /// there is no selected thread, default to the first thread If there is no + /// selected frame, default to the first frame. //------------------------------------------------------------------ ExecutionContextRef(Target *target, bool adopt_selected); //------------------------------------------------------------------ /// Construct using an execution context scope. /// - /// If the ExecutionContextScope object is valid and refers to a frame, - /// make weak references too the frame, thread, process and target. - /// If the ExecutionContextScope object is valid and refers to a thread, - /// make weak references too the thread, process and target. - /// If the ExecutionContextScope object is valid and refers to a process, - /// make weak references too the process and target. - /// If the ExecutionContextScope object is valid and refers to a target, - /// make weak references too the target. + /// If the ExecutionContextScope object is valid and refers to a frame, make + /// weak references too the frame, thread, process and target. If the + /// ExecutionContextScope object is valid and refers to a thread, make weak + /// references too the thread, process and target. If the + /// ExecutionContextScope object is valid and refers to a process, make weak + /// references too the process and target. If the ExecutionContextScope + /// object is valid and refers to a target, make weak references too the + /// target. //------------------------------------------------------------------ ExecutionContextRef(ExecutionContextScope *exe_scope); //------------------------------------------------------------------ /// Construct using an execution context scope. /// - /// If the ExecutionContextScope object refers to a frame, - /// make weak references too the frame, thread, process and target. - /// If the ExecutionContextScope object refers to a thread, - /// make weak references too the thread, process and target. - /// If the ExecutionContextScope object refers to a process, - /// make weak references too the process and target. - /// If the ExecutionContextScope object refers to a target, - /// make weak references too the target. + /// If the ExecutionContextScope object refers to a frame, make weak + /// references too the frame, thread, process and target. If the + /// ExecutionContextScope object refers to a thread, make weak references + /// too the thread, process and target. If the ExecutionContextScope object + /// refers to a process, make weak references too the process and target. If + /// the ExecutionContextScope object refers to a target, make weak + /// references too the target. //------------------------------------------------------------------ ExecutionContextRef(ExecutionContextScope &exe_scope); @@ -167,33 +164,33 @@ public: void Clear(); //------------------------------------------------------------------ - /// Set accessor that creates a weak reference to the target - /// referenced in \a target_sp. + /// Set accessor that creates a weak reference to the target referenced in + /// \a target_sp. /// - /// If \a target_sp is valid this object will create a weak - /// reference to that object, otherwise any previous target weak - /// reference contained in this object will be reset. + /// If \a target_sp is valid this object will create a weak reference to + /// that object, otherwise any previous target weak reference contained in + /// this object will be reset. /// - /// Only the weak reference to the target will be updated, no other - /// weak references will be modified. If you want this execution - /// context to make a weak reference to the target's process, use - /// the ExecutionContextRef::SetContext() functions. + /// Only the weak reference to the target will be updated, no other weak + /// references will be modified. If you want this execution context to make + /// a weak reference to the target's process, use the + /// ExecutionContextRef::SetContext() functions. /// /// @see ExecutionContextRef::SetContext(const lldb::TargetSP &, bool) //------------------------------------------------------------------ void SetTargetSP(const lldb::TargetSP &target_sp); //------------------------------------------------------------------ - /// Set accessor that creates a weak reference to the process - /// referenced in \a process_sp. + /// Set accessor that creates a weak reference to the process referenced in + /// \a process_sp. /// - /// If \a process_sp is valid this object will create a weak - /// reference to that object, otherwise any previous process weak - /// reference contained in this object will be reset. + /// If \a process_sp is valid this object will create a weak reference to + /// that object, otherwise any previous process weak reference contained in + /// this object will be reset. /// - /// Only the weak reference to the process will be updated, no other - /// weak references will be modified. If you want this execution - /// context to make a weak reference to the target, use the + /// Only the weak reference to the process will be updated, no other weak + /// references will be modified. If you want this execution context to make + /// a weak reference to the target, use the /// ExecutionContextRef::SetContext() functions. /// /// @see ExecutionContextRef::SetContext(const lldb::ProcessSP &) @@ -201,34 +198,34 @@ public: void SetProcessSP(const lldb::ProcessSP &process_sp); //------------------------------------------------------------------ - /// Set accessor that creates a weak reference to the thread - /// referenced in \a thread_sp. + /// Set accessor that creates a weak reference to the thread referenced in + /// \a thread_sp. /// - /// If \a thread_sp is valid this object will create a weak - /// reference to that object, otherwise any previous thread weak - /// reference contained in this object will be reset. + /// If \a thread_sp is valid this object will create a weak reference to + /// that object, otherwise any previous thread weak reference contained in + /// this object will be reset. /// - /// Only the weak reference to the thread will be updated, no other - /// weak references will be modified. If you want this execution - /// context to make a weak reference to the thread's process and - /// target, use the ExecutionContextRef::SetContext() functions. + /// Only the weak reference to the thread will be updated, no other weak + /// references will be modified. If you want this execution context to make + /// a weak reference to the thread's process and target, use the + /// ExecutionContextRef::SetContext() functions. /// /// @see ExecutionContextRef::SetContext(const lldb::ThreadSP &) //------------------------------------------------------------------ void SetThreadSP(const lldb::ThreadSP &thread_sp); //------------------------------------------------------------------ - /// Set accessor that creates a weak reference to the frame - /// referenced in \a frame_sp. + /// Set accessor that creates a weak reference to the frame referenced in \a + /// frame_sp. /// - /// If \a frame_sp is valid this object will create a weak - /// reference to that object, otherwise any previous frame weak - /// reference contained in this object will be reset. + /// If \a frame_sp is valid this object will create a weak reference to that + /// object, otherwise any previous frame weak reference contained in this + /// object will be reset. /// - /// Only the weak reference to the frame will be updated, no other - /// weak references will be modified. If you want this execution - /// context to make a weak reference to the frame's thread, process - /// and target, use the ExecutionContextRef::SetContext() functions. + /// Only the weak reference to the frame will be updated, no other weak + /// references will be modified. If you want this execution context to make + /// a weak reference to the frame's thread, process and target, use the + /// ExecutionContextRef::SetContext() functions. /// /// @see ExecutionContextRef::SetContext(const lldb::StackFrameSP &) //------------------------------------------------------------------ @@ -281,28 +278,25 @@ public: //------------------------------------------------------------------ /// Create an ExecutionContext object from this object. /// - /// Create strong references to any execution context objects that - /// are still valid. Any of the returned shared pointers in the - /// ExecutionContext objects is not guaranteed to be valid. - /// @returns + /// Create strong references to any execution context objects that are still + /// valid. Any of the returned shared pointers in the ExecutionContext + /// objects is not guaranteed to be valid. @returns /// An execution context object that has strong references to /// any valid weak references in this object. //------------------------------------------------------------------ ExecutionContext Lock(bool thread_and_frame_only_if_stopped) const; //------------------------------------------------------------------ - /// Returns true if this object has a weak reference to a thread. - /// The return value is only an indication of whether this object has - /// a weak reference and does not indicate whether the weak reference - /// is valid or not. + /// Returns true if this object has a weak reference to a thread. The return + /// value is only an indication of whether this object has a weak reference + /// and does not indicate whether the weak reference is valid or not. //------------------------------------------------------------------ bool HasThreadRef() const { return m_tid != LLDB_INVALID_THREAD_ID; } //------------------------------------------------------------------ - /// Returns true if this object has a weak reference to a frame. - /// The return value is only an indication of whether this object has - /// a weak reference and does not indicate whether the weak reference - /// is valid or not. + /// Returns true if this object has a weak reference to a frame. The return + /// value is only an indication of whether this object has a weak reference + /// and does not indicate whether the weak reference is valid or not. //------------------------------------------------------------------ bool HasFrameRef() const { return m_stack_id.IsValid(); } @@ -327,25 +321,25 @@ protected: }; //---------------------------------------------------------------------- -/// @class ExecutionContext ExecutionContext.h "lldb/Target/ExecutionContext.h" -/// @brief A class that contains an execution context. +/// @class ExecutionContext ExecutionContext.h +/// "lldb/Target/ExecutionContext.h" +/// A class that contains an execution context. /// -/// This baton object can be passed into any function that requires -/// a context that specifies a target, process, thread and frame. -/// These objects are designed to be used for short term execution -/// context object storage while a function might be trying to evaluate -/// something that requires a thread or frame. ExecutionContextRef -/// objects can be used to initialize one of these objects to turn -/// the weak execution context object references to the target, process, -/// thread and frame into strong references (shared pointers) so that -/// functions can guarantee that these objects won't go away in the +/// This baton object can be passed into any function that requires a context +/// that specifies a target, process, thread and frame. These objects are +/// designed to be used for short term execution context object storage while +/// a function might be trying to evaluate something that requires a thread or +/// frame. ExecutionContextRef objects can be used to initialize one of these +/// objects to turn the weak execution context object references to the +/// target, process, thread and frame into strong references (shared pointers) +/// so that functions can guarantee that these objects won't go away in the /// middle of a function. /// -/// ExecutionContext objects should be used as short lived objects -/// (typically on the stack) in order to lock down an execution context -/// for local use and for passing down to other functions that also -/// require specific contexts. They should NOT be used for long term -/// storage, for long term storage use ExecutionContextRef objects. +/// ExecutionContext objects should be used as short lived objects (typically +/// on the stack) in order to lock down an execution context for local use and +/// for passing down to other functions that also require specific contexts. +/// They should NOT be used for long term storage, for long term storage use +/// ExecutionContextRef objects. //---------------------------------------------------------------------- class ExecutionContext { public: @@ -384,8 +378,7 @@ public: bool thread_and_frame_only_if_stopped = false); // These two variants take in a locker, and grab the target, lock the API - // mutex into locker, then - // fill in the rest of the shared pointers. + // mutex into locker, then fill in the rest of the shared pointers. ExecutionContext(const ExecutionContextRef &exe_ctx_ref, std::unique_lock<std::recursive_mutex> &locker); ExecutionContext(const ExecutionContextRef *exe_ctx_ref, @@ -441,14 +434,14 @@ public: /// Returns a pointer to the target object. /// /// The returned pointer might be nullptr. Calling HasTargetScope(), - /// HasProcessScope(), HasThreadScope(), or HasFrameScope() - /// can help to pre-validate this pointer so that this accessor can - /// freely be used without having to check for nullptr each time. + /// HasProcessScope(), HasThreadScope(), or HasFrameScope() can help to pre- + /// validate this pointer so that this accessor can freely be used without + /// having to check for nullptr each time. /// - /// @see ExecutionContext::HasTargetScope() const - /// @see ExecutionContext::HasProcessScope() const - /// @see ExecutionContext::HasThreadScope() const - /// @see ExecutionContext::HasFrameScope() const + /// @see ExecutionContext::HasTargetScope() const @see + /// ExecutionContext::HasProcessScope() const @see + /// ExecutionContext::HasThreadScope() const @see + /// ExecutionContext::HasFrameScope() const //------------------------------------------------------------------ Target *GetTargetPtr() const; @@ -456,13 +449,13 @@ public: /// Returns a pointer to the process object. /// /// The returned pointer might be nullptr. Calling HasProcessScope(), - /// HasThreadScope(), or HasFrameScope() can help to pre-validate - /// this pointer so that this accessor can freely be used without - /// having to check for nullptr each time. + /// HasThreadScope(), or HasFrameScope() can help to pre-validate this + /// pointer so that this accessor can freely be used without having to check + /// for nullptr each time. /// - /// @see ExecutionContext::HasProcessScope() const - /// @see ExecutionContext::HasThreadScope() const - /// @see ExecutionContext::HasFrameScope() const + /// @see ExecutionContext::HasProcessScope() const @see + /// ExecutionContext::HasThreadScope() const @see + /// ExecutionContext::HasFrameScope() const //------------------------------------------------------------------ Process *GetProcessPtr() const; @@ -470,21 +463,21 @@ public: /// Returns a pointer to the thread object. /// /// The returned pointer might be nullptr. Calling HasThreadScope() or - /// HasFrameScope() can help to pre-validate this pointer so that - /// this accessor can freely be used without having to check for - /// nullptr each time. + /// HasFrameScope() can help to pre-validate this pointer so that this + /// accessor can freely be used without having to check for nullptr each + /// time. /// - /// @see ExecutionContext::HasThreadScope() const - /// @see ExecutionContext::HasFrameScope() const + /// @see ExecutionContext::HasThreadScope() const @see + /// ExecutionContext::HasFrameScope() const //------------------------------------------------------------------ Thread *GetThreadPtr() const { return m_thread_sp.get(); } //------------------------------------------------------------------ /// Returns a pointer to the frame object. /// - /// The returned pointer might be nullptr. Calling HasFrameScope(), - /// can help to pre-validate this pointer so that this accessor can - /// freely be used without having to check for nullptr each time. + /// The returned pointer might be nullptr. Calling HasFrameScope(), can help + /// to pre-validate this pointer so that this accessor can freely be used + /// without having to check for nullptr each time. /// /// @see ExecutionContext::HasFrameScope() const //------------------------------------------------------------------ @@ -494,14 +487,13 @@ public: /// Returns a reference to the target object. /// /// Clients should call HasTargetScope(), HasProcessScope(), - /// HasThreadScope(), or HasFrameScope() prior to calling this - /// function to ensure that this ExecutionContext object contains - /// a valid target. + /// HasThreadScope(), or HasFrameScope() prior to calling this function to + /// ensure that this ExecutionContext object contains a valid target. /// - /// @see ExecutionContext::HasTargetScope() const - /// @see ExecutionContext::HasProcessScope() const - /// @see ExecutionContext::HasThreadScope() const - /// @see ExecutionContext::HasFrameScope() const + /// @see ExecutionContext::HasTargetScope() const @see + /// ExecutionContext::HasProcessScope() const @see + /// ExecutionContext::HasThreadScope() const @see + /// ExecutionContext::HasFrameScope() const //------------------------------------------------------------------ Target &GetTargetRef() const; @@ -509,33 +501,32 @@ public: /// Returns a reference to the process object. /// /// Clients should call HasProcessScope(), HasThreadScope(), or - /// HasFrameScope() prior to calling this function to ensure that - /// this ExecutionContext object contains a valid target. + /// HasFrameScope() prior to calling this function to ensure that this + /// ExecutionContext object contains a valid target. /// - /// @see ExecutionContext::HasProcessScope() const - /// @see ExecutionContext::HasThreadScope() const - /// @see ExecutionContext::HasFrameScope() const + /// @see ExecutionContext::HasProcessScope() const @see + /// ExecutionContext::HasThreadScope() const @see + /// ExecutionContext::HasFrameScope() const //------------------------------------------------------------------ Process &GetProcessRef() const; //------------------------------------------------------------------ /// Returns a reference to the thread object. /// - /// Clients should call HasThreadScope(), or HasFrameScope() prior - /// to calling this function to ensure that this ExecutionContext - /// object contains a valid target. + /// Clients should call HasThreadScope(), or HasFrameScope() prior to + /// calling this function to ensure that this ExecutionContext object + /// contains a valid target. /// - /// @see ExecutionContext::HasThreadScope() const - /// @see ExecutionContext::HasFrameScope() const + /// @see ExecutionContext::HasThreadScope() const @see + /// ExecutionContext::HasFrameScope() const //------------------------------------------------------------------ Thread &GetThreadRef() const; //------------------------------------------------------------------ /// Returns a reference to the thread object. /// - /// Clients should call HasFrameScope() prior to calling this - /// function to ensure that this ExecutionContext object contains - /// a valid target. + /// Clients should call HasFrameScope() prior to calling this function to + /// ensure that this ExecutionContext object contains a valid target. /// /// @see ExecutionContext::HasFrameScope() const //------------------------------------------------------------------ @@ -596,8 +587,8 @@ public: void SetTargetPtr(Target *target); //------------------------------------------------------------------ - /// Set accessor to set only the process shared pointer from a - /// process pointer. + /// Set accessor to set only the process shared pointer from a process + /// pointer. //------------------------------------------------------------------ void SetProcessPtr(Process *process); @@ -608,50 +599,47 @@ public: void SetThreadPtr(Thread *thread); //------------------------------------------------------------------ - /// Set accessor to set only the frame shared pointer from a frame - /// pointer. + /// Set accessor to set only the frame shared pointer from a frame pointer. //------------------------------------------------------------------ void SetFramePtr(StackFrame *frame); //------------------------------------------------------------------ // Set the execution context using a target shared pointer. // - // If "target_sp" is valid, sets the target context to match and - // if "get_process" is true, sets the process shared pointer if - // the target currently has a process. + // If "target_sp" is valid, sets the target context to match and if + // "get_process" is true, sets the process shared pointer if the target + // currently has a process. //------------------------------------------------------------------ void SetContext(const lldb::TargetSP &target_sp, bool get_process); //------------------------------------------------------------------ // Set the execution context using a process shared pointer. // - // If "process_sp" is valid, then set the process and target in this - // context. Thread and frame contexts will be cleared. - // If "process_sp" is not valid, all shared pointers are reset. + // If "process_sp" is valid, then set the process and target in this context. + // Thread and frame contexts will be cleared. If "process_sp" is not valid, + // all shared pointers are reset. //------------------------------------------------------------------ void SetContext(const lldb::ProcessSP &process_sp); //------------------------------------------------------------------ // Set the execution context using a thread shared pointer. // - // If "thread_sp" is valid, then set the thread, process and target - // in this context. The frame context will be cleared. - // If "thread_sp" is not valid, all shared pointers are reset. + // If "thread_sp" is valid, then set the thread, process and target in this + // context. The frame context will be cleared. If "thread_sp" is not valid, + // all shared pointers are reset. //------------------------------------------------------------------ void SetContext(const lldb::ThreadSP &thread_sp); //------------------------------------------------------------------ // Set the execution context using a frame shared pointer. // - // If "frame_sp" is valid, then set the frame, thread, process and - // target in this context - // If "frame_sp" is not valid, all shared pointers are reset. + // If "frame_sp" is valid, then set the frame, thread, process and target in + // this context If "frame_sp" is not valid, all shared pointers are reset. //------------------------------------------------------------------ void SetContext(const lldb::StackFrameSP &frame_sp); //------------------------------------------------------------------ - /// Returns true the ExecutionContext object contains a valid - /// target. + /// Returns true the ExecutionContext object contains a valid target. /// /// This function can be called after initializing an ExecutionContext /// object, and if it returns true, calls to GetTargetPtr() and @@ -660,36 +648,35 @@ public: bool HasTargetScope() const; //------------------------------------------------------------------ - /// Returns true the ExecutionContext object contains a valid - /// target and process. + /// Returns true the ExecutionContext object contains a valid target and + /// process. /// /// This function can be called after initializing an ExecutionContext /// object, and if it returns true, calls to GetTargetPtr() and - /// GetTargetRef(), GetProcessPtr(), and GetProcessRef(), do not - /// need to be checked for validity. + /// GetTargetRef(), GetProcessPtr(), and GetProcessRef(), do not need to be + /// checked for validity. //------------------------------------------------------------------ bool HasProcessScope() const; //------------------------------------------------------------------ - /// Returns true the ExecutionContext object contains a valid - /// target, process, and thread. + /// Returns true the ExecutionContext object contains a valid target, + /// process, and thread. /// /// This function can be called after initializing an ExecutionContext - /// object, and if it returns true, calls to GetTargetPtr(), - /// GetTargetRef(), GetProcessPtr(), GetProcessRef(), GetThreadPtr(), - /// and GetThreadRef() do not need to be checked for validity. + /// object, and if it returns true, calls to GetTargetPtr(), GetTargetRef(), + /// GetProcessPtr(), GetProcessRef(), GetThreadPtr(), and GetThreadRef() do + /// not need to be checked for validity. //------------------------------------------------------------------ bool HasThreadScope() const; //------------------------------------------------------------------ - /// Returns true the ExecutionContext object contains a valid - /// target, process, thread and frame. + /// Returns true the ExecutionContext object contains a valid target, + /// process, thread and frame. /// /// This function can be called after initializing an ExecutionContext - /// object, and if it returns true, calls to GetTargetPtr(), - /// GetTargetRef(), GetProcessPtr(), GetProcessRef(), GetThreadPtr(), - /// GetThreadRef(), GetFramePtr(), and GetFrameRef() do not need - /// to be checked for validity. + /// object, and if it returns true, calls to GetTargetPtr(), GetTargetRef(), + /// GetProcessPtr(), GetProcessRef(), GetThreadPtr(), GetThreadRef(), + /// GetFramePtr(), and GetFrameRef() do not need to be checked for validity. //------------------------------------------------------------------ bool HasFrameScope() const; diff --git a/include/lldb/Target/ExecutionContextScope.h b/include/lldb/Target/ExecutionContextScope.h index 36d3d9de49b05..b73ca576bd8aa 100644 --- a/include/lldb/Target/ExecutionContextScope.h +++ b/include/lldb/Target/ExecutionContextScope.h @@ -20,22 +20,21 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class ExecutionContextScope ExecutionContextScope.h -/// "lldb/Symbol/ExecutionContextScope.h" -/// @brief Inherit from this if your object can reconstruct its +/// "lldb/Symbol/ExecutionContextScope.h" Inherit from this if your object can +/// reconstruct its /// execution context. /// -/// Many objects that have pointers back to parent execution context -/// objects can inherit from this pure virtual class can reconstruct -/// their execution context without having to keep a complete -/// ExecutionContext object in the object state. Examples of these -/// objects include: Process, Thread, RegisterContext and StackFrame. +/// Many objects that have pointers back to parent execution context objects +/// can inherit from this pure virtual class can reconstruct their execution +/// context without having to keep a complete ExecutionContext object in the +/// object state. Examples of these objects include: Process, Thread, +/// RegisterContext and StackFrame. /// -/// Objects can contain a valid pointer to an instance of this so they -/// can reconstruct the execution context. +/// Objects can contain a valid pointer to an instance of this so they can +/// reconstruct the execution context. /// -/// Objects that adhere to this protocol can reconstruct enough of a -/// execution context to allow functions that take a execution contexts -/// to be called. +/// Objects that adhere to this protocol can reconstruct enough of a execution +/// context to allow functions that take a execution contexts to be called. //---------------------------------------------------------------------- class ExecutionContextScope { public: @@ -52,9 +51,9 @@ public: //------------------------------------------------------------------ /// Reconstruct the object's execution context into \a sc. /// - /// The object should fill in as much of the ExecutionContextScope as it - /// can so function calls that require a execution context can be made - /// for the given object. + /// The object should fill in as much of the ExecutionContextScope as it can + /// so function calls that require a execution context can be made for the + /// given object. /// /// @param[out] exe_ctx /// A reference to an execution context object that gets filled diff --git a/include/lldb/Target/JITLoader.h b/include/lldb/Target/JITLoader.h index 97f2a9796a805..56f1417eddb0e 100644 --- a/include/lldb/Target/JITLoader.h +++ b/include/lldb/Target/JITLoader.h @@ -19,21 +19,21 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class JITLoader JITLoader.h "lldb/Target/JITLoader.h" -/// @brief A plug-in interface definition class for JIT loaders. +/// A plug-in interface definition class for JIT loaders. /// -/// Plugins of this kind listen for code generated at runtime in the -/// target. They are very similar to dynamic loader, with the difference -/// that they do not have information about the target's dyld and -/// that there may be multiple JITLoader plugins per process, while -/// there is at most one DynamicLoader. +/// Plugins of this kind listen for code generated at runtime in the target. +/// They are very similar to dynamic loader, with the difference that they do +/// not have information about the target's dyld and that there may be +/// multiple JITLoader plugins per process, while there is at most one +/// DynamicLoader. //---------------------------------------------------------------------- class JITLoader : public PluginInterface { public: //------------------------------------------------------------------ /// Find a JIT loader plugin for a given process. /// - /// Scans the installed DynamicLoader plug-ins and tries to find - /// all applicable instances for the current process. + /// Scans the installed DynamicLoader plug-ins and tries to find all + /// applicable instances for the current process. /// /// @param[in] process /// The process for which to try and locate a JIT loader @@ -52,22 +52,22 @@ public: //------------------------------------------------------------------ /// Called after attaching a process. /// - /// Allow JITLoader plug-ins to execute some code after - /// attaching to a process. + /// Allow JITLoader plug-ins to execute some code after attaching to a + /// process. //------------------------------------------------------------------ virtual void DidAttach() = 0; //------------------------------------------------------------------ /// Called after launching a process. /// - /// Allow JITLoader plug-ins to execute some code after - /// the process has stopped for the first time on launch. + /// Allow JITLoader plug-ins to execute some code after the process has + /// stopped for the first time on launch. //------------------------------------------------------------------ virtual void DidLaunch() = 0; //------------------------------------------------------------------ - /// Called after a new shared object has been loaded so that it can - /// be probed for JIT entry point hooks. + /// Called after a new shared object has been loaded so that it can be + /// probed for JIT entry point hooks. //------------------------------------------------------------------ virtual void ModulesDidLoad(lldb_private::ModuleList &module_list) = 0; diff --git a/include/lldb/Target/Language.h b/include/lldb/Target/Language.h index f81679f78129a..dd7db26f3ba6d 100644 --- a/include/lldb/Target/Language.h +++ b/include/lldb/Target/Language.h @@ -184,19 +184,16 @@ public: virtual const char *GetLanguageSpecificTypeLookupHelp(); // if an individual data formatter can apply to several types and cross a - // language boundary - // it makes sense for individual languages to want to customize the printing - // of values of that - // type by appending proper prefix/suffix information in language-specific - // ways + // language boundary it makes sense for individual languages to want to + // customize the printing of values of that type by appending proper + // prefix/suffix information in language-specific ways virtual bool GetFormatterPrefixSuffix(ValueObject &valobj, ConstString type_hint, std::string &prefix, std::string &suffix); // if a language has a custom format for printing variable declarations that - // it wants LLDB to honor - // it should return an appropriate closure here + // it wants LLDB to honor it should return an appropriate closure here virtual DumpValueObjectOptions::DeclPrintingHelper GetDeclPrintingHelper(); virtual LazyBool IsLogicalTrue(ValueObject &valobj, Status &error); @@ -206,11 +203,9 @@ public: virtual bool IsNilReference(ValueObject &valobj); // for a ValueObject of some "reference type", if the language provides a - // technique - // to decide whether the reference has ever been assigned to some object, this - // method - // will return true if such detection is possible, and if the reference has - // never been assigned + // technique to decide whether the reference has ever been assigned to some + // object, this method will return true if such detection is possible, and if + // the reference has never been assigned virtual bool IsUninitializedReference(ValueObject &valobj); virtual bool GetFunctionDisplayName(const SymbolContext *sc, diff --git a/include/lldb/Target/LanguageRuntime.h b/include/lldb/Target/LanguageRuntime.h index 98db941669c79..6537a8f6dd552 100644 --- a/include/lldb/Target/LanguageRuntime.h +++ b/include/lldb/Target/LanguageRuntime.h @@ -85,26 +85,23 @@ public: Address &address, Value::ValueType &value_type) = 0; - // This call should return a CompilerType given a generic type name - // and an ExecutionContextScope in which one can actually fetch - // any specialization information required. + // This call should return a CompilerType given a generic type name and an + // ExecutionContextScope in which one can actually fetch any specialization + // information required. virtual CompilerType GetConcreteType(ExecutionContextScope *exe_scope, ConstString abstract_type_name) { return CompilerType(); } // This should be a fast test to determine whether it is likely that this - // value would - // have a dynamic type. + // value would have a dynamic type. virtual bool CouldHaveDynamicValue(ValueObject &in_value) = 0; // The contract for GetDynamicTypeAndAddress() is to return a "bare-bones" - // dynamic type - // For instance, given a Base* pointer, GetDynamicTypeAndAddress() will return - // the type of - // Derived, not Derived*. The job of this API is to correct this misalignment - // between the - // static type and the discovered dynamic type + // dynamic type For instance, given a Base* pointer, + // GetDynamicTypeAndAddress() will return the type of Derived, not Derived*. + // The job of this API is to correct this misalignment between the static + // type and the discovered dynamic type virtual TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name, ValueObject &static_value) = 0; @@ -144,18 +141,16 @@ public: virtual void ModulesDidLoad(const ModuleList &module_list) {} - // Called by the Clang expression evaluation engine to allow runtimes to alter - // the set of target options provided to - // the compiler. - // If the options prototype is modified, runtimes must return true, false - // otherwise. + // Called by the Clang expression evaluation engine to allow runtimes to + // alter the set of target options provided to the compiler. If the options + // prototype is modified, runtimes must return true, false otherwise. virtual bool GetOverrideExprOptions(clang::TargetOptions &prototype) { return false; } // Called by ClangExpressionParser::PrepareForExecution to query for any - // custom LLVM IR passes - // that need to be run before an expression is assembled and run. + // custom LLVM IR passes that need to be run before an expression is + // assembled and run. virtual bool GetIRPasses(LLVMUserExpression::IRPasses &custom_passes) { return false; } diff --git a/include/lldb/Target/Memory.h b/include/lldb/Target/Memory.h index af6be15df9fb6..16d7b256a78e1 100644 --- a/include/lldb/Target/Memory.h +++ b/include/lldb/Target/Memory.h @@ -120,8 +120,8 @@ protected: //---------------------------------------------------------------------- // A class that can track allocated memory and give out allocated memory -// without us having to make an allocate/deallocate call every time we -// need some memory in a process that is being debugged. +// without us having to make an allocate/deallocate call every time we need +// some memory in a process that is being debugged. //---------------------------------------------------------------------- class AllocatedMemoryCache { public: diff --git a/include/lldb/Target/MemoryRegionInfo.h b/include/lldb/Target/MemoryRegionInfo.h index 0824b2442acc2..505ecfcfc5ae7 100644 --- a/include/lldb/Target/MemoryRegionInfo.h +++ b/include/lldb/Target/MemoryRegionInfo.h @@ -25,7 +25,7 @@ public: MemoryRegionInfo() : m_range(), m_read(eDontKnow), m_write(eDontKnow), m_execute(eDontKnow), - m_mapped(eDontKnow) {} + m_mapped(eDontKnow), m_flash(eDontKnow), m_blocksize(0) {} ~MemoryRegionInfo() {} @@ -58,9 +58,17 @@ public: void SetName(const char *name) { m_name = ConstString(name); } + OptionalBool GetFlash() const { return m_flash; } + + void SetFlash(OptionalBool val) { m_flash = val; } + + lldb::offset_t GetBlocksize() const { return m_blocksize; } + + void SetBlocksize(lldb::offset_t blocksize) { m_blocksize = blocksize; } + //---------------------------------------------------------------------- - // Get permissions as a uint32_t that is a mask of one or more bits from - // the lldb::Permissions + // Get permissions as a uint32_t that is a mask of one or more bits from the + // lldb::Permissions //---------------------------------------------------------------------- uint32_t GetLLDBPermissions() const { uint32_t permissions = 0; @@ -74,8 +82,8 @@ public: } //---------------------------------------------------------------------- - // Set permissions from a uint32_t that contains one or more bits from - // the lldb::Permissions + // Set permissions from a uint32_t that contains one or more bits from the + // lldb::Permissions //---------------------------------------------------------------------- void SetLLDBPermissions(uint32_t permissions) { m_read = (permissions & lldb::ePermissionsReadable) ? eYes : eNo; @@ -98,6 +106,8 @@ protected: OptionalBool m_execute; OptionalBool m_mapped; ConstString m_name; + OptionalBool m_flash; + lldb::offset_t m_blocksize; }; } diff --git a/include/lldb/Target/ModuleCache.h b/include/lldb/Target/ModuleCache.h index 4959ee8ea0a3f..a060937e0614a 100644 --- a/include/lldb/Target/ModuleCache.h +++ b/include/lldb/Target/ModuleCache.h @@ -28,10 +28,10 @@ class UUID; //---------------------------------------------------------------------- /// @class ModuleCache ModuleCache.h "lldb/Target/ModuleCache.h" -/// @brief A module cache class. +/// A module cache class. /// -/// Caches locally modules that are downloaded from remote targets. -/// Each cached module maintains 2 views: +/// Caches locally modules that are downloaded from remote targets. Each +/// cached module maintains 2 views: /// - UUID view: /// /${CACHE_ROOT}/${PLATFORM_NAME}/.cache/${UUID}/${MODULE_FILENAME} /// - Sysroot view: @@ -42,7 +42,8 @@ class UUID; /// /// Example: /// UUID view : -/// /tmp/lldb/remote-linux/.cache/30C94DC6-6A1F-E951-80C3-D68D2B89E576-D5AE213C/libc.so.6 +/// /tmp/lldb/remote- +/// linux/.cache/30C94DC6-6A1F-E951-80C3-D68D2B89E576-D5AE213C/libc.so.6 /// Sysroot view: /tmp/lldb/remote-linux/ubuntu/lib/x86_64-linux-gnu/libc.so.6 //---------------------------------------------------------------------- diff --git a/include/lldb/Target/ObjCLanguageRuntime.h b/include/lldb/Target/ObjCLanguageRuntime.h index 97a2a731581a8..6f8354ea3a277 100644 --- a/include/lldb/Target/ObjCLanguageRuntime.h +++ b/include/lldb/Target/ObjCLanguageRuntime.h @@ -48,10 +48,9 @@ public: class ClassDescriptor; typedef std::shared_ptr<ClassDescriptor> ClassDescriptorSP; - // the information that we want to support retrieving from an ObjC class - // this needs to be pure virtual since there are at least 2 different - // implementations - // of the runtime, and more might come + // the information that we want to support retrieving from an ObjC class this + // needs to be pure virtual since there are at least 2 different + // implementations of the runtime, and more might come class ClassDescriptor { public: ClassDescriptor() @@ -66,8 +65,8 @@ public: virtual ClassDescriptorSP GetMetaclass() const = 0; - // virtual if any implementation has some other version-specific rules - // but for the known v1/v2 this is all that needs to be done + // virtual if any implementation has some other version-specific rules but + // for the known v1/v2 this is all that needs to be done virtual bool IsKVO() { if (m_is_kvo == eLazyBoolCalculate) { const char *class_name = GetClassName().AsCString(); @@ -78,8 +77,8 @@ public: return (m_is_kvo == eLazyBoolYes); } - // virtual if any implementation has some other version-specific rules - // but for the known v1/v2 this is all that needs to be done + // virtual if any implementation has some other version-specific rules but + // for the known v1/v2 this is all that needs to be done virtual bool IsCFType() { if (m_is_cf == eLazyBoolCalculate) { const char *class_name = GetClassName().AsCString(); @@ -268,15 +267,14 @@ public: virtual DeclVendor *GetDeclVendor() { return nullptr; } // Finds the byte offset of the child_type ivar in parent_type. If it can't - // find the - // offset, returns LLDB_INVALID_IVAR_OFFSET. + // find the offset, returns LLDB_INVALID_IVAR_OFFSET. virtual size_t GetByteOffsetForIvar(CompilerType &parent_qual_type, const char *ivar_name); - // Given the name of an Objective-C runtime symbol (e.g., ivar offset symbol), - // try to determine from the runtime what the value of that symbol would be. - // Useful when the underlying binary is stripped. + // Given the name of an Objective-C runtime symbol (e.g., ivar offset + // symbol), try to determine from the runtime what the value of that symbol + // would be. Useful when the underlying binary is stripped. virtual lldb::addr_t LookupRuntimeSymbol(const ConstString &name) { return LLDB_INVALID_ADDRESS; } @@ -334,8 +332,7 @@ protected: private: // We keep a map of <Class,Selector>->Implementation so we don't have to call - // the resolver - // function over and over. + // the resolver function over and over. // FIXME: We need to watch for the loading of Protocols, and flush the cache // for any diff --git a/include/lldb/Target/OperatingSystem.h b/include/lldb/Target/OperatingSystem.h index 24ded3f697230..fe4fdee182f4b 100644 --- a/include/lldb/Target/OperatingSystem.h +++ b/include/lldb/Target/OperatingSystem.h @@ -22,13 +22,13 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class OperatingSystem OperatingSystem.h "lldb/Target/OperatingSystem.h" -/// @brief A plug-in interface definition class for halted OS helpers. +/// A plug-in interface definition class for halted OS helpers. /// /// Halted OS plug-ins can be used by any process to locate and create /// OS objects, like threads, during the lifetime of a debug session. /// This is commonly used when attaching to an operating system that is -/// halted, such as when debugging over JTAG or connecting to low level -/// kernel debug services. +/// halted, such as when debugging over JTAG or connecting to low level kernel +/// debug services. //---------------------------------------------------------------------- class OperatingSystem : public PluginInterface { @@ -36,9 +36,8 @@ public: //------------------------------------------------------------------ /// Find a halted OS plugin for a given process. /// - /// Scans the installed OperatingSystem plug-ins and tries to find - /// an instance that matches the current target triple and - /// executable. + /// Scans the installed OperatingSystem plug-ins and tries to find an + /// instance that matches the current target triple and executable. /// /// @param[in] process /// The process for which to try and locate a halted OS diff --git a/include/lldb/Target/PathMappingList.h b/include/lldb/Target/PathMappingList.h index b1b551f2d24d9..a5ee3265a223a 100644 --- a/include/lldb/Target/PathMappingList.h +++ b/include/lldb/Target/PathMappingList.h @@ -90,7 +90,7 @@ public: bool RemapPath(llvm::StringRef path, std::string &new_path) const; bool RemapPath(const char *, std::string &) const = delete; - bool ReverseRemapPath(const ConstString &path, ConstString &new_path) const; + bool ReverseRemapPath(const FileSpec &file, FileSpec &fixed) const; //------------------------------------------------------------------ /// Finds a source file given a file spec using the path remappings. diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h index 6288a3ab684ff..217b945d29cd8 100644 --- a/include/lldb/Target/Platform.h +++ b/include/lldb/Target/Platform.h @@ -27,12 +27,10 @@ #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" #include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/Timeout.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-public.h" - -// TODO pull NativeDelegate class out of NativeProcessProtocol so we -// can just forward ref the NativeDelegate rather than include it here. -#include "lldb/Host/common/NativeProcessProtocol.h" +#include "llvm/Support/VersionTuple.h" namespace lldb_private { @@ -57,7 +55,7 @@ typedef llvm::SmallVector<lldb::addr_t, 6> MmapArgList; //---------------------------------------------------------------------- /// @class Platform Platform.h "lldb/Target/Platform.h" -/// @brief A plug-in interface definition class for debug platform that +/// A plug-in interface definition class for debug platform that /// includes many platform abilities such as: /// @li getting platform information such as supported architectures, /// supported binary file formats and more @@ -78,8 +76,8 @@ public: //------------------------------------------------------------------ /// Destructor. /// - /// The destructor is virtual since this class is designed to be - /// inherited from by the plug-in instance. + /// The destructor is virtual since this class is designed to be inherited + /// from by the plug-in instance. //------------------------------------------------------------------ ~Platform() override; @@ -92,13 +90,13 @@ public: //------------------------------------------------------------------ /// Get the native host platform plug-in. /// - /// There should only be one of these for each host that LLDB runs - /// upon that should be statically compiled in and registered using - /// preprocessor macros or other similar build mechanisms in a + /// There should only be one of these for each host that LLDB runs upon that + /// should be statically compiled in and registered using preprocessor + /// macros or other similar build mechanisms in a /// PlatformSubclass::Initialize() function. /// - /// This platform will be used as the default platform when launching - /// or attaching to processes unless another platform is specified. + /// This platform will be used as the default platform when launching or + /// attaching to processes unless another platform is specified. //------------------------------------------------------------------ static lldb::PlatformSP GetHostPlatform(); @@ -127,8 +125,8 @@ public: //------------------------------------------------------------------ /// Find a platform plugin for a given process. /// - /// Scans the installed Platform plug-ins and tries to find - /// an instance that can be used for \a process + /// Scans the installed Platform plug-ins and tries to find an instance that + /// can be used for \a process /// /// @param[in] process /// The process for which to try and locate a platform @@ -142,19 +140,17 @@ public: // FindPlugin (Process *process, const ConstString &plugin_name); //------------------------------------------------------------------ - /// Set the target's executable based off of the existing - /// architecture information in \a target given a path to an - /// executable \a exe_file. + /// Set the target's executable based off of the existing architecture + /// information in \a target given a path to an executable \a exe_file. /// - /// Each platform knows the architectures that it supports and can - /// select the correct architecture slice within \a exe_file by - /// inspecting the architecture in \a target. If the target had an - /// architecture specified, then in can try and obey that request - /// and optionally fail if the architecture doesn't match up. - /// If no architecture is specified, the platform should select the - /// default architecture from \a exe_file. Any application bundles - /// or executable wrappers can also be inspected for the actual - /// application binary within the bundle that should be used. + /// Each platform knows the architectures that it supports and can select + /// the correct architecture slice within \a exe_file by inspecting the + /// architecture in \a target. If the target had an architecture specified, + /// then in can try and obey that request and optionally fail if the + /// architecture doesn't match up. If no architecture is specified, the + /// platform should select the default architecture from \a exe_file. Any + /// application bundles or executable wrappers can also be inspected for the + /// actual application binary within the bundle that should be used. /// /// @return /// Returns \b true if this Platform plug-in was able to find @@ -167,10 +163,10 @@ public: //------------------------------------------------------------------ /// Find a symbol file given a symbol file module specification. /// - /// Each platform might have tricks to find symbol files for an - /// executable given information in a symbol file ModuleSpec. Some - /// platforms might also support symbol files that are bundles and - /// know how to extract the right symbol file given a bundle. + /// Each platform might have tricks to find symbol files for an executable + /// given information in a symbol file ModuleSpec. Some platforms might also + /// support symbol files that are bundles and know how to extract the right + /// symbol file given a bundle. /// /// @param[in] target /// The target in which we are trying to resolve the symbol file. @@ -215,9 +211,8 @@ public: FileSpec &sym_file); //------------------------------------------------------------------ - /// Resolves the FileSpec to a (possibly) remote path. Remote - /// platforms must override this to resolve to a path on the remote - /// side. + /// Resolves the FileSpec to a (possibly) remote path. Remote platforms must + /// override this to resolve to a path on the remote side. //------------------------------------------------------------------ virtual bool ResolveRemotePath(const FileSpec &platform_path, FileSpec &resolved_platform_path); @@ -225,17 +220,15 @@ public: //------------------------------------------------------------------ /// Get the OS version from a connected platform. /// - /// Some platforms might not be connected to a remote platform, but - /// can figure out the OS version for a process. This is common for - /// simulator platforms that will run native programs on the current - /// host, but the simulator might be simulating a different OS. The - /// \a process parameter might be specified to help to determine - /// the OS version. + /// Some platforms might not be connected to a remote platform, but can + /// figure out the OS version for a process. This is common for simulator + /// platforms that will run native programs on the current host, but the + /// simulator might be simulating a different OS. The \a process parameter + /// might be specified to help to determine the OS version. //------------------------------------------------------------------ - virtual bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update, - Process *process = nullptr); + virtual llvm::VersionTuple GetOSVersion(Process *process = nullptr); - bool SetOSVersion(uint32_t major, uint32_t minor, uint32_t update); + bool SetOSVersion(llvm::VersionTuple os_version); bool GetOSBuildString(std::string &s); @@ -253,19 +246,19 @@ public: //------------------------------------------------------------------ /// Report the current status for this platform. /// - /// The returned string usually involves returning the OS version - /// (if available), and any SDK directory that might be being used - /// for local file caching, and if connected a quick blurb about - /// what this platform is connected to. + /// The returned string usually involves returning the OS version (if + /// available), and any SDK directory that might be being used for local + /// file caching, and if connected a quick blurb about what this platform is + /// connected to. //------------------------------------------------------------------ virtual void GetStatus(Stream &strm); //------------------------------------------------------------------ // Subclasses must be able to fetch the current OS version // - // Remote classes must be connected for this to succeed. Local - // subclasses don't need to override this function as it will just - // call the HostInfo::GetOSVersion(). + // Remote classes must be connected for this to succeed. Local subclasses + // don't need to override this function as it will just call the + // HostInfo::GetOSVersion(). //------------------------------------------------------------------ virtual bool GetRemoteOSVersion() { return false; } @@ -295,8 +288,8 @@ public: //------------------------------------------------------------------ /// Locate a file for a platform. /// - /// The default implementation of this function will return the same - /// file patch in \a local_file as was in \a platform_file. + /// The default implementation of this function will return the same file + /// patch in \a local_file as was in \a platform_file. /// /// @param[in] platform_file /// The platform file path to locate and cache locally. @@ -326,8 +319,8 @@ public: //---------------------------------------------------------------------- // Locate the scripting resource given a module specification. // - // Locating the file should happen only on the local computer or using - // the current computers global settings. + // Locating the file should happen only on the local computer or using the + // current computers global settings. //---------------------------------------------------------------------- virtual FileSpecList LocateExecutableScriptingResources(Target *target, Module &module, @@ -347,8 +340,8 @@ public: virtual Status DisconnectRemote(); //------------------------------------------------------------------ - /// Get the platform's supported architectures in the order in which - /// they should be searched. + /// Get the platform's supported architectures in the order in which they + /// should be searched. /// /// @param[in] idx /// A zero based architecture index @@ -368,14 +361,14 @@ public: BreakpointSite *bp_site); //------------------------------------------------------------------ - /// Launch a new process on a platform, not necessarily for - /// debugging, it could be just for running the process. + /// Launch a new process on a platform, not necessarily for debugging, it + /// could be just for running the process. //------------------------------------------------------------------ virtual Status LaunchProcess(ProcessLaunchInfo &launch_info); //------------------------------------------------------------------ - /// Perform expansion of the command-line for this launch info - /// This can potentially involve wildcard expansion + /// Perform expansion of the command-line for this launch info This can + /// potentially involve wildcard expansion // environment variable replacement, and whatever other // argument magic the platform defines as part of its typical // user experience @@ -388,28 +381,27 @@ public: virtual Status KillProcess(const lldb::pid_t pid); //------------------------------------------------------------------ - /// Lets a platform answer if it is compatible with a given - /// architecture and the target triple contained within. + /// Lets a platform answer if it is compatible with a given architecture and + /// the target triple contained within. //------------------------------------------------------------------ virtual bool IsCompatibleArchitecture(const ArchSpec &arch, bool exact_arch_match, ArchSpec *compatible_arch_ptr); //------------------------------------------------------------------ - /// Not all platforms will support debugging a process by spawning - /// somehow halted for a debugger (specified using the - /// "eLaunchFlagDebug" launch flag) and then attaching. If your - /// platform doesn't support this, override this function and return - /// false. + /// Not all platforms will support debugging a process by spawning somehow + /// halted for a debugger (specified using the "eLaunchFlagDebug" launch + /// flag) and then attaching. If your platform doesn't support this, + /// override this function and return false. //------------------------------------------------------------------ virtual bool CanDebugProcess() { return true; } //------------------------------------------------------------------ - /// Subclasses do not need to implement this function as it uses - /// the Platform::LaunchProcess() followed by Platform::Attach (). - /// Remote platforms will want to subclass this function in order - /// to be able to intercept STDIO and possibly launch a separate - /// process that will debug the debuggee. + /// Subclasses do not need to implement this function as it uses the + /// Platform::LaunchProcess() followed by Platform::Attach (). Remote + /// platforms will want to subclass this function in order to be able to + /// intercept STDIO and possibly launch a separate process that will debug + /// the debuggee. //------------------------------------------------------------------ virtual lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, @@ -426,11 +418,11 @@ public: //------------------------------------------------------------------ /// Attach to an existing process using a process ID. /// - /// Each platform subclass needs to implement this function and - /// attempt to attach to the process with the process ID of \a pid. - /// The platform subclass should return an appropriate ProcessSP - /// subclass that is attached to the process, or an empty shared - /// pointer with an appropriate error. + /// Each platform subclass needs to implement this function and attempt to + /// attach to the process with the process ID of \a pid. The platform + /// subclass should return an appropriate ProcessSP subclass that is + /// attached to the process, or an empty shared pointer with an appropriate + /// error. /// /// @param[in] pid /// The process ID that we should attempt to attach to. @@ -451,12 +443,11 @@ public: //------------------------------------------------------------------ /// Attach to an existing process by process name. /// - /// This function is not meant to be overridden by Process - /// subclasses. It will first call - /// Process::WillAttach (const char *) and if that returns \b - /// true, Process::DoAttach (const char *) will be called to - /// actually do the attach. If DoAttach returns \b true, then - /// Process::DidAttach() will be called. + /// This function is not meant to be overridden by Process subclasses. It + /// will first call Process::WillAttach (const char *) and if that returns + /// \b true, Process::DoAttach (const char *) will be called to actually do + /// the attach. If DoAttach returns \b true, then Process::DidAttach() will + /// be called. /// /// @param[in] process_name /// A process name to match against the current process list. @@ -471,8 +462,8 @@ public: // Status &error) = 0; //------------------------------------------------------------------ - // The base class Platform will take care of the host platform. - // Subclasses will need to fill in the remote case. + // The base class Platform will take care of the host platform. Subclasses + // will need to fill in the remote case. //------------------------------------------------------------------ virtual uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &proc_infos); @@ -480,15 +471,15 @@ public: virtual bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info); //------------------------------------------------------------------ - // Set a breakpoint on all functions that can end up creating a thread - // for this platform. This is needed when running expressions and - // also for process control. + // Set a breakpoint on all functions that can end up creating a thread for + // this platform. This is needed when running expressions and also for + // process control. //------------------------------------------------------------------ virtual lldb::BreakpointSP SetThreadCreationBreakpoint(Target &target); //------------------------------------------------------------------ - // Given a target, find the local SDK directory if one exists on the - // current host. + // Given a target, find the local SDK directory if one exists on the current + // host. //------------------------------------------------------------------ virtual lldb_private::ConstString GetSDKDirectory(lldb_private::Target &target) { @@ -517,9 +508,9 @@ public: } //--------------------------------------------------------------------------- - /// If the triple contains not specify the vendor, os, and environment parts, - /// we "augment" these using information from the platform and return the - /// resulting ArchSpec object. + /// If the triple contains not specify the vendor, os, and environment + /// parts, we "augment" these using information from the platform and return + /// the resulting ArchSpec object. //--------------------------------------------------------------------------- ArchSpec GetAugmentedArchSpec(llvm::StringRef triple); @@ -537,8 +528,8 @@ public: void SetSDKBuild(const ConstString &sdk_build) { m_sdk_build = sdk_build; } - // Override this to return true if your platform supports Clang modules. - // You may also need to override AddClangModuleCompilationOptions to pass the + // Override this to return true if your platform supports Clang modules. You + // may also need to override AddClangModuleCompilationOptions to pass the // right Clang flags for your platform. virtual bool SupportsModules() { return false; } @@ -553,9 +544,8 @@ public: bool SetWorkingDirectory(const FileSpec &working_dir); // There may be modules that we don't want to find by default for operations - // like "setting breakpoint by name". - // The platform will return "true" from this call if the passed in module - // happens to be one of these. + // like "setting breakpoint by name". The platform will return "true" from + // this call if the passed in module happens to be one of these. virtual bool ModuleIsExcludedForUnconstrainedSearches(Target &target, @@ -610,11 +600,11 @@ public: //---------------------------------------------------------------------- /// Install a file or directory to the remote system. /// - /// Install is similar to Platform::PutFile(), but it differs in that if - /// an application/framework/shared library is installed on a remote - /// platform and the remote platform requires something to be done to - /// register the application/framework/shared library, then this extra - /// registration can be done. + /// Install is similar to Platform::PutFile(), but it differs in that if an + /// application/framework/shared library is installed on a remote platform + /// and the remote platform requires something to be done to register the + /// application/framework/shared library, then this extra registration can + /// be done. /// /// @param[in] src /// The source file/directory to install on the remote system. @@ -633,7 +623,7 @@ public: //---------------------------------------------------------------------- virtual Status Install(const FileSpec &src, const FileSpec &dst); - virtual size_t GetEnvironment(StringList &environment); + virtual Environment GetEnvironment(); virtual bool GetFileExists(const lldb_private::FileSpec &file_spec); @@ -687,8 +677,7 @@ public: // the process to exit std::string *command_output, // Pass nullptr if you don't want the command output - uint32_t timeout_sec); // Timeout in seconds to wait for shell program to - // finish + const Timeout<std::micro> &timeout); virtual void SetLocalCacheDirectory(const char *local); @@ -710,12 +699,12 @@ public: //------------------------------------------------------------------ /// Locate a queue name given a thread's qaddr /// - /// On a system using libdispatch ("Grand Central Dispatch") style - /// queues, a thread may be associated with a GCD queue or not, - /// and a queue may be associated with multiple threads. - /// The process/thread must provide a way to find the "dispatch_qaddr" - /// for each thread, and from that dispatch_qaddr this Platform method - /// will locate the queue name and provide that. + /// On a system using libdispatch ("Grand Central Dispatch") style queues, a + /// thread may be associated with a GCD queue or not, and a queue may be + /// associated with multiple threads. The process/thread must provide a way + /// to find the "dispatch_qaddr" for each thread, and from that + /// dispatch_qaddr this Platform method will locate the queue name and + /// provide that. /// /// @param[in] process /// A process is required for reading memory. @@ -736,12 +725,12 @@ public: //------------------------------------------------------------------ /// Locate a queue ID given a thread's qaddr /// - /// On a system using libdispatch ("Grand Central Dispatch") style - /// queues, a thread may be associated with a GCD queue or not, - /// and a queue may be associated with multiple threads. - /// The process/thread must provide a way to find the "dispatch_qaddr" - /// for each thread, and from that dispatch_qaddr this Platform method - /// will locate the queue ID and provide that. + /// On a system using libdispatch ("Grand Central Dispatch") style queues, a + /// thread may be associated with a GCD queue or not, and a queue may be + /// associated with multiple threads. The process/thread must provide a way + /// to find the "dispatch_qaddr" for each thread, and from that + /// dispatch_qaddr this Platform method will locate the queue ID and provide + /// that. /// /// @param[in] process /// A process is required for reading memory. @@ -761,12 +750,12 @@ public: //------------------------------------------------------------------ /// Provide a list of trap handler function names for this platform /// - /// The unwinder needs to treat trap handlers specially -- the stack - /// frame may not be aligned correctly for a trap handler (the kernel - /// often won't perturb the stack pointer, or won't re-align it properly, - /// in the process of calling the handler) and the frame above the handler - /// needs to be treated by the unwinder's "frame 0" rules instead of its - /// "middle of the stack frame" rules. + /// The unwinder needs to treat trap handlers specially -- the stack frame + /// may not be aligned correctly for a trap handler (the kernel often won't + /// perturb the stack pointer, or won't re-align it properly, in the process + /// of calling the handler) and the frame above the handler needs to be + /// treated by the unwinder's "frame 0" rules instead of its "middle of the + /// stack frame" rules. /// /// In a user process debugging scenario, the list of trap handlers is /// typically just "_sigtramp". @@ -782,12 +771,11 @@ public: virtual const std::vector<ConstString> &GetTrapHandlerSymbolNames(); //------------------------------------------------------------------ - /// Find a support executable that may not live within in the - /// standard locations related to LLDB. + /// Find a support executable that may not live within in the standard + /// locations related to LLDB. /// - /// Executable might exist within the Platform SDK directories, or - /// in standard tool directories within the current IDE that is - /// running LLDB. + /// Executable might exist within the Platform SDK directories, or in + /// standard tool directories within the current IDE that is running LLDB. /// /// @param[in] basename /// The basename of the executable to locate in the current @@ -801,19 +789,17 @@ public: //------------------------------------------------------------------ /// Allow the platform to set preferred memory cache line size. If non-zero - /// (and the user - /// has not set cache line size explicitly), this value will be used as the - /// cache line - /// size for memory reads. + /// (and the user has not set cache line size explicitly), this value will + /// be used as the cache line size for memory reads. //------------------------------------------------------------------ virtual uint32_t GetDefaultMemoryCacheLineSize() { return 0; } //------------------------------------------------------------------ /// Load a shared library into this process. /// - /// Try and load a shared library into the current process. This - /// call might fail in the dynamic loader plug-in says it isn't safe - /// to try and load shared libraries at the moment. + /// Try and load a shared library into the current process. This call might + /// fail in the dynamic loader plug-in says it isn't safe to try and load + /// shared libraries at the moment. /// /// @param[in] process /// The process to load the image. @@ -846,9 +832,49 @@ public: const lldb_private::FileSpec &remote_file, lldb_private::Status &error); + //------------------------------------------------------------------ + /// Load a shared library specified by base name into this process, + /// looking by hand along a set of paths. + /// + /// @param[in] process + /// The process to load the image. + /// + /// @param[in] library_name + /// The name of the library to look for. If library_name is an + /// absolute path, the basename will be extracted and searched for + /// along the paths. This emulates the behavior of the loader when + /// given an install name and a set (e.g. DYLD_LIBRARY_PATH provided) of + /// alternate paths. + /// + /// @param[in] path_list + /// The list of paths to use to search for the library. First + /// match wins. + /// + /// @param[out] error + /// An error object that gets filled in with any errors that + /// might occur when trying to load the shared library. + /// + /// @param[out] loaded_path + /// If non-null, the path to the dylib that was successfully loaded + /// is stored in this path. + /// + /// @return + /// A token that represents the shared library which can be + /// passed to UnloadImage. A value of + /// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared + /// library can't be opened. + //------------------------------------------------------------------ + uint32_t LoadImageUsingPaths(lldb_private::Process *process, + const lldb_private::FileSpec &library_name, + const std::vector<std::string> &paths, + lldb_private::Status &error, + lldb_private::FileSpec *loaded_path); + virtual uint32_t DoLoadImage(lldb_private::Process *process, const lldb_private::FileSpec &remote_file, - lldb_private::Status &error); + const std::vector<std::string> *paths, + lldb_private::Status &error, + lldb_private::FileSpec *loaded_path = nullptr); virtual Status UnloadImage(lldb_private::Process *process, uint32_t image_token); @@ -856,8 +882,8 @@ public: //------------------------------------------------------------------ /// Connect to all processes waiting for a debugger to attach /// - /// If the platform have a list of processes waiting for a debugger - /// to connect to them then connect to all of these pending processes. + /// If the platform have a list of processes waiting for a debugger to + /// connect to them then connect to all of these pending processes. /// /// @param[in] debugger /// The debugger used for the connect. @@ -874,11 +900,11 @@ public: protected: bool m_is_host; - // Set to true when we are able to actually set the OS version while - // being connected. For remote platforms, we might set the version ahead - // of time before we actually connect and this version might change when - // we actually connect to a remote platform. For the host platform this - // will be set to the once we call HostInfo::GetOSVersion(). + // Set to true when we are able to actually set the OS version while being + // connected. For remote platforms, we might set the version ahead of time + // before we actually connect and this version might change when we actually + // connect to a remote platform. For the host platform this will be set to + // the once we call HostInfo::GetOSVersion(). bool m_os_version_set_while_connected; bool m_system_arch_set_while_connected; ConstString @@ -888,9 +914,7 @@ protected: // modules that have no install path set std::string m_remote_url; std::string m_name; - uint32_t m_major_os_version; - uint32_t m_minor_os_version; - uint32_t m_update_os_version; + llvm::VersionTuple m_os_version; ArchSpec m_system_arch; // The architecture of the kernel or the remote platform typedef std::map<uint32_t, ConstString> IDToNameMap; @@ -915,23 +939,22 @@ protected: //------------------------------------------------------------------ /// Ask the Platform subclass to fill in the list of trap handler names /// - /// For most Unix user process environments, this will be a single - /// function name, _sigtramp. More specialized environments may have - /// additional handler names. The unwinder code needs to know when a - /// trap handler is on the stack because the unwind rules for the frame - /// that caused the trap are different. + /// For most Unix user process environments, this will be a single function + /// name, _sigtramp. More specialized environments may have additional + /// handler names. The unwinder code needs to know when a trap handler is + /// on the stack because the unwind rules for the frame that caused the trap + /// are different. /// - /// The base class Platform ivar m_trap_handlers should be updated by - /// the Platform subclass when this method is called. If there are no + /// The base class Platform ivar m_trap_handlers should be updated by the + /// Platform subclass when this method is called. If there are no /// predefined trap handlers, this method may be a no-op. //------------------------------------------------------------------ virtual void CalculateTrapHandlerSymbolNames() = 0; const char *GetCachedUserName(uint32_t uid) { std::lock_guard<std::mutex> guard(m_mutex); - // return the empty string if our string is NULL - // so we can tell when things were in the negative - // cached (didn't find a valid user name, don't keep + // return the empty string if our string is NULL so we can tell when things + // were in the negative cached (didn't find a valid user name, don't keep // trying) const auto pos = m_uid_map.find(uid); return ((pos != m_uid_map.end()) ? pos->second.AsCString("") : nullptr); @@ -961,9 +984,8 @@ protected: const char *GetCachedGroupName(uint32_t gid) { std::lock_guard<std::mutex> guard(m_mutex); - // return the empty string if our string is NULL - // so we can tell when things were in the negative - // cached (didn't find a valid group name, don't keep + // return the empty string if our string is NULL so we can tell when things + // were in the negative cached (didn't find a valid group name, don't keep // trying) const auto pos = m_gid_map.find(gid); return ((pos != m_gid_map.end()) ? pos->second.AsCString("") : nullptr); @@ -1057,11 +1079,10 @@ public: //------------------------------------------------------------------ /// Select the active platform. /// - /// In order to debug remotely, other platform's can be remotely - /// connected to and set as the selected platform for any subsequent - /// debugging. This allows connection to remote targets and allows - /// the ability to discover process info, launch and attach to remote - /// processes. + /// In order to debug remotely, other platform's can be remotely connected + /// to and set as the selected platform for any subsequent debugging. This + /// allows connection to remote targets and allows the ability to discover + /// process info, launch and attach to remote processes. //------------------------------------------------------------------ lldb::PlatformSP GetSelectedPlatform() { std::lock_guard<std::recursive_mutex> guard(m_mutex); diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h index 16f37f4dd5dcb..66ac5a692522b 100644 --- a/include/lldb/Target/Process.h +++ b/include/lldb/Target/Process.h @@ -38,6 +38,7 @@ #include "lldb/Host/HostThread.h" #include "lldb/Host/ProcessRunLock.h" #include "lldb/Interpreter/Options.h" +#include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/InstrumentationRuntime.h" #include "lldb/Target/Memory.h" @@ -53,6 +54,7 @@ #include "lldb/lldb-private.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/VersionTuple.h" namespace lldb_private { @@ -113,8 +115,8 @@ typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP; //---------------------------------------------------------------------- // ProcessInstanceInfo // -// Describes an existing process and any discoverable information that -// pertains to that process. +// Describes an existing process and any discoverable information that pertains +// to that process. //---------------------------------------------------------------------- class ProcessInstanceInfo : public ProcessInfo { public: @@ -278,7 +280,8 @@ protected: class ProcessLaunchCommandOptions : public Options { public: ProcessLaunchCommandOptions() : Options() { - // Keep default values of all options in one place: OptionParsingStarting () + // Keep default values of all options in one place: OptionParsingStarting + // () OptionParsingStarting(nullptr); } @@ -316,7 +319,8 @@ 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, false, + FileSpec::Style::native); } ProcessInstanceInfo &GetProcessInfo() { return m_match_info; } @@ -388,10 +392,8 @@ protected: }; // This class tracks the Modification state of the process. Things that can -// currently modify -// the program are running the program (which will up the StopID) and writing -// memory (which -// will up the MemoryID.) +// currently modify the program are running the program (which will up the +// StopID) and writing memory (which will up the MemoryID.) // FIXME: Should we also include modification of register states? class ProcessModID { @@ -498,7 +500,7 @@ inline bool operator!=(const ProcessModID &lhs, const ProcessModID &rhs) { //---------------------------------------------------------------------- /// @class Process Process.h "lldb/Target/Process.h" -/// @brief A plug-in interface definition class for debugging a process. +/// A plug-in interface definition class for debugging a process. //---------------------------------------------------------------------- class Process : public std::enable_shared_from_this<Process>, public ProcessProperties, @@ -539,12 +541,11 @@ public: enum Warnings { eWarningsOptimization = 1 }; typedef Range<lldb::addr_t, lldb::addr_t> LoadRange; - // We use a read/write lock to allow on or more clients to - // access the process state while the process is stopped (reader). - // We lock the write lock to control access to the process - // while it is running (readers, or clients that want the process - // stopped can block waiting for the process to stop, or just - // try to lock it to see if they can immediately access the stopped + // We use a read/write lock to allow on or more clients to access the process + // state while the process is stopped (reader). We lock the write lock to + // control access to the process while it is running (readers, or clients + // that want the process stopped can block waiting for the process to stop, + // or just try to lock it to see if they can immediately access the stopped // process. If the try read lock fails, then the process is running. typedef ProcessRunLock::ProcessRunLocker StopLocker; @@ -560,8 +561,8 @@ public: /// A notification structure that can be used by clients to listen /// for changes in a process's lifetime. /// -/// @see RegisterNotificationCallbacks (const Notifications&) -/// @see UnregisterNotificationCallbacks (const Notifications&) +/// @see RegisterNotificationCallbacks (const Notifications&) @see +/// UnregisterNotificationCallbacks (const Notifications&) //------------------------------------------------------------------ #ifndef SWIG typedef struct { @@ -657,8 +658,8 @@ public: Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp); //------------------------------------------------------------------ - /// Construct with a shared pointer to a target, the Process listener, - /// and the appropriate UnixSignalsSP for the process. + /// Construct with a shared pointer to a target, the Process listener, and + /// the appropriate UnixSignalsSP for the process. //------------------------------------------------------------------ Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const lldb::UnixSignalsSP &unix_signals_sp); @@ -666,8 +667,8 @@ public: //------------------------------------------------------------------ /// Destructor. /// - /// The destructor is virtual since this class is designed to be - /// inherited from by the plug-in instance. + /// The destructor is virtual since this class is designed to be inherited + /// from by the plug-in instance. //------------------------------------------------------------------ ~Process() override; @@ -678,12 +679,12 @@ public: static const ProcessPropertiesSP &GetGlobalProperties(); //------------------------------------------------------------------ - /// Find a Process plug-in that can debug \a module using the - /// currently selected architecture. + /// Find a Process plug-in that can debug \a module using the currently + /// selected architecture. /// - /// Scans all loaded plug-in interfaces that implement versions of - /// the Process plug-in interface and returns the first instance - /// that can debug the file. + /// Scans all loaded plug-in interfaces that implement versions of the + /// Process plug-in interface and returns the first instance that can debug + /// the file. /// /// @param[in] module_sp /// The module shared pointer that this process will debug. @@ -704,11 +705,10 @@ public: /// Static function that can be used with the \b host function /// Host::StartMonitoringChildProcess (). /// - /// This function can be used by lldb_private::Process subclasses - /// when they want to watch for a local process and have its exit - /// status automatically set when the host child process exits. - /// Subclasses should call Host::StartMonitoringChildProcess () - /// with: + /// This function can be used by lldb_private::Process subclasses when they + /// want to watch for a local process and have its exit status automatically + /// set when the host child process exits. Subclasses should call + /// Host::StartMonitoringChildProcess () with: /// callback = Process::SetHostProcessExitStatus /// pid = Process::GetID() /// monitor_signals = false @@ -728,9 +728,9 @@ public: //------------------------------------------------------------------ /// Check if a plug-in instance can debug the file in \a module. /// - /// Each plug-in is given a chance to say whether it can debug - /// the file in \a module. If the Process plug-in instance can - /// debug a file on the current system, it should return \b true. + /// Each plug-in is given a chance to say whether it can debug the file in + /// \a module. If the Process plug-in instance can debug a file on the + /// current system, it should return \b true. /// /// @return /// Returns \b true if this Process plug-in instance can @@ -742,8 +742,8 @@ public: //------------------------------------------------------------------ /// This object is about to be destroyed, do any necessary cleanup. /// - /// Subclasses that override this method should always call this - /// superclass method. + /// Subclasses that override this method should always call this superclass + /// method. //------------------------------------------------------------------ virtual void Finalize(); @@ -757,13 +757,13 @@ public: bool IsValid() const { return !m_finalize_called; } //------------------------------------------------------------------ - /// Return a multi-word command object that can be used to expose - /// plug-in specific commands. + /// Return a multi-word command object that can be used to expose plug-in + /// specific commands. /// /// This object will be used to resolve plug-in commands and can be /// triggered by a call to: /// - /// (lldb) process commmand <args> + /// (lldb) process command <args> /// /// @return /// A CommandObject which can be one of the concrete subclasses @@ -775,16 +775,15 @@ public: //------------------------------------------------------------------ /// Launch a new process. /// - /// Launch a new process by spawning a new process using the - /// target object's executable module's file as the file to launch. + /// Launch a new process by spawning a new process using the target object's + /// executable module's file as the file to launch. /// - /// This function is not meant to be overridden by Process - /// subclasses. It will first call Process::WillLaunch (Module *) - /// and if that returns \b true, Process::DoLaunch (Module*, - /// char const *[],char const *[],const char *,const char *, - /// const char *) will be called to actually do the launching. If - /// DoLaunch returns \b true, then Process::DidLaunch() will be - /// called. + /// This function is not meant to be overridden by Process subclasses. It + /// will first call Process::WillLaunch (Module *) and if that returns \b + /// true, Process::DoLaunch (Module*, char const *[],char const *[],const + /// char *,const char *, const char *) will be called to actually do the + /// launching. If DoLaunch returns \b true, then Process::DidLaunch() will + /// be called. /// /// @param[in] launch_info /// Details regarding the environment, STDIN/STDOUT/STDERR @@ -807,13 +806,48 @@ public: } //------------------------------------------------------------------ + // FUTURE WORK: GetLoadImageUtilityFunction are the first use we've + // had of having other plugins cache data in the Process. This is handy for + // long-living plugins - like the Platform - which manage interactions whose + // lifetime is governed by the Process lifetime. If we find we need to do + // this more often, we should construct a general solution to the problem. + // The consensus suggestion was that we have a token based registry in the + // Process. Some undecided questions are (1) who manages the tokens. It's + // probably best that you add the element and get back a token that + // represents it. That will avoid collisions. But there may be some utility + // in the registerer controlling the token? (2) whether the thing added + // should be simply owned by Process, and just go away when it does (3) + // whether the registree should be notified of the Process' demise. + // + // We are postponing designing this till we have at least a second use case. + //------------------------------------------------------------------ + //------------------------------------------------------------------ + /// Get the cached UtilityFunction that assists in loading binary images + /// into the process. + /// + /// @param[in] platform + /// The platform fetching the UtilityFunction. + /// @param[in] factory + /// A function that will be called only once per-process in a + /// thread-safe way to create the UtilityFunction if it has not + /// been initialized yet. + /// + /// @return + /// The cached utility function or null if the platform is not the + /// same as the target's platform. + //------------------------------------------------------------------ + UtilityFunction *GetLoadImageUtilityFunction( + Platform *platform, + llvm::function_ref<std::unique_ptr<UtilityFunction>()> factory); + + //------------------------------------------------------------------ /// Get the dynamic loader plug-in for this process. /// - /// The default action is to let the DynamicLoader plug-ins check - /// the main executable and the DynamicLoader will select itself - /// automatically. Subclasses can override this if inspecting the - /// executable is not desired, or if Process subclasses can only - /// use a specific DynamicLoader plug-in. + /// The default action is to let the DynamicLoader plug-ins check the main + /// executable and the DynamicLoader will select itself automatically. + /// Subclasses can override this if inspecting the executable is not + /// desired, or if Process subclasses can only use a specific DynamicLoader + /// plug-in. //------------------------------------------------------------------ virtual DynamicLoader *GetDynamicLoader(); @@ -828,11 +862,11 @@ public: virtual const lldb::DataBufferSP GetAuxvData(); //------------------------------------------------------------------ - /// Sometimes processes know how to retrieve and load shared libraries. - /// This is normally done by DynamicLoader plug-ins, but sometimes the - /// connection to the process allows retrieving this information. The - /// dynamic loader plug-ins can use this function if they can't - /// determine the current shared library load state. + /// Sometimes processes know how to retrieve and load shared libraries. This + /// is normally done by DynamicLoader plug-ins, but sometimes the connection + /// to the process allows retrieving this information. The dynamic loader + /// plug-ins can use this function if they can't determine the current + /// shared library load state. /// /// @return /// The number of shared libraries that were loaded @@ -857,11 +891,10 @@ public: //------------------------------------------------------------------ /// Attach to an existing process using the process attach info. /// - /// This function is not meant to be overridden by Process - /// subclasses. It will first call WillAttach (lldb::pid_t) - /// or WillAttach (const char *), and if that returns \b - /// true, DoAttach (lldb::pid_t) or DoAttach (const char *) will - /// be called to actually do the attach. If DoAttach returns \b + /// This function is not meant to be overridden by Process subclasses. It + /// will first call WillAttach (lldb::pid_t) or WillAttach (const char *), + /// and if that returns \b true, DoAttach (lldb::pid_t) or DoAttach (const + /// char *) will be called to actually do the attach. If DoAttach returns \b /// true, then Process::DidAttach() will be called. /// /// @param[in] pid @@ -896,12 +929,11 @@ public: //------------------------------------------------------------------ /// Get the image information address for the current process. /// - /// Some runtimes have system functions that can help dynamic - /// loaders locate the dynamic loader information needed to observe - /// shared libraries being loaded or unloaded. This function is - /// in the Process interface (as opposed to the DynamicLoader - /// interface) to ensure that remote debugging can take advantage of - /// this functionality. + /// Some runtimes have system functions that can help dynamic loaders locate + /// the dynamic loader information needed to observe shared libraries being + /// loaded or unloaded. This function is in the Process interface (as + /// opposed to the DynamicLoader interface) to ensure that remote debugging + /// can take advantage of this functionality. /// /// @return /// The address of the dynamic loader information, or @@ -913,17 +945,16 @@ public: //------------------------------------------------------------------ /// Called when the process is about to broadcast a public stop. /// - /// There are public and private stops. Private stops are when the - /// process is doing things like stepping and the client doesn't - /// need to know about starts and stop that implement a thread plan. - /// Single stepping over a source line in code might end up being - /// implemented by one or more process starts and stops. Public stops - /// are when clients will be notified that the process is stopped. - /// These events typically trigger UI updates (thread stack frames to - /// be displayed, variables to be displayed, and more). This function - /// can be overriden and allows process subclasses to do something - /// before the eBroadcastBitStateChanged event is sent to public - /// clients. + /// There are public and private stops. Private stops are when the process + /// is doing things like stepping and the client doesn't need to know about + /// starts and stop that implement a thread plan. Single stepping over a + /// source line in code might end up being implemented by one or more + /// process starts and stops. Public stops are when clients will be notified + /// that the process is stopped. These events typically trigger UI updates + /// (thread stack frames to be displayed, variables to be displayed, and + /// more). This function can be overriden and allows process subclasses to + /// do something before the eBroadcastBitStateChanged event is sent to + /// public clients. //------------------------------------------------------------------ virtual void WillPublicStop() {} @@ -946,8 +977,8 @@ public: //------------------------------------------------------------------ /// Unregister for process and thread notifications. /// -/// Clients can unregister notification callbacks by passing a copy of -/// the original baton and callbacks in \a callbacks. +/// Clients can unregister notification callbacks by passing a copy of the +/// original baton and callbacks in \a callbacks. /// /// @param[in] callbacks /// A structure that contains the notification baton and @@ -967,25 +998,24 @@ public: // Built in Process Control functions //================================================================== //------------------------------------------------------------------ - /// Resumes all of a process's threads as configured using the - /// Thread run control functions. + /// Resumes all of a process's threads as configured using the Thread run + /// control functions. /// - /// Threads for a process should be updated with one of the run - /// control actions (resume, step, or suspend) that they should take - /// when the process is resumed. If no run control action is given - /// to a thread it will be resumed by default. + /// Threads for a process should be updated with one of the run control + /// actions (resume, step, or suspend) that they should take when the + /// process is resumed. If no run control action is given to a thread it + /// will be resumed by default. /// - /// This function is not meant to be overridden by Process - /// subclasses. This function will take care of disabling any - /// breakpoints that threads may be stopped at, single stepping, and - /// re-enabling breakpoints, and enabling the basic flow control - /// that the plug-in instances need not worry about. + /// This function is not meant to be overridden by Process subclasses. This + /// function will take care of disabling any breakpoints that threads may be + /// stopped at, single stepping, and re-enabling breakpoints, and enabling + /// the basic flow control that the plug-in instances need not worry about. /// - /// N.B. This function also sets the Write side of the Run Lock, - /// which is unset when the corresponding stop event is pulled off - /// the Public Event Queue. If you need to resume the process without - /// setting the Run Lock, use PrivateResume (though you should only do - /// that from inside the Process class. + /// N.B. This function also sets the Write side of the Run Lock, which is + /// unset when the corresponding stop event is pulled off the Public Event + /// Queue. If you need to resume the process without setting the Run Lock, + /// use PrivateResume (though you should only do that from inside the + /// Process class. /// /// @return /// Returns an error object. @@ -1001,11 +1031,10 @@ public: //------------------------------------------------------------------ /// Halts a running process. /// - /// This function is not meant to be overridden by Process - /// subclasses. - /// If the process is successfully halted, a eStateStopped - /// process event with GetInterrupted will be broadcast. If false, we will - /// halt the process with no events generated by the halt. + /// This function is not meant to be overridden by Process subclasses. If + /// the process is successfully halted, a eStateStopped process event with + /// GetInterrupted will be broadcast. If false, we will halt the process + /// with no events generated by the halt. /// /// @param[in] clear_thread_plans /// If true, when the process stops, clear all thread plans. @@ -1023,8 +1052,7 @@ public: //------------------------------------------------------------------ /// Detaches from a running or stopped process. /// - /// This function is not meant to be overridden by Process - /// subclasses. + /// This function is not meant to be overridden by Process subclasses. /// /// @param[in] keep_stopped /// If true, don't resume the process on detach. @@ -1035,11 +1063,10 @@ public: Status Detach(bool keep_stopped); //------------------------------------------------------------------ - /// Kills the process and shuts down all threads that were spawned - /// to track and monitor the process. + /// Kills the process and shuts down all threads that were spawned to track + /// and monitor the process. /// - /// This function is not meant to be overridden by Process - /// subclasses. + /// This function is not meant to be overridden by Process subclasses. /// /// @param[in] force_kill /// Whether lldb should force a kill (instead of a detach) from @@ -1057,8 +1084,7 @@ public: //------------------------------------------------------------------ /// Sends a process a UNIX signal \a signal. /// - /// This function is not meant to be overridden by Process - /// subclasses. + /// This function is not meant to be overridden by Process subclasses. /// /// @return /// Returns an error object. @@ -1076,8 +1102,7 @@ public: //------------------------------------------------------------------ /// Called before attaching to a process. /// - /// Allow Process plug-ins to execute some code before attaching a - /// process. + /// Allow Process plug-ins to execute some code before attaching a process. /// /// @return /// Returns an error object. @@ -1087,8 +1112,7 @@ public: //------------------------------------------------------------------ /// Called before attaching to a process. /// - /// Allow Process plug-ins to execute some code before attaching a - /// process. + /// Allow Process plug-ins to execute some code before attaching a process. /// /// @return /// Returns an error object. @@ -1173,33 +1197,31 @@ public: /// If you can figure out the process architecture after attach, fill it /// in here. /// - /// Allow Process plug-ins to execute some code after attaching to - /// a process. + /// Allow Process plug-ins to execute some code after attaching to a + /// process. //------------------------------------------------------------------ virtual void DidAttach(ArchSpec &process_arch) { process_arch.Clear(); } //------------------------------------------------------------------ /// Called after a process re-execs itself. /// - /// Allow Process plug-ins to execute some code after a process has - /// exec'ed itself. Subclasses typically should override DoDidExec() - /// as the lldb_private::Process class needs to remove its dynamic - /// loader, runtime, ABI and other plug-ins, as well as unload all - /// shared libraries. + /// Allow Process plug-ins to execute some code after a process has exec'ed + /// itself. Subclasses typically should override DoDidExec() as the + /// lldb_private::Process class needs to remove its dynamic loader, runtime, + /// ABI and other plug-ins, as well as unload all shared libraries. //------------------------------------------------------------------ virtual void DidExec(); //------------------------------------------------------------------ - /// Subclasses of Process should implement this function if they - /// need to do anything after a process exec's itself. + /// Subclasses of Process should implement this function if they need to do + /// anything after a process exec's itself. //------------------------------------------------------------------ virtual void DoDidExec() {} //------------------------------------------------------------------ /// Called before launching to a process. /// - /// Allow Process plug-ins to execute some code before launching a - /// process. + /// Allow Process plug-ins to execute some code before launching a process. /// /// @return /// Returns an error object. @@ -1209,9 +1231,9 @@ public: //------------------------------------------------------------------ /// Launch a new process. /// - /// Launch a new process by spawning a new process using - /// \a exe_module's file as the file to launch. Launch details are - /// provided in \a launch_info. + /// Launch a new process by spawning a new process using \a exe_module's + /// file as the file to launch. Launch details are provided in \a + /// launch_info. /// /// @param[in] exe_module /// The module from which to extract the file specification and @@ -1236,16 +1258,14 @@ public: //------------------------------------------------------------------ /// Called after launching a process. /// - /// Allow Process plug-ins to execute some code after launching - /// a process. + /// Allow Process plug-ins to execute some code after launching a process. //------------------------------------------------------------------ virtual void DidLaunch() {} //------------------------------------------------------------------ /// Called before resuming to a process. /// - /// Allow Process plug-ins to execute some code before resuming a - /// process. + /// Allow Process plug-ins to execute some code before resuming a process. /// /// @return /// Returns an error object. @@ -1253,13 +1273,13 @@ public: virtual Status WillResume() { return Status(); } //------------------------------------------------------------------ - /// Resumes all of a process's threads as configured using the - /// Thread run control functions. + /// Resumes all of a process's threads as configured using the Thread run + /// control functions. /// - /// Threads for a process should be updated with one of the run - /// control actions (resume, step, or suspend) that they should take - /// when the process is resumed. If no run control action is given - /// to a thread it will be resumed by default. + /// Threads for a process should be updated with one of the run control + /// actions (resume, step, or suspend) that they should take when the + /// process is resumed. If no run control action is given to a thread it + /// will be resumed by default. /// /// @return /// Returns \b true if the process successfully resumes using @@ -1280,16 +1300,14 @@ public: //------------------------------------------------------------------ /// Called after resuming a process. /// - /// Allow Process plug-ins to execute some code after resuming - /// a process. + /// Allow Process plug-ins to execute some code after resuming a process. //------------------------------------------------------------------ virtual void DidResume() {} //------------------------------------------------------------------ /// Called before halting to a process. /// - /// Allow Process plug-ins to execute some code before halting a - /// process. + /// Allow Process plug-ins to execute some code before halting a process. /// /// @return /// Returns an error object. @@ -1300,13 +1318,10 @@ public: /// Halts a running process. /// /// DoHalt must produce one and only one stop StateChanged event if it - /// actually - /// stops the process. If the stop happens through some natural event (for - /// instance a SIGSTOP), then forwarding that event will do. Otherwise, you - /// must - /// generate the event manually. This function is called from the context of - /// the - /// private state thread. + /// actually stops the process. If the stop happens through some natural + /// event (for instance a SIGSTOP), then forwarding that event will do. + /// Otherwise, you must generate the event manually. This function is called + /// from the context of the private state thread. /// /// @param[out] caused_stop /// If true, then this Halt caused the stop, otherwise, the @@ -1327,16 +1342,15 @@ public: //------------------------------------------------------------------ /// Called after halting a process. /// - /// Allow Process plug-ins to execute some code after halting - /// a process. + /// Allow Process plug-ins to execute some code after halting a process. //------------------------------------------------------------------ virtual void DidHalt() {} //------------------------------------------------------------------ /// Called before detaching from a process. /// - /// Allow Process plug-ins to execute some code before detaching - /// from a process. + /// Allow Process plug-ins to execute some code before detaching from a + /// process. /// /// @return /// Returns an error object. @@ -1361,8 +1375,8 @@ public: //------------------------------------------------------------------ /// Called after detaching from a process. /// - /// Allow Process plug-ins to execute some code after detaching - /// from a process. + /// Allow Process plug-ins to execute some code after detaching from a + /// process. //------------------------------------------------------------------ virtual void DidDetach() {} @@ -1371,8 +1385,8 @@ public: //------------------------------------------------------------------ /// Called before sending a signal to a process. /// - /// Allow Process plug-ins to execute some code before sending a - /// signal to a process. + /// Allow Process plug-ins to execute some code before sending a signal to a + /// process. /// /// @return /// Returns no error if it is safe to proceed with a call to @@ -1406,8 +1420,8 @@ public: //------------------------------------------------------------------ /// Called after sending a signal to a process. /// - /// Allow Process plug-ins to execute some code after sending a - /// signal to a process. + /// Allow Process plug-ins to execute some code after sending a signal to a + /// process. //------------------------------------------------------------------ virtual void DidSignal() {} @@ -1417,45 +1431,28 @@ public: /// event is taken from the queue... /// /// This callback is called as the event - /// is about to be queued up to allow Process plug-ins to execute - /// some code prior to clients being notified that a process was - /// stopped. Common operations include updating the thread list, - /// invalidating any thread state (registers, stack, etc) prior to - /// letting the notification go out. + /// is about to be queued up to allow Process plug-ins to execute some code + /// prior to clients being notified that a process was stopped. Common + /// operations include updating the thread list, invalidating any thread + /// state (registers, stack, etc) prior to letting the notification go out. /// //------------------------------------------------------------------ virtual void RefreshStateAfterStop() = 0; //------------------------------------------------------------------ - /// Sometimes the connection to a process can detect the host OS - /// version that the process is running on. The current platform - /// should be checked first in case the platform is connected, but - /// clients can fall back onto this function if the platform fails - /// to identify the host OS version. The platform should be checked - /// first in case you are running a simulator platform that might - /// itself be running natively, but have different heuristics for - /// figuring out which OS is is emulating. - /// - /// @param[out] major - /// The major OS version, or UINT32_MAX if it can't be determined - /// - /// @param[out] minor - /// The minor OS version, or UINT32_MAX if it can't be determined - /// - /// @param[out] update - /// The update OS version, or UINT32_MAX if it can't be determined + /// Sometimes the connection to a process can detect the host OS version + /// that the process is running on. The current platform should be checked + /// first in case the platform is connected, but clients can fall back onto + /// this function if the platform fails to identify the host OS version. The + /// platform should be checked first in case you are running a simulator + /// platform that might itself be running natively, but have different + /// heuristics for figuring out which OS is is emulating. /// /// @return - /// Returns \b true if the host OS version info was filled in - /// and \b false otherwise. + /// Returns the version tuple of the host OS. In case of failure an empty + /// VersionTuple is returner. //------------------------------------------------------------------ - virtual bool GetHostOSVersion(uint32_t &major, uint32_t &minor, - uint32_t &update) { - major = UINT32_MAX; - minor = UINT32_MAX; - update = UINT32_MAX; - return false; - } + virtual llvm::VersionTuple GetHostOSVersion() { return llvm::VersionTuple(); } //------------------------------------------------------------------ /// Get the target object pointer for this module. @@ -1464,7 +1461,7 @@ public: /// A Target object pointer to the target that owns this /// module. //------------------------------------------------------------------ - Target &GetTarget() { return *m_target_sp.lock(); } + Target &GetTarget() { return *m_target_wp.lock(); } //------------------------------------------------------------------ /// Get the const target object pointer for this module. @@ -1473,17 +1470,17 @@ public: /// A const Target object pointer to the target that owns this /// module. //------------------------------------------------------------------ - const Target &GetTarget() const { return *m_target_sp.lock(); } + const Target &GetTarget() const { return *m_target_wp.lock(); } //------------------------------------------------------------------ /// Flush all data in the process. /// - /// Flush the memory caches, all threads, and any other cached data - /// in the process. + /// Flush the memory caches, all threads, and any other cached data in the + /// process. /// - /// This function can be called after a world changing event like - /// adding a new symbol file, or after the process makes a large - /// context switch (from boot ROM to booted into an OS). + /// This function can be called after a world changing event like adding a + /// new symbol file, or after the process makes a large context switch (from + /// boot ROM to booted into an OS). //------------------------------------------------------------------ void Flush(); @@ -1516,22 +1513,23 @@ public: //------------------------------------------------------------------ // Notify this process class that modules got loaded. // - // If subclasses override this method, they must call this version - // before doing anything in the subclass version of the function. + // If subclasses override this method, they must call this version before + // doing anything in the subclass version of the function. //------------------------------------------------------------------ virtual void ModulesDidLoad(ModuleList &module_list); //------------------------------------------------------------------ /// Retrieve the list of shared libraries that are loaded for this process - /// This method is used on pre-macOS 10.12, pre-iOS 10, pre-tvOS 10, - /// pre-watchOS 3 systems. The following two methods are for newer versions - /// of those OSes. + /// This method is used on pre-macOS 10.12, pre-iOS 10, pre-tvOS 10, pre- + /// watchOS 3 systems. The following two methods are for newer versions of + /// those OSes. /// /// For certain platforms, the time it takes for the DynamicLoader plugin to /// read all of the shared libraries out of memory over a slow communication /// channel may be too long. In that instance, the gdb-remote stub may be - /// able to retrieve the necessary information about the solibs out of memory - /// and return a concise summary sufficient for the DynamicLoader plugin. + /// able to retrieve the necessary information about the solibs out of + /// memory and return a concise summary sufficient for the DynamicLoader + /// plugin. /// /// @param [in] image_list_address /// The address where the table of shared libraries is stored in memory, @@ -1555,16 +1553,14 @@ public: } // On macOS 10.12, tvOS 10, iOS 10, watchOS 3 and newer, debugserver can - // return - // the full list of loaded shared libraries without needing any input. + // return the full list of loaded shared libraries without needing any input. virtual lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos() { return StructuredData::ObjectSP(); } // On macOS 10.12, tvOS 10, iOS 10, watchOS 3 and newer, debugserver can - // return - // information about binaries given their load addresses. + // return information about binaries given their load addresses. virtual lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos( const std::vector<lldb::addr_t> &load_addresses) { return StructuredData::ObjectSP(); @@ -1574,21 +1570,20 @@ public: // Get information about the library shared cache, if that exists // // On macOS 10.12, tvOS 10, iOS 10, watchOS 3 and newer, debugserver can - // return - // information about the library shared cache (a set of standard libraries - // that are - // loaded at the same location for all processes on a system) in use. + // return information about the library shared cache (a set of standard + // libraries that are loaded at the same location for all processes on a + // system) in use. //------------------------------------------------------------------ virtual lldb_private::StructuredData::ObjectSP GetSharedCacheInfo() { return StructuredData::ObjectSP(); } //------------------------------------------------------------------ - /// Print a user-visible warning about a module being built with optimization + /// Print a user-visible warning about a module being built with + /// optimization /// - /// Prints a async warning message to the user one time per Module - /// where a function is found that was compiled with optimization, per - /// Process. + /// Prints a async warning message to the user one time per Module where a + /// function is found that was compiled with optimization, per Process. /// /// @param [in] sc /// A SymbolContext with eSymbolContextFunction and eSymbolContextModule @@ -1648,13 +1643,12 @@ public: //------------------------------------------------------------------ /// Set accessor for the process exit status (return code). /// - /// Sometimes a child exits and the exit can be detected by global - /// functions (signal handler for SIGCHLD for example). This - /// accessor allows the exit status to be set from an external - /// source. + /// Sometimes a child exits and the exit can be detected by global functions + /// (signal handler for SIGCHLD for example). This accessor allows the exit + /// status to be set from an external source. /// - /// Setting this will cause a eStateExited event to be posted to - /// the process event queue. + /// Setting this will cause a eStateExited event to be posted to the process + /// event queue. /// /// @param[in] exit_status /// The value for the process's return code. @@ -1673,11 +1667,10 @@ public: virtual bool IsAlive(); //------------------------------------------------------------------ - /// Before lldb detaches from a process, it warns the user that they are about - /// to lose their debug session. - /// In some cases, this warning doesn't need to be emitted -- for instance, - /// with core file debugging where - /// the user can reconstruct the "state" by simply re-running the debugger on + /// Before lldb detaches from a process, it warns the user that they are + /// about to lose their debug session. In some cases, this warning doesn't + /// need to be emitted -- for instance, with core file debugging where the + /// user can reconstruct the "state" by simply re-running the debugger on /// the core file. /// /// @return @@ -1688,10 +1681,9 @@ public: //------------------------------------------------------------------ /// Actually do the reading of memory from a process. /// - /// Subclasses must override this function and can return fewer - /// bytes than requested when memory requests are too large. This - /// class will break up the memory requests and keep advancing the - /// arguments along as needed. + /// Subclasses must override this function and can return fewer bytes than + /// requested when memory requests are too large. This class will break up + /// the memory requests and keep advancing the arguments along as needed. /// /// @param[in] vm_addr /// A virtual load address that indicates where to start reading @@ -1704,8 +1696,15 @@ public: /// A byte buffer that is at least \a size bytes long that /// will receive the memory bytes. /// + /// @param[out] error + /// An error that indicates the success or failure of this + /// operation. If error indicates success (error.Success()), + /// then the value returned can be trusted, otherwise zero + /// will be returned. + /// /// @return /// The number of bytes that were actually read into \a buf. + /// Zero is returned in the case of an error. //------------------------------------------------------------------ virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error) = 0; @@ -1713,13 +1712,12 @@ public: //------------------------------------------------------------------ /// Read of memory from a process. /// - /// This function will read memory from the current process's - /// address space and remove any traps that may have been inserted - /// into the memory. + /// This function will read memory from the current process's address space + /// and remove any traps that may have been inserted into the memory. /// - /// This function is not meant to be overridden by Process - /// subclasses, the subclasses should implement - /// Process::DoReadMemory (lldb::addr_t, size_t, void *). + /// This function is not meant to be overridden by Process subclasses, the + /// subclasses should implement Process::DoReadMemory (lldb::addr_t, size_t, + /// void *). /// /// @param[in] vm_addr /// A virtual load address that indicates where to start reading @@ -1732,12 +1730,18 @@ public: /// @param[in] size /// The number of bytes to read. /// + /// @param[out] error + /// An error that indicates the success or failure of this + /// operation. If error indicates success (error.Success()), + /// then the value returned can be trusted, otherwise zero + /// will be returned. + /// /// @return /// The number of bytes that were actually read into \a buf. If /// the returned number is greater than zero, yet less than \a /// size, then this function will get called again with \a /// vm_addr, \a buf, and \a size updated appropriately. Zero is - /// returned to indicate an error. + /// returned in the case of an error. //------------------------------------------------------------------ virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error); @@ -1745,12 +1749,12 @@ public: //------------------------------------------------------------------ /// Read a NULL terminated string from memory /// - /// This function will read a cache page at a time until a NULL - /// string terminator is found. It will stop reading if an aligned - /// sequence of NULL termination \a type_width bytes is not found - /// before reading \a cstr_max_len bytes. The results are always - /// guaranteed to be NULL terminated, and that no more than - /// (max_bytes - type_width) bytes will be read. + /// This function will read a cache page at a time until a NULL string + /// terminator is found. It will stop reading if an aligned sequence of NULL + /// termination \a type_width bytes is not found before reading \a + /// cstr_max_len bytes. The results are always guaranteed to be NULL + /// terminated, and that no more than (max_bytes - type_width) bytes will be + /// read. /// /// @param[in] vm_addr /// The virtual load address to start the memory read. @@ -1779,9 +1783,9 @@ public: /// /// This function will read a cache page at a time until the NULL /// C string terminator is found. It will stop reading if the NULL - /// termination byte isn't found before reading \a cstr_max_len - /// bytes, and the results are always guaranteed to be NULL - /// terminated (at most cstr_max_len - 1 bytes will be read). + /// termination byte isn't found before reading \a cstr_max_len bytes, and + /// the results are always guaranteed to be NULL terminated (at most + /// cstr_max_len - 1 bytes will be read). //------------------------------------------------------------------ size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr, size_t cstr_max_len, Status &error); @@ -1793,8 +1797,8 @@ public: Status &error); //------------------------------------------------------------------ - /// Reads an unsigned integer of the specified byte size from - /// process memory. + /// Reads an unsigned integer of the specified byte size from process + /// memory. /// /// @param[in] load_addr /// A load address of the integer to read. @@ -1862,13 +1866,12 @@ public: //------------------------------------------------------------------ /// Write all or part of a scalar value to memory. /// - /// The value contained in \a scalar will be swapped to match the - /// byte order of the process that is being debugged. If \a size is - /// less than the size of scalar, the least significant \a size bytes - /// from scalar will be written. If \a size is larger than the byte - /// size of scalar, then the extra space will be padded with zeros - /// and the scalar value will be placed in the least significant - /// bytes in memory. + /// The value contained in \a scalar will be swapped to match the byte order + /// of the process that is being debugged. If \a size is less than the size + /// of scalar, the least significant \a size bytes from scalar will be + /// written. If \a size is larger than the byte size of scalar, then the + /// extra space will be padded with zeros and the scalar value will be + /// placed in the least significant bytes in memory. /// /// @param[in] vm_addr /// A virtual load address that indicates where to start writing @@ -1901,13 +1904,13 @@ public: //------------------------------------------------------------------ /// Write memory to a process. /// - /// This function will write memory to the current process's - /// address space and maintain any traps that might be present due - /// to software breakpoints. + /// This function will write memory to the current process's address space + /// and maintain any traps that might be present due to software + /// breakpoints. /// - /// This function is not meant to be overridden by Process - /// subclasses, the subclasses should implement - /// Process::DoWriteMemory (lldb::addr_t, size_t, void *). + /// This function is not meant to be overridden by Process subclasses, the + /// subclasses should implement Process::DoWriteMemory (lldb::addr_t, + /// size_t, void *). /// /// @param[in] vm_addr /// A virtual load address that indicates where to start writing @@ -1930,9 +1933,9 @@ public: //------------------------------------------------------------------ /// Actually allocate memory in the process. /// - /// This function will allocate memory in the process's address - /// space. This can't rely on the generic function calling mechanism, - /// since that requires this function. + /// This function will allocate memory in the process's address space. This + /// can't rely on the generic function calling mechanism, since that + /// requires this function. /// /// @param[in] size /// The size of the allocation requested. @@ -1950,12 +1953,14 @@ public: return LLDB_INVALID_ADDRESS; } + virtual Status WriteObjectFile(std::vector<ObjectFile::LoadableData> entries); + //------------------------------------------------------------------ /// The public interface to allocating memory in the process. /// - /// This function will allocate memory in the process's address - /// space. This can't rely on the generic function calling mechanism, - /// since that requires this function. + /// This function will allocate memory in the process's address space. This + /// can't rely on the generic function calling mechanism, since that + /// requires this function. /// /// @param[in] size /// The size of the allocation requested. @@ -1979,9 +1984,9 @@ public: /// The public interface to allocating memory in the process, this also /// clears the allocated memory. /// - /// This function will allocate memory in the process's address - /// space. This can't rely on the generic function calling mechanism, - /// since that requires this function. + /// This function will allocate memory in the process's address space. This + /// can't rely on the generic function calling mechanism, since that + /// requires this function. /// /// @param[in] size /// The size of the allocation requested. @@ -2023,18 +2028,18 @@ public: /// Locate the memory region that contains load_addr. /// /// If load_addr is within the address space the process has mapped - /// range_info will be filled in with the start and end of that range - /// as well as the permissions for that range and range_info.GetMapped - /// will return true. + /// range_info will be filled in with the start and end of that range as + /// well as the permissions for that range and range_info.GetMapped will + /// return true. /// - /// If load_addr is outside any mapped region then range_info will - /// have its start address set to load_addr and the end of the - /// range will indicate the start of the next mapped range or be - /// set to LLDB_INVALID_ADDRESS if there are no valid mapped ranges - /// between load_addr and the end of the process address space. + /// If load_addr is outside any mapped region then range_info will have its + /// start address set to load_addr and the end of the range will indicate + /// the start of the next mapped range or be set to LLDB_INVALID_ADDRESS if + /// there are no valid mapped ranges between load_addr and the end of the + /// process address space. /// - /// GetMemoryRegionInfo will only return an error if it is - /// unimplemented for the current process. + /// GetMemoryRegionInfo will only return an error if it is unimplemented for + /// the current process. /// /// @param[in] load_addr /// The load address to query the range_info for. @@ -2087,9 +2092,9 @@ public: //------------------------------------------------------------------ /// Attempt to get the attributes for a region of memory in the process. /// - /// It may be possible for the remote debug server to inspect attributes - /// for a region of memory in the process, such as whether there is a - /// valid page of memory at a given address or whether that page is + /// It may be possible for the remote debug server to inspect attributes for + /// a region of memory in the process, such as whether there is a valid page + /// of memory at a given address or whether that page is /// readable/writable/executable by the process. /// /// @param[in] load_addr @@ -2109,8 +2114,8 @@ public: uint32_t &permissions); //------------------------------------------------------------------ - /// Determines whether executing JIT-compiled code in this process - /// is possible. + /// Determines whether executing JIT-compiled code in this process is + /// possible. /// /// @return /// True if execution of JIT code is possible; false otherwise. @@ -2118,8 +2123,7 @@ public: bool CanJIT(); //------------------------------------------------------------------ - /// Sets whether executing JIT-compiled code in this process - /// is possible. + /// Sets whether executing JIT-compiled code in this process is possible. /// /// @param[in] can_jit /// True if execution of JIT code is possible; false otherwise. @@ -2127,8 +2131,8 @@ public: void SetCanJIT(bool can_jit); //------------------------------------------------------------------ - /// Determines whether executing function calls using the interpreter - /// is possible for this process. + /// Determines whether executing function calls using the interpreter is + /// possible for this process. /// /// @return /// True if possible; false otherwise. @@ -2136,8 +2140,8 @@ public: bool CanInterpretFunctionCalls() { return m_can_interpret_function_calls; } //------------------------------------------------------------------ - /// Sets whether executing function calls using the interpreter - /// is possible for this process. + /// Sets whether executing function calls using the interpreter is possible + /// for this process. /// /// @param[in] can_interpret_function_calls /// True if possible; false otherwise. @@ -2147,8 +2151,8 @@ public: } //------------------------------------------------------------------ - /// Sets whether executing code in this process is possible. - /// This could be either through JIT or interpreting. + /// Sets whether executing code in this process is possible. This could be + /// either through JIT or interpreting. /// /// @param[in] can_run_code /// True if execution of code is possible; false otherwise. @@ -2158,8 +2162,8 @@ public: //------------------------------------------------------------------ /// Actually deallocate memory in the process. /// - /// This function will deallocate memory in the process's address - /// space that was allocated with AllocateMemory. + /// This function will deallocate memory in the process's address space that + /// was allocated with AllocateMemory. /// /// @param[in] ptr /// A return value from AllocateMemory, pointing to the memory you @@ -2179,8 +2183,8 @@ public: //------------------------------------------------------------------ /// The public interface to deallocating memory in the process. /// - /// This function will deallocate memory in the process's address - /// space that was allocated with AllocateMemory. + /// This function will deallocate memory in the process's address space that + /// was allocated with AllocateMemory. /// /// @param[in] ptr /// A return value from AllocateMemory, pointing to the memory you @@ -2194,20 +2198,19 @@ public: //------------------------------------------------------------------ /// Get any available STDOUT. /// - /// Calling this method is a valid operation only if all of the - /// following conditions are true: - /// 1) The process was launched, and not attached to. - /// 2) The process was not launched with eLaunchFlagDisableSTDIO. - /// 3) The process was launched without supplying a valid file path + /// Calling this method is a valid operation only if all of the following + /// conditions are true: 1) The process was launched, and not attached to. + /// 2) The process was not launched with eLaunchFlagDisableSTDIO. 3) The + /// process was launched without supplying a valid file path /// for STDOUT. /// - /// Note that the implementation will probably need to start a read - /// thread in the background to make sure that the pipe is drained - /// and the STDOUT buffered appropriately, to prevent the process - /// from deadlocking trying to write to a full buffer. + /// Note that the implementation will probably need to start a read thread + /// in the background to make sure that the pipe is drained and the STDOUT + /// buffered appropriately, to prevent the process from deadlocking trying + /// to write to a full buffer. /// - /// Events will be queued indicating that there is STDOUT available - /// that can be retrieved using this function. + /// Events will be queued indicating that there is STDOUT available that can + /// be retrieved using this function. /// /// @param[out] buf /// A buffer that will receive any STDOUT bytes that are @@ -2226,20 +2229,19 @@ public: //------------------------------------------------------------------ /// Get any available STDERR. /// - /// Calling this method is a valid operation only if all of the - /// following conditions are true: - /// 1) The process was launched, and not attached to. - /// 2) The process was not launched with eLaunchFlagDisableSTDIO. - /// 3) The process was launched without supplying a valid file path + /// Calling this method is a valid operation only if all of the following + /// conditions are true: 1) The process was launched, and not attached to. + /// 2) The process was not launched with eLaunchFlagDisableSTDIO. 3) The + /// process was launched without supplying a valid file path /// for STDERR. /// - /// Note that the implementation will probably need to start a read - /// thread in the background to make sure that the pipe is drained - /// and the STDERR buffered appropriately, to prevent the process - /// from deadlocking trying to write to a full buffer. + /// Note that the implementation will probably need to start a read thread + /// in the background to make sure that the pipe is drained and the STDERR + /// buffered appropriately, to prevent the process from deadlocking trying + /// to write to a full buffer. /// - /// Events will be queued indicating that there is STDERR available - /// that can be retrieved using this function. + /// Events will be queued indicating that there is STDERR available that can + /// be retrieved using this function. /// /// @param[in] buf /// A buffer that will receive any STDERR bytes that are @@ -2258,11 +2260,10 @@ public: //------------------------------------------------------------------ /// Puts data into this process's STDIN. /// - /// Calling this method is a valid operation only if all of the - /// following conditions are true: - /// 1) The process was launched, and not attached to. - /// 2) The process was not launched with eLaunchFlagDisableSTDIO. - /// 3) The process was launched without supplying a valid file path + /// Calling this method is a valid operation only if all of the following + /// conditions are true: 1) The process was launched, and not attached to. + /// 2) The process was not launched with eLaunchFlagDisableSTDIO. 3) The + /// process was launched without supplying a valid file path /// for STDIN. /// /// @param[in] buf @@ -2320,9 +2321,9 @@ public: } // This is implemented completely using the lldb::Process API. Subclasses - // don't need to implement this function unless the standard flow of - // read existing opcode, write breakpoint opcode, verify breakpoint opcode - // doesn't work for a specific process plug-in. + // don't need to implement this function unless the standard flow of read + // existing opcode, write breakpoint opcode, verify breakpoint opcode doesn't + // work for a specific process plug-in. virtual Status EnableSoftwareBreakpoint(BreakpointSite *bp_site); // This is implemented completely using the lldb::Process API. Subclasses @@ -2346,8 +2347,8 @@ public: Status EnableBreakpointSiteByID(lldb::user_id_t break_id); - // BreakpointLocations use RemoveOwnerFromBreakpointSite to remove - // themselves from the owner's list of this breakpoint sites. + // BreakpointLocations use RemoveOwnerFromBreakpointSite to remove themselves + // from the owner's list of this breakpoint sites. void RemoveOwnerFromBreakpointSite(lldb::user_id_t owner_id, lldb::user_id_t owner_loc_id, lldb::BreakpointSiteSP &bp_site_sp); @@ -2369,11 +2370,10 @@ public: ThreadList &GetThreadList() { return m_thread_list; } - // When ExtendedBacktraces are requested, the HistoryThreads that are - // created need an owner -- they're saved here in the Process. The - // threads in this list are not iterated over - driver programs need to - // request the extended backtrace calls starting from a root concrete - // thread one by one. + // When ExtendedBacktraces are requested, the HistoryThreads that are created + // need an owner -- they're saved here in the Process. The threads in this + // list are not iterated over - driver programs need to request the extended + // backtrace calls starting from a root concrete thread one by one. ThreadList &GetExtendedThreadList() { return m_extended_thread_list; } ThreadList::ThreadIterable Threads() { return m_thread_list.Threads(); } @@ -2385,10 +2385,9 @@ public: // Returns true if an index id has been assigned to a thread. bool HasAssignedIndexIDToThread(uint64_t sb_thread_id); - // Given a thread_id, it will assign a more reasonable index id for display to - // the user. - // If the thread_id has previously been assigned, the same index id will be - // used. + // Given a thread_id, it will assign a more reasonable index id for display + // to the user. If the thread_id has previously been assigned, the same index + // id will be used. uint32_t AssignIndexIDToThread(uint64_t thread_id); //------------------------------------------------------------------ @@ -2413,13 +2412,11 @@ public: lldb::StateType GetNextEvent(lldb::EventSP &event_sp); // Returns the process state when it is stopped. If specified, event_sp_ptr - // is set to the event which triggered the stop. If wait_always = false, - // and the process is already stopped, this function returns immediately. - // If the process is hijacked and use_run_lock is true (the default), then - // this + // is set to the event which triggered the stop. If wait_always = false, and + // the process is already stopped, this function returns immediately. If the + // process is hijacked and use_run_lock is true (the default), then this // function releases the run lock after the stop. Setting use_run_lock to - // false - // will avoid this behavior. + // false will avoid this behavior. lldb::StateType WaitForProcessToStop(const Timeout<std::micro> &timeout, lldb::EventSP *event_sp_ptr = nullptr, @@ -2433,14 +2430,13 @@ public: /// Waits for the process state to be running within a given msec timeout. /// /// The main purpose of this is to implement an interlock waiting for - /// HandlePrivateEvent - /// to push an IOHandler. + /// HandlePrivateEvent to push an IOHandler. /// - /// @param[in] timeout_msec + /// @param[in] timeout /// The maximum time length to wait for the process to transition to the - /// eStateRunning state, specified in milliseconds. + /// eStateRunning state. //-------------------------------------------------------------------------------------- - void SyncIOHandler(uint32_t iohandler_id, uint64_t timeout_msec); + void SyncIOHandler(uint32_t iohandler_id, const Timeout<std::micro> &timeout); lldb::StateType GetStateChangedEvents( lldb::EventSP &event_sp, const Timeout<std::micro> &timeout, @@ -2448,8 +2444,8 @@ public: hijack_listener); // Pass an empty ListenerSP to use builtin listener //-------------------------------------------------------------------------------------- - /// Centralize the code that handles and prints descriptions for process state - /// changes. + /// Centralize the code that handles and prints descriptions for process + /// state changes. /// /// @param[in] event_sp /// The process state changed event @@ -2494,8 +2490,8 @@ public: /// event, then make a new listener, set to listen to process events, and /// then call this with that listener. Then you will have to wait on that /// listener explicitly for events (rather than using the GetNextEvent & - /// WaitFor* - /// calls above. Be sure to call RestoreProcessEvents when you are done. + /// WaitFor* calls above. Be sure to call RestoreProcessEvents when you are + /// done. /// /// @param[in] listener /// This is the new listener to whom all process events will be delivered. @@ -2577,27 +2573,26 @@ public: void SetSTDIOFileDescriptor(int file_descriptor); //------------------------------------------------------------------ - // Add a permanent region of memory that should never be read or - // written to. This can be used to ensure that memory reads or writes - // to certain areas of memory never end up being sent to the - // DoReadMemory or DoWriteMemory functions which can improve - // performance. + // Add a permanent region of memory that should never be read or written to. + // This can be used to ensure that memory reads or writes to certain areas of + // memory never end up being sent to the DoReadMemory or DoWriteMemory + // functions which can improve performance. //------------------------------------------------------------------ void AddInvalidMemoryRegion(const LoadRange ®ion); //------------------------------------------------------------------ - // Remove a permanent region of memory that should never be read or - // written to that was previously added with AddInvalidMemoryRegion. + // Remove a permanent region of memory that should never be read or written + // to that was previously added with AddInvalidMemoryRegion. //------------------------------------------------------------------ bool RemoveInvalidMemoryRange(const LoadRange ®ion); //------------------------------------------------------------------ // If the setup code of a thread plan needs to do work that might involve - // calling a function in the target, it should not do that work directly - // in one of the thread plan functions (DidPush/WillResume) because - // such work needs to be handled carefully. Instead, put that work in - // a PreResumeAction callback, and register it with the process. It will - // get done before the actual "DoResume" gets called. + // calling a function in the target, it should not do that work directly in + // one of the thread plan functions (DidPush/WillResume) because such work + // needs to be handled carefully. Instead, put that work in a + // PreResumeAction callback, and register it with the process. It will get + // done before the actual "DoResume" gets called. //------------------------------------------------------------------ typedef bool(PreResumeActionCallback)(void *); @@ -2623,10 +2618,10 @@ public: GetInstrumentationRuntime(lldb::InstrumentationRuntimeType type); //------------------------------------------------------------------ - /// Try to fetch the module specification for a module with the - /// given file name and architecture. Process sub-classes have to - /// override this method if they support platforms where the - /// Platform object can't get the module spec for all module. + /// Try to fetch the module specification for a module with the given file + /// name and architecture. Process sub-classes have to override this method + /// if they support platforms where the Platform object can't get the module + /// spec for all module. /// /// @param[in] module_file_spec /// The file name of the module to get specification for. @@ -2650,8 +2645,8 @@ public: //------------------------------------------------------------------ /// Try to find the load address of a file. - /// The load address is defined as the address of the first memory - /// region what contains data mapped from the specified file. + /// The load address is defined as the address of the first memory region + /// what contains data mapped from the specified file. /// /// @param[in] file /// The name of the file whose load address we are looking for @@ -2678,12 +2673,11 @@ public: //------------------------------------------------------------------ /// Find the next branch instruction to set a breakpoint on /// - /// When instruction stepping through a source line, instead of - /// stepping through each instruction, we can put a breakpoint on - /// the next branch instruction (within the range of instructions - /// we are stepping through) and continue the process to there, - /// yielding significant performance benefits over instruction - /// stepping. + /// When instruction stepping through a source line, instead of stepping + /// through each instruction, we can put a breakpoint on the next branch + /// instruction (within the range of instructions we are stepping through) + /// and continue the process to there, yielding significant performance + /// benefits over instruction stepping. /// /// @param[in] default_stop_addr /// The address of the instruction where lldb would put a @@ -2710,8 +2704,8 @@ public: /// The default implementation here will always return an error indiciating /// the feature is unsupported. /// - /// StructuredDataPlugin implementations will call this to configure - /// a feature that has been reported as being supported. + /// StructuredDataPlugin implementations will call this to configure a + /// feature that has been reported as being supported. /// /// @param[in] type_name /// The StructuredData type name as previously discovered by @@ -2733,13 +2727,12 @@ public: const StructuredData::ObjectSP &config_sp); //------------------------------------------------------------------ - /// Broadcasts the given structured data object from the given - /// plugin. + /// Broadcasts the given structured data object from the given plugin. /// - /// StructuredDataPlugin instances can use this to optionally - /// broadcast any of their data if they want to make it available - /// for clients. The data will come in on the structured data - /// event bit (eBroadcastBitStructuredData). + /// StructuredDataPlugin instances can use this to optionally broadcast any + /// of their data if they want to make it available for clients. The data + /// will come in on the structured data event bit + /// (eBroadcastBitStructuredData). /// /// @param[in] object_sp /// The structured data object to broadcast. @@ -2752,12 +2745,12 @@ public: const lldb::StructuredDataPluginSP &plugin_sp); //------------------------------------------------------------------ - /// Returns the StructuredDataPlugin associated with a given type - /// name, if there is one. + /// Returns the StructuredDataPlugin associated with a given type name, if + /// there is one. /// /// There will only be a plugin for a given StructuredDataType if the - /// debugged process monitor claims that the feature is supported. - /// This is one way to tell whether a feature is available. + /// debugged process monitor claims that the feature is supported. This is + /// one way to tell whether a feature is available. /// /// @return /// The plugin if one is available for the specified feature; @@ -2767,17 +2760,14 @@ public: GetStructuredDataPlugin(const ConstString &type_name) const; //------------------------------------------------------------------ - /// Starts tracing with the configuration provided in options. To - /// enable tracing on the complete process the thread_id in the - /// options should be set to LLDB_INVALID_THREAD_ID. The API returns - /// a user_id which is needed by other API's that manipulate the - /// trace instance. - /// The handling of erroneous or unsupported configuration is left - /// to the trace technology implementations in the server, as they - /// could be returned as an error, or rounded to a valid - /// configuration to start tracing. In the later case the - /// GetTraceConfig should supply the actual used trace - /// configuration. + /// Starts tracing with the configuration provided in options. To enable + /// tracing on the complete process the thread_id in the options should be + /// set to LLDB_INVALID_THREAD_ID. The API returns a user_id which is needed + /// by other API's that manipulate the trace instance. The handling of + /// erroneous or unsupported configuration is left to the trace technology + /// implementations in the server, as they could be returned as an error, or + /// rounded to a valid configuration to start tracing. In the later case the + /// GetTraceConfig should supply the actual used trace configuration. //------------------------------------------------------------------ virtual lldb::user_id_t StartTrace(const TraceOptions &options, Status &error) { @@ -2786,25 +2776,23 @@ public: } //------------------------------------------------------------------ - /// Stops the tracing instance leading to deletion of the trace - /// data. The tracing instance is identified by the user_id which - /// is obtained when tracing was started from the StartTrace. - /// In case tracing of the complete process needs to be stopped - /// the thread_id should be set to LLDB_INVALID_THREAD_ID. - /// In the other case that tracing on an individual thread needs - /// to be stopped a thread_id can be supplied. + /// Stops the tracing instance leading to deletion of the trace data. The + /// tracing instance is identified by the user_id which is obtained when + /// tracing was started from the StartTrace. In case tracing of the complete + /// process needs to be stopped the thread_id should be set to + /// LLDB_INVALID_THREAD_ID. In the other case that tracing on an individual + /// thread needs to be stopped a thread_id can be supplied. //------------------------------------------------------------------ virtual Status StopTrace(lldb::user_id_t uid, lldb::tid_t thread_id) { return Status("Not implemented"); } //------------------------------------------------------------------ - /// Provides the trace data as raw bytes. A buffer needs to be - /// supplied to copy the trace data. The exact behavior of this API - /// may vary across trace technology, as some may support partial - /// reading of the trace data from a specified offset while some - /// may not. The thread_id should be used to select a particular - /// thread for trace extraction. + /// Provides the trace data as raw bytes. A buffer needs to be supplied to + /// copy the trace data. The exact behavior of this API may vary across + /// trace technology, as some may support partial reading of the trace data + /// from a specified offset while some may not. The thread_id should be used + /// to select a particular thread for trace extraction. //------------------------------------------------------------------ virtual Status GetData(lldb::user_id_t uid, lldb::tid_t thread_id, llvm::MutableArrayRef<uint8_t> &buffer, @@ -2823,12 +2811,12 @@ public: //------------------------------------------------------------------ /// API to obtain the trace configuration used by a trace instance. - /// Configurations that may be specific to some trace technology - /// should be stored in the custom parameters. The options are - /// transported to the server, which shall interpret accordingly. - /// The thread_id can be specified in the options to obtain the - /// configuration used by a specific thread. The thread_id specified - /// should also match the uid otherwise an error will be returned. + /// Configurations that may be specific to some trace technology should be + /// stored in the custom parameters. The options are transported to the + /// server, which shall interpret accordingly. The thread_id can be + /// specified in the options to obtain the configuration used by a specific + /// thread. The thread_id specified should also match the uid otherwise an + /// error will be returned. //------------------------------------------------------------------ virtual Status GetTraceConfig(lldb::user_id_t uid, TraceOptions &options) { return Status("Not implemented"); @@ -2840,8 +2828,8 @@ protected: lldb::StateType GetPrivateState(); //------------------------------------------------------------------ - /// The "private" side of resuming a process. This doesn't alter the - /// state of m_run_lock, but just causes the process to resume. + /// The "private" side of resuming a process. This doesn't alter the state + /// of m_run_lock, but just causes the process to resume. /// /// @return /// An Status object describing the success or failure of the resume. @@ -2858,16 +2846,16 @@ protected: /// /// A facility for printing a warning to the user once per repeat_key. /// - /// warning_type is from the Process::Warnings enums. - /// repeat_key is a pointer value that will be used to ensure that the - /// warning message is not printed multiple times. For instance, with a - /// warning about a function being optimized, you can pass the CompileUnit - /// pointer to have the warning issued for only the first function in a - /// CU, or the Function pointer to have it issued once for every function, - /// or a Module pointer to have it issued once per Module. + /// warning_type is from the Process::Warnings enums. repeat_key is a + /// pointer value that will be used to ensure that the warning message is + /// not printed multiple times. For instance, with a warning about a + /// function being optimized, you can pass the CompileUnit pointer to have + /// the warning issued for only the first function in a CU, or the Function + /// pointer to have it issued once for every function, or a Module pointer + /// to have it issued once per Module. /// - /// Classes outside Process should call a specific PrintWarning method - /// so that the warning strings are all centralized in Process, instead of + /// Classes outside Process should call a specific PrintWarning method so + /// that the warning strings are all centralized in Process, instead of /// calling PrintWarning() directly. /// /// @param [in] warning_type @@ -2885,15 +2873,14 @@ protected: const char *fmt, ...) __attribute__((format(printf, 4, 5))); //------------------------------------------------------------------ - // NextEventAction provides a way to register an action on the next - // event that is delivered to this process. There is currently only - // one next event action allowed in the process at one time. If a - // new "NextEventAction" is added while one is already present, the - // old action will be discarded (with HandleBeingUnshipped called - // after it is discarded.) + // NextEventAction provides a way to register an action on the next event + // that is delivered to this process. There is currently only one next event + // action allowed in the process at one time. If a new "NextEventAction" is + // added while one is already present, the old action will be discarded (with + // HandleBeingUnshipped called after it is discarded.) // - // If you want to resume the process as a result of a resume action, - // call RequestResume, don't call Resume directly. + // If you want to resume the process as a result of a resume action, call + // RequestResume, don't call Resume directly. //------------------------------------------------------------------ class NextEventAction { public: @@ -2949,18 +2936,17 @@ protected: void ForceNextEventDelivery() { m_force_next_event_delivery = true; } //------------------------------------------------------------------ - /// Loads any plugins associated with asynchronous structured data - /// and maps the relevant supported type name to the plugin. + /// Loads any plugins associated with asynchronous structured data and maps + /// the relevant supported type name to the plugin. /// - /// Processes can receive asynchronous structured data from the - /// process monitor. This method will load and map any structured - /// data plugins that support the given set of supported type names. - /// Later, if any of these features are enabled, the process monitor - /// is free to generate asynchronous structured data. The data must - /// come in as a single \b StructuredData::Dictionary. That dictionary - /// must have a string field named 'type', with a value that equals - /// the relevant type name string (one of the values in - /// \b supported_type_names). + /// Processes can receive asynchronous structured data from the process + /// monitor. This method will load and map any structured data plugins that + /// support the given set of supported type names. Later, if any of these + /// features are enabled, the process monitor is free to generate + /// asynchronous structured data. The data must come in as a single \b + /// StructuredData::Dictionary. That dictionary must have a string field + /// named 'type', with a value that equals the relevant type name string + /// (one of the values in \b supported_type_names). /// /// @param[in] supported_type_names /// An array of zero or more type names. Each must be unique. @@ -2973,10 +2959,9 @@ protected: //------------------------------------------------------------------ /// Route the incoming structured data dictionary to the right plugin. /// - /// The incoming structured data must be a dictionary, and it must - /// have a key named 'type' that stores a string value. The string - /// value must be the name of the structured data feature that - /// knows how to handle it. + /// The incoming structured data must be a dictionary, and it must have a + /// key named 'type' that stores a string value. The string value must be + /// the name of the structured data feature that knows how to handle it. /// /// @param[in] object_sp /// When non-null and pointing to a dictionary, the 'type' @@ -3022,7 +3007,7 @@ protected: //------------------------------------------------------------------ // Member variables //------------------------------------------------------------------ - std::weak_ptr<Target> m_target_sp; ///< The target that owns this process. + std::weak_ptr<Target> m_target_wp; ///< The target that owns this process. ThreadSafeValue<lldb::StateType> m_public_state; ThreadSafeValue<lldb::StateType> m_private_state; // The actual state of our process @@ -3107,11 +3092,11 @@ protected: bool m_currently_handling_do_on_removals; bool m_resume_requested; // If m_currently_handling_event or // m_currently_handling_do_on_removals are true, - // Resume will only request a resume, using this flag - // to check. + // Resume will only request a resume, using this + // flag to check. bool m_finalizing; // This is set at the beginning of Process::Finalize() to - // stop functions from looking up or creating things during - // a finalize call + // stop functions from looking up or creating things + // during a finalize call bool m_finalize_called; // This is set at the end of Process::Finalize() bool m_clear_thread_plans_on_stop; bool m_force_next_event_delivery; @@ -3129,6 +3114,9 @@ protected: StructuredDataPluginMap m_structured_data_plugin_map; enum { eCanJITDontKnow = 0, eCanJITYes, eCanJITNo } m_can_jit; + + std::unique_ptr<UtilityFunction> m_dlopen_utility_func_up; + std::once_flag m_dlopen_utility_func_flag_once; size_t RemoveBreakpointOpcodesFromBuffer(lldb::addr_t addr, size_t size, uint8_t *buf) const; @@ -3160,12 +3148,9 @@ private: static lldb::thread_result_t PrivateStateThread(void *arg); // The starts up the private state thread that will watch for events from the - // debugee. - // Pass true for is_secondary_thread in the case where you have to temporarily - // spin up a - // secondary state thread to handle events from a hand-called function on the - // primary - // private state thread. + // debugee. Pass true for is_secondary_thread in the case where you have to + // temporarily spin up a secondary state thread to handle events from a hand- + // called function on the primary private state thread. lldb::thread_result_t RunPrivateStateThread(bool is_secondary_thread); @@ -3178,8 +3163,7 @@ protected: const Timeout<std::micro> &timeout); // This waits for both the state change broadcaster, and the control - // broadcaster. - // If control_only, it only waits for the control broadcaster. + // broadcaster. If control_only, it only waits for the control broadcaster. bool GetEventsPrivate(lldb::EventSP &event_sp, const Timeout<std::micro> &timeout, bool control_only); @@ -3220,14 +3204,12 @@ protected: private: //------------------------------------------------------------------ - /// This is the part of the event handling that for a process event. - /// It decides what to do with the event and returns true if the - /// event needs to be propagated to the user, and false otherwise. - /// If the event is not propagated, this call will most likely set - /// the target to executing again. - /// There is only one place where this call should be called, - /// HandlePrivateEvent. - /// Don't call it from anywhere else... + /// This is the part of the event handling that for a process event. It + /// decides what to do with the event and returns true if the event needs to + /// be propagated to the user, and false otherwise. If the event is not + /// propagated, this call will most likely set the target to executing + /// again. There is only one place where this call should be called, + /// HandlePrivateEvent. Don't call it from anywhere else... /// /// @param[in] event_ptr /// This is the event we are handling. diff --git a/include/lldb/Target/ProcessInfo.h b/include/lldb/Target/ProcessInfo.h index 4077abf89baf8..0e0d8548feb6f 100644 --- a/include/lldb/Target/ProcessInfo.h +++ b/include/lldb/Target/ProcessInfo.h @@ -11,8 +11,9 @@ #define liblldb_ProcessInfo_h_ // LLDB headers -#include "lldb/Interpreter/Args.h" #include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/Args.h" +#include "lldb/Utility/Environment.h" #include "lldb/Utility/FileSpec.h" namespace lldb_private { @@ -20,9 +21,9 @@ namespace lldb_private { // ProcessInfo // // A base class for information for a process. This can be used to fill -// out information for a process prior to launching it, or it can be -// used for an instance of a process and can be filled in with the -// existing values for that process. +// out information for a process prior to launching it, or it can be used for +// an instance of a process and can be filled in with the existing values for +// that process. //---------------------------------------------------------------------- class ProcessInfo { public: @@ -81,18 +82,16 @@ public: void SetArguments(char const **argv, bool first_arg_is_executable); - Args &GetEnvironmentEntries() { return m_environment; } - - const Args &GetEnvironmentEntries() const { return m_environment; } + Environment &GetEnvironment() { return m_environment; } + const Environment &GetEnvironment() const { return m_environment; } protected: FileSpec m_executable; std::string m_arg0; // argv[0] if supported. If empty, then use m_executable. - // Not all process plug-ins support specifying an argv[0] - // that differs from the resolved platform executable - // (which is in m_executable) + // Not all process plug-ins support specifying an argv[0] that differs from + // the resolved platform executable (which is in m_executable) Args m_arguments; // All program arguments except argv[0] - Args m_environment; + Environment m_environment; uint32_t m_uid; uint32_t m_gid; ArchSpec m_arch; diff --git a/include/lldb/Target/ProcessLaunchInfo.h b/include/lldb/Target/ProcessLaunchInfo.h index fc715f28544d1..92c517a3e4609 100644 --- a/include/lldb/Target/ProcessLaunchInfo.h +++ b/include/lldb/Target/ProcessLaunchInfo.h @@ -107,13 +107,18 @@ public: return m_monitor_callback; } + /// A Monitor callback which does not take any action on process events. Use + /// this if you don't need to take any particular action when the process + /// terminates, but you still need to reap it. + static bool NoOpMonitorCallback(lldb::pid_t pid, bool exited, int signal, + int status); + bool GetMonitorSignals() const { return m_monitor_signals; } // If the LaunchInfo has a monitor callback, then arrange to monitor the - // process. - // Return true if the LaunchInfo has taken care of monitoring the process, and - // false if the - // caller might want to monitor the process themselves. + // process. Return true if the LaunchInfo has taken care of monitoring the + // process, and false if the caller might want to monitor the process + // themselves. bool MonitorProcess() const; diff --git a/include/lldb/Target/ProcessStructReader.h b/include/lldb/Target/ProcessStructReader.h index cfc8fe11a39ab..8f1445ae8c1b1 100644 --- a/include/lldb/Target/ProcessStructReader.h +++ b/include/lldb/Target/ProcessStructReader.h @@ -16,6 +16,7 @@ #include "lldb/Symbol/CompilerType.h" #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Status.h" diff --git a/include/lldb/Target/Queue.h b/include/lldb/Target/Queue.h index 2df4d54a89b6c..62cc3ccf2e2fc 100644 --- a/include/lldb/Target/Queue.h +++ b/include/lldb/Target/Queue.h @@ -22,15 +22,14 @@ namespace lldb_private { //------------------------------------------------------------------ // Queue: -// This class represents a libdispatch aka Grand Central Dispatch -// queue in the process. +// This class represents a libdispatch aka Grand Central Dispatch queue in the +// process. // // A program using libdispatch will create queues, put work items -// (functions, blocks) on the queues. The system will create / -// reassign pthreads to execute the work items for the queues. A -// serial queue will be associated with a single thread (or possibly -// no thread, if it is not doing any work). A concurrent queue may -// be associated with multiple threads. +// (functions, blocks) on the queues. The system will create / reassign +// pthreads to execute the work items for the queues. A serial queue will be +// associated with a single thread (or possibly no thread, if it is not doing +// any work). A concurrent queue may be associated with multiple threads. //------------------------------------------------------------------ class Queue : public std::enable_shared_from_this<Queue> { diff --git a/include/lldb/Target/QueueItem.h b/include/lldb/Target/QueueItem.h index acbf94e1b0f9f..76bcea36a2fa4 100644 --- a/include/lldb/Target/QueueItem.h +++ b/include/lldb/Target/QueueItem.h @@ -29,12 +29,11 @@ namespace lldb_private { //------------------------------------------------------------------ // QueueItem: -// This class represents a work item enqueued on a libdispatch aka -// Grand Central Dispatch (GCD) queue. Most often, this will be a -// function or block. -// "enqueued" here means that the work item has been added to a queue -// but it has not yet started executing. When it is "dequeued", -// execution of the item begins. +// This class represents a work item enqueued on a libdispatch aka Grand +// Central Dispatch (GCD) queue. Most often, this will be a function or block. +// "enqueued" here means that the work item has been added to a queue but it +// has not yet started executing. When it is "dequeued", execution of the item +// begins. //------------------------------------------------------------------ class QueueItem : public std::enable_shared_from_this<QueueItem> { diff --git a/include/lldb/Target/QueueList.h b/include/lldb/Target/QueueList.h index 91cf3eb6d4c20..b35de13aa1e54 100644 --- a/include/lldb/Target/QueueList.h +++ b/include/lldb/Target/QueueList.h @@ -21,12 +21,11 @@ namespace lldb_private { //------------------------------------------------------------------ // QueueList: -// This is the container for libdispatch aka Grand Central Dispatch -// Queue objects. +// This is the container for libdispatch aka Grand Central Dispatch Queue +// objects. // -// Each Process will have a QueueList. When the process execution is -// paused, the QueueList may be populated with Queues by the -// SystemRuntime. +// Each Process will have a QueueList. When the process execution is paused, +// the QueueList may be populated with Queues by the SystemRuntime. //------------------------------------------------------------------ class QueueList { diff --git a/include/lldb/Target/RegisterCheckpoint.h b/include/lldb/Target/RegisterCheckpoint.h index 578cf25eef25c..e4b407124c9fc 100644 --- a/include/lldb/Target/RegisterCheckpoint.h +++ b/include/lldb/Target/RegisterCheckpoint.h @@ -16,20 +16,19 @@ namespace lldb_private { -// Inherit from UserID in case pushing/popping all register values can be -// done using a 64 bit integer that holds a baton/cookie instead of actually -// having to read all register values into a buffer +// Inherit from UserID in case pushing/popping all register values can be done +// using a 64 bit integer that holds a baton/cookie instead of actually having +// to read all register values into a buffer class RegisterCheckpoint : public UserID { public: enum class Reason { // An expression is about to be run on the thread if the protocol that // talks to the debuggee supports checkpointing the registers using a - // push/pop then the UserID base class in the RegisterCheckpoint can - // be used to store the baton/cookie that refers to the remote saved - // state. + // push/pop then the UserID base class in the RegisterCheckpoint can be + // used to store the baton/cookie that refers to the remote saved state. eExpression, - // The register checkpoint wants the raw register bytes, so they must - // be read into m_data_sp, or the save/restore checkpoint should fail. + // The register checkpoint wants the raw register bytes, so they must be + // read into m_data_sp, or the save/restore checkpoint should fail. eDataBackup }; diff --git a/include/lldb/Target/RegisterContext.h b/include/lldb/Target/RegisterContext.h index c438a0cd12cfd..73a2930fd2b51 100644 --- a/include/lldb/Target/RegisterContext.h +++ b/include/lldb/Target/RegisterContext.h @@ -63,16 +63,14 @@ public: } // These two functions are used to implement "push" and "pop" of register - // states. They are used primarily - // for expression evaluation, where we need to push a new state (storing the - // old one in data_sp) and then - // restoring the original state by passing the data_sp we got from - // ReadAllRegisters to WriteAllRegisterValues. - // ReadAllRegisters will do what is necessary to return a coherent set of - // register values for this thread, which - // may mean e.g. interrupting a thread that is sitting in a kernel trap. That - // is a somewhat disruptive operation, - // so these API's should only be used when this behavior is needed. + // states. They are used primarily for expression evaluation, where we need + // to push a new state (storing the old one in data_sp) and then restoring + // the original state by passing the data_sp we got from ReadAllRegisters to + // WriteAllRegisterValues. ReadAllRegisters will do what is necessary to + // return a coherent set of register values for this thread, which may mean + // e.g. interrupting a thread that is sitting in a kernel trap. That is a + // somewhat disruptive operation, so these API's should only be used when + // this behavior is needed. virtual bool ReadAllRegisterValues(lldb_private::RegisterCheckpoint ®_checkpoint); diff --git a/include/lldb/Target/RegisterNumber.h b/include/lldb/Target/RegisterNumber.h index 5649c8022ee79..1a0ab49bdce39 100644 --- a/include/lldb/Target/RegisterNumber.h +++ b/include/lldb/Target/RegisterNumber.h @@ -26,8 +26,8 @@ public: // This constructor plus the init() method below allow for the placeholder // creation of an invalid object initially, possibly to be filled in. It - // would be more consistent to have three Set* methods to set the three - // data that the object needs. + // would be more consistent to have three Set* methods to set the three data + // that the object needs. RegisterNumber(); void init(lldb_private::Thread &thread, lldb::RegisterKind kind, diff --git a/include/lldb/Target/SectionLoadHistory.h b/include/lldb/Target/SectionLoadHistory.h index e1db141ea9e3d..0ed335a9d0405 100644 --- a/include/lldb/Target/SectionLoadHistory.h +++ b/include/lldb/Target/SectionLoadHistory.h @@ -23,8 +23,8 @@ namespace lldb_private { class SectionLoadHistory { public: enum : unsigned { - // Pass eStopIDNow to any function that takes a stop ID to get - // the current value. + // Pass eStopIDNow to any function that takes a stop ID to get the current + // value. eStopIDNow = UINT32_MAX }; //------------------------------------------------------------------ @@ -33,8 +33,8 @@ public: SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {} ~SectionLoadHistory() { - // Call clear since this takes a lock and clears the section load list - // in case another thread is currently using this section load list + // Call clear since this takes a lock and clears the section load list in + // case another thread is currently using this section load list Clear(); } @@ -59,14 +59,14 @@ public: bool warn_multiple = false); // The old load address should be specified when unloading to ensure we get - // the correct instance of the section as a shared library could be loaded - // at more than one location. + // the correct instance of the section as a shared library could be loaded at + // more than one location. bool SetSectionUnloaded(uint32_t stop_id, const lldb::SectionSP §ion_sp, lldb::addr_t load_addr); // Unload all instances of a section. This function can be used on systems - // that don't support multiple copies of the same shared library to be - // loaded at the same time. + // that don't support multiple copies of the same shared library to be loaded + // at the same time. size_t SetSectionUnloaded(uint32_t stop_id, const lldb::SectionSP §ion_sp); diff --git a/include/lldb/Target/SectionLoadList.h b/include/lldb/Target/SectionLoadList.h index beb345b71290c..1156c686df177 100644 --- a/include/lldb/Target/SectionLoadList.h +++ b/include/lldb/Target/SectionLoadList.h @@ -34,8 +34,8 @@ public: SectionLoadList(const SectionLoadList &rhs); ~SectionLoadList() { - // Call clear since this takes a lock and clears the section load list - // in case another thread is currently using this section load list + // Call clear since this takes a lock and clears the section load list in + // case another thread is currently using this section load list Clear(); } @@ -55,14 +55,14 @@ public: bool warn_multiple = false); // The old load address should be specified when unloading to ensure we get - // the correct instance of the section as a shared library could be loaded - // at more than one location. + // the correct instance of the section as a shared library could be loaded at + // more than one location. bool SetSectionUnloaded(const lldb::SectionSP §ion_sp, lldb::addr_t load_addr); // Unload all instances of a section. This function can be used on systems - // that don't support multiple copies of the same shared library to be - // loaded at the same time. + // that don't support multiple copies of the same shared library to be loaded + // at the same time. size_t SetSectionUnloaded(const lldb::SectionSP §ion_sp); void Dump(Stream &s, Target *target); diff --git a/include/lldb/Target/StackFrame.h b/include/lldb/Target/StackFrame.h index d97043578ce9a..ce9b162276726 100644 --- a/include/lldb/Target/StackFrame.h +++ b/include/lldb/Target/StackFrame.h @@ -32,7 +32,7 @@ namespace lldb_private { /// @class StackFrame StackFrame.h "lldb/Target/StackFrame.h" /// -/// @brief This base class provides an interface to stack frames. +/// 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 @@ -59,10 +59,10 @@ public: /// /// This is the one constructor that doesn't take a RegisterContext /// parameter. This ctor may be called when creating a history StackFrame; - /// these are used if we've collected a stack trace of pc addresses at - /// some point in the past. We may only have pc values. We may have pc - /// values and the stop_id when the stack trace was recorded. We may have a - /// CFA, or more likely, we won't. + /// these are used if we've collected a stack trace of pc addresses at some + /// point in the past. We may only have pc values. We may have pc values + /// and the stop_id when the stack trace was recorded. We may have a CFA, + /// or more likely, we won't. /// /// @param [in] thread_sp /// The Thread that this frame belongs to. @@ -165,9 +165,9 @@ public: /// Provide a SymbolContext for this StackFrame's current pc value. /// /// The StackFrame maintains this SymbolContext and adds additional - /// information - /// to it on an as-needed basis. This helps to avoid different functions - /// looking up symbolic information for a given pc value multiple times. + /// information to it on an as-needed basis. This helps to avoid different + /// functions looking up symbolic information for a given pc value multiple + /// times. /// /// @params [in] resolve_scope /// Flags from the SymbolContextItem enumerated type which specify what @@ -182,9 +182,9 @@ public: //------------------------------------------------------------------ /// Return the Canonical Frame Address (DWARF term) for this frame. /// - /// The CFA is typically the value of the stack pointer register before - /// the call invocation is made. It will not change during the lifetime - /// of a stack frame. It is often not the same thing as the frame pointer + /// The CFA is typically the value of the stack pointer register before the + /// call invocation is made. It will not change during the lifetime of a + /// stack frame. It is often not the same thing as the frame pointer /// register value. /// /// Live StackFrames will always have a CFA but other types of frames may @@ -220,9 +220,8 @@ public: //------------------------------------------------------------------ /// Get the current lexical scope block for this StackFrame, if possible. /// - /// If debug information is available for this stack frame, return a - /// pointer to the innermost lexical Block that the frame is currently - /// executing. + /// If debug information is available for this stack frame, return a pointer + /// to the innermost lexical Block that the frame is currently executing. /// /// @return /// A pointer to the current Block. nullptr is returned if this can @@ -251,11 +250,12 @@ public: } //------------------------------------------------------------------ - /// Retrieve the list of variables that are in scope at this StackFrame's pc. + /// Retrieve the list of variables that are in scope at this StackFrame's + /// pc. /// /// A frame that is not live may return an empty VariableList for a given - /// pc value even though variables would be available at this point if - /// it were a live stack frame. + /// pc value even though variables would be available at this point if it + /// were a live stack frame. /// /// @param[in] get_file_globals /// Whether to also retrieve compilation-unit scoped variables @@ -268,11 +268,12 @@ public: VariableList *GetVariableList(bool get_file_globals); //------------------------------------------------------------------ - /// Retrieve the list of variables that are in scope at this StackFrame's pc. + /// Retrieve the list of variables that are in scope at this StackFrame's + /// pc. /// /// A frame that is not live may return an empty VariableListSP for a - /// given pc value even though variables would be available at this point - /// if it were a live stack frame. + /// given pc value even though variables would be available at this point if + /// it were a live stack frame. /// /// @param[in] get_file_globals /// Whether to also retrieve compilation-unit scoped variables @@ -287,8 +288,8 @@ public: bool must_have_valid_location = false); //------------------------------------------------------------------ - /// Create a ValueObject for a variable name / pathname, possibly - /// including simple dereference/child selection syntax. + /// Create a ValueObject for a variable name / pathname, possibly including + /// simple dereference/child selection syntax. /// /// @param[in] var_expr /// The string specifying a variable to base the VariableObject off @@ -327,8 +328,8 @@ public: bool HasDebugInformation(); //------------------------------------------------------------------ - /// Return the disassembly for the instructions of this StackFrame's function - /// as a single C string. + /// Return the disassembly for the instructions of this StackFrame's + /// function as a single C string. /// /// @return // C string with the assembly instructions for this function. @@ -366,8 +367,8 @@ public: void Dump(Stream *strm, bool show_frame_index, bool show_fullpaths); //------------------------------------------------------------------ - /// Print a description of this stack frame and/or the source context/assembly - /// for this stack frame. + /// Print a description of this stack frame and/or the source + /// context/assembly for this stack frame. /// /// @param[in] strm /// The Stream to send the output to. @@ -392,9 +393,9 @@ public: bool show_unique = false, const char *frame_marker = nullptr); //------------------------------------------------------------------ - /// Query whether this frame is a concrete frame on the call stack, - /// or if it is an inlined frame derived from the debug information - /// and presented by the debugger. + /// Query whether this frame is a concrete frame on the call stack, or if it + /// is an inlined frame derived from the debug information and presented by + /// the debugger. /// /// @return /// true if this is an inlined frame. @@ -402,7 +403,8 @@ public: bool IsInlined(); //------------------------------------------------------------------ - /// Query this frame to find what frame it is in this Thread's StackFrameList. + /// Query this frame to find what frame it is in this Thread's + /// StackFrameList. /// /// @return /// StackFrame index 0 indicates the currently-executing function. Inline @@ -411,8 +413,8 @@ public: uint32_t GetFrameIndex() const; //------------------------------------------------------------------ - /// Query this frame to find what frame it is in this Thread's StackFrameList, - /// not counting inlined frames. + /// Query this frame to find what frame it is in this Thread's + /// StackFrameList, not counting inlined frames. /// /// @return /// StackFrame index 0 indicates the currently-executing function. Inline @@ -442,8 +444,7 @@ public: //------------------------------------------------------------------ /// Add an arbitrary Variable object (e.g. one that specifics a global or - /// static) - /// to a StackFrame's list of ValueObjects. + /// static) to a StackFrame's list of ValueObjects. /// /// @params [in] variable_sp /// The Variable to base this ValueObject on @@ -460,8 +461,8 @@ public: lldb::DynamicValueType use_dynamic); //------------------------------------------------------------------ - /// Query this frame to determine what the default language should be - /// when parsing expressions given the execution context. + /// Query this frame to determine what the default language should be when + /// parsing expressions given the execution context. /// /// @return /// The language of the frame if known, else lldb::eLanguageTypeUnknown. @@ -469,8 +470,7 @@ public: lldb::LanguageType GetLanguage(); // similar to GetLanguage(), but is allowed to take a potentially incorrect - // guess - // if exact information is not available + // guess if exact information is not available lldb::LanguageType GuessLanguage(); //------------------------------------------------------------------ @@ -488,8 +488,8 @@ public: //------------------------------------------------------------------ /// Attempt to reconstruct the ValueObject for the address contained in a - /// given register plus an offset. The ExpressionPath should indicate how to - /// get to this value using "frame variable." + /// given register plus an offset. The ExpressionPath should indicate how + /// to get to this value using "frame variable." /// /// @params [in] reg /// The name of the register. diff --git a/include/lldb/Target/StackID.h b/include/lldb/Target/StackID.h index 7b7e9e5187b6d..51e51a6c07414 100644 --- a/include/lldb/Target/StackID.h +++ b/include/lldb/Target/StackID.h @@ -81,20 +81,20 @@ protected: lldb::addr_t m_pc; // The pc value for the function/symbol for this frame. This will // only get used if the symbol scope is nullptr (the code where we are - // stopped is not represented by any function or symbol in any - // shared library). + // stopped is not represented by any function or symbol in any shared + // library). lldb::addr_t m_cfa; // The call frame address (stack pointer) value // at the beginning of the function that uniquely - // identifies this frame (along with m_symbol_scope below) + // identifies this frame (along with m_symbol_scope + // below) SymbolContextScope * m_symbol_scope; // If nullptr, there is no block or symbol for this frame. // If not nullptr, this will either be the scope for the - // lexical block for the frame, or the scope - // for the symbol. Symbol context scopes are - // always be unique pointers since the are part - // of the Block and Symbol objects and can easily - // be used to tell if a stack ID is the same as - // another. + // lexical block for the frame, or the scope for the + // symbol. Symbol context scopes are always be unique + // pointers since the are part of the Block and Symbol + // objects and can easily be used to tell if a stack ID + // is the same as another. }; bool operator==(const StackID &lhs, const StackID &rhs); diff --git a/include/lldb/Target/StopInfo.h b/include/lldb/Target/StopInfo.h index c99877cbd8abc..b25bf7dd3d5dd 100644 --- a/include/lldb/Target/StopInfo.h +++ b/include/lldb/Target/StopInfo.h @@ -40,12 +40,10 @@ public: lldb::ThreadSP GetThread() const { return m_thread_wp.lock(); } - // The value of the StopInfo depends on the StopReason. - // StopReason Meaning - // ---------------------------------------------- - // eStopReasonBreakpoint BreakpointSiteID - // eStopReasonSignal Signal number - // eStopReasonWatchpoint WatchpointLocationID + // The value of the StopInfo depends on the StopReason. StopReason + // Meaning ---------------------------------------------- + // eStopReasonBreakpoint BreakpointSiteID eStopReasonSignal + // Signal number eStopReasonWatchpoint WatchpointLocationID // eStopReasonPlanComplete No significance uint64_t GetValue() const { return m_value; } @@ -53,10 +51,8 @@ public: virtual lldb::StopReason GetStopReason() const = 0; // ShouldStopSynchronous will get called before any thread plans are - // consulted, and if it says we should - // resume the target, then we will just immediately resume. This should not - // run any code in or resume the - // target. + // consulted, and if it says we should resume the target, then we will just + // immediately resume. This should not run any code in or resume the target. virtual bool ShouldStopSynchronous(Event *event_ptr) { return true; } @@ -88,14 +84,11 @@ public: virtual bool IsValidForOperatingSystemThread(Thread &thread) { return true; } // Sometimes the thread plan logic will know that it wants a given stop to - // stop or not, - // regardless of what the ordinary logic for that StopInfo would dictate. The - // main example - // of this is the ThreadPlanCallFunction, which for instance knows - based on - // how that particular - // expression was executed - whether it wants all breakpoints to auto-continue - // or not. - // Use OverrideShouldStop on the StopInfo to implement this. + // stop or not, regardless of what the ordinary logic for that StopInfo would + // dictate. The main example of this is the ThreadPlanCallFunction, which + // for instance knows - based on how that particular expression was executed + // - whether it wants all breakpoints to auto-continue or not. Use + // OverrideShouldStop on the StopInfo to implement this. void OverrideShouldStop(bool override_value) { m_override_should_stop = override_value ? eLazyBoolYes : eLazyBoolNo; @@ -159,15 +152,13 @@ protected: virtual bool DoShouldNotify(Event *event_ptr) { return false; } - // Stop the thread by default. Subclasses can override this to allow - // the thread to continue if desired. The ShouldStop method should not do - // anything - // that might run code. If you need to run code when deciding whether to stop - // at this StopInfo, that must be done in the PerformAction. + // Stop the thread by default. Subclasses can override this to allow the + // thread to continue if desired. The ShouldStop method should not do + // anything that might run code. If you need to run code when deciding + // whether to stop at this StopInfo, that must be done in the PerformAction. // The PerformAction will always get called before the ShouldStop. This is - // done by the - // ProcessEventData::DoOnRemoval, though the ThreadPlanBase needs to consult - // this later on. + // done by the ProcessEventData::DoOnRemoval, though the ThreadPlanBase needs + // to consult this later on. virtual bool ShouldStop(Event *event_ptr) { return true; } //------------------------------------------------------------------ @@ -185,14 +176,13 @@ protected: StructuredData::ObjectSP m_extended_info; // The extended info for this stop info - // This determines whether the target has run since this stop info. - // N.B. running to evaluate a user expression does not count. + // This determines whether the target has run since this stop info. N.B. + // running to evaluate a user expression does not count. bool HasTargetRunSinceMe(); // MakeStopInfoValid is necessary to allow saved stop infos to resurrect - // themselves as valid. - // It should only be used by Thread::RestoreThreadStateFromCheckpoint and to - // make sure the one-step + // themselves as valid. It should only be used by + // Thread::RestoreThreadStateFromCheckpoint and to make sure the one-step // needed for before-the-fact watchpoints does not prevent us from stopping void MakeStopInfoValid(); diff --git a/include/lldb/Target/SystemRuntime.h b/include/lldb/Target/SystemRuntime.h index 8c6c2ece967fc..06cc3ec2d0121 100644 --- a/include/lldb/Target/SystemRuntime.h +++ b/include/lldb/Target/SystemRuntime.h @@ -29,20 +29,20 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class SystemRuntime SystemRuntime.h "lldb/Target/SystemRuntime.h" -/// @brief A plug-in interface definition class for system runtimes. +/// A plug-in interface definition class for system runtimes. /// /// The system runtime plugins can collect information from the system -/// libraries during a Process' lifetime and provide information about -/// how objects/threads were originated. +/// libraries during a Process' lifetime and provide information about how +/// objects/threads were originated. /// -/// For instance, a system runtime plugin use a breakpoint when threads -/// are created to record the backtrace of where that thread was created. -/// Later, when backtracing the created thread, it could extend the backtrace -/// to show where it was originally created from. +/// For instance, a system runtime plugin use a breakpoint when threads are +/// created to record the backtrace of where that thread was created. Later, +/// when backtracing the created thread, it could extend the backtrace to show +/// where it was originally created from. /// -/// The plugin will insert its own breakpoint when Created and start collecting -/// information. Later when it comes time to augment a Thread, it can be -/// asked to provide that information. +/// The plugin will insert its own breakpoint when Created and start +/// collecting information. Later when it comes time to augment a Thread, it +/// can be asked to provide that information. /// //---------------------------------------------------------------------- @@ -51,9 +51,8 @@ public: //------------------------------------------------------------------ /// Find a system runtime plugin for a given process. /// - /// Scans the installed SystemRuntime plugins and tries to find - /// an instance that can be used to track image changes in \a - /// process. + /// Scans the installed SystemRuntime plugins and tries to find an instance + /// that can be used to track image changes in \a process. /// /// @param[in] process /// The process for which to try and locate a system runtime @@ -69,60 +68,60 @@ public: //------------------------------------------------------------------ /// Destructor. /// - /// The destructor is virtual since this class is designed to be - /// inherited by the plug-in instance. + /// The destructor is virtual since this class is designed to be inherited + /// by the plug-in instance. //------------------------------------------------------------------ ~SystemRuntime() override; //------------------------------------------------------------------ /// Called after attaching to a process. /// - /// Allow the SystemRuntime plugin to execute some code after attaching - /// to a process. + /// Allow the SystemRuntime plugin to execute some code after attaching to a + /// process. //------------------------------------------------------------------ virtual void DidAttach(); //------------------------------------------------------------------ /// Called after launching a process. /// - /// Allow the SystemRuntime plugin to execute some code after launching - /// a process. + /// Allow the SystemRuntime plugin to execute some code after launching a + /// process. //------------------------------------------------------------------ virtual void DidLaunch(); //------------------------------------------------------------------ /// Called when modules have been loaded in the process. /// - /// Allow the SystemRuntime plugin to enable logging features in the - /// system runtime libraries. + /// Allow the SystemRuntime plugin to enable logging features in the system + /// runtime libraries. //------------------------------------------------------------------ virtual void ModulesDidLoad(lldb_private::ModuleList &module_list); //------------------------------------------------------------------ /// Called before detaching from a process. /// - /// This will give a SystemRuntime plugin a chance to free any resources - /// in the inferior process before we detach. + /// This will give a SystemRuntime plugin a chance to free any resources in + /// the inferior process before we detach. //------------------------------------------------------------------ virtual void Detach(); //------------------------------------------------------------------ - /// Return a list of thread origin extended backtraces that may - /// be available. + /// Return a list of thread origin extended backtraces that may be + /// available. /// /// A System Runtime may be able to provide a backtrace of when this - /// thread was originally created. Furthermore, it may be able to - /// provide that extended backtrace for different styles of creation. - /// On a system with both pthreads and libdispatch, aka Grand Central - /// Dispatch, queues, the system runtime may be able to provide the - /// pthread creation of the thread and it may also be able to provide - /// the backtrace of when this GCD queue work block was enqueued. - /// The caller may request these different origins by name. + /// thread was originally created. Furthermore, it may be able to provide + /// that extended backtrace for different styles of creation. On a system + /// with both pthreads and libdispatch, aka Grand Central Dispatch, queues, + /// the system runtime may be able to provide the pthread creation of the + /// thread and it may also be able to provide the backtrace of when this GCD + /// queue work block was enqueued. The caller may request these different + /// origins by name. /// - /// The names will be provided in the order that they are most likely - /// to be requested. For instance, a most natural order may be to - /// request the GCD libdispatch queue origin. If there is none, then - /// request the pthread origin. + /// The names will be provided in the order that they are most likely to be + /// requested. For instance, a most natural order may be to request the GCD + /// libdispatch queue origin. If there is none, then request the pthread + /// origin. /// /// @return /// A vector of ConstStrings with names like "pthread" or "libdispatch". @@ -135,13 +134,12 @@ public: /// Return a Thread which shows the origin of this thread's creation. /// /// This likely returns a HistoryThread which shows how thread was - /// originally created (e.g. "pthread" type), or how the work that - /// is currently executing on it was originally enqueued (e.g. - /// "libdispatch" type). + /// originally created (e.g. "pthread" type), or how the work that is + /// currently executing on it was originally enqueued (e.g. "libdispatch" + /// type). /// - /// There may be a chain of thread-origins; it may be informative to - /// the end user to query the returned ThreadSP for its origins as - /// well. + /// There may be a chain of thread-origins; it may be informative to the end + /// user to query the returned ThreadSP for its origins as well. /// /// @param [in] thread /// The thread to examine. @@ -168,8 +166,8 @@ public: /// a libdispatch queue in the future, or it represents a function/block /// that is currently executing on a thread. /// - /// This method will report a thread backtrace of the function that - /// enqueued it originally, if possible. + /// This method will report a thread backtrace of the function that enqueued + /// it originally, if possible. /// /// @param [in] queue_item_sp /// The QueueItem that we are getting an extended backtrace for. @@ -189,10 +187,11 @@ public: } //------------------------------------------------------------------ - /// Populate the Process' QueueList with libdispatch / GCD queues that exist. + /// Populate the Process' QueueList with libdispatch / GCD queues that + /// exist. /// - /// When process execution is paused, the SystemRuntime may be called to fill - /// in the list of Queues that currently exist. + /// When process execution is paused, the SystemRuntime may be called to + /// fill in the list of Queues that currently exist. /// /// @param [out] queue_list /// This QueueList will be cleared, and any queues that currently exist @@ -205,12 +204,10 @@ public: /// Get the queue name for a thread given a thread's dispatch_qaddr. /// /// On systems using libdispatch queues, a thread may be associated with a - /// queue. - /// There will be a call to get the thread's dispatch_qaddr. At the - /// dispatch_qaddr - /// we will find the address of this thread's dispatch_queue_t structure. - /// Given the address of the dispatch_queue_t structure for a thread, - /// get the queue name and return it. + /// queue. There will be a call to get the thread's dispatch_qaddr. At the + /// dispatch_qaddr we will find the address of this thread's + /// dispatch_queue_t structure. Given the address of the dispatch_queue_t + /// structure for a thread, get the queue name and return it. /// /// @param [in] dispatch_qaddr /// The address of the dispatch_qaddr pointer for this thread. @@ -229,12 +226,10 @@ public: /// dispatch_qaddr. /// /// On systems using libdispatch queues, a thread may be associated with a - /// queue. - /// There will be a call to get the thread's dispatch_qaddr. At the - /// dispatch_qaddr - /// we will find the address of this thread's dispatch_queue_t structure. - /// Given the address of the dispatch_queue_t structure for a thread, - /// get the queue ID and return it. + /// queue. There will be a call to get the thread's dispatch_qaddr. At the + /// dispatch_qaddr we will find the address of this thread's + /// dispatch_queue_t structure. Given the address of the dispatch_queue_t + /// structure for a thread, get the queue ID and return it. /// /// @param [in] dispatch_qaddr /// The address of the dispatch_qaddr pointer for this thread. @@ -252,10 +247,8 @@ public: /// dispatch_qaddr. /// /// On systems using libdispatch queues, a thread may be associated with a - /// queue. - /// There will be a call to get the thread's dispatch_qaddr. - /// Given the thread's dispatch_qaddr, find the libdispatch_queue_t address - /// and + /// queue. There will be a call to get the thread's dispatch_qaddr. Given + /// the thread's dispatch_qaddr, find the libdispatch_queue_t address and /// return it. /// /// @param [in] dispatch_qaddr @@ -274,8 +267,8 @@ public: /// Retrieve the Queue kind for the queue at a thread's dispatch_qaddr. /// /// Retrieve the Queue kind - either eQueueKindSerial or - /// eQueueKindConcurrent, indicating that this queue processes work - /// items serially or concurrently. + /// eQueueKindConcurrent, indicating that this queue processes work items + /// serially or concurrently. /// /// @return /// The Queue kind, if it could be read, else eQueueKindUnknown. @@ -288,8 +281,8 @@ public: /// Get the pending work items for a libdispatch Queue /// /// If this system/process is using libdispatch and the runtime can do so, - /// retrieve the list of pending work items for the specified Queue and - /// add it to the Queue. + /// retrieve the list of pending work items for the specified Queue and add + /// it to the Queue. /// /// @param [in] queue /// The queue of interest. @@ -300,8 +293,8 @@ public: /// Complete the fields in a QueueItem /// /// PopulatePendingItemsForQueue() may not fill in all of the QueueItem - /// details; when the remaining fields are needed, they will be - /// fetched by call this method. + /// details; when the remaining fields are needed, they will be fetched by + /// call this method. /// /// @param [in] queue_item /// The QueueItem that we will be completing. @@ -316,8 +309,7 @@ public: //------------------------------------------------------------------ /// Add key-value pairs to the StructuredData dictionary object with /// information debugserver may need when constructing the - /// jThreadExtendedInfo - /// packet. + /// jThreadExtendedInfo packet. /// /// @param [out] dict /// Dictionary to which key-value pairs should be added; they will diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h index a5d2000698103..75af8e80d2e51 100644 --- a/include/lldb/Target/Target.h +++ b/include/lldb/Target/Target.h @@ -35,6 +35,7 @@ #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/SectionLoadHistory.h" #include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Timeout.h" #include "lldb/lldb-public.h" @@ -102,9 +103,6 @@ public: const char *GetDisassemblyFlavor() const; - // void - // SetDisassemblyFlavor(const char *flavor); - InlineStrategy GetInlineStrategy() const; llvm::StringRef GetArg0() const; @@ -115,9 +113,8 @@ public: void SetRunArguments(const Args &args); - size_t GetEnvironmentAsArgs(Args &env) const; - - void SetEnvironmentFromArgs(const Args &env); + Environment GetEnvironment() const; + void SetEnvironment(Environment env); bool GetSkipPrologue() const; @@ -235,8 +232,8 @@ class EvaluateExpressionOptions { public: // MSVC has a bug here that reports C4268: 'const' static/global data // initialized with compiler generated default constructor fills the object -// with zeros. -// Confirmed that MSVC is *not* zero-initializing, it's just a bogus warning. +// with zeros. Confirmed that MSVC is *not* zero-initializing, it's just a +// bogus warning. #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable : 4268) @@ -353,8 +350,7 @@ public: } // Allows the expression contents to be remapped to point to the specified - // file and line - // using #line directives. + // file and line using #line directives. void SetPoundLine(const char *path, uint32_t line) const { if (path && path[0]) { m_pound_line_file = path; @@ -401,8 +397,8 @@ private: Timeout<std::micro> m_one_thread_timeout = llvm::None; lldb::ExpressionCancelCallback m_cancel_callback = nullptr; void *m_cancel_callback_baton = nullptr; - // If m_pound_line_file is not empty and m_pound_line_line is non-zero, - // use #line %u "%s" before the expression content to remap where the source + // If m_pound_line_file is not empty and m_pound_line_line is non-zero, use + // #line %u "%s" before the expression content to remap where the source // originates mutable std::string m_pound_line_file; mutable uint32_t m_pound_line_line; @@ -490,9 +486,6 @@ public: static void SetDefaultArchitecture(const ArchSpec &arch); - // void - // UpdateInstanceName (); - lldb::ModuleSP GetSharedModule(const ModuleSpec &module_spec, Status *error_ptr = nullptr); @@ -563,9 +556,8 @@ public: LazyBool move_to_nearest_code); // Use this to create breakpoint that matches regex against the source lines - // in files given in source_file_list: - // If function_names is non-empty, also filter by function after the matches - // are made. + // in files given in source_file_list: If function_names is non-empty, also + // filter by function after the matches are made. lldb::BreakpointSP CreateSourceRegexBreakpoint( const FileSpecList *containingModules, const FileSpecList *source_file_list, @@ -589,8 +581,8 @@ public: // Use this to create a function breakpoint by regexp in // containingModule/containingSourceFiles, or all modules if it is nullptr - // When "skip_prologue is set to eLazyBoolCalculate, we use the current target - // setting, else we use the values passed in + // When "skip_prologue is set to eLazyBoolCalculate, we use the current + // target setting, else we use the values passed in lldb::BreakpointSP CreateFuncRegexBreakpoint( const FileSpecList *containingModules, const FileSpecList *containingSourceFiles, RegularExpression &func_regexp, @@ -598,10 +590,10 @@ public: bool internal, bool request_hardware); // Use this to create a function breakpoint by name in containingModule, or - // all modules if it is nullptr - // When "skip_prologue is set to 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. + // all modules if it is nullptr When "skip_prologue is set to + // 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, @@ -618,11 +610,10 @@ public: Status *additional_args_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. + // 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, @@ -741,14 +732,14 @@ public: /// 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 eAddressClassInvalid, then the address + /// 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. //------------------------------------------------------------------ lldb::addr_t GetCallableLoadAddress( lldb::addr_t load_addr, - lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const; + AddressClass addr_class = AddressClass::eInvalid) const; //------------------------------------------------------------------ /// Get \a load_addr as an opcode for this target. @@ -757,22 +748,20 @@ public: /// 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 eAddressClassInvalid, then the address + /// 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. //------------------------------------------------------------------ lldb::addr_t GetOpcodeLoadAddress( lldb::addr_t load_addr, - lldb::AddressClass addr_class = lldb::eAddressClassInvalid) const; + 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 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. + // 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. lldb::addr_t GetBreakableLoadAddress(lldb::addr_t addr); void ModulesDidLoad(ModuleList &module_list); @@ -949,7 +938,7 @@ public: bool MergeArchitecture(const ArchSpec &arch_spec); - Architecture *GetArchitecturePlugin() { return m_arch.GetPlugin(); } + Architecture *GetArchitecturePlugin() const { return m_arch.GetPlugin(); } Debugger &GetDebugger() { return m_debugger; } @@ -957,12 +946,12 @@ public: Status &error); // Reading memory through the target allows us to skip going to the process - // for reading memory if possible and it allows us to try and read from - // any constant sections in our object files on disk. If you always want - // live program memory, read straight from the process. If you possibly - // want to read from const sections in object files, read from the target. - // This version of ReadMemory will try and read memory from the process - // if the process is alive. The order is: + // for reading memory if possible and it allows us to try and read from any + // constant sections in our object files on disk. If you always want live + // program memory, read straight from the process. If you possibly want to + // read from const sections in object files, read from the target. This + // version of ReadMemory will try and read memory from the process if the + // process is alive. The order is: // 1 - if (prefer_file_cache == true) then read from object file cache // 2 - if there is a valid process, try and read from its memory // 3 - if (prefer_file_cache == false) then read from object file cache @@ -993,13 +982,6 @@ public: return m_section_load_history.GetCurrentSectionLoadList(); } - // const SectionLoadList& - // GetSectionLoadList() const - // { - // return const_cast<SectionLoadHistory - // *>(&m_section_load_history)->GetCurrentSectionLoadList(); - // } - static Target *GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr); @@ -1025,9 +1007,8 @@ public: PersistentExpressionState * GetPersistentExpressionStateForLanguage(lldb::LanguageType language); - // Creates a UserExpression for the given language, the rest of the parameters - // have the - // same meaning as for the UserExpression constructor. + // Creates a UserExpression for the given language, the rest of the + // parameters have the same meaning as for the UserExpression constructor. // Returns a new-ed object which the caller owns. UserExpression *GetUserExpressionForLanguage( @@ -1035,10 +1016,9 @@ public: Expression::ResultType desired_type, const EvaluateExpressionOptions &options, Status &error); - // Creates a FunctionCaller for the given language, the rest of the parameters - // have the - // same meaning as for the FunctionCaller constructor. Since a FunctionCaller - // can't be + // Creates a FunctionCaller for the given language, the rest of the + // parameters have the same meaning as for the FunctionCaller constructor. + // Since a FunctionCaller can't be // IR Interpreted, it makes no sense to call this with an // ExecutionContextScope that lacks // a Process. @@ -1051,8 +1031,7 @@ public: const char *name, Status &error); // Creates a UtilityFunction for the given language, the rest of the - // parameters have the - // same meaning as for the UtilityFunction constructor. + // parameters have the same meaning as for the UtilityFunction constructor. // Returns a new-ed object which the caller owns. UtilityFunction *GetUtilityFunctionForLanguage(const char *expr, @@ -1065,8 +1044,8 @@ public: lldb::ClangASTImporterSP GetClangASTImporter(); //---------------------------------------------------------------------- - // Install any files through the platform that need be to installed - // prior to launching or attaching. + // Install any files through the platform that need be to installed prior to + // launching or attaching. //---------------------------------------------------------------------- Status Install(ProcessLaunchInfo *launch_info); @@ -1091,10 +1070,10 @@ public: void ClearAllLoadedSections(); // Since expressions results can persist beyond the lifetime of a process, - // and the const expression results are available after a process is gone, - // we provide a way for expressions to be evaluated from the Target itself. - // If an expression is going to be run, then it should have a frame filled - // in in th execution context. + // and the const expression results are available after a process is gone, we + // provide a way for expressions to be evaluated from the Target itself. If + // an expression is going to be run, then it should have a frame filled in in + // th execution context. lldb::ExpressionResults EvaluateExpression( llvm::StringRef expression, ExecutionContextScope *exe_scope, lldb::ValueObjectSP &result_valobj_sp, @@ -1103,6 +1082,11 @@ public: lldb::ExpressionVariableSP GetPersistentVariable(const ConstString &name); + /// Return the next available number for numbered persistent variables. + unsigned GetNextPersistentVariableIndex() { + return m_next_persistent_variable_index++; + } + lldb::addr_t GetPersistentSymbol(const ConstString &name); //------------------------------------------------------------------ @@ -1148,17 +1132,15 @@ public: bool m_active; // Use CreateStopHook to make a new empty stop hook. The GetCommandPointer - // and fill it with commands, - // and SetSpecifier to set the specifier shared pointer (can be null, that - // will match anything.) + // and fill it with commands, and SetSpecifier to set the specifier shared + // pointer (can be null, that will match anything.) StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid); friend class Target; }; typedef std::shared_ptr<StopHook> StopHookSP; - // Add an empty stop hook to the Target's stop hook list, and returns a shared - // pointer to it in new_hook. - // Returns the id of the new hook. + // Add an empty stop hook to the Target's stop hook list, and returns a + // shared pointer to it in new_hook. Returns the id of the new hook. StopHookSP CreateStopHook(); void RunStopHooks(); @@ -1173,9 +1155,6 @@ public: bool GetSuppressStopHooks() { return m_suppress_stop_hooks; } - // StopHookSP & - // GetStopHookByIndex (size_t index); - // bool RemoveStopHookByID(lldb::user_id_t uid); void RemoveAllStopHooks(); @@ -1275,9 +1254,9 @@ protected: lldb::BreakpointSP m_last_created_breakpoint; WatchpointList m_watchpoint_list; lldb::WatchpointSP m_last_created_watchpoint; - // We want to tightly control the process destruction process so - // we can correctly tear down everything that we need to, so the only - // class that knows about the process lifespan is this target class. + // We want to tightly control the process destruction process so we can + // correctly tear down everything that we need to, so the only class that + // knows about the process lifespan is this target class. lldb::ProcessSP m_process_sp; lldb::SearchFilterSP m_search_filter_sp; PathMappingList m_image_search_paths; @@ -1297,10 +1276,33 @@ protected: bool m_valid; bool m_suppress_stop_hooks; bool m_is_dummy_target; + unsigned m_next_persistent_variable_index = 0; static void ImageSearchPathsChanged(const PathMappingList &path_list, void *baton); + //------------------------------------------------------------------ + // Utilities for `statistics` command. + //------------------------------------------------------------------ +private: + std::vector<uint32_t> m_stats_storage; + bool m_collecting_stats = false; + +public: + void SetCollectingStats(bool v) { m_collecting_stats = v; } + + bool GetCollectingStats() { return m_collecting_stats; } + + void IncrementStats(lldb_private::StatisticKind key) { + if (!GetCollectingStats()) + return; + lldbassert(key < lldb_private::StatisticKind::StatisticMax && + "invalid statistics!"); + m_stats_storage[key] += 1; + } + + std::vector<uint32_t> GetStatistics() { return m_stats_storage; } + private: //------------------------------------------------------------------ /// Construct with optional file and arch. diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h index 1b0b6ef557e8c..9ce73e0cbeffc 100644 --- a/include/lldb/Target/Thread.h +++ b/include/lldb/Target/Thread.h @@ -214,8 +214,8 @@ public: // This function is called on all the threads before "ShouldResume" and // "WillResume" in case a thread needs to change its state before the - // ThreadList polls all the threads to figure out which ones actually - // will get to run and how. + // ThreadList polls all the threads to figure out which ones actually will + // get to run and how. void SetupForResume(); // Do not override this function, it is for thread plan logic only @@ -224,8 +224,8 @@ public: // Override this to do platform specific tasks before resume. virtual void WillResume(lldb::StateType resume_state) {} - // This clears generic thread state after a resume. If you subclass this, - // be sure to call it. + // This clears generic thread state after a resume. If you subclass this, be + // sure to call it. virtual void DidResume(); // This notifies the thread when a private stop occurs. @@ -244,14 +244,10 @@ public: void Flush(); // Return whether this thread matches the specification in ThreadSpec. This - // is a virtual - // method because at some point we may extend the thread spec with a platform - // specific - // dictionary of attributes, which then only the platform specific Thread - // implementation - // would know how to match. For now, this just calls through to the - // ThreadSpec's - // ThreadPassesBasicTests method. + // is a virtual method because at some point we may extend the thread spec + // with a platform specific dictionary of attributes, which then only the + // platform specific Thread implementation would know how to match. For now, + // this just calls through to the ThreadSpec's ThreadPassesBasicTests method. virtual bool MatchesSpec(const ThreadSpec *spec); lldb::StopInfoSP GetStopInfo(); @@ -261,9 +257,8 @@ public: bool StopInfoIsUpToDate() const; // This sets the stop reason to a "blank" stop reason, so you can call - // functions on the thread - // without having the called function run with whatever stop reason you - // stopped with. + // functions on the thread without having the called function run with + // whatever stop reason you stopped with. void SetStopInfoToNothing(); bool ThreadStoppedForAReason(); @@ -492,16 +487,15 @@ public: virtual void ClearBackingThread() { // Subclasses can use this function if a thread is actually backed by // another thread. This is currently used for the OperatingSystem plug-ins - // where they might have a thread that is in memory, yet its registers - // are available through the lldb_private::Thread subclass for the current + // where they might have a thread that is in memory, yet its registers are + // available through the lldb_private::Thread subclass for the current // lldb_private::Process class. Since each time the process stops the - // backing - // threads for memory threads can change, we need a way to clear the backing - // thread for all memory threads each time we stop. + // backing threads for memory threads can change, we need a way to clear + // the backing thread for all memory threads each time we stop. } - // 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. + // 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, bool stop_format); @@ -607,30 +601,24 @@ public: // Thread Plan Providers: // This section provides the basic thread plans that the Process control // machinery uses to run the target. ThreadPlan.h provides more details on - // how this mechanism works. - // The thread provides accessors to a set of plans that perform basic - // operations. - // The idea is that particular Platform plugins can override these methods to - // provide the implementation of these basic operations appropriate to their - // environment. + // how this mechanism works. The thread provides accessors to a set of plans + // that perform basic operations. The idea is that particular Platform + // plugins can override these methods to provide the implementation of these + // basic operations appropriate to their environment. // // NB: All the QueueThreadPlanXXX providers return Shared Pointers to // Thread plans. This is useful so that you can modify the plans after // creation in ways specific to that plan type. Also, it is often necessary - // for - // ThreadPlans that utilize other ThreadPlans to implement their task to keep - // a shared - // pointer to the sub-plan. - // But besides that, the shared pointers should only be held onto by entities - // who live no longer - // than the thread containing the ThreadPlan. + // for ThreadPlans that utilize other ThreadPlans to implement their task to + // keep a shared pointer to the sub-plan. But besides that, the shared + // pointers should only be held onto by entities who live no longer than the + // thread containing the ThreadPlan. // FIXME: If this becomes a problem, we can make a version that just returns a // pointer, // which it is clearly unsafe to hold onto, and a shared pointer version, and - // only allow - // ThreadPlan and Co. to use the latter. That is made more annoying to do - // because there's - // no elegant way to friend a method to all sub-classes of a given class. + // only allow ThreadPlan and Co. to use the latter. That is made more + // annoying to do because there's no elegant way to friend a method to all + // sub-classes of a given class. // //------------------------------------------------------------------ @@ -717,9 +705,8 @@ public: LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); // Helper function that takes a LineEntry to step, insted of an AddressRange. - // This may combine multiple - // LineEntries of the same source line number to step over a longer address - // range in a single operation. + // This may combine multiple LineEntries of the same source line number to + // step over a longer address range in a single operation. virtual lldb::ThreadPlanSP QueueThreadPlanForStepOverRange( bool abort_other_plans, const LineEntry &line_entry, const SymbolContext &addr_context, lldb::RunMode stop_other_threads, @@ -779,9 +766,8 @@ public: LazyBool step_out_avoids_code_without_debug_info = eLazyBoolCalculate); // Helper function that takes a LineEntry to step, insted of an AddressRange. - // This may combine multiple - // LineEntries of the same source line number to step over a longer address - // range in a single operation. + // This may combine multiple LineEntries of the same source line number to + // step over a longer address range in a single operation. virtual lldb::ThreadPlanSP QueueThreadPlanForStepInRange( bool abort_other_plans, const LineEntry &line_entry, const SymbolContext &addr_context, const char *step_in_target, @@ -1115,23 +1101,22 @@ public: void SetTracer(lldb::ThreadPlanTracerSP &tracer_sp); //------------------------------------------------------------------ - // Get the thread index ID. The index ID that is guaranteed to not - // be re-used by a process. They start at 1 and increase with each - // new thread. This allows easy command line access by a unique ID - // that is easier to type than the actual system thread ID. + // Get the thread index ID. The index ID that is guaranteed to not be re-used + // by a process. They start at 1 and increase with each new thread. This + // allows easy command line access by a unique ID that is easier to type than + // the actual system thread ID. //------------------------------------------------------------------ uint32_t GetIndexID() const; //------------------------------------------------------------------ // Get the originating thread's index ID. - // In the case of an "extended" thread -- a thread which represents - // the stack that enqueued/spawned work that is currently executing -- - // we need to provide the IndexID of the thread that actually did - // this work. We don't want to just masquerade as that thread's IndexID - // by using it in our own IndexID because that way leads to madness - - // but the driver program which is iterating over extended threads - // may ask for the OriginatingThreadID to display that information - // to the user. + // In the case of an "extended" thread -- a thread which represents the stack + // that enqueued/spawned work that is currently executing -- we need to + // provide the IndexID of the thread that actually did this work. We don't + // want to just masquerade as that thread's IndexID by using it in our own + // IndexID because that way leads to madness - but the driver program which + // is iterating over extended threads may ask for the OriginatingThreadID to + // display that information to the user. // Normal threads will return the same thing as GetIndexID(); //------------------------------------------------------------------ virtual uint32_t GetExtendedBacktraceOriginatingIndexID() { @@ -1139,10 +1124,10 @@ public: } //------------------------------------------------------------------ - // The API ID is often the same as the Thread::GetID(), but not in - // all cases. Thread::GetID() is the user visible thread ID that - // clients would want to see. The API thread ID is the thread ID - // that is used when sending data to/from the debugging protocol. + // The API ID is often the same as the Thread::GetID(), but not in all cases. + // Thread::GetID() is the user visible thread ID that clients would want to + // see. The API thread ID is the thread ID that is used when sending data + // to/from the debugging protocol. //------------------------------------------------------------------ virtual lldb::user_id_t GetProtocolID() const { return GetID(); } @@ -1171,9 +1156,9 @@ public: uint32_t num_frames_with_source); // We need a way to verify that even though we have a thread in a shared - // pointer that the object itself is still valid. Currently this won't be - // the case if DestroyThread() was called. DestroyThread is called when - // a thread has been removed from the Process' thread list. + // pointer that the object itself is still valid. Currently this won't be the + // case if DestroyThread() was called. DestroyThread is called when a thread + // has been removed from the Process' thread list. bool IsValid() const { return !m_destroy_called; } // Sets and returns a valid stop info based on the process stop ID and the @@ -1194,8 +1179,8 @@ public: //---------------------------------------------------------------------- // Ask the thread subclass to set its stop info. // - // Thread subclasses should call Thread::SetStopInfo(...) with the - // reason the thread stopped. + // Thread subclasses should call Thread::SetStopInfo(...) with the reason the + // thread stopped. // // @return // True if Thread::SetStopInfo(...) was called, false otherwise. @@ -1206,10 +1191,10 @@ public: // Gets the temporary resume state for a thread. // // This value gets set in each thread by complex debugger logic in - // Thread::ShouldResume() and an appropriate thread resume state will get - // set in each thread every time the process is resumed prior to calling - // Process::DoResume(). The lldb_private::Process subclass should adhere - // to the thread resume state request which will be one of: + // Thread::ShouldResume() and an appropriate thread resume state will get set + // in each thread every time the process is resumed prior to calling + // Process::DoResume(). The lldb_private::Process subclass should adhere to + // the thread resume state request which will be one of: // // eStateRunning - thread will resume when process is resumed // eStateStepping - thread should step 1 instruction and stop when process @@ -1257,10 +1242,9 @@ protected: friend class StackFrame; friend class OperatingSystem; - // This is necessary to make sure thread assets get destroyed while the thread - // is still in good shape - // to call virtual thread methods. This must be called by classes that derive - // from Thread in their destructor. + // This is necessary to make sure thread assets get destroyed while the + // thread is still in good shape to call virtual thread methods. This must + // be called by classes that derive from Thread in their destructor. virtual void DestroyThread(); void PushPlan(lldb::ThreadPlanSP &plan_sp); @@ -1286,8 +1270,7 @@ protected: virtual bool IsOperatingSystemPluginThread() const { return false; } // Subclasses that have a way to get an extended info dictionary for this - // thread should - // fill + // thread should fill virtual lldb_private::StructuredData::ObjectSP FetchThreadExtendedInfo() { return StructuredData::ObjectSP(); } @@ -1307,7 +1290,8 @@ protected: lldb::StopInfoSP m_stop_info_sp; ///< The private stop reason for this thread uint32_t m_stop_info_stop_id; // This is the stop id for which the StopInfo is // valid. Can use this so you know that - // the thread's m_stop_info_sp is current and you don't have to fetch it again + // the thread's m_stop_info_sp is current and you don't have to fetch it + // again uint32_t m_stop_info_override_stop_id; // The stop ID containing the last time // the stop info was checked against // the stop info override diff --git a/include/lldb/Target/ThreadCollection.h b/include/lldb/Target/ThreadCollection.h index e3965b57e7a6a..dd5e81c1af480 100644 --- a/include/lldb/Target/ThreadCollection.h +++ b/include/lldb/Target/ThreadCollection.h @@ -39,9 +39,9 @@ public: void InsertThread(const lldb::ThreadSP &thread_sp, uint32_t idx); - // Note that "idx" is not the same as the "thread_index". It is a zero - // based index to accessing the current threads, whereas "thread_index" - // is a unique index assigned + // Note that "idx" is not the same as the "thread_index". It is a zero based + // index to accessing the current threads, whereas "thread_index" is a unique + // index assigned lldb::ThreadSP GetThreadAtIndex(uint32_t idx); virtual ThreadIterable Threads() { diff --git a/include/lldb/Target/ThreadList.h b/include/lldb/Target/ThreadList.h index 2ebcd0b0e2c90..6285cb1e0fb46 100644 --- a/include/lldb/Target/ThreadList.h +++ b/include/lldb/Target/ThreadList.h @@ -43,9 +43,8 @@ public: lldb::ThreadSP GetSelectedThread(); // Manage the thread to use for running expressions. This is usually the - // Selected thread, - // but sometimes (e.g. when evaluating breakpoint conditions & stop hooks) it - // isn't. + // Selected thread, but sometimes (e.g. when evaluating breakpoint conditions + // & stop hooks) it isn't. class ExpressionExecutionThreadPusher { public: ExpressionExecutionThreadPusher(ThreadList &thread_list, lldb::tid_t tid) @@ -83,9 +82,9 @@ public: void Destroy(); - // Note that "idx" is not the same as the "thread_index". It is a zero - // based index to accessing the current threads, whereas "thread_index" - // is a unique index assigned + // Note that "idx" is not the same as the "thread_index". It is a zero based + // index to accessing the current threads, whereas "thread_index" is a unique + // index assigned lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update = true); lldb::ThreadSP FindThreadByID(lldb::tid_t tid, bool can_update = true); @@ -102,6 +101,8 @@ public: lldb::ThreadSP GetThreadSPForThreadPtr(Thread *thread_ptr); + lldb::ThreadSP GetBackingThread(const lldb::ThreadSP &real_thread); + bool ShouldStop(Event *event_ptr); Vote ShouldReportStop(Event *event_ptr); diff --git a/include/lldb/Target/ThreadPlan.h b/include/lldb/Target/ThreadPlan.h index acc63ffe562b5..7591fa9c9d072 100644 --- a/include/lldb/Target/ThreadPlan.h +++ b/include/lldb/Target/ThreadPlan.h @@ -340,9 +340,8 @@ class ThreadPlan : public std::enable_shared_from_this<ThreadPlan>, public: typedef enum { eAllThreads, eSomeThreads, eThisThread } ThreadScope; - // We use these enums so that we can cast a base thread plan to it's real type - // without having to resort - // to dynamic casting. + // We use these enums so that we can cast a base thread plan to it's real + // type without having to resort to dynamic casting. typedef enum { eKindGeneric, eKindNull, @@ -432,9 +431,8 @@ public: virtual bool ShouldAutoContinue(Event *event_ptr) { return false; } - // Whether a "stop class" event should be reported to the "outside world". In - // general - // if a thread plan is active, events should not be reported. + // Whether a "stop class" event should be reported to the "outside world". + // In general if a thread plan is active, events should not be reported. virtual Vote ShouldReportStop(Event *event_ptr); @@ -445,8 +443,7 @@ public: virtual bool StopOthers(); // This is the wrapper for DoWillResume that does generic ThreadPlan logic, - // then - // calls DoWillResume. + // then calls DoWillResume. bool WillResume(lldb::StateType resume_state, bool current_plan); virtual bool WillStop() = 0; @@ -468,8 +465,8 @@ public: virtual bool MischiefManaged(); virtual void ThreadDestroyed() { - // Any cleanup that a plan might want to do in case the thread goes away - // in the middle of the plan being queued on a thread can be done here. + // Any cleanup that a plan might want to do in case the thread goes away in + // the middle of the plan being queued on a thread can be done here. } bool GetPrivate() { return m_plan_private; } @@ -509,39 +506,35 @@ public: } // Some thread plans hide away the actual stop info which caused any - // particular stop. For - // instance the ThreadPlanCallFunction restores the original stop reason so - // that stopping and - // calling a few functions won't lose the history of the run. - // This call can be implemented to get you back to the real stop info. + // particular stop. For instance the ThreadPlanCallFunction restores the + // original stop reason so that stopping and calling a few functions won't + // lose the history of the run. This call can be implemented to get you back + // to the real stop info. virtual lldb::StopInfoSP GetRealStopInfo() { return m_thread.GetStopInfo(); } // If the completion of the thread plan stepped out of a function, the return - // value of the function - // might have been captured by the thread plan (currently only - // ThreadPlanStepOut does this.) - // If so, the ReturnValueObject can be retrieved from here. + // value of the function might have been captured by the thread plan + // (currently only ThreadPlanStepOut does this.) If so, the ReturnValueObject + // can be retrieved from here. virtual lldb::ValueObjectSP GetReturnValueObject() { return lldb::ValueObjectSP(); } // If the thread plan managing the evaluation of a user expression lives - // longer than the command - // that instigated the expression (generally because the expression evaluation - // hit a breakpoint, and - // the user regained control at that point) a subsequent process control - // command step/continue/etc. might - // complete the expression evaluations. If so, the result of the expression - // evaluation will show up here. + // longer than the command that instigated the expression (generally because + // the expression evaluation hit a breakpoint, and the user regained control + // at that point) a subsequent process control command step/continue/etc. + // might complete the expression evaluations. If so, the result of the + // expression evaluation will show up here. virtual lldb::ExpressionVariableSP GetExpressionVariable() { return lldb::ExpressionVariableSP(); } - // If a thread plan stores the state before it was run, then you might - // want to restore the state when it is done. This will do that job. - // This is mostly useful for artificial plans like CallFunction plans. + // If a thread plan stores the state before it was run, then you might want + // to restore the state when it is done. This will do that job. This is + // mostly useful for artificial plans like CallFunction plans. virtual bool RestoreThreadState() { // Nothing to do in general. @@ -585,8 +578,7 @@ protected: ThreadPlan *GetPreviousPlan() { return m_thread.GetPreviousPlan(this); } // This forwards the private Thread::GetPrivateStopInfo which is generally - // what - // ThreadPlan's need to know. + // what ThreadPlan's need to know. lldb::StopInfoSP GetPrivateStopInfo() { return m_thread.GetPrivateStopInfo(); @@ -638,10 +630,10 @@ private: //---------------------------------------------------------------------- // ThreadPlanNull: -// Threads are assumed to always have at least one plan on the plan stack. -// This is put on the plan stack when a thread is destroyed so that if you -// accidentally access a thread after it is destroyed you won't crash. -// But asking questions of the ThreadPlanNull is definitely an error. +// Threads are assumed to always have at least one plan on the plan stack. This +// is put on the plan stack when a thread is destroyed so that if you +// accidentally access a thread after it is destroyed you won't crash. But +// asking questions of the ThreadPlanNull is definitely an error. //---------------------------------------------------------------------- class ThreadPlanNull : public ThreadPlan { diff --git a/include/lldb/Target/ThreadPlanCallFunction.h b/include/lldb/Target/ThreadPlanCallFunction.h index 1c75b0a3645c0..56bfc819320c0 100644 --- a/include/lldb/Target/ThreadPlanCallFunction.h +++ b/include/lldb/Target/ThreadPlanCallFunction.h @@ -24,9 +24,8 @@ namespace lldb_private { class ThreadPlanCallFunction : public ThreadPlan { // Create a thread plan to call a function at the address passed in the - // "function" - // argument. If you plan to call GetReturnValueObject, then pass in the - // return type, otherwise just pass in an invalid CompilerType. + // "function" argument. If you plan to call GetReturnValueObject, then pass + // in the return type, otherwise just pass in an invalid CompilerType. public: ThreadPlanCallFunction(Thread &thread, const Address &function, const CompilerType &return_type, @@ -69,27 +68,23 @@ public: return m_return_valobj_sp; } - // Return the stack pointer that the function received - // on entry. Any stack address below this should be - // considered invalid after the function has been - // cleaned up. + // Return the stack pointer that the function received on entry. Any stack + // address below this should be considered invalid after the function has + // been cleaned up. lldb::addr_t GetFunctionStackPointer() { return m_function_sp; } - // Classes that derive from FunctionCaller, and implement - // their own WillPop methods should call this so that the - // thread state gets restored if the plan gets discarded. + // Classes that derive from FunctionCaller, and implement their own WillPop + // methods should call this so that the thread state gets restored if the + // plan gets discarded. void WillPop() override; // If the thread plan stops mid-course, this will be the stop reason that - // interrupted us. - // Once DoTakedown is called, this will be the real stop reason at the end of - // the function call. - // If it hasn't been set for one or the other of these reasons, we'll return - // the PrivateStopReason. - // This is needed because we want the CallFunction thread plans not to show up - // as the stop reason. - // But if something bad goes wrong, it is nice to be able to tell the user - // what really happened. + // interrupted us. Once DoTakedown is called, this will be the real stop + // reason at the end of the function call. If it hasn't been set for one or + // the other of these reasons, we'll return the PrivateStopReason. This is + // needed because we want the CallFunction thread plans not to show up as the + // stop reason. But if something bad goes wrong, it is nice to be able to + // tell the user what really happened. lldb::StopInfoSP GetRealStopInfo() override { if (m_real_stop_info_sp) @@ -140,9 +135,9 @@ protected: Thread::ThreadStateCheckpoint m_stored_thread_state; lldb::StopInfoSP m_real_stop_info_sp; // In general we want to hide call function - // thread plans, but for reporting purposes, - // it's nice to know the real stop reason. - // This gets set in DoTakedown. + // thread plans, but for reporting purposes, it's + // nice to know the real stop reason. This gets set + // in DoTakedown. StreamString m_constructor_errors; lldb::ValueObjectSP m_return_valobj_sp; // If this contains a valid pointer, // use the ABI to extract values when diff --git a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h index 1c67ddd5cdda9..d58f7f050dbec 100644 --- a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h +++ b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h @@ -27,11 +27,9 @@ namespace lldb_private { class ThreadPlanCallFunctionUsingABI : public ThreadPlanCallFunction { // Create a thread plan to call a function at the address passed in the - // "function" - // argument, this function is executed using register manipulation instead of - // JIT. - // Class derives from ThreadPlanCallFunction and differs by calling a - // alternative + // "function" argument, this function is executed using register manipulation + // instead of JIT. Class derives from ThreadPlanCallFunction and differs by + // calling a alternative // ABI interface ABI::PrepareTrivialCall() which provides more detailed // information. public: diff --git a/include/lldb/Target/ThreadPlanShouldStopHere.h b/include/lldb/Target/ThreadPlanShouldStopHere.h index 60c0e38667073..030d5e434bd92 100644 --- a/include/lldb/Target/ThreadPlanShouldStopHere.h +++ b/include/lldb/Target/ThreadPlanShouldStopHere.h @@ -19,20 +19,16 @@ namespace lldb_private { // This is an interface that ThreadPlans can adopt to allow flexible -// modifications of the behavior -// when a thread plan comes to a place where it would ordinarily stop. If such -// modification makes -// sense for your plan, inherit from this class, and when you would be about to -// stop (in your ShouldStop -// method), call InvokeShouldStopHereCallback, passing in the frame comparison -// between where the step operation -// started and where you arrived. If it returns true, then QueueStepOutFromHere -// will queue the plan -// to execute instead of stopping. +// modifications of the behavior when a thread plan comes to a place where it +// would ordinarily stop. If such modification makes sense for your plan, +// inherit from this class, and when you would be about to stop (in your +// ShouldStop method), call InvokeShouldStopHereCallback, passing in the frame +// comparison between where the step operation started and where you arrived. +// If it returns true, then QueueStepOutFromHere will queue the plan to execute +// instead of stopping. // // The classic example of the use of this is ThreadPlanStepInRange not stopping -// in frames that have -// no debug information. +// in frames that have no debug information. // // This class also defines a set of flags to control general aspects of this // "ShouldStop" behavior. @@ -82,11 +78,9 @@ public: virtual ~ThreadPlanShouldStopHere(); // Set the ShouldStopHere callbacks. Pass in null to clear them and have no - // special behavior (though you - // can also call ClearShouldStopHereCallbacks for that purpose. If you pass - // in a valid pointer, it will - // adopt the non-null fields, and any null fields will be set to the default - // values. + // special behavior (though you can also call ClearShouldStopHereCallbacks + // for that purpose. If you pass in a valid pointer, it will adopt the non- + // null fields, and any null fields will be set to the default values. void SetShouldStopHereCallbacks(const ThreadPlanShouldStopHereCallbacks *callbacks, diff --git a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h index 969c008f67d1c..e799ec5a44ff0 100644 --- a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h +++ b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h @@ -31,6 +31,7 @@ public: bool StopOthers() override; lldb::StateType GetPlanRunState() override; bool WillStop() override; + void WillPop() override; bool MischiefManaged() override; void ThreadDestroyed() override; void SetAutoContinue(bool do_it); diff --git a/include/lldb/Target/ThreadPlanStepRange.h b/include/lldb/Target/ThreadPlanStepRange.h index ffb27d02e2d08..65bc1671cb1e5 100644 --- a/include/lldb/Target/ThreadPlanStepRange.h +++ b/include/lldb/Target/ThreadPlanStepRange.h @@ -58,10 +58,9 @@ protected: size_t &insn_offset); // Pushes a plan to proceed through the next section of instructions in the - // range - usually just a RunToAddress - // plan to run to the next branch. Returns true if it pushed such a plan. If - // there was no available 'quick run' - // plan, then just single step. + // range - usually just a RunToAddress plan to run to the next branch. + // Returns true if it pushed such a plan. If there was no available 'quick + // run' plan, then just single step. bool SetNextBranchBreakpoint(); void ClearNextBranchBreakpoint(); diff --git a/include/lldb/Target/UnixSignals.h b/include/lldb/Target/UnixSignals.h index a209f3549aed7..7ec683585f8e0 100644 --- a/include/lldb/Target/UnixSignals.h +++ b/include/lldb/Target/UnixSignals.h @@ -63,8 +63,7 @@ public: // These provide an iterator through the signals available on this system. // Call GetFirstSignalNumber to get the first entry, then iterate on - // GetNextSignalNumber - // till you get back LLDB_INVALID_SIGNAL_NUMBER. + // GetNextSignalNumber till you get back LLDB_INVALID_SIGNAL_NUMBER. int32_t GetFirstSignalNumber() const; int32_t GetNextSignalNumber(int32_t current_signal) const; @@ -76,13 +75,10 @@ public: ConstString GetShortName(ConstString name) const; // We assume that the elements of this object are constant once it is - // constructed, - // since a process should never need to add or remove symbols as it runs. So - // don't - // call these functions anywhere but the constructor of your subclass of - // UnixSignals or in - // your Process Plugin's GetUnixSignals method before you return the - // UnixSignal object. + // constructed, since a process should never need to add or remove symbols as + // it runs. So don't call these functions anywhere but the constructor of + // your subclass of UnixSignals or in your Process Plugin's GetUnixSignals + // method before you return the UnixSignal object. void AddSignal(int signo, const char *name, bool default_suppress, bool default_stop, bool default_notify, @@ -90,15 +86,14 @@ public: void RemoveSignal(int signo); - // Returns a current version of the data stored in this class. - // Version gets incremented each time Set... method is called. + // Returns a current version of the data stored in this class. Version gets + // incremented each time Set... method is called. uint64_t GetVersion() const; - // Returns a vector of signals that meet criteria provided in arguments. - // Each should_[suppress|stop|notify] flag can be - // None - no filtering by this flag - // true - only signals that have it set to true are returned - // false - only signals that have it set to true are returned + // Returns a vector of signals that meet criteria provided in arguments. Each + // should_[suppress|stop|notify] flag can be None - no filtering by this + // flag true - only signals that have it set to true are returned false - + // only signals that have it set to true are returned std::vector<int32_t> GetFilteredSignals(llvm::Optional<bool> should_suppress, llvm::Optional<bool> should_stop, llvm::Optional<bool> should_notify); @@ -126,10 +121,10 @@ protected: collection m_signals; - // This version gets incremented every time something is changing in - // this class, including when we call AddSignal from the constructor. - // So after the object is constructed m_version is going to be > 0 - // if it has at least one signal registered in it. + // This version gets incremented every time something is changing in this + // class, including when we call AddSignal from the constructor. So after the + // object is constructed m_version is going to be > 0 if it has at least one + // signal registered in it. uint64_t m_version = 0; // GDBRemote signals need to be copyable. diff --git a/include/lldb/Utility/AnsiTerminal.h b/include/lldb/Utility/AnsiTerminal.h index 5eaf2fd0e069e..b5ff239f800d1 100644 --- a/include/lldb/Utility/AnsiTerminal.h +++ b/include/lldb/Utility/AnsiTerminal.h @@ -50,6 +50,7 @@ #define ANSI_1_CTRL(ctrl1) "\033["##ctrl1 ANSI_ESC_END #define ANSI_2_CTRL(ctrl1, ctrl2) "\033["##ctrl1 ";"##ctrl2 ANSI_ESC_END +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" @@ -118,17 +119,21 @@ inline std::string FormatAnsiTerminalCodes(llvm::StringRef format, break; } + bool found_code = false; for (const auto &code : codes) { if (!right.consume_front(code.name)) continue; if (do_color) fmt.append(code.value); - format = right; + found_code = true; break; } - - format = format.drop_front(); + format = right; + // If we haven't found a valid replacement value, we just copy the string + // to the result without any modifications. + if (!found_code) + fmt.append(tok_hdr); } return fmt; } diff --git a/include/lldb/Utility/ArchSpec.h b/include/lldb/Utility/ArchSpec.h index 50f69606e3df3..680e9b1b9ea66 100644 --- a/include/lldb/Utility/ArchSpec.h +++ b/include/lldb/Utility/ArchSpec.h @@ -10,6 +10,7 @@ #ifndef LLDB_UTILITY_ARCHSPEC_H #define LLDB_UTILITY_ARCHSPEC_H +#include "lldb/Utility/CompletionRequest.h" #include "lldb/Utility/ConstString.h" #include "lldb/lldb-enumerations.h" #include "lldb/lldb-forward.h" @@ -23,13 +24,13 @@ namespace lldb_private { //---------------------------------------------------------------------- -/// @class ArchSpec ArchSpec.h "lldb/Utility/ArchSpec.h" -/// @brief An architecture specification class. +/// @class ArchSpec ArchSpec.h "lldb/Utility/ArchSpec.h" An architecture +/// specification class. /// /// A class designed to be created from a cpu type and subtype, a -/// string representation, or an llvm::Triple. Keeping all of the -/// conversions of strings to architecture enumeration values confined -/// to this class allows new architecture support to be added easily. +/// string representation, or an llvm::Triple. Keeping all of the conversions +/// of strings to architecture enumeration values confined to this class +/// allows new architecture support to be added easily. //---------------------------------------------------------------------- class ArchSpec { public: @@ -245,16 +246,15 @@ public: //------------------------------------------------------------------ /// Default constructor. /// - /// Default constructor that initializes the object with invalid - /// cpu type and subtype values. + /// Default constructor that initializes the object with invalid cpu type + /// and subtype values. //------------------------------------------------------------------ ArchSpec(); //------------------------------------------------------------------ /// Constructor over triple. /// - /// Constructs an ArchSpec with properties consistent with the given - /// Triple. + /// Constructs an ArchSpec with properties consistent with the given Triple. //------------------------------------------------------------------ explicit ArchSpec(const llvm::Triple &triple); explicit ArchSpec(const char *triple_cstr); @@ -262,8 +262,8 @@ public: //------------------------------------------------------------------ /// Constructor over architecture name. /// - /// Constructs an ArchSpec with properties consistent with the given - /// object type and architecture name. + /// Constructs an ArchSpec with properties consistent with the given object + /// type and architecture name. //------------------------------------------------------------------ explicit ArchSpec(ArchitectureType arch_type, uint32_t cpu_type, uint32_t cpu_subtype); @@ -284,16 +284,18 @@ public: //--------------------------------------------------------------------------- /// Returns true if the OS, vendor and environment fields of the triple are - /// unset. The triple is expected to be normalized (llvm::Triple::normalize). + /// unset. The triple is expected to be normalized + /// (llvm::Triple::normalize). //--------------------------------------------------------------------------- static bool ContainsOnlyArch(const llvm::Triple &normalized_triple); - static size_t AutoComplete(llvm::StringRef name, StringList &matches); + static void ListSupportedArchNames(StringList &list); + static size_t AutoComplete(CompletionRequest &request); //------------------------------------------------------------------ /// Returns a static string representing the current architecture. /// - /// @return A static string correcponding to the current + /// @return A static string corresponding to the current /// architecture. //------------------------------------------------------------------ const char *GetArchitectureName() const; @@ -306,8 +308,8 @@ public: bool IsMIPS() const; //------------------------------------------------------------------ - /// Returns a string representing current architecture as a target CPU - /// for tools like compiler, disassembler etc. + /// Returns a string representing current architecture as a target CPU for + /// tools like compiler, disassembler etc. /// /// @return A string representing target CPU for the current /// architecture. @@ -329,8 +331,7 @@ public: void Clear(); //------------------------------------------------------------------ - /// Returns the size in bytes of an address of the current - /// architecture. + /// Returns the size in bytes of an address of the current architecture. /// /// @return The byte size of an address of the current architecture. //------------------------------------------------------------------ @@ -356,9 +357,8 @@ public: //------------------------------------------------------------------ /// Set the distribution id of the architecture. /// - /// This will be something like "ubuntu", "fedora", etc. on Linux. - /// This should be the same value returned by - /// HostInfo::GetDistributionId (). + /// This will be something like "ubuntu", "fedora", etc. on Linux. This + /// should be the same value returned by HostInfo::GetDistributionId (). ///------------------------------------------------------------------ void SetDistributionId(const char *distribution_id); @@ -395,13 +395,12 @@ public: //------------------------------------------------------------------ /// Merges fields from another ArchSpec into this ArchSpec. /// - /// This will use the supplied ArchSpec to fill in any fields of - /// the triple in this ArchSpec which were unspecified. This can - /// be used to refine a generic ArchSpec with a more specific one. - /// For example, if this ArchSpec's triple is something like - /// i386-unknown-unknown-unknown, and we have a triple which is - /// x64-pc-windows-msvc, then merging that triple into this one - /// will result in the triple i386-pc-windows-msvc. + /// This will use the supplied ArchSpec to fill in any fields of the triple + /// in this ArchSpec which were unspecified. This can be used to refine a + /// generic ArchSpec with a more specific one. For example, if this + /// ArchSpec's triple is something like i386-unknown-unknown-unknown, and we + /// have a triple which is x64-pc-windows-msvc, then merging that triple + /// into this one will result in the triple i386-pc-windows-msvc. /// //------------------------------------------------------------------ void MergeFrom(const ArchSpec &other); @@ -421,16 +420,16 @@ public: /// /// @return True if the object, and CPU were successfully set. /// - /// As a side effect, the vendor value is usually set to unknown. - /// The exections are + /// As a side effect, the vendor value is usually set to unknown. The + /// exceptions are /// aarch64-apple-ios /// arm-apple-ios /// thumb-apple-ios /// x86-apple- /// x86_64-apple- /// - /// As a side effect, the os value is usually set to unknown - /// The exceptions are + /// As a side effect, the os value is usually set to unknown The exceptions + /// are /// *-*-aix /// aarch64-apple-ios /// arm-apple-ios @@ -456,10 +455,10 @@ public: //------------------------------------------------------------------ /// Sets this ArchSpec's byte order. /// - /// In the common case there is no need to call this method as the - /// byte order can almost always be determined by the architecture. - /// However, many CPU's are bi-endian (ARM, Alpha, PowerPC, etc) - /// and the default/assumed byte order may be incorrect. + /// In the common case there is no need to call this method as the byte + /// order can almost always be determined by the architecture. However, many + /// CPU's are bi-endian (ARM, Alpha, PowerPC, etc) and the default/assumed + /// byte order may be incorrect. //------------------------------------------------------------------ void SetByteOrder(lldb::ByteOrder byte_order) { m_byte_order = byte_order; } @@ -476,28 +475,28 @@ public: //------------------------------------------------------------------ /// Architecture data byte width accessor /// - /// @return the size in 8-bit (host) bytes of a minimum addressable - /// unit from the Architecture's data bus + /// @return the size in 8-bit (host) bytes of a minimum addressable unit + /// from the Architecture's data bus //------------------------------------------------------------------ uint32_t GetDataByteSize() const; //------------------------------------------------------------------ /// Architecture code byte width accessor /// - /// @return the size in 8-bit (host) bytes of a minimum addressable - /// unit from the Architecture's code bus + /// @return the size in 8-bit (host) bytes of a minimum addressable unit + /// from the Architecture's code bus //------------------------------------------------------------------ uint32_t GetCodeByteSize() const; //------------------------------------------------------------------ - /// Architecture tripple accessor. + /// Architecture triple accessor. /// /// @return A triple describing this ArchSpec. //------------------------------------------------------------------ llvm::Triple &GetTriple() { return m_triple; } //------------------------------------------------------------------ - /// Architecture tripple accessor. + /// Architecture triple accessor. /// /// @return A triple describing this ArchSpec. //------------------------------------------------------------------ @@ -506,14 +505,14 @@ public: void DumpTriple(Stream &s) const; //------------------------------------------------------------------ - /// Architecture tripple setter. + /// Architecture triple setter. /// - /// Configures this ArchSpec according to the given triple. If the - /// triple has unknown components in all of the vendor, OS, and - /// the optional environment field (i.e. "i386-unknown-unknown") - /// then default values are taken from the host. Architecture and - /// environment components are used to further resolve the CPU type - /// and subtype, endian characteristics, etc. + /// Configures this ArchSpec according to the given triple. If the triple + /// has unknown components in all of the vendor, OS, and the optional + /// environment field (i.e. "i386-unknown-unknown") then default values are + /// taken from the host. Architecture and environment components are used + /// to further resolve the CPU type and subtype, endian characteristics, + /// etc. /// /// @return A triple describing this ArchSpec. //------------------------------------------------------------------ @@ -530,8 +529,8 @@ public: lldb::ByteOrder GetDefaultEndian() const; //------------------------------------------------------------------ - /// Returns true if 'char' is a signed type by defualt in the - /// architecture false otherwise + /// Returns true if 'char' is a signed type by default in the architecture + /// false otherwise /// /// @return True if 'char' is a signed type by default on the /// architecture and false otherwise. @@ -539,18 +538,18 @@ public: bool CharIsSignedByDefault() const; //------------------------------------------------------------------ - /// Compare an ArchSpec to another ArchSpec, requiring an exact cpu - /// type match between them. - /// e.g. armv7s is not an exact match with armv7 - this would return false + /// Compare an ArchSpec to another ArchSpec, requiring an exact cpu type + /// match between them. e.g. armv7s is not an exact match with armv7 - this + /// would return false /// /// @return true if the two ArchSpecs match. //------------------------------------------------------------------ bool IsExactMatch(const ArchSpec &rhs) const; //------------------------------------------------------------------ - /// Compare an ArchSpec to another ArchSpec, requiring a compatible - /// cpu type match between them. - /// e.g. armv7s is compatible with armv7 - this method would return true + /// Compare an ArchSpec to another ArchSpec, requiring a compatible cpu type + /// match between them. e.g. armv7s is compatible with armv7 - this method + /// would return true /// /// @return true if the two ArchSpecs are compatible //------------------------------------------------------------------ @@ -566,12 +565,12 @@ public: //------------------------------------------------------------------ /// Detect whether this architecture uses thumb code exclusively /// - /// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can - /// only execute the Thumb instructions, never Arm. We should normally - /// pick up arm/thumbness from their the processor status bits (cpsr/xpsr) - /// or hints on each function - but when doing bare-boards low level - /// debugging (especially common with these embedded processors), we may - /// not have those things easily accessible. + /// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can only execute + /// the Thumb instructions, never Arm. We should normally pick up + /// arm/thumbness from their the processor status bits (cpsr/xpsr) or hints + /// on each function - but when doing bare-boards low level debugging + /// (especially common with these embedded processors), we may not have + /// those things easily accessible. /// /// @return true if this is an arm ArchSpec which can only execute Thumb /// instructions @@ -592,31 +591,30 @@ protected: Core m_core = kCore_invalid; lldb::ByteOrder m_byte_order = lldb::eByteOrderInvalid; - // Additional arch flags which we cannot get from triple and core - // For MIPS these are application specific extensions like - // micromips, mips16 etc. + // Additional arch flags which we cannot get from triple and core For MIPS + // these are application specific extensions like micromips, mips16 etc. uint32_t m_flags = 0; ConstString m_distribution_id; - // Called when m_def or m_entry are changed. Fills in all remaining - // members with default values. + // Called when m_def or m_entry are changed. Fills in all remaining members + // with default values. void CoreUpdated(bool update_triple); }; //------------------------------------------------------------------ -/// @fn bool operator< (const ArchSpec& lhs, const ArchSpec& rhs) -/// @brief Less than operator. +/// @fn bool operator< (const ArchSpec& lhs, const ArchSpec& rhs) Less than +/// operator. /// -/// Tests two ArchSpec objects to see if \a lhs is less than \a -/// rhs. +/// Tests two ArchSpec objects to see if \a lhs is less than \a rhs. /// -/// @param[in] lhs The Left Hand Side ArchSpec object to compare. -/// @param[in] rhs The Left Hand Side ArchSpec object to compare. +/// @param[in] lhs The Left Hand Side ArchSpec object to compare. @param[in] +/// rhs The Left Hand Side ArchSpec object to compare. /// /// @return true if \a lhs is less than \a rhs //------------------------------------------------------------------ bool operator<(const ArchSpec &lhs, const ArchSpec &rhs); +bool operator==(const ArchSpec &lhs, const ArchSpec &rhs); bool ParseMachCPUDashSubtypeTriple(llvm::StringRef triple_str, ArchSpec &arch); diff --git a/include/lldb/Interpreter/Args.h b/include/lldb/Utility/Args.h index 19d7ac4185665..dec3dfaa4785b 100644 --- a/include/lldb/Interpreter/Args.h +++ b/include/lldb/Utility/Args.h @@ -7,54 +7,30 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_Command_h_ -#define liblldb_Command_h_ +#ifndef LLDB_UTILITY_ARGS_H +#define LLDB_UTILITY_ARGS_H -// C Includes -// C++ Includes -#include <list> +#include "lldb/Utility/Environment.h" +#include "lldb/lldb-private-types.h" +#include "lldb/lldb-types.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" #include <string> #include <utility> #include <vector> -// Other libraries and framework includes -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/StringRef.h" -// Project includes -#include "lldb/Utility/Status.h" -#include "lldb/lldb-private-types.h" -#include "lldb/lldb-types.h" - namespace lldb_private { -struct Option; - -typedef std::vector<std::tuple<std::string, int, std::string>> OptionArgVector; -typedef std::shared_ptr<OptionArgVector> OptionArgVectorSP; - -struct OptionArgElement { - enum { eUnrecognizedArg = -1, eBareDash = -2, eBareDoubleDash = -3 }; - - OptionArgElement(int defs_index, int pos, int arg_pos) - : opt_defs_index(defs_index), opt_pos(pos), opt_arg_pos(arg_pos) {} - - int opt_defs_index; - int opt_pos; - int opt_arg_pos; -}; - -typedef std::vector<OptionArgElement> OptionElementVector; - //---------------------------------------------------------------------- -/// @class Args Args.h "lldb/Interpreter/Args.h" -/// @brief A command line argument class. +/// @class Args Args.h "lldb/Utility/Args.h" +/// A command line argument class. /// -/// The Args class is designed to be fed a command line. The -/// command line is copied into an internal buffer and then split up -/// into arguments. Arguments are space delimited if there are no quotes -/// (single, double, or backtick quotes) surrounding the argument. Spaces -/// can be escaped using a \ character to avoid having to surround an -/// argument that contains a space with quotes. +/// The Args class is designed to be fed a command line. The command line is +/// copied into an internal buffer and then split up into arguments. Arguments +/// are space delimited if there are no quotes (single, double, or backtick +/// quotes) surrounding the argument. Spaces can be escaped using a \ +/// character to avoid having to surround an argument that contains a space +/// with quotes. //---------------------------------------------------------------------- class Args { public: @@ -72,6 +48,11 @@ public: llvm::StringRef ref; char quote; const char *c_str() const { return ptr.get(); } + + //------------------------------------------------------------------ + /// Returns true if this argument was quoted in any way. + //------------------------------------------------------------------ + bool IsQuoted() const { return quote != '\0'; } }; //------------------------------------------------------------------ @@ -95,6 +76,12 @@ public: //------------------------------------------------------------------ ~Args(); + explicit Args(const Environment &env) : Args() { + SetArguments(const_cast<const char **>(env.getEnvp().get())); + } + + explicit operator Environment() const { return GetConstArgumentVector(); } + //------------------------------------------------------------------ /// Dump all entries to the stream \a s using label \a label_name. /// @@ -113,18 +100,17 @@ public: //------------------------------------------------------------------ /// Sets the command string contained by this object. /// - /// The command string will be copied and split up into arguments - /// that can be accessed via the accessor functions. + /// The command string will be copied and split up into arguments that can + /// be accessed via the accessor functions. /// /// @param[in] command /// A command StringRef that will be copied and split up /// into arguments. /// /// @see Args::GetArgumentCount() const - /// @see Args::GetArgumentAtIndex (size_t) const - /// @see Args::GetArgumentVector () - /// @see Args::Shift () - /// @see Args::Unshift (const char *) + /// @see Args::GetArgumentAtIndex (size_t) const @see + /// Args::GetArgumentVector () @see Args::Shift () @see Args::Unshift (const + /// char *) //------------------------------------------------------------------ void SetCommandString(llvm::StringRef command); @@ -142,8 +128,8 @@ public: bool empty() const { return GetArgumentCount() == 0; } //------------------------------------------------------------------ - /// Gets the NULL terminated C string argument pointer for the - /// argument at index \a idx. + /// Gets the NULL terminated C string argument pointer for the argument at + /// index \a idx. /// /// @return /// The NULL terminated C string argument pointer if \a idx is a @@ -154,10 +140,10 @@ public: llvm::ArrayRef<ArgEntry> entries() const { return m_entries; } char GetArgumentQuoteCharAtIndex(size_t idx) const; - std::vector<ArgEntry>::const_iterator begin() const { - return m_entries.begin(); - } - std::vector<ArgEntry>::const_iterator end() const { return m_entries.end(); } + using const_iterator = std::vector<ArgEntry>::const_iterator; + + const_iterator begin() const { return m_entries.begin(); } + const_iterator end() const { return m_entries.end(); } size_t size() const { return GetArgumentCount(); } const ArgEntry &operator[](size_t n) const { return m_entries[n]; } @@ -165,9 +151,9 @@ public: //------------------------------------------------------------------ /// Gets the argument vector. /// - /// The value returned by this function can be used by any function - /// that takes and vector. The return value is just like \a argv - /// in the standard C entry point function: + /// The value returned by this function can be used by any function that + /// takes and vector. The return value is just like \a argv in the standard + /// C entry point function: /// \code /// int main (int argc, const char **argv); /// \endcode @@ -181,9 +167,9 @@ public: //------------------------------------------------------------------ /// Gets the argument vector. /// - /// The value returned by this function can be used by any function - /// that takes and vector. The return value is just like \a argv - /// in the standard C entry point function: + /// The value returned by this function can be used by any function that + /// takes and vector. The return value is just like \a argv in the standard + /// C entry point function: /// \code /// int main (int argc, const char **argv); /// \endcode @@ -237,8 +223,8 @@ public: char quote_char = '\0'); //------------------------------------------------------------------ - /// Replaces the argument value at index \a idx to \a arg_cstr - /// if \a idx is a valid argument index. + /// Replaces the argument value at index \a idx to \a arg_cstr if \a idx is + /// a valid argument index. /// /// @param[in] idx /// The index of the argument that will have its value replaced. @@ -263,11 +249,11 @@ public: void DeleteArgumentAtIndex(size_t idx); //------------------------------------------------------------------ - /// Sets the argument vector value, optionally copying all - /// arguments into an internal buffer. + /// Sets the argument vector value, optionally copying all arguments into an + /// internal buffer. /// - /// Sets the arguments to match those found in \a argv. All argument - /// strings will be copied into an internal buffers. + /// Sets the arguments to match those found in \a argv. All argument strings + /// will be copied into an internal buffers. // // FIXME: Handle the quote character somehow. //------------------------------------------------------------------ @@ -276,21 +262,20 @@ public: void SetArguments(const char **argv); //------------------------------------------------------------------ - /// Shifts the first argument C string value of the array off the - /// argument array. + /// Shifts the first argument C string value of the array off the argument + /// array. /// - /// The string value will be freed, so a copy of the string should - /// be made by calling Args::GetArgumentAtIndex (size_t) const - /// first and copying the returned value before calling - /// Args::Shift(). + /// The string value will be freed, so a copy of the string should be made + /// by calling Args::GetArgumentAtIndex (size_t) const first and copying the + /// returned value before calling Args::Shift(). /// /// @see Args::GetArgumentAtIndex (size_t) const //------------------------------------------------------------------ void Shift(); //------------------------------------------------------------------ - /// Inserts a class owned copy of \a arg_cstr at the beginning of - /// the argument vector. + /// Inserts a class owned copy of \a arg_cstr at the beginning of the + /// argument vector. /// /// A copy \a arg_cstr will be made. /// @@ -303,44 +288,6 @@ public: void Unshift(llvm::StringRef arg_str, char quote_char = '\0'); //------------------------------------------------------------------ - /// Parse the arguments in the contained arguments. - /// - /// The arguments that are consumed by the argument parsing process - /// will be removed from the argument vector. The arguments that - /// get processed start at the second argument. The first argument - /// is assumed to be the command and will not be touched. - /// - /// param[in] platform_sp - /// The platform used for option validation. This is necessary - /// because an empty execution_context is not enough to get us - /// to a reasonable platform. If the platform isn't given, - /// we'll try to get it from the execution context. If we can't - /// get it from the execution context, we'll skip validation. - /// - /// param[in] require_validation - /// When true, it will fail option parsing if validation could - /// not occur due to not having a platform. - /// - /// @see class Options - //------------------------------------------------------------------ - Status ParseOptions(Options &options, ExecutionContext *execution_context, - lldb::PlatformSP platform_sp, bool require_validation); - - bool IsPositionalArgument(const char *arg); - - // The following works almost identically to ParseOptions, except that no - // option is required to have arguments, and it builds up the - // option_arg_vector as it parses the options. - - std::string ParseAliasOptions(Options &options, CommandReturnObject &result, - OptionArgVector *option_arg_vector, - llvm::StringRef raw_input_line); - - void ParseArgsForCompletion(Options &options, - OptionElementVector &option_element_vector, - uint32_t cursor_index); - - //------------------------------------------------------------------ // Clear the arguments. // // For re-setting or blanking out the list of arguments. @@ -376,39 +323,12 @@ public: return min <= sval64 && sval64 <= max; } - static lldb::addr_t StringToAddress(const ExecutionContext *exe_ctx, - llvm::StringRef s, - lldb::addr_t fail_value, Status *error); - - static bool StringToBoolean(llvm::StringRef s, bool fail_value, - bool *success_ptr); - - static char StringToChar(llvm::StringRef s, char fail_value, - bool *success_ptr); - - static int64_t StringToOptionEnum(llvm::StringRef s, - OptionEnumValueElement *enum_values, - int32_t fail_value, Status &error); - - static lldb::ScriptLanguage - StringToScriptLanguage(llvm::StringRef s, lldb::ScriptLanguage fail_value, - bool *success_ptr); - - // TODO: Use StringRef - static Status StringToFormat(const char *s, lldb::Format &format, - size_t *byte_size_ptr); // If non-NULL, then a - // byte size can precede - // the format character - static lldb::Encoding StringToEncoding(llvm::StringRef s, lldb::Encoding fail_value = lldb::eEncodingInvalid); static uint32_t StringToGenericRegister(llvm::StringRef s); - static bool StringToVersion(llvm::StringRef string, uint32_t &major, - uint32_t &minor, uint32_t &update); - static const char *GetShellSafeArgument(const FileSpec &shell, const char *unsafe_arg, std::string &safe_arg); @@ -423,58 +343,121 @@ public: static void EncodeEscapeSequences(const char *src, std::string &dst); // ExpandEscapeSequences will change a string of possibly non-printable - // characters and expand them into text. So '\n' will turn into two characters - // like "\n" which is suitable for human reading. When a character is not - // printable and isn't one of the common in escape sequences listed in the - // help for EncodeEscapeSequences, then it will be encoded as octal. Printable - // characters are left alone. + // characters and expand them into text. So '\n' will turn into two + // characters like "\n" which is suitable for human reading. When a character + // is not printable and isn't one of the common in escape sequences listed in + // the help for EncodeEscapeSequences, then it will be encoded as octal. + // Printable characters are left alone. static void ExpandEscapedCharacters(const char *src, std::string &dst); static std::string EscapeLLDBCommandArgument(const std::string &arg, char quote_char); +private: + std::vector<ArgEntry> m_entries; + std::vector<char *> m_argv; +}; + +//---------------------------------------------------------------------- +/// @class OptionsWithRaw Args.h "lldb/Utility/Args.h" +/// A pair of an option list with a 'raw' string as a suffix. +/// +/// This class works similar to Args, but handles the case where we have a +/// trailing string that shouldn't be interpreted as a list of arguments but +/// preserved as is. It is also only useful for handling command line options +/// (e.g. '-foo bar -i0') that start with a dash. +/// +/// The leading option list is optional. If the first non-space character +/// in the string starts with a dash, and the string contains an argument +/// that is an unquoted double dash (' -- '), then everything up to the double +/// dash is parsed as a list of arguments. Everything after the double dash +/// is interpreted as the raw suffix string. Note that the space behind the +/// double dash is not part of the raw suffix. +/// +/// All strings not matching the above format as considered to be just a raw +/// string without any options. +/// +/// @see Args +//---------------------------------------------------------------------- +class OptionsWithRaw { +public: //------------------------------------------------------------------ - /// Add or replace an environment variable with the given value. + /// Parse the given string as a list of optional arguments with a raw suffix. /// - /// This command adds the environment variable if it is not already - /// present using the given value. If the environment variable is - /// already in the list, it replaces the first such occurrence - /// with the new value. + /// See the class description for a description of the input format. + /// + /// @param[in] argument_string + /// The string that should be parsed. //------------------------------------------------------------------ - void AddOrReplaceEnvironmentVariable(llvm::StringRef env_var_name, - llvm::StringRef new_value); + explicit OptionsWithRaw(llvm::StringRef argument_string); - /// Return whether a given environment variable exists. + //------------------------------------------------------------------ + /// Returns true if there are any arguments before the raw suffix. + //------------------------------------------------------------------ + bool HasArgs() const { return m_has_args; } + + //------------------------------------------------------------------ + /// Returns the list of arguments. /// - /// This command treats Args like a list of environment variables, - /// as used in ProcessLaunchInfo. It treats each argument as - /// an {env_var_name}={value} or an {env_var_name} entry. + /// You can only call this method if HasArgs returns true. + //------------------------------------------------------------------ + Args &GetArgs() { + assert(m_has_args); + return m_args; + } + + //------------------------------------------------------------------ + /// Returns the list of arguments. /// - /// @param[in] env_var_name - /// Specifies the name of the environment variable to check. + /// You can only call this method if HasArgs returns true. + //------------------------------------------------------------------ + const Args &GetArgs() const { + assert(m_has_args); + return m_args; + } + + //------------------------------------------------------------------ + /// Returns the part of the input string that was used for parsing the + /// argument list. This string also includes the double dash that is used + /// for separating the argument list from the suffix. /// - /// @param[out] argument_index - /// If non-null, then when the environment variable is found, - /// the index of the argument position will be returned in - /// the size_t pointed to by this argument. + /// You can only call this method if HasArgs returns true. + //------------------------------------------------------------------ + llvm::StringRef GetArgStringWithDelimiter() const { + assert(m_has_args); + return m_arg_string_with_delimiter; + } + + //------------------------------------------------------------------ + /// Returns the part of the input string that was used for parsing the + /// argument list. /// - /// @return - /// true if the specified env var name exists in the list in - /// either of the above-mentioned formats; otherwise, false. + /// You can only call this method if HasArgs returns true. //------------------------------------------------------------------ - bool ContainsEnvironmentVariable(llvm::StringRef env_var_name, - size_t *argument_index = nullptr) const; + llvm::StringRef GetArgString() const { + assert(m_has_args); + return m_arg_string; + } + + //------------------------------------------------------------------ + /// Returns the raw suffix part of the parsed string. + //------------------------------------------------------------------ + const std::string &GetRawPart() const { return m_suffix; } private: - size_t FindArgumentIndexForOption(Option *long_options, - int long_options_index) const; + void SetFromString(llvm::StringRef arg_string); - std::vector<ArgEntry> m_entries; - std::vector<char *> m_argv; + /// Keeps track if we have parsed and stored any arguments. + bool m_has_args = false; + Args m_args; + llvm::StringRef m_arg_string; + llvm::StringRef m_arg_string_with_delimiter; - void UpdateArgsAfterOptionParsing(); + // FIXME: This should be a StringRef, but some of the calling code expect a + // C string here so only a real std::string is possible. + std::string m_suffix; }; } // namespace lldb_private -#endif // liblldb_Command_h_ +#endif // LLDB_UTILITY_ARGS_H diff --git a/include/lldb/Utility/Baton.h b/include/lldb/Utility/Baton.h index 065f2960962da..59999e4697fa9 100644 --- a/include/lldb/Utility/Baton.h +++ b/include/lldb/Utility/Baton.h @@ -23,15 +23,15 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class Baton Baton.h "lldb/Core/Baton.h" -/// @brief A class designed to wrap callback batons so they can cleanup +/// A class designed to wrap callback batons so they can cleanup /// any acquired resources /// -/// This class is designed to be used by any objects that have a -/// callback function that takes a baton where the baton might need to +/// This class is designed to be used by any objects that have a callback +/// function that takes a baton where the baton might need to /// free/delete/close itself. /// -/// The default behavior is to not free anything. Subclasses can -/// free any needed resources in their destructors. +/// The default behavior is to not free anything. Subclasses can free any +/// needed resources in their destructors. //---------------------------------------------------------------------- class Baton { public: diff --git a/include/lldb/Utility/CleanUp.h b/include/lldb/Utility/CleanUp.h index 0d7bc8d992193..ef460ddd5e7fe 100644 --- a/include/lldb/Utility/CleanUp.h +++ b/include/lldb/Utility/CleanUp.h @@ -13,249 +13,31 @@ #include "lldb/lldb-public.h" #include <functional> -namespace lldb_utility { +namespace lldb_private { -//---------------------------------------------------------------------- -// Templated class that guarantees that a cleanup callback function will -// be called. The cleanup function will be called once under the -// following conditions: -// - when the object goes out of scope -// - when the user explicitly calls clean. -// - the current value will be cleaned up when a new value is set using -// set(T value) as long as the current value hasn't already been cleaned. -// -// This class is designed to be used with simple types for type T (like -// file descriptors, opaque handles, pointers, etc). If more complex -// type T objects are desired, we need to probably specialize this class -// to take "const T&" for all input T parameters. Yet if a type T is -// complex already it might be better to build the cleanup functionality -// into T. -// -// The cleanup function must take one argument that is of type T. -// The calback function return type is R. The return value is currently -// needed for "CallbackType". If there is an easy way to get around the -// need for the return value we can change this class. -// -// The two template parameters are: -// T - The variable type of value that will be stored and used as the -// sole argument for the cleanup callback. -// R - The return type for the cleanup function. -// -// EXAMPLES -// // Use with file handles that get opened where you want to close -// // them. Below we use "int open(const char *path, int oflag, ...)" -// // which returns an integer file descriptor. -1 is the invalid file -// // descriptor so to make an object that will call "int close(int fd)" -// // automatically we can use: -// -// CleanUp <int, int> fd(open("/tmp/a.txt", O_RDONLY, 0), -1, close); -// -// // malloc/free example -// CleanUp <void *, void> malloced_bytes(malloc(32), NULL, free); -//---------------------------------------------------------------------- -template <typename T, typename R = void> class CleanUp { -public: - typedef T value_type; - typedef std::function<R(value_type)> CallbackType; - - //---------------------------------------------------------------------- - // Constructor that sets the current value only. No values are - // considered to be invalid and the cleanup function will be called - // regardless of the value of m_current_value. - //---------------------------------------------------------------------- - CleanUp(value_type value, CallbackType callback) - : m_current_value(value), m_invalid_value(), m_callback(callback), - m_callback_called(false), m_invalid_value_is_valid(false) {} - - //---------------------------------------------------------------------- - // Constructor that sets the current value and also the invalid value. - // The cleanup function will be called on "m_value" as long as it isn't - // equal to "m_invalid_value". - //---------------------------------------------------------------------- - CleanUp(value_type value, value_type invalid, CallbackType callback) - : m_current_value(value), m_invalid_value(invalid), m_callback(callback), - m_callback_called(false), m_invalid_value_is_valid(true) {} - - //---------------------------------------------------------------------- - // Automatically cleanup when this object goes out of scope. - //---------------------------------------------------------------------- - ~CleanUp() { clean(); } - - //---------------------------------------------------------------------- - // Access the value stored in this class - //---------------------------------------------------------------------- - value_type get() { return m_current_value; } - - //---------------------------------------------------------------------- - // Access the value stored in this class - //---------------------------------------------------------------------- - const value_type get() const { return m_current_value; } - - //---------------------------------------------------------------------- - // Reset the owned value to "value". If a current value is valid and - // the cleanup callback hasn't been called, the previous value will - // be cleaned up (see void CleanUp::clean()). - //---------------------------------------------------------------------- - void set(const value_type value) { - // Cleanup the current value if needed - clean(); - // Now set the new value and mark our callback as not called - m_callback_called = false; - m_current_value = value; - } - - //---------------------------------------------------------------------- - // Checks is "m_current_value" is valid. The value is considered valid - // no invalid value was supplied during construction of this object or - // if an invalid value was supplied and "m_current_value" is not equal - // to "m_invalid_value". - // - // Returns true if "m_current_value" is valid, false otherwise. - //---------------------------------------------------------------------- - bool is_valid() const { - if (m_invalid_value_is_valid) - return m_current_value != m_invalid_value; - return true; - } - - //---------------------------------------------------------------------- - // This function will call the cleanup callback provided in the - // constructor one time if the value is considered valid (See is_valid()). - // This function sets m_callback_called to true so we don't call the - // cleanup callback multiple times on the same value. - //---------------------------------------------------------------------- - void clean() { - if (m_callback && !m_callback_called) { - m_callback_called = true; - if (is_valid()) - m_callback(m_current_value); - } - } +/// Run a cleanup function on scope exit unless it's explicitly disabled. +class CleanUp { + std::function<void()> Clean; - //---------------------------------------------------------------------- - // Cancels the cleanup that would have been called on "m_current_value" - // if it was valid. This function can be used to release the value - // contained in this object so ownership can be transferred to the caller. - //---------------------------------------------------------------------- - value_type release() { - m_callback_called = true; - return m_current_value; - } - -private: - value_type m_current_value; - const value_type m_invalid_value; - CallbackType m_callback; - bool m_callback_called; - bool m_invalid_value_is_valid; - - // Outlaw default constructor, copy constructor and the assignment operator - DISALLOW_COPY_AND_ASSIGN(CleanUp); -}; - -template <typename T, typename R, typename A0> class CleanUp2 { public: - typedef T value_type; - typedef std::function<R(value_type, A0)> CallbackType; - - //---------------------------------------------------------------------- - // Constructor that sets the current value only. No values are - // considered to be invalid and the cleanup function will be called - // regardless of the value of m_current_value. - //---------------------------------------------------------------------- - CleanUp2(value_type value, CallbackType callback, A0 arg) - : m_current_value(value), m_invalid_value(), m_callback(callback), - m_callback_called(false), m_invalid_value_is_valid(false), - m_argument(arg) {} - - //---------------------------------------------------------------------- - // Constructor that sets the current value and also the invalid value. - // The cleanup function will be called on "m_value" as long as it isn't - // equal to "m_invalid_value". - //---------------------------------------------------------------------- - CleanUp2(value_type value, value_type invalid, CallbackType callback, A0 arg) - : m_current_value(value), m_invalid_value(invalid), m_callback(callback), - m_callback_called(false), m_invalid_value_is_valid(true), - m_argument(arg) {} - - //---------------------------------------------------------------------- - // Automatically cleanup when this object goes out of scope. - //---------------------------------------------------------------------- - ~CleanUp2() { clean(); } + /// Register a cleanup function which applies \p Func to a list of arguments. + /// Use caution with arguments which are references: they will be copied. + template <typename F, typename... Args> + CleanUp(F &&Func, Args &&... args) + : Clean(std::bind(std::forward<F>(Func), std::forward<Args>(args)...)) {} - //---------------------------------------------------------------------- - // Access the value stored in this class - //---------------------------------------------------------------------- - value_type get() { return m_current_value; } - - //---------------------------------------------------------------------- - // Access the value stored in this class - //---------------------------------------------------------------------- - const value_type get() const { return m_current_value; } - - //---------------------------------------------------------------------- - // Reset the owned value to "value". If a current value is valid and - // the cleanup callback hasn't been called, the previous value will - // be cleaned up (see void CleanUp::clean()). - //---------------------------------------------------------------------- - void set(const value_type value) { - // Cleanup the current value if needed - clean(); - // Now set the new value and mark our callback as not called - m_callback_called = false; - m_current_value = value; + ~CleanUp() { + if (Clean) + Clean(); } - //---------------------------------------------------------------------- - // Checks is "m_current_value" is valid. The value is considered valid - // no invalid value was supplied during construction of this object or - // if an invalid value was supplied and "m_current_value" is not equal - // to "m_invalid_value". - // - // Returns true if "m_current_value" is valid, false otherwise. - //---------------------------------------------------------------------- - bool is_valid() const { - if (m_invalid_value_is_valid) - return m_current_value != m_invalid_value; - return true; - } - - //---------------------------------------------------------------------- - // This function will call the cleanup callback provided in the - // constructor one time if the value is considered valid (See is_valid()). - // This function sets m_callback_called to true so we don't call the - // cleanup callback multiple times on the same value. - //---------------------------------------------------------------------- - void clean() { - if (m_callback && !m_callback_called) { - m_callback_called = true; - if (is_valid()) - m_callback(m_current_value, m_argument); - } - } + /// Disable the cleanup. + void disable() { Clean = nullptr; } - //---------------------------------------------------------------------- - // Cancels the cleanup that would have been called on "m_current_value" - // if it was valid. This function can be used to release the value - // contained in this object so ownership can be transferred to the caller. - //---------------------------------------------------------------------- - value_type release() { - m_callback_called = true; - return m_current_value; - } - -private: - value_type m_current_value; - const value_type m_invalid_value; - CallbackType m_callback; - bool m_callback_called; - bool m_invalid_value_is_valid; - A0 m_argument; - - // Outlaw default constructor, copy constructor and the assignment operator - DISALLOW_COPY_AND_ASSIGN(CleanUp2); + // Prevent cleanups from being run more than once. + DISALLOW_COPY_AND_ASSIGN(CleanUp); }; -} // namespace lldb_utility +} // namespace lldb_private #endif // #ifndef liblldb_CleanUp_h_ diff --git a/include/lldb/Utility/CompletionRequest.h b/include/lldb/Utility/CompletionRequest.h new file mode 100644 index 0000000000000..cfae16f00b37b --- /dev/null +++ b/include/lldb/Utility/CompletionRequest.h @@ -0,0 +1,120 @@ +//===-- CompletionRequest.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_COMPLETIONREQUEST_H +#define LLDB_UTILITY_COMPLETIONREQUEST_H + +#include "lldb/Utility/Args.h" +#include "lldb/Utility/StringList.h" +#include "llvm/ADT/StringRef.h" + +namespace lldb_private { + +//---------------------------------------------------------------------- +/// @class CompletionRequest CompletionRequest.h +/// "lldb/Utility/ArgCompletionRequest.h" +/// +/// Contains all information necessary to complete an incomplete command +/// for the user. Will be filled with the generated completions by the different +/// completions functions. +/// +//---------------------------------------------------------------------- +class CompletionRequest { +public: + //---------------------------------------------------------- + /// Constructs a completion request. + /// + /// @param [in] command_line + /// The command line the user has typed at this point. + /// + /// @param [in] raw_cursor_pos + /// The position of the cursor in the command line string. Index 0 means + /// the cursor is at the start of the line. The completion starts from + /// this cursor position. + /// + /// @param [in] match_start_point + /// @param [in] max_return_elements + /// If there is a match that is expensive to compute, these are here to + /// allow you to compute the completions in batches. Start the + /// 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. + //---------------------------------------------------------- + CompletionRequest(llvm::StringRef command_line, unsigned raw_cursor_pos, + int match_start_point, int max_return_elements, + StringList &matches); + + llvm::StringRef GetRawLine() const { return m_command; } + + unsigned GetRawCursorPos() const { return m_raw_cursor_pos; } + + const Args &GetParsedLine() const { return m_parsed_line; } + + Args &GetParsedLine() { return m_parsed_line; } + + const Args &GetPartialParsedLine() const { return m_partial_parsed_line; } + + void SetCursorIndex(int i) { m_cursor_index = i; } + int GetCursorIndex() const { return m_cursor_index; } + + void SetCursorCharPosition(int pos) { m_cursor_char_position = pos; } + int GetCursorCharPosition() const { return m_cursor_char_position; } + + int GetMatchStartPoint() const { return m_match_start_point; } + + int GetMaxReturnElements() const { return m_max_return_elements; } + + bool GetWordComplete() { return m_word_complete; } + + void SetWordComplete(bool v) { m_word_complete = v; } + + /// The array of matches returned. + StringList &GetMatches() { return *m_matches; } + + llvm::StringRef GetCursorArgument() const { + return GetParsedLine().GetArgumentAtIndex(GetCursorIndex()); + } + + llvm::StringRef GetCursorArgumentPrefix() const { + return GetCursorArgument().substr(0, GetCursorCharPosition()); + } + +private: + /// The raw command line we are supposed to complete. + llvm::StringRef m_command; + /// The cursor position in m_command. + unsigned m_raw_cursor_pos; + /// The command line parsed as arguments. + Args m_parsed_line; + /// The command line until the cursor position parsed as arguments. + Args m_partial_parsed_line; + /// The index of the argument in which the completion cursor is. + int m_cursor_index; + /// The cursor position in the argument indexed by m_cursor_index. + int m_cursor_char_position; + /// If there is a match that is expensive + /// to compute, these are here to allow you to compute the completions in + /// batches. Start the completion from \amatch_start_point, and return + /// \amatch_return_elements elements. + // FIXME: These two values are not implemented. + int m_match_start_point; + int m_max_return_elements; + /// \btrue if this is a complete option value (a space will be inserted + /// after the completion.) \bfalse otherwise. + bool m_word_complete = false; + // We don't own the list. + StringList *m_matches; +}; + +} // namespace lldb_private + +#endif // LLDB_UTILITY_COMPLETIONREQUEST_H diff --git a/include/lldb/Utility/Connection.h b/include/lldb/Utility/Connection.h index be5641d5fa632..1b0801378f849 100644 --- a/include/lldb/Utility/Connection.h +++ b/include/lldb/Utility/Connection.h @@ -32,16 +32,16 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class Connection Connection.h "lldb/Utility/Connection.h" -/// @brief A communication connection class. +/// A communication connection class. /// /// A class that implements that actual communication functions for -/// connecting/disconnecting, reading/writing, and waiting for bytes -/// to become available from a two way communication connection. +/// connecting/disconnecting, reading/writing, and waiting for bytes to become +/// available from a two way communication connection. /// -/// This class is designed to only do very simple communication -/// functions. Instances can be instantiated and given to a -/// Communication class to perform communications where clients can -/// listen for broadcasts, and perform other higher level communications. +/// This class is designed to only do very simple communication functions. +/// Instances can be instantiated and given to a Communication class to +/// perform communications where clients can listen for broadcasts, and +/// perform other higher level communications. //---------------------------------------------------------------------- class Connection { public: @@ -51,8 +51,8 @@ public: Connection() = default; //------------------------------------------------------------------ - /// Virtual destructor since this class gets subclassed and handed - /// to a Communication object. + /// Virtual destructor since this class gets subclassed and handed to a + /// Communication object. //------------------------------------------------------------------ virtual ~Connection(); @@ -79,8 +79,7 @@ public: Status *error_ptr) = 0; //------------------------------------------------------------------ - /// Disconnect the communications connection if one is currently - /// connected. + /// Disconnect the communications connection if one is currently connected. /// /// @param[out] error_ptr /// A pointer to an error object that should be given an @@ -138,8 +137,8 @@ public: lldb::ConnectionStatus &status, Status *error_ptr) = 0; //------------------------------------------------------------------ - /// The actual write function that attempts to write to the - /// communications protocol. + /// The actual write function that attempts to write to the communications + /// protocol. /// /// Subclasses must override this function. /// @@ -190,10 +189,9 @@ public: //------------------------------------------------------------------ /// Returns the underlying IOObject used by the Connection. /// - /// The IOObject can be used to wait for data to become available - /// on the connection. If the Connection does not use IOObjects (and - /// hence does not support waiting) this function should return a - /// null pointer. + /// The IOObject can be used to wait for data to become available on the + /// connection. If the Connection does not use IOObjects (and hence does not + /// support waiting) this function should return a null pointer. /// /// @return /// The underlying IOObject used for reading. diff --git a/include/lldb/Utility/ConstString.h b/include/lldb/Utility/ConstString.h index fbf1a9bf536ec..98b3447abe3eb 100644 --- a/include/lldb/Utility/ConstString.h +++ b/include/lldb/Utility/ConstString.h @@ -26,17 +26,17 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class ConstString ConstString.h "lldb/Utility/ConstString.h" -/// @brief A uniqued constant string class. +/// A uniqued constant string class. /// -/// Provides an efficient way to store strings as uniqued strings. After -/// the strings are uniqued, finding strings that are equal to one -/// another is very fast as just the pointers need to be compared. It -/// also allows for many common strings from many different sources to -/// be shared to keep the memory footprint low. +/// Provides an efficient way to store strings as uniqued strings. After the +/// strings are uniqued, finding strings that are equal to one another is very +/// fast as just the pointers need to be compared. It also allows for many +/// common strings from many different sources to be shared to keep the memory +/// footprint low. /// -/// No reference counting is done on strings that are added to the -/// string pool, once strings are added they are in the string pool for -/// the life of the program. +/// No reference counting is done on strings that are added to the string +/// pool, once strings are added they are in the string pool for the life of +/// the program. //---------------------------------------------------------------------- class ConstString { public: @@ -74,11 +74,10 @@ public: //------------------------------------------------------------------ /// Construct with C String value with max length /// - /// Constructs this object with a C string with a length. If - /// \a max_cstr_len is greater than the actual length of the string, - /// the string length will be truncated. This allows substrings to - /// be created without the need to NULL terminate the string as it - /// is passed into this function. + /// Constructs this object with a C string with a length. If \a max_cstr_len + /// is greater than the actual length of the string, the string length will + /// be truncated. This allows substrings to be created without the need to + /// NULL terminate the string as it is passed into this function. /// /// @param[in] cstr /// A pointer to the first character in the C string. The C @@ -99,8 +98,8 @@ public: //------------------------------------------------------------------ /// Destructor /// - /// Since constant string values are currently not reference counted, - /// there isn't much to do here. + /// Since constant string values are currently not reference counted, there + /// isn't much to do here. //------------------------------------------------------------------ ~ConstString() = default; @@ -112,8 +111,8 @@ public: //-------------------------------------------------------------- /// C equality test. /// - /// Two C strings are equal when they are contained in ConstString - /// objects when their pointer values are equal to each other. + /// Two C strings are equal when they are contained in ConstString objects + /// when their pointer values are equal to each other. /// /// @return /// Returns \b true if the C string in \a lhs is equal to @@ -127,8 +126,8 @@ public: //------------------------------------------------------------------ /// Convert to bool operator. /// - /// This allows code to check a ConstString object to see if it - /// contains a valid string using code such as: + /// This allows code to check a ConstString object to see if it contains a + /// valid string using code such as: /// /// @code /// ConstString str(...); @@ -140,7 +139,7 @@ public: /// /b True this object contains a valid non-empty C string, \b /// false otherwise. //------------------------------------------------------------------ - explicit operator bool() const { return m_string && m_string[0]; } + explicit operator bool() const { return !IsEmpty(); } //------------------------------------------------------------------ /// Assignment operator @@ -161,10 +160,9 @@ public: //------------------------------------------------------------------ /// Equal to operator /// - /// Returns true if this string is equal to the string in \a rhs. - /// This operation is very fast as it results in a pointer - /// comparison since all strings are in a uniqued in a global string - /// pool. + /// Returns true if this string is equal to the string in \a rhs. This + /// operation is very fast as it results in a pointer comparison since all + /// strings are in a uniqued in a global string pool. /// /// @param[in] rhs /// Another string object to compare this object to. @@ -174,18 +172,17 @@ public: /// @li \b false if this object is not equal to \a rhs. //------------------------------------------------------------------ bool operator==(const ConstString &rhs) const { - // We can do a pointer compare to compare these strings since they - // must come from the same pool in order to be equal. + // We can do a pointer compare to compare these strings since they must + // come from the same pool in order to be equal. return m_string == rhs.m_string; } //------------------------------------------------------------------ /// Not equal to operator /// - /// Returns true if this string is not equal to the string in \a rhs. - /// This operation is very fast as it results in a pointer - /// comparison since all strings are in a uniqued in a global string - /// pool. + /// Returns true if this string is not equal to the string in \a rhs. This + /// operation is very fast as it results in a pointer comparison since all + /// strings are in a uniqued in a global string pool. /// /// @param[in] rhs /// Another string object to compare this object to. @@ -203,8 +200,8 @@ public: //------------------------------------------------------------------ /// Get the string value as a C string. /// - /// Get the value of the contained string as a NULL terminated C - /// string value. + /// Get the value of the contained string as a NULL terminated C string + /// value. /// /// If \a value_if_empty is nullptr, then nullptr will be returned. /// @@ -230,11 +227,10 @@ public: //------------------------------------------------------------------ /// Get the string value as a C string. /// - /// Get the value of the contained string as a NULL terminated C - /// string value. Similar to the ConstString::AsCString() function, - /// yet this function will always return nullptr if the string is not - /// valid. So this function is a direct accessor to the string - /// pointer value. + /// Get the value of the contained string as a NULL terminated C string + /// value. Similar to the ConstString::AsCString() function, yet this + /// function will always return nullptr if the string is not valid. So this + /// function is a direct accessor to the string pointer value. /// /// @return /// Returns nullptr the string is invalid, otherwise the C string @@ -245,8 +241,8 @@ public: //------------------------------------------------------------------ /// Get the length in bytes of string value. /// - /// The string pool stores the length of the string, so we can avoid - /// calling strlen() on the pointer value with this function. + /// The string pool stores the length of the string, so we can avoid calling + /// strlen() on the pointer value with this function. /// /// @return /// Returns the number of bytes that this string occupies in @@ -257,18 +253,18 @@ public: //------------------------------------------------------------------ /// Clear this object's state. /// - /// Clear any contained string and reset the value to the an empty - /// string value. + /// Clear any contained string and reset the value to the an empty string + /// value. //------------------------------------------------------------------ void Clear() { m_string = nullptr; } //------------------------------------------------------------------ /// Equal to operator /// - /// Returns true if this string is equal to the string in \a rhs. - /// If case sensitive equality is tested, this operation is very - /// fast as it results in a pointer comparison since all strings - /// are in a uniqued in a global string pool. + /// Returns true if this string is equal to the string in \a rhs. If case + /// sensitive equality is tested, this operation is very fast as it results + /// in a pointer comparison since all strings are in a uniqued in a global + /// string pool. /// /// @param[in] rhs /// The Left Hand Side const ConstString object reference. @@ -290,13 +286,13 @@ public: //------------------------------------------------------------------ /// Compare two string objects. /// - /// Compares the C string values contained in \a lhs and \a rhs and - /// returns an integer result. + /// Compares the C string values contained in \a lhs and \a rhs and returns + /// an integer result. /// /// NOTE: only call this function when you want a true string - /// comparison. If you want string equality use the, use the == - /// operator as it is much more efficient. Also if you want string - /// inequality, use the != operator for the same reasons. + /// comparison. If you want string equality use the, use the == operator as + /// it is much more efficient. Also if you want string inequality, use the + /// != operator for the same reasons. /// /// @param[in] lhs /// The Left Hand Side const ConstString object reference. @@ -319,10 +315,9 @@ public: //------------------------------------------------------------------ /// Dump the object description to a stream. /// - /// Dump the string value to the stream \a s. If the contained string - /// is empty, print \a value_if_empty to the stream instead. If - /// \a value_if_empty is nullptr, then nothing will be dumped to the - /// stream. + /// Dump the string value to the stream \a s. If the contained string is + /// empty, print \a value_if_empty to the stream instead. If \a + /// value_if_empty is nullptr, then nothing will be dumped to the stream. /// /// @param[in] s /// The stream that will be used to dump the object description. @@ -353,12 +348,12 @@ public: //------------------------------------------------------------------ /// Set the C string value. /// - /// Set the string value in the object by uniquing the \a cstr - /// string value in our global string pool. + /// Set the string value in the object by uniquing the \a cstr string value + /// in our global string pool. /// - /// If the C string already exists in the global string pool, it - /// finds the current entry and returns the existing value. If it - /// doesn't exist, it is added to the string pool. + /// If the C string already exists in the global string pool, it finds the + /// current entry and returns the existing value. If it doesn't exist, it is + /// added to the string pool. /// /// @param[in] cstr /// A NULL terminated C string to add to the string pool. @@ -370,12 +365,12 @@ public: //------------------------------------------------------------------ /// Set the C string value and its mangled counterpart. /// - /// Object files and debug symbols often use mangled string to - /// represent the linkage name for a symbol, function or global. - /// The string pool can efficiently store these values and their - /// counterparts so when we run into another instance of a mangled - /// name, we can avoid calling the name demangler over and over on - /// the same strings and then trying to unique them. + /// Object files and debug symbols often use mangled string to represent the + /// linkage name for a symbol, function or global. The string pool can + /// efficiently store these values and their counterparts so when we run + /// into another instance of a mangled name, we can avoid calling the name + /// demangler over and over on the same strings and then trying to unique + /// them. /// /// @param[in] demangled /// The demangled C string to correlate with the \a mangled @@ -389,15 +384,15 @@ public: const ConstString &mangled); //------------------------------------------------------------------ - /// Retrieve the mangled or demangled counterpart for a mangled - /// or demangled ConstString. + /// Retrieve the mangled or demangled counterpart for a mangled or demangled + /// ConstString. /// - /// Object files and debug symbols often use mangled string to - /// represent the linkage name for a symbol, function or global. - /// The string pool can efficiently store these values and their - /// counterparts so when we run into another instance of a mangled - /// name, we can avoid calling the name demangler over and over on - /// the same strings and then trying to unique them. + /// Object files and debug symbols often use mangled string to represent the + /// linkage name for a symbol, function or global. The string pool can + /// efficiently store these values and their counterparts so when we run + /// into another instance of a mangled name, we can avoid calling the name + /// demangler over and over on the same strings and then trying to unique + /// them. /// /// @param[in] counterpart /// A reference to a ConstString object that might get filled in @@ -413,14 +408,13 @@ public: /// Set the C string value with length. /// /// Set the string value in the object by uniquing \a cstr_len bytes - /// starting at the \a cstr string value in our global string pool. - /// If trim is true, then \a cstr_len indicates a maximum length of - /// the CString and if the actual length of the string is less, then - /// it will be trimmed. + /// starting at the \a cstr string value in our global string pool. If trim + /// is true, then \a cstr_len indicates a maximum length of the CString and + /// if the actual length of the string is less, then it will be trimmed. /// - /// If the C string already exists in the global string pool, it - /// finds the current entry and returns the existing value. If it - /// doesn't exist, it is added to the string pool. + /// If the C string already exists in the global string pool, it finds the + /// current entry and returns the existing value. If it doesn't exist, it is + /// added to the string pool. /// /// @param[in] cstr /// A NULL terminated C string to add to the string pool. @@ -431,20 +425,19 @@ public: void SetCStringWithLength(const char *cstr, size_t cstr_len); //------------------------------------------------------------------ - /// Set the C string value with the minimum length between - /// \a fixed_cstr_len and the actual length of the C string. This - /// can be used for data structures that have a fixed length to - /// store a C string where the string might not be NULL terminated - /// if the string takes the entire buffer. + /// Set the C string value with the minimum length between \a fixed_cstr_len + /// and the actual length of the C string. This can be used for data + /// structures that have a fixed length to store a C string where the string + /// might not be NULL terminated if the string takes the entire buffer. //------------------------------------------------------------------ void SetTrimmedCStringWithLength(const char *cstr, size_t fixed_cstr_len); //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// Return the size in bytes that this object takes in memory. This - /// returns the size in bytes of this object, which does not include - /// any the shared string values it may refer to. + /// Return the size in bytes that this object takes in memory. This returns + /// the size in bytes of this object, which does not include any the shared + /// string values it may refer to. /// /// @return /// The number of bytes that this object occupies in memory. @@ -456,9 +449,8 @@ public: //------------------------------------------------------------------ /// Get the size in bytes of the current global string pool. /// - /// Reports the size in bytes of all shared C string values, - /// containers and any other values as a byte size for the - /// entire string pool. + /// Reports the size in bytes of all shared C string values, containers and + /// any other values as a byte size for the entire string pool. /// /// @return /// The number of bytes that the global string pool occupies diff --git a/include/lldb/Utility/DataBuffer.h b/include/lldb/Utility/DataBuffer.h index ffa71c06be804..05cb609207373 100644 --- a/include/lldb/Utility/DataBuffer.h +++ b/include/lldb/Utility/DataBuffer.h @@ -22,39 +22,36 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class DataBuffer DataBuffer.h "lldb/Core/DataBuffer.h" -/// @brief A pure virtual protocol class for abstracted data buffers. +/// A pure virtual protocol class for abstracted data buffers. /// /// DataBuffer is an abstract class that gets packaged into a shared pointer -/// that can use to implement various ways to store data (on the heap, -/// memory mapped, cached inferior memory). It gets used by DataExtractor -/// so many DataExtractor objects can share the same data and sub-ranges -/// of that shared data, and the last object that contains a reference -/// to the shared data will free it. +/// that can use to implement various ways to store data (on the heap, memory +/// mapped, cached inferior memory). It gets used by DataExtractor so many +/// DataExtractor objects can share the same data and sub-ranges of that +/// shared data, and the last object that contains a reference to the shared +/// data will free it. /// /// Subclasses can implement as many different constructors or member -/// functions that allow data to be stored in the object's buffer prior -/// to handing the shared data to clients that use these buffers. +/// functions that allow data to be stored in the object's buffer prior to +/// handing the shared data to clients that use these buffers. /// -/// All subclasses must override all of the pure virtual functions as -/// they are used by clients to access the data. Having a common -/// interface allows different ways of storing data, yet using it in -/// one common way. +/// All subclasses must override all of the pure virtual functions as they are +/// used by clients to access the data. Having a common interface allows +/// different ways of storing data, yet using it in one common way. /// -/// This class currently expects all data to be available without any -/// extra calls being made, but we can modify it to optionally get -/// data on demand with some extra function calls to load the data -/// before it gets accessed. +/// This class currently expects all data to be available without any extra +/// calls being made, but we can modify it to optionally get data on demand +/// with some extra function calls to load the data before it gets accessed. //---------------------------------------------------------------------- class DataBuffer { public: //------------------------------------------------------------------ /// Destructor /// - /// The destructor is virtual as other classes will inherit from - /// this class and be downcast to the DataBuffer pure virtual - /// interface. The virtual destructor ensures that destructing the - /// base class will destruct the class that inherited from it - /// correctly. + /// The destructor is virtual as other classes will inherit from this class + /// and be downcast to the DataBuffer pure virtual interface. The virtual + /// destructor ensures that destructing the base class will destruct the + /// class that inherited from it correctly. //------------------------------------------------------------------ virtual ~DataBuffer() {} diff --git a/include/lldb/Utility/DataBufferHeap.h b/include/lldb/Utility/DataBufferHeap.h index 20e27ef8950c6..d64e5b7563a90 100644 --- a/include/lldb/Utility/DataBufferHeap.h +++ b/include/lldb/Utility/DataBufferHeap.h @@ -21,14 +21,14 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class DataBufferHeap DataBufferHeap.h "lldb/Core/DataBufferHeap.h" -/// @brief A subclass of DataBuffer that stores a data buffer on the heap. +/// A subclass of DataBuffer that stores a data buffer on the heap. /// -/// This class keeps its data in a heap based buffer that is owned by -/// the object. This class is best used to store chunks of data that -/// are created or read from sources that can't intelligently and lazily -/// fault new data pages in. Large amounts of data that comes from files -/// should probably use DataBufferLLVM, which can intelligently determine -/// when memory mapping is optimal. +/// This class keeps its data in a heap based buffer that is owned by the +/// object. This class is best used to store chunks of data that are created +/// or read from sources that can't intelligently and lazily fault new data +/// pages in. Large amounts of data that comes from files should probably use +/// DataBufferLLVM, which can intelligently determine when memory mapping is +/// optimal. //---------------------------------------------------------------------- class DataBufferHeap : public DataBuffer { public: @@ -42,8 +42,7 @@ public: //------------------------------------------------------------------ /// Construct with size \a n and fill with \a ch. /// - /// Initialize this class with \a n bytes and fills the buffer with - /// \a ch. + /// Initialize this class with \a n bytes and fills the buffer with \a ch. /// /// @param[in] n /// The number of bytes that heap based buffer should contain. @@ -67,8 +66,8 @@ public: //------------------------------------------------------------------ /// Destructor. /// - /// Virtual destructor since this class inherits from a pure virtual - /// base class #DataBuffer. + /// Virtual destructor since this class inherits from a pure virtual base + /// class #DataBuffer. //------------------------------------------------------------------ ~DataBufferHeap() override; @@ -90,8 +89,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. + /// Sets the number of bytes that this object should be able to contain. + /// This can be used prior to copying data into the buffer. /// /// @param[in] byte_size /// The new size in bytes that this data buffer should attempt @@ -123,8 +122,8 @@ public: private: //------------------------------------------------------------------ - // This object uses a std::vector<uint8_t> to store its data. This - // takes care of free the data when the object is deleted. + // This object uses a std::vector<uint8_t> to store its data. This takes care + // of free the data when the object is deleted. //------------------------------------------------------------------ typedef std::vector<uint8_t> buffer_t; ///< Buffer type buffer_t m_data; ///< The heap based buffer where data is stored diff --git a/include/lldb/Utility/DataBufferLLVM.h b/include/lldb/Utility/DataBufferLLVM.h index 0eb229cffbe24..d76582cbf47cc 100644 --- a/include/lldb/Utility/DataBufferLLVM.h +++ b/include/lldb/Utility/DataBufferLLVM.h @@ -40,8 +40,8 @@ public: char *GetChars() { return reinterpret_cast<char *>(GetBytes()); } private: - /// \brief Construct a DataBufferLLVM from \p Buffer. \p Buffer must be a - /// valid pointer. + /// Construct a DataBufferLLVM from \p Buffer. \p Buffer must be a valid + /// pointer. explicit DataBufferLLVM(std::unique_ptr<llvm::WritableMemoryBuffer> Buffer); std::unique_ptr<llvm::WritableMemoryBuffer> Buffer; diff --git a/include/lldb/Utility/DataEncoder.h b/include/lldb/Utility/DataEncoder.h index ea347d86237b9..c1214705c7260 100644 --- a/include/lldb/Utility/DataEncoder.h +++ b/include/lldb/Utility/DataEncoder.h @@ -23,13 +23,12 @@ namespace lldb_private { //---------------------------------------------------------------------- -/// @class DataEncoder DataEncoder.h "lldb/Core/DataEncoder.h" -/// @brief An binary data encoding class. +/// @class DataEncoder DataEncoder.h "lldb/Core/DataEncoder.h" An binary data +/// encoding class. /// -/// DataEncoder is a class that can encode binary data (swapping if needed) -/// to a data buffer. The data buffer can be caller owned, or can be -/// shared data that can be shared between multiple DataEncoder or -/// DataEncoder instances. +/// DataEncoder is a class that can encode binary data (swapping if needed) to +/// a data buffer. The data buffer can be caller owned, or can be shared data +/// that can be shared between multiple DataEncoder or DataEncoder instances. /// /// @see DataBuffer //---------------------------------------------------------------------- @@ -45,9 +44,8 @@ public: //------------------------------------------------------------------ /// Construct with a buffer that is owned by the caller. /// - /// This constructor allows us to use data that is owned by the - /// caller. The data must stay around as long as this object is - /// valid. + /// This constructor allows us to use data that is owned by the caller. The + /// data must stay around as long as this object is valid. /// /// @param[in] data /// A pointer to caller owned data. @@ -67,10 +65,10 @@ public: //------------------------------------------------------------------ /// Construct with shared data. /// - /// Copies the data shared pointer which adds a reference to the - /// contained in \a data_sp. The shared data reference is reference - /// counted to ensure the data lives as long as anyone still has a - /// valid shared pointer to the data in \a data_sp. + /// Copies the data shared pointer which adds a reference to the contained + /// in \a data_sp. The shared data reference is reference counted to ensure + /// the data lives as long as anyone still has a valid shared pointer to the + /// data in \a data_sp. /// /// @param[in] data_sp /// A shared pointer to data. @@ -87,26 +85,24 @@ public: //------------------------------------------------------------------ /// Destructor /// - /// If this object contains a valid shared data reference, the - /// reference count on the data will be decremented, and if zero, - /// the data will be freed. + /// If this object contains a valid shared data reference, the reference + /// count on the data will be decremented, and if zero, the data will be + /// freed. //------------------------------------------------------------------ ~DataEncoder(); //------------------------------------------------------------------ /// Clears the object state. /// - /// Clears the object contents back to a default invalid state, and - /// release any references to shared data that this object may - /// contain. + /// Clears the object contents back to a default invalid state, and release + /// any references to shared data that this object may contain. //------------------------------------------------------------------ void Clear(); //------------------------------------------------------------------ /// Get the current address size. /// - /// Return the size in bytes of any address values this object will - /// extract. + /// Return the size in bytes of any address values this object will extract. /// /// @return /// The size in bytes of address values that will be extracted. @@ -135,8 +131,7 @@ public: //------------------------------------------------------------------ /// Get the shared data offset. /// - /// Get the offset of the first byte of data in the shared data (if - /// any). + /// Get the offset of the first byte of data in the shared data (if any). /// /// @return /// If this object contains shared data, this function returns @@ -189,11 +184,10 @@ public: //------------------------------------------------------------------ /// Encode an unsigned integer of size \a byte_size to \a offset. /// - /// Encode a single integer value at \a offset and return the offset - /// that follows the newly encoded integer when the data is successfully - /// encoded into the existing data. There must be enough room in the - /// data, else UINT32_MAX will be returned to indicate that encoding - /// failed. + /// Encode a single integer value at \a offset and return the offset that + /// follows the newly encoded integer when the data is successfully encoded + /// into the existing data. There must be enough room in the data, else + /// UINT32_MAX will be returned to indicate that encoding failed. /// /// @param[in] offset /// The offset within the contained data at which to put the @@ -233,15 +227,14 @@ public: uint32_t PutData(uint32_t offset, const void *src, uint32_t src_len); //------------------------------------------------------------------ - /// Encode an address in the existing buffer at \a offset bytes into - /// the buffer. + /// Encode an address in the existing buffer at \a offset bytes into the + /// buffer. /// - /// Encode a single address (honoring the m_addr_size member) to - /// the data and return the next offset where subsequent data would - /// go. - /// pointed to by \a offset_ptr. The size of the extracted address - /// comes from the \a m_addr_size member variable and should be - /// set correctly prior to extracting any address values. + /// Encode a single address (honoring the m_addr_size member) to the data + /// and return the next offset where subsequent data would go. pointed to by + /// \a offset_ptr. The size of the extracted address comes from the \a + /// m_addr_size member variable and should be set correctly prior to + /// extracting any address values. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -259,8 +252,7 @@ public: //------------------------------------------------------------------ /// Put a C string to \a offset. /// - /// Encodes a C string into the existing data including the - /// terminating + /// Encodes a C string into the existing data including the terminating /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -282,8 +274,8 @@ public: //------------------------------------------------------------------ /// Set the address byte size. /// - /// Set the size in bytes that will be used when extracting any - /// address and pointer values from data contained in this object. + /// Set the size in bytes that will be used when extracting any address and + /// pointer values from data contained in this object. /// /// @param[in] addr_size /// The size in bytes to use when extracting addresses. @@ -293,11 +285,10 @@ public: //------------------------------------------------------------------ /// Set data with a buffer that is caller owned. /// - /// Use data that is owned by the caller when extracting values. - /// The data must stay around as long as this object, or any object - /// that copies a subset of this object's data, is valid. If \a - /// bytes is NULL, or \a length is zero, this object will contain - /// no data. + /// Use data that is owned by the caller when extracting values. The data + /// must stay around as long as this object, or any object that copies a + /// subset of this object's data, is valid. If \a bytes is NULL, or \a + /// length is zero, this object will contain no data. /// /// @param[in] bytes /// A pointer to caller owned data. @@ -316,15 +307,14 @@ public: //------------------------------------------------------------------ /// Adopt a subset of shared data in \a data_sp. /// - /// Copies the data shared pointer which adds a reference to the - /// contained in \a data_sp. The shared data reference is reference - /// counted to ensure the data lives as long as anyone still has a - /// valid shared pointer to the data in \a data_sp. The byte order - /// and address byte size settings remain the same. If - /// \a offset is not a valid offset in \a data_sp, then no reference - /// to the shared data will be added. If there are not \a length - /// bytes available in \a data starting at \a offset, the length - /// will be truncated to contains as many bytes as possible. + /// Copies the data shared pointer which adds a reference to the contained + /// in \a data_sp. The shared data reference is reference counted to ensure + /// the data lives as long as anyone still has a valid shared pointer to the + /// data in \a data_sp. The byte order and address byte size settings remain + /// the same. If \a offset is not a valid offset in \a data_sp, then no + /// reference to the shared data will be added. If there are not \a length + /// bytes available in \a data starting at \a offset, the length will be + /// truncated to contains as many bytes as possible. /// /// @param[in] data_sp /// A shared pointer to data. @@ -344,8 +334,8 @@ public: //------------------------------------------------------------------ /// Set the byte_order value. /// - /// Sets the byte order of the data to extract. Extracted values - /// will be swapped if necessary when decoding. + /// Sets the byte order of the data to extract. Extracted values will be + /// swapped if necessary when decoding. /// /// @param[in] byte_order /// The byte order value to use when extracting data. diff --git a/include/lldb/Utility/DataExtractor.h b/include/lldb/Utility/DataExtractor.h index 8107a3554422b..50c88db8e358b 100644 --- a/include/lldb/Utility/DataExtractor.h +++ b/include/lldb/Utility/DataExtractor.h @@ -34,16 +34,16 @@ template <typename T> class SmallVectorImpl; namespace lldb_private { //---------------------------------------------------------------------- -/// @class DataExtractor DataExtractor.h "lldb/Core/DataExtractor.h" -/// @brief An data extractor class. +/// @class DataExtractor DataExtractor.h "lldb/Core/DataExtractor.h" An data +/// extractor class. /// -/// DataExtractor is a class that can extract data (swapping if needed) -/// from a data buffer. The data buffer can be caller owned, or can be -/// shared data that can be shared between multiple DataExtractor -/// instances. Multiple DataExtractor objects can share the same data, -/// yet extract values in different address sizes and byte order modes. -/// Each object can have a unique position in the shared data and extract -/// data from different offsets. +/// DataExtractor is a class that can extract data (swapping if needed) from a +/// data buffer. The data buffer can be caller owned, or can be shared data +/// that can be shared between multiple DataExtractor instances. Multiple +/// DataExtractor objects can share the same data, yet extract values in +/// different address sizes and byte order modes. Each object can have a +/// unique position in the shared data and extract data from different +/// offsets. /// /// @see DataBuffer //---------------------------------------------------------------------- @@ -51,7 +51,7 @@ class DataExtractor { public: //------------------------------------------------------------------ /// @typedef DataExtractor::Type - /// @brief Type enumerations used in the dump routines. + /// Type enumerations used in the dump routines. //------------------------------------------------------------------ typedef enum { TypeUInt8, ///< Format output as unsigned 8 bit integers @@ -74,9 +74,8 @@ public: //------------------------------------------------------------------ /// Construct with a buffer that is owned by the caller. /// - /// This constructor allows us to use data that is owned by the - /// caller. The data must stay around as long as this object is - /// valid. + /// This constructor allows us to use data that is owned by the caller. The + /// data must stay around as long as this object is valid. /// /// @param[in] data /// A pointer to caller owned data. @@ -100,10 +99,10 @@ public: //------------------------------------------------------------------ /// Construct with shared data. /// - /// Copies the data shared pointer which adds a reference to the - /// contained in \a data_sp. The shared data reference is reference - /// counted to ensure the data lives as long as anyone still has a - /// valid shared pointer to the data in \a data_sp. + /// Copies the data shared pointer which adds a reference to the contained + /// in \a data_sp. The shared data reference is reference counted to ensure + /// the data lives as long as anyone still has a valid shared pointer to the + /// data in \a data_sp. /// /// @param[in] data_sp /// A shared pointer to data. @@ -123,16 +122,14 @@ public: //------------------------------------------------------------------ /// Construct with a subset of \a data. /// - /// Initialize this object with a subset of the data bytes in \a - /// data. If \a data contains shared data, then a reference to the - /// shared data will be added to ensure the shared data stays around - /// as long as any objects have references to the shared data. The - /// byte order value and the address size settings are copied from \a - /// data. If \a offset is not a valid offset in \a data, then no - /// reference to the shared data will be added. If there are not - /// \a length bytes available in \a data starting at \a offset, - /// the length will be truncated to contain as many bytes as - /// possible. + /// Initialize this object with a subset of the data bytes in \a data. If \a + /// data contains shared data, then a reference to the shared data will be + /// added to ensure the shared data stays around as long as any objects have + /// references to the shared data. The byte order value and the address size + /// settings are copied from \a data. If \a offset is not a valid offset in + /// \a data, then no reference to the shared data will be added. If there + /// are not \a length bytes available in \a data starting at \a offset, the + /// length will be truncated to contain as many bytes as possible. /// /// @param[in] data /// Another DataExtractor object that contains data. @@ -155,8 +152,8 @@ public: /// Assignment operator. /// /// Copies all data, byte order and address size settings from \a rhs into - /// this object. If \a rhs contains shared data, a reference to that - /// shared data will be added. + /// this object. If \a rhs contains shared data, a reference to that shared + /// data will be added. /// /// @param[in] rhs /// Another DataExtractor object to copy. @@ -169,9 +166,9 @@ public: //------------------------------------------------------------------ /// Destructor /// - /// If this object contains a valid shared data reference, the - /// reference count on the data will be decremented, and if zero, - /// the data will be freed. + /// If this object contains a valid shared data reference, the reference + /// count on the data will be decremented, and if zero, the data will be + /// freed. //------------------------------------------------------------------ virtual ~DataExtractor(); @@ -180,19 +177,17 @@ public: //------------------------------------------------------------------ /// Clears the object state. /// - /// Clears the object contents back to a default invalid state, and - /// release any references to shared data that this object may - /// contain. + /// Clears the object contents back to a default invalid state, and release + /// any references to shared data that this object may contain. //------------------------------------------------------------------ void Clear(); //------------------------------------------------------------------ - /// Dumps the binary data as \a type objects to stream \a s (or to - /// Log() if \a s is nullptr) starting \a offset bytes into the data - /// and stopping after dumping \a length bytes. The offset into the - /// data is displayed at the beginning of each line and can be - /// offset by base address \a base_addr. \a num_per_line objects - /// will be displayed on each line. + /// Dumps the binary data as \a type objects to stream \a s (or to Log() if + /// \a s is nullptr) starting \a offset bytes into the data and stopping + /// after dumping \a length bytes. The offset into the data is displayed at + /// the beginning of each line and can be offset by base address \a + /// base_addr. \a num_per_line objects will be displayed on each line. /// /// @param[in] s /// The stream to dump the output to. If nullptr the output will @@ -228,29 +223,11 @@ public: const char *type_format = nullptr) const; //------------------------------------------------------------------ - /// Dump a UUID value at \a offset. + /// Extract an arbitrary number of bytes in the specified byte order. /// - /// Dump a UUID starting at \a offset bytes into this object's data. - /// If the stream \a s is nullptr, the output will be sent to Log(). - /// - /// @param[in] s - /// The stream to dump the output to. If nullptr the output will - /// be dumped to Log(). - /// - /// @param[in] offset - /// The offset into the data at which to extract and dump a - /// UUID value. - //------------------------------------------------------------------ - void DumpUUID(Stream *s, lldb::offset_t offset) const; - - //------------------------------------------------------------------ - /// Extract an arbitrary number of bytes in the specified byte - /// order. - /// - /// Attemps to extract \a length bytes starting at \a offset bytes - /// into this data in the requested byte order (\a dst_byte_order) - /// and place the results in \a dst. \a dst must be at least \a - /// length bytes long. + /// Attemps to extract \a length bytes starting at \a offset bytes into this + /// data in the requested byte order (\a dst_byte_order) and place the + /// results in \a dst. \a dst must be at least \a length bytes long. /// /// @param[in] offset /// The offset in bytes into the contained data at which to @@ -278,10 +255,10 @@ public: //------------------------------------------------------------------ /// Extract an address from \a *offset_ptr. /// - /// Extract a single address from the data and update the offset - /// pointed to by \a offset_ptr. The size of the extracted address - /// comes from the \a m_addr_size member variable and should be - /// set correctly prior to extracting any address values. + /// Extract a single address from the data and update the offset pointed to + /// by \a offset_ptr. The size of the extracted address comes from the \a + /// m_addr_size member variable and should be set correctly prior to + /// extracting any address values. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -300,8 +277,7 @@ public: //------------------------------------------------------------------ /// Get the current address size. /// - /// Return the size in bytes of any address values this object will - /// extract. + /// Return the size in bytes of any address values this object will extract. /// /// @return /// The size in bytes of address values that will be extracted. @@ -319,11 +295,10 @@ public: //------------------------------------------------------------------ /// Extract a C string from \a *offset_ptr. /// - /// Returns a pointer to a C String from the data at the offset - /// pointed to by \a offset_ptr. A variable length NULL terminated C - /// string will be extracted and the \a offset_ptr will be - /// updated with the offset of the byte that follows the NULL - /// terminator byte. + /// Returns a pointer to a C String from the data at the offset pointed to + /// by \a offset_ptr. A variable length NULL terminated C string will be + /// extracted and the \a offset_ptr will be updated with the offset of the + /// byte that follows the NULL terminator byte. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -343,8 +318,8 @@ public: //------------------------------------------------------------------ /// Extract a C string from \a *offset_ptr with field size \a len. /// - /// Returns a pointer to a C String from the data at the offset - /// pointed to by \a offset_ptr, with a field length of \a len. + /// Returns a pointer to a C String from the data at the offset pointed to + /// by \a offset_ptr, with a field length of \a len. /// A NULL terminated C string will be extracted and the \a offset_ptr /// will be updated with the offset of the byte that follows the fixed /// length field. @@ -367,10 +342,10 @@ public: //------------------------------------------------------------------ /// Extract \a length bytes from \a *offset_ptr. /// - /// Returns a pointer to a bytes in this object's data at the offset - /// pointed to by \a offset_ptr. If \a length is zero or too large, - /// then the offset pointed to by \a offset_ptr will not be updated - /// and nullptr will be returned. + /// Returns a pointer to a bytes in this object's data at the offset pointed + /// to by \a offset_ptr. If \a length is zero or too large, then the offset + /// pointed to by \a offset_ptr will not be updated and nullptr will be + /// returned. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -414,17 +389,16 @@ public: void *dst) const; //------------------------------------------------------------------ - /// Copy \a dst_len bytes from \a *offset_ptr and ensure the copied - /// data is treated as a value that can be swapped to match the - /// specified byte order. + /// Copy \a dst_len bytes from \a *offset_ptr and ensure the copied data is + /// treated as a value that can be swapped to match the specified byte + /// order. /// - /// For values that are larger than the supported integer sizes, - /// this function can be used to extract data in a specified byte - /// order. It can also be used to copy a smaller integer value from - /// to a larger value. The extra bytes left over will be padded - /// correctly according to the byte order of this object and the - /// \a dst_byte_order. This can be very handy when say copying a - /// partial data value into a register. + /// For values that are larger than the supported integer sizes, this + /// function can be used to extract data in a specified byte order. It can + /// also be used to copy a smaller integer value from to a larger value. The + /// extra bytes left over will be padded correctly according to the byte + /// order of this object and the \a dst_byte_order. This can be very handy + /// when say copying a partial data value into a register. /// /// @param[in] src_offset /// The offset into this data from which to start copying an @@ -469,8 +443,7 @@ public: //------------------------------------------------------------------ /// Get the shared data offset. /// - /// Get the offset of the first byte of data in the shared data (if - /// any). + /// Get the offset of the first byte of data in the shared data (if any). /// /// @return /// If this object contains shared data, this function returns @@ -511,10 +484,10 @@ public: //------------------------------------------------------------------ /// Extract an integer of size \a byte_size from \a *offset_ptr. /// - /// Extract a single integer value and update the offset pointed to - /// by \a offset_ptr. The size of the extracted integer is specified - /// by the \a byte_size argument. \a byte_size must have a value - /// >= 1 and <= 4 since the return value is only 32 bits wide. + /// Extract a single integer value and update the offset pointed to by \a + /// offset_ptr. The size of the extracted integer is specified by the \a + /// byte_size argument. \a byte_size must have a value >= 1 and <= 4 since + /// the return value is only 32 bits wide. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -532,14 +505,13 @@ public: uint32_t GetMaxU32(lldb::offset_t *offset_ptr, size_t byte_size) const; //------------------------------------------------------------------ - /// Extract an unsigned integer of size \a byte_size from \a - /// *offset_ptr. + /// Extract an unsigned integer of size \a byte_size from \a *offset_ptr. /// - /// Extract a single unsigned integer value and update the offset - /// pointed to by \a offset_ptr. The size of the extracted integer - /// is specified by the \a byte_size argument. \a byte_size must - /// have a value greater than or equal to one and less than or equal - /// to eight since the return value is 64 bits wide. + /// Extract a single unsigned integer value and update the offset pointed to + /// by \a offset_ptr. The size of the extracted integer is specified by the + /// \a byte_size argument. \a byte_size must have a value greater than or + /// equal to one and less than or equal to eight since the return value is + /// 64 bits wide. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -563,12 +535,11 @@ public: //------------------------------------------------------------------ /// Extract an signed integer of size \a byte_size from \a *offset_ptr. /// - /// Extract a single signed integer value (sign extending if required) - /// and update the offset pointed to by \a offset_ptr. The size of - /// the extracted integer is specified by the \a byte_size argument. - /// \a byte_size must have a value greater than or equal to one and - /// less than or equal to eight since the return value is 64 bits - /// wide. + /// Extract a single signed integer value (sign extending if required) and + /// update the offset pointed to by \a offset_ptr. The size of the extracted + /// integer is specified by the \a byte_size argument. \a byte_size must + /// have a value greater than or equal to one and less than or equal to + /// eight since the return value is 64 bits wide. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -587,15 +558,15 @@ public: int64_t GetMaxS64(lldb::offset_t *offset_ptr, size_t byte_size) const; //------------------------------------------------------------------ - /// Extract an unsigned integer of size \a byte_size from \a - /// *offset_ptr, then extract the bitfield from this value if - /// \a bitfield_bit_size is non-zero. + /// Extract an unsigned integer of size \a byte_size from \a *offset_ptr, + /// then extract the bitfield from this value if \a bitfield_bit_size is + /// non-zero. /// - /// Extract a single unsigned integer value and update the offset - /// pointed to by \a offset_ptr. The size of the extracted integer - /// is specified by the \a byte_size argument. \a byte_size must - /// have a value greater than or equal to one and less than or equal - /// to 8 since the return value is 64 bits wide. + /// Extract a single unsigned integer value and update the offset pointed to + /// by \a offset_ptr. The size of the extracted integer is specified by the + /// \a byte_size argument. \a byte_size must have a value greater than or + /// equal to one and less than or equal to 8 since the return value is 64 + /// bits wide. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -627,16 +598,15 @@ public: uint32_t bitfield_bit_offset) const; //------------------------------------------------------------------ - /// Extract an signed integer of size \a byte_size from \a - /// *offset_ptr, then extract and signe extend the bitfield from - /// this value if \a bitfield_bit_size is non-zero. + /// Extract an signed integer of size \a byte_size from \a *offset_ptr, then + /// extract and signe extend the bitfield from this value if \a + /// bitfield_bit_size is non-zero. /// - /// Extract a single signed integer value (sign extending if required) - /// and update the offset pointed to by \a offset_ptr. The size of - /// the extracted integer is specified by the \a byte_size argument. - /// \a byte_size must have a value greater than or equal to one and - /// less than or equal to eight since the return value is 64 bits - /// wide. + /// Extract a single signed integer value (sign extending if required) and + /// update the offset pointed to by \a offset_ptr. The size of the extracted + /// integer is specified by the \a byte_size argument. \a byte_size must + /// have a value greater than or equal to one and less than or equal to + /// eight since the return value is 64 bits wide. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -670,10 +640,10 @@ public: //------------------------------------------------------------------ /// Extract an pointer from \a *offset_ptr. /// - /// Extract a single pointer from the data and update the offset - /// pointed to by \a offset_ptr. The size of the extracted pointer - /// comes from the \a m_addr_size member variable and should be - /// set correctly prior to extracting any pointer values. + /// Extract a single pointer from the data and update the offset pointed to + /// by \a offset_ptr. The size of the extracted pointer comes from the \a + /// m_addr_size member variable and should be set correctly prior to + /// extracting any pointer values. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -699,8 +669,8 @@ public: //------------------------------------------------------------------ /// Extract a uint8_t value from \a *offset_ptr. /// - /// Extract a single uint8_t from the binary data at the offset - /// pointed to by \a offset_ptr, and advance the offset on success. + /// Extract a single uint8_t from the binary data at the offset pointed to + /// by \a offset_ptr, and advance the offset on success. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -728,9 +698,9 @@ public: //------------------------------------------------------------------ /// Extract \a count uint8_t values from \a *offset_ptr. /// - /// Extract \a count uint8_t values from the binary data at the - /// offset pointed to by \a offset_ptr, and advance the offset on - /// success. The extracted values are copied into \a dst. + /// Extract \a count uint8_t values from the binary data at the offset + /// pointed to by \a offset_ptr, and advance the offset on success. The + /// extracted values are copied into \a dst. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -755,8 +725,8 @@ public: //------------------------------------------------------------------ /// Extract a uint16_t value from \a *offset_ptr. /// - /// Extract a single uint16_t from the binary data at the offset - /// pointed to by \a offset_ptr, and update the offset on success. + /// Extract a single uint16_t from the binary data at the offset pointed to + /// by \a offset_ptr, and update the offset on success. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -773,9 +743,9 @@ public: //------------------------------------------------------------------ /// Extract \a count uint16_t values from \a *offset_ptr. /// - /// Extract \a count uint16_t values from the binary data at the - /// offset pointed to by \a offset_ptr, and advance the offset on - /// success. The extracted values are copied into \a dst. + /// Extract \a count uint16_t values from the binary data at the offset + /// pointed to by \a offset_ptr, and advance the offset on success. The + /// extracted values are copied into \a dst. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -800,8 +770,8 @@ public: //------------------------------------------------------------------ /// Extract a uint32_t value from \a *offset_ptr. /// - /// Extract a single uint32_t from the binary data at the offset - /// pointed to by \a offset_ptr, and update the offset on success. + /// Extract a single uint32_t from the binary data at the offset pointed to + /// by \a offset_ptr, and update the offset on success. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -818,9 +788,9 @@ public: //------------------------------------------------------------------ /// Extract \a count uint32_t values from \a *offset_ptr. /// - /// Extract \a count uint32_t values from the binary data at the - /// offset pointed to by \a offset_ptr, and advance the offset on - /// success. The extracted values are copied into \a dst. + /// Extract \a count uint32_t values from the binary data at the offset + /// pointed to by \a offset_ptr, and advance the offset on success. The + /// extracted values are copied into \a dst. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -845,8 +815,8 @@ public: //------------------------------------------------------------------ /// Extract a uint64_t value from \a *offset_ptr. /// - /// Extract a single uint64_t from the binary data at the offset - /// pointed to by \a offset_ptr, and update the offset on success. + /// Extract a single uint64_t from the binary data at the offset pointed to + /// by \a offset_ptr, and update the offset on success. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -863,9 +833,9 @@ public: //------------------------------------------------------------------ /// Extract \a count uint64_t values from \a *offset_ptr. /// - /// Extract \a count uint64_t values from the binary data at the - /// offset pointed to by \a offset_ptr, and advance the offset on - /// success. The extracted values are copied into \a dst. + /// Extract \a count uint64_t values from the binary data at the offset + /// pointed to by \a offset_ptr, and advance the offset on success. The + /// extracted values are copied into \a dst. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -890,10 +860,10 @@ public: //------------------------------------------------------------------ /// Extract a signed LEB128 value from \a *offset_ptr. /// - /// Extracts an signed LEB128 number from this object's data - /// starting at the offset pointed to by \a offset_ptr. The offset - /// pointed to by \a offset_ptr will be updated with the offset of - /// the byte following the last extracted byte. + /// Extracts an signed LEB128 number from this object's data starting at the + /// offset pointed to by \a offset_ptr. The offset pointed to by \a + /// offset_ptr will be updated with the offset of the byte following the + /// last extracted byte. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -910,10 +880,10 @@ public: //------------------------------------------------------------------ /// Extract a unsigned LEB128 value from \a *offset_ptr. /// - /// Extracts an unsigned LEB128 number from this object's data - /// starting at the offset pointed to by \a offset_ptr. The offset - /// pointed to by \a offset_ptr will be updated with the offset of - /// the byte following the last extracted byte. + /// Extracts an unsigned LEB128 number from this object's data starting at + /// the offset pointed to by \a offset_ptr. The offset pointed to by \a + /// offset_ptr will be updated with the offset of the byte following the + /// last extracted byte. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced @@ -932,9 +902,9 @@ public: //------------------------------------------------------------------ /// Peek at a C string at \a offset. /// - /// Peeks at a string in the contained data. No verification is done - /// to make sure the entire string lies within the bounds of this - /// object's data, only \a offset is verified to be a valid offset. + /// Peeks at a string in the contained data. No verification is done to make + /// sure the entire string lies within the bounds of this object's data, + /// only \a offset is verified to be a valid offset. /// /// @param[in] offset /// An offset into the data. @@ -948,8 +918,8 @@ public: //------------------------------------------------------------------ /// Peek at a bytes at \a offset. /// - /// Returns a pointer to \a length bytes at \a offset as long as - /// there are \a length bytes available starting at \a offset. + /// Returns a pointer to \a length bytes at \a offset as long as there are + /// \a length bytes available starting at \a offset. /// /// @return /// A non-nullptr data pointer if \a offset is a valid offset and @@ -965,8 +935,8 @@ public: //------------------------------------------------------------------ /// Set the address byte size. /// - /// Set the size in bytes that will be used when extracting any - /// address and pointer values from data contained in this object. + /// Set the size in bytes that will be used when extracting any address and + /// pointer values from data contained in this object. /// /// @param[in] addr_size /// The size in bytes to use when extracting addresses. @@ -981,11 +951,10 @@ public: //------------------------------------------------------------------ /// Set data with a buffer that is caller owned. /// - /// Use data that is owned by the caller when extracting values. - /// The data must stay around as long as this object, or any object - /// that copies a subset of this object's data, is valid. If \a - /// bytes is nullptr, or \a length is zero, this object will contain - /// no data. + /// Use data that is owned by the caller when extracting values. The data + /// must stay around as long as this object, or any object that copies a + /// subset of this object's data, is valid. If \a bytes is nullptr, or \a + /// length is zero, this object will contain no data. /// /// @param[in] bytes /// A pointer to caller owned data. @@ -1005,16 +974,14 @@ public: //------------------------------------------------------------------ /// Adopt a subset of \a data. /// - /// Set this object's data to be a subset of the data bytes in \a - /// data. If \a data contains shared data, then a reference to the - /// shared data will be added to ensure the shared data stays around - /// as long as any objects have references to the shared data. The - /// byte order and the address size settings are copied from \a - /// data. If \a offset is not a valid offset in \a data, then no - /// reference to the shared data will be added. If there are not - /// \a length bytes available in \a data starting at \a offset, - /// the length will be truncated to contains as many bytes as - /// possible. + /// Set this object's data to be a subset of the data bytes in \a data. If + /// \a data contains shared data, then a reference to the shared data will + /// be added to ensure the shared data stays around as long as any objects + /// have references to the shared data. The byte order and the address size + /// settings are copied from \a data. If \a offset is not a valid offset in + /// \a data, then no reference to the shared data will be added. If there + /// are not \a length bytes available in \a data starting at \a offset, the + /// length will be truncated to contains as many bytes as possible. /// /// @param[in] data /// Another DataExtractor object that contains data. @@ -1034,15 +1001,14 @@ public: //------------------------------------------------------------------ /// Adopt a subset of shared data in \a data_sp. /// - /// Copies the data shared pointer which adds a reference to the - /// contained in \a data_sp. The shared data reference is reference - /// counted to ensure the data lives as long as anyone still has a - /// valid shared pointer to the data in \a data_sp. The byte order - /// and address byte size settings remain the same. If - /// \a offset is not a valid offset in \a data_sp, then no reference - /// to the shared data will be added. If there are not \a length - /// bytes available in \a data starting at \a offset, the length - /// will be truncated to contains as many bytes as possible. + /// Copies the data shared pointer which adds a reference to the contained + /// in \a data_sp. The shared data reference is reference counted to ensure + /// the data lives as long as anyone still has a valid shared pointer to the + /// data in \a data_sp. The byte order and address byte size settings remain + /// the same. If \a offset is not a valid offset in \a data_sp, then no + /// reference to the shared data will be added. If there are not \a length + /// bytes available in \a data starting at \a offset, the length will be + /// truncated to contains as many bytes as possible. /// /// @param[in] data_sp /// A shared pointer to data. @@ -1063,8 +1029,8 @@ public: //------------------------------------------------------------------ /// Set the byte_order value. /// - /// Sets the byte order of the data to extract. Extracted values - /// will be swapped if necessary when decoding. + /// Sets the byte order of the data to extract. Extracted values will be + /// swapped if necessary when decoding. /// /// @param[in] byte_order /// The byte order value to use when extracting data. @@ -1074,10 +1040,10 @@ public: //------------------------------------------------------------------ /// Skip an LEB128 number at \a *offset_ptr. /// - /// Skips a LEB128 number (signed or unsigned) from this object's - /// data starting at the offset pointed to by \a offset_ptr. The - /// offset pointed to by \a offset_ptr will be updated with the - /// offset of the byte following the last extracted byte. + /// Skips a LEB128 number (signed or unsigned) from this object's data + /// starting at the offset pointed to by \a offset_ptr. The offset pointed + /// to by \a offset_ptr will be updated with the offset of the byte + /// following the last extracted byte. /// /// @param[in,out] offset_ptr /// A pointer to an offset within the data that will be advanced diff --git a/include/lldb/Utility/Environment.h b/include/lldb/Utility/Environment.h new file mode 100644 index 0000000000000..ed0a36d7b3aa5 --- /dev/null +++ b/include/lldb/Utility/Environment.h @@ -0,0 +1,96 @@ +//===-- Environment.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_ENVIRONMENT_H +#define LLDB_UTILITY_ENVIRONMENT_H + +#include "llvm/ADT/StringMap.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/FormatProviders.h" + +namespace lldb_private { + +class Environment : private llvm::StringMap<std::string> { + using Base = llvm::StringMap<std::string>; + +public: + class Envp { + public: + Envp(Envp &&RHS) = default; + Envp &operator=(Envp &&RHS) = default; + + char *const *get() const { return Data; } + operator char *const *() const { return get(); } + + private: + explicit Envp(const Environment &Env); + char *make_entry(llvm::StringRef Key, llvm::StringRef Value); + Envp(const Envp &) = delete; + Envp &operator=(const Envp &) = delete; + friend class Environment; + + llvm::BumpPtrAllocator Allocator; + char **Data; + }; + + using Base::const_iterator; + using Base::iterator; + using Base::value_type; + + using Base::begin; + using Base::clear; + using Base::count; + using Base::empty; + using Base::end; + using Base::erase; + using Base::find; + using Base::insert; + using Base::lookup; + using Base::size; + using Base::try_emplace; + using Base::operator[]; + + Environment() : Base() {} + Environment(const Environment &RHS) : Base(RHS) {} + Environment(Environment &&RHS) : Base(std::move(RHS)) {} + Environment(char *const *Env) + : Environment(const_cast<const char *const *>(Env)) {} + Environment(const char *const *Env); + + Environment &operator=(Environment RHS) { + Base::operator=(std::move(RHS)); + return *this; + } + + std::pair<iterator, bool> insert(llvm::StringRef KeyEqValue) { + return insert(KeyEqValue.split('=')); + } + + void insert(const_iterator first, const_iterator last); + + Envp getEnvp() const { return Envp(*this); } + + static std::string compose(const value_type &KeyValue) { + return (KeyValue.first() + "=" + KeyValue.second).str(); + } +}; + +} // namespace lldb_private + +namespace llvm { +template <> struct format_provider<lldb_private::Environment> { + static void format(const lldb_private::Environment &Env, raw_ostream &Stream, + StringRef Style) { + for (const auto &KV : Env) + Stream << "env[" << KV.first() << "] = " << KV.second << "\n"; + } +}; +} // namespace llvm + +#endif // #ifndef LLDB_UTILITY_ENVIRONMENT_H diff --git a/include/lldb/Utility/FileSpec.h b/include/lldb/Utility/FileSpec.h index 55d44d84087d5..d062ba598cccf 100644 --- a/include/lldb/Utility/FileSpec.h +++ b/include/lldb/Utility/FileSpec.h @@ -19,9 +19,10 @@ // Project includes #include "lldb/Utility/ConstString.h" -#include "llvm/ADT/StringRef.h" // for StringRef +#include "llvm/ADT/StringRef.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/Path.h" #include <stddef.h> // for size_t #include <stdint.h> // for uint32_t, uint64_t @@ -43,37 +44,32 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class FileSpec FileSpec.h "lldb/Host/FileSpec.h" -/// @brief A file utility class. +/// A file utility class. /// /// A file specification class that divides paths up into a directory -/// and basename. These string values of the paths are put into uniqued -/// string pools for fast comparisons and efficient memory usage. +/// and basename. These string values of the paths are put into uniqued string +/// pools for fast comparisons and efficient memory usage. /// -/// Another reason the paths are split into the directory and basename -/// is to allow efficient debugger searching. Often in a debugger the -/// user types in the basename of the file, for example setting a -/// breakpoint by file and line, or specifying a module (shared library) -/// to limit the scope in which to execute a command. The user rarely -/// types in a full path. When the paths are already split up, it makes -/// it easy for us to compare only the basenames of a lot of file -/// specifications without having to split up the file path each time -/// to get to the basename. +/// Another reason the paths are split into the directory and basename is to +/// allow efficient debugger searching. Often in a debugger the user types in +/// the basename of the file, for example setting a breakpoint by file and +/// line, or specifying a module (shared library) to limit the scope in which +/// to execute a command. The user rarely types in a full path. When the paths +/// are already split up, it makes it easy for us to compare only the +/// basenames of a lot of file specifications without having to split up the +/// file path each time to get to the basename. //---------------------------------------------------------------------- class FileSpec { public: - enum PathSyntax : unsigned char { - ePathSyntaxPosix, - ePathSyntaxWindows, - ePathSyntaxHostNative - }; + using Style = llvm::sys::path::Style; FileSpec(); //------------------------------------------------------------------ /// 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 + /// 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). /// /// @param[in] path @@ -87,7 +83,7 @@ public: /// @see FileSpec::SetFile (const char *path, bool resolve) //------------------------------------------------------------------ explicit FileSpec(llvm::StringRef path, bool resolve_path, - PathSyntax syntax = ePathSyntaxHostNative); + Style style = Style::native); explicit FileSpec(llvm::StringRef path, bool resolve_path, const llvm::Triple &Triple); @@ -95,8 +91,7 @@ public: //------------------------------------------------------------------ /// Copy constructor /// - /// Makes a copy of the uniqued directory and filename strings from - /// \a rhs. + /// Makes a copy of the uniqued directory and filename strings from \a rhs. /// /// @param[in] rhs /// A const FileSpec object reference to copy. @@ -106,8 +101,8 @@ public: //------------------------------------------------------------------ /// Copy constructor /// - /// Makes a copy of the uniqued directory and filename strings from - /// \a rhs if it is not nullptr. + /// Makes a copy of the uniqued directory and filename strings from \a rhs + /// if it is not nullptr. /// /// @param[in] rhs /// A const FileSpec object pointer to copy if non-nullptr. @@ -126,8 +121,7 @@ public: //------------------------------------------------------------------ /// Assignment operator. /// - /// Makes a copy of the uniqued directory and filename strings from - /// \a rhs. + /// Makes a copy of the uniqued directory and filename strings from \a rhs. /// /// @param[in] rhs /// A const FileSpec object reference to assign to this object. @@ -185,8 +179,8 @@ public: //------------------------------------------------------------------ /// Convert to pointer operator. /// - /// This allows code to check a FileSpec object to see if it - /// contains anything valid using code such as: + /// This allows code to check a FileSpec object to see if it contains + /// anything valid using code such as: /// /// @code /// FileSpec file_spec(...); @@ -203,8 +197,8 @@ public: //------------------------------------------------------------------ /// Logical NOT operator. /// - /// This allows code to check a FileSpec object to see if it is - /// invalid using code such as: + /// This allows code to check a FileSpec object to see if it is invalid + /// using code such as: /// /// @code /// FileSpec file_spec(...); @@ -221,20 +215,19 @@ public: //------------------------------------------------------------------ /// Clears the object state. /// - /// Clear this object by releasing both the directory and filename - /// string values and reverting them to empty strings. + /// Clear this object by releasing both the directory and filename string + /// values and reverting them to empty strings. //------------------------------------------------------------------ void Clear(); //------------------------------------------------------------------ /// Compare two FileSpec objects. /// - /// If \a full is true, then both the directory and the filename - /// must match. If \a full is false, then the directory names for - /// \a lhs and \a rhs are only compared if they are both not empty. - /// This allows a FileSpec object to only contain a filename - /// and it can match FileSpec objects that have matching - /// filenames with different paths. + /// If \a full is true, then both the directory and the filename must match. + /// If \a full is false, then the directory names for \a lhs and \a rhs are + /// only compared if they are both not empty. This allows a FileSpec object + /// to only contain a filename and it can match FileSpec objects that have + /// matching filenames with different paths. /// /// @param[in] lhs /// A const reference to the Left Hand Side object to compare. @@ -256,8 +249,7 @@ public: //------------------------------------------------------------------ static int Compare(const FileSpec &lhs, const FileSpec &rhs, bool full); - static bool Equal(const FileSpec &a, const FileSpec &b, bool full, - bool remove_backups = false); + static bool Equal(const FileSpec &a, const FileSpec &b, bool full); //------------------------------------------------------------------ /// Case sensitivity of path. @@ -266,14 +258,14 @@ public: /// \b true if the file path is case sensitive (POSIX), false /// if case insensitive (Windows). //------------------------------------------------------------------ - bool IsCaseSensitive() const { return m_syntax != ePathSyntaxWindows; } + bool IsCaseSensitive() const { return m_style != Style::windows; } //------------------------------------------------------------------ /// Dump this object to a Stream. /// - /// Dump the object to the supplied stream \a s. If the object - /// contains a valid directory name, it will be displayed followed - /// by a directory delimiter, and the filename. + /// Dump the object to the supplied stream \a s. If the object contains a + /// valid directory name, it will be displayed followed by a directory + /// delimiter, and the filename. /// /// @param[in] s /// The stream to which to dump the object description. @@ -303,8 +295,8 @@ public: /// 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. + /// 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 @@ -314,14 +306,14 @@ public: //------------------------------------------------------------------ /// 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. + /// 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; - PathSyntax GetPathSyntax() const; + Style GetPathStyle() const; //------------------------------------------------------------------ /// Directory string get accessor. @@ -356,9 +348,8 @@ public: const ConstString &GetFilename() const; //------------------------------------------------------------------ - /// Returns true if the filespec represents an implementation source - /// file (files with a ".c", ".cpp", ".m", ".mm" (many more) - /// extension). + /// Returns true if the filespec represents an implementation source file + /// (files with a ".c", ".cpp", ".m", ".mm" (many more) extension). /// /// @return /// \b true if the filespec represents an implementation source @@ -387,9 +378,8 @@ public: //------------------------------------------------------------------ /// Extract the full path to the file. /// - /// Extract the directory and path into a fixed buffer. This is - /// needed as the directory and path are stored in separate string - /// values. + /// Extract the directory and path into a fixed buffer. This is needed as + /// the directory and path are stored in separate string values. /// /// @param[out] path /// The buffer in which to place the extracted full path. @@ -436,10 +426,10 @@ public: //------------------------------------------------------------------ /// Extract the extension of the file. /// - /// Returns a ConstString that represents the extension of the filename - /// for this FileSpec object. If this object does not represent a file, - /// or the filename has no extension, ConstString(nullptr) is returned. - /// The dot ('.') character is not returned as part of the extension + /// Returns a ConstString that represents the extension of the filename for + /// this FileSpec object. If this object does not represent a file, or the + /// filename has no extension, ConstString(nullptr) is returned. The dot + /// ('.') character is not returned as part of the extension /// /// @return /// Returns the extension of the file as a ConstString object. @@ -450,8 +440,8 @@ public: /// Return the filename without the extension part /// /// Returns a ConstString that represents the filename of this object - /// without the extension part (e.g. for a file named "foo.bar", "foo" - /// is returned) + /// without the extension part (e.g. for a file named "foo.bar", "foo" is + /// returned) /// /// @return /// Returns the filename without extension @@ -462,9 +452,8 @@ public: //------------------------------------------------------------------ /// 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). + /// 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 @@ -476,9 +465,9 @@ public: //------------------------------------------------------------------ /// Get the memory cost of this object. /// - /// Return the size in bytes that this object takes in memory. This - /// returns the size in bytes of this object, not any shared string - /// values it may refer to. + /// Return the size in bytes that this object takes in memory. This returns + /// the size in bytes of this object, not any shared string values it may + /// refer to. /// /// @return /// The number of bytes that this object occupies in memory. @@ -488,17 +477,11 @@ public: size_t MemorySize() const; //------------------------------------------------------------------ - /// Normalize a pathname by collapsing redundant separators and - /// up-level references. - //------------------------------------------------------------------ - FileSpec GetNormalizedPath() const; - - //------------------------------------------------------------------ /// Change the file specified with a new path. /// - /// Update the contents of this object with a new path. The path will - /// be split up into a directory and filename and stored as uniqued - /// string values for quick comparison and efficient memory usage. + /// Update the contents of this object with a new path. The path will be + /// split up into a directory and filename and stored as uniqued string + /// values for quick comparison and efficient memory usage. /// /// @param[in] path /// A full, partial, or relative path to a file. @@ -507,8 +490,7 @@ 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, - PathSyntax syntax = ePathSyntaxHostNative); + void SetFile(llvm::StringRef path, bool resolve_path, Style style); void SetFile(llvm::StringRef path, bool resolve_path, const llvm::Triple &Triple); @@ -518,11 +500,11 @@ public: //------------------------------------------------------------------ /// Set if the file path has been resolved or not. /// - /// If you know a file path is already resolved and avoided passing - /// a \b true parameter for any functions that take a "bool - /// resolve_path" parameter, you can set the value manually using - /// this call to make sure we don't try and resolve it later, or try - /// and resolve a path that has already been resolved. + /// If you know a file path is already resolved and avoided passing a \b + /// true parameter for any functions that take a "bool resolve_path" + /// parameter, you can set the value manually using this call to make sure + /// we don't try and resolve it later, or try and resolve a path that has + /// already been resolved. /// /// @param[in] is_resolved /// A boolean value that will replace the current value that @@ -549,7 +531,14 @@ public: void AppendPathComponent(llvm::StringRef component); void AppendPathComponent(const FileSpec &new_path); - void RemoveLastPathComponent(); + //------------------------------------------------------------------ + /// Removes the last path component by replacing the current path with its + /// parent. When the current path has no parent, this is a no-op. + /// + /// @return + /// A boolean value indicating whether the path was updated. + //------------------------------------------------------------------ + bool RemoveLastPathComponent(); ConstString GetLastPathComponent() const; @@ -576,13 +565,17 @@ public: protected: //------------------------------------------------------------------ + // Convenience method for setting the file without changing the style. + //------------------------------------------------------------------ + void SetFile(llvm::StringRef path, bool resolve_path); + + //------------------------------------------------------------------ // Member variables //------------------------------------------------------------------ ConstString m_directory; ///< The uniqued directory path ConstString m_filename; ///< The uniqued filename path mutable bool m_is_resolved = false; ///< True if this path has been resolved. - PathSyntax - m_syntax; ///< The syntax that this path uses (e.g. Windows / Posix) + Style m_style; ///< The syntax that this path uses (e.g. Windows / Posix) }; //---------------------------------------------------------------------- @@ -616,6 +609,6 @@ template <> struct format_provider<lldb_private::FileSpec> { static void format(const lldb_private::FileSpec &F, llvm::raw_ostream &Stream, StringRef Style); }; -} +} // namespace llvm #endif // liblldb_FileSpec_h_ diff --git a/include/lldb/Utility/Flags.h b/include/lldb/Utility/Flags.h index 1b303858b1c1c..5ef6122d1146e 100644 --- a/include/lldb/Utility/Flags.h +++ b/include/lldb/Utility/Flags.h @@ -17,10 +17,10 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class Flags Flags.h "lldb/Utility/Flags.h" -/// @brief A class to manage flags. +/// A class to manage flags. /// -/// The Flags class managed flag bits and allows testing and -/// modification of individual or multiple flag bits. +/// The Flags class managed flag bits and allows testing and modification of +/// individual or multiple flag bits. //---------------------------------------------------------------------- class Flags { public: @@ -32,8 +32,8 @@ public: //---------------------------------------------------------------------- /// Construct with initial flag bit values. /// - /// Constructs this object with \a mask as the initial value for all - /// of the flags. + /// Constructs this object with \a mask as the initial value for all of the + /// flags. /// /// @param[in] mask /// The initial value for all flags. @@ -64,8 +64,7 @@ public: ValueType Get() const { return m_flags; } //---------------------------------------------------------------------- - /// Return the number of flags that can be represented in this - /// object. + /// Return the number of flags that can be represented in this object. /// /// @return /// The maximum number bits in this flag object. @@ -95,8 +94,7 @@ public: } //---------------------------------------------------------------------- - /// Set one or more flags by logical OR'ing \a mask with the current - /// flags. + /// Set one or more flags by logical OR'ing \a mask with the current flags. /// /// @param[in] mask /// A bitfield containing one or more flags. diff --git a/include/lldb/Utility/History.h b/include/lldb/Utility/History.h deleted file mode 100644 index c6882b65fd8ec..0000000000000 --- a/include/lldb/Utility/History.h +++ /dev/null @@ -1,136 +0,0 @@ -//===-- History.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_History_h_ -#define lldb_History_h_ - -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN - -// C++ Includes -#include <mutex> -#include <stack> -#include <string> - -#include <stddef.h> // for size_t -#include <stdint.h> - -namespace lldb_private { -class Stream; -} - -namespace lldb_private { - -//---------------------------------------------------------------------- -/// @class HistorySource History.h "lldb/Core/History.h" -/// @brief A class that defines history events. -//---------------------------------------------------------------------- - -class HistorySource { -public: - typedef const void *HistoryEvent; - - HistorySource() : m_mutex(), m_events() {} - - virtual ~HistorySource() {} - - // Create a new history event. Subclasses should use any data or members - // in the subclass of this class to produce a history event and push it - // onto the end of the history stack. - - virtual HistoryEvent CreateHistoryEvent() = 0; - - virtual void DeleteHistoryEvent(HistoryEvent event) = 0; - - virtual void DumpHistoryEvent(Stream &strm, HistoryEvent event) = 0; - - virtual size_t GetHistoryEventCount() = 0; - - virtual HistoryEvent GetHistoryEventAtIndex(uint32_t idx) = 0; - - virtual HistoryEvent GetCurrentHistoryEvent() = 0; - - // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs. - virtual int CompareHistoryEvents(const HistoryEvent lhs, - const HistoryEvent rhs) = 0; - - virtual bool IsCurrentHistoryEvent(const HistoryEvent event) = 0; - -private: - typedef std::stack<HistoryEvent> collection; - - std::recursive_mutex m_mutex; - collection m_events; - - DISALLOW_COPY_AND_ASSIGN(HistorySource); -}; - -//---------------------------------------------------------------------- -/// @class HistorySourceUInt History.h "lldb/Core/History.h" -/// @brief A class that defines history events that are represented by -/// unsigned integers. -/// -/// Any history event that is defined by a unique monotonically -/// increasing unsigned integer -//---------------------------------------------------------------------- - -class HistorySourceUInt : public HistorySource { - HistorySourceUInt(const char *id_name, uintptr_t start_value = 0u) - : HistorySource(), m_name(id_name), m_curr_id(start_value) {} - - ~HistorySourceUInt() override {} - - // Create a new history event. Subclasses should use any data or members - // in the subclass of this class to produce a history event and push it - // onto the end of the history stack. - - HistoryEvent CreateHistoryEvent() override { - ++m_curr_id; - return (HistoryEvent)m_curr_id; - } - - void DeleteHistoryEvent(HistoryEvent event) override { - // Nothing to delete, the event contains the integer - } - - void DumpHistoryEvent(Stream &strm, HistoryEvent event) override; - - size_t GetHistoryEventCount() override { return m_curr_id; } - - HistoryEvent GetHistoryEventAtIndex(uint32_t idx) override { - return (HistoryEvent)((uintptr_t)idx); - } - - HistoryEvent GetCurrentHistoryEvent() override { - return (HistoryEvent)m_curr_id; - } - - // Return 0 when lhs == rhs, 1 if lhs > rhs, or -1 if lhs < rhs. - int CompareHistoryEvents(const HistoryEvent lhs, - const HistoryEvent rhs) override { - uintptr_t lhs_uint = (uintptr_t)lhs; - uintptr_t rhs_uint = (uintptr_t)rhs; - if (lhs_uint < rhs_uint) - return -1; - if (lhs_uint > rhs_uint) - return +1; - return 0; - } - - bool IsCurrentHistoryEvent(const HistoryEvent event) override { - return (uintptr_t)event == m_curr_id; - } - -protected: - std::string m_name; // The name of the history unsigned integer - uintptr_t m_curr_id; // The current value of the history unsigned unteger -}; - -} // namespace lldb_private - -#endif // lldb_History_h_ diff --git a/include/lldb/Utility/JSON.h b/include/lldb/Utility/JSON.h index 8bf9c4b37b023..6fe1945ea227a 100644 --- a/include/lldb/Utility/JSON.h +++ b/include/lldb/Utility/JSON.h @@ -79,9 +79,8 @@ public: // SFINAE to avoid having ambiguous overloads because of the implicit type // promotion. If we // would have constructors only with int64_t, uint64_t and double types then - // constructing a - // JSONNumber from an int32_t (or any other similar type) would fail to - // compile. + // constructing a JSONNumber from an int32_t (or any other similar type) + // would fail to compile. template <typename T, typename std::enable_if< std::is_integral<T>::value && diff --git a/include/lldb/Utility/Log.h b/include/lldb/Utility/Log.h index 80a80fc164853..62776bdb281bb 100644 --- a/include/lldb/Utility/Log.h +++ b/include/lldb/Utility/Log.h @@ -17,6 +17,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringMap.h" // for StringMap #include "llvm/ADT/StringRef.h" // for StringRef, StringLiteral +#include "llvm/Support/Error.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/RWMutex.h" @@ -73,10 +74,10 @@ public: : log_ptr(nullptr), categories(categories), default_flags(default_flags) {} - // This function is safe to call at any time - // If the channel is disabled after (or concurrently with) this function - // returning a non-null Log pointer, it is still safe to attempt to write to - // the Log object -- the output will be discarded. + // This function is safe to call at any time If the channel is disabled + // after (or concurrently with) this function returning a non-null Log + // pointer, it is still safe to attempt to write to the Log object -- the + // output will be discarded. Log *GetLogIfAll(uint32_t mask) { Log *log = log_ptr.load(std::memory_order_relaxed); if (log && log->GetMask().AllSet(mask)) @@ -84,10 +85,10 @@ public: return nullptr; } - // This function is safe to call at any time - // If the channel is disabled after (or concurrently with) this function - // returning a non-null Log pointer, it is still safe to attempt to write to - // the Log object -- the output will be discarded. + // This function is safe to call at any time If the channel is disabled + // after (or concurrently with) this function returning a non-null Log + // pointer, it is still safe to attempt to write to the Log object -- the + // output will be discarded. Log *GetLogIfAny(uint32_t mask) { Log *log = log_ptr.load(std::memory_order_relaxed); if (log && log->GetMask().AnySet(mask)) @@ -140,6 +141,15 @@ public: Format(file, function, llvm::formatv(format, std::forward<Args>(args)...)); } + template <typename... Args> + void FormatError(llvm::Error error, llvm::StringRef file, + llvm::StringRef function, const char *format, + Args &&... args) { + Format(file, function, + llvm::formatv(format, llvm::toString(std::move(error)), + std::forward<Args>(args)...)); + } + void Printf(const char *format, ...) __attribute__((format(printf, 2, 3))); void VAPrintf(const char *format, va_list args); @@ -161,8 +171,8 @@ public: private: Channel &m_channel; - // The mutex makes sure enable/disable operations are thread-safe. The options - // and mask variables are atomic to enable their reading in + // The mutex makes sure enable/disable operations are thread-safe. The + // options and mask variables are atomic to enable their reading in // Channel::GetLogIfAny without taking the mutex to speed up the fast path. // Their modification however, is still protected by this mutex. llvm::sys::RWMutex m_mutex; @@ -208,14 +218,27 @@ private: do { \ ::lldb_private::Log *log_private = (log); \ if (log_private) \ - log_private->Format(__FILE__, __FUNCTION__, __VA_ARGS__); \ + log_private->Format(__FILE__, __func__, __VA_ARGS__); \ } while (0) #define LLDB_LOGV(log, ...) \ do { \ ::lldb_private::Log *log_private = (log); \ if (log_private && log_private->GetVerbose()) \ - log_private->Format(__FILE__, __FUNCTION__, __VA_ARGS__); \ + log_private->Format(__FILE__, __func__, __VA_ARGS__); \ + } while (0) + +// Write message to log, if error is set. In the log message refer to the error +// with {0}. Error is cleared regardless of whether logging is enabled. +#define LLDB_LOG_ERROR(log, error, ...) \ + do { \ + ::lldb_private::Log *log_private = (log); \ + ::llvm::Error error_private = (error); \ + if (log_private && error_private) { \ + log_private->FormatError(::std::move(error_private), __FILE__, __func__, \ + __VA_ARGS__); \ + } else \ + ::llvm::consumeError(::std::move(error_private)); \ } while (0) #endif // LLDB_UTILITY_LOG_H diff --git a/include/lldb/Utility/RegularExpression.h b/include/lldb/Utility/RegularExpression.h index dba7001ce0fa9..6048fcc610a3b 100644 --- a/include/lldb/Utility/RegularExpression.h +++ b/include/lldb/Utility/RegularExpression.h @@ -52,11 +52,11 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class RegularExpression RegularExpression.h /// "lldb/Utility/RegularExpression.h" -/// @brief A C++ wrapper class for regex. +/// A C++ wrapper class for regex. /// -/// This regular expression class wraps the posix regex functions -/// \c regcomp(), \c regerror(), \c regexec(), and \c regfree() from -/// the header file in \c /usr/include/regex\.h. +/// This regular expression class wraps the posix regex functions \c +/// regcomp(), \c regerror(), \c regexec(), and \c regfree() from the header +/// file in \c /usr/include/regex\.h. //---------------------------------------------------------------------- class RegularExpression { public: @@ -98,8 +98,8 @@ public: //------------------------------------------------------------------ /// Default constructor. /// - /// The default constructor that initializes the object state such - /// that it contains no compiled regular expression. + /// The default constructor that initializes the object state such that it + /// contains no compiled regular expression. //------------------------------------------------------------------ RegularExpression(); @@ -108,8 +108,8 @@ public: //------------------------------------------------------------------ /// Destructor. /// - /// Any previously compiled regular expression contained in this - /// object will be freed. + /// Any previously compiled regular expression contained in this object will + /// be freed. //------------------------------------------------------------------ ~RegularExpression(); @@ -120,12 +120,11 @@ public: //------------------------------------------------------------------ /// Compile a regular expression. /// - /// Compile a regular expression using the supplied regular - /// expression text. The compiled regular expression lives - /// in this object so that it can be readily used for regular - /// expression matches. Execute() can be called after the regular - /// expression is compiled. Any previously compiled regular - /// expression contained in this object will be freed. + /// Compile a regular expression using the supplied regular expression text. + /// The compiled regular expression lives in this object so that it can be + /// readily used for regular expression matches. Execute() can be called + /// after the regular expression is compiled. Any previously compiled + /// regular expression contained in this object will be freed. /// /// @param[in] re /// A NULL terminated C string that represents the regular @@ -141,11 +140,11 @@ public: //------------------------------------------------------------------ /// Executes a regular expression. /// - /// Execute a regular expression match using the compiled regular - /// expression that is already in this object against the match - /// string \a s. If any parens are used for regular expression - /// matches \a match_count should indicate the number of regmatch_t - /// values that are present in \a match_ptr. + /// Execute a regular expression match using the compiled regular expression + /// that is already in this object against the match string \a s. If any + /// parens are used for regular expression matches \a match_count should + /// indicate the number of regmatch_t values that are present in \a + /// match_ptr. /// /// @param[in] string /// The string to match against the compile regular expression. @@ -167,8 +166,8 @@ public: //------------------------------------------------------------------ /// Free the compiled regular expression. /// - /// If this object contains a valid compiled regular expression, - /// this function will free any resources it was consuming. + /// If this object contains a valid compiled regular expression, this + /// function will free any resources it was consuming. //------------------------------------------------------------------ void Free(); diff --git a/include/lldb/Utility/SafeMachO.h b/include/lldb/Utility/SafeMachO.h index 791410a38b34f..1565b313f42b6 100644 --- a/include/lldb/Utility/SafeMachO.h +++ b/include/lldb/Utility/SafeMachO.h @@ -9,18 +9,15 @@ #ifndef liblldb_SafeMachO_h_ #define liblldb_SafeMachO_h_ -// This header file is required to work around collisions between the defines in -// mach/machine.h, and enum members -// of the same name in llvm's MachO.h. If you want to use llvm/Support/MachO.h, -// use this file instead. -// The caveats are: -// 1) You can only use the MachO.h enums, you can't use the defines. That won't -// make a difference since the values +// This header file is required to work around collisions between the defines +// in mach/machine.h, and enum members of the same name in llvm's MachO.h. If +// you want to use llvm/Support/MachO.h, use this file instead. The caveats +// are: 1) You can only use the MachO.h enums, you can't use the defines. That +// won't make a difference since the values // are the same. // 2) If you need any header file that relies on mach/machine.h, you must -// include that first. -// 3) This isn't a total solution, it doesn't undef every define that MachO.h -// has borrowed from various system headers, +// include that first. 3) This isn't a total solution, it doesn't undef every +// define that MachO.h has borrowed from various system headers, // only the ones that come from mach/machine.h because that is the one we // ended up pulling in from various places. // diff --git a/include/lldb/Utility/SelectHelper.h b/include/lldb/Utility/SelectHelper.h index 12950d032fb68..004952f1c598d 100644 --- a/include/lldb/Utility/SelectHelper.h +++ b/include/lldb/Utility/SelectHelper.h @@ -23,32 +23,31 @@ public: // Defaults to infinite wait for select unless you call SetTimeout() SelectHelper(); - // Call SetTimeout() before calling SelectHelper::Select() to set the - // timeout based on the current time + the timeout. This allows multiple - // calls to SelectHelper::Select() without having to worry about the - // absolute timeout as this class manages to set the relative timeout - // correctly. + // Call SetTimeout() before calling SelectHelper::Select() to set the timeout + // based on the current time + the timeout. This allows multiple calls to + // SelectHelper::Select() without having to worry about the absolute timeout + // as this class manages to set the relative timeout correctly. void SetTimeout(const std::chrono::microseconds &timeout); - // Call the FDSet*() functions before calling SelectHelper::Select() to - // set the file descriptors that we will watch for when calling - // select. This will cause FD_SET() to be called prior to calling select - // using the "fd" provided. + // Call the FDSet*() functions before calling SelectHelper::Select() to set + // the file descriptors that we will watch for when calling select. This will + // cause FD_SET() to be called prior to calling select using the "fd" + // provided. void FDSetRead(lldb::socket_t fd); void FDSetWrite(lldb::socket_t fd); void FDSetError(lldb::socket_t fd); - // Call the FDIsSet*() functions after calling SelectHelper::Select() - // to check which file descriptors are ready for read/write/error. This - // will contain the result of FD_ISSET after calling select for a given - // file descriptor. + // Call the FDIsSet*() functions after calling SelectHelper::Select() to + // check which file descriptors are ready for read/write/error. This will + // contain the result of FD_ISSET after calling select for a given file + // descriptor. bool FDIsSetRead(lldb::socket_t fd) const; bool FDIsSetWrite(lldb::socket_t fd) const; bool FDIsSetError(lldb::socket_t fd) const; - // Call the system's select() to wait for descriptors using - // timeout provided in a call the SelectHelper::SetTimeout(), - // or infinite wait if no timeout was set. + // Call the system's select() to wait for descriptors using timeout provided + // in a call the SelectHelper::SetTimeout(), or infinite wait if no timeout + // was set. lldb_private::Status Select(); protected: diff --git a/include/lldb/Utility/SharedCluster.h b/include/lldb/Utility/SharedCluster.h index b01f702c27879..61b9804ad3356 100644 --- a/include/lldb/Utility/SharedCluster.h +++ b/include/lldb/Utility/SharedCluster.h @@ -15,6 +15,8 @@ #include "llvm/ADT/SmallPtrSet.h" +#include <mutex> + namespace lldb_private { namespace imp { @@ -48,9 +50,9 @@ public: delete object; } - // Decrement refcount should have been called on this ClusterManager, - // and it should have locked the mutex, now we will unlock it before - // we destroy it... + // Decrement refcount should have been called on this ClusterManager, and + // it should have locked the mutex, now we will unlock it before we destroy + // it... m_mutex.unlock(); } diff --git a/include/lldb/Utility/SharingPtr.h b/include/lldb/Utility/SharingPtr.h index 41fa0c8121d89..691c92afaaaeb 100644 --- a/include/lldb/Utility/SharingPtr.h +++ b/include/lldb/Utility/SharingPtr.h @@ -14,9 +14,9 @@ // C++ Includes #include <memory> -// Microsoft Visual C++ currently does not enable std::atomic to work -// in CLR mode - as such we need to "hack around it" for MSVC++ builds only -// using Windows specific intrinsics instead of the C++11 atomic support +// Microsoft Visual C++ currently does not enable std::atomic to work in CLR +// mode - as such we need to "hack around it" for MSVC++ builds only using +// Windows specific intrinsics instead of the C++11 atomic support #ifdef _MSC_VER #include <intrin.h> #else diff --git a/include/lldb/Utility/Status.h b/include/lldb/Utility/Status.h index 8c3e009a8c2e5..3bd2cd5b3b410 100644 --- a/include/lldb/Utility/Status.h +++ b/include/lldb/Utility/Status.h @@ -28,30 +28,27 @@ class raw_ostream; namespace lldb_private { //---------------------------------------------------------------------- -/// @class Status Status.h "lldb/Utility/Status.h" -/// @brief An error handling class. +/// @class Status Status.h "lldb/Utility/Status.h" An error handling class. /// /// This class is designed to be able to hold any error code that can be -/// encountered on a given platform. The errors are stored as a value -/// of type Status::ValueType. This value should be large enough to hold -/// any and all errors that the class supports. Each error has an -/// associated type that is of type lldb::ErrorType. New types -/// can be added to support new error types, and architecture specific -/// types can be enabled. In the future we may wish to switch to a -/// registration mechanism where new error types can be registered at -/// runtime instead of a hard coded scheme. +/// encountered on a given platform. The errors are stored as a value of type +/// Status::ValueType. This value should be large enough to hold any and all +/// errors that the class supports. Each error has an associated type that is +/// of type lldb::ErrorType. New types can be added to support new error +/// types, and architecture specific types can be enabled. In the future we +/// may wish to switch to a registration mechanism where new error types can +/// be registered at runtime instead of a hard coded scheme. /// -/// All errors in this class also know how to generate a string -/// representation of themselves for printing results and error codes. -/// The string value will be fetched on demand and its string value will -/// be cached until the error is cleared of the value of the error -/// changes. +/// All errors in this class also know how to generate a string representation +/// of themselves for printing results and error codes. The string value will +/// be fetched on demand and its string value will be cached until the error +/// is cleared of the value of the error changes. //---------------------------------------------------------------------- class Status { public: //------------------------------------------------------------------ - /// Every error value that this object can contain needs to be able - /// to fit into ValueType. + /// Every error value that this object can contain needs to be able to fit + /// into ValueType. //------------------------------------------------------------------ typedef uint32_t ValueType; @@ -98,11 +95,10 @@ public: //------------------------------------------------------------------ /// Get the error string associated with the current error. // - /// Gets the error value as a NULL terminated C string. The error - /// string will be fetched and cached on demand. The error string - /// will be retrieved from a callback that is appropriate for the - /// type of the error and will be cached until the error value is - /// changed or cleared. + /// Gets the error value as a NULL terminated C string. The error string + /// will be fetched and cached on demand. The error string will be retrieved + /// from a callback that is appropriate for the type of the error and will + /// be cached until the error value is changed or cleared. /// /// @return /// The error as a NULL terminated C string value if the error @@ -114,8 +110,8 @@ public: //------------------------------------------------------------------ /// Clear the object state. /// - /// Reverts the state of this object to contain a generic success - /// value and frees any cached error string value. + /// Reverts the state of this object to contain a generic success value and + /// frees any cached error string value. //------------------------------------------------------------------ void Clear(); @@ -147,8 +143,8 @@ public: //------------------------------------------------------------------ /// Set accessor from a kern_return_t. /// - /// Set accesssor for the error value to \a err and the error type - /// to \c MachKernel. + /// Set accesssor for the error value to \a err and the error type to \c + /// MachKernel. /// /// @param[in] err /// A mach error code. @@ -163,8 +159,8 @@ public: //------------------------------------------------------------------ /// Set accesssor with an error value and type. /// - /// Set accesssor for the error value to \a err and the error type - /// to \a type. + /// Set accesssor for the error value to \a err and the error type to \a + /// type. /// /// @param[in] err /// A mach error code. @@ -177,28 +173,28 @@ public: //------------------------------------------------------------------ /// Set the current error to errno. /// - /// Update the error value to be \c errno and update the type to - /// be \c Status::POSIX. + /// Update the error value to be \c errno and update the type to be \c + /// Status::POSIX. //------------------------------------------------------------------ void SetErrorToErrno(); //------------------------------------------------------------------ /// Set the current error to a generic error. /// - /// Update the error value to be \c LLDB_GENERIC_ERROR and update the - /// type to be \c Status::Generic. + /// Update the error value to be \c LLDB_GENERIC_ERROR and update the type + /// to be \c Status::Generic. //------------------------------------------------------------------ void SetErrorToGenericError(); //------------------------------------------------------------------ /// Set the current error string to \a err_str. /// - /// Set accessor for the error string value for a generic errors, - /// or to supply additional details above and beyond the standard - /// error strings that the standard type callbacks typically - /// provide. This allows custom strings to be supplied as an - /// error explanation. The error string value will remain until the - /// error value is cleared or a new error value/type is assigned. + /// Set accessor for the error string value for a generic errors, or to + /// supply additional details above and beyond the standard error strings + /// that the standard type callbacks typically provide. This allows custom + /// strings to be supplied as an error explanation. The error string value + /// will remain until the error value is cleared or a new error value/type + /// is assigned. /// /// @param err_str /// The new custom error string to copy and cache. @@ -224,8 +220,8 @@ public: //------------------------------------------------------------------ /// Test for success condition. /// - /// Returns true if the error code in this object is considered a - /// successful return value. + /// Returns true if the error code in this object is considered a successful + /// return value. /// /// @return /// \b true if this object contains an value that describes @@ -236,8 +232,8 @@ public: //------------------------------------------------------------------ /// Test for a failure due to a generic interrupt. /// - /// Returns true if the error code in this object was caused by an interrupt. - /// At present only supports Posix EINTR. + /// Returns true if the error code in this object was caused by an + /// interrupt. At present only supports Posix EINTR. /// /// @return /// \b true if this object contains an value that describes diff --git a/include/lldb/Utility/Stream.h b/include/lldb/Utility/Stream.h index 5a00f0a50ca36..bf837749fa37a 100644 --- a/include/lldb/Utility/Stream.h +++ b/include/lldb/Utility/Stream.h @@ -25,7 +25,7 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class Stream Stream.h "lldb/Utility/Stream.h" -/// @brief A stream class that can stream formatted output to a file. +/// A stream class that can stream formatted output to a file. //---------------------------------------------------------------------- class Stream { public: @@ -40,15 +40,14 @@ public: //------------------------------------------------------------------ /// Construct with flags and address size and byte order. /// - /// Construct with dump flags \a flags and the default address - /// size. \a flags can be any of the above enumeration logical OR'ed - /// together. + /// Construct with dump flags \a flags and the default address size. \a + /// flags can be any of the above enumeration logical OR'ed together. //------------------------------------------------------------------ Stream(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order); //------------------------------------------------------------------ - /// Construct a default Stream, not binary, host byte order and - /// host addr size. + /// Construct a default Stream, not binary, host byte order and host addr + /// size. /// //------------------------------------------------------------------ Stream(); @@ -65,16 +64,15 @@ public: //------------------------------------------------------------------ /// Flush the stream. /// - /// Subclasses should flush the stream to make any output appear - /// if the stream has any buffering. + /// Subclasses should flush the stream to make any output appear if the + /// stream has any buffering. //------------------------------------------------------------------ virtual void Flush() = 0; //------------------------------------------------------------------ /// Output character bytes to the stream. /// - /// Appends \a src_len characters from the buffer \a src 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. @@ -95,8 +93,8 @@ public: //------------------------------------------------------------------ /// Set the byte_order value. /// - /// Sets the byte order of the data to extract. Extracted values - /// will be swapped if necessary when decoding. + /// Sets the byte order of the data to extract. Extracted values will be + /// swapped if necessary when decoding. /// /// @param[in] byte_order /// The byte order value to use when extracting data. @@ -107,9 +105,8 @@ public: lldb::ByteOrder SetByteOrder(lldb::ByteOrder byte_order); //------------------------------------------------------------------ - /// Format a C string from a printf style format and variable - /// arguments and encode and append the resulting C string as hex - /// bytes. + /// Format a C string from a printf style format and variable arguments and + /// encode and append the resulting C string as hex bytes. /// /// @param[in] format /// A printf style format string. @@ -124,9 +121,8 @@ 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. + /// Format a C string from a printf style format and variable arguments and + /// encode and append the resulting C string as hex bytes. /// /// @param[in] format /// A printf style format string. @@ -163,8 +159,8 @@ public: size_t PutPointer(void *ptr); - // Append \a src_len bytes from \a src to the stream as hex characters - // (two ascii characters per byte of input data) + // Append \a src_len bytes from \a src to the stream as hex characters (two + // ascii characters per byte of input data) size_t PutBytesAsRawHex8(const void *src, size_t src_len, lldb::ByteOrder src_byte_order = lldb::eByteOrderInvalid, @@ -314,8 +310,8 @@ public: //------------------------------------------------------------------ /// Output an address value to this stream. /// - /// Put an address \a addr out to the stream with optional \a prefix - /// and \a suffix strings. + /// Put an address \a addr out to the stream with optional \a prefix and \a + /// suffix strings. /// /// @param[in] addr /// An address value. @@ -335,8 +331,8 @@ public: //------------------------------------------------------------------ /// Output an address range to this stream. /// - /// Put an address range \a lo_addr - \a hi_addr out to the stream - /// with optional \a prefix and \a suffix strings. + /// Put an address range \a lo_addr - \a hi_addr out to the stream with + /// optional \a prefix and \a suffix strings. /// /// @param[in] lo_addr /// The start address of the address range. @@ -415,8 +411,8 @@ public: //------------------------------------------------------------------ /// Indent the current line in the stream. /// - /// Indent the current line using the current indentation level and - /// print an optional string following the indentation spaces. + /// Indent the current line using the current indentation level and print an + /// optional string following the indentation spaces. /// /// @param[in] s /// A C string to print following the indentation. If nullptr, just @@ -438,8 +434,8 @@ public: //------------------------------------------------------------------ /// Output an offset value. /// - /// Put an offset \a uval out to the stream using the printf format - /// in \a format. + /// Put an offset \a uval out to the stream using the printf format in \a + /// format. /// /// @param[in] offset /// The offset value. @@ -472,8 +468,8 @@ public: //------------------------------------------------------------------ /// Output a quoted C string value to the stream. /// - /// Print a double quoted NULL terminated C string to the stream - /// using the printf format in \a format. + /// Print a double quoted NULL terminated C string to the stream using the + /// printf format in \a format. /// /// @param[in] cstr /// A NULL terminated C string value. @@ -503,8 +499,8 @@ public: //------------------------------------------------------------------ /// Output a SLEB128 number to the stream. /// - /// Put an SLEB128 \a uval out to the stream using the printf format - /// in \a format. + /// Put an SLEB128 \a uval out to the stream using the printf format in \a + /// format. /// /// @param[in] uval /// A uint64_t value that was extracted as a SLEB128 value. @@ -517,8 +513,8 @@ public: //------------------------------------------------------------------ /// Output a ULEB128 number to the stream. /// - /// Put an ULEB128 \a uval out to the stream using the printf format - /// in \a format. + /// Put an ULEB128 \a uval out to the stream using the printf format in \a + /// format. /// /// @param[in] uval /// A uint64_t value that was extracted as a ULEB128 value. diff --git a/include/lldb/Utility/StreamTee.h b/include/lldb/Utility/StreamTee.h index 676178a0fe75e..569ba19799788 100644 --- a/include/lldb/Utility/StreamTee.h +++ b/include/lldb/Utility/StreamTee.h @@ -61,10 +61,9 @@ public: std::lock_guard<std::recursive_mutex> guard(m_streams_mutex); 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. + // 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) strm->Flush(); @@ -79,10 +78,9 @@ public: 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. + // 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); @@ -121,10 +119,9 @@ public: void SetStreamAtIndex(uint32_t idx, const lldb::StreamSP &stream_sp) { std::lock_guard<std::recursive_mutex> guard(m_streams_mutex); - // Resize our stream vector as necessary to fit as many streams - // as needed. This also allows this class to be used with hard - // coded indexes that can be used contain many streams, not all - // of which are valid. + // Resize our stream vector as necessary to fit as many streams as needed. + // This also allows this class to be used with hard coded indexes that can + // be used contain many streams, not all of which are valid. if (idx >= m_streams.size()) m_streams.resize(idx + 1); m_streams[idx] = stream_sp; diff --git a/include/lldb/Utility/StringExtractor.h b/include/lldb/Utility/StringExtractor.h index 311cec87e695f..4b75d5c5484d3 100644 --- a/include/lldb/Utility/StringExtractor.h +++ b/include/lldb/Utility/StringExtractor.h @@ -41,8 +41,8 @@ public: m_index = 0; } - // Returns true if the file position is still valid for the data - // contained in this string extractor object. + // Returns true if the file position is still valid for the data contained in + // this string extractor object. bool IsGood() const { return m_index != UINT64_MAX; } uint64_t GetFilePos() const { return m_index; } @@ -129,9 +129,9 @@ protected: //------------------------------------------------------------------ std::string m_packet; // The string in which to extract data. uint64_t m_index; // When extracting data from a packet, this index - // will march along as things get extracted. If set - // to UINT64_MAX the end of the packet data was - // reached when decoding information + // will march along as things get extracted. If set to + // UINT64_MAX the end of the packet data was reached + // when decoding information }; #endif // utility_StringExtractor_h_ diff --git a/include/lldb/Utility/StringExtractorGDBRemote.h b/include/lldb/Utility/StringExtractorGDBRemote.h new file mode 100644 index 0000000000000..93e760b881127 --- /dev/null +++ b/include/lldb/Utility/StringExtractorGDBRemote.h @@ -0,0 +1,204 @@ +//===-- StringExtractorGDBRemote.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_STRINGEXTRACTORGDBREMOTE_H +#define LLDB_UTILITY_STRINGEXTRACTORGDBREMOTE_H + +#include "lldb/Utility/Status.h" +#include "lldb/Utility/StringExtractor.h" +#include "llvm/ADT/StringRef.h" // for StringRef + +#include <string> + +#include <stddef.h> // for size_t +#include <stdint.h> // for uint8_t + +class StringExtractorGDBRemote : public StringExtractor { +public: + typedef bool (*ResponseValidatorCallback)( + void *baton, const StringExtractorGDBRemote &response); + + StringExtractorGDBRemote() : StringExtractor(), m_validator(nullptr) {} + + StringExtractorGDBRemote(llvm::StringRef str) + : StringExtractor(str), m_validator(nullptr) {} + + StringExtractorGDBRemote(const char *cstr) + : StringExtractor(cstr), m_validator(nullptr) {} + + StringExtractorGDBRemote(const StringExtractorGDBRemote &rhs) + : StringExtractor(rhs), m_validator(rhs.m_validator) {} + + virtual ~StringExtractorGDBRemote() {} + + bool ValidateResponse() const; + + void CopyResponseValidator(const StringExtractorGDBRemote &rhs); + + void SetResponseValidator(ResponseValidatorCallback callback, void *baton); + + void SetResponseValidatorToOKErrorNotSupported(); + + void SetResponseValidatorToASCIIHexBytes(); + + void SetResponseValidatorToJSON(); + + enum ServerPacketType { + eServerPacketType_nack = 0, + eServerPacketType_ack, + eServerPacketType_invalid, + eServerPacketType_unimplemented, + eServerPacketType_interrupt, // CTRL+c packet or "\x03" + eServerPacketType_A, // Program arguments packet + eServerPacketType_qfProcessInfo, + eServerPacketType_qsProcessInfo, + eServerPacketType_qC, + eServerPacketType_qEcho, + eServerPacketType_qGroupName, + eServerPacketType_qHostInfo, + eServerPacketType_qLaunchGDBServer, + eServerPacketType_qQueryGDBServer, + eServerPacketType_qKillSpawnedProcess, + eServerPacketType_qLaunchSuccess, + eServerPacketType_qModuleInfo, + eServerPacketType_qProcessInfoPID, + eServerPacketType_qSpeedTest, + eServerPacketType_qUserName, + eServerPacketType_qGetWorkingDir, + eServerPacketType_qFileLoadAddress, + eServerPacketType_QEnvironment, + eServerPacketType_QEnableErrorStrings, + eServerPacketType_QLaunchArch, + eServerPacketType_QSetDisableASLR, + eServerPacketType_QSetDetachOnError, + eServerPacketType_QSetSTDIN, + eServerPacketType_QSetSTDOUT, + eServerPacketType_QSetSTDERR, + eServerPacketType_QSetWorkingDir, + eServerPacketType_QStartNoAckMode, + eServerPacketType_qPlatform_shell, + eServerPacketType_qPlatform_mkdir, + eServerPacketType_qPlatform_chmod, + eServerPacketType_vFile_open, + eServerPacketType_vFile_close, + eServerPacketType_vFile_pread, + eServerPacketType_vFile_pwrite, + eServerPacketType_vFile_size, + eServerPacketType_vFile_mode, + eServerPacketType_vFile_exists, + eServerPacketType_vFile_md5, + eServerPacketType_vFile_stat, + eServerPacketType_vFile_symlink, + eServerPacketType_vFile_unlink, + // debug server packages + eServerPacketType_QEnvironmentHexEncoded, + eServerPacketType_QListThreadsInStopReply, + eServerPacketType_QPassSignals, + eServerPacketType_QRestoreRegisterState, + eServerPacketType_QSaveRegisterState, + eServerPacketType_QSetLogging, + eServerPacketType_QSetMaxPacketSize, + eServerPacketType_QSetMaxPayloadSize, + eServerPacketType_QSetEnableAsyncProfiling, + eServerPacketType_QSyncThreadState, + eServerPacketType_QThreadSuffixSupported, + + eServerPacketType_jThreadsInfo, + eServerPacketType_qsThreadInfo, + eServerPacketType_qfThreadInfo, + eServerPacketType_qGetPid, + eServerPacketType_qGetProfileData, + eServerPacketType_qGDBServerVersion, + eServerPacketType_qMemoryRegionInfo, + eServerPacketType_qMemoryRegionInfoSupported, + eServerPacketType_qProcessInfo, + eServerPacketType_qRcmd, + eServerPacketType_qRegisterInfo, + eServerPacketType_qShlibInfoAddr, + eServerPacketType_qStepPacketSupported, + eServerPacketType_qSupported, + eServerPacketType_qSyncThreadStateSupported, + eServerPacketType_qThreadExtraInfo, + eServerPacketType_qThreadStopInfo, + eServerPacketType_qVAttachOrWaitSupported, + eServerPacketType_qWatchpointSupportInfo, + eServerPacketType_qWatchpointSupportInfoSupported, + eServerPacketType_qXfer_auxv_read, + + eServerPacketType_jSignalsInfo, + eServerPacketType_jModulesInfo, + + eServerPacketType_vAttach, + eServerPacketType_vAttachWait, + eServerPacketType_vAttachOrWait, + eServerPacketType_vAttachName, + eServerPacketType_vCont, + eServerPacketType_vCont_actions, // vCont? + + eServerPacketType_stop_reason, // '?' + + eServerPacketType_c, + eServerPacketType_C, + eServerPacketType_D, + eServerPacketType_g, + eServerPacketType_G, + eServerPacketType_H, + eServerPacketType_I, // stdin notification + eServerPacketType_k, + eServerPacketType_m, + eServerPacketType_M, + eServerPacketType_p, + eServerPacketType_P, + eServerPacketType_s, + eServerPacketType_S, + eServerPacketType_T, + eServerPacketType_x, + eServerPacketType_X, + eServerPacketType_Z, + eServerPacketType_z, + + eServerPacketType__M, + eServerPacketType__m, + eServerPacketType_notify, // '%' notification + + eServerPacketType_jTraceStart, + eServerPacketType_jTraceBufferRead, + eServerPacketType_jTraceMetaRead, + eServerPacketType_jTraceStop, + eServerPacketType_jTraceConfigRead, + }; + + ServerPacketType GetServerPacketType() const; + + enum ResponseType { eUnsupported = 0, eAck, eNack, eError, eOK, eResponse }; + + ResponseType GetResponseType() const; + + bool IsOKResponse() const; + + bool IsUnsupportedResponse() const; + + bool IsNormalResponse() const; + + bool IsErrorResponse() const; + + // Returns zero if the packet isn't a EXX packet where XX are two hex digits. + // Otherwise the error encoded in XX is returned. + uint8_t GetError(); + + lldb_private::Status GetStatus(); + + size_t GetEscapedBinaryData(std::string &str); + +protected: + ResponseValidatorCallback m_validator; + void *m_validator_baton; +}; + +#endif // LLDB_UTILITY_STRINGEXTRACTORGDBREMOTE_H diff --git a/include/lldb/Utility/StringList.h b/include/lldb/Utility/StringList.h index 6553e5dfdfb97..1cb68885e771c 100644 --- a/include/lldb/Utility/StringList.h +++ b/include/lldb/Utility/StringList.h @@ -100,20 +100,17 @@ public: // Copy assignment for a vector of strings StringList &operator=(const std::vector<std::string> &rhs); - // This string list contains a list of valid auto completion - // strings, and the "s" is passed in. "matches" is filled in - // with zero or more string values that start with "s", and - // the first string to exactly match one of the string - // values in this collection, will have "exact_matches_idx" - // filled in to match the index, or "exact_matches_idx" will - // have SIZE_MAX + // This string list contains a list of valid auto completion strings, and the + // "s" is passed in. "matches" is filled in with zero or more string values + // that start with "s", and the first string to exactly match one of the + // string values in this collection, will have "exact_matches_idx" filled in + // to match the index, or "exact_matches_idx" will have SIZE_MAX size_t AutoComplete(llvm::StringRef s, StringList &matches, size_t &exact_matches_idx) const; // Dump the StringList to the given lldb_private::Log, `log`, one item per - // line. - // If given, `name` will be used to identify the start and end of the list in - // the output. + // line. If given, `name` will be used to identify the start and end of the + // list in the output. virtual void LogDump(Log *log, const char *name = nullptr); // Static helper to convert an iterable of strings to a StringList, and then diff --git a/include/lldb/Utility/StructuredData.h b/include/lldb/Utility/StructuredData.h index 2ea5fb98e0555..d3ebab16f51d9 100644 --- a/include/lldb/Utility/StructuredData.h +++ b/include/lldb/Utility/StructuredData.h @@ -38,17 +38,17 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class StructuredData StructuredData.h "lldb/Utility/StructuredData.h" -/// @brief A class which can hold structured data +/// A class which can hold structured data /// -/// The StructuredData class is designed to hold the data from a JSON -/// or plist style file -- a serialized data structure with dictionaries -/// (maps, hashes), arrays, and concrete values like integers, floating -/// point numbers, strings, booleans. +/// The StructuredData class is designed to hold the data from a JSON or plist +/// style file -- a serialized data structure with dictionaries (maps, +/// hashes), arrays, and concrete values like integers, floating point +/// numbers, strings, booleans. /// -/// StructuredData does not presuppose any knowledge of the schema for -/// the data it is holding; it can parse JSON data, for instance, and -/// other parts of lldb can iterate through the parsed data set to find -/// keys and values that may be present. +/// StructuredData does not presuppose any knowledge of the schema for the +/// data it is holding; it can parse JSON data, for instance, and other parts +/// of lldb can iterate through the parsed data set to find keys and values +/// that may be present. //---------------------------------------------------------------------- class StructuredData { diff --git a/include/lldb/Utility/TildeExpressionResolver.h b/include/lldb/Utility/TildeExpressionResolver.h index 84620320c7aca..ae6b4073f6aa6 100644 --- a/include/lldb/Utility/TildeExpressionResolver.h +++ b/include/lldb/Utility/TildeExpressionResolver.h @@ -22,7 +22,7 @@ class TildeExpressionResolver { public: virtual ~TildeExpressionResolver(); - /// \brief Resolve a Tilde Expression contained according to bash rules. + /// Resolve a Tilde Expression contained according to bash rules. /// /// \param Expr Contains the tilde expression to resolve. A valid tilde /// expression must begin with a tilde and contain only non @@ -35,7 +35,7 @@ public: virtual bool ResolveExact(llvm::StringRef Expr, llvm::SmallVectorImpl<char> &Output) = 0; - /// \brief Auto-complete a tilde expression with all matching values. + /// Auto-complete a tilde expression with all matching values. /// /// \param Expr Contains the tilde expression prefix to resolve. See /// ResolveExact() for validity rules. @@ -48,8 +48,8 @@ public: virtual bool ResolvePartial(llvm::StringRef Expr, llvm::StringSet<> &Output) = 0; - /// \brief Resolve an entire path that begins with a tilde expression, - /// replacing the username portion with the matched result. + /// Resolve an entire path that begins with a tilde expression, replacing + /// the username portion with the matched result. bool ResolveFullPath(llvm::StringRef Expr, llvm::SmallVectorImpl<char> &Output); }; diff --git a/include/lldb/Utility/Timeout.h b/include/lldb/Utility/Timeout.h index 7b627a45fc639..ecb33b346e96a 100644 --- a/include/lldb/Utility/Timeout.h +++ b/include/lldb/Utility/Timeout.h @@ -22,9 +22,9 @@ namespace lldb_private { // from Timeout<std::milli> to Timeout<std::micro>. // // The intended meaning of the values is: -// - llvm::None - no timeout, the call should wait forever -// - 0 - poll, only complete the call if it will not block -// - >0 - wait for a given number of units for the result +// - llvm::None - no timeout, the call should wait forever - 0 - poll, only +// complete the call if it will not block - >0 - wait for a given number of +// units for the result template <typename Ratio> class Timeout : public llvm::Optional<std::chrono::duration<int64_t, Ratio>> { private: diff --git a/include/lldb/Utility/Timer.h b/include/lldb/Utility/Timer.h index c06ac17d344de..2c1e984837c28 100644 --- a/include/lldb/Utility/Timer.h +++ b/include/lldb/Utility/Timer.h @@ -20,7 +20,7 @@ class Stream; //---------------------------------------------------------------------- /// @class Timer Timer.h "lldb/Utility/Timer.h" -/// @brief A timer class that simplifies common timing metrics. +/// A timer class that simplifies common timing metrics. //---------------------------------------------------------------------- class Timer { diff --git a/include/lldb/Utility/UUID.h b/include/lldb/Utility/UUID.h index 5e64e90797893..d42c88862bfaf 100644 --- a/include/lldb/Utility/UUID.h +++ b/include/lldb/Utility/UUID.h @@ -15,6 +15,7 @@ #include <stddef.h> #include <stdint.h> #include <string> +#include "llvm/ADT/ArrayRef.h" namespace llvm { class StringRef; @@ -26,36 +27,49 @@ namespace lldb_private { class UUID { public: - // Most UUIDs are 16 bytes, but some Linux build-ids (SHA1) are 20. - typedef uint8_t ValueType[20]; + UUID() = default; - //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ - UUID(); - UUID(const UUID &rhs); - UUID(const void *uuid_bytes, uint32_t num_uuid_bytes); + /// Creates a UUID from the data pointed to by the bytes argument. No special + /// significance is attached to any of the values. + static UUID fromData(const void *bytes, uint32_t num_bytes) { + if (bytes) + return fromData({reinterpret_cast<const uint8_t *>(bytes), num_bytes}); + return UUID(); + } - ~UUID(); + /// Creates a uuid from the data pointed to by the bytes argument. No special + /// significance is attached to any of the values. + static UUID fromData(llvm::ArrayRef<uint8_t> bytes) { return UUID(bytes); } - const UUID &operator=(const UUID &rhs); + /// Creates a UUID from the data pointed to by the bytes argument. Data + /// consisting purely of zero bytes is treated as an invalid UUID. + static UUID fromOptionalData(const void *bytes, uint32_t num_bytes) { + if (bytes) + return fromOptionalData( + {reinterpret_cast<const uint8_t *>(bytes), num_bytes}); + return UUID(); + } - void Clear(); + /// Creates a UUID from the data pointed to by the bytes argument. Data + /// consisting purely of zero bytes is treated as an invalid UUID. + static UUID fromOptionalData(llvm::ArrayRef<uint8_t> bytes) { + if (llvm::all_of(bytes, [](uint8_t b) { return b == 0; })) + return UUID(); + return UUID(bytes); + } - void Dump(Stream *s) const; + void Clear() { m_bytes.clear(); } - const void *GetBytes() const; - - size_t GetByteSize() const; + void Dump(Stream *s) const; - bool IsValid() const; + llvm::ArrayRef<uint8_t> GetBytes() const { return m_bytes; } - bool SetBytes(const void *uuid_bytes, uint32_t num_uuid_bytes = 16); + explicit operator bool() const { return IsValid(); } + bool IsValid() const { return !m_bytes.empty(); } - std::string GetAsString(const char *separator = nullptr) const; + std::string GetAsString(llvm::StringRef separator = "-") const; size_t SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes = 16); - size_t SetFromCString(const char *c_str, uint32_t num_uuid_bytes = 16); // Decode as many UUID bytes (up to 16) as possible from the C string "cstr" // This is used for auto completion where a partial UUID might have been @@ -77,25 +91,34 @@ public: /// The original string, with all decoded bytes removed. //------------------------------------------------------------------ static llvm::StringRef - DecodeUUIDBytesFromString(llvm::StringRef str, ValueType &uuid_bytes, - uint32_t &bytes_decoded, + DecodeUUIDBytesFromString(llvm::StringRef str, + llvm::SmallVectorImpl<uint8_t> &uuid_bytes, uint32_t num_uuid_bytes = 16); -protected: - //------------------------------------------------------------------ - // Classes that inherit from UUID can see and modify these - //------------------------------------------------------------------ - uint32_t m_num_uuid_bytes; // Should be 16 or 20 - ValueType m_uuid; -}; +private: + UUID(llvm::ArrayRef<uint8_t> bytes) : m_bytes(bytes.begin(), bytes.end()) {} -bool operator==(const UUID &lhs, const UUID &rhs); -bool operator!=(const UUID &lhs, const UUID &rhs); -bool operator<(const UUID &lhs, const UUID &rhs); -bool operator<=(const UUID &lhs, const UUID &rhs); -bool operator>(const UUID &lhs, const UUID &rhs); -bool operator>=(const UUID &lhs, const UUID &rhs); + // GNU ld generates 20-byte build-ids. Size chosen to avoid heap allocations + // for this case. + llvm::SmallVector<uint8_t, 20> m_bytes; + friend bool operator==(const UUID &LHS, const UUID &RHS) { + return LHS.m_bytes == RHS.m_bytes; + } + friend bool operator!=(const UUID &LHS, const UUID &RHS) { + return !(LHS == RHS); + } + friend bool operator<(const UUID &LHS, const UUID &RHS) { + return LHS.m_bytes < RHS.m_bytes; + } + friend bool operator<=(const UUID &LHS, const UUID &RHS) { + return !(RHS < LHS); + } + friend bool operator>(const UUID &LHS, const UUID &RHS) { return RHS < LHS; } + friend bool operator>=(const UUID &LHS, const UUID &RHS) { + return !(LHS < RHS); + } +}; } // namespace lldb_private #endif // LLDB_UTILITY_UUID_H diff --git a/include/lldb/Utility/UserID.h b/include/lldb/Utility/UserID.h index b178efd44fe4e..9e15e6a43c6cf 100644 --- a/include/lldb/Utility/UserID.h +++ b/include/lldb/Utility/UserID.h @@ -20,14 +20,14 @@ namespace lldb_private { //---------------------------------------------------------------------- /// @class UserID UserID.h "lldb/Core/UserID.h" -/// @brief A mix in class that contains a generic user ID. +/// A mix in class that contains a generic user ID. /// -/// UserID is designed as a mix in class that can contain an integer -/// based unique identifier for a variety of objects in lldb. +/// UserID is designed as a mix in class that can contain an integer based +/// unique identifier for a variety of objects in lldb. /// -/// The value for this identifier is chosen by each parser plug-in. A -/// value should be chosen that makes sense for each kind of object -/// and should allow quick access to further and more in depth parsing. +/// The value for this identifier is chosen by each parser plug-in. A value +/// should be chosen that makes sense for each kind of object and should allow +/// quick access to further and more in depth parsing. /// /// Symbol table entries can use this to store the original symbol table /// index, functions can use it to store the symbol table index or the @@ -68,11 +68,9 @@ struct UserID { void SetID(lldb::user_id_t uid) { m_uid = uid; } //------------------------------------------------------------------ - /// Unary predicate function object that can search for a matching - /// user ID. + /// Unary predicate function object that can search for a matching user ID. /// - /// Function object that can be used on any class that inherits - /// from UserID: + /// Function object that can be used on any class that inherits from UserID: /// \code /// iterator pos; /// pos = std::find_if (coll.begin(), coll.end(), UserID::IDMatches(blockID)); diff --git a/include/lldb/lldb-defines.h b/include/lldb/lldb-defines.h index a1318f4412e9c..edb70be09fd95 100644 --- a/include/lldb/lldb-defines.h +++ b/include/lldb/lldb-defines.h @@ -12,7 +12,7 @@ #include "lldb/lldb-types.h" -#if defined(_MSC_VER) +#if defined(_WIN32) #if defined(EXPORT_LIBLLDB) #define LLDB_API __declspec(dllexport) #elif defined(IMPORT_LIBLLDB) @@ -20,7 +20,7 @@ #else #define LLDB_API #endif -#else // defined (_MSC_VER) +#else // defined (_WIN32) #define LLDB_API #endif diff --git a/include/lldb/lldb-enumerations.h b/include/lldb/lldb-enumerations.h index 760e12b0e799d..a1f7303795349 100644 --- a/include/lldb/lldb-enumerations.h +++ b/include/lldb/lldb-enumerations.h @@ -21,8 +21,8 @@ // warning, as it's part of -Wmicrosoft which also catches a whole slew of // other useful issues. // -// To make matters worse, early versions of SWIG don't recognize the syntax -// of specifying the underlying type of an enum (and Python doesn't care anyway) +// To make matters worse, early versions of SWIG don't recognize the syntax of +// specifying the underlying type of an enum (and Python doesn't care anyway) // so we need a way to specify the underlying type when the enum is being used // from C++ code, but just use a regular enum when swig is pre-processing. #define FLAGS_ENUM(Name) enum Name : unsigned @@ -44,6 +44,9 @@ enum StateType { ///launched or attached to anything yet eStateAttaching, ///< Process is currently trying to attach eStateLaunching, ///< Process is in the process of launching + // The state changes eStateAttaching and eStateLaunching are both sent while the + // private state thread is either not yet started or paused. For that reason, they + // should only be signaled as public state changes, and not private state changes. eStateStopped, ///< Process or thread is stopped and can be examined. eStateRunning, ///< Process or thread is running and can't be examined. eStateStepping, ///< Process or thread is in the process of stepping and can @@ -193,9 +196,8 @@ enum ScriptLanguage { //---------------------------------------------------------------------- // Register numbering types -// See RegisterContext::ConvertRegisterKindToRegisterNumber to convert -// any of these to the lldb internal register numbering scheme -// (eRegisterKindLLDB). +// See RegisterContext::ConvertRegisterKindToRegisterNumber to convert any of +// these to the lldb internal register numbering scheme (eRegisterKindLLDB). //---------------------------------------------------------------------- enum RegisterKind { eRegisterKindEHFrame = 0, // the register numbers seen in eh_frame @@ -445,8 +447,8 @@ enum LanguageType { // Vendor Extensions // Note: Language::GetNameForLanguageType // assumes these can be used as indexes into array language_names, and - // Language::SetLanguageFromCString and Language::AsCString - // assume these can be used as indexes into array g_languages. + // Language::SetLanguageFromCString and Language::AsCString assume these can + // be used as indexes into array g_languages. eLanguageTypeMipsAssembler = 0x0024, ///< Mips_Assembler. eLanguageTypeExtRenderScript = 0x0025, ///< RenderScript. eNumLanguageTypes @@ -624,7 +626,7 @@ enum SectionType { eSectionTypeDebug, eSectionTypeZeroFill, eSectionTypeDataObjCMessageRefs, // Pointer to function pointer + selector - eSectionTypeDataObjCCFStrings, // Objective C const CFString/NSString objects + eSectionTypeDataObjCCFStrings, // Objective-C const CFString/NSString objects eSectionTypeDWARFDebugAbbrev, eSectionTypeDWARFDebugAddr, eSectionTypeDWARFDebugAranges, @@ -656,6 +658,9 @@ enum SectionType { eSectionTypeGoSymtab, eSectionTypeAbsoluteAddress, // Dummy section for symbols with absolute // address + eSectionTypeDWARFGNUDebugAltLink, + eSectionTypeDWARFDebugTypes, // DWARF .debug_types section + eSectionTypeDWARFDebugNames, // DWARF v5 .debug_names eSectionTypeOther }; @@ -670,10 +675,10 @@ FLAGS_ENUM(FunctionNameType){ (1u << 1), // Automatically figure out which FunctionNameType // bits to set based on the function name. eFunctionNameTypeFull = (1u << 2), // The function name. - // For C this is the same as just the name of the function - // For C++ this is the mangled or demangled version of the mangled name. - // For ObjC this is the full function signature with the + or - // - and the square brackets and the class and selector + // For C this is the same as just the name of the function For C++ this is + // the mangled or demangled version of the mangled name. For ObjC this is + // the full function signature with the + or - and the square brackets and + // the class and selector eFunctionNameTypeBase = (1u << 3), // The function name only, no namespaces // or arguments and no class // methods or selectors will be searched. @@ -772,8 +777,8 @@ enum TemplateArgumentKind { }; //---------------------------------------------------------------------- -// Options that can be set for a formatter to alter its behavior -// Not all of these are applicable to all formatter types +// Options that can be set for a formatter to alter its behavior Not all of +// these are applicable to all formatter types //---------------------------------------------------------------------- FLAGS_ENUM(TypeOptions){eTypeOptionNone = (0u), eTypeOptionCascade = (1u << 0), @@ -784,23 +789,22 @@ FLAGS_ENUM(TypeOptions){eTypeOptionNone = (0u), eTypeOptionShowOneLiner = (1u << 5), eTypeOptionHideNames = (1u << 6), eTypeOptionNonCacheable = (1u << 7), - eTypeOptionHideEmptyAggregates = (1u << 8)}; + eTypeOptionHideEmptyAggregates = (1u << 8), + eTypeOptionFrontEndWantsDereference = (1u << 9) +}; //---------------------------------------------------------------------- -// This is the return value for frame comparisons. If you are comparing frame A -// to frame B -// the following cases arise: -// 1) When frame A pushes frame B (or a frame that ends up pushing B) A is Older -// than B. -// 2) When frame A pushed frame B (or if frame A is on the stack but B is not) A -// is Younger than B -// 3) When frame A and frame B have the same StackID, they are Equal. -// 4) When frame A and frame B have the same immediate parent frame, but are not -// equal, the comparison yields +// This is the return value for frame comparisons. If you are comparing frame +// A to frame B the following cases arise: 1) When frame A pushes frame B (or a +// frame that ends up pushing B) A is Older than B. 2) When frame A pushed +// frame B (or if frame A is on the stack but B is not) A is Younger than B 3) +// When frame A and frame B have the same StackID, they are Equal. 4) When +// frame A and frame B have the same immediate parent frame, but are not equal, +// the comparison yields // SameParent. // 5) If the two frames are on different threads or processes the comparison is -// Invalid -// 6) If for some reason we can't figure out what went on, we return Unknown. +// Invalid 6) If for some reason we can't figure out what went on, we return +// Unknown. //---------------------------------------------------------------------- enum FrameComparison { eFrameCompareInvalid, @@ -812,31 +816,10 @@ enum FrameComparison { }; //---------------------------------------------------------------------- -// Address Class -// -// A way of classifying an address used for disassembling and setting -// breakpoints. Many object files can track exactly what parts of their -// object files are code, data and other information. This is of course -// above and beyond just looking at the section types. For example, code -// might contain PC relative data and the object file might be able to -// tell us that an address in code is data. -//---------------------------------------------------------------------- -enum AddressClass { - eAddressClassInvalid, - eAddressClassUnknown, - eAddressClassCode, - eAddressClassCodeAlternateISA, - eAddressClassData, - eAddressClassDebug, - eAddressClassRuntime -}; - -//---------------------------------------------------------------------- // File Permissions // -// Designed to mimic the unix file permission bits so they can be -// used with functions that set 'mode_t' to certain values for -// permissions. +// Designed to mimic the unix file permission bits so they can be used with +// functions that set 'mode_t' to certain values for permissions. //---------------------------------------------------------------------- FLAGS_ENUM(FilePermissions){ eFilePermissionsUserRead = (1u << 8), eFilePermissionsUserWrite = (1u << 7), @@ -896,8 +879,8 @@ FLAGS_ENUM(FilePermissions){ //---------------------------------------------------------------------- // Queue work item types // -// The different types of work that can be enqueued on a libdispatch -// aka Grand Central Dispatch (GCD) queue. +// The different types of work that can be enqueued on a libdispatch aka Grand +// Central Dispatch (GCD) queue. //---------------------------------------------------------------------- enum QueueItemKind { eQueueItemKindUnknown = 0, @@ -931,8 +914,8 @@ enum ExpressionEvaluationPhase { //---------------------------------------------------------------------- // Watchpoint Kind -// Indicates what types of events cause the watchpoint to fire. -// Used by Native*Protocol-related classes. +// Indicates what types of events cause the watchpoint to fire. Used by Native +// *Protocol-related classes. //---------------------------------------------------------------------- FLAGS_ENUM(WatchpointKind){eWatchpointKindWrite = (1u << 0), eWatchpointKindRead = (1u << 1)}; @@ -947,9 +930,9 @@ enum GdbSignal { }; //---------------------------------------------------------------------- -// Used with SBHost::GetPath (lldb::PathType) to find files that are -// related to LLDB on the current host machine. Most files are relative -// to LLDB or are in known locations. +// Used with SBHost::GetPath (lldb::PathType) to find files that are related to +// LLDB on the current host machine. Most files are relative to LLDB or are in +// known locations. //---------------------------------------------------------------------- enum PathType { ePathTypeLLDBShlibDir, // The directory where the lldb.so (unix) or LLDB @@ -1008,58 +991,54 @@ FLAGS_ENUM(CommandFlags){ //---------------------------------------------------------------------- // eCommandRequiresTarget // - // Ensures a valid target is contained in m_exe_ctx prior to executing - // the command. If a target doesn't exist or is invalid, the command - // will fail and CommandObject::GetInvalidTargetDescription() will be - // returned as the error. CommandObject subclasses can override the - // virtual function for GetInvalidTargetDescription() to provide custom - // strings when needed. + // Ensures a valid target is contained in m_exe_ctx prior to executing the + // command. If a target doesn't exist or is invalid, the command will fail + // and CommandObject::GetInvalidTargetDescription() will be returned as the + // error. CommandObject subclasses can override the virtual function for + // GetInvalidTargetDescription() to provide custom strings when needed. //---------------------------------------------------------------------- eCommandRequiresTarget = (1u << 0), //---------------------------------------------------------------------- // eCommandRequiresProcess // - // Ensures a valid process is contained in m_exe_ctx prior to executing - // the command. If a process doesn't exist or is invalid, the command - // will fail and CommandObject::GetInvalidProcessDescription() will be - // returned as the error. CommandObject subclasses can override the - // virtual function for GetInvalidProcessDescription() to provide custom - // strings when needed. + // Ensures a valid process is contained in m_exe_ctx prior to executing the + // command. If a process doesn't exist or is invalid, the command will fail + // and CommandObject::GetInvalidProcessDescription() will be returned as + // the error. CommandObject subclasses can override the virtual function + // for GetInvalidProcessDescription() to provide custom strings when + // needed. //---------------------------------------------------------------------- eCommandRequiresProcess = (1u << 1), //---------------------------------------------------------------------- // eCommandRequiresThread // - // Ensures a valid thread is contained in m_exe_ctx prior to executing - // the command. If a thread doesn't exist or is invalid, the command - // will fail and CommandObject::GetInvalidThreadDescription() will be - // returned as the error. CommandObject subclasses can override the - // virtual function for GetInvalidThreadDescription() to provide custom - // strings when needed. + // Ensures a valid thread is contained in m_exe_ctx prior to executing the + // command. If a thread doesn't exist or is invalid, the command will fail + // and CommandObject::GetInvalidThreadDescription() will be returned as the + // error. CommandObject subclasses can override the virtual function for + // GetInvalidThreadDescription() to provide custom strings when needed. //---------------------------------------------------------------------- eCommandRequiresThread = (1u << 2), //---------------------------------------------------------------------- // eCommandRequiresFrame // - // Ensures a valid frame is contained in m_exe_ctx prior to executing - // the command. If a frame doesn't exist or is invalid, the command - // will fail and CommandObject::GetInvalidFrameDescription() will be - // returned as the error. CommandObject subclasses can override the - // virtual function for GetInvalidFrameDescription() to provide custom - // strings when needed. + // Ensures a valid frame is contained in m_exe_ctx prior to executing the + // command. If a frame doesn't exist or is invalid, the command will fail + // and CommandObject::GetInvalidFrameDescription() will be returned as the + // error. CommandObject subclasses can override the virtual function for + // GetInvalidFrameDescription() to provide custom strings when needed. //---------------------------------------------------------------------- eCommandRequiresFrame = (1u << 3), //---------------------------------------------------------------------- // eCommandRequiresRegContext // - // Ensures a valid register context (from the selected frame if there - // is a frame in m_exe_ctx, or from the selected thread from m_exe_ctx) - // is available from m_exe_ctx prior to executing the command. If a - // target doesn't exist or is invalid, the command will fail and - // CommandObject::GetInvalidRegContextDescription() will be returned as - // the error. CommandObject subclasses can override the virtual function - // for GetInvalidRegContextDescription() to provide custom strings when - // needed. + // Ensures a valid register context (from the selected frame if there is a + // frame in m_exe_ctx, or from the selected thread from m_exe_ctx) is + // available from m_exe_ctx prior to executing the command. If a target + // doesn't exist or is invalid, the command will fail and + // CommandObject::GetInvalidRegContextDescription() will be returned as the + // error. CommandObject subclasses can override the virtual function for + // GetInvalidRegContextDescription() to provide custom strings when needed. //---------------------------------------------------------------------- eCommandRequiresRegContext = (1u << 4), //---------------------------------------------------------------------- @@ -1073,15 +1052,15 @@ FLAGS_ENUM(CommandFlags){ //---------------------------------------------------------------------- // eCommandProcessMustBeLaunched // - // Verifies that there is a launched process in m_exe_ctx, if there - // isn't, the command will fail with an appropriate error message. + // Verifies that there is a launched process in m_exe_ctx, if there isn't, + // the command will fail with an appropriate error message. //---------------------------------------------------------------------- eCommandProcessMustBeLaunched = (1u << 6), //---------------------------------------------------------------------- // eCommandProcessMustBePaused // - // Verifies that there is a paused process in m_exe_ctx, if there - // isn't, the command will fail with an appropriate error message. + // Verifies that there is a paused process in m_exe_ctx, if there isn't, + // the command will fail with an appropriate error message. //---------------------------------------------------------------------- eCommandProcessMustBePaused = (1u << 7)}; diff --git a/include/lldb/lldb-forward.h b/include/lldb/lldb-forward.h index a324edf9da3bc..e3964268dfda0 100644 --- a/include/lldb/lldb-forward.h +++ b/include/lldb/lldb-forward.h @@ -76,6 +76,7 @@ class ConnectionFileDescriptor; class ConstString; class CXXSyntheticChildren; class DWARFCallFrameInfo; +class DWARFDataExtractor; class DWARFExpression; class DataBuffer; class DataEncoder; diff --git a/include/lldb/lldb-private-defines.h b/include/lldb/lldb-private-defines.h index 22172366c259b..9b6594422e827 100644 --- a/include/lldb/lldb-private-defines.h +++ b/include/lldb/lldb-private-defines.h @@ -23,7 +23,7 @@ #endif /// \macro LLVM_FALLTHROUGH -/// \brief Marks an empty statement preceding a deliberate switch fallthrough. +/// Marks an empty statement preceding a deliberate switch fallthrough. #if __has_cpp_attribute(clang::fallthrough) #define LLVM_FALLTHROUGH [[clang::fallthrough]] #else diff --git a/include/lldb/lldb-private-enumerations.h b/include/lldb/lldb-private-enumerations.h index 983ddf3d23d60..c25f285c97133 100644 --- a/include/lldb/lldb-private-enumerations.h +++ b/include/lldb/lldb-private-enumerations.h @@ -43,6 +43,26 @@ typedef enum AddressType { } AddressType; //---------------------------------------------------------------------- +// Address Class +// +// A way of classifying an address used for disassembling and setting +// breakpoints. Many object files can track exactly what parts of their object +// files are code, data and other information. This is of course above and +// beyond just looking at the section types. For example, code might contain PC +// relative data and the object file might be able to tell us that an address +// in code is data. +//---------------------------------------------------------------------- +enum class AddressClass { + eInvalid, + eUnknown, + eCode, + eCodeAlternateISA, + eData, + eDebug, + eRuntime +}; + +//---------------------------------------------------------------------- // Votes - Need a tri-state, yes, no, no opinion... //---------------------------------------------------------------------- typedef enum Vote { eVoteNo = -1, eVoteNoOpinion = 0, eVoteYes = 1 } Vote; @@ -105,9 +125,9 @@ typedef enum SortOrder { } SortOrder; //---------------------------------------------------------------------- -// LazyBool is for boolean values that need to be calculated lazily. -// Values start off set to eLazyBoolCalculate, and then they can be -// calculated once and set to eLazyBoolNo or eLazyBoolYes. +// LazyBool is for boolean values that need to be calculated lazily. Values +// start off set to eLazyBoolCalculate, and then they can be calculated once +// and set to eLazyBoolNo or eLazyBoolYes. //---------------------------------------------------------------------- typedef enum LazyBool { eLazyBoolCalculate = -1, @@ -217,8 +237,7 @@ enum class LineStatus { enum class TypeValidatorResult : bool { Success = true, Failure = false }; //---------------------------------------------------------------------- -// Enumerations that can be used to specify scopes types when looking up -// types. +// Enumerations that can be used to specify scopes types when looking up types. //---------------------------------------------------------------------- enum class CompilerContextKind { Invalid = 0, @@ -234,6 +253,35 @@ enum class CompilerContextKind { Typedef }; +//---------------------------------------------------------------------- +// Enumerations that can be used to specify the kind of metric we're looking at +// when collecting stats. +//---------------------------------------------------------------------- +enum StatisticKind { + ExpressionSuccessful = 0, + ExpressionFailure = 1, + FrameVarSuccess = 2, + FrameVarFailure = 3, + StatisticMax = 4 +}; + + +inline std::string GetStatDescription(lldb_private::StatisticKind K) { + switch (K) { + case StatisticKind::ExpressionSuccessful: + return "Number of expr evaluation successes"; + case StatisticKind::ExpressionFailure: + return "Number of expr evaluation failures"; + case StatisticKind::FrameVarSuccess: + return "Number of frame var successes"; + case StatisticKind::FrameVarFailure: + return "Number of frame var failures"; + case StatisticKind::StatisticMax: + return ""; + } + llvm_unreachable("Statistic not registered!"); +} + } // namespace lldb_private namespace llvm { diff --git a/include/lldb/lldb-private-forward.h b/include/lldb/lldb-private-forward.h index ea122525ef906..65d3032811647 100644 --- a/include/lldb/lldb-private-forward.h +++ b/include/lldb/lldb-private-forward.h @@ -15,8 +15,8 @@ #include <memory> namespace lldb_private { -// --------------------------------------------------------------- -// Class forward decls. +// --------------------------------------------------------------- Class +// forward decls. // --------------------------------------------------------------- class NativeBreakpoint; class NativeBreakpointList; @@ -26,8 +26,7 @@ class NativeThreadProtocol; class ResumeActionList; class UnixSignals; -// --------------------------------------------------------------- -// SP/WP decls. +// --------------------------------------------------------------- SP/WP decls. // --------------------------------------------------------------- typedef std::shared_ptr<NativeBreakpoint> NativeBreakpointSP; } diff --git a/include/lldb/lldb-private-types.h b/include/lldb/lldb-private-types.h index fd21641218fb8..7ba7350e868c2 100644 --- a/include/lldb/lldb-private-types.h +++ b/include/lldb/lldb-private-types.h @@ -30,9 +30,8 @@ typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType)( const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Status &error); //---------------------------------------------------------------------- -// Every register is described in detail including its name, alternate -// name (optional), encoding, size in bytes and the default display -// format. +// Every register is described in detail including its name, alternate name +// (optional), encoding, size in bytes and the default display format. //---------------------------------------------------------------------- struct RegisterInfo { const char *name; // Name of this register, can't be NULL @@ -41,28 +40,29 @@ struct RegisterInfo { uint32_t byte_offset; // The byte offset in the register context data where // this register's value is found. // This is optional, and can be 0 if a particular RegisterContext does not - // need to - // address its registers by byte offset. + // need to address its registers by byte offset. lldb::Encoding encoding; // Encoding of the register bits lldb::Format format; // Default display format uint32_t kinds[lldb::kNumRegisterKinds]; // Holds all of the various register // numbers for all register kinds uint32_t *value_regs; // List of registers (terminated with - // LLDB_INVALID_REGNUM). If this value is not - // null, all registers in this list will be read first, at which point the - // value - // for this register will be valid. For example, the value list for ah - // would be eax (x86) or rax (x64). + // LLDB_INVALID_REGNUM). If this value is not null, + // all registers in this list will be read first, at + // which point the value for this register will be + // valid. For example, the value list for ah would be + // eax (x86) or rax (x64). uint32_t *invalidate_regs; // List of registers (terminated with // LLDB_INVALID_REGNUM). If this value is not - // null, all registers in this list will be invalidated when the value of this - // register changes. For example, the invalidate list for eax would be rax - // ax, ah, and al. + // null, all registers in this list will be + // invalidated when the value of this register + // changes. For example, the invalidate list for + // eax would be rax ax, ah, and al. const uint8_t *dynamic_size_dwarf_expr_bytes; // A DWARF expression that when // evaluated gives // the byte size of this register. size_t dynamic_size_dwarf_len; // The length of the DWARF expression in bytes - // in the dynamic_size_dwarf_expr_bytes member. + // in the dynamic_size_dwarf_expr_bytes + // member. llvm::ArrayRef<uint8_t> data(const uint8_t *context_base) const { return llvm::ArrayRef<uint8_t>(context_base + byte_offset, byte_size); @@ -85,8 +85,8 @@ struct RegisterSet { // values in this array are // *indices* (not register numbers) into a particular RegisterContext's // register array. For example, if eax is defined at index 4 for a - // particular RegisterContext, eax would be included in this RegisterSet - // by adding the value 4. Not by adding the value lldb_eax_i386. + // particular RegisterContext, eax would be included in this RegisterSet by + // adding the value 4. Not by adding the value lldb_eax_i386. }; struct OptionEnumValueElement { @@ -112,7 +112,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. + // |validator->IsValid()|, otherwise always + // valid. OptionEnumValueElement *enum_values; // If non-NULL an array of enum values. uint32_t completion_type; // Cookie the option class can use to do define the // argument completion. diff --git a/include/lldb/lldb-types.h b/include/lldb/lldb-types.h index fc445f55a9e55..79f441569304f 100644 --- a/include/lldb/lldb-types.h +++ b/include/lldb/lldb-types.h @@ -31,8 +31,8 @@ //---------------------------------------------------------------------- // TODO: Add a bunch of ifdefs to determine the host system and what -// things should be defined. Currently MacOSX is being assumed by default -// since that is what lldb was first developed for. +// things should be defined. Currently MacOSX is being assumed by default since +// that is what lldb was first developed for. #ifdef _WIN32 diff --git a/include/lldb/lldb-versioning.h b/include/lldb/lldb-versioning.h index b0af5dc64b47e..9d5fd164119e8 100644 --- a/include/lldb/lldb-versioning.h +++ b/include/lldb/lldb-versioning.h @@ -100,8 +100,8 @@ */ // if you want the version checking to work on other OS/compiler, define -// appropriate IMPL_DEPRECATED/IMPL_TOONEW -// and define LLDB_API_CHECK_VERSIONING_WORKS when you are ready to go live +// appropriate IMPL_DEPRECATED/IMPL_TOONEW and define +// LLDB_API_CHECK_VERSIONING_WORKS when you are ready to go live #if defined(__APPLE__) && defined(__clang__) #define LLDB_API_IMPL_DEPRECATED __attribute__((deprecated)) #define LLDB_API_IMPL_TOONEW __attribute__((unavailable)) diff --git a/include/lldb/module.modulemap b/include/lldb/module.modulemap new file mode 100644 index 0000000000000..cec0428c18400 --- /dev/null +++ b/include/lldb/module.modulemap @@ -0,0 +1,139 @@ + +module lldb_API { + requires cplusplus + + umbrella "API" + module * { export * } +} + +module lldb_Host { + requires cplusplus + + // Because we have OS-specific headers in Host, we just list + // all OS-independent headers here that will include the correct + // OS-specific header for us. + module ConnectionFileDescriptor { header "Host/ConnectionFileDescriptor.h" export * } + module Debug { header "Host/Debug.h" export * } + module Editline { header "Host/Editline.h" export * } + module FileCache { header "Host/FileCache.h" export * } + module File { header "Host/File.h" export * } + module FileSystem { header "Host/FileSystem.h" export * } + module HostGetOpt { header "Host/HostGetOpt.h" export * } + module Host { header "Host/Host.h" export * } + module HostInfoBase { header "Host/HostInfoBase.h" export * } + module HostInfo { header "Host/HostInfo.h" export * } + module HostNativeProcessBase { header "Host/HostNativeProcessBase.h" export * } + module HostNativeProcess { header "Host/HostNativeProcess.h" export * } + module HostNativeThreadBase { header "Host/HostNativeThreadBase.h" export * } + module HostNativeThreadForward { header "Host/HostNativeThreadForward.h" export * } + module HostNativeThread { header "Host/HostNativeThread.h" export * } + module HostProcess { header "Host/HostProcess.h" export * } + module HostThread { header "Host/HostThread.h" export * } + module LockFileBase { header "Host/LockFileBase.h" export * } + module LockFile { header "Host/LockFile.h" export * } + module MainLoopBase { header "Host/MainLoopBase.h" export * } + module MainLoop { header "Host/MainLoop.h" export * } + module MonitoringProcessLauncher { header "Host/MonitoringProcessLauncher.h" export * } + module OptionParser { header "Host/OptionParser.h" export * } + 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 SocketAddress { header "Host/SocketAddress.h" export * } + module Socket { header "Host/Socket.h" export * } + module StringConvert { header "Host/StringConvert.h" export * } + module Symbols { header "Host/Symbols.h" export * } + module TaskPool { header "Host/TaskPool.h" export * } + module Terminal { header "Host/Terminal.h" export * } + module ThreadLauncher { header "Host/ThreadLauncher.h" export * } + module Time { header "Host/Time.h" export * } + module XML { header "Host/XML.h" export * } + + export * +} + +module lldb_Initialization { + requires cplusplus + + umbrella "Initialization" + module * { export * } +} + + +module lldb_Wrapper { + + module lldb_Breakpoint { + requires cplusplus + + umbrella "Breakpoint" + module * { export * } + } + + module lldb_Core { + requires cplusplus + + umbrella "Core" + module * { export * } + } + + module lldb_DataFormatters { + requires cplusplus + + umbrella "DataFormatters" + module * { export * } + } + + module lldb_Expression { + requires cplusplus + + umbrella "Expression" + module * { export * } + // TODO: This file includes a non-public header. + exclude header "Expression/REPL.h" + } + + module lldb_Interpreter { + requires cplusplus + + umbrella "Interpreter" + module * { export * } + } + + module lldb_Symbol { + requires cplusplus + + umbrella "Symbol" + module * { export * } + } + module lldb_Target { + requires cplusplus + + umbrella "Target" + module * { export * } + } +} + + +module lldb_Utility { + requires cplusplus + + umbrella "Utility" + module * { export * } + + module lldb_defines { header "lldb-defines.h" export * } + module lldb_enumerations { header "lldb-enumerations.h" export * } + module lldb_forward { header "lldb-forward.h" export * } + module lldb_private_enumerations { header "lldb-private-enumerations.h" export * } + module lldb_private_defines { header "lldb-private-defines.h" export * } + module lldb_private_forward { header "lldb-private-forward.h" export * } + module lldb_private { header "lldb-private.h" export * } + module lldb_private_interfaces { header "lldb-private-interfaces.h" export * } + module lldb_private_types { header "lldb-private-types.h" export * } + module lldb_public { header "lldb-public.h" export * } + module lldb_types { header "lldb-types.h" export * } + module lldb_versioning { header "lldb-versioning.h" export * } + +} |
